Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- CompoundCTokenFilter
- Optimization enabled
- true
- Compiler version
- v0.8.3+commit.8d00100c
- Optimization runs
- 999
- EVM Version
- istanbul
- Verified at
- 2025-12-09T06:45:10.331919Z
Constructor Arguments
000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca
Arg [0] (address) : 0x514910771af9ca656af840dff83e8264ecf986ca
/Users/ovdbigge/argent/contracts5/contracts/infrastructure/dapp/CompoundCTokenFilter.sol
// Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz>
// 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/>.
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.3;
import "./BaseFilter.sol";
contract CompoundCTokenFilter is BaseFilter {
bytes4 private constant CETH_MINT = bytes4(keccak256("mint()"));
bytes4 private constant CERC20_MINT = bytes4(keccak256("mint(uint256)"));
bytes4 private constant CTOKEN_REDEEM = bytes4(keccak256("redeem(uint256)"));
bytes4 private constant CTOKEN_REDEEM_UNDERLYING = bytes4(keccak256("redeemUnderlying(uint256)"));
bytes4 private constant CTOKEN_BORROW = bytes4(keccak256("borrow(uint256)"));
bytes4 private constant CETH_REPAY_BORROW = bytes4(keccak256("repayBorrow()"));
bytes4 private constant CERC20_REPAY_BORROW = bytes4(keccak256("repayBorrow(uint256)"));
bytes4 private constant ERC20_APPROVE = bytes4(keccak256("approve(address,uint256)"));
address public immutable underlying;
constructor (address _underlying) {
underlying = _underlying;
}
function isValid(address /*_wallet*/, address _spender, address _to, bytes calldata _data) external view override returns (bool valid) {
// disable ETH transfer for cErc20
if (_data.length < 4) {
return (_data.length == 0) && (underlying == address(0));
}
bytes4 method = getMethod(_data);
// cToken methods
if (_spender == _to) {
if (underlying == address(0)) {
return (
method == CETH_MINT ||
method == CTOKEN_REDEEM ||
method == CTOKEN_REDEEM_UNDERLYING ||
method == CTOKEN_BORROW ||
method == CETH_REPAY_BORROW);
} else {
return (
method == CERC20_MINT ||
method == CTOKEN_REDEEM ||
method == CTOKEN_REDEEM_UNDERLYING ||
method == CTOKEN_BORROW ||
method == CERC20_REPAY_BORROW);
}
// ERC20 methods
} else {
// only allow an approve on the underlying
return (method == ERC20_APPROVE && underlying == _to);
}
}
}
/contracts/infrastructure/dapp/BaseFilter.sol
// Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz>
// 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/>.
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.3;
import "./IFilter.sol";
abstract contract BaseFilter is IFilter {
function getMethod(bytes memory _data) internal pure returns (bytes4 method) {
// solhint-disable-next-line no-inline-assembly
assembly {
method := mload(add(_data, 0x20))
}
}
}
/contracts/infrastructure/dapp/IFilter.sol
// Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz>
// 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/>.
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.3;
interface IFilter {
function isValid(address _wallet, address _spender, address _to, bytes calldata _data) external view returns (bool valid);
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":999,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"/Users/ovdbigge/argent/contracts5/contracts/infrastructure/dapp/CompoundCTokenFilter.sol":"CompoundCTokenFilter"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_underlying","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"valid","internalType":"bool"}],"name":"isValid","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"_spender","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"underlying","inputs":[]}]
Contract Creation Code
0x60a060405234801561001057600080fd5b506040516104f63803806104f683398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c6104536100a36000396000818160400152818160b801528181610148015261032701526104536000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636f307dc31461003b578063e0274e1d1461007f575b600080fd5b6100627f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61009261008d366004610380565b6100a2565b6040519015158152602001610076565b600060048210156100e957811580156100e257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316155b9050610354565b600061012a84848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061035d92505050565b9050846001600160a01b0316866001600160a01b031614156102e7577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661022e576001600160e01b031981167f1249c58b0000000000000000000000000000000000000000000000000000000014806101bc57506001600160e01b0319811663db006a7560e01b145b806101d757506001600160e01b0319811663852a12e360e01b145b806101f257506001600160e01b0319811663317afabb60e21b145b8061022657506001600160e01b031981167f4e4d9fea00000000000000000000000000000000000000000000000000000000145b915050610354565b6001600160e01b031981167fa0712d6800000000000000000000000000000000000000000000000000000000148061027657506001600160e01b0319811663db006a7560e01b145b8061029157506001600160e01b0319811663852a12e360e01b145b806102ac57506001600160e01b0319811663317afabb60e21b145b8061022657506001600160e01b031981167f0e7527020000000000000000000000000000000000000000000000000000000014915050610354565b6001600160e01b031981167f095ea7b3000000000000000000000000000000000000000000000000000000001480156102265750846001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316149150505b95945050505050565b6020015190565b80356001600160a01b038116811461037b57600080fd5b919050565b600080600080600060808688031215610397578081fd5b6103a086610364565b94506103ae60208701610364565b93506103bc60408701610364565b9250606086013567ffffffffffffffff808211156103d8578283fd5b818801915088601f8301126103eb578283fd5b8135818111156103f9578384fd5b89602082850101111561040a578384fd5b969995985093965060200194939250505056fea264697066735822122017bd58de151996e53a06cadc3e62873e2d03d121b4833566bbd1c13014701eab64736f6c63430008030033000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636f307dc31461003b578063e0274e1d1461007f575b600080fd5b6100627f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca81565b6040516001600160a01b0390911681526020015b60405180910390f35b61009261008d366004610380565b6100a2565b6040519015158152602001610076565b600060048210156100e957811580156100e257507f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316155b9050610354565b600061012a84848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061035d92505050565b9050846001600160a01b0316866001600160a01b031614156102e7577f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b031661022e576001600160e01b031981167f1249c58b0000000000000000000000000000000000000000000000000000000014806101bc57506001600160e01b0319811663db006a7560e01b145b806101d757506001600160e01b0319811663852a12e360e01b145b806101f257506001600160e01b0319811663317afabb60e21b145b8061022657506001600160e01b031981167f4e4d9fea00000000000000000000000000000000000000000000000000000000145b915050610354565b6001600160e01b031981167fa0712d6800000000000000000000000000000000000000000000000000000000148061027657506001600160e01b0319811663db006a7560e01b145b8061029157506001600160e01b0319811663852a12e360e01b145b806102ac57506001600160e01b0319811663317afabb60e21b145b8061022657506001600160e01b031981167f0e7527020000000000000000000000000000000000000000000000000000000014915050610354565b6001600160e01b031981167f095ea7b3000000000000000000000000000000000000000000000000000000001480156102265750846001600160a01b03167f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316149150505b95945050505050565b6020015190565b80356001600160a01b038116811461037b57600080fd5b919050565b600080600080600060808688031215610397578081fd5b6103a086610364565b94506103ae60208701610364565b93506103bc60408701610364565b9250606086013567ffffffffffffffff808211156103d8578283fd5b818801915088601f8301126103eb578283fd5b8135818111156103f9578384fd5b89602082850101111561040a578384fd5b969995985093965060200194939250505056fea264697066735822122017bd58de151996e53a06cadc3e62873e2d03d121b4833566bbd1c13014701eab64736f6c63430008030033