Contract 0x81cFAE226343B24BA12EC6521Db2C79E7aeeb310 5

Txn Hash Method
Block
From
To
Value [Txn Fee]
0xd4e87f76ecb6694c1674394bed6a6966a44a9ef51070cdd0c0dac10127d48b210x60806040264109812023-02-10 17:40:55118 days 20 hrs ago0x9098b50ee2d9e4c3c69928a691da3b192b4c9673 IN  Create: MockAaveLendingPool0 xDAI0.00079287481
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MockAaveLendingPool

Compiler Version
v0.7.1+commit.f4a555be

Optimization Enabled:
Yes with 9999 runs

Other Settings:
default evmVersion
File 1 of 3 : MockMaliciousQueryReverter.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.7.0;

contract MockMaliciousQueryReverter {
    enum RevertType { DoNotRevert, NonMalicious, MaliciousSwapQuery, MaliciousJoinExitQuery }

    RevertType public revertType = RevertType.DoNotRevert;

    function setRevertType(RevertType newRevertType) external {
        revertType = newRevertType;
    }

    function maybeRevertMaliciously() public view {
        if (revertType == RevertType.NonMalicious) {
            revert("NON_MALICIOUS_REVERT");
        } else if (revertType == RevertType.MaliciousSwapQuery) {
            spoofSwapQueryRevert();
        } else if (revertType == RevertType.MaliciousJoinExitQuery) {
            spoofJoinExitQueryRevert();
        } else {
            // Do nothing
        }
    }

    function spoofJoinExitQueryRevert() public pure {
        uint256[] memory tokenAmounts = new uint256[](2);
        tokenAmounts[0] = 1;
        tokenAmounts[1] = 2;

        uint256 bptAmount = 420;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of
            // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values
            // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32
            let size := mul(mload(tokenAmounts), 32)

            // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there
            // will be at least one available slot due to how the memory scratch space works.
            // We can safely overwrite whatever is stored in this slot as we will revert immediately after that.
            let start := sub(tokenAmounts, 0x20)
            mstore(start, bptAmount)

            // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb
            // We use the previous slot to `bptAmount`.
            mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb)
            start := sub(start, 0x04)

            // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return
            // the `bptAmount`, the array's length, and the error signature.
            revert(start, add(size, 68))
        }
    }

    function spoofSwapQueryRevert() public pure {
        int256[] memory deltas = new int256[](2);
        deltas[0] = 1;
        deltas[1] = 2;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            // We will return a raw representation of the array in memory, which is composed of a 32 byte length,
            // followed by the 32 byte int256 values. Because revert expects a size in bytes, we multiply the array
            // length (stored at `deltas`) by 32.
            let size := mul(mload(deltas), 32)

            // We send one extra value for the error signature "QueryError(int256[])" which is 0xfa61cc12.
            // We store it in the previous slot to the `deltas` array. We know there will be at least one available
            // slot due to how the memory scratch space works.
            // We can safely overwrite whatever is stored in this slot as we will revert immediately after that.
            mstore(sub(deltas, 0x20), 0x00000000000000000000000000000000000000000000000000000000fa61cc12)
            let start := sub(deltas, 0x04)

            // When copying from `deltas` into returndata, we copy an additional 36 bytes to also return the array's
            // length and the error signature.
            revert(start, add(size, 36))
        }
    }
}

File 2 of 3 : MockAaveLendingPool.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.7.0;

import "@orbcollective/shared-dependencies/contracts/MockMaliciousQueryReverter.sol";

import "../interfaces/ILendingPool.sol";

contract MockAaveLendingPool is ILendingPool, MockMaliciousQueryReverter {
    uint256 private _rate = 1e27;

    function getReserveNormalizedIncome(address) external view override returns (uint256) {
        maybeRevertMaliciously();
        return _rate;
    }

    function setReserveNormalizedIncome(uint256 newRate) external {
        _rate = newRate;
    }
}

File 3 of 3 : ILendingPool.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

interface ILendingPool {
    /**
     * @dev returns a 27 decimal fixed point 'ray' value so a rate of 1 is represented as 1e27
     */
    function getReserveNormalizedIncome(address asset) external view returns (uint256);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 9999
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"getReserveNormalizedIncome","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maybeRevertMaliciously","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revertType","outputs":[{"internalType":"enum MockMaliciousQueryReverter.RevertType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRate","type":"uint256"}],"name":"setReserveNormalizedIncome","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum MockMaliciousQueryReverter.RevertType","name":"newRevertType","type":"uint8"}],"name":"setRevertType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spoofJoinExitQueryRevert","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"spoofSwapQueryRevert","outputs":[],"stateMutability":"pure","type":"function"}]

60806040526000805460ff191690556b033b2e3c9fd0803ce800000060015534801561002a57600080fd5b506103ee8061003a6000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80632cd103391161005b5780632cd10339146100b15780637ce3ee48146100d1578063d15e0053146100d9578063d652e8c61461011e5761007d565b8063146d4eee146100825780631bfec0001461008c57806329478cb4146100a9575b600080fd5b61008a610147565b005b61008a600480360360208110156100a257600080fd5b50356101b7565b61008a6101bc565b61008a600480360360208110156100c757600080fd5b503560ff16610285565b61008a6102c4565b61010c600480360360208110156100ef57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661039d565b60408051918252519081900360200190f35b6101266103af565b6040518082600381111561013657fe5b815260200191505060405180910390f35b604080516002808252606080830184529260208301908036833701905050905060018160008151811061017657fe5b60200260200101818152505060028160018151811061019157fe5b602002602001018181525050602081510263fa61cc126020830352600482036024820181fd5b600155565b600160005460ff1660038111156101cf57fe5b141561023c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4e4f4e5f4d414c4943494f55535f524556455254000000000000000000000000604482015290519081900360640190fd5b600260005460ff16600381111561024f57fe5b14156102625761025d610147565b610283565b600360005460ff16600381111561027557fe5b14156102835761025d6102c4565b565b600080548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018360038111156102bc57fe5b021790555050565b60408051600280825260608083018452926020830190803683370190505090506001816000815181106102f357fe5b60200260200101818152505060028160018151811061030e57fe5b60209081029190910181019190915281516101a47fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe084018190526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc085015291027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc83016044820181fd5b60006103a76101bc565b505060015490565b60005460ff168156fea26469706673582212206bb1e128d058b588579bb7671fee74a7915983663ec9bdaf739767d080539cd664736f6c63430007010033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.