More Info
Private Name Tags
ContractCreator
Latest 5 from a total of 5 transactions
Loading...
Loading
Contract Name:
UniAdapter
Compiler Version
v0.6.9+commit.3e3065ac
Contract Source Code (Solidity)
/** *Submitted for verification at BscScan.com on 2022-01-05 */ // 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/IUni.sol interface IUni { function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function token0() external view returns (address); function token1() external view returns (address); } // 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/SmartRoute/adapter/UniAdapter.sol contract UniAdapter is IDODOAdapter { using SafeMath for uint; //fromToken == token0 function sellBase(address to, address pool, bytes memory data) external override { address baseToken = IUni(pool).token0(); (uint reserveIn, uint reserveOut,) = IUni(pool).getReserves(); uint receiveQuoteAmount; { (uint256 fee, uint256 denFee) = abi.decode(data, (uint256, uint256)); require(reserveIn > 0 && reserveOut > 0, 'UniAdapter: INSUFFICIENT_LIQUIDITY'); uint balance0 = IERC20(baseToken).balanceOf(pool); uint sellBaseAmount = balance0 - reserveIn; uint sellBaseAmountWithFee = sellBaseAmount.mul(denFee - fee); uint numerator = sellBaseAmountWithFee.mul(reserveOut); uint denominator = reserveIn.mul(denFee).add(sellBaseAmountWithFee); receiveQuoteAmount = numerator / denominator; } IUni(pool).swap(0, receiveQuoteAmount, to, new bytes(0)); } //fromToken == token1 function sellQuote(address to, address pool, bytes memory data) external override { address quoteToken = IUni(pool).token1(); (uint reserveOut, uint reserveIn,) = IUni(pool).getReserves(); uint receiveBaseAmount; { (uint256 fee, uint256 denFee) = abi.decode(data, (uint256, uint256)); require(reserveIn > 0 && reserveOut > 0, 'UniAdapter: INSUFFICIENT_LIQUIDITY'); uint balance1 = IERC20(quoteToken).balanceOf(pool); uint sellQuoteAmount = balance1 - reserveIn; uint sellQuoteAmountWithFee = sellQuoteAmount.mul(denFee - fee); uint numerator = sellQuoteAmountWithFee.mul(reserveOut); uint denominator = reserveIn.mul(denFee).add(sellQuoteAmountWithFee); receiveBaseAmount = numerator / denominator; } IUni(pool).swap(receiveBaseAmount, 0, to, new bytes(0)); } }
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":"data","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":"data","type":"bytes"}],"name":"sellQuote","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506108b3806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806330e6ae311461003b5780636f7929f2146100fc575b600080fd5b6100fa6004803603606081101561005157600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561008557600080fd5b82018360208201111561009757600080fd5b803590602001918460018302840111640100000000831117156100b957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101bb945050505050565b005b6100fa6004803603606081101561011257600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561014657600080fd5b82018360208201111561015857600080fd5b8035906020019184600183028401116401000000008311171561017a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610542945050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156101f657600080fd5b505afa15801561020a573d6000803e3d6000fd5b505050506040513d602081101561022057600080fd5b505160408051630240bc6b60e21b8152905191925060009182916001600160a01b03871691630902f1ac91600480820192606092909190829003018186803b15801561026b57600080fd5b505afa15801561027f573d6000803e3d6000fd5b505050506040513d606081101561029557600080fd5b50805160209182015186516001600160701b039283169550911692506000918291829188019060408110156102c957600080fd5b508051602090910151909250905084158015906102e65750600084115b6103215760405162461bcd60e51b815260040180806020018281038252602281526020018061085c6022913960400191505060405180910390fd5b6000866001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561037957600080fd5b505afa15801561038d573d6000803e3d6000fd5b505050506040513d60208110156103a357600080fd5b5051905085810360006103be8286860363ffffffff6107b116565b905060006103d2828963ffffffff6107b116565b905060006103f6836103ea8c8963ffffffff6107b116565b9063ffffffff61081516565b905080828161040157fe5b04975050505050505050856001600160a01b031663022c0d9f6000838a600067ffffffffffffffff8111801561043657600080fd5b506040519080825280601f01601f191660200182016040528015610461576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156104d25781810151838201526020016104ba565b50505050905090810190601f1680156104ff5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561052157600080fd5b505af1158015610535573d6000803e3d6000fd5b5050505050505050505050565b6000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561057d57600080fd5b505afa158015610591573d6000803e3d6000fd5b505050506040513d60208110156105a757600080fd5b505160408051630240bc6b60e21b8152905191925060009182916001600160a01b03871691630902f1ac91600480820192606092909190829003018186803b1580156105f257600080fd5b505afa158015610606573d6000803e3d6000fd5b505050506040513d606081101561061c57600080fd5b50805160209182015186516001600160701b0392831695509116925060009182918291880190604081101561065057600080fd5b5080516020909101519092509050831580159061066d5750600085115b6106a85760405162461bcd60e51b815260040180806020018281038252602281526020018061085c6022913960400191505060405180910390fd5b6000866001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561070057600080fd5b505afa158015610714573d6000803e3d6000fd5b505050506040513d602081101561072a57600080fd5b5051905084810360006107458286860363ffffffff6107b116565b90506000610759828a63ffffffff6107b116565b90506000610771836103ea8b8963ffffffff6107b116565b905080828161077c57fe5b04975050505050505050856001600160a01b031663022c0d9f8260008a600067ffffffffffffffff8111801561043657600080fd5b6000826107c05750600061080f565b828202828482816107cd57fe5b041461080c576040805162461bcd60e51b815260206004820152600960248201526826aaa62fa2a92927a960b91b604482015290519081900360640190fd5b90505b92915050565b60008282018381101561080c576040805162461bcd60e51b815260206004820152600960248201526820a2222fa2a92927a960b91b604482015290519081900360640190fdfe556e69416461707465723a20494e53554646494349454e545f4c4951554944495459a264697066735822122066f20386f482a412e7f0bcfb64531b5137d12362e8f9a2d92ea9b9de97f3af0164736f6c63430006090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c806330e6ae311461003b5780636f7929f2146100fc575b600080fd5b6100fa6004803603606081101561005157600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561008557600080fd5b82018360208201111561009757600080fd5b803590602001918460018302840111640100000000831117156100b957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101bb945050505050565b005b6100fa6004803603606081101561011257600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561014657600080fd5b82018360208201111561015857600080fd5b8035906020019184600183028401116401000000008311171561017a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610542945050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156101f657600080fd5b505afa15801561020a573d6000803e3d6000fd5b505050506040513d602081101561022057600080fd5b505160408051630240bc6b60e21b8152905191925060009182916001600160a01b03871691630902f1ac91600480820192606092909190829003018186803b15801561026b57600080fd5b505afa15801561027f573d6000803e3d6000fd5b505050506040513d606081101561029557600080fd5b50805160209182015186516001600160701b039283169550911692506000918291829188019060408110156102c957600080fd5b508051602090910151909250905084158015906102e65750600084115b6103215760405162461bcd60e51b815260040180806020018281038252602281526020018061085c6022913960400191505060405180910390fd5b6000866001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561037957600080fd5b505afa15801561038d573d6000803e3d6000fd5b505050506040513d60208110156103a357600080fd5b5051905085810360006103be8286860363ffffffff6107b116565b905060006103d2828963ffffffff6107b116565b905060006103f6836103ea8c8963ffffffff6107b116565b9063ffffffff61081516565b905080828161040157fe5b04975050505050505050856001600160a01b031663022c0d9f6000838a600067ffffffffffffffff8111801561043657600080fd5b506040519080825280601f01601f191660200182016040528015610461576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156104d25781810151838201526020016104ba565b50505050905090810190601f1680156104ff5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561052157600080fd5b505af1158015610535573d6000803e3d6000fd5b5050505050505050505050565b6000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561057d57600080fd5b505afa158015610591573d6000803e3d6000fd5b505050506040513d60208110156105a757600080fd5b505160408051630240bc6b60e21b8152905191925060009182916001600160a01b03871691630902f1ac91600480820192606092909190829003018186803b1580156105f257600080fd5b505afa158015610606573d6000803e3d6000fd5b505050506040513d606081101561061c57600080fd5b50805160209182015186516001600160701b0392831695509116925060009182918291880190604081101561065057600080fd5b5080516020909101519092509050831580159061066d5750600085115b6106a85760405162461bcd60e51b815260040180806020018281038252602281526020018061085c6022913960400191505060405180910390fd5b6000866001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561070057600080fd5b505afa158015610714573d6000803e3d6000fd5b505050506040513d602081101561072a57600080fd5b5051905084810360006107458286860363ffffffff6107b116565b90506000610759828a63ffffffff6107b116565b90506000610771836103ea8b8963ffffffff6107b116565b905080828161077c57fe5b04975050505050505050856001600160a01b031663022c0d9f8260008a600067ffffffffffffffff8111801561043657600080fd5b6000826107c05750600061080f565b828202828482816107cd57fe5b041461080c576040805162461bcd60e51b815260206004820152600960248201526826aaa62fa2a92927a960b91b604482015290519081900360640190fd5b90505b92915050565b60008282018381101561080c576040805162461bcd60e51b815260206004820152600960248201526820a2222fa2a92927a960b91b604482015290519081900360640190fdfe556e69416461707465723a20494e53554646494349454e545f4c4951554944495459a264697066735822122066f20386f482a412e7f0bcfb64531b5137d12362e8f9a2d92ea9b9de97f3af0164736f6c63430006090033
Deployed Bytecode Sourcemap
4942:1931:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5044:897;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5044:897:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5044:897:0;;-1:-1:-1;5044:897:0;;-1:-1:-1;;;;;5044:897:0:i;:::-;;5976:894;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5976:894:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5976:894:0;;-1:-1:-1;5976:894:0;;-1:-1:-1;;;;;5976:894:0:i;5044:897::-;5136:17;5161:4;-1:-1:-1;;;;;5156:17:0;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5156:19:0;5223:24;;;-1:-1:-1;;;5223:24:0;;;;5156:19;;-1:-1:-1;5187:14:0;;;;-1:-1:-1;;;;;5223:22:0;;;;;:24;;;;;;;;;;;;;;;:22;:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5223:24:0;;;;;;;5335:36;;-1:-1:-1;;;;;5186:61:0;;;;-1:-1:-1;5186:61:0;;;-1:-1:-1;5258:23:0;;;;;;5335:36;;;5223:24;5335:36;;;;;;;;;-1:-1:-1;5335:36:0;;;;;;;;;-1:-1:-1;5335:36:0;-1:-1:-1;5390:13:0;;;;;:31;;;5420:1;5407:10;:14;5390:31;5382:78;;;;-1:-1:-1;;;5382:78:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5473:13;5496:9;-1:-1:-1;;;;;5489:27:0;;5517:4;5489:33;;;;;;;;;;;;;-1:-1:-1;;;;;5489:33:0;-1:-1:-1;;;;;5489:33:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5489:33:0;;-1:-1:-1;5555:20:0;;;5533:19;5625:32;5555:20;5644:12;;;5625:32;:18;:32;:::i;:::-;5596:61;-1:-1:-1;5668:14:0;5685:37;5596:61;5711:10;5685:37;:25;:37;:::i;:::-;5668:54;-1:-1:-1;5733:16:0;5752:48;5778:21;5752;:9;5766:6;5752:21;:13;:21;:::i;:::-;:25;:48;:25;:48;:::i;:::-;5733:67;;5844:11;5832:9;:23;;;;;;5811:44;;5044:897;;;;;;;5882:4;-1:-1:-1;;;;;5877:15:0;;5893:1;5896:18;5916:2;5930:1;5920:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5920:12:0;;5877:56;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5877:56:0;-1:-1:-1;;;;;5877:56:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5044:897;;;;;;;:::o;5976:894::-;6069:18;6095:4;-1:-1:-1;;;;;6090:17:0;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6090:19:0;6157:24;;;-1:-1:-1;;;6157:24:0;;;;6090:19;;-1:-1:-1;6121:15:0;;;;-1:-1:-1;;;;;6157:22:0;;;;;:24;;;;;;;;;;;;;;;:22;:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6157:24:0;;;;;;;6268:36;;-1:-1:-1;;;;;6120:61:0;;;;-1:-1:-1;6120:61:0;;;-1:-1:-1;6192:22:0;;;;;;6268:36;;;6157:24;6268:36;;;;;;;;;-1:-1:-1;6268:36:0;;;;;;;;;-1:-1:-1;6268:36:0;-1:-1:-1;6323:13:0;;;;;:31;;;6353:1;6340:10;:14;6323:31;6315:78;;;;-1:-1:-1;;;6315:78:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6406:13;6429:10;-1:-1:-1;;;;;6422:28:0;;6451:4;6422:34;;;;;;;;;;;;;-1:-1:-1;;;;;6422:34:0;-1:-1:-1;;;;;6422:34:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6422:34:0;;-1:-1:-1;6490:20:0;;;6467;6553:33;6490:20;6573:12;;;6553:33;:19;:33;:::i;:::-;6523:63;-1:-1:-1;6597:14:0;6614:38;6523:63;6641:10;6614:38;:26;:38;:::i;:::-;6597:55;-1:-1:-1;6663:16:0;6682:49;6708:22;6682:21;:9;6696:6;6682:21;:13;:21;:::i;:49::-;6663:68;;6774:11;6762:9;:23;;;;;;6742:43;;5976:894;;;;;;;6812:4;-1:-1:-1;;;;;6807:15:0;;6823:17;6842:1;6845:2;6859:1;6849:12;;;;;;;;;;3669:226;3727:7;3751:6;3747:47;;-1:-1:-1;3781:1:0;3774:8;;3747:47;3818:5;;;3822:1;3818;:5;:1;3842:5;;;;;:10;3834:32;;;;;-1:-1:-1;;;3834:32:0;;;;;;;;;;;;-1:-1:-1;;;3834:32:0;;;;;;;;;;;;;;;3886:1;-1:-1:-1;3669:226:0;;;;;:::o;4493:161::-;4551:7;4583:5;;;4607:6;;;;4599:28;;;;;-1:-1:-1;;;4599:28:0;;;;;;;;;;;;-1:-1:-1;;;4599:28:0;;;;;;;;;;;;;
Swarm Source
ipfs://66f20386f482a412e7f0bcfb64531b5137d12362e8f9a2d92ea9b9de97f3af01
Loading...
Loading
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
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.