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:
- CompoundLikeWrapper
- Optimization enabled
- true
- Compiler version
- v0.8.14+commit.80d49f37
- Optimization runs
- 1000000
- EVM Version
- london
- Verified at
- 2023-09-05T20:19:57.950262Z
Constructor Arguments
0000000000000000000000006de54724e128274520606f038591a00c5e94a1f60000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd0
Arg [0] (address) : 0x6de54724e128274520606f038591a00c5e94a1f6
Arg [1] (address) : 0x4e8fe8fd314cfc09bdb0942c5adcc37431abdcd0
contracts/wrappers/CompoundLikeWrapper.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.14; pragma abicoder v1; import "../interfaces/IComptroller.sol"; import "../interfaces/IWrapper.sol"; contract CompoundLikeWrapper is IWrapper { IComptroller private immutable _comptroller; IERC20 private constant _BASE = IERC20(0x0000000000000000000000000000000000000000); IERC20 private immutable _cBase; mapping(IERC20 => IERC20) public cTokenToToken; mapping(IERC20 => IERC20) public tokenTocToken; constructor(IComptroller comptroller, IERC20 cBase) { _comptroller = comptroller; _cBase = cBase; } function addMarkets(ICToken[] memory markets) external { unchecked { for (uint256 i = 0; i < markets.length; i++) { (bool isListed, , ) = _comptroller.markets(markets[i]); require(isListed, "Market is not listed"); IERC20 underlying = markets[i].underlying(); cTokenToToken[markets[i]] = underlying; tokenTocToken[underlying] = markets[i]; } } } function removeMarkets(ICToken[] memory markets) external { unchecked { for (uint256 i = 0; i < markets.length; i++) { (bool isListed, , ) = _comptroller.markets(markets[i]); require(!isListed, "Market is listed"); IERC20 underlying = markets[i].underlying(); delete cTokenToToken[markets[i]]; delete tokenTocToken[underlying]; } } } function wrap(IERC20 token) external view override returns (IERC20 wrappedToken, uint256 rate) { if (token == _BASE) { return (_cBase, 1e36 / ICToken(address(_cBase)).exchangeRateStored()); } else if (token == _cBase) { return (_BASE, ICToken(address(_cBase)).exchangeRateStored()); } IERC20 underlying = cTokenToToken[token]; IERC20 cToken = tokenTocToken[token]; if (underlying != IERC20(address(0))) { return (underlying, ICToken(address(token)).exchangeRateStored()); } else if (cToken != IERC20(address(0))) { return (cToken, 1e36 / ICToken(address(cToken)).exchangeRateStored()); } else { revert("Unsupported token"); } } }
/contracts/interfaces/IWrapper.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.14; pragma abicoder v1; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWrapper { function wrap(IERC20 token) external view returns (IERC20 wrappedToken, uint256 rate); }
/contracts/interfaces/IComptroller.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.14; pragma abicoder v1; import "./ICToken.sol"; interface IComptroller { function getAllMarkets() external view returns (ICToken[] memory); function markets(ICToken market) external view returns (bool isListed, uint256 collateralFactorMantissa, bool isComped); }
/contracts/interfaces/ICToken.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.14; pragma abicoder v1; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ICToken is IERC20 { function underlying() external view returns (IERC20 token); function exchangeRateStored() external view returns (uint256 exchangeRate); }
/_openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
Compiler Settings
{"remappings":[],"optimizer":{"runs":1000000,"enabled":true},"metadata":{"useLiteralContent":true,"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london","compilationTarget":{"contracts/wrappers/CompoundLikeWrapper.sol":"CompoundLikeWrapper"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"comptroller","internalType":"contract IComptroller"},{"type":"address","name":"cBase","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMarkets","inputs":[{"type":"address[]","name":"markets","internalType":"contract ICToken[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"cTokenToToken","inputs":[{"type":"address","name":"","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeMarkets","inputs":[{"type":"address[]","name":"markets","internalType":"contract ICToken[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"tokenTocToken","inputs":[{"type":"address","name":"","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"wrappedToken","internalType":"contract IERC20"},{"type":"uint256","name":"rate","internalType":"uint256"}],"name":"wrap","inputs":[{"type":"address","name":"token","internalType":"contract IERC20"}]}]
Contract Creation Code
0x60c060405234801561001057600080fd5b50604051610c9e380380610c9e8339818101604052604081101561003357600080fd5b5080516020909101516001600160a01b039182166080521660a05260805160a051610c0f61008f600039600081816102e501528181610306015281816103ab015261040001526000818161065201526108ab0152610c0f6000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80637d683561116100505780637d6835611461013a578063bfef7bdf1461017d578063da40385d1461022257600080fd5b8063023276f01461006c57806346bfac4a146100cf575b600080fd5b61009f6004803603602081101561008257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102c5565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091528051918290030190f35b610111600480360360208110156100e557600080fd5b506000602081905273ffffffffffffffffffffffffffffffffffffffff91358216815260409020541681565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101116004803603602081101561015057600080fd5b50600160205273ffffffffffffffffffffffffffffffffffffffff90358116600090815260409020541681565b6102206004803603602081101561019357600080fd5b8101906020810181356401000000008111156101ae57600080fd5b8201836020820111156101c057600080fd5b803590602001918460208302840111640100000000831117156101e257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610642945050505050565b005b6102206004803603602081101561023857600080fd5b81019060208101813564010000000081111561025357600080fd5b82018360208201111561026557600080fd5b8035906020019184602083028401116401000000008311171561028757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061089b945050505050565b60008073ffffffffffffffffffffffffffffffffffffffff83166103a9577f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561036f573d6000803e3d6000fd5b505050506040513d602081101561038557600080fd5b50516103a0906ec097ce7bc90715b34b9f1000000000610b6f565b91509150915091565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361048b5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610469573d6000803e3d6000fd5b505050506040513d602081101561047f57600080fd5b50519094909350915050565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260208181526040808320546001909252909120549082169116811561053757818573ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b505190969095509350505050565b73ffffffffffffffffffffffffffffffffffffffff8116156105db57808173ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561059f573d6000803e3d6000fd5b505050506040513d60208110156105b557600080fd5b50516105d0906ec097ce7bc90715b34b9f1000000000610b6f565b935093505050915091565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e737570706f7274656420746f6b656e000000000000000000000000000000604482015290519081900360640190fd5b60005b81518110156108975760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e8f294b84848151811061069e5761069e610baa565b60200260200101516040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050606060405180830381865afa1580156106f5573d6000803e3d6000fd5b505050506040513d606081101561070b57600080fd5b50519050801561077c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4d61726b6574206973206c697374656400000000000000000000000000000000604482015290519081900360640190fd5b600083838151811061079057610790610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107e2573d6000803e3d6000fd5b505050506040513d60208110156107f857600080fd5b50518451909150600090819086908690811061081657610816610baa565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff9081168352828201939093526040918201600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915594909316835260019081905291208054909216909155919091019050610645565b5050565b60005b81518110156108975760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e8f294b8484815181106108f7576108f7610baa565b60200260200101516040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050606060405180830381865afa15801561094e573d6000803e3d6000fd5b505050506040513d606081101561096457600080fd5b50519050806109d457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4d61726b6574206973206e6f74206c6973746564000000000000000000000000604482015290519081900360640190fd5b60008383815181106109e8576109e8610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a3a573d6000803e3d6000fd5b505050506040513d6020811015610a5057600080fd5b5051845190915081906000908190879087908110610a7057610a70610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838381518110610b0257610b02610baa565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff92831660009081526001928390526040902080547fffffffffffffffffffffffff000000000000000000000000000000000000000016939091169290921790915591909101905061089e565b600082610ba5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea2646970667358221220106ce230fdc4d870d38ca8590d946b4a4a8f964a77d32a7dd95284df2a8fe78964736f6c634300080e00330000000000000000000000006de54724e128274520606f038591a00c5e94a1f60000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd0
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100675760003560e01c80637d683561116100505780637d6835611461013a578063bfef7bdf1461017d578063da40385d1461022257600080fd5b8063023276f01461006c57806346bfac4a146100cf575b600080fd5b61009f6004803603602081101561008257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102c5565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091528051918290030190f35b610111600480360360208110156100e557600080fd5b506000602081905273ffffffffffffffffffffffffffffffffffffffff91358216815260409020541681565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101116004803603602081101561015057600080fd5b50600160205273ffffffffffffffffffffffffffffffffffffffff90358116600090815260409020541681565b6102206004803603602081101561019357600080fd5b8101906020810181356401000000008111156101ae57600080fd5b8201836020820111156101c057600080fd5b803590602001918460208302840111640100000000831117156101e257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610642945050505050565b005b6102206004803603602081101561023857600080fd5b81019060208101813564010000000081111561025357600080fd5b82018360208201111561026557600080fd5b8035906020019184602083028401116401000000008311171561028757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061089b945050505050565b60008073ffffffffffffffffffffffffffffffffffffffff83166103a9577f0000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd07f0000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd073ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561036f573d6000803e3d6000fd5b505050506040513d602081101561038557600080fd5b50516103a0906ec097ce7bc90715b34b9f1000000000610b6f565b91509150915091565b7f0000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361048b5760007f0000000000000000000000004e8fe8fd314cfc09bdb0942c5adcc37431abdcd073ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610469573d6000803e3d6000fd5b505050506040513d602081101561047f57600080fd5b50519094909350915050565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260208181526040808320546001909252909120549082169116811561053757818573ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b505190969095509350505050565b73ffffffffffffffffffffffffffffffffffffffff8116156105db57808173ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561059f573d6000803e3d6000fd5b505050506040513d60208110156105b557600080fd5b50516105d0906ec097ce7bc90715b34b9f1000000000610b6f565b935093505050915091565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e737570706f7274656420746f6b656e000000000000000000000000000000604482015290519081900360640190fd5b60005b81518110156108975760007f0000000000000000000000006de54724e128274520606f038591a00c5e94a1f673ffffffffffffffffffffffffffffffffffffffff16638e8f294b84848151811061069e5761069e610baa565b60200260200101516040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050606060405180830381865afa1580156106f5573d6000803e3d6000fd5b505050506040513d606081101561070b57600080fd5b50519050801561077c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4d61726b6574206973206c697374656400000000000000000000000000000000604482015290519081900360640190fd5b600083838151811061079057610790610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107e2573d6000803e3d6000fd5b505050506040513d60208110156107f857600080fd5b50518451909150600090819086908690811061081657610816610baa565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff9081168352828201939093526040918201600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915594909316835260019081905291208054909216909155919091019050610645565b5050565b60005b81518110156108975760007f0000000000000000000000006de54724e128274520606f038591a00c5e94a1f673ffffffffffffffffffffffffffffffffffffffff16638e8f294b8484815181106108f7576108f7610baa565b60200260200101516040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050606060405180830381865afa15801561094e573d6000803e3d6000fd5b505050506040513d606081101561096457600080fd5b50519050806109d457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4d61726b6574206973206e6f74206c6973746564000000000000000000000000604482015290519081900360640190fd5b60008383815181106109e8576109e8610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a3a573d6000803e3d6000fd5b505050506040513d6020811015610a5057600080fd5b5051845190915081906000908190879087908110610a7057610a70610baa565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838381518110610b0257610b02610baa565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff92831660009081526001928390526040902080547fffffffffffffffffffffffff000000000000000000000000000000000000000016939091169290921790915591909101905061089e565b600082610ba5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea2646970667358221220106ce230fdc4d870d38ca8590d946b4a4a8f964a77d32a7dd95284df2a8fe78964736f6c634300080e0033