Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
21244754 | 33 hrs ago | 0.17914467 ETH | ||||
21244754 | 33 hrs ago | 0.17914467 ETH | ||||
21244190 | 35 hrs ago | 0.27972 ETH | ||||
21244190 | 35 hrs ago | 0.27972 ETH | ||||
21226454 | 3 days ago | 0.1998 ETH | ||||
21226454 | 3 days ago | 0.1998 ETH | ||||
21222341 | 4 days ago | 1.65834 ETH | ||||
21222341 | 4 days ago | 1.65834 ETH | ||||
21217674 | 5 days ago | 0.5994 ETH | ||||
21217674 | 5 days ago | 0.5994 ETH | ||||
21212767 | 5 days ago | 0.2997 ETH | ||||
21212767 | 5 days ago | 0.2997 ETH | ||||
21206155 | 6 days ago | 0.5994 ETH | ||||
21206155 | 6 days ago | 0.5994 ETH | ||||
21118725 | 18 days ago | 0.51516531 ETH | ||||
21118725 | 18 days ago | 0.51516531 ETH | ||||
21108842 | 20 days ago | 0.02628069 ETH | ||||
21108842 | 20 days ago | 0.02628069 ETH | ||||
21106342 | 20 days ago | 0.53399646 ETH | ||||
21106342 | 20 days ago | 0.53399646 ETH | ||||
21091992 | 22 days ago | 0.4995 ETH | ||||
21091992 | 22 days ago | 0.4995 ETH | ||||
21083245 | 23 days ago | 0.99507992 ETH | ||||
21083245 | 23 days ago | 0.99507992 ETH | ||||
21057799 | 27 days ago | 0.07208488 ETH |
Loading...
Loading
Contract Name:
UniSwapV3
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 780 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "./BaseSwap.sol"; import "../libraries/BytesLib.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@kyber.network/utils-sc/contracts/IERC20Ext.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol"; import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IMulticall.sol"; import "@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; import "@uniswap/v3-core/contracts/libraries/BitMath.sol"; import "@uniswap/v3-core/contracts/libraries/TickMath.sol"; import "@uniswap/v3-core/contracts/libraries/SwapMath.sol"; import "@uniswap/v3-core/contracts/libraries/LiquidityMath.sol"; interface ISwapRouterInternal is ISwapRouter, IMulticall, IPeripheryImmutableState {} library TickBitmap { function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) { wordPos = int16(tick >> 8); bitPos = uint8(tick % 256); } function nextInitializedTickWithinOneWord( IUniswapV3Pool pool, int24 tick, int24 tickSpacing, bool lte ) internal view returns (int24 next, bool initialized) { int24 compressed = tick / tickSpacing; if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity if (lte) { (int16 wordPos, uint8 bitPos) = position(compressed); // all the 1s at or to the right of the current bitPos uint256 mask = (1 << bitPos) - 1 + (1 << bitPos); uint256 masked = pool.tickBitmap(wordPos) & mask; // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word initialized = masked != 0; // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick next = initialized ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing : (compressed - int24(bitPos)) * tickSpacing; } else { // start from the word of the next tick, since the current tick state doesn't matter (int16 wordPos, uint8 bitPos) = position(compressed + 1); // all the 1s at or to the left of the bitPos uint256 mask = ~((1 << bitPos) - 1); uint256 masked = pool.tickBitmap(wordPos) & mask; // if there are no initialized ticks to the left of the current tick, return leftmost in the word initialized = masked != 0; // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick next = initialized ? (compressed + 1 + int24(BitMath.leastSignificantBit(masked) - bitPos)) * tickSpacing : (compressed + 1 + int24(type(uint8).max - bitPos)) * tickSpacing; } } } /// General swap for uniswap v3 and its clones contract UniSwapV3 is BaseSwap { using SafeERC20 for IERC20Ext; using Address for address; using EnumerableSet for EnumerableSet.AddressSet; using BytesLib for bytes; using SafeCast for uint256; using LowGasSafeMath for uint256; using LowGasSafeMath for int256; using TickBitmap for IUniswapV3Pool; EnumerableSet.AddressSet private uniRouters; event UpdatedUniRouters(ISwapRouterInternal[] routers, bool isSupported); constructor(address _admin, ISwapRouterInternal[] memory routers) BaseSwap(_admin) { for (uint256 i = 0; i < routers.length; i++) { uniRouters.add(address(routers[i])); } } struct StepComputations { // the price at the beginning of the step uint160 sqrtPriceStartX96; // the next tick to swap to from the current tick in the swap direction int24 tickNext; // whether tickNext is initialized or not bool initialized; // sqrt(price) for the next tick (1/0) uint160 sqrtPriceNextX96; // how much is being swapped in in this step uint256 amountIn; // how much is being swapped out uint256 amountOut; // how much fee is being paid in uint256 feeAmount; } struct SwapState { // the amount remaining to be swapped in/out of the input/output asset int256 amountSpecifiedRemaining; // the amount already swapped out/in of the output/input asset int256 amountCalculated; // current sqrt(price) uint160 sqrtPriceX96; // the tick associated with the current price int24 tick; // the current liquidity in range uint128 liquidity; } function getAllUniRouters() external view returns (address[] memory addresses) { uint256 length = uniRouters.length(); addresses = new address[](length); for (uint256 i = 0; i < length; i++) { addresses[i] = uniRouters.at(i); } } function updateUniRouters(ISwapRouterInternal[] calldata routers, bool isSupported) external onlyAdmin { for (uint256 i = 0; i < routers.length; i++) { if (isSupported) { uniRouters.add(address(routers[i])); } else { uniRouters.remove(address(routers[i])); } } emit UpdatedUniRouters(routers, isSupported); } /// @dev get expected return and conversion rate if using a Uni router function getExpectedReturn(GetExpectedReturnParams calldata params) external view override onlyProxyContract returns (uint256 destAmount) { require(params.tradePath.length >= 2, "invalid tradePath"); (ISwapRouterInternal router, uint24[] memory fees) = parseExtraArgs( params.tradePath.length - 1, params.extraArgs ); destAmount = params.srcAmount; for (uint256 i = 0; i < params.tradePath.length - 1; i++) { destAmount = getAmountOut( router, destAmount, params.tradePath[i], params.tradePath[i + 1], fees[i] ); } } /// @dev get expected return and conversion rate if using a Uni router function getExpectedReturnWithImpact(GetExpectedReturnParams calldata params) external view override onlyProxyContract returns (uint256 destAmount, uint256 priceImpact) { require(params.tradePath.length >= 2, "invalid tradePath"); (ISwapRouterInternal router, uint24[] memory fees) = parseExtraArgs( params.tradePath.length - 1, params.extraArgs ); destAmount = params.srcAmount; uint256 quote = params.srcAmount; for (uint256 i = 0; i < params.tradePath.length - 1; i++) { destAmount = getAmountOut( router, destAmount, params.tradePath[i], params.tradePath[i + 1], fees[i] ); quote = getQuote(router, quote, params.tradePath[i], params.tradePath[i + 1], fees[i]); } if (quote <= destAmount) { priceImpact = 0; } else { priceImpact = quote.sub(destAmount).mul(BPS) / quote; } } function getExpectedIn(GetExpectedInParams calldata params) external view override onlyProxyContract returns (uint256 srcAmount) { require(params.tradePath.length >= 2, "invalid tradePath"); (ISwapRouterInternal router, uint24[] memory fees) = parseExtraArgs( params.tradePath.length - 1, params.extraArgs ); srcAmount = params.destAmount; for (uint256 i = params.tradePath.length - 1; i > 0; i--) { srcAmount = getAmountIn( router, srcAmount, params.tradePath[i - 1], params.tradePath[i], fees[i - 1] ); } } function getExpectedInWithImpact(GetExpectedInParams calldata params) external view override onlyProxyContract returns (uint256 srcAmount, uint256 priceImpact) { require(params.tradePath.length >= 2, "invalid tradePath"); (ISwapRouterInternal router, uint24[] memory fees) = parseExtraArgs( params.tradePath.length - 1, params.extraArgs ); srcAmount = params.destAmount; for (uint256 i = params.tradePath.length - 1; i > 0; i--) { srcAmount = getAmountIn( router, srcAmount, params.tradePath[i - 1], params.tradePath[i], fees[i - 1] ); } uint256 quote = srcAmount; for (uint256 i = 0; i < params.tradePath.length - 1; i++) { quote = getQuote(router, quote, params.tradePath[i], params.tradePath[i + 1], fees[i]); } if (quote <= params.destAmount) { priceImpact = 0; } else { priceImpact = quote.sub(params.destAmount).mul(BPS) / quote; } } /// @dev swap token via a supported UniSwap router /// @notice for some tokens that are paying fee, for example: DGX /// contract will trade with received src token amount (after minus fee) /// for UniSwap, fee will be taken in src token function swap(SwapParams calldata params) external payable override onlyProxyContract returns (uint256 destAmount) { require(params.tradePath.length >= 2, "invalid tradePath"); (ISwapRouterInternal router, uint24[] memory fees) = parseExtraArgs( params.tradePath.length - 1, params.extraArgs ); safeApproveAllowance(address(router), IERC20Ext(params.tradePath[0])); destAmount = getBalance( IERC20Ext(params.tradePath[params.tradePath.length - 1]), params.recipient ); // actual swap if (params.tradePath.length == 2) { swapExactInputSingle( router, params.srcAmount, params.minDestAmount, params.tradePath, fees, params.recipient ); } else { swapExactInput( router, params.srcAmount, params.minDestAmount, params.tradePath, fees, params.recipient ); } destAmount = getBalance( IERC20Ext(params.tradePath[params.tradePath.length - 1]), params.recipient ).sub(destAmount); } function swapExactInput( ISwapRouterInternal router, uint256 srcAmount, uint256 minDestAmount, address[] calldata tradePath, uint24[] memory fees, address recipient ) internal { bytes memory path = abi.encodePacked(safeWrapToken(tradePath[0], router.WETH9())); for (uint256 i = 0; i < fees.length; i++) { path = abi.encodePacked( path, fees[i], safeWrapToken(tradePath[i + 1], router.WETH9()) ); } ISwapRouter.ExactInputParams memory swapData = ISwapRouter.ExactInputParams({ path: path, recipient: recipient, deadline: MAX_AMOUNT, amountIn: srcAmount, amountOutMinimum: minDestAmount }); if (tradePath[tradePath.length - 1] == address(ETH_TOKEN_ADDRESS)) { swapData.recipient = address(0); bytes[] memory multicallData = new bytes[](2); multicallData[0] = abi.encodeWithSelector( 0xc04b8d59, // exactInput swapData ); multicallData[1] = abi.encodeWithSelector( 0x49404b7c, // unwrapWETH9 minDestAmount, recipient ); router.multicall(multicallData); } else { router.exactInput{value: tradePath[0] == address(ETH_TOKEN_ADDRESS) ? srcAmount : 0}( swapData ); } } function swapExactInputSingle( ISwapRouterInternal router, uint256 srcAmount, uint256 minDestAmount, address[] memory tradePath, uint24[] memory fees, address recipient ) internal { ISwapRouter.ExactInputSingleParams memory swapData = ISwapRouter.ExactInputSingleParams({ tokenIn: safeWrapToken(tradePath[0], router.WETH9()), tokenOut: safeWrapToken(tradePath[1], router.WETH9()), fee: fees[0], recipient: recipient, deadline: MAX_AMOUNT, amountIn: srcAmount, amountOutMinimum: minDestAmount, sqrtPriceLimitX96: 0 }); if (tradePath[tradePath.length - 1] == address(ETH_TOKEN_ADDRESS)) { swapData.recipient = address(0); bytes[] memory multicallData = new bytes[](2); multicallData[0] = abi.encodeWithSelector( 0x414bf389, // exactInputSingle swapData ); multicallData[1] = abi.encodeWithSelector( 0x49404b7c, // unwrapWETH9 minDestAmount, recipient ); router.multicall(multicallData); } else { router.exactInputSingle{ value: tradePath[0] == address(ETH_TOKEN_ADDRESS) ? srcAmount : 0 }(swapData); } } /// @param extraArgs expecting <[20B] address router><[3B] uint24 poolFee1><[3B] uint24 poolFee2>... function parseExtraArgs(uint256 feeLength, bytes calldata extraArgs) internal view returns (ISwapRouterInternal router, uint24[] memory fees) { fees = new uint24[](feeLength); router = ISwapRouterInternal(extraArgs.toAddress(0)); for (uint256 i = 0; i < feeLength; i++) { fees[i] = extraArgs.toUint24(20 + i * 3); } require(router != ISwapRouterInternal(0), "invalid address"); require(uniRouters.contains(address(router)), "unsupported router"); } function getAmountOut( ISwapRouterInternal router, uint256 amountIn, address tokenIn, address tokenOut, uint24 fee ) private view returns (uint256 amountOut) { return getAmount(router, amountIn.toInt256(), tokenIn, tokenOut, fee); } function getAmountIn( ISwapRouterInternal router, uint256 amountOut, address tokenIn, address tokenOut, uint24 fee ) private view returns (uint256 amountIn) { return getAmount(router, -amountOut.toInt256(), tokenIn, tokenOut, fee); } function getAmount( ISwapRouterInternal router, int256 amountSpecified, address tokenIn, address tokenOut, uint24 fee ) private view returns (uint256 amountOut) { IUniswapV3Pool pool = IUniswapV3Pool( PoolAddress.computeAddress( router.factory(), PoolAddress.getPoolKey(tokenIn, tokenOut, fee) ) ); int24 tickSpacing = pool.tickSpacing(); // if tokenIn == tokenOut bool zeroForOne = tokenIn < tokenOut; uint160 sqrtPriceLimitX96 = zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1; SwapState memory state; state.amountSpecifiedRemaining = amountSpecified; state.amountCalculated = 0; (state.sqrtPriceX96, state.tick, , , , , ) = pool.slot0(); state.liquidity = pool.liquidity(); bool exactInput = amountSpecified > 0; while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) { StepComputations memory step; step.sqrtPriceStartX96 = state.sqrtPriceX96; (step.tickNext, step.initialized) = pool.nextInitializedTickWithinOneWord( state.tick, tickSpacing, zeroForOne ); if (step.tickNext < TickMath.MIN_TICK) { step.tickNext = TickMath.MIN_TICK; } else if (step.tickNext > TickMath.MAX_TICK) { step.tickNext = TickMath.MAX_TICK; } step.sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(step.tickNext); (state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath .computeSwapStep( state.sqrtPriceX96, ( zeroForOne ? step.sqrtPriceNextX96 < sqrtPriceLimitX96 : step.sqrtPriceNextX96 > sqrtPriceLimitX96 ) ? sqrtPriceLimitX96 : step.sqrtPriceNextX96, state.liquidity, state.amountSpecifiedRemaining, fee ); if (exactInput) { state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256(); state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256()); } else { state.amountSpecifiedRemaining += step.amountOut.toInt256(); state.amountCalculated = state.amountCalculated.add( (step.amountIn + step.feeAmount).toInt256() ); } if (state.sqrtPriceX96 == step.sqrtPriceNextX96) { if (step.initialized) { (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext); if (zeroForOne) liquidityNet = -liquidityNet; state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet); } state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext; } else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) { // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96); } } if (state.amountCalculated < 0) { return uint256(-state.amountCalculated); } return uint256(state.amountCalculated); } function getQuote( ISwapRouterInternal router, uint256 quote, address tokenIn, address tokenOut, uint24 fee ) internal view returns (uint256 quoteOut) { IUniswapV3Pool pool = IUniswapV3Pool( PoolAddress.computeAddress( router.factory(), PoolAddress.getPoolKey(tokenIn, tokenOut, fee) ) ); // if tokenIn == tokenOut bool zeroForOne = tokenIn < tokenOut; SwapState memory state; (state.sqrtPriceX96, state.tick, , , , , ) = pool.slot0(); uint160 sqrtPriceX96 = zeroForOne ? state.sqrtPriceX96 : TickMath.getSqrtRatioAtTick(-state.tick); quoteOut = quote.mul(sqrtPriceX96) >> 96; quoteOut = quoteOut.mul(sqrtPriceX96) >> 96; } function safeWrapToken(address token, address wrappedToken) internal pure returns (address) { return token == address(ETH_TOKEN_ADDRESS) ? wrappedToken : token; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "@kyber.network/utils-sc/contracts/Withdrawable.sol"; import "@kyber.network/utils-sc/contracts/Utils.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./ISwap.sol"; abstract contract BaseSwap is ISwap, Withdrawable, Utils { using SafeERC20 for IERC20Ext; using SafeMath for uint256; uint256 internal constant MAX_AMOUNT = type(uint256).max; address public proxyContract; event UpdatedproxyContract(address indexed _oldProxyImpl, address indexed _newProxyImpl); modifier onlyProxyContract() { require(msg.sender == proxyContract, "only swap impl"); _; } constructor(address _admin) Withdrawable(_admin) {} receive() external payable {} function updateProxyContract(address _proxyContract) external onlyAdmin { require(_proxyContract != address(0), "invalid swap impl"); emit UpdatedproxyContract(proxyContract, _proxyContract); proxyContract = _proxyContract; } // Swap contracts don't keep funds. It's safe to set the max allowance function safeApproveAllowance(address spender, IERC20Ext token) internal { if (token != ETH_TOKEN_ADDRESS && token.allowance(address(this), spender) == 0) { token.safeApprove(spender, MAX_ALLOWANCE); } } }
pragma solidity 0.7.6; library BytesLib { function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_start + 20 >= _start, "toAddress_overflow"); require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { require(_start + 3 >= _start, "toUint24_overflow"); require(_bytes.length >= _start + 3, "toUint24_outOfBounds"); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_start + 32 >= _start, "toUint256_overflow"); require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.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 IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; 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)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ 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)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @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. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @dev Interface extending ERC20 standard to include decimals() as * it is optional in the OpenZeppelin IERC20 interface. */ interface IERC20Ext is IERC20 { /** * @dev This function is required as Kyber requires to interact * with token.decimals() with many of its operations. */ function decimals() external view returns (uint8 digits); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { 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); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Multicall interface /// @notice Enables calling multiple methods in a single call to the contract interface IMulticall { /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed /// @dev The `msg.value` should not be trusted for any method callable from multicall. /// @param data The encoded function data for each of the calls to make to this contract /// @return results The results from each of the calls passed in via data function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @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); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title BitMath /// @dev This library provides functionality for computing bit properties of an unsigned integer library BitMath { /// @notice Returns the index of the most significant bit of the number, /// where the least significant bit is at index 0 and the most significant bit is at index 255 /// @dev The function satisfies the property: /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1) /// @param x the value for which to compute the most significant bit, must be greater than 0 /// @return r the index of the most significant bit function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } /// @notice Returns the index of the least significant bit of the number, /// where the least significant bit is at index 0 and the most significant bit is at index 255 /// @dev The function satisfies the property: /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0) /// @param x the value for which to compute the least significant bit, must be greater than 0 /// @return r the index of the least significant bit function leastSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0); r = 255; if (x & type(uint128).max > 0) { r -= 128; } else { x >>= 128; } if (x & type(uint64).max > 0) { r -= 64; } else { x >>= 64; } if (x & type(uint32).max > 0) { r -= 32; } else { x >>= 32; } if (x & type(uint16).max > 0) { r -= 16; } else { x >>= 16; } if (x & type(uint8).max > 0) { r -= 8; } else { x >>= 8; } if (x & 0xf > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import './FullMath.sol'; import './SqrtPriceMath.sol'; /// @title Computes the result of a swap within ticks /// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick. library SwapMath { /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive /// @param sqrtRatioCurrentX96 The current sqrt price of the pool /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred /// @param liquidity The usable liquidity /// @param amountRemaining How much input or output amount is remaining to be swapped in/out /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap /// @return feeAmount The amount of input that will be taken as a fee function computeSwapStep( uint160 sqrtRatioCurrentX96, uint160 sqrtRatioTargetX96, uint128 liquidity, int256 amountRemaining, uint24 feePips ) internal pure returns ( uint160 sqrtRatioNextX96, uint256 amountIn, uint256 amountOut, uint256 feeAmount ) { bool zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96; bool exactIn = amountRemaining >= 0; if (exactIn) { uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6); amountIn = zeroForOne ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true) : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true); if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96; else sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput( sqrtRatioCurrentX96, liquidity, amountRemainingLessFee, zeroForOne ); } else { amountOut = zeroForOne ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false) : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false); if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96; else sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput( sqrtRatioCurrentX96, liquidity, uint256(-amountRemaining), zeroForOne ); } bool max = sqrtRatioTargetX96 == sqrtRatioNextX96; // get the input/output amounts if (zeroForOne) { amountIn = max && exactIn ? amountIn : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true); amountOut = max && !exactIn ? amountOut : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false); } else { amountIn = max && exactIn ? amountIn : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true); amountOut = max && !exactIn ? amountOut : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false); } // cap the output amount to not exceed the remaining output amount if (!exactIn && amountOut > uint256(-amountRemaining)) { amountOut = uint256(-amountRemaining); } if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) { // we didn't reach the target, so take the remainder of the maximum input as fee feeAmount = uint256(amountRemaining) - amountIn; } else { feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for liquidity library LiquidityMath { /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows /// @param x The liquidity before change /// @param y The delta by which liquidity should be changed /// @return z The liquidity delta function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) { if (y < 0) { require((z = x - uint128(-y)) < x, 'LS'); } else { require((z = x + uint128(y)) >= x, 'LA'); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./IERC20Ext.sol"; import "./PermissionAdmin.sol"; abstract contract Withdrawable is PermissionAdmin { using SafeERC20 for IERC20Ext; event TokenWithdraw(IERC20Ext token, uint256 amount, address sendTo); event EtherWithdraw(uint256 amount, address sendTo); constructor(address _admin) PermissionAdmin(_admin) {} /** * @dev Withdraw all IERC20Ext compatible tokens * @param token IERC20Ext The address of the token contract */ function withdrawToken( IERC20Ext token, uint256 amount, address sendTo ) external onlyAdmin { token.safeTransfer(sendTo, amount); emit TokenWithdraw(token, amount, sendTo); } /** * @dev Withdraw Ethers */ function withdrawEther(uint256 amount, address payable sendTo) external onlyAdmin { (bool success, ) = sendTo.call{value: amount}(""); require(success, "withdraw failed"); emit EtherWithdraw(amount, sendTo); } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "./IERC20Ext.sol"; /** * @title Kyber utility file * mostly shared constants and rate calculation helpers * inherited by most of kyber contracts. * previous utils implementations are for previous solidity versions. */ abstract contract Utils { // Declared constants below to be used in tandem with // getDecimalsConstant(), for gas optimization purposes // which return decimals from a constant list of popular // tokens. IERC20Ext internal constant ETH_TOKEN_ADDRESS = IERC20Ext( 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ); IERC20Ext internal constant USDT_TOKEN_ADDRESS = IERC20Ext( 0xdAC17F958D2ee523a2206206994597C13D831ec7 ); IERC20Ext internal constant DAI_TOKEN_ADDRESS = IERC20Ext( 0x6B175474E89094C44Da98b954EedeAC495271d0F ); IERC20Ext internal constant USDC_TOKEN_ADDRESS = IERC20Ext( 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 ); IERC20Ext internal constant WBTC_TOKEN_ADDRESS = IERC20Ext( 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599 ); IERC20Ext internal constant KNC_TOKEN_ADDRESS = IERC20Ext( 0xdd974D5C2e2928deA5F71b9825b8b646686BD200 ); uint256 public constant BPS = 10000; // Basic Price Steps. 1 step = 0.01% uint256 internal constant PRECISION = (10**18); uint256 internal constant MAX_QTY = (10**28); // 10B tokens uint256 internal constant MAX_RATE = (PRECISION * 10**7); // up to 10M tokens per eth uint256 internal constant MAX_DECIMALS = 18; uint256 internal constant ETH_DECIMALS = 18; uint256 internal constant MAX_ALLOWANCE = uint256(-1); // token.approve inifinite mapping(IERC20Ext => uint256) internal decimals; /// @dev Sets the decimals of a token to storage if not already set, and returns /// the decimals value of the token. Prefer using this function over /// getDecimals(), to avoid forgetting to set decimals in local storage. /// @param token The token type /// @return tokenDecimals The decimals of the token function getSetDecimals(IERC20Ext token) internal returns (uint256 tokenDecimals) { tokenDecimals = getDecimalsConstant(token); if (tokenDecimals > 0) return tokenDecimals; tokenDecimals = decimals[token]; if (tokenDecimals == 0) { tokenDecimals = token.decimals(); decimals[token] = tokenDecimals; } } /// @dev Get the balance of a user /// @param token The token type /// @param user The user's address /// @return The balance function getBalance(IERC20Ext token, address user) internal view returns (uint256) { if (token == ETH_TOKEN_ADDRESS) { return user.balance; } else { return token.balanceOf(user); } } /// @dev Get the decimals of a token, read from the constant list, storage, /// or from token.decimals(). Prefer using getSetDecimals when possible. /// @param token The token type /// @return tokenDecimals The decimals of the token function getDecimals(IERC20Ext token) internal view returns (uint256 tokenDecimals) { // return token decimals if has constant value tokenDecimals = getDecimalsConstant(token); if (tokenDecimals > 0) return tokenDecimals; // handle case where token decimals is not a declared decimal constant tokenDecimals = decimals[token]; // moreover, very possible that old tokens have decimals 0 // these tokens will just have higher gas fees. return (tokenDecimals > 0) ? tokenDecimals : token.decimals(); } function calcDestAmount( IERC20Ext src, IERC20Ext dest, uint256 srcAmount, uint256 rate ) internal view returns (uint256) { return calcDstQty(srcAmount, getDecimals(src), getDecimals(dest), rate); } function calcSrcAmount( IERC20Ext src, IERC20Ext dest, uint256 destAmount, uint256 rate ) internal view returns (uint256) { return calcSrcQty(destAmount, getDecimals(src), getDecimals(dest), rate); } function calcDstQty( uint256 srcQty, uint256 srcDecimals, uint256 dstDecimals, uint256 rate ) internal pure returns (uint256) { require(srcQty <= MAX_QTY, "srcQty > MAX_QTY"); require(rate <= MAX_RATE, "rate > MAX_RATE"); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION; } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals))); } } function calcSrcQty( uint256 dstQty, uint256 srcDecimals, uint256 dstDecimals, uint256 rate ) internal pure returns (uint256) { require(dstQty <= MAX_QTY, "dstQty > MAX_QTY"); require(rate <= MAX_RATE, "rate > MAX_RATE"); //source quantity is rounded up. to avoid dest quantity being too low. uint256 numerator; uint256 denominator; if (srcDecimals >= dstDecimals) { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals))); denominator = rate; } else { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); numerator = (PRECISION * dstQty); denominator = (rate * (10**(dstDecimals - srcDecimals))); } return (numerator + denominator - 1) / denominator; //avoid rounding down errors } function calcRateFromQty( uint256 srcAmount, uint256 destAmount, uint256 srcDecimals, uint256 dstDecimals ) internal pure returns (uint256) { require(srcAmount <= MAX_QTY, "srcAmount > MAX_QTY"); require(destAmount <= MAX_QTY, "destAmount > MAX_QTY"); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); return ((destAmount * PRECISION) / ((10**(dstDecimals - srcDecimals)) * srcAmount)); } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); return ((destAmount * PRECISION * (10**(srcDecimals - dstDecimals))) / srcAmount); } } /// @dev save storage access by declaring token decimal constants /// @param token The token type /// @return token decimals function getDecimalsConstant(IERC20Ext token) internal pure returns (uint256) { if (token == ETH_TOKEN_ADDRESS) { return ETH_DECIMALS; } else if (token == USDT_TOKEN_ADDRESS) { return 6; } else if (token == DAI_TOKEN_ADDRESS) { return 18; } else if (token == USDC_TOKEN_ADDRESS) { return 6; } else if (token == WBTC_TOKEN_ADDRESS) { return 8; } else if (token == KNC_TOKEN_ADDRESS) { return 18; } else { return 0; } } function minOf(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? y : x; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; interface ISwap { struct GetExpectedReturnParams { uint256 srcAmount; address[] tradePath; uint256 feeBps; bytes extraArgs; } function getExpectedReturn(GetExpectedReturnParams calldata params) external view returns (uint256 destAmount); function getExpectedReturnWithImpact(GetExpectedReturnParams calldata params) external view returns (uint256 destAmount, uint256 priceImpact); struct GetExpectedInParams { uint256 destAmount; address[] tradePath; uint256 feeBps; bytes extraArgs; } function getExpectedIn(GetExpectedInParams calldata params) external view returns (uint256 srcAmount); function getExpectedInWithImpact(GetExpectedInParams calldata params) external view returns (uint256 srcAmount, uint256 priceImpact); struct SwapParams { uint256 srcAmount; uint256 minDestAmount; address[] tradePath; address recipient; uint256 feeBps; address payable feeReceiver; bytes extraArgs; } function swap(SwapParams calldata params) external payable returns (uint256 destAmount); }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; abstract contract PermissionAdmin { address public admin; address public pendingAdmin; event AdminClaimed(address newAdmin, address previousAdmin); event TransferAdminPending(address pendingAdmin); constructor(address _admin) { require(_admin != address(0), "admin 0"); admin = _admin; } modifier onlyAdmin() { require(msg.sender == admin, "only admin"); _; } /** * @dev Allows the current admin to set the pendingAdmin address. * @param newAdmin The address to transfer ownership to. */ function transferAdmin(address newAdmin) public onlyAdmin { require(newAdmin != address(0), "new admin 0"); emit TransferAdminPending(newAdmin); pendingAdmin = newAdmin; } /** * @dev Allows the current admin to set the admin in one tx. Useful initial deployment. * @param newAdmin The address to transfer ownership to. */ function transferAdminQuickly(address newAdmin) public onlyAdmin { require(newAdmin != address(0), "admin 0"); emit TransferAdminPending(newAdmin); emit AdminClaimed(newAdmin, admin); admin = newAdmin; } /** * @dev Allows the pendingAdmin address to finalize the change admin process. */ function claimAdmin() public { require(pendingAdmin == msg.sender, "not pending"); emit AdminClaimed(pendingAdmin, admin); admin = pendingAdmin; pendingAdmin = address(0); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @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); /** * @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); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ 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) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { 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) { // 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) { 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) { 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) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); 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) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @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. 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) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); 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) { require(b > 0, "SafeMath: modulo by zero"); 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) { 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. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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) { 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) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @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); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @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 fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: MIT pragma solidity >=0.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import './LowGasSafeMath.sol'; import './SafeCast.sol'; import './FullMath.sol'; import './UnsafeMath.sol'; import './FixedPoint96.sol'; /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMath { using LowGasSafeMath for uint256; using SafeCast for uint256; /// @notice Gets the next sqrt price given a delta of token0 /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the /// price less in order to not send too much output. /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token0 to add or remove from virtual reserves /// @param add Whether to add or remove the amount of token0 /// @return The price after adding or removing amount, depending on add function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price if (amount == 0) return sqrtPX96; uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; if (add) { uint256 product; if ((product = amount * sqrtPX96) / amount == sqrtPX96) { uint256 denominator = numerator1 + product; if (denominator >= numerator1) // always fits in 160 bits return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator)); } return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount))); } else { uint256 product; // if the product overflows, we know the denominator underflows // in addition, we must check that the denominator does not underflow require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); uint256 denominator = numerator1 - product; return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160(); } } /// @notice Gets the next sqrt price given a delta of token1 /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the /// price less in order to not send too much output. /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token1 to add, or remove, from virtual reserves /// @param add Whether to add, or remove, the amount of token1 /// @return The price after adding or removing `amount` function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // if we're adding (subtracting), rounding down requires rounding the quotient down (up) // in both cases, avoid a mulDiv for most inputs if (add) { uint256 quotient = ( amount <= type(uint160).max ? (amount << FixedPoint96.RESOLUTION) / liquidity : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity) ); return uint256(sqrtPX96).add(quotient).toUint160(); } else { uint256 quotient = ( amount <= type(uint160).max ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity) : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity) ); require(sqrtPX96 > quotient); // always fits 160 bits return uint160(sqrtPX96 - quotient); } } /// @notice Gets the next sqrt price given an input amount of token0 or token1 /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount /// @param liquidity The amount of usable liquidity /// @param amountIn How much of token0, or token1, is being swapped in /// @param zeroForOne Whether the amount in is token0 or token1 /// @return sqrtQX96 The price after adding the input amount to token0 or token1 function getNextSqrtPriceFromInput( uint160 sqrtPX96, uint128 liquidity, uint256 amountIn, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we don't pass the target price return zeroForOne ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true) : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true); } /// @notice Gets the next sqrt price given an output amount of token0 or token1 /// @dev Throws if price or liquidity are 0 or the next price is out of bounds /// @param sqrtPX96 The starting price before accounting for the output amount /// @param liquidity The amount of usable liquidity /// @param amountOut How much of token0, or token1, is being swapped out /// @param zeroForOne Whether the amount out is token0 or token1 /// @return sqrtQX96 The price after removing the output amount of token0 or token1 function getNextSqrtPriceFromOutput( uint160 sqrtPX96, uint128 liquidity, uint256 amountOut, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we pass the target price return zeroForOne ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false) : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false); } /// @notice Gets the amount0 delta between two prices /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up or down /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96; require(sqrtRatioAX96 > 0); return roundUp ? UnsafeMath.divRoundingUp( FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96 ) : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96; } /// @notice Gets the amount1 delta between two prices /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up, or down /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return roundUp ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96) : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Helper that gets signed token0 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount0 delta /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount0) { return liquidity < 0 ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } /// @notice Helper that gets signed token1 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount1 delta /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount1) { return liquidity < 0 ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.0; /// @title Optimized overflow and underflow safe math operations /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost library LowGasSafeMath { /// @notice Returns x + y, reverts if sum overflows uint256 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x + y, reverts if overflows or underflows /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(int256 x, int256 y) internal pure returns (int256 z) { require((z = x + y) >= x == (y >= 0)); } /// @notice Returns x - y, reverts if overflows or underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(int256 x, int256 y) internal pure returns (int256 z) { require((z = x - y) <= x == (y >= 0)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
{ "optimizer": { "enabled": true, "runs": 780 }, "metadata": { "bytecodeHash": "none" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"contract ISwapRouterInternal[]","name":"routers","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"}],"name":"AdminClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"EtherWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20Ext","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"TokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pendingAdmin","type":"address"}],"name":"TransferAdminPending","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ISwapRouterInternal[]","name":"routers","type":"address[]"},{"indexed":false,"internalType":"bool","name":"isSupported","type":"bool"}],"name":"UpdatedUniRouters","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_oldProxyImpl","type":"address"},{"indexed":true,"internalType":"address","name":"_newProxyImpl","type":"address"}],"name":"UpdatedproxyContract","type":"event"},{"inputs":[],"name":"BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllUniRouters","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISwap.GetExpectedInParams","name":"params","type":"tuple"}],"name":"getExpectedIn","outputs":[{"internalType":"uint256","name":"srcAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISwap.GetExpectedInParams","name":"params","type":"tuple"}],"name":"getExpectedInWithImpact","outputs":[{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"priceImpact","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISwap.GetExpectedReturnParams","name":"params","type":"tuple"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISwap.GetExpectedReturnParams","name":"params","type":"tuple"}],"name":"getExpectedReturnWithImpact","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"uint256","name":"priceImpact","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxyContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"minDestAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"address payable","name":"feeReceiver","type":"address"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISwap.SwapParams","name":"params","type":"tuple"}],"name":"swap","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdminQuickly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_proxyContract","type":"address"}],"name":"updateProxyContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwapRouterInternal[]","name":"routers","type":"address[]"},{"internalType":"bool","name":"isSupported","type":"bool"}],"name":"updateUniRouters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"sendTo","type":"address"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Ext","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"sendTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162004c4e38038062004c4e833981016040819052620000349162000186565b8180806001600160a01b0381166200007d576040805162461bcd60e51b8152602060048201526007602482015266061646d696e20360cc1b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b03929092169190911781559150505b8151811015620000e457620000da828281518110620000bc57fe5b60200260200101516004620000ed60201b6200127c1790919060201c565b50600101620000a1565b50505062000276565b600062000104836001600160a01b0384166200010d565b90505b92915050565b60006200011b83836200015c565b620001535750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000107565b50600062000107565b60009081526001919091016020526040902054151590565b805162000181816200025d565b919050565b6000806040838503121562000199578182fd5b8251620001a6816200025d565b602084810151919350906001600160401b0380821115620001c5578384fd5b818601915086601f830112620001d9578384fd5b815181811115620001e657fe5b838102604051858282010181811085821117156200020057fe5b604052828152858101935084860182860187018b10156200021f578788fd5b8795505b838610156200024c57620002378162000174565b85526001959095019493860193860162000223565b508096505050505050509250929050565b6001600160a01b03811681146200027357600080fd5b50565b6149c880620002866000396000f3fe6080604052600436106101125760003560e01c806368aa6dd9116100a5578063ce56c45411610074578063e19b609d11610059578063e19b609d146102e5578063ed55044314610305578063f851a4401461031a57610119565b8063ce56c454146102a5578063d6ba0bfc146102c557610119565b806368aa6dd91461023d57806375829def1461025057806377f50f97146102705780637acc86781461028557610119565b80633ccdbb28116100e15780633ccdbb28146101bb57806343bea4b3146101db5780634582d279146101fb5780634db1d03d1461021d57610119565b806305a727091461011e5780631373524614610155578063249d39e914610177578063267822471461019957610119565b3661011957005b600080fd5b34801561012a57600080fd5b5061013e6101393660046141fb565b61032f565b60405161014c9291906147f8565b60405180910390f35b34801561016157600080fd5b5061017561017036600461400f565b61054e565b005b34801561018357600080fd5b5061018c61061c565b60405161014c91906147d8565b3480156101a557600080fd5b506101ae610622565b60405161014c91906144ad565b3480156101c757600080fd5b506101756101d63660046141ab565b610631565b3480156101e757600080fd5b5061018c6101f63660046141fb565b6106e0565b34801561020757600080fd5b50610210610814565b60405161014c91906144db565b34801561022957600080fd5b5061018c6102383660046141fb565b6108af565b61018c61024b36600461422e565b610992565b34801561025c57600080fd5b5061017561026b36600461400f565b610bb5565b34801561027c57600080fd5b50610175610cba565b34801561029157600080fd5b506101756102a036600461400f565b610d8c565b3480156102b157600080fd5b506101756102c03660046143d1565b610ed9565b3480156102d157600080fd5b506101756102e036600461412b565b611013565b3480156102f157600080fd5b5061013e6103003660046141fb565b611119565b34801561031157600080fd5b506101ae61125e565b34801561032657600080fd5b506101ae61126d565b60035460009081906001600160a01b031633146103675760405162461bcd60e51b815260040161035e906146d9565b60405180910390fd5b60026103766020850185614806565b905010156103965760405162461bcd60e51b815260040161035e906146a2565b6000806103c360016103ab6020880188614806565b9050038680606001906103be9190614854565b61129a565b863595509092509050600060016103dd6020880188614806565b90500390505b80156104705761046583866103fb60208a018a614806565b6001860381811061040857fe5b905060200201602081019061041d919061400f565b61042a60208b018b614806565b8681811061043457fe5b9050602002016020810190610449919061400f565b86600187038151811061045857fe5b60200260200101516113fa565b9450600019016103e3565b508360005b60016104846020890189614806565b9050038110156105115761050784836104a060208b018b614806565b858181106104aa57fe5b90506020020160208101906104bf919061400f565b6104cc60208c018c614806565b866001018181106104d957fe5b90506020020160208101906104ee919061400f565b8786815181106104fa57fe5b6020026020010151611420565b9150600101610475565b50853581116105235760009350610546565b8061053b612710610535838a356115b2565b906115c2565b8161054257fe5b0493505b505050915091565b6000546001600160a01b0316331461059a576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b0381166105c05760405162461bcd60e51b815260040161035e906145fd565b6003546040516001600160a01b038084169216907f7c5d026310440df4ec67ef47368cd26898f9dbec4b95934dbbc4a3d9d46c49a990600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b61271081565b6001546001600160a01b031681565b6000546001600160a01b0316331461067d576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6106916001600160a01b03841682846115e6565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b6003546000906001600160a01b0316331461070d5760405162461bcd60e51b815260040161035e906146d9565b600261071c6020840184614806565b9050101561073c5760405162461bcd60e51b815260040161035e906146a2565b60008061076460016107516020870187614806565b9050038580606001906103be9190614854565b85359450909250905060005b600161077f6020870187614806565b90500381101561080c57610802838561079b6020890189614806565b858181106107a557fe5b90506020020160208101906107ba919061400f565b6107c760208a018a614806565b866001018181106107d457fe5b90506020020160208101906107e9919061400f565b8686815181106107f557fe5b602002602001015161163d565b9350600101610770565b505050919050565b606060006108226004611654565b90508067ffffffffffffffff8111801561083b57600080fd5b50604051908082528060200260200182016040528015610865578160200160208202803683370190505b50915060005b818110156108aa5761087e600482611667565b83828151811061088a57fe5b6001600160a01b039092166020928302919091019091015260010161086b565b505090565b6003546000906001600160a01b031633146108dc5760405162461bcd60e51b815260040161035e906146d9565b60026108eb6020840184614806565b9050101561090b5760405162461bcd60e51b815260040161035e906146a2565b60008061092060016107516020870187614806565b8535945090925090506000600161093a6020870187614806565b90500390505b801561080c5761098783856109586020890189614806565b6001860381811061096557fe5b905060200201602081019061097a919061400f565b61042a60208a018a614806565b935060001901610940565b6003546000906001600160a01b031633146109bf5760405162461bcd60e51b815260040161035e906146d9565b60026109ce6040840184614806565b905010156109ee5760405162461bcd60e51b815260040161035e906146a2565b600080610a166001610a036040870187614806565b905003858060c001906103be9190614854565b9092509050610a5182610a2c6040870187614806565b6000818110610a3757fe5b9050602002016020810190610a4c919061400f565b611673565b610aa6610a616040860186614806565b6001610a706040890189614806565b905003818110610a7c57fe5b9050602002016020810190610a91919061400f565b610aa1608087016060880161400f565b61173a565b9250610ab56040850185614806565b905060021415610b2557610b208285356020870135610ad76040890189614806565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250889250610b1b91505060808b0160608c0161400f565b6117f2565b610b53565b610b538285356020870135610b3d6040890189614806565b86610b4e60808c0160608d0161400f565b611b99565b610bad83610ba7610b676040880188614806565b6001610b7660408b018b614806565b905003818110610b8257fe5b9050602002016020810190610b97919061400f565b610aa16080890160608a0161400f565b906115b2565b949350505050565b6000546001600160a01b03163314610c01576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610c5c576040805162461bcd60e51b815260206004820152600b60248201527f6e65772061646d696e2030000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610d19576040805162461bcd60e51b815260206004820152600b60248201527f6e6f742070656e64696e67000000000000000000000000000000000000000000604482015290519081900360640190fd5b600154600054604080516001600160a01b03938416815292909116602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000546001600160a01b03163314610dd8576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610e33576040805162461bcd60e51b815260206004820152600760248201527f61646d696e203000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600054604080516001600160a01b038085168252909216602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a1600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610f25576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d8060008114610f70576040519150601f19603f3d011682016040523d82523d6000602084013e610f75565b606091505b5050905080610fcb576040805162461bcd60e51b815260206004820152600f60248201527f7769746864726177206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b6000546001600160a01b0316331461105f576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b60005b828110156110d85781156110a25761109c84848381811061107f57fe5b9050602002016020810190611094919061400f565b60049061127c565b506110d0565b6110ce8484838181106110b157fe5b90506020020160208101906110c6919061400f565b600490611f91565b505b600101611062565b507f56f34eb6bd4451b93fcc586e59d7ca42dba8fdb9fc157152eb3b4d0cf190b2c283838360405161110c93929190614588565b60405180910390a1505050565b60035460009081906001600160a01b031633146111485760405162461bcd60e51b815260040161035e906146d9565b60026111576020850185614806565b905010156111775760405162461bcd60e51b815260040161035e906146a2565b60008061118c60016103ab6020880188614806565b8635955090925090508360005b60016111a86020890189614806565b90500381101561123c5761121e84876111c460208b018b614806565b858181106111ce57fe5b90506020020160208101906111e3919061400f565b6111f060208c018c614806565b866001018181106111fd57fe5b9050602002016020810190611212919061400f565b8786815181106107f557fe5b955061123284836104a060208b018b614806565b9150600101611199565b5084811161124d5760009350610546565b8061053b61271061053583896115b2565b6003546001600160a01b031681565b6000546001600160a01b031681565b6000611291836001600160a01b038416611fa6565b90505b92915050565b600060608467ffffffffffffffff811180156112b557600080fd5b506040519080825280602002602001820160405280156112df578160200160208202803683370190505b509050611326600085858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509293925050611ff09050565b915060005b858110156113a45761137c8160030260140186868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506120b39050565b82828151811061138857fe5b62ffffff9092166020928302919091019091015260010161132b565b506001600160a01b0382166113cb5760405162461bcd60e51b815260040161035e90614634565b6113d660048361216f565b6113f25760405162461bcd60e51b815260040161035e9061466b565b935093915050565b60006114148661140987612184565b60000386868661219a565b90505b95945050505050565b6000806114a7876001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561145f57600080fd5b505afa158015611473573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611497919061402b565b6114a28787876126fc565b61275e565b90506001600160a01b03808516908616106114c0613f2e565b826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156114f957600080fd5b505afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115319190614326565b5050505050600290810b900b60608301526001600160a01b0316604082015260008261156c57611567826060015160000361285a565b611572565b81604001515b905060606115898a6001600160a01b0384166115c2565b901c945060606115a2866001600160a01b0384166115c2565b901c9a9950505050505050505050565b8082038281111561129457600080fd5b60008215806115dd575050818102818382816115da57fe5b04145b61129457600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611638908490612b8c565b505050565b60006114148661164c87612184565b86868661219a565b600061165f82612c3d565b90505b919050565b60006112918383612c41565b6001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1480159061171b5750604051636eb1769f60e11b81526001600160a01b0382169063dd62ed3e906116c990309086906004016144c1565b60206040518083038186803b1580156116e157600080fd5b505afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171991906143b9565b155b15611736576117366001600160a01b03821683600019612ca5565b5050565b60006001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561177257506001600160a01b03811631611294565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d60208110156117e957600080fd5b50519050611294565b600060405180610100016040528061188e8660008151811061181057fe5b60200260200101518a6001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b505afa158015611865573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611889919061402b565b612db8565b6001600160a01b031681526020016118ac8660018151811061181057fe5b6001600160a01b03168152602001846000815181106118c757fe5b602002602001015162ffffff168152602001836001600160a01b03168152602001600019815260200187815260200186815260200160006001600160a01b0316815250905073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03168460018651038151811061193a57fe5b60200260200101516001600160a01b03161415611ac6576000606082810182905260408051600280825292810190915290816020015b606081526020019060019003908161197057905050905063414bf3898260405160240161199d9190614769565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050816000815181106119d657fe5b60200260200101819052506349404b7c86846040516024016119f99291906147e1565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600181518110611a3257fe5b6020908102919091010152604051631592ca1b60e31b81526001600160a01b0389169063ac9650d890611a69908490600401614528565b600060405180830381600087803b158015611a8357600080fd5b505af1158015611a97573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611abf9190810190614047565b5050611b90565b866001600160a01b031663414bf38973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031686600081518110611b0057fe5b60200260200101516001600160a01b031614611b1d576000611b1f565b875b836040518363ffffffff1660e01b8152600401611b3c9190614769565b6020604051808303818588803b158015611b5557600080fd5b505af1158015611b69573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611b8e91906143b9565b505b50505050505050565b6000611bf985856000818110611bab57fe5b9050602002016020810190611bc0919061400f565b896001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b604051602001611c09919061442c565b604051602081830303815290604052905060005b8351811015611cc75781848281518110611c3357fe5b6020026020010151611c9b888885600101818110611c4d57fe5b9050602002016020810190611c62919061400f565b8c6001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b604051602001611cad93929190614449565b60408051601f198184030181529190529150600101611c1d565b506040805160a0810182528281526001600160a01b038416602082015260001991810182905260608101899052608081018890529073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90879087908101818110611d2157fe5b9050602002016020810190611d36919061400f565b6001600160a01b03161415611eba576000602082018190526040805160028082526060820190925290816020015b6060815260200190600190039081611d6457905050905063c04b8d5982604051602401611d919190614710565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600081518110611dca57fe5b60200260200101819052506349404b7c8885604051602401611ded9291906147e1565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600181518110611e2657fe5b6020908102919091010152604051631592ca1b60e31b81526001600160a01b038b169063ac9650d890611e5d908490600401614528565b600060405180830381600087803b158015611e7757600080fd5b505af1158015611e8b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eb39190810190614047565b5050611f86565b6001600160a01b03891663c04b8d5973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8888600081611ee957fe5b9050602002016020810190611efe919061400f565b6001600160a01b031614611f13576000611f15565b895b836040518363ffffffff1660e01b8152600401611f329190614710565b6020604051808303818588803b158015611f4b57600080fd5b505af1158015611f5f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f8491906143b9565b505b505050505050505050565b6000611291836001600160a01b038416612dea565b6000611fb28383612eb0565b611fe857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611294565b506000611294565b60008182601401101561204a576040805162461bcd60e51b815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b81601401835110156120a3576040805162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b500160200151600160601b900490565b60008182600301101561210d576040805162461bcd60e51b815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015612166576040805162461bcd60e51b815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b6000611291836001600160a01b038416612eb0565b6000600160ff1b821061219657600080fd5b5090565b6000806121d9876001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561145f57600080fd5b90506000816001600160a01b031663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561221657600080fd5b505afa15801561222a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224e91906141e1565b90506001600160a01b03808616908716106000816122805773fffd8963efd1fc6a506488495d951d5263988d25612287565b6401000276a45b9050612291613f2e565b8981526000602082015260408051633850c7bd60e01b815290516001600160a01b03871691633850c7bd9160048083019260e0929190829003018186803b1580156122db57600080fd5b505afa1580156122ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123139190614326565b5050505050600290810b900b60608301526001600160a01b039081166040808401919091528051630d34328160e11b8152905191871691631a68650291600480820192602092909190829003018186803b15801561237057600080fd5b505afa158015612384573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a89190614266565b6001600160801b0316608082015260008a135b8151158015906123e15750826001600160a01b031682604001516001600160a01b031614155b156126c8576123ee613f5c565b60408301516001600160a01b0390811682526060840151612413918916908888612ec8565b15156040830152600290810b810b60208301819052620d89e719910b121561244457620d89e7196020820152612463565b6020810151620d89e860029190910b131561246357620d89e860208201525b612470816020015161285a565b6001600160a01b0316606082015260408301516124e190866124aa57856001600160a01b031683606001516001600160a01b0316116124c4565b856001600160a01b031683606001516001600160a01b0316105b6124d25782606001516124d4565b855b608086015186518d6130d4565b60c085015260a084015260808301526001600160a01b031660408401528115612543576125178160c00151826080015101612184565b835103835260a08101516125399061252e90612184565b6020850151906132c6565b602084015261257e565b6125508160a00151612184565b835101835260c081015160808201516125789161256d9101612184565b6020850151906132dc565b60208401525b80606001516001600160a01b031683604001516001600160a01b031614156126875780604001511561265e57602081015160405163f30dba9360e01b81526000916001600160a01b038a169163f30dba93916125dc916004016145ef565b6101006040518083038186803b1580156125f557600080fd5b505afa158015612609573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262d9190614280565b5050505050509150508515612640576000035b61264e8460800151826132f2565b6001600160801b03166080850152505b8461266d578060200151612676565b60018160200151035b600290810b900b60608401526126c2565b80600001516001600160a01b031683604001516001600160a01b0316146126c2576126b583604001516133a8565b600290810b900b60608401525b506123bb565b6000826020015112156126e957506020015160000394506114179350505050565b50602001519a9950505050505050505050565b612704613f98565b826001600160a01b0316846001600160a01b03161115612722579192915b6040518060600160405280856001600160a01b03168152602001846001600160a01b031681526020018362ffffff1681525090505b9392505050565b600081602001516001600160a01b031682600001516001600160a01b03161061278657600080fd5b50805160208083015160409384015184516001600160a01b0394851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b6bffffffffffffffffffffffff191660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b60008060008360020b12612871578260020b612879565b8260020b6000035b9050620d89e88111156128b7576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b6000600182166128cb57600160801b6128dd565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612911576ffff97272373d413259a46990580e213a0260801c5b6004821615612930576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561294f576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561296e576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561298d576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156129ac576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156129cb576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156129eb576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615612a0b576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615612a2b576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615612a4b576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615612a6b576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615612a8b576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615612aab576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615612acb576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615612aec576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615612b0c576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615612b2b576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615612b48576b048a170391f7dc42444e8fa20260801c5b60008460020b1315612b63578060001981612b5f57fe5b0490505b640100000000810615612b77576001612b7a565b60005b60ff16602082901c0192505050919050565b6000612be1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136d49092919063ffffffff16565b80519091501561163857808060200190516020811015612c0057600080fd5b50516116385760405162461bcd60e51b815260040180806020018281038252602a81526020018061495c602a913960400191505060405180910390fd5b5490565b81546000908210612c835760405162461bcd60e51b81526004018080602001828103825260228152602001806149146022913960400191505060405180910390fd5b826000018281548110612c9257fe5b9060005260206000200154905092915050565b801580612d2b575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612cfd57600080fd5b505afa158015612d11573d6000803e3d6000fd5b505050506040513d6020811015612d2757600080fd5b5051155b612d665760405162461bcd60e51b81526004018080602001828103825260368152602001806149866036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611638908490612b8c565b60006001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14612de45782611291565b50919050565b60008181526001830160205260408120548015612ea65783546000198083019190810190600090879083908110612e1d57fe5b9060005260206000200154905080876000018481548110612e3a57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612e6a57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611294565b6000915050611294565b60009081526001919091016020526040902054151590565b60008060008460020b8660020b81612edc57fe5b05905060008660020b128015612f0357508460020b8660020b81612efc57fe5b0760020b15155b15612f0d57600019015b8315612feb57600080612f1f836136e3565b60405163299ce14b60e11b81529193509150600160ff83161b8001600019019060009082906001600160a01b038d1690635339c29690612f639088906004016145e1565b60206040518083038186803b158015612f7b57600080fd5b505afa158015612f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb391906143b9565b168015159650905085612fcd57888360ff16860302612fe0565b88612fd7826136f5565b840360ff168603025b9650505050506130ca565b600080612ffa836001016136e3565b60405163299ce14b60e11b81529193509150600019600160ff84161b01199060009082906001600160a01b038d1690635339c2969061303d9088906004016145e1565b60206040518083038186803b15801561305557600080fd5b505afa158015613069573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308d91906143b9565b1680151596509050856130ad57888360ff0360ff168660010101026130c3565b88836130b883613795565b0360ff168660010101025b9650505050505b5094509492505050565b60008080806001600160a01b03808916908a16101581871280159061315957600061310d8989620f42400362ffffff16620f424061387f565b905082613126576131218c8c8c600161392e565b613133565b6131338b8d8c600161399e565b9550858110613144578a9650613153565b6131508c8b8386613a5b565b96505b506131a3565b816131705761316b8b8b8b600061399e565b61317d565b61317d8a8c8b600061392e565b9350838860000310613191578995506131a3565b6131a08b8a8a60000385613aa7565b95505b6001600160a01b038a8116908716148215613206578080156131c25750815b6131d8576131d3878d8c600161399e565b6131da565b855b95508080156131e7575081155b6131fd576131f8878d8c600061392e565b6131ff565b845b9450613250565b8080156132105750815b613226576132218c888c600161392e565b613228565b855b9550808015613235575081155b61324b576132468c888c600061399e565b61324d565b845b94505b8115801561326057508860000385115b1561326c578860000394505b81801561328b57508a6001600160a01b0316876001600160a01b031614155b1561329a5785890393506132b7565b6132b4868962ffffff168a620f42400362ffffff16613af3565b93505b50505095509550955095915050565b8082038281131560008312151461129457600080fd5b8181018281121560008312151461129457600080fd5b60008082600f0b121561335757826001600160801b03168260000384039150816001600160801b031610613352576040805162461bcd60e51b81526020600482015260026024820152614c5360f01b604482015290519081900360640190fd5b611294565b826001600160801b03168284019150816001600160801b03161015611294576040805162461bcd60e51b81526020600482015260026024820152614c4160f01b604482015290519081900360640190fd5b60006401000276a36001600160a01b038316108015906133e4575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b613419576040805162461bcd60e51b81526020600482015260016024820152602960f91b604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166001600160801b03811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106134ba57607f810383901c91506134c4565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b146136c557886001600160a01b03166136a98261285a565b6001600160a01b031611156136be57816136c0565b805b6136c7565b815b9998505050505050505050565b6060610bad8484600085613b2d565b60020b600881901d9161010090910790565b600080821161370357600080fd5b600160801b821061371657608091821c91015b68010000000000000000821061372e57604091821c91015b640100000000821061374257602091821c91015b62010000821061375457601091821c91015b610100821061376557600891821c91015b6010821061377557600491821c91015b6004821061378557600291821c91015b6002821061166257600101919050565b60008082116137a357600080fd5b5060ff6001600160801b038216156137be57607f19016137c6565b608082901c91505b67ffffffffffffffff8216156137df57603f19016137e7565b604082901c91505b63ffffffff8216156137fc57601f1901613804565b602082901c91505b61ffff82161561381757600f190161381f565b601082901c91505b60ff8216156138315760071901613839565b600882901c91505b600f82161561384b5760031901613853565b600482901c91505b6003821615613865576001190161386d565b600282901c91505b60018216156116625760001901919050565b60008080600019858709868602925082811090839003039050806138b557600084116138aa57600080fd5b508290049050612757565b8084116138c157600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6000836001600160a01b0316856001600160a01b0316111561394e579293925b8161397b57613976836001600160801b03168686036001600160a01b0316600160601b61387f565b611417565b611417836001600160801b03168686036001600160a01b0316600160601b613af3565b6000836001600160a01b0316856001600160a01b031611156139be579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b0386860381169087166139fa57600080fd5b83613a2a57866001600160a01b0316613a1d8383896001600160a01b031661387f565b81613a2457fe5b04613a50565b613a50613a418383896001600160a01b0316613af3565b886001600160a01b0316613c7d565b979650505050505050565b600080856001600160a01b031611613a7257600080fd5b6000846001600160801b031611613a8857600080fd5b81613a9a576139768585856001613c88565b6114178585856001613d69565b600080856001600160a01b031611613abe57600080fd5b6000846001600160801b031611613ad457600080fd5b81613ae6576139768585856000613d69565b6114178585856000613c88565b6000613b0084848461387f565b905060008280613b0c57fe5b8486091115612757576000198110613b2357600080fd5b6001019392505050565b606082471015613b6e5760405162461bcd60e51b81526004018080602001828103825260268152602001806149366026913960400191505060405180910390fd5b613b7785613e5e565b613bc8576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613c065780518252601f199092019160209182019101613be7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613c68576040519150601f19603f3d011682016040523d82523d6000602084013e613c6d565b606091505b5091509150613a50828286613e64565b808204910615150190565b60008115613cfb5760006001600160a01b03841115613cbe57613cb984600160601b876001600160801b031661387f565b613cd6565b6001600160801b038516606085901b81613cd457fe5b045b9050613cf3613cee6001600160a01b03881683613f08565b613f18565b915050610bad565b60006001600160a01b03841115613d2957613d2484600160601b876001600160801b0316613af3565b613d40565b613d40606085901b6001600160801b038716613c7d565b905080866001600160a01b031611613d5757600080fd5b6001600160a01b038616039050610bad565b600082613d77575083610bad565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b168215613e17576001600160a01b03861684810290858281613db757fe5b041415613de857818101828110613de657613ddc83896001600160a01b031683613af3565b9350505050610bad565b505b613e0e82613e09878a6001600160a01b03168681613e0257fe5b0490613f08565b613c7d565b92505050610bad565b6001600160a01b03861684810290858281613e2e57fe5b04148015613e3b57508082115b613e4457600080fd5b808203613ddc613cee846001600160a01b038b1684613af3565b3b151590565b60608315613e73575081612757565b825115613e835782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613ecd578181015183820152602001613eb5565b50505050905090810190601f168015613efa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8082018281101561129457600080fd5b806001600160a01b038116811461166257600080fd5b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b604080516060810182526000808252602082018190529181019190915290565b805161166281614905565b8051600281900b811461166257600080fd5b600060808284031215612de4578081fd5b80516001600160801b038116811461166257600080fd5b805161ffff8116811461166257600080fd5b600060208284031215614020578081fd5b8135612757816148ed565b60006020828403121561403c578081fd5b8151612757816148ed565b60006020808385031215614059578182fd5b825167ffffffffffffffff80821115614070578384fd5b8185019150601f8681840112614084578485fd5b82518281111561409057fe5b61409d8586830201614899565b81815285810190858701885b8481101561411b57815188018c603f8201126140c3578a8bfd5b898101516040898211156140d357fe5b6140e4828a01601f19168d01614899565b8281528f828486010111156140f7578d8efd5b614106838e83018487016148bd565b875250505092880192908801906001016140a9565b50909a9950505050505050505050565b60008060006040848603121561413f578182fd5b833567ffffffffffffffff80821115614156578384fd5b818601915086601f830112614169578384fd5b813581811115614177578485fd5b876020808302850101111561418a578485fd5b602092830195509350508401356141a081614905565b809150509250925092565b6000806000606084860312156141bf578283fd5b83356141ca816148ed565b92506020840135915060408401356141a0816148ed565b6000602082840312156141f2578081fd5b61129182613fc3565b60006020828403121561420c578081fd5b813567ffffffffffffffff811115614222578182fd5b610bad84828501613fd5565b60006020828403121561423f578081fd5b813567ffffffffffffffff811115614255578182fd5b820160e08185031215612757578182fd5b600060208284031215614277578081fd5b61129182613fe6565b600080600080600080600080610100898b03121561429c578586fd5b6142a589613fe6565b9750602089015180600f0b81146142ba578687fd5b80975050604089015195506060890151945060808901518060060b81146142df578485fd5b60a08a01519094506142f0816148ed565b60c08a015190935063ffffffff81168114614309578283fd5b915061431760e08a01613fb8565b90509295985092959890939650565b600080600080600080600060e0888a031215614340578081fd5b875161434b816148ed565b965061435960208901613fc3565b955061436760408901613ffd565b945061437560608901613ffd565b935061438360808901613ffd565b925060a088015160ff81168114614398578182fd5b60c08901519092506143a981614905565b8091505092959891949750929550565b6000602082840312156143ca578081fd5b5051919050565b600080604083850312156143e3578182fd5b8235915060208301356143f5816148ed565b809150509250929050565b600081518084526144188160208601602086016148bd565b601f01601f19169290920160200192915050565b60609190911b6bffffffffffffffffffffffff1916815260140190565b6000845161445b8184602089016148bd565b60e89490941b7fffffff0000000000000000000000000000000000000000000000000000000000169190930190815260609190911b6bffffffffffffffffffffffff1916600382015260170192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561451c5783516001600160a01b0316835292840192918401916001016144f7565b50909695505050505050565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561457b57603f19888603018452614569858351614400565b9450928501929085019060010161454d565b5092979650505050505050565b6040808252810183905260008460608301825b868110156145cb5782356145ae816148ed565b6001600160a01b031682526020928301929091019060010161459b565b5080925050508215156020830152949350505050565b60019190910b815260200190565b60029190910b815260200190565b60208082526011908201527f696e76616c6964207377617020696d706c000000000000000000000000000000604082015260600190565b6020808252600f908201527f696e76616c696420616464726573730000000000000000000000000000000000604082015260600190565b60208082526012908201527f756e737570706f7274656420726f757465720000000000000000000000000000604082015260600190565b60208082526011908201527f696e76616c696420747261646550617468000000000000000000000000000000604082015260600190565b6020808252600e908201527f6f6e6c79207377617020696d706c000000000000000000000000000000000000604082015260600190565b600060208252825160a0602084015261472c60c0840182614400565b90506001600160a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b6000610100820190506001600160a01b0380845116835280602085015116602084015262ffffff60408501511660408401528060608501511660608401526080840151608084015260a084015160a084015260c084015160c08401528060e08501511660e08401525092915050565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b6000808335601e1984360301811261481c578283fd5b83018035915067ffffffffffffffff821115614836578283fd5b602090810192508102360382131561484d57600080fd5b9250929050565b6000808335601e1984360301811261486a578283fd5b83018035915067ffffffffffffffff821115614884578283fd5b60200191503681900382131561484d57600080fd5b60405181810167ffffffffffffffff811182821017156148b557fe5b604052919050565b60005b838110156148d85781810151838201526020016148c0565b838111156148e7576000848401525b50505050565b6001600160a01b038116811461490257600080fd5b50565b801515811461490257600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a164736f6c6343000706000a000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da727800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Deployed Bytecode
0x6080604052600436106101125760003560e01c806368aa6dd9116100a5578063ce56c45411610074578063e19b609d11610059578063e19b609d146102e5578063ed55044314610305578063f851a4401461031a57610119565b8063ce56c454146102a5578063d6ba0bfc146102c557610119565b806368aa6dd91461023d57806375829def1461025057806377f50f97146102705780637acc86781461028557610119565b80633ccdbb28116100e15780633ccdbb28146101bb57806343bea4b3146101db5780634582d279146101fb5780634db1d03d1461021d57610119565b806305a727091461011e5780631373524614610155578063249d39e914610177578063267822471461019957610119565b3661011957005b600080fd5b34801561012a57600080fd5b5061013e6101393660046141fb565b61032f565b60405161014c9291906147f8565b60405180910390f35b34801561016157600080fd5b5061017561017036600461400f565b61054e565b005b34801561018357600080fd5b5061018c61061c565b60405161014c91906147d8565b3480156101a557600080fd5b506101ae610622565b60405161014c91906144ad565b3480156101c757600080fd5b506101756101d63660046141ab565b610631565b3480156101e757600080fd5b5061018c6101f63660046141fb565b6106e0565b34801561020757600080fd5b50610210610814565b60405161014c91906144db565b34801561022957600080fd5b5061018c6102383660046141fb565b6108af565b61018c61024b36600461422e565b610992565b34801561025c57600080fd5b5061017561026b36600461400f565b610bb5565b34801561027c57600080fd5b50610175610cba565b34801561029157600080fd5b506101756102a036600461400f565b610d8c565b3480156102b157600080fd5b506101756102c03660046143d1565b610ed9565b3480156102d157600080fd5b506101756102e036600461412b565b611013565b3480156102f157600080fd5b5061013e6103003660046141fb565b611119565b34801561031157600080fd5b506101ae61125e565b34801561032657600080fd5b506101ae61126d565b60035460009081906001600160a01b031633146103675760405162461bcd60e51b815260040161035e906146d9565b60405180910390fd5b60026103766020850185614806565b905010156103965760405162461bcd60e51b815260040161035e906146a2565b6000806103c360016103ab6020880188614806565b9050038680606001906103be9190614854565b61129a565b863595509092509050600060016103dd6020880188614806565b90500390505b80156104705761046583866103fb60208a018a614806565b6001860381811061040857fe5b905060200201602081019061041d919061400f565b61042a60208b018b614806565b8681811061043457fe5b9050602002016020810190610449919061400f565b86600187038151811061045857fe5b60200260200101516113fa565b9450600019016103e3565b508360005b60016104846020890189614806565b9050038110156105115761050784836104a060208b018b614806565b858181106104aa57fe5b90506020020160208101906104bf919061400f565b6104cc60208c018c614806565b866001018181106104d957fe5b90506020020160208101906104ee919061400f565b8786815181106104fa57fe5b6020026020010151611420565b9150600101610475565b50853581116105235760009350610546565b8061053b612710610535838a356115b2565b906115c2565b8161054257fe5b0493505b505050915091565b6000546001600160a01b0316331461059a576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b0381166105c05760405162461bcd60e51b815260040161035e906145fd565b6003546040516001600160a01b038084169216907f7c5d026310440df4ec67ef47368cd26898f9dbec4b95934dbbc4a3d9d46c49a990600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b61271081565b6001546001600160a01b031681565b6000546001600160a01b0316331461067d576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6106916001600160a01b03841682846115e6565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b6003546000906001600160a01b0316331461070d5760405162461bcd60e51b815260040161035e906146d9565b600261071c6020840184614806565b9050101561073c5760405162461bcd60e51b815260040161035e906146a2565b60008061076460016107516020870187614806565b9050038580606001906103be9190614854565b85359450909250905060005b600161077f6020870187614806565b90500381101561080c57610802838561079b6020890189614806565b858181106107a557fe5b90506020020160208101906107ba919061400f565b6107c760208a018a614806565b866001018181106107d457fe5b90506020020160208101906107e9919061400f565b8686815181106107f557fe5b602002602001015161163d565b9350600101610770565b505050919050565b606060006108226004611654565b90508067ffffffffffffffff8111801561083b57600080fd5b50604051908082528060200260200182016040528015610865578160200160208202803683370190505b50915060005b818110156108aa5761087e600482611667565b83828151811061088a57fe5b6001600160a01b039092166020928302919091019091015260010161086b565b505090565b6003546000906001600160a01b031633146108dc5760405162461bcd60e51b815260040161035e906146d9565b60026108eb6020840184614806565b9050101561090b5760405162461bcd60e51b815260040161035e906146a2565b60008061092060016107516020870187614806565b8535945090925090506000600161093a6020870187614806565b90500390505b801561080c5761098783856109586020890189614806565b6001860381811061096557fe5b905060200201602081019061097a919061400f565b61042a60208a018a614806565b935060001901610940565b6003546000906001600160a01b031633146109bf5760405162461bcd60e51b815260040161035e906146d9565b60026109ce6040840184614806565b905010156109ee5760405162461bcd60e51b815260040161035e906146a2565b600080610a166001610a036040870187614806565b905003858060c001906103be9190614854565b9092509050610a5182610a2c6040870187614806565b6000818110610a3757fe5b9050602002016020810190610a4c919061400f565b611673565b610aa6610a616040860186614806565b6001610a706040890189614806565b905003818110610a7c57fe5b9050602002016020810190610a91919061400f565b610aa1608087016060880161400f565b61173a565b9250610ab56040850185614806565b905060021415610b2557610b208285356020870135610ad76040890189614806565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250889250610b1b91505060808b0160608c0161400f565b6117f2565b610b53565b610b538285356020870135610b3d6040890189614806565b86610b4e60808c0160608d0161400f565b611b99565b610bad83610ba7610b676040880188614806565b6001610b7660408b018b614806565b905003818110610b8257fe5b9050602002016020810190610b97919061400f565b610aa16080890160608a0161400f565b906115b2565b949350505050565b6000546001600160a01b03163314610c01576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610c5c576040805162461bcd60e51b815260206004820152600b60248201527f6e65772061646d696e2030000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610d19576040805162461bcd60e51b815260206004820152600b60248201527f6e6f742070656e64696e67000000000000000000000000000000000000000000604482015290519081900360640190fd5b600154600054604080516001600160a01b03938416815292909116602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000546001600160a01b03163314610dd8576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610e33576040805162461bcd60e51b815260206004820152600760248201527f61646d696e203000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600054604080516001600160a01b038085168252909216602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a1600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610f25576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d8060008114610f70576040519150601f19603f3d011682016040523d82523d6000602084013e610f75565b606091505b5050905080610fcb576040805162461bcd60e51b815260206004820152600f60248201527f7769746864726177206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b6000546001600160a01b0316331461105f576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b60005b828110156110d85781156110a25761109c84848381811061107f57fe5b9050602002016020810190611094919061400f565b60049061127c565b506110d0565b6110ce8484838181106110b157fe5b90506020020160208101906110c6919061400f565b600490611f91565b505b600101611062565b507f56f34eb6bd4451b93fcc586e59d7ca42dba8fdb9fc157152eb3b4d0cf190b2c283838360405161110c93929190614588565b60405180910390a1505050565b60035460009081906001600160a01b031633146111485760405162461bcd60e51b815260040161035e906146d9565b60026111576020850185614806565b905010156111775760405162461bcd60e51b815260040161035e906146a2565b60008061118c60016103ab6020880188614806565b8635955090925090508360005b60016111a86020890189614806565b90500381101561123c5761121e84876111c460208b018b614806565b858181106111ce57fe5b90506020020160208101906111e3919061400f565b6111f060208c018c614806565b866001018181106111fd57fe5b9050602002016020810190611212919061400f565b8786815181106107f557fe5b955061123284836104a060208b018b614806565b9150600101611199565b5084811161124d5760009350610546565b8061053b61271061053583896115b2565b6003546001600160a01b031681565b6000546001600160a01b031681565b6000611291836001600160a01b038416611fa6565b90505b92915050565b600060608467ffffffffffffffff811180156112b557600080fd5b506040519080825280602002602001820160405280156112df578160200160208202803683370190505b509050611326600085858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509293925050611ff09050565b915060005b858110156113a45761137c8160030260140186868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506120b39050565b82828151811061138857fe5b62ffffff9092166020928302919091019091015260010161132b565b506001600160a01b0382166113cb5760405162461bcd60e51b815260040161035e90614634565b6113d660048361216f565b6113f25760405162461bcd60e51b815260040161035e9061466b565b935093915050565b60006114148661140987612184565b60000386868661219a565b90505b95945050505050565b6000806114a7876001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561145f57600080fd5b505afa158015611473573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611497919061402b565b6114a28787876126fc565b61275e565b90506001600160a01b03808516908616106114c0613f2e565b826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156114f957600080fd5b505afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115319190614326565b5050505050600290810b900b60608301526001600160a01b0316604082015260008261156c57611567826060015160000361285a565b611572565b81604001515b905060606115898a6001600160a01b0384166115c2565b901c945060606115a2866001600160a01b0384166115c2565b901c9a9950505050505050505050565b8082038281111561129457600080fd5b60008215806115dd575050818102818382816115da57fe5b04145b61129457600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611638908490612b8c565b505050565b60006114148661164c87612184565b86868661219a565b600061165f82612c3d565b90505b919050565b60006112918383612c41565b6001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1480159061171b5750604051636eb1769f60e11b81526001600160a01b0382169063dd62ed3e906116c990309086906004016144c1565b60206040518083038186803b1580156116e157600080fd5b505afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171991906143b9565b155b15611736576117366001600160a01b03821683600019612ca5565b5050565b60006001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561177257506001600160a01b03811631611294565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d60208110156117e957600080fd5b50519050611294565b600060405180610100016040528061188e8660008151811061181057fe5b60200260200101518a6001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b505afa158015611865573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611889919061402b565b612db8565b6001600160a01b031681526020016118ac8660018151811061181057fe5b6001600160a01b03168152602001846000815181106118c757fe5b602002602001015162ffffff168152602001836001600160a01b03168152602001600019815260200187815260200186815260200160006001600160a01b0316815250905073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03168460018651038151811061193a57fe5b60200260200101516001600160a01b03161415611ac6576000606082810182905260408051600280825292810190915290816020015b606081526020019060019003908161197057905050905063414bf3898260405160240161199d9190614769565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050816000815181106119d657fe5b60200260200101819052506349404b7c86846040516024016119f99291906147e1565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600181518110611a3257fe5b6020908102919091010152604051631592ca1b60e31b81526001600160a01b0389169063ac9650d890611a69908490600401614528565b600060405180830381600087803b158015611a8357600080fd5b505af1158015611a97573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611abf9190810190614047565b5050611b90565b866001600160a01b031663414bf38973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031686600081518110611b0057fe5b60200260200101516001600160a01b031614611b1d576000611b1f565b875b836040518363ffffffff1660e01b8152600401611b3c9190614769565b6020604051808303818588803b158015611b5557600080fd5b505af1158015611b69573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611b8e91906143b9565b505b50505050505050565b6000611bf985856000818110611bab57fe5b9050602002016020810190611bc0919061400f565b896001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b604051602001611c09919061442c565b604051602081830303815290604052905060005b8351811015611cc75781848281518110611c3357fe5b6020026020010151611c9b888885600101818110611c4d57fe5b9050602002016020810190611c62919061400f565b8c6001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185157600080fd5b604051602001611cad93929190614449565b60408051601f198184030181529190529150600101611c1d565b506040805160a0810182528281526001600160a01b038416602082015260001991810182905260608101899052608081018890529073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90879087908101818110611d2157fe5b9050602002016020810190611d36919061400f565b6001600160a01b03161415611eba576000602082018190526040805160028082526060820190925290816020015b6060815260200190600190039081611d6457905050905063c04b8d5982604051602401611d919190614710565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600081518110611dca57fe5b60200260200101819052506349404b7c8885604051602401611ded9291906147e1565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505081600181518110611e2657fe5b6020908102919091010152604051631592ca1b60e31b81526001600160a01b038b169063ac9650d890611e5d908490600401614528565b600060405180830381600087803b158015611e7757600080fd5b505af1158015611e8b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eb39190810190614047565b5050611f86565b6001600160a01b03891663c04b8d5973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8888600081611ee957fe5b9050602002016020810190611efe919061400f565b6001600160a01b031614611f13576000611f15565b895b836040518363ffffffff1660e01b8152600401611f329190614710565b6020604051808303818588803b158015611f4b57600080fd5b505af1158015611f5f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f8491906143b9565b505b505050505050505050565b6000611291836001600160a01b038416612dea565b6000611fb28383612eb0565b611fe857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611294565b506000611294565b60008182601401101561204a576040805162461bcd60e51b815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b81601401835110156120a3576040805162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b500160200151600160601b900490565b60008182600301101561210d576040805162461bcd60e51b815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015612166576040805162461bcd60e51b815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b6000611291836001600160a01b038416612eb0565b6000600160ff1b821061219657600080fd5b5090565b6000806121d9876001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561145f57600080fd5b90506000816001600160a01b031663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561221657600080fd5b505afa15801561222a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224e91906141e1565b90506001600160a01b03808616908716106000816122805773fffd8963efd1fc6a506488495d951d5263988d25612287565b6401000276a45b9050612291613f2e565b8981526000602082015260408051633850c7bd60e01b815290516001600160a01b03871691633850c7bd9160048083019260e0929190829003018186803b1580156122db57600080fd5b505afa1580156122ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123139190614326565b5050505050600290810b900b60608301526001600160a01b039081166040808401919091528051630d34328160e11b8152905191871691631a68650291600480820192602092909190829003018186803b15801561237057600080fd5b505afa158015612384573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a89190614266565b6001600160801b0316608082015260008a135b8151158015906123e15750826001600160a01b031682604001516001600160a01b031614155b156126c8576123ee613f5c565b60408301516001600160a01b0390811682526060840151612413918916908888612ec8565b15156040830152600290810b810b60208301819052620d89e719910b121561244457620d89e7196020820152612463565b6020810151620d89e860029190910b131561246357620d89e860208201525b612470816020015161285a565b6001600160a01b0316606082015260408301516124e190866124aa57856001600160a01b031683606001516001600160a01b0316116124c4565b856001600160a01b031683606001516001600160a01b0316105b6124d25782606001516124d4565b855b608086015186518d6130d4565b60c085015260a084015260808301526001600160a01b031660408401528115612543576125178160c00151826080015101612184565b835103835260a08101516125399061252e90612184565b6020850151906132c6565b602084015261257e565b6125508160a00151612184565b835101835260c081015160808201516125789161256d9101612184565b6020850151906132dc565b60208401525b80606001516001600160a01b031683604001516001600160a01b031614156126875780604001511561265e57602081015160405163f30dba9360e01b81526000916001600160a01b038a169163f30dba93916125dc916004016145ef565b6101006040518083038186803b1580156125f557600080fd5b505afa158015612609573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262d9190614280565b5050505050509150508515612640576000035b61264e8460800151826132f2565b6001600160801b03166080850152505b8461266d578060200151612676565b60018160200151035b600290810b900b60608401526126c2565b80600001516001600160a01b031683604001516001600160a01b0316146126c2576126b583604001516133a8565b600290810b900b60608401525b506123bb565b6000826020015112156126e957506020015160000394506114179350505050565b50602001519a9950505050505050505050565b612704613f98565b826001600160a01b0316846001600160a01b03161115612722579192915b6040518060600160405280856001600160a01b03168152602001846001600160a01b031681526020018362ffffff1681525090505b9392505050565b600081602001516001600160a01b031682600001516001600160a01b03161061278657600080fd5b50805160208083015160409384015184516001600160a01b0394851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b6bffffffffffffffffffffffff191660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b60008060008360020b12612871578260020b612879565b8260020b6000035b9050620d89e88111156128b7576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b6000600182166128cb57600160801b6128dd565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612911576ffff97272373d413259a46990580e213a0260801c5b6004821615612930576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561294f576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561296e576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561298d576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156129ac576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156129cb576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156129eb576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615612a0b576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615612a2b576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615612a4b576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615612a6b576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615612a8b576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615612aab576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615612acb576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615612aec576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615612b0c576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615612b2b576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615612b48576b048a170391f7dc42444e8fa20260801c5b60008460020b1315612b63578060001981612b5f57fe5b0490505b640100000000810615612b77576001612b7a565b60005b60ff16602082901c0192505050919050565b6000612be1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136d49092919063ffffffff16565b80519091501561163857808060200190516020811015612c0057600080fd5b50516116385760405162461bcd60e51b815260040180806020018281038252602a81526020018061495c602a913960400191505060405180910390fd5b5490565b81546000908210612c835760405162461bcd60e51b81526004018080602001828103825260228152602001806149146022913960400191505060405180910390fd5b826000018281548110612c9257fe5b9060005260206000200154905092915050565b801580612d2b575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612cfd57600080fd5b505afa158015612d11573d6000803e3d6000fd5b505050506040513d6020811015612d2757600080fd5b5051155b612d665760405162461bcd60e51b81526004018080602001828103825260368152602001806149866036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611638908490612b8c565b60006001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14612de45782611291565b50919050565b60008181526001830160205260408120548015612ea65783546000198083019190810190600090879083908110612e1d57fe5b9060005260206000200154905080876000018481548110612e3a57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612e6a57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611294565b6000915050611294565b60009081526001919091016020526040902054151590565b60008060008460020b8660020b81612edc57fe5b05905060008660020b128015612f0357508460020b8660020b81612efc57fe5b0760020b15155b15612f0d57600019015b8315612feb57600080612f1f836136e3565b60405163299ce14b60e11b81529193509150600160ff83161b8001600019019060009082906001600160a01b038d1690635339c29690612f639088906004016145e1565b60206040518083038186803b158015612f7b57600080fd5b505afa158015612f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb391906143b9565b168015159650905085612fcd57888360ff16860302612fe0565b88612fd7826136f5565b840360ff168603025b9650505050506130ca565b600080612ffa836001016136e3565b60405163299ce14b60e11b81529193509150600019600160ff84161b01199060009082906001600160a01b038d1690635339c2969061303d9088906004016145e1565b60206040518083038186803b15801561305557600080fd5b505afa158015613069573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308d91906143b9565b1680151596509050856130ad57888360ff0360ff168660010101026130c3565b88836130b883613795565b0360ff168660010101025b9650505050505b5094509492505050565b60008080806001600160a01b03808916908a16101581871280159061315957600061310d8989620f42400362ffffff16620f424061387f565b905082613126576131218c8c8c600161392e565b613133565b6131338b8d8c600161399e565b9550858110613144578a9650613153565b6131508c8b8386613a5b565b96505b506131a3565b816131705761316b8b8b8b600061399e565b61317d565b61317d8a8c8b600061392e565b9350838860000310613191578995506131a3565b6131a08b8a8a60000385613aa7565b95505b6001600160a01b038a8116908716148215613206578080156131c25750815b6131d8576131d3878d8c600161399e565b6131da565b855b95508080156131e7575081155b6131fd576131f8878d8c600061392e565b6131ff565b845b9450613250565b8080156132105750815b613226576132218c888c600161392e565b613228565b855b9550808015613235575081155b61324b576132468c888c600061399e565b61324d565b845b94505b8115801561326057508860000385115b1561326c578860000394505b81801561328b57508a6001600160a01b0316876001600160a01b031614155b1561329a5785890393506132b7565b6132b4868962ffffff168a620f42400362ffffff16613af3565b93505b50505095509550955095915050565b8082038281131560008312151461129457600080fd5b8181018281121560008312151461129457600080fd5b60008082600f0b121561335757826001600160801b03168260000384039150816001600160801b031610613352576040805162461bcd60e51b81526020600482015260026024820152614c5360f01b604482015290519081900360640190fd5b611294565b826001600160801b03168284019150816001600160801b03161015611294576040805162461bcd60e51b81526020600482015260026024820152614c4160f01b604482015290519081900360640190fd5b60006401000276a36001600160a01b038316108015906133e4575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b613419576040805162461bcd60e51b81526020600482015260016024820152602960f91b604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166001600160801b03811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106134ba57607f810383901c91506134c4565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b146136c557886001600160a01b03166136a98261285a565b6001600160a01b031611156136be57816136c0565b805b6136c7565b815b9998505050505050505050565b6060610bad8484600085613b2d565b60020b600881901d9161010090910790565b600080821161370357600080fd5b600160801b821061371657608091821c91015b68010000000000000000821061372e57604091821c91015b640100000000821061374257602091821c91015b62010000821061375457601091821c91015b610100821061376557600891821c91015b6010821061377557600491821c91015b6004821061378557600291821c91015b6002821061166257600101919050565b60008082116137a357600080fd5b5060ff6001600160801b038216156137be57607f19016137c6565b608082901c91505b67ffffffffffffffff8216156137df57603f19016137e7565b604082901c91505b63ffffffff8216156137fc57601f1901613804565b602082901c91505b61ffff82161561381757600f190161381f565b601082901c91505b60ff8216156138315760071901613839565b600882901c91505b600f82161561384b5760031901613853565b600482901c91505b6003821615613865576001190161386d565b600282901c91505b60018216156116625760001901919050565b60008080600019858709868602925082811090839003039050806138b557600084116138aa57600080fd5b508290049050612757565b8084116138c157600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6000836001600160a01b0316856001600160a01b0316111561394e579293925b8161397b57613976836001600160801b03168686036001600160a01b0316600160601b61387f565b611417565b611417836001600160801b03168686036001600160a01b0316600160601b613af3565b6000836001600160a01b0316856001600160a01b031611156139be579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b0386860381169087166139fa57600080fd5b83613a2a57866001600160a01b0316613a1d8383896001600160a01b031661387f565b81613a2457fe5b04613a50565b613a50613a418383896001600160a01b0316613af3565b886001600160a01b0316613c7d565b979650505050505050565b600080856001600160a01b031611613a7257600080fd5b6000846001600160801b031611613a8857600080fd5b81613a9a576139768585856001613c88565b6114178585856001613d69565b600080856001600160a01b031611613abe57600080fd5b6000846001600160801b031611613ad457600080fd5b81613ae6576139768585856000613d69565b6114178585856000613c88565b6000613b0084848461387f565b905060008280613b0c57fe5b8486091115612757576000198110613b2357600080fd5b6001019392505050565b606082471015613b6e5760405162461bcd60e51b81526004018080602001828103825260268152602001806149366026913960400191505060405180910390fd5b613b7785613e5e565b613bc8576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613c065780518252601f199092019160209182019101613be7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613c68576040519150601f19603f3d011682016040523d82523d6000602084013e613c6d565b606091505b5091509150613a50828286613e64565b808204910615150190565b60008115613cfb5760006001600160a01b03841115613cbe57613cb984600160601b876001600160801b031661387f565b613cd6565b6001600160801b038516606085901b81613cd457fe5b045b9050613cf3613cee6001600160a01b03881683613f08565b613f18565b915050610bad565b60006001600160a01b03841115613d2957613d2484600160601b876001600160801b0316613af3565b613d40565b613d40606085901b6001600160801b038716613c7d565b905080866001600160a01b031611613d5757600080fd5b6001600160a01b038616039050610bad565b600082613d77575083610bad565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b168215613e17576001600160a01b03861684810290858281613db757fe5b041415613de857818101828110613de657613ddc83896001600160a01b031683613af3565b9350505050610bad565b505b613e0e82613e09878a6001600160a01b03168681613e0257fe5b0490613f08565b613c7d565b92505050610bad565b6001600160a01b03861684810290858281613e2e57fe5b04148015613e3b57508082115b613e4457600080fd5b808203613ddc613cee846001600160a01b038b1684613af3565b3b151590565b60608315613e73575081612757565b825115613e835782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613ecd578181015183820152602001613eb5565b50505050905090810190601f168015613efa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8082018281101561129457600080fd5b806001600160a01b038116811461166257600080fd5b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b604080516060810182526000808252602082018190529181019190915290565b805161166281614905565b8051600281900b811461166257600080fd5b600060808284031215612de4578081fd5b80516001600160801b038116811461166257600080fd5b805161ffff8116811461166257600080fd5b600060208284031215614020578081fd5b8135612757816148ed565b60006020828403121561403c578081fd5b8151612757816148ed565b60006020808385031215614059578182fd5b825167ffffffffffffffff80821115614070578384fd5b8185019150601f8681840112614084578485fd5b82518281111561409057fe5b61409d8586830201614899565b81815285810190858701885b8481101561411b57815188018c603f8201126140c3578a8bfd5b898101516040898211156140d357fe5b6140e4828a01601f19168d01614899565b8281528f828486010111156140f7578d8efd5b614106838e83018487016148bd565b875250505092880192908801906001016140a9565b50909a9950505050505050505050565b60008060006040848603121561413f578182fd5b833567ffffffffffffffff80821115614156578384fd5b818601915086601f830112614169578384fd5b813581811115614177578485fd5b876020808302850101111561418a578485fd5b602092830195509350508401356141a081614905565b809150509250925092565b6000806000606084860312156141bf578283fd5b83356141ca816148ed565b92506020840135915060408401356141a0816148ed565b6000602082840312156141f2578081fd5b61129182613fc3565b60006020828403121561420c578081fd5b813567ffffffffffffffff811115614222578182fd5b610bad84828501613fd5565b60006020828403121561423f578081fd5b813567ffffffffffffffff811115614255578182fd5b820160e08185031215612757578182fd5b600060208284031215614277578081fd5b61129182613fe6565b600080600080600080600080610100898b03121561429c578586fd5b6142a589613fe6565b9750602089015180600f0b81146142ba578687fd5b80975050604089015195506060890151945060808901518060060b81146142df578485fd5b60a08a01519094506142f0816148ed565b60c08a015190935063ffffffff81168114614309578283fd5b915061431760e08a01613fb8565b90509295985092959890939650565b600080600080600080600060e0888a031215614340578081fd5b875161434b816148ed565b965061435960208901613fc3565b955061436760408901613ffd565b945061437560608901613ffd565b935061438360808901613ffd565b925060a088015160ff81168114614398578182fd5b60c08901519092506143a981614905565b8091505092959891949750929550565b6000602082840312156143ca578081fd5b5051919050565b600080604083850312156143e3578182fd5b8235915060208301356143f5816148ed565b809150509250929050565b600081518084526144188160208601602086016148bd565b601f01601f19169290920160200192915050565b60609190911b6bffffffffffffffffffffffff1916815260140190565b6000845161445b8184602089016148bd565b60e89490941b7fffffff0000000000000000000000000000000000000000000000000000000000169190930190815260609190911b6bffffffffffffffffffffffff1916600382015260170192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561451c5783516001600160a01b0316835292840192918401916001016144f7565b50909695505050505050565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561457b57603f19888603018452614569858351614400565b9450928501929085019060010161454d565b5092979650505050505050565b6040808252810183905260008460608301825b868110156145cb5782356145ae816148ed565b6001600160a01b031682526020928301929091019060010161459b565b5080925050508215156020830152949350505050565b60019190910b815260200190565b60029190910b815260200190565b60208082526011908201527f696e76616c6964207377617020696d706c000000000000000000000000000000604082015260600190565b6020808252600f908201527f696e76616c696420616464726573730000000000000000000000000000000000604082015260600190565b60208082526012908201527f756e737570706f7274656420726f757465720000000000000000000000000000604082015260600190565b60208082526011908201527f696e76616c696420747261646550617468000000000000000000000000000000604082015260600190565b6020808252600e908201527f6f6e6c79207377617020696d706c000000000000000000000000000000000000604082015260600190565b600060208252825160a0602084015261472c60c0840182614400565b90506001600160a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b6000610100820190506001600160a01b0380845116835280602085015116602084015262ffffff60408501511660408401528060608501511660608401526080840151608084015260a084015160a084015260c084015160c08401528060e08501511660e08401525092915050565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b6000808335601e1984360301811261481c578283fd5b83018035915067ffffffffffffffff821115614836578283fd5b602090810192508102360382131561484d57600080fd5b9250929050565b6000808335601e1984360301811261486a578283fd5b83018035915067ffffffffffffffff821115614884578283fd5b60200191503681900382131561484d57600080fd5b60405181810167ffffffffffffffff811182821017156148b557fe5b604052919050565b60005b838110156148d85781810151838201526020016148c0565b838111156148e7576000848401525b50505050565b6001600160a01b038116811461490257600080fd5b50565b801515811461490257600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a164736f6c6343000706000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da727800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
-----Decoded View---------------
Arg [0] : _admin (address): 0xa3e78aB6f120C730D6F3939c0Dc6dcD0E3da7278
Arg [1] : routers (address[]): 0xE592427A0AEce92De3Edee1F18E0157C05861564
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da7278
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [3] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ 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.