More Info
Private Name Tags
ContractCreator
Latest 4 from a total of 4 transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xEc9E0883...5a6F11D9C The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
Zap
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/external/IERC20Querier.sol"; import "./interfaces/external/IWETH9.sol"; import "./interfaces/IZap.sol"; import "./interfaces/IZapEvent.sol"; import "./interfaces/uniswapV3/ISwapRouter.sol"; import "./libraries/constants/ZapConstants.sol"; import "./libraries/constants/Constants.sol"; import "./libraries/uniswapV3/TransferHelper.sol"; import "./libraries/ParameterVerificationHelper.sol"; import "./libraries/PoolHelper.sol"; import "./ZapInitializer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; /// @dev verified, public contract /// @dev ceratin functions only owner callable contract Zap is IZap, IZapEvent, Ownable, ZapInitializer { using SafeMath for uint256; uint24 public override slippageToleranceNumerator; address public WETH; constructor(uint24 _slippageToleranceNumerator) { // initialize pre-defined swapPath and swapTradeFeeNumerator initializeSwapTradeFeeNumerator(); initializeSwapPath(); slippageToleranceNumerator = _slippageToleranceNumerator; WETH = Constants.WETH_ADDRESS; } function getSwapInfo( address inputToken, address outputToken ) public view override returns ( bool isPathDefined, address[] memory swapPathArray, uint24[] memory swapTradeFeeArray ) { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // get swapPath address[] memory _swapPathArray = swapPath[inputToken][outputToken]; uint256 pathLength = _swapPathArray.length; if (pathLength >= 2) { // statement for "single swap path" & "multiple swap path" bool _isPathDefined = true; uint24[] memory _swapTradeFeeArray = new uint24[](pathLength - 1); for (uint i = 0; i < (pathLength - 1); i++) { uint24 tradeFee = swapTradeFeeNumerator[_swapPathArray[i]][ _swapPathArray[i + 1] ]; if (tradeFee == 0) { // path not defined if tradeFee is 0 _isPathDefined = false; } _swapTradeFeeArray[i] = tradeFee; } return (_isPathDefined, _swapPathArray, _swapTradeFeeArray); } else { // statement for "path is not defined" return (false, new address[](0), new uint24[](0)); } } function setSlippageToleranceNumerator( uint24 slippageTolerance ) public onlyOwner { // parameter verification ParameterVerificationHelper.verifyGreaterThanZero(slippageTolerance); // verify slippageTolerance is less than SLIPPAGE_TOLERANCE_DENOMINATOR require( slippageTolerance < ZapConstants.SLIPPAGE_TOLERANCE_DENOMINATOR, "slippageTolerance too big" ); // update slippageToleranceNumerator slippageToleranceNumerator = slippageTolerance; // emit UpdateSlippageTolerance event emit UpdateSlippageTolerance(slippageTolerance); } function setSwapTradeFeeNumerator( address inputToken, address outputToken, uint24 swapTradeFee ) public onlyOwner { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); ParameterVerificationHelper.verifyGreaterThanZero(swapTradeFee); // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // verify pool is exist address poolAddress = PoolHelper.getPoolAddress( Constants.UNISWAP_V3_FACTORY_ADDRESS, inputToken, outputToken, swapTradeFee ); require(poolAddress != address(0), "pool not exist"); // update swapTradeFeeNumerator swapTradeFeeNumerator[inputToken][outputToken] = swapTradeFee; // emit UpdateSwapTradeFee event emit UpdateSwapTradeFee(inputToken, outputToken, swapTradeFee); } function setSwapPath( address inputToken, address outputToken, address[] memory newSwapPath ) public onlyOwner { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); uint256 pathLength = newSwapPath.length; for (uint i = 0; i < pathLength; i++) { ParameterVerificationHelper.verifyNotZeroAddress(newSwapPath[i]); } // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // verify input path is valid swap path require(pathLength >= 2, "path too short"); // verify first token in newSwapPath is inputToken require(newSwapPath[0] == inputToken, "path not start from inputToken"); // verify last token in newSwapPath is outputToken require( newSwapPath[(pathLength - 1)] == outputToken, "path not end with outputToken" ); // verify each swap’s fee is defined for (uint i = 0; i < (pathLength - 1); i++) { uint24 tradeFee = swapTradeFeeNumerator[newSwapPath[i]][ newSwapPath[i + 1] ]; require(tradeFee != 0, "tradefee not defined"); } // update Swap Path swapPath[inputToken][outputToken] = newSwapPath; // emit UpdateSwapPath event emit UpdateSwapPath(inputToken, outputToken, newSwapPath); } function getTokenExchangeRate( address inputToken, address outputToken ) public view override returns ( address token0, address token1, uint256 tokenPriceWith18Decimals ) { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // verify swap trade fee is defined uint24 tradeFee = swapTradeFeeNumerator[inputToken][outputToken]; require(tradeFee != 0, "tradeFee not define"); // verify pool is exist address poolAddress = PoolHelper.getPoolAddress( Constants.UNISWAP_V3_FACTORY_ADDRESS, inputToken, outputToken, tradeFee ); require(poolAddress != address(0), "pool not exist"); // query pool info (token0, token1, , , , , ) = PoolHelper.getPoolInfo(poolAddress); // calculate token price with 18 decimal precision tokenPriceWith18Decimals = PoolHelper.getTokenPriceWithDecimalsByPool( poolAddress, ZapConstants.DECIMALS_PRECISION ); } function getMinimumSwapOutAmount( address inputToken, address outputToken, uint256 inputAmount ) public view override returns (uint256 minimumSwapOutAmount) { uint256 estimateSwapOutAmount = getEstimateSwapOutAmount( inputToken, outputToken, inputAmount ); // calculate price include slippage tolerance uint256 _minimumSwapOutAmount = estimateSwapOutAmount .mul( uint256(ZapConstants.SLIPPAGE_TOLERANCE_DENOMINATOR).sub( slippageToleranceNumerator ) ) .div(ZapConstants.SLIPPAGE_TOLERANCE_DENOMINATOR); minimumSwapOutAmount = _minimumSwapOutAmount; } function getEstimateSwapOutAmount( address inputToken, address outputToken, uint256 inputAmount ) public view returns (uint256 estimateSwapOutAmount) { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); ParameterVerificationHelper.verifyGreaterThanZero(inputAmount); // variable verification require( slippageToleranceNumerator > 0, "slippageToleranceNumerator is 0" ); // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // verify swap info is defined ( bool isPathDefined, address[] memory swapPathArray, uint24[] memory swapTradeFeeArray ) = getSwapInfo(inputToken, outputToken); require(isPathDefined == true, "path not define"); // get swap path length as loop end index uint256 pathLength = swapPathArray.length; // intput token decimal adjustment uint256 calcAmount = inputAmount.mul( 10 ** (PoolHelper.getTokenDecimalAdjustment(inputToken)) ); // Loop calculate minimum swap out amount for (uint i = 0; i < (pathLength - 1); i++) { address tokenIn = swapPathArray[i]; address tokenOut = swapPathArray[i + 1]; ( address token0, address token1, uint256 tokenPriceWith18Decimals // (token1/token0) * 10**DECIMALS_PRECISION ) = getTokenExchangeRate(tokenIn, tokenOut); // deduct trade fee calcAmount = calcAmount .mul( uint256(ZapConstants.SWAP_TRADE_FEE_DENOMINATOR).sub( swapTradeFeeArray[i] ) ) .div(ZapConstants.SWAP_TRADE_FEE_DENOMINATOR); // get swap out amount without slippage require(tokenIn == token0 || tokenIn == token1); if (tokenIn == token0) { calcAmount = calcAmount.mul(tokenPriceWith18Decimals).div( 10 ** ZapConstants.DECIMALS_PRECISION ); } else { calcAmount = calcAmount .mul(10 ** ZapConstants.DECIMALS_PRECISION) .div(tokenPriceWith18Decimals); } } // output token decimal adjustment estimateSwapOutAmount = calcAmount.div( 10 ** (PoolHelper.getTokenDecimalAdjustment(outputToken)) ); } /// @notice caller need to approve inputToken to Zap contract in inputAmount amount function swapToken( bool isETH, address inputToken, address outputToken, uint256 inputAmount, address recipient ) public payable override returns (uint256 outputAmount) { // get minimum swap out amount uint256 minimumSwapOutAmount = getMinimumSwapOutAmount( inputToken, outputToken, inputAmount ); outputAmount = swapTokenWithMinimumOutput( isETH, inputToken, outputToken, inputAmount, minimumSwapOutAmount, recipient ); } /// @notice caller need to approve inputToken to Zap contract in inputAmount amount function swapTokenWithMinimumOutput( bool isETH, address inputToken, address outputToken, uint256 inputAmount, uint256 minimumSwapOutAmount, address recipient ) public payable override returns (uint256 outputAmount) { // parameter verification ParameterVerificationHelper.verifyNotZeroAddress(inputToken); ParameterVerificationHelper.verifyNotZeroAddress(outputToken); ParameterVerificationHelper.verifyNotZeroAddress(recipient); ParameterVerificationHelper.verifyGreaterThanZero(inputAmount); // verify inputToken is not outputToken require(inputToken != outputToken, "inputToken == outputToken"); // verify swap info is defined ( bool isPathDefined, address[] memory swapPathArray, uint24[] memory swapTradeFeeArray ) = getSwapInfo(inputToken, outputToken); require(isPathDefined == true, "path not define"); if (isETH) { // verify input ETH is the same as inputAmount ParameterVerificationHelper.verifyMsgValueEqualsInputAmount( inputAmount ); require( inputToken == WETH, "input ETH must have swap path from WETH" ); // prepare WETH for swap IWETH9(WETH).deposit{value: inputAmount}(); } else { // verify caller inputToken allowance is more or equal to inputAmount require( IERC20Querier(inputToken).allowance( msg.sender, address(this) ) >= inputAmount, "allowance insufficient" ); // transfer inputToken in inputAmount from caller to Zap contract TransferHelper.safeTransferFrom( inputToken, msg.sender, address(this), inputAmount ); } // approve inputToken to SmartRouter in inputAmount amount TransferHelper.safeApprove( inputToken, Constants.SWAP_ROUTER_ADDRESS, inputAmount ); uint256 pathLength = swapPathArray.length; if (pathLength == 2) { // statement for "single swap path", swap by exactInputSingle function outputAmount = ISwapRouter(Constants.SWAP_ROUTER_ADDRESS) .exactInputSingle( ISwapRouter.ExactInputSingleParams( inputToken, outputToken, swapTradeFeeArray[0], recipient, block.timestamp.add(transactionDeadlineDuration), inputAmount, minimumSwapOutAmount, 0 ) ); // emit SingleSwap event emit SingleSwap( recipient, isETH, inputToken, inputAmount, outputToken, outputAmount, swapPathArray, swapTradeFeeArray ); } else { // statement for "multiple swap path", swap by exactInput function bytes memory path = abi.encodePacked(swapPathArray[0]); for (uint i = 0; i < (pathLength - 1); i++) { path = abi.encodePacked( path, swapTradeFeeArray[i], swapPathArray[i + 1] ); } outputAmount = ISwapRouter(Constants.SWAP_ROUTER_ADDRESS) .exactInput( ISwapRouter.ExactInputParams( path, recipient, block.timestamp.add(transactionDeadlineDuration), inputAmount, minimumSwapOutAmount ) ); // emit MultiSwap event emit MultiSwap( recipient, isETH, inputToken, inputAmount, outputToken, outputAmount, swapPathArray, swapTradeFeeArray ); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20Querier is IERC20 { function decimals() external view returns (uint256); function name() external view returns (string memory); function symbol() external view returns (string memory); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Interface for WETH9 interface IWETH9 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IZap { /// @dev get zap data function slippageToleranceNumerator() external view returns (uint24); function getSwapInfo( address inputToken, address outputToken ) external view returns ( bool isPathDefined, address[] memory swapPathArray, uint24[] memory swapTradeFeeArray ); function getTokenExchangeRate( address inputToken, address outputToken ) external view returns ( address token0, address token1, uint256 tokenPriceWith18Decimals ); function getMinimumSwapOutAmount( address inputToken, address outputToken, uint256 inputAmount ) external view returns (uint256 minimumSwapOutAmount); /// @dev swapToken function swapToken( bool isETH, address inputToken, address outputToken, uint256 inputAmount, address recipient ) external payable returns (uint256 outputAmount); function swapTokenWithMinimumOutput( bool isETH, address inputToken, address outputToken, uint256 inputAmount, uint256 minimumSwapOutAmount, address recipient ) external payable returns (uint256 outputAmount); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IZapEvent { event UpdateSlippageTolerance(uint24 slippageTolerance); event UpdateSwapTradeFee( address indexed inputToken, address indexed outputToken, uint24 swapTradeFee ); event UpdateSwapPath( address indexed inputToken, address indexed outputToken, address[] newSwapPath ); event SingleSwap( address indexed recipient, bool isETH, address inputToken, uint256 inputAmount, address outputToken, uint256 outputAmount, address[] swapPath, uint24[] swapTradeFee ); event MultiSwap( address indexed recipient, bool isETH, address inputToken, uint256 inputAmount, address outputToken, uint256 outputAmount, address[] swapPath, uint24[] swapTradeFee ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; interface ISwapRouter { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle( ExactInputSingleParams calldata params ) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput( ExactInputParams calldata params ) external payable returns (uint256 amountOut); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; interface IUniswapV3Factory { /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; interface IUniswapV3Pool { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Constants { /// @dev ArbiturmOne & Goerli uniswap V3 address public constant UNISWAP_V3_FACTORY_ADDRESS = address(0x1F98431c8aD98523631AE4a59f267346ea31F984); address public constant NONFUNGIBLE_POSITION_MANAGER_ADDRESS = address(0xC36442b4a4522E871399CD717aBDD847Ab11FE88); address public constant SWAP_ROUTER_ADDRESS = address(0xE592427A0AEce92De3Edee1F18E0157C05861564); /// @dev ArbiturmOne token address address public constant WETH_ADDRESS = address(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1); address public constant ARB_ADDRESS = address(0x912CE59144191C1204E64559FE8253a0e49E6548); address public constant WBTC_ADDRESS = address(0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f); address public constant USDC_ADDRESS = address(0xaf88d065e77c8cC2239327C5EDb3A432268e5831); address public constant USDCE_ADDRESS = address(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8); address public constant USDT_ADDRESS = address(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9); address public constant RDNT_ADDRESS = address(0x3082CC23568eA640225c2467653dB90e9250AaA0); address public constant LINK_ADDRESS = address(0xf97f4df75117a78c1A5a0DBb814Af92458539FB4); /// @dev black hole address address public constant BLACK_HOLE_ADDRESS = address(0x000000000000000000000000000000000000dEaD); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ZapConstants { /// @dev decimal precision uint256 public constant DECIMALS_PRECISION = 18; /// @dev denominator uint24 public constant SLIPPAGE_TOLERANCE_DENOMINATOR = 1000000; uint24 public constant SWAP_TRADE_FEE_DENOMINATOR = 1000000; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ParameterVerificationHelper { function verifyNotZeroAddress(address inputAddress) internal pure { require(inputAddress != address(0), "input zero address"); } function verifyGreaterThanZero(uint256 inputNumber) internal pure { require(inputNumber > 0, "input 0"); } function verifyGreaterThanZero(int24 inputNumber) internal pure { require(inputNumber > 0, "input 0"); } function verifyGreaterThanOne(int24 inputNumber) internal pure { require(inputNumber > 1, "input <= 1"); } function verifyGreaterThanOrEqualToZero(int24 inputNumber) internal pure { require(inputNumber >= 0, "input less than 0"); } function verifyPairTokensHaveWeth( address token0Address, address token1Address, address wethAddress ) internal pure { require( token0Address == wethAddress || token1Address == wethAddress, "pair token not have WETH" ); } function verifyMsgValueEqualsInputAmount( uint256 inputAmount ) internal view { require(msg.value == inputAmount, "msg.value != inputAmount"); } function verifyPairTokensHaveInputToken( address token0Address, address token1Address, address inputToken ) internal pure { require( token0Address == inputToken || token1Address == inputToken, "pair token not have inputToken" ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../interfaces/external/IERC20Querier.sol"; import "../interfaces/uniswapV3/IUniswapV3Factory.sol"; import "../interfaces/uniswapV3/IUniswapV3Pool.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; library PoolHelper { using SafeMath for uint256; function getPoolAddress( address uniswapV3FactoryAddress, address tokenA, address tokenB, uint24 poolFee ) internal view returns (address poolAddress) { return IUniswapV3Factory(uniswapV3FactoryAddress).getPool( tokenA, tokenB, poolFee ); } function getPoolInfo( address poolAddress ) internal view returns ( address token0, address token1, uint24 poolFee, int24 tick, uint160 sqrtPriceX96, uint256 decimal0, uint256 decimal1 ) { (sqrtPriceX96, tick, , , , , ) = IUniswapV3Pool(poolAddress).slot0(); token0 = IUniswapV3Pool(poolAddress).token0(); token1 = IUniswapV3Pool(poolAddress).token1(); poolFee = IUniswapV3Pool(poolAddress).fee(); decimal0 = IERC20Querier(token0).decimals(); decimal1 = IERC20Querier(token1).decimals(); } /// @dev formula explanation /* [Original formula (without decimal precision)] (token1 * (10^decimal1)) / (token0 * (10^decimal0)) = (sqrtPriceX96 / (2^96))^2 tokenPrice = token1/token0 = (sqrtPriceX96 / (2^96))^2 * (10^decimal0) / (10^decimal1) [Formula with decimal precision & decimal adjustment] tokenPriceWithDecimalAdj = tokenPrice * (10^decimalPrecision) = (sqrtPriceX96 * (10^decimalPrecision) / (2^96))^2 / 10^(decimalPrecision + decimal1 - decimal0) */ function getTokenPriceWithDecimalsByPool( address poolAddress, uint256 decimalPrecision ) internal view returns (uint256 tokenPriceWithDecimals) { ( , , , , uint160 sqrtPriceX96, uint256 decimal0, uint256 decimal1 ) = getPoolInfo(poolAddress); // when decimalPrecision is 18, // calculation restriction: 79228162514264337594 <= sqrtPriceX96 <= type(uint160).max uint256 scaledPriceX96 = uint256(sqrtPriceX96) .mul(10 ** decimalPrecision) .div(2 ** 96); uint256 tokenPriceWithoutDecimalAdj = scaledPriceX96.mul( scaledPriceX96 ); uint256 decimalAdj = decimalPrecision.add(decimal1).sub(decimal0); uint256 result = tokenPriceWithoutDecimalAdj.div(10 ** decimalAdj); require(result > 0, "token price too small"); tokenPriceWithDecimals = result; } function getTokenDecimalAdjustment( address token ) internal view returns (uint256 decimalAdjustment) { uint256 tokenDecimalStandard = 18; uint256 decimal = IERC20Querier(token).decimals(); return tokenDecimalStandard.sub(decimal); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector( IERC20.transferFrom.selector, from, to, value ) ); require( success && (data.length == 0 || abi.decode(data, (bool))), "STF" ); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.transfer.selector, to, value) ); require( success && (data.length == 0 || abi.decode(data, (bool))), "ST" ); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.approve.selector, to, value) ); require( success && (data.length == 0 || abi.decode(data, (bool))), "SA" ); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, "STE"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./libraries/constants/Constants.sol"; contract ZapInitializer { /// @dev Uniswap-Transaction-related Variable uint256 public transactionDeadlineDuration = 300; // inputToken => outputToken => swapPath mapping(address => mapping(address => address[])) internal swapPath; // inputToken => outputToken => swapTradeFeeNumerator mapping(address => mapping(address => uint24)) internal swapTradeFeeNumerator; function initializeSwapTradeFeeNumerator() internal { address WETH = Constants.WETH_ADDRESS; address ARB = Constants.ARB_ADDRESS; address WBTC = Constants.WBTC_ADDRESS; address USDC = Constants.USDC_ADDRESS; address USDCE = Constants.USDCE_ADDRESS; address USDT = Constants.USDT_ADDRESS; address RDNT = Constants.RDNT_ADDRESS; address LINK = Constants.LINK_ADDRESS; /// @dev ArbitrumOne mainnet initialization trade fee 0.01% swapTradeFeeNumerator[USDC][USDCE] = 100; swapTradeFeeNumerator[USDC][USDT] = 100; swapTradeFeeNumerator[USDCE][USDC] = 100; swapTradeFeeNumerator[USDCE][USDT] = 100; swapTradeFeeNumerator[USDT][USDC] = 100; swapTradeFeeNumerator[USDT][USDCE] = 100; /// @dev ArbitrumOne mainnet initialization trade fee 0.05% swapTradeFeeNumerator[WETH][ARB] = 500; swapTradeFeeNumerator[WETH][WBTC] = 500; swapTradeFeeNumerator[WETH][USDC] = 500; swapTradeFeeNumerator[WETH][USDCE] = 500; swapTradeFeeNumerator[WETH][USDT] = 500; swapTradeFeeNumerator[ARB][WETH] = 500; swapTradeFeeNumerator[WBTC][WETH] = 500; swapTradeFeeNumerator[USDCE][ARB] = 500; swapTradeFeeNumerator[USDCE][WETH] = 500; swapTradeFeeNumerator[USDCE][WBTC] = 500; swapTradeFeeNumerator[USDT][WETH] = 500; /// @dev ArbitrumOne mainnet initialization trade fee 0.30% swapTradeFeeNumerator[WETH][RDNT] = 3000; swapTradeFeeNumerator[WETH][LINK] = 3000; swapTradeFeeNumerator[RDNT][WETH] = 3000; swapTradeFeeNumerator[LINK][WETH] = 3000; } function initializeSwapPath() internal { address WETH = Constants.WETH_ADDRESS; address ARB = Constants.ARB_ADDRESS; address WBTC = Constants.WBTC_ADDRESS; address USDC = Constants.USDC_ADDRESS; address USDCE = Constants.USDCE_ADDRESS; address USDT = Constants.USDT_ADDRESS; address RDNT = Constants.RDNT_ADDRESS; address LINK = Constants.LINK_ADDRESS; /// @dev ArbitrumOne mainnet initialization single swap // trade fee 0.01% swapPath[USDC][USDCE] = [USDC, USDCE]; swapPath[USDC][USDT] = [USDC, USDT]; swapPath[USDCE][USDC] = [USDCE, USDC]; swapPath[USDCE][USDT] = [USDCE, USDT]; swapPath[USDT][USDC] = [USDT, USDC]; swapPath[USDT][USDCE] = [USDT, USDCE]; /// @dev ArbitrumOne mainnet initialization single swap // trade fee 0.05% swapPath[WETH][ARB] = [WETH, ARB]; swapPath[WETH][WBTC] = [WETH, WBTC]; swapPath[WETH][USDC] = [WETH, USDC]; swapPath[WETH][USDCE] = [WETH, USDCE]; swapPath[WETH][USDT] = [WETH, USDT]; swapPath[ARB][WETH] = [ARB, WETH]; swapPath[WBTC][WETH] = [WBTC, WETH]; swapPath[USDCE][ARB] = [USDCE, ARB]; swapPath[USDCE][WETH] = [USDCE, WETH]; swapPath[USDT][WETH] = [USDT, WETH]; /// @dev ArbitrumOne mainnet initialization single swap // trade fee 0.30% swapPath[WETH][RDNT] = [WETH, RDNT]; swapPath[WETH][LINK] = [WETH, LINK]; swapPath[RDNT][WETH] = [RDNT, WETH]; swapPath[LINK][WETH] = [LINK, WETH]; /// @dev ArbitrumOne mainnet initialization multi swap swapPath[ARB][WBTC] = [ARB, WETH, WBTC]; swapPath[ARB][USDC] = [ARB, WETH, USDC]; swapPath[ARB][USDCE] = [ARB, WETH, USDCE]; swapPath[ARB][USDT] = [ARB, WETH, USDT]; swapPath[ARB][RDNT] = [ARB, WETH, RDNT]; swapPath[ARB][LINK] = [ARB, WETH, LINK]; swapPath[WBTC][ARB] = [WBTC, WETH, ARB]; swapPath[WBTC][USDC] = [WBTC, WETH, USDC]; swapPath[WBTC][USDCE] = [WBTC, WETH, USDCE]; swapPath[WBTC][USDT] = [WBTC, WETH, USDT]; swapPath[WBTC][RDNT] = [WBTC, WETH, RDNT]; swapPath[WBTC][LINK] = [WBTC, WETH, LINK]; swapPath[USDC][ARB] = [USDC, USDCE, ARB]; swapPath[USDC][WETH] = [USDC, USDCE, WETH]; swapPath[USDC][WBTC] = [USDC, USDCE, WBTC]; swapPath[USDC][RDNT] = [USDC, USDCE, WETH, RDNT]; swapPath[USDC][LINK] = [USDC, USDCE, WETH, LINK]; swapPath[USDCE][WBTC] = [USDCE, WETH, WBTC]; swapPath[USDCE][RDNT] = [USDCE, WETH, RDNT]; swapPath[USDCE][LINK] = [USDCE, WETH, LINK]; swapPath[USDT][ARB] = [USDT, USDCE, ARB]; swapPath[USDT][WBTC] = [USDT, USDCE, WBTC]; swapPath[USDT][RDNT] = [USDT, WETH, RDNT]; swapPath[USDT][LINK] = [USDT, WETH, LINK]; swapPath[RDNT][ARB] = [RDNT, WETH, ARB]; swapPath[RDNT][WBTC] = [RDNT, WETH, WBTC]; swapPath[RDNT][USDC] = [RDNT, WETH, USDC]; swapPath[RDNT][USDCE] = [RDNT, WETH, USDCE]; swapPath[RDNT][USDT] = [RDNT, WETH, USDT]; swapPath[RDNT][LINK] = [RDNT, WETH, LINK]; swapPath[LINK][ARB] = [LINK, WETH, ARB]; swapPath[LINK][WBTC] = [LINK, WETH, WBTC]; swapPath[LINK][USDC] = [LINK, WETH, USDC]; swapPath[LINK][USDCE] = [LINK, WETH, USDCE]; swapPath[LINK][USDT] = [LINK, WETH, USDT]; swapPath[LINK][RDNT] = [LINK, WETH, RDNT]; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint24","name":"_slippageToleranceNumerator","type":"uint24"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bool","name":"isETH","type":"bool"},{"indexed":false,"internalType":"address","name":"inputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"inputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"swapPath","type":"address[]"},{"indexed":false,"internalType":"uint24[]","name":"swapTradeFee","type":"uint24[]"}],"name":"MultiSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bool","name":"isETH","type":"bool"},{"indexed":false,"internalType":"address","name":"inputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"inputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"swapPath","type":"address[]"},{"indexed":false,"internalType":"uint24[]","name":"swapTradeFee","type":"uint24[]"}],"name":"SingleSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint24","name":"slippageTolerance","type":"uint24"}],"name":"UpdateSlippageTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"inputToken","type":"address"},{"indexed":true,"internalType":"address","name":"outputToken","type":"address"},{"indexed":false,"internalType":"address[]","name":"newSwapPath","type":"address[]"}],"name":"UpdateSwapPath","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"inputToken","type":"address"},{"indexed":true,"internalType":"address","name":"outputToken","type":"address"},{"indexed":false,"internalType":"uint24","name":"swapTradeFee","type":"uint24"}],"name":"UpdateSwapTradeFee","type":"event"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"name":"getEstimateSwapOutAmount","outputs":[{"internalType":"uint256","name":"estimateSwapOutAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"name":"getMinimumSwapOutAmount","outputs":[{"internalType":"uint256","name":"minimumSwapOutAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"}],"name":"getSwapInfo","outputs":[{"internalType":"bool","name":"isPathDefined","type":"bool"},{"internalType":"address[]","name":"swapPathArray","type":"address[]"},{"internalType":"uint24[]","name":"swapTradeFeeArray","type":"uint24[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"}],"name":"getTokenExchangeRate","outputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint256","name":"tokenPriceWith18Decimals","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"slippageTolerance","type":"uint24"}],"name":"setSlippageToleranceNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"address[]","name":"newSwapPath","type":"address[]"}],"name":"setSwapPath","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint24","name":"swapTradeFee","type":"uint24"}],"name":"setSwapTradeFeeNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slippageToleranceNumerator","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isETH","type":"bool"},{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"swapToken","outputs":[{"internalType":"uint256","name":"outputAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bool","name":"isETH","type":"bool"},{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"minimumSwapOutAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"swapTokenWithMinimumOutput","outputs":[{"internalType":"uint256","name":"outputAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"transactionDeadlineDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x6080604052600436106100e85760003560e01c80638da5cb5b1161008a578063cb612cfb11610059578063cb612cfb14610275578063da02e7181461028b578063e1454fd0146102ab578063f2fde38b146102f157600080fd5b80638da5cb5b146101cd578063ac94e8ca146101ff578063ad5c46481461021f578063ae39ecfc1461024657600080fd5b80634aec7a31116100c65780634aec7a311461015557806352c076c314610168578063666fc8b314610198578063715018a6146101b857600080fd5b80630ddb88ae146100ed57806336d02ea11461010f5780633b4cdc431461012f575b600080fd5b3480156100f957600080fd5b5061010d610108366004611eb8565b610311565b005b34801561011b57600080fd5b5061010d61012a366004611fb5565b61066b565b61014261013d36600461200e565b610799565b6040519081526020015b60405180910390f35b610142610163366004612076565b6107c2565b34801561017457600080fd5b506004546101849062ffffff1681565b60405162ffffff909116815260200161014c565b3480156101a457600080fd5b506101426101b33660046120e6565b610e18565b3480156101c457600080fd5b5061010d6110ce565b3480156101d957600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161014c565b34801561020b57600080fd5b5061010d61021a366004612127565b6110e2565b34801561022b57600080fd5b506004546101e790630100000090046001600160a01b031681565b34801561025257600080fd5b5061026661026136600461214b565b61119b565b60405161014c939291906121fd565b34801561028157600080fd5b5061014260015481565b34801561029757600080fd5b506101426102a63660046120e6565b6113df565b3480156102b757600080fd5b506102cb6102c636600461214b565b611424565b604080516001600160a01b0394851681529390921660208401529082015260600161014c565b3480156102fd57600080fd5b5061010d61030c36600461222a565b611578565b6103196115f1565b6103228361164b565b61032b8261164b565b805160005b8181101561036c5761035a83828151811061034d5761034d612247565b602002602001015161164b565b8061036481612273565b915050610330565b50826001600160a01b0316846001600160a01b0316036103a75760405162461bcd60e51b815260040161039e9061228c565b60405180910390fd5b60028110156103e95760405162461bcd60e51b815260206004820152600e60248201526d1c185d1a081d1bdbc81cda1bdc9d60921b604482015260640161039e565b836001600160a01b03168260008151811061040657610406612247565b60200260200101516001600160a01b0316146104645760405162461bcd60e51b815260206004820152601e60248201527f70617468206e6f742073746172742066726f6d20696e707574546f6b656e0000604482015260640161039e565b6001600160a01b0383168261047a6001846122c3565b8151811061048a5761048a612247565b60200260200101516001600160a01b0316146104e85760405162461bcd60e51b815260206004820152601d60248201527f70617468206e6f7420656e642077697468206f7574707574546f6b656e000000604482015260640161039e565b60005b6104f66001836122c3565b8110156105e35760006003600085848151811061051557610515612247565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008584600161054d91906122d6565b8151811061055d5761055d612247565b6020908102919091018101516001600160a01b0316825281019190915260400160009081205462ffffff1691508190036105d05760405162461bcd60e51b81526020600482015260146024820152731d1c985919599959481b9bdd081919599a5b995960621b604482015260640161039e565b50806105db81612273565b9150506104eb565b506001600160a01b0380851660009081526002602090815260408083209387168352928152919020835161061992850190611e03565b50826001600160a01b0316846001600160a01b03167f1b8a2f263025a93091ad02833d5c0dffaa83d6e6d8d21e11f0e0b5c48f63dd578460405161065d91906122e9565b60405180910390a350505050565b6106736115f1565b61067c8361164b565b6106858261164b565b6106938162ffffff16611696565b816001600160a01b0316836001600160a01b0316036106c45760405162461bcd60e51b815260040161039e9061228c565b60006106e6731f98431c8ad98523631ae4a59f267346ea31f9848585856116d0565b90506001600160a01b03811661072f5760405162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081b9bdd08195e1a5cdd60921b604482015260640161039e565b6001600160a01b03848116600081815260036020908152604080832094881680845294825291829020805462ffffff191662ffffff881690811790915591519182527f036c706ce028591ddd5006239a630c0bb9bce2ece55d1120c8519913fe74fc63910161065d565b6000806107a78686866113df565b90506107b78787878785886107c2565b979650505050505050565b60006107cd8661164b565b6107d68561164b565b6107df8261164b565b6107e884611696565b846001600160a01b0316866001600160a01b0316036108195760405162461bcd60e51b815260040161039e9061228c565b6000806000610828898961119b565b919450925090506001831515146108735760405162461bcd60e51b815260206004820152600f60248201526e70617468206e6f7420646566696e6560881b604482015260640161039e565b8915610964576108828761175a565b6004546001600160a01b038a8116630100000090920416146108f65760405162461bcd60e51b815260206004820152602760248201527f696e70757420455448206d7573742068617665207377617020706174682066726044820152660deda40ae8aa8960cb1b606482015260840161039e565b600460039054906101000a90046001600160a01b03166001600160a01b031663d0e30db0886040518263ffffffff1660e01b81526004016000604051808303818588803b15801561094657600080fd5b505af115801561095a573d6000803e3d6000fd5b5050505050610a27565b604051636eb1769f60e11b815233600482015230602482015287906001600160a01b038b169063dd62ed3e90604401602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d491906122fc565b1015610a1b5760405162461bcd60e51b8152602060048201526016602482015275185b1b1bddd85b98d9481a5b9cdd59999a58da595b9d60521b604482015260640161039e565b610a278933308a6117a9565b610a468973e592427a0aece92de3edee1f18e0157c05861564896118b3565b81516002819003610c105773e592427a0aece92de3edee1f18e0157c058615646001600160a01b031663414bf3896040518061010001604052808d6001600160a01b031681526020018c6001600160a01b0316815260200185600081518110610ab157610ab1612247565b602002602001015162ffffff168152602001896001600160a01b03168152602001610ae7600154426119b390919063ffffffff16565b815260208082018d905260408083018d90526000606093840152805160e086811b6001600160e01b031916825285516001600160a01b03908116600484015293860151841660248301529185015162ffffff16604482015292840151821660648401526080840151608484015260a084015160a484015260c084015160c4840152929092015190911660e4820152610104016020604051808303816000875af1158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc91906122fc565b9450856001600160a01b03167f0ff70a757dde6555c17e755d4725dbec5d2662e928b64e2a2772a047db1d9f0d8c8c8b8d8a8989604051610c039796959493929190612315565b60405180910390a2610e0a565b600083600081518110610c2557610c25612247565b6020026020010151604051602001610c55919060609190911b6bffffffffffffffffffffffff1916815260140190565b604051602081830303815290604052905060005b610c746001846122c3565b811015610cf25781848281518110610c8e57610c8e612247565b602002602001015186836001610ca491906122d6565b81518110610cb457610cb4612247565b6020026020010151604051602001610cce9392919061239b565b60405160208183030381529060405291508080610cea90612273565b915050610c69565b5073e592427a0aece92de3edee1f18e0157c058615646001600160a01b031663c04b8d596040518060a001604052808481526020018a6001600160a01b03168152602001610d4b600154426119b390919063ffffffff16565b81526020018c81526020018b8152506040518263ffffffff1660e01b8152600401610d7691906123e7565b6020604051808303816000875af1158015610d95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db991906122fc565b9550866001600160a01b03167fe2fbd4605def93f01b1643f166a5a181f02f79d949cd5fccb5b0e5416b32ee6e8d8d8c8e8b8a8a604051610e009796959493929190612315565b60405180910390a2505b505050509695505050505050565b6000610e238461164b565b610e2c8361164b565b610e3582611696565b60045462ffffff16610e895760405162461bcd60e51b815260206004820152601f60248201527f736c697070616765546f6c6572616e63654e756d657261746f72206973203000604482015260640161039e565b826001600160a01b0316846001600160a01b031603610eba5760405162461bcd60e51b815260040161039e9061228c565b6000806000610ec9878761119b565b91945092509050600183151514610f145760405162461bcd60e51b815260206004820152600f60248201526e70617468206e6f7420646566696e6560881b604482015260640161039e565b81516000610f36610f248a6119c8565b610f2f90600a61253a565b8890611a47565b905060005b610f466001846122c3565b8110156110a2576000858281518110610f6157610f61612247565b60200260200101519050600086836001610f7b91906122d6565b81518110610f8b57610f8b612247565b602002602001015190506000806000610fa48585611424565b925092509250610fff620f424062ffffff16610ff9610ff28c8a81518110610fce57610fce612247565b602002602001015162ffffff16620f424062ffffff16611a5390919063ffffffff16565b8a90611a47565b90611a5f565b9650826001600160a01b0316856001600160a01b031614806110325750816001600160a01b0316856001600160a01b0316145b61103b57600080fd5b826001600160a01b0316856001600160a01b0316036110745761106d6110636012600a61253a565b610ff98984611a47565b965061108a565b61108781610ff9610ff26012600a61253a565b96505b5050505050808061109a90612273565b915050610f3b565b506110c16110af896119c8565b6110ba90600a61253a565b8290611a5f565b9998505050505050505050565b6110d66115f1565b6110e06000611a6b565b565b6110ea6115f1565b6110f88162ffffff16611696565b620f424062ffffff82161061114f5760405162461bcd60e51b815260206004820152601960248201527f736c697070616765546f6c6572616e636520746f6f2062696700000000000000604482015260640161039e565b6004805462ffffff191662ffffff83169081179091556040519081527f6dee1c9db313684d98cb20b5cbbd22b75f01ce5241372a0bb9328b9ff7f53ab29060200160405180910390a150565b60006060806111a98561164b565b6111b28461164b565b836001600160a01b0316856001600160a01b0316036111e35760405162461bcd60e51b815260040161039e9061228c565b6001600160a01b03808616600090815260026020908152604080832093881683529281528282208054845181840281018401909552808552929392909183018282801561125957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161123b575b50505050509050600081519050600281106113b9576001600061127c82846122c3565b67ffffffffffffffff81111561129457611294611ea2565b6040519080825280602002602001820160405280156112bd578160200160208202803683370190505b50905060005b6112ce6001856122c3565b8110156113a8576000600360008784815181106112ed576112ed612247565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008784600161132591906122d6565b8151811061133557611335612247565b6020908102919091018101516001600160a01b0316825281019190915260400160009081205462ffffff16915081900361136e57600093505b8083838151811061138157611381612247565b62ffffff9092166020928302919091019091015250806113a081612273565b9150506112c3565b509095509193509091506113d89050565b5050604080516000808252602082018181528284019093529450925090505b9250925092565b6000806113ed858585610e18565b60045490915060009061141a90620f424090610ff99061141390839062ffffff16611a53565b8590611a47565b9695505050505050565b60008060006114328561164b565b61143b8461164b565b836001600160a01b0316856001600160a01b03160361146c5760405162461bcd60e51b815260040161039e9061228c565b6001600160a01b03808616600090815260036020908152604080832093881683529290529081205462ffffff16908190036114df5760405162461bcd60e51b81526020600482015260136024820152727472616465466565206e6f7420646566696e6560681b604482015260640161039e565b6000611501731f98431c8ad98523631ae4a59f267346ea31f9848888856116d0565b90506001600160a01b03811661154a5760405162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081b9bdd08195e1a5cdd60921b604482015260640161039e565b61155381611abb565b5094995092975061156d935084925060129150611d379050565b925050509250925092565b6115806115f1565b6001600160a01b0381166115e55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161039e565b6115ee81611a6b565b50565b6000546001600160a01b031633146110e05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039e565b6001600160a01b0381166115ee5760405162461bcd60e51b8152602060048201526012602482015271696e707574207a65726f206164647265737360701b604482015260640161039e565b600081116115ee5760405162461bcd60e51b81526020600482015260076024820152660696e70757420360cc1b604482015260640161039e565b604051630b4c774160e11b81526001600160a01b038481166004830152838116602483015262ffffff8316604483015260009190861690631698ee8290606401602060405180830381865afa15801561172d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117519190612546565b95945050505050565b8034146115ee5760405162461bcd60e51b815260206004820152601860248201527f6d73672e76616c756520213d20696e707574416d6f756e740000000000000000604482015260640161039e565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169161180d9190612563565b6000604051808303816000865af19150503d806000811461184a576040519150601f19603f3d011682016040523d82523d6000602084013e61184f565b606091505b5091509150818015611879575080511580611879575080806020019051810190611879919061257f565b6118ab5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161039e565b505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b179052915160009283929087169161190f9190612563565b6000604051808303816000865af19150503d806000811461194c576040519150601f19603f3d011682016040523d82523d6000602084013e611951565b606091505b509150915081801561197b57508051158061197b57508080602001905181019061197b919061257f565b6119ac5760405162461bcd60e51b8152602060048201526002602482015261534160f01b604482015260640161039e565b5050505050565b60006119bf82846122d6565b90505b92915050565b600080601290506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3391906122fc565b9050611a3f8282611a53565b949350505050565b60006119bf828461259c565b60006119bf82846122c3565b60006119bf82846125b3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000806000806000876001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2891906125e7565b505060408051630dfe168160e01b8152905194995094975050506001600160a01b038b1692630dfe168192600480830193506020928290030181865afa158015611b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9a9190612546565b9650876001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfe9190612546565b9550876001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c629190612686565b9450866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ca2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc691906122fc565b9150856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2a91906122fc565b9050919395979092949650565b600080600080611d4686611abb565b965096509650505050506000611d7a600160601b610ff988600a611d6a919061253a565b6001600160a01b03881690611a47565b90506000611d888280611a47565b90506000611da085611d9a8a876119b3565b90611a53565b90506000611db9611db283600a61253a565b8490611a5f565b9050600081116110c15760405162461bcd60e51b81526020600482015260156024820152741d1bdad95b881c1c9a58d9481d1bdbc81cdb585b1b605a1b604482015260640161039e565b828054828255906000526020600020908101928215611e58579160200282015b82811115611e5857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190611e23565b50611e64929150611e68565b5090565b5b80821115611e645760008155600101611e69565b6001600160a01b03811681146115ee57600080fd5b8035611e9d81611e7d565b919050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215611ecd57600080fd5b8335611ed881611e7d565b9250602084810135611ee981611e7d565b9250604085013567ffffffffffffffff80821115611f0657600080fd5b818701915087601f830112611f1a57600080fd5b813581811115611f2c57611f2c611ea2565b8060051b604051601f19603f83011681018181108582111715611f5157611f51611ea2565b60405291825284820192508381018501918a831115611f6f57600080fd5b938501935b82851015611f9457611f8585611e92565b84529385019392850192611f74565b8096505050505050509250925092565b62ffffff811681146115ee57600080fd5b600080600060608486031215611fca57600080fd5b8335611fd581611e7d565b92506020840135611fe581611e7d565b91506040840135611ff581611fa4565b809150509250925092565b80151581146115ee57600080fd5b600080600080600060a0868803121561202657600080fd5b853561203181612000565b9450602086013561204181611e7d565b9350604086013561205181611e7d565b925060608601359150608086013561206881611e7d565b809150509295509295909350565b60008060008060008060c0878903121561208f57600080fd5b863561209a81612000565b955060208701356120aa81611e7d565b945060408701356120ba81611e7d565b9350606087013592506080870135915060a08701356120d881611e7d565b809150509295509295509295565b6000806000606084860312156120fb57600080fd5b833561210681611e7d565b9250602084013561211681611e7d565b929592945050506040919091013590565b60006020828403121561213957600080fd5b813561214481611fa4565b9392505050565b6000806040838503121561215e57600080fd5b823561216981611e7d565b9150602083013561217981611e7d565b809150509250929050565b600081518084526020808501945080840160005b838110156121bd5781516001600160a01b031687529582019590820190600101612198565b509495945050505050565b600081518084526020808501945080840160005b838110156121bd57815162ffffff16875295820195908201906001016121dc565b83151581526060602082015260006122186060830185612184565b828103604084015261141a81856121c8565b60006020828403121561223c57600080fd5b813561214481611e7d565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016122855761228561225d565b5060010190565b60208082526019908201527f696e707574546f6b656e203d3d206f7574707574546f6b656e00000000000000604082015260600190565b818103818111156119c2576119c261225d565b808201808211156119c2576119c261225d565b6020815260006119bf6020830184612184565b60006020828403121561230e57600080fd5b5051919050565b87151581526001600160a01b03878116602083015260408201879052851660608201526080810184905260e060a0820181905260009061235790830185612184565b82810360c084015261236981856121c8565b9a9950505050505050505050565b60005b8381101561239257818101518382015260200161237a565b50506000910152565b600084516123ad818460208901612377565b60e89490941b6001600160e81b0319169190930190815260609190911b6bffffffffffffffffffffffff1916600382015260170192915050565b602081526000825160a0602084015280518060c085015261240f8160e0860160208501612377565b60018060a01b0360208601511660408501526040850151606085015260608501516080850152608085015160a085015260e0601f19601f8301168501019250505092915050565b600181815b808511156124915781600019048211156124775761247761225d565b8085161561248457918102915b93841c939080029061245b565b509250929050565b6000826124a8575060016119c2565b816124b5575060006119c2565b81600181146124cb57600281146124d5576124f1565b60019150506119c2565b60ff8411156124e6576124e661225d565b50506001821b6119c2565b5060208310610133831016604e8410600b8410161715612514575081810a6119c2565b61251e8383612456565b80600019048211156125325761253261225d565b029392505050565b60006119bf8383612499565b60006020828403121561255857600080fd5b815161214481611e7d565b60008251612575818460208701612377565b9190910192915050565b60006020828403121561259157600080fd5b815161214481612000565b80820281158282048414176119c2576119c261225d565b6000826125d057634e487b7160e01b600052601260045260246000fd5b500490565b805161ffff81168114611e9d57600080fd5b600080600080600080600060e0888a03121561260257600080fd5b875161260d81611e7d565b8097505060208801518060020b811461262557600080fd5b9550612633604089016125d5565b9450612641606089016125d5565b935061264f608089016125d5565b925060a088015160ff8116811461266557600080fd5b60c089015190925061267681612000565b8091505092959891949750929550565b60006020828403121561269857600080fd5b815161214481611fa456fea26469706673582212201fd4cff36c98467a503f3eaa8ed23ade10414fbb1898d5f4f9d57ba568fa626464736f6c63430008120033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ 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.