More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
CurveAdapter
Compiler Version
v0.6.9+commit.3e3065ac
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2021-08-20 */ // File: contracts/SmartRoute/intf/IDODOAdapter.sol /* Copyright 2020 DODO ZOO. SPDX-License-Identifier: Apache-2.0 */ pragma solidity 0.6.9; interface IDODOAdapter { function sellBase(address to, address pool, bytes memory data) external; function sellQuote(address to, address pool, bytes memory data) external; } // File: contracts/SmartRoute/intf/ICurve.sol interface ICurve { // solium-disable-next-line mixedcase function get_dy_underlying(int128 i, int128 j, uint256 dx) external view returns(uint256 dy); // solium-disable-next-line mixedcase function get_dy(int128 i, int128 j, uint256 dx) external view returns(uint256 dy); // solium-disable-next-line mixedcase function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 minDy) external; // solium-disable-next-line mixedcase function exchange(int128 i, int128 j, uint256 dx, uint256 minDy) external; // view coins address function underlying_coins(int128 arg0) external view returns(address out); function coins(int128 arg0) external view returns(address out); } // File: contracts/intf/IERC20.sol /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); } // File: contracts/lib/SafeMath.sol /** * @title SafeMath * @author DODO Breeder * * @notice Math operations with safety checks that revert on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "MUL_ERROR"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "DIVIDING_ERROR"); return a / b; } function divCeil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 quotient = div(a, b); uint256 remainder = a - quotient * b; if (remainder > 0) { return quotient + 1; } else { return quotient; } } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SUB_ERROR"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "ADD_ERROR"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = x / 2 + 1; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } // File: contracts/lib/SafeERC20.sol /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn( token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value) ); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/SmartRoute/lib/UniversalERC20.sol library UniversalERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); function universalTransfer( IERC20 token, address payable to, uint256 amount ) internal { if (amount > 0) { if (isETH(token)) { to.transfer(amount); } else { token.safeTransfer(to, amount); } } } function universalApproveMax( IERC20 token, address to, uint256 amount ) internal { uint256 allowance = token.allowance(address(this), to); if (allowance < amount) { if (allowance > 0) { token.safeApprove(to, 0); } token.safeApprove(to, uint256(-1)); } } function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) { if (isETH(token)) { return who.balance; } else { return token.balanceOf(who); } } function tokenBalanceOf(IERC20 token, address who) internal view returns (uint256) { return token.balanceOf(who); } function isETH(IERC20 token) internal pure returns (bool) { return token == ETH_ADDRESS; } } // File: contracts/SmartRoute/adapter/CurveAdapter.sol // for two tokens; to adapter like dodo V1 contract CurveAdapter is IDODOAdapter { using SafeMath for uint; using UniversalERC20 for IERC20; function _curveSwap(address to, address pool, bytes memory moreInfo) internal { (bool noLending, address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (bool, address, address, int128, int128)); uint256 sellAmount = IERC20(fromToken).balanceOf(address(this)); // approve IERC20(fromToken).universalApproveMax(pool, sellAmount); // swap if(noLending == true) { ICurve(pool).exchange(i, j, sellAmount, 0); } else if(noLending == false) { ICurve(pool).exchange_underlying(i, j, sellAmount, 0); } if(to != address(this)) { SafeERC20.safeTransfer(IERC20(toToken), to, IERC20(toToken).balanceOf(address(this))); } } function sellBase(address to, address pool, bytes memory moreInfo) external override { _curveSwap(to, pool, moreInfo); } function sellQuote(address to, address pool, bytes memory moreInfo) external override { _curveSwap(to, pool, moreInfo); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"moreInfo","type":"bytes"}],"name":"sellBase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"moreInfo","type":"bytes"}],"name":"sellQuote","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506107a6806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806330e6ae311461003b5780636f7929f21461003b575b600080fd5b6100fa6004803603606081101561005157600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561008557600080fd5b82018360208201111561009757600080fd5b803590602001918460018302840111640100000000831117156100b957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506100fc945050505050565b005b61010783838361010c565b505050565b60008060008060008580602001905160a081101561012957600080fd5b508051602080830151604080850151606086015160809096015182516370a0823160e01b81523060048201529251959b50929950975093955093506000926001600160a01b038816926370a0823192602480840193919291829003018186803b15801561019557600080fd5b505afa1580156101a9573d6000803e3d6000fd5b505050506040513d60208110156101bf57600080fd5b505190506101dd6001600160a01b038616898363ffffffff61039016565b600186151514156102685760408051630f7c084960e21b8152600f85810b810b600483015284810b900b60248201526044810183905260006064820181905291516001600160a01b038b1692633df02124926084808201939182900301818387803b15801561024b57600080fd5b505af115801561025f573d6000803e3d6000fd5b505050506102e9565b856102e95760408051635320bf6b60e11b8152600f85810b810b600483015284810b900b60248201526044810183905260006064820181905291516001600160a01b038b169263a6417ed6926084808201939182900301818387803b1580156102d057600080fd5b505af11580156102e4573d6000803e3d6000fd5b505050505b6001600160a01b038916301461038557610385848a866001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561035457600080fd5b505afa158015610368573d6000803e3d6000fd5b505050506040513d602081101561037e57600080fd5b505161045a565b505050505050505050565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b1580156103e157600080fd5b505afa1580156103f5573d6000803e3d6000fd5b505050506040513d602081101561040b57600080fd5b5051905081811015610454578015610438576104386001600160a01b03851684600063ffffffff6104ac16565b6104546001600160a01b0385168460001963ffffffff6104ac16565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526101079084906105bb565b801580610532575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561050457600080fd5b505afa158015610518573d6000803e3d6000fd5b505050506040513d602081101561052e57600080fd5b5051155b61056d5760405162461bcd60e51b815260040180806020018281038252603681526020018061073b6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526101079084905b60006060836001600160a01b0316836040518082805190602001908083835b602083106105f95780518252601f1990920191602091820191016105da565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461065b576040519150601f19603f3d011682016040523d82523d6000602084013e610660565b606091505b5091509150816106b7576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610454578080602001905160208110156106d357600080fd5b50516104545760405162461bcd60e51b815260040180806020018281038252602a815260200180610711602a913960400191505060405180910390fdfe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220c59c1198cd7af47e1f2e440b3b7d6fef745b84024aaa739ab851e0ff51be522a64736f6c63430006090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c806330e6ae311461003b5780636f7929f21461003b575b600080fd5b6100fa6004803603606081101561005157600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561008557600080fd5b82018360208201111561009757600080fd5b803590602001918460018302840111640100000000831117156100b957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506100fc945050505050565b005b61010783838361010c565b505050565b60008060008060008580602001905160a081101561012957600080fd5b508051602080830151604080850151606086015160809096015182516370a0823160e01b81523060048201529251959b50929950975093955093506000926001600160a01b038816926370a0823192602480840193919291829003018186803b15801561019557600080fd5b505afa1580156101a9573d6000803e3d6000fd5b505050506040513d60208110156101bf57600080fd5b505190506101dd6001600160a01b038616898363ffffffff61039016565b600186151514156102685760408051630f7c084960e21b8152600f85810b810b600483015284810b900b60248201526044810183905260006064820181905291516001600160a01b038b1692633df02124926084808201939182900301818387803b15801561024b57600080fd5b505af115801561025f573d6000803e3d6000fd5b505050506102e9565b856102e95760408051635320bf6b60e11b8152600f85810b810b600483015284810b900b60248201526044810183905260006064820181905291516001600160a01b038b169263a6417ed6926084808201939182900301818387803b1580156102d057600080fd5b505af11580156102e4573d6000803e3d6000fd5b505050505b6001600160a01b038916301461038557610385848a866001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561035457600080fd5b505afa158015610368573d6000803e3d6000fd5b505050506040513d602081101561037e57600080fd5b505161045a565b505050505050505050565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b1580156103e157600080fd5b505afa1580156103f5573d6000803e3d6000fd5b505050506040513d602081101561040b57600080fd5b5051905081811015610454578015610438576104386001600160a01b03851684600063ffffffff6104ac16565b6104546001600160a01b0385168460001963ffffffff6104ac16565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526101079084906105bb565b801580610532575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561050457600080fd5b505afa158015610518573d6000803e3d6000fd5b505050506040513d602081101561052e57600080fd5b5051155b61056d5760405162461bcd60e51b815260040180806020018281038252603681526020018061073b6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526101079084905b60006060836001600160a01b0316836040518082805190602001908083835b602083106105f95780518252601f1990920191602091820191016105da565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461065b576040519150601f19603f3d011682016040523d82523d6000602084013e610660565b606091505b5091509150816106b7576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610454578080602001905160208110156106d357600080fd5b50516104545760405162461bcd60e51b815260040180806020018281038252602a815260200180610711602a913960400191505060405180910390fdfe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220c59c1198cd7af47e1f2e440b3b7d6fef745b84024aaa739ab851e0ff51be522a64736f6c63430006090033
Deployed Bytecode Sourcemap
9816:1181:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10717:134;;;;;;;;;;;;;;;;-1:-1:-1;;;;;10717:134:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10717:134:0;;-1:-1:-1;10717:134:0;;-1:-1:-1;;;;;10717:134:0:i;:::-;;;10813:30;10824:2;10828:4;10834:8;10813:10;:30::i;:::-;10717:134;;;:::o;9931:778::-;10021:14;10037:17;10056:15;10073:8;10083;10106;10095:62;;;;;;;;;;;;;;;-1:-1:-1;10095:62:0;;;;;;;;;;;;;;;;;;;;;10189:42;;-1:-1:-1;;;10189:42:0;;10225:4;10189:42;;;;;;10095:62;;-1:-1:-1;10095:62:0;;-1:-1:-1;10095:62:0;-1:-1:-1;10095:62:0;;-1:-1:-1;10095:62:0;-1:-1:-1;10168:18:0;;-1:-1:-1;;;;;10189:27:0;;;;;:42;;;;;10095:62;;10189:42;;;;;;:27;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10189:42:0;;-1:-1:-1;10264:55:0;-1:-1:-1;;;;;10264:37:0;;10302:4;10189:42;10264:55;:37;:55;:::i;:::-;10363:4;10350:17;;;;10347:209;;;10384:42;;;-1:-1:-1;;;10384:42:0;;;;;;;;;;;;;;;;;;;;;;;;;;;10424:1;10384:42;;;;;;;;-1:-1:-1;;;;;10384:21:0;;;;;:42;;;;;;;;;;;10424:1;10384:21;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10347:209;;;10456:18;10453:103;;10491:53;;;-1:-1:-1;;;10491:53:0;;;;;;;;;;;;;;;;;;;;;;;;;;;10542:1;10491:53;;;;;;;;-1:-1:-1;;;;;10491:32:0;;;;;:53;;;;;;;;;;;10542:1;10491:32;:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10453:103;-1:-1:-1;;;;;10569:19:0;;10583:4;10569:19;10566:136;;10605:85;10635:7;10645:2;10656:7;-1:-1:-1;;;;;10649:25:0;;10683:4;10649:40;;;;;;;;;;;;;-1:-1:-1;;;;;10649:40:0;-1:-1:-1;;;;;10649:40:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10649:40:0;10605:22;:85::i;:::-;9931:778;;;;;;;;;:::o;8832:374::-;8977:34;;;-1:-1:-1;;;8977:34:0;;9001:4;8977:34;;;;-1:-1:-1;;;;;8977:34:0;;;;;;;;;8957:17;;8977:15;;;;;:34;;;;;;;;;;;;;;:15;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8977:34:0;;-1:-1:-1;9026:18:0;;;9022:177;;;9065:13;;9061:78;;9099:24;-1:-1:-1;;;;;9099:17:0;;9117:2;9121:1;9099:24;:17;:24;:::i;:::-;9153:34;-1:-1:-1;;;;;9153:17:0;;9171:2;-1:-1:-1;;9153:34:0;:17;:34;:::i;:::-;8832:374;;;;:::o;5614:211::-;5758:58;;;-1:-1:-1;;;;;5758:58:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5758:58:0;-1:-1:-1;;;5758:58:0;;;5731:86;;5751:5;;5731:19;:86::i;6126:670::-;6544:10;;;6543:62;;-1:-1:-1;6560:39:0;;;-1:-1:-1;;;6560:39:0;;6584:4;6560:39;;;;-1:-1:-1;;;;;6560:39:0;;;;;;;;;:15;;;;;;:39;;;;;;;;;;;;;;;:15;:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6560:39:0;:44;6543:62;6521:166;;;;-1:-1:-1;;;6521:166:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6725:62;;;-1:-1:-1;;;;;6725:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;6725:62:0;-1:-1:-1;;;6725:62:0;;;6698:90;;6718:5;;7187:1046;7847:12;7861:23;7896:5;-1:-1:-1;;;;;7888:19:0;7908:4;7888:25;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;7888:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7846:67;;;;7932:7;7924:52;;;;;-1:-1:-1;;;7924:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7993:17;;:21;7989:237;;8148:10;8137:30;;;;;;;;;;;;;;;-1:-1:-1;8137:30:0;8129:85;;;;-1:-1:-1;;;8129:85:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Swarm Source
ipfs://c59c1198cd7af47e1f2e440b3b7d6fef745b84024aaa739ab851e0ff51be522a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
POL | 100.00% | $0.452435 | 0.0001 | $0.000045 |
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.