Skip to content
Verified contractExactSEL-1.0

AaveV4DecoderAndSanitizer

Address0x8838a3580428423e856bd9beae7fc5a1b170c79d
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.21

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.21+commit.d9974bed
Language
solidity
Optimization
Yes, 200 runs
EVM version
shanghai
License
SEL-1.0
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,353,374
Creation transaction
0xb033b3772a…2084db9ece

src/base/DecodersAndSanitizers/Protocols/AaveV4DecoderAndSanitizer.sol

// SPDX-License-Identifier: SEL-1.0
// Copyright © 2025 Veda Tech Labs
// Derived from Boring Vault Software © 2025 Veda Tech Labs (TEST ONLY – NO COMMERCIAL USE)
// Licensed under Software Evaluation License, Version 1.0
// Last audited: boring-vault-fixes@6ef21c4c54140a9ea00f3ffbcb9850d28db19854 — file:audit/0xmacro-veda-95.pdf
pragma solidity 0.8.21;

contract AaveV4DecoderAndSanitizer {
    //============================== ERRORS ===============================

    error AaveV4DecoderAndSanitizer__InvalidReserveId();

    //============================== AAVEV4 ===============================
    // Aave V4 spokes identify reserves with a per-spoke uint256 reserveId instead of the
    // underlying asset address. The reserveId is cast to an address and packed into
    // addressesFound so each merkle leaf pins the exact (spoke, reserveId) pair; reserveIds
    // that do not fit in 160 bits are rejected so the cast cannot alias two ids onto one leaf.
    // Withdraw and borrow always send funds to msg.sender (the vault); onBehalfOf is the
    // position owner being debited/credited. SECURITY: every reserve function packs onBehalfOf
    // into addressesFound, so the merkle leaf MUST pin it to the vault. This argument governs whose
    // position is touched and, for withdraw/borrow, coincides with the account whose funds move; a
    // leaf that left it unpinned (or pinned to a non-vault address) would let value leave the vault.
    // Aave V4 has no onchain rewards controller (incentives accrue offchain), so unlike the V3
    // decoder there is no claim function to decode.

    function supply(
        uint256 reserveId,
        uint256,
        /*amount*/
        address onBehalfOf
    )
        external
        pure
        virtual
        returns (bytes memory addressesFound)
    {
        addressesFound = abi.encodePacked(_sanitizeReserveId(reserveId), onBehalfOf);
    }

    function withdraw(
        uint256 reserveId,
        uint256,
        /*amount*/
        address onBehalfOf
    )
        external
        pure
        virtual
        returns (bytes memory addressesFound)
    {
        addressesFound = abi.encodePacked(_sanitizeReserveId(reserveId), onBehalfOf);
    }

    function borrow(
        uint256 reserveId,
        uint256,
        /*amount*/
        address onBehalfOf
    )
        external
        pure
        virtual
        returns (bytes memory addressesFound)
    {
        addressesFound = abi.encodePacked(_sanitizeReserveId(reserveId), onBehalfOf);
    }

    function repay(
        uint256 reserveId,
        uint256,
        /*amount*/
        address onBehalfOf
    )
        external
        pure
        virtual
        returns (bytes memory addressesFound)
    {
        addressesFound = abi.encodePacked(_sanitizeReserveId(reserveId), onBehalfOf);
    }

    function setUsingAsCollateral(
        uint256 reserveId,
        bool,
        /*usingAsCollateral*/
        address onBehalfOf
    )
        external
        pure
        virtual
        returns (bytes memory addressesFound)
    {
        addressesFound = abi.encodePacked(_sanitizeReserveId(reserveId), onBehalfOf);
    }

    function updateUserRiskPremium(address onBehalfOf) external pure virtual returns (bytes memory addressesFound) {
        addressesFound = abi.encodePacked(onBehalfOf);
    }

    function updateUserDynamicConfig(address onBehalfOf) external pure virtual returns (bytes memory addressesFound) {
        addressesFound = abi.encodePacked(onBehalfOf);
    }

    // NOTE: setUserPositionManager(address,bool) is deliberately NOT decodable. An approved
    // position manager can call withdraw/borrow with onBehalfOf = vault and receives the funds
    // itself (V4 pays msg.sender), bypassing merkle verification entirely. Add it only with a
    // dedicated helper, test coverage, and the approve flag pinned.

    function _sanitizeReserveId(uint256 reserveId) internal pure returns (address) {
        if (reserveId > type(uint160).max) revert AaveV4DecoderAndSanitizer__InvalidReserveId();
        return address(uint160(reserveId));
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": [
    "@solmate/=lib/solmate/src/",
    "@forge-std/=lib/forge-std/src/",
    "@ds-test/=lib/forge-std/lib/ds-test/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@ccip/=lib/ccip/",
    "@oapp-auth/=lib/OAppAuth/src/",
    "lib/OAppAuth/lib/LayerZero-V2/:forge-std/=lib/OAppAuth/lib/LayerZero-V2/lib/forge-std/src/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/lib/LayerZero-V2/:forge-std/=lib/OAppAuth/lib/LayerZero-V2/lib/forge-std/src/",
    "lib/OAppAuth/lib/openzeppelin-contracts/:erc4626-tests/=lib/OAppAuth/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/lib/openzeppelin-contracts/:erc4626-tests/=lib/OAppAuth/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/OAppAuth/lib/openzeppelin-contracts/:forge-std/=lib/OAppAuth/lib/openzeppelin-contracts/lib/forge-std/src/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/lib/openzeppelin-contracts/:forge-std/=lib/OAppAuth/lib/openzeppelin-contracts/lib/forge-std/src/",
    "lib/OAppAuth/:solidity-bytes-utils/=lib/OAppAuth/node_modules/solidity-bytes-utils/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/:solidity-bytes-utils/=lib/OAppAuth/node_modules/solidity-bytes-utils/",
    "lib/OAppAuth/:forge-std/=lib/OAppAuth/lib/forge-std/src/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/:forge-std/=lib/OAppAuth/lib/forge-std/src/",
    "lib/OAppAuth/:openzeppelin-contracts/=lib/OAppAuth/lib/openzeppelin-contracts/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/:openzeppelin-contracts/=lib/OAppAuth/lib/openzeppelin-contracts/",
    "lib/OAppAuth/:solmate/=lib/OAppAuth/lib/solmate/src/",
    "/private/tmp/scops1259/bv/lib/OAppAuth/:solmate/=lib/OAppAuth/lib/solmate/src/",
    "lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "/private/tmp/scops1259/bv/lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-contracts/:forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/",
    "/private/tmp/scops1259/bv/lib/openzeppelin-contracts/:forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/",
    "@devtools-oapp-evm/=lib/OAppAuth/lib/devtools/packages/oapp-evm/contracts/oapp/",
    "@layerzerolabs/lz-evm-messagelib-v2/=lib/OAppAuth/node_modules/@layerzerolabs/lz-evm-messagelib-v2/",
    "@layerzerolabs/lz-evm-protocol-v2/=lib/OAppAuth/lib/LayerZero-V2/packages/layerzero-v2/evm/protocol/",
    "@layerzerolabs/oapp-evm/=lib/OAppAuth/lib/devtools/packages/oapp-evm/",
    "@lz-oapp-evm/=lib/OAppAuth/lib/LayerZero-V2/packages/layerzero-v2/evm/oapp/contracts/oapp/",
    "@sbu/=lib/OAppAuth/lib/solidity-bytes-utils/",
    "LayerZero-V2/=lib/OAppAuth/lib/",
    "OAppAuth/=lib/OAppAuth/",
    "ccip/=lib/ccip/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/OAppAuth/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solidity-bytes-utils/=lib/OAppAuth/node_modules/solidity-bytes-utils/",
    "solmate/=lib/solmate/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.