Feature Tip: Add private address tag to any address under My Name Tag !
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 311 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Sell | 21417073 | 56 days ago | IN | 0 ETH | 0.00776107 | ||||
Sell | 21417056 | 56 days ago | IN | 0 ETH | 0.00722323 | ||||
Withdraw Tokens | 17885914 | 550 days ago | IN | 0 ETH | 0.00271773 | ||||
Withdraw Tokens | 17367829 | 623 days ago | IN | 0 ETH | 0.00203831 | ||||
Withdraw Tokens | 17367801 | 623 days ago | IN | 0 ETH | 0.00234909 | ||||
Withdraw Tokens | 16932038 | 685 days ago | IN | 0 ETH | 0.0014793 | ||||
Execute Payable | 16303589 | 773 days ago | IN | 0 ETH | 0.00279309 | ||||
Execute Payable | 16303588 | 773 days ago | IN | 0 ETH | 0.00286545 | ||||
Execute Payable | 15358362 | 908 days ago | IN | 0 ETH | 0.00096128 | ||||
Execute Payable | 15251626 | 925 days ago | IN | 0 ETH | 0.00299877 | ||||
Execute Payable | 15003251 | 965 days ago | IN | 0 ETH | 0.00908357 | ||||
Execute Payable | 14805150 | 998 days ago | IN | 0 ETH | 0.00319689 | ||||
Execute Payable | 14786893 | 1001 days ago | IN | 0 ETH | 0.00765093 | ||||
Execute Payable | 14756561 | 1006 days ago | IN | 0 ETH | 0.02417511 | ||||
Execute Payable | 14576214 | 1035 days ago | IN | 0.19999995 ETH | 0.00439536 | ||||
Execute Payable | 14575980 | 1035 days ago | IN | 0 ETH | 0.00418251 | ||||
Execute Payable | 14565714 | 1036 days ago | IN | 0.4 ETH | 0.01236645 | ||||
Execute Payable | 14532123 | 1041 days ago | IN | 0.501842 ETH | 0.00646835 | ||||
Execute Payable | 14532105 | 1041 days ago | IN | 0 ETH | 0.00571131 | ||||
Execute Payable | 14524420 | 1043 days ago | IN | 0.99999453 ETH | 0.01024095 | ||||
Execute Payable | 14524387 | 1043 days ago | IN | 0 ETH | 0.01065616 | ||||
Execute Payable | 14339216 | 1072 days ago | IN | 0 ETH | 0.00471009 | ||||
Execute Payable | 14313423 | 1076 days ago | IN | 0.5 ETH | 0.00616693 | ||||
Execute Payable | 14313331 | 1076 days ago | IN | 0 ETH | 0.00672641 | ||||
Execute Payable | 14301936 | 1077 days ago | IN | 0 ETH | 0.00919862 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
16303589 | 773 days ago | 0.62622474 ETH | ||||
16303589 | 773 days ago | 0.62622474 ETH | ||||
16303588 | 773 days ago | 1.10545182 ETH | ||||
16303588 | 773 days ago | 1.10545182 ETH | ||||
15358362 | 908 days ago | 0.42972896 ETH | ||||
15358362 | 908 days ago | 0.42972896 ETH | ||||
15003251 | 965 days ago | 0.07996585 ETH | ||||
15003251 | 965 days ago | 0.07996585 ETH | ||||
14877764 | 987 days ago | 0.65205371 ETH | ||||
14877764 | 987 days ago | 0.65205371 ETH | ||||
14828498 | 995 days ago | 0.88570386 ETH | ||||
14828498 | 995 days ago | 0.88570386 ETH | ||||
14828063 | 995 days ago | 0.37913061 ETH | ||||
14828063 | 995 days ago | 0.37913061 ETH | ||||
14828050 | 995 days ago | 0.38011481 ETH | ||||
14828050 | 995 days ago | 0.38011481 ETH | ||||
14805150 | 998 days ago | 0.51800015 ETH | ||||
14805150 | 998 days ago | 0.51800015 ETH | ||||
14786893 | 1001 days ago | 0.15952735 ETH | ||||
14786893 | 1001 days ago | 0.15952735 ETH | ||||
14765954 | 1005 days ago | 0.90631366 ETH | ||||
14765954 | 1005 days ago | 0.90631366 ETH | ||||
14761421 | 1005 days ago | 0.27786472 ETH | ||||
14761421 | 1005 days ago | 0.27786472 ETH | ||||
14756561 | 1006 days ago | 0.03050911 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
VanillaV1Router02
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "./VanillaV1Token02.sol"; import "./VanillaV1Uniswap02.sol"; import "./VanillaV1Migration01.sol"; import "./VanillaV1Safelist01.sol"; import "./interfaces/v1/VanillaV1API01.sol"; import "./interfaces/IVanillaV1Router02.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IVanillaV1MigrationTarget02.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; /// @dev Needed functions from the WETH contract originally deployed in https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#code interface IWETH { function deposit() external payable; function withdraw(uint256 amount) external; function balanceOf(address owner) external returns (uint256); } /// @title Entry point API for Vanilla trading router contract VanillaV1Router02 is VanillaV1Uniswap02, IVanillaV1Router02 { /// @inheritdoc IVanillaV1Router02 uint256 public immutable override epoch; /// @inheritdoc IVanillaV1Router02 IVanillaV1Token02 public immutable override vnlContract; /// @inheritdoc IVanillaV1Router02 mapping(address => mapping(address => PriceData)) public override tokenPriceData; IVanillaV1Safelist01 immutable public override safeList; // adopted from @openzeppelin/contracts/security/ReentrancyGuard.sol, modifying because we need to access the status variable uint256 private constant NOT_EXECUTING = 1; uint256 private constant EXECUTING = 2; uint256 private executingStatus; // make sure to set this NOT_EXECUTING in constructor /** @notice Deploys the contract and the VanillaGovernanceToken contract. @dev initializes the token contract for safe reference and sets the epoch for reward calculations @param _peripheryState The address of UniswapRouter contract @param _v1temp The address of Vanilla v1 contract */ constructor( IPeripheryImmutableState _peripheryState, VanillaV1API01 _v1temp ) VanillaV1Uniswap02(_peripheryState) { VanillaV1API01 v1 = VanillaV1API01(_v1temp); address vanillaDAO = msg.sender; address v1Token01 = v1.vnlContract(); VanillaV1Token02 tokenContract = new VanillaV1Token02( new VanillaV1MigrationState({migrationOwner: vanillaDAO}), v1Token01); tokenContract.mint(vanillaDAO, calculateTreasuryShare(IERC20(v1Token01).totalSupply())); vnlContract = tokenContract; epoch = v1.epoch(); safeList = new VanillaV1Safelist01({safeListOwner: vanillaDAO}); executingStatus = NOT_EXECUTING; } function calculateTreasuryShare(uint256 existingVNLSupply) private pure returns (uint256) { /// assuming that 100% of current total VNL v1 supply will be converted to VNL v1.1, the calculated treasury share will be /// 15% of current total supply: /// treasuryShare = existingVNLSupply / (100% - 15%) - existingVNLSupply /// = existingVNLSupply / ( 85 / 100 ) - existingVNLSupply /// = existingVNLSupply * 100 / 85 - existingVNLSupply return (existingVNLSupply * 100 / 85) - existingVNLSupply; } function isTokenRewarded(address token) internal view returns (bool) { return safeList.isSafelisted(token); } modifier beforeDeadline(uint256 deadline) { if (deadline < block.timestamp) { revert TradeExpired(); } _; } /// @dev Returns `defaultHolder` if `order.wethOwner` is unspecified function verifyWETHAccount (OrderData calldata order) view internal returns (address) { if (order.useWETH) { return msg.sender; } return address(this); } function validateTradeOrderSafety(OrderData calldata order) internal view { // we need to do couple of checks if calling the `buy` or `sell` function directly (i.e. not by `execute` or `executePayable`) if (executingStatus == NOT_EXECUTING) { // if we'd accept value, then it would just get locked into contract (all WETH wrapping happens in // `executePayable`) until anybody calls `withdrawAndRefund` (via `execute` or `executePayable`) to get them if (msg.value > 0) { revert UnauthorizedValueSent(); } // if we'd allow wethHoldingAccount to be this contract, // - a buy would always fail because the contract doesn't keep WETHs in the balance // - a sell would result in WETHs locked into the contract (all WETH unwrapping and ether sending happens in // `withdrawAndRefund` via `multicall`) if (!order.useWETH) { revert InvalidWethAccount(); } } } /// @inheritdoc IVanillaV1Router02 function buy( OrderData calldata buyOrder ) external override payable beforeDeadline(buyOrder.blockTimeDeadline) { address wethSource = verifyWETHAccount(buyOrder); validateTradeOrderSafety(buyOrder); _executeBuy(msg.sender, wethSource, buyOrder); } function _executeBuy( address owner, address currentWETHHolder, OrderData calldata buyOrder ) internal { address token = buyOrder.token; uint256 numEth = buyOrder.numEth; // don't use getPositionData() PriceData storage prices = tokenPriceData[owner][token]; // verify the one-trade-per-block-per-token rule and protect against reentrancy updateLatestBlock(prices); // do the swap and update price data uint256 tokens = _buy(token, numEth, buyOrder.numToken, currentWETHHolder, buyOrder.fee); prices.ethSum = uint112(uint(prices.ethSum) + numEth); prices.tokenSum = uint112(uint(prices.tokenSum) + tokens); prices.weightedBlockSum = prices.weightedBlockSum + (block.number * tokens); emit TokensPurchased(owner, token, numEth, tokens); } /** @dev Receives the ether only from WETH contract during withdraw() */ receive() external payable { // make sure that router accepts ETH only from WETH contract assert(msg.sender == _wethAddr); } function multicall(address payable caller, bytes[] calldata data) internal returns (bytes[] memory results) { // adopted from @openzeppelin/contracts/utils/Multicall.sol, made it internal to enable safe payability results = new bytes[](data.length); for (uint i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } withdrawAndRefundWETH(caller); return results; } function withdrawAndRefundWETH(address payable recipient) internal { IWETH weth = IWETH(_wethAddr); uint256 balance = weth.balanceOf(address(this)); if (balance > 0) { weth.withdraw(balance); } uint256 etherBalance = address(this).balance; if (etherBalance > 0) { Address.sendValue(recipient, etherBalance); } } modifier noNestedExecute () { require(executingStatus == NOT_EXECUTING); executingStatus = EXECUTING; _; executingStatus = NOT_EXECUTING; } function execute(bytes[] calldata data) external override noNestedExecute returns (bytes[] memory results) { results = multicall(payable(msg.sender), data); } function executePayable(bytes[] calldata data) external payable override noNestedExecute returns (bytes[] memory results) { if (msg.value > 0) { IWETH weth = IWETH(_wethAddr); weth.deposit{value: msg.value}(); } results = multicall(payable(msg.sender), data); } /// @inheritdoc IVanillaV1Router02 function sell(OrderData calldata sellOrder) external override payable beforeDeadline(sellOrder.blockTimeDeadline) { address wethRecipient = verifyWETHAccount(sellOrder); validateTradeOrderSafety(sellOrder); _executeSell(msg.sender, wethRecipient, sellOrder); } function updateLatestBlock(PriceData storage position) internal { if (position.latestBlock >= block.number) { revert TooManyTradesPerBlock(); } position.latestBlock = uint32(block.number); } function recalculateAfterSwap(uint256 numToken, PriceData memory position, RewardParams memory rewardParams) internal view returns ( PriceData memory positionAfter, TradeResult memory result, uint256 avgBlock) { avgBlock = position.weightedBlockSum / position.tokenSum; result.profitablePrice = numToken * position.ethSum / position.tokenSum; uint256 newTokenSum = position.tokenSum - numToken; result.price = rewardParams.numEth; // this can be 0 when pool is not initialized if (rewardParams.averagePeriodInSeconds > 0) { result.twapPeriodInSeconds = rewardParams.averagePeriodInSeconds; result.maxProfitablePrice = rewardParams.expectedAvgEth; uint256 twapPeriodWeightedPrice = (result.profitablePrice * (MAX_TWAP_PERIOD - rewardParams.averagePeriodInSeconds) + rewardParams.expectedAvgEth * rewardParams.averagePeriodInSeconds) / MAX_TWAP_PERIOD; uint256 rewardablePrice = Math.min( rewardParams.numEth, twapPeriodWeightedPrice ); result.rewardableProfit = rewardablePrice > result.profitablePrice ? rewardablePrice - result.profitablePrice : 0; result.reward = _calculateReward( epoch, avgBlock, block.number, result.rewardableProfit ); } positionAfter.ethSum = uint112(_proportionOf( position.ethSum, newTokenSum, position.tokenSum )); positionAfter.weightedBlockSum = _proportionOf( position.weightedBlockSum, newTokenSum, position.tokenSum ); positionAfter.tokenSum = uint112(newTokenSum); } function _executeSell( address owner, address recipient, OrderData calldata sellOrder ) internal returns (uint256) { // verify the one-trade-per-block-per-token rule and protect against reentrancy // ownership verified in `getVerifiedPositionData` PriceData storage prices = getVerifiedPositionData(owner, sellOrder.token); // verify the one-trade-per-block-per-token rule and protect against reentrancy updateLatestBlock(prices); if (sellOrder.numToken > prices.tokenSum) { revert TokenBalanceExceeded(sellOrder.numToken, prices.tokenSum); } // do the swap, calculate the profit and update price data RewardParams memory rewardParams = _sell(sellOrder.token, sellOrder.numToken, sellOrder.numEth, sellOrder.fee, recipient); (PriceData memory changedPosition, TradeResult memory result,) = recalculateAfterSwap(sellOrder.numToken, prices, rewardParams); prices.tokenSum = changedPosition.tokenSum; prices.weightedBlockSum = changedPosition.weightedBlockSum; prices.ethSum = changedPosition.ethSum; // prices.latestBlock has been already updated in `updateLatestBlock(PriceData storage)` if (result.reward > 0 && isTokenRewarded(sellOrder.token)) { // mint tokens if eligible for reward vnlContract.mint(msg.sender, result.reward); } emit TokensSold( owner, sellOrder.token, sellOrder.numToken, rewardParams.numEth, calculateRealProfit(result), result.reward ); return rewardParams.numEth; } function calculateRealProfit(TradeResult memory result) internal pure returns (uint256 profit) { return result.price > result.profitablePrice ? result.price - result.profitablePrice : 0; } /// @inheritdoc IVanillaV1Router02 function estimateReward( address owner, address token, uint256 numEth, uint256 numTokensSold ) external view override returns ( uint256 avgBlock, uint256 htrs, RewardEstimate memory estimate ) { // ownership verified in `getPositionData` PriceData memory prices = getVerifiedPositionData(owner, token); { RewardParams memory lowFeeEstimate = estimateRewardParams(token, numTokensSold, 500); lowFeeEstimate.numEth = numEth; (, estimate.low, avgBlock) = recalculateAfterSwap(numTokensSold, prices, lowFeeEstimate); } { RewardParams memory mediumFeeEstimate = estimateRewardParams(token, numTokensSold, 3000); mediumFeeEstimate.numEth = numEth; (, estimate.medium,) = recalculateAfterSwap(numTokensSold, prices, mediumFeeEstimate); } { RewardParams memory highFeeEstimate = estimateRewardParams(token, numTokensSold, 10000); highFeeEstimate.numEth = numEth; (, estimate.high,) = recalculateAfterSwap(numTokensSold, prices, highFeeEstimate); } htrs = _estimateHTRS(avgBlock); } function _estimateHTRS(uint256 avgBlock) internal view returns (uint256) { // H = "Holding/Trading Ratio, Squared" (HTRS) // = ((Bmax-Bavg)/(Bmax-Bmin))² // = (((Bmax-Bmin)-(Bavg-Bmin))/(Bmax-Bmin))² // = (Bhold/Btrade)² (= 0 if Bmax = Bavg, NaN if Bmax = Bmin) if (avgBlock == block.number || block.number == epoch) return 0; uint256 bhold = block.number - avgBlock; uint256 btrade = block.number - epoch; return bhold * bhold * 1_000_000 / (btrade * btrade); } function _calculateReward( uint256 epoch_, uint256 avgBlock, uint256 currentBlock, uint256 profit ) internal pure returns (uint256) { /* Reward formula: P = absolute profit in Ether = `profit` Bmax = block.number when trade is happening = `block.number` Bavg = volume-weighted average block.number of purchase = `avgBlock` Bmin = "epoch", the block.number when contract was deployed = `epoch_` Bhold = Bmax-Bavg = number of blocks the trade has been held (instead of traded) Btrade= Bmax-Bmin = max possible trading time in blocks H = "Holding/Trading Ratio, Squared" (HTRS) = ((Bmax-Bavg)/(Bmax-Bmin))² = (((Bmax-Bmin)-(Bavg-Bmin))/(Bmax-Bmin))² = (Bhold/Btrade)² (= 0 if Bmax = Bavg, NaN if Bmax = Bmin) L = WETH reserve limit for any traded token = `_reserveLimit` R = minted rewards = P*H = if (P = 0 || Bmax = Bavg || BMax = Bmin) 0 else P * (Bhold/Btrade)² */ if (profit == 0) return 0; if (currentBlock == avgBlock) return 0; if (currentBlock == epoch_) return 0; // these cannot underflow thanks to previous checks uint256 bhold = currentBlock - avgBlock; uint256 btrade = currentBlock - epoch_; // no division by zero possible, thanks to previous checks return profit * (bhold * bhold) / btrade / btrade; } function _proportionOf( uint256 total, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { // percentage = (numerator/denominator) // proportion = total * percentage return total * numerator / denominator; } function getVerifiedPositionData(address owner, address token) internal view returns (PriceData storage priceData) { priceData = tokenPriceData[owner][token]; // check that owner has the tokens if (priceData.tokenSum == 0) { revert NoTokenPositionFound({ owner: owner, token: token }); } } /// @inheritdoc IVanillaV1Router02 function withdrawTokens(address token) external override { address owner = msg.sender; // ownership verified in `getVerifiedPositionData` PriceData storage priceData = getVerifiedPositionData(owner, token); // effects before interactions to prevent reentrancy (,uint256 tokenSum,,) = clearState(priceData); // use safeTransfer to make sure that unsuccessful transaction reverts SafeERC20.safeTransfer(IERC20(token), owner, tokenSum); } /// @inheritdoc IVanillaV1Router02 function migratePosition(address token, address nextVersion) external override { if (nextVersion == address(0) || safeList.nextVersion() != nextVersion) { revert UnapprovedMigrationTarget(nextVersion); } address owner = msg.sender; // ownership verified in `getVerifiedPositionData` PriceData storage priceData = getVerifiedPositionData(owner, token); // effects before interactions to prevent reentrancy (uint256 ethSum, uint256 tokenSum, uint256 weightedBlockSum, uint256 latestBlock) = clearState(priceData); // transfer tokens before state, so that MigrationTarget can make the balance checks SafeERC20.safeTransfer(IERC20(token), nextVersion, tokenSum); // finally, transfer the state IVanillaV1MigrationTarget02(nextVersion).migrateState(owner, token, ethSum, tokenSum, weightedBlockSum, latestBlock); } function clearState(PriceData storage priceData) internal returns (uint256 ethSum, uint256 tokenSum, uint256 weightedBlockSum, uint256 latestBlock) { tokenSum = priceData.tokenSum; ethSum = priceData.ethSum; weightedBlockSum = priceData.weightedBlockSum; latestBlock = priceData.latestBlock; priceData.tokenSum = 0; priceData.ethSum = 0; priceData.weightedBlockSum = 0; priceData.latestBlock = 0; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { VanillaV1Converter } from "./VanillaV1Migration01.sol"; import "./interfaces/IVanillaV1Token02.sol"; import "./interfaces/v1/VanillaV1Token01.sol"; /** @title Governance Token for Vanilla Finance. */ contract VanillaV1Token02 is ERC20("Vanilla", "VNL"), VanillaV1Converter, IVanillaV1Token02 { string private constant _ERROR_ACCESS_DENIED = "c1"; address private immutable _owner; /** @notice Deploys the token and sets the caller as an owner. */ constructor(IVanillaV1MigrationState _migrationState, address _vnlAddress) VanillaV1Converter(_migrationState, IERC20(_vnlAddress)) { _owner = msg.sender; } /** @dev set the decimals explicitly to 12, for (theoretical maximum of) VNL reward of a 1ETH of profit should be displayed as 1000000VNL (18-6 = 12 decimals). */ function decimals() public pure override returns (uint8) { return 12; } modifier onlyOwner() { require(_owner == msg.sender, _ERROR_ACCESS_DENIED); _; } function mintConverted(address target, uint256 amount) internal override { _mint(target, amount); } /** @notice Mints the tokens. Used only by the VanillaRouter-contract. @param to The recipient address of the minted tokens @param tradeReward The amount of tokens to be minted */ function mint(address to, uint256 tradeReward) external override onlyOwner { _mint(to, tradeReward); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol"; import "./TickMath.sol"; import "./VanillaV1Constants02.sol"; /** @title The Uniswap v3-enabled base contract for Vanilla. */ contract VanillaV1Uniswap02 is IUniswapV3SwapCallback, VanillaV1Constants02 { address internal immutable _uniswapFactoryAddr; address internal immutable _wethAddr; // for ensuring the authenticity of swapCallback caller, also reentrancy/delegatecall control address private authorizedPool; address private immutable sentinelValue; // sentinelValue _must_ be immutable /** @notice Deploys the contract and initializes Uniswap contract references @dev using UniswapRouter to ensure that Vanilla uses the same WETH contract @param router The Uniswap periphery contract implementing the IPeripheryImmutableState */ constructor(IPeripheryImmutableState router) { // fetch addresses via router to guarantee correctness _wethAddr = router.WETH9(); _uniswapFactoryAddr = router.factory(); // we use address(this) as non-zero sentinel value for gas optimization sentinelValue = address(this); authorizedPool = address(this); } // because Uniswap V3 swaps are implemented with callback mechanisms, the callback-function becomes a public interface for // transferring tokens away from custody, so we want to make sure that we only authorize a _single Uniswap pool_ to // call the uniswapV3SwapCallback-function modifier onlyAuthorizedUse(IUniswapV3Pool pool) { address sentinel = sentinelValue; // protect the swap against any potential reentrancy (authorizedPool is set to to pool's address before // first swap and resetted back to sentinelValue if (authorizedPool != sentinel) { revert UnauthorizedReentrantAccess(); } // delegatecalling the callback function should not be a problem, but there's no reason to allow that if (address(this) != sentinel) { revert UnauthorizedDelegateCall(); } authorizedPool = address(pool); _; // set back to original, non-zero address for a refund authorizedPool = sentinel; } // this modifier needs to be used on every Uniswap v3 pool callback functions whose access is authorized by `onlyAuthorizedUse` modifier modifier onlyAuthorizedCallback() { if (msg.sender != authorizedPool) { revert UnauthorizedCallback(); } _; } struct SwapParams { address source; address recipient; uint256 tokensIn; uint256 tokensOut; address tokenIn; address tokenOut; } function _swapToken0To1(IUniswapV3Pool pool, SwapParams memory params) private onlyAuthorizedUse(pool) returns (uint256 numTokens) { // limits are verified in the callback function to optimize gas uint256 balanceBefore = IERC20(params.tokenOut).balanceOf(params.recipient); (,int256 amountOut) = pool.swap( params.recipient, true, // "zeroForOne": The direction of the swap, true for token0 to token1, false for token1 to token0 int256(params.tokensIn), TickMath.MIN_SQRT_RATIO+1, abi.encode(balanceBefore, params) ); // v3 pool uses sign the represents the flow of tokens into the pool, so negative amount means tokens leaving if (amountOut > 0 || uint256(-amountOut) < params.tokensOut) { revert InvalidSwap(params.tokensOut, amountOut); } numTokens = uint256(-amountOut); } function _swapToken1To0(IUniswapV3Pool pool, SwapParams memory params) private onlyAuthorizedUse(pool) returns (uint256 numTokens) { // limits are verified in the callback function to optimize gas uint256 balanceBefore = IERC20(params.tokenOut).balanceOf(params.recipient); (int256 amountOut,) = pool.swap( params.recipient, false, // "zeroForOne": The direction of the swap, true for token0 to token1, false for token1 to token0 int256(params.tokensIn), TickMath.MAX_SQRT_RATIO-1, abi.encode(balanceBefore, params) ); // v3 pool uses sign the represents the flow of tokens into the pool, so negative amount means tokens leaving if (amountOut > 0 || uint256(-amountOut) < params.tokensOut) { revert InvalidSwap(params.tokensOut, amountOut); } numTokens = uint256(-amountOut); } function _buy(address token, uint256 numEth, uint256 limit, address wethHolder, uint24 fee) internal returns (uint256 numTokens) { (IUniswapV3Pool pool, bool tokenFirst) = _v3pool(token, fee); if (address(pool) == address(0)) { revert UninitializedUniswapPool(token, fee); } SwapParams memory params = SwapParams({ source: wethHolder, recipient: address(this), tokensIn: numEth, tokensOut: limit, tokenIn: _wethAddr, tokenOut: token }); if (tokenFirst) { numTokens = _swapToken1To0(pool, params); } else { numTokens = _swapToken0To1(pool, params); } } struct RewardParams { uint256 numEth; uint256 expectedAvgEth; uint32 averagePeriodInSeconds; } function _sell( address token, uint256 numTokens, uint256 limit, uint24 fee, address recipient) internal returns (RewardParams memory) { (IUniswapV3Pool pool, bool tokenFirst) = _v3pool(token, fee); if (address(pool) == address(0)) { revert UninitializedUniswapPool(token, fee); } SwapParams memory params = SwapParams({ source: address(this), recipient: recipient, tokensIn: numTokens, tokensOut: limit, tokenIn: token, tokenOut: _wethAddr }); ObservedEntry memory oldest = oldestObservation(pool); if (!oldest.poolInitialized) { revert UninitializedUniswapPool(token, fee); } if (tokenFirst) { (uint160 avgSqrtPrice, uint32 period) = calculateTWAP(pool, oldest); uint256 numEth = _swapToken0To1(pool, params); return RewardParams({ numEth: numEth, expectedAvgEth: expectedEthForToken0(numTokens, avgSqrtPrice), averagePeriodInSeconds: period }); } else { (uint160 avgSqrtPrice, uint32 period) = calculateTWAP(pool, oldest); uint256 numEth = _swapToken1To0(pool, params); return RewardParams({ numEth: numEth, expectedAvgEth: expectedEthForToken1(numTokens, avgSqrtPrice), averagePeriodInSeconds: period }); } } function estimateRewardParams(address token, uint256 numTokens, uint24 fee) internal view returns ( RewardParams memory) { (IUniswapV3Pool pool, bool tokenFirst) = _v3pool(token, fee); if (address(pool) == address(0)) { return RewardParams({ numEth: 0, expectedAvgEth: 0, averagePeriodInSeconds: 0 }); } ObservedEntry memory oldest = oldestObservation(pool); if (!oldest.poolInitialized) { return RewardParams({ numEth: 0, expectedAvgEth: 0, averagePeriodInSeconds: 0 }); } (uint160 avgSqrtPrice, uint32 period) = calculateTWAP(pool, oldest); if (tokenFirst) { return RewardParams({ numEth: 0, // really wish Uniswap v3 had provided a read-only API for querying this expectedAvgEth: expectedEthForToken0(numTokens, avgSqrtPrice), averagePeriodInSeconds: period }); } else { return RewardParams({ numEth: 0, expectedAvgEth: expectedEthForToken1(numTokens, avgSqrtPrice), averagePeriodInSeconds: period }); } } struct ObservedEntry { uint32 blockTimestamp; int56 tickCumulative; uint16 observationCardinality; bool poolInitialized; } function oldestObservation(IUniswapV3Pool pool) internal view returns (ObservedEntry memory) { (,,uint16 observationIndex, uint16 observationCardinality,,,) = pool.slot0(); if (observationCardinality == 0) { return ObservedEntry(0,0,0, false); } uint16 oldestIndex = uint16((uint32(observationIndex) + 1) % observationCardinality); { // it's important to check if the observation in oldestIndex is initialized, because if it's not, then // the oracle has not been fully initialized after pool.increaseObservationCardinalityNext() and oldest // observation is actually the index 0 (uint32 blockTimestamp, int56 tickCumulative,, bool initialized) = pool.observations(oldestIndex); if (initialized) { return ObservedEntry({ blockTimestamp: blockTimestamp, tickCumulative: tickCumulative, observationCardinality: observationCardinality, poolInitialized: true }); } } { (uint32 blockTimestamp, int56 tickCumulative,,) = pool.observations(0); return ObservedEntry({ blockTimestamp: blockTimestamp, tickCumulative: tickCumulative, observationCardinality: observationCardinality, poolInitialized: true }); } } function getSqrtRatioAtAverageTick(uint period, int tickCumulativeDiff) pure internal returns (uint160) { int24 avgTick = int24(tickCumulativeDiff / int(uint(period))); // round down to negative infinity is correct behavior for tick math if (tickCumulativeDiff < 0 && (tickCumulativeDiff % int(uint(period)) != 0)) avgTick--; return TickMath.getSqrtRatioAtTick(avgTick); } function expectedEthForToken1(uint numTokens, uint sqrtPriceX96) internal pure returns (uint) { if (sqrtPriceX96 == 0) { // calculated average price can be 0 when no swaps has been done and observations are not updated return 0; } // derivation from the whitepaper equations when weth is the token0: // Q96 = 2^96, sqrtPriceX96 = Q*sqrt(price) = sqrt(numTokens/numEth) // => (sqrtPriceX96/Q96)^2 = numTokens/numEth // => numEth = numTokens / sqrtPriceX96^2 / Q96^2 // = (Q96^2 * numTokens) / sqrtPriceX96^2 // = (2 ** 192) * numTokens / (sqrtPriceX96 ** 2) if (numTokens < Q64 && sqrtPriceX96 < Q128) { return Q192 * numTokens / (sqrtPriceX96 ** 2); } else { // either numTokens or price is too high for full precision math within a uint256, so we derive an alternative where // the fixedpoint resolution is reduced from Q96 to Q64: // ((sqrtPriceX96/2^32) / (Q96/2^32))^2 = numTokens/numEth // => ((sqrtPriceX64) / (Q64))^2 = numTokens/numEth // => ((sqrtPriceX64) / (Q64))^2 = numTokens/numEth // => numEth = numTokens / sqrtPriceX64^2 / Q64^2 // = (2 ** 128 * numTokens ) / sqrtPriceX64^2 // this makes the overflow practically impossible, but increases the precision loss (which is acceptable since this // math is only used for estimating reward parameters) uint sqrtPriceX64 = sqrtPriceX96 / 2**32; return (Q128 * numTokens) / (sqrtPriceX64**2); } } function expectedEthForToken0(uint numTokens, uint sqrtPriceX96) internal pure returns (uint) { if (sqrtPriceX96 == 0) { // calculated average price can be 0 when no swaps has been done and observations are not updated return 0; } if (numTokens == 0) { return 0; } // derivation from the whitepaper equations when weth is the token1: // Q96 = 2^96, sqrtPriceX96 = Q*sqrt(price) = sqrt(numEth/numTokens) // => (sqrtPriceX96/Q96)^2 = numEth/numTokens // => numEth = numTokens * sqrtPriceX96^2 / Q96^2 // = (2 ** 192) * numTokens / (sqrtPriceX96 ** 2) // = sqrtPriceX96 ** 2 / (2 ** 192 / numTokens) if (sqrtPriceX96 < Q128) { return (sqrtPriceX96 ** 2) / (Q192 / numTokens); } else { // if price is too high for full precision math within a uint256, we derive an alternative where // the fixedpoint resolution is reduced from Q96 to Q64: // ((sqrtPriceX96/2^32) / (Q96/2^32))^2 = numEth/numTokens // => ((sqrtPriceX64) / (Q64))^2 = numEth/numTokens // => numEth = numTokens * sqrtPriceX64^2 / Q64^2 // = sqrtPriceX64 ** 2 / (2 ** 128 / numTokens) // the level of precision loss is acceptable since this math is only used for estimating reward parameters uint sqrtPriceX64 = sqrtPriceX96 / 2**32; return (sqrtPriceX64**2) / (Q128 / numTokens); } } function calculateTWAP(IUniswapV3Pool pool, ObservedEntry memory preSwap) internal view returns (uint160 avgSqrtPrice, uint32 period) { if (preSwap.observationCardinality == 1) { return (0, 0); } period = uint32(Math.min(block.timestamp - preSwap.blockTimestamp, MAX_TWAP_PERIOD)); uint32[] memory secondAgos = new uint32[](2); secondAgos[0] = period; secondAgos[1] = 0; (int56[] memory tickCumulatives, ) = pool.observe(secondAgos); avgSqrtPrice = getSqrtRatioAtAverageTick(period, tickCumulatives[1] - tickCumulatives[0]); } function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external override onlyAuthorizedCallback { if (amount1Delta < 0 && amount0Delta < 0) { // this should never happen, but in case it does, it would wreck these calculations so check and revert revert InvalidUniswapState(); } // if delta0 is positive (meaning tokens are expected to increase in the pool) then delta1 is negative // (meaning pool's token amounts are expected to decrease), and vice versa (uint256 amountIn, uint256 amountOut) = amount0Delta > 0 ? (uint256(amount0Delta), uint256(-amount1Delta)) : (uint256(amount1Delta), uint256(-amount0Delta)); (uint256 balanceBeforeSwap, SwapParams memory params) = abi.decode(data, (uint256, SwapParams)); // Pool has already transferred the `amountOut` tokens to recipient, so check the limit before transferring the tokens if (IERC20(params.tokenOut).balanceOf(params.recipient) < balanceBeforeSwap + params.tokensOut) { revert SlippageExceeded(params.tokensOut, amountOut); } // check if for some reason the pool actually tries to request more tokens than user allowed if (amountIn > params.tokensIn) { revert AllowanceExceeded(params.tokensIn, amountIn); } if (params.source == address(this)) { IERC20(params.tokenIn).transfer(msg.sender, amountIn); } else { IERC20(params.tokenIn).transferFrom(params.source, msg.sender, amountIn); } } function _v3pool( address token, uint24 fee ) internal view returns (IUniswapV3Pool pool, bool tokenFirst) { // save an SLOAD address weth = _wethAddr; // as order of tokens is important in Uniswap pairs, we record this information here and pass it on to caller // for gas optimization tokenFirst = token < weth; // it's better to just query UniswapV3Factory for pool address instead of calculating the CREATE2 address // ourselves, as there are now three fee-tiers it's not guaranteed that all three are created for WETH-pairs // and any subsequent calls to non-existing pool will fail - and the UniswapV3Factory holds the canonical information // of which fee tiers are created // (and after EIP-2929, the uniswap factory address can be added to warmup accesslist which makes the call cost // insignificant compared to safety and simplicity gains) pool = IUniswapV3Pool(IUniswapV3Factory(_uniswapFactoryAddr).getPool(token, weth, fee)); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IVanillaV1MigrationState, IVanillaV1Converter} from "./interfaces/IVanillaV1Migration01.sol"; /// @title The contract keeping the record of VNL v1 -> v1.1 migration state contract VanillaV1MigrationState is IVanillaV1MigrationState { address private immutable owner; /// @inheritdoc IVanillaV1MigrationState bytes32 public override stateRoot; /// @inheritdoc IVanillaV1MigrationState uint64 public override blockNumber; /// @inheritdoc IVanillaV1MigrationState uint64 public override conversionDeadline; /// @dev the conversion deadline is initialized to 30 days from the deployment /// @param migrationOwner The address of the owner of migration state constructor(address migrationOwner) { owner = migrationOwner; conversionDeadline = uint64(block.timestamp + 30 days); } modifier onlyOwner() { if (msg.sender != owner) { revert UnauthorizedAccess(); } _; } modifier beforeDeadline() { if (block.timestamp >= conversionDeadline) { revert MigrationStateUpdateDisabled(); } _; } /// @inheritdoc IVanillaV1MigrationState function updateConvertibleState(bytes32 newStateRoot, uint64 blockNum) onlyOwner beforeDeadline external override { stateRoot = newStateRoot; blockNumber = blockNum; conversionDeadline = uint64(block.timestamp + 30 days); } /// @inheritdoc IVanillaV1MigrationState function verifyEligibility(bytes32[] memory proof, address tokenOwner, uint256 amount) external view override returns (bool) { // deliberately using encodePacked with a delimiter string to resolve ambiguity and let client implementations be simpler bytes32 leafInTree = keccak256(abi.encodePacked(tokenOwner, ":", amount)); return block.timestamp < conversionDeadline && MerkleProof.verify(proof, stateRoot, leafInTree); } } /// @title Conversion functionality for migrating VNL v1 tokens to VNL v1.1 abstract contract VanillaV1Converter is IVanillaV1Converter { /// @inheritdoc IVanillaV1Converter IVanillaV1MigrationState public override migrationState; IERC20 internal vnl; constructor(IVanillaV1MigrationState _state, IERC20 _VNLv1) { migrationState = _state; vnl = _VNLv1; } function mintConverted(address target, uint256 amount) internal virtual; /// @inheritdoc IVanillaV1Converter function checkEligibility(bytes32[] memory proof) external view override returns (bool convertible, bool transferable) { uint256 balance = vnl.balanceOf(msg.sender); convertible = migrationState.verifyEligibility(proof, msg.sender, balance); transferable = balance > 0 && vnl.allowance(msg.sender, address(this)) >= balance; } /// @inheritdoc IVanillaV1Converter function convertVNL(bytes32[] memory proof) external override { if (block.timestamp >= migrationState.conversionDeadline()) { revert ConversionWindowClosed(); } uint256 convertedAmount = vnl.balanceOf(msg.sender); if (convertedAmount == 0) { revert NoConvertibleVNL(); } // because VanillaV1Token01's cannot be burned, the conversion just locks them into this contract permanently address freezer = address(this); uint256 previouslyFrozen = vnl.balanceOf(freezer); // we know that OpenZeppelin ERC20 returns always true and reverts on failure, so no need to check the return value vnl.transferFrom(msg.sender, freezer, convertedAmount); // These should never fail as we know precisely how VanillaV1Token01.transferFrom is implemented if (vnl.balanceOf(freezer) != previouslyFrozen + convertedAmount) { revert FreezerBalanceMismatch(); } if (vnl.balanceOf(msg.sender) > 0) { revert UnexpectedTokensAfterConversion(); } if (!migrationState.verifyEligibility(proof, msg.sender, convertedAmount)) { revert VerificationFailed(); } // finally let implementor to mint the converted amount of tokens and log the event mintConverted(msg.sender, convertedAmount); emit VNLConverted(msg.sender, convertedAmount); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "./interfaces/IVanillaV1Safelist01.sol"; /// @title The contract that keeps a safelist of rewardable ERC-20 tokens and next approved Vanilla version contract VanillaV1Safelist01 is IVanillaV1Safelist01 { address private immutable owner; /// @inheritdoc IVanillaV1Safelist01 mapping(address => bool) public override isSafelisted; /// @inheritdoc IVanillaV1Safelist01 address public override nextVersion; constructor(address safeListOwner) { owner = safeListOwner; } modifier onlyOwner() { if (msg.sender != owner) { revert UnauthorizedAccess(); } _; } /// @notice Adds and removes tokens to/from the safelist. Only for the owner. /// @dev Adds first and removes second, so adding and removing a token will not result in safelisted token /// @param added Array of added ERC-20 addresses /// @param removed Array of removed ERC-20 addresses function modify(address[] calldata added, address[] calldata removed) external onlyOwner { uint numAdded = added.length; if (numAdded > 0) { for (uint i = 0; i < numAdded; i++) { isSafelisted[added[i]] = true; } emit TokensAdded(added); } uint numRemoved = removed.length; if (numRemoved > 0) { for (uint i = 0; i < numRemoved; i++) { delete isSafelisted[removed[i]]; } emit TokensRemoved(removed); } } /// @notice Approves the next version implementation. Only for the owner. /// @param implementation Address of the IVanillaV1MigrationTarget02 implementation function approveNextVersion(address implementation) external onlyOwner { nextVersion = implementation; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; interface VanillaV1API01 { /** @notice Checks if the given ERC-20 token will be eligible for rewards (i.e. a safelisted token) @param token The ERC-20 token address */ function isTokenRewarded(address token) external view returns (bool); /// internally tracked reserves for price manipulation protection for each token (Uniswap uses uint112 so uint128 is plenty) function wethReserves(address token) external view returns (uint128); function epoch() external view returns (uint256); function vnlContract() external view returns (address); function reserveLimit() external view returns (uint128); /// Price data, indexed as [owner][token] function tokenPriceData(address owner, address token) external view returns (uint256 ethSum, uint256 tokenSum, uint256 weightedBlockSum, uint256 latestBlock); /** @notice Estimates the reward. @dev Estimates the reward for given `owner` when selling `numTokensSold``token`s for `numEth` Ether. Also returns the individual components of the reward formula. @return profitablePrice The expected amount of Ether for this trade. Profit of this trade can be calculated with `numEth`-`profitablePrice`. @return avgBlock The volume-weighted average block for the `owner` and `token` @return htrs The Holding/Trading Ratio, Squared- estimate for this trade, percentage value range in fixed point range 0-100.0000. @return vpc The Value-Protection Coefficient- estimate for this trade, percentage value range in fixed point range 0-100.0000. @return reward The token reward estimate for this trade. */ function estimateReward( address owner, address token, uint256 numEth, uint256 numTokensSold ) external view returns ( uint256 profitablePrice, uint256 avgBlock, uint256 htrs, uint256 vpc, uint256 reward ); /** @notice Buys the tokens with Ether. Use the external pricefeed for pricing. @dev Buys the `numToken` tokens for all the msg.value Ether, before `blockTimeDeadline` @param token The address of ERC20 token to be bought @param numToken The amount of ERC20 tokens to be bought @param blockTimeDeadline The block timestamp when this buy-transaction expires */ function depositAndBuy( address token, uint256 numToken, uint256 blockTimeDeadline ) external payable; /** @notice Buys the tokens with WETH. Use the external pricefeed for pricing. @dev Buys the `numToken` tokens for all the msg.value Ether, before `blockTimeDeadline` @param token The address of ERC20 token to be bought @param numEth The amount of WETH to spend. Needs to be pre-approved for the VanillaRouter. @param numToken The amount of ERC20 tokens to be bought @param blockTimeDeadline The block timestamp when this buy-transaction expires */ function buy( address token, uint256 numEth, uint256 numToken, uint256 blockTimeDeadline ) external; /** @notice Sells the tokens the caller owns. Use the external pricefeed for pricing. @dev Sells the `numToken` tokens msg.sender owns, for `numEth` ether, before `blockTimeDeadline` @param token The address of ERC20 token to be sold @param numToken The amount of ERC20 tokens to be sold @param numEthLimit The minimum amount of ether to be received for exchange (the limit order) @param blockTimeDeadline The block timestamp when this sell-transaction expires */ function sell( address token, uint256 numToken, uint256 numEthLimit, uint256 blockTimeDeadline ) external; /** @notice Sells the tokens the caller owns. Use the external pricefeed for pricing. @dev Sells the `numToken` tokens msg.sender owns, for `numEth` ether, before `blockTimeDeadline` @param token The address of ERC20 token to be sold @param numToken The amount of ERC20 tokens to be sold @param numEthLimit The minimum amount of ether to be received for exchange (the limit order) @param blockTimeDeadline The block timestamp when this sell-transaction expires */ function sellAndWithdraw( address token, uint256 numToken, uint256 numEthLimit, uint256 blockTimeDeadline ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "./IVanillaV1Token02.sol"; import "./IVanillaV1Safelist01.sol"; /// @title Entry point API for Vanilla trading router interface IVanillaV1Router02 { /// @notice Gets the epoch block.number used in reward calculations function epoch() external view returns (uint256); /// @notice Gets the address of the VNL token contract function vnlContract() external view returns (IVanillaV1Token02); /// @dev data for calculating volume-weighted average prices, average purchasing block, and limiting trades per block struct PriceData { uint256 weightedBlockSum; uint112 ethSum; uint112 tokenSum; uint32 latestBlock; } /// @notice Price data, indexed as [owner][token] function tokenPriceData(address owner, address token) external view returns ( uint256 weightedBlockSum, uint112 ethSum, uint112 tokenSum, uint32 latestBlock); /// @dev Emitted when tokens are sold. /// @param seller The owner of tokens. /// @param token The address of the sold token. /// @param amount Number of sold tokens. /// @param eth The received ether from the trade. /// @param profit The calculated profit from the trade. /// @param reward The amount of VanillaGovernanceToken reward tokens transferred to seller. event TokensSold( address indexed seller, address indexed token, uint256 amount, uint256 eth, uint256 profit, uint256 reward ); /// @dev Emitted when tokens are bought. /// @param buyer The new owner of tokens. /// @param token The address of the purchased token. /// @param eth The amount of ether spent in the trade. /// @param amount Number of purchased tokens. event TokensPurchased( address indexed buyer, address indexed token, uint256 eth, uint256 amount ); /// @notice Gets the address of the safelist contract function safeList() external view returns (IVanillaV1Safelist01); struct TradeResult { /// the number of Ether received in the trade uint256 price; /// the length of observable history available in Uniswap v3 pool (5 minute cap) uint256 twapPeriodInSeconds; /// the number of Ether expected to make trade profitable uint256 profitablePrice; /// the max number of Ether to be used in reward calculations (also equals the 5-min capped TWAP price from the pool) uint256 maxProfitablePrice; /// the amount of rewardable profit to be used in reward calculations (the full profit equals `profitablePrice - price`) uint256 rewardableProfit; /// the amount of VNL reward for this trade uint256 reward; } struct RewardEstimate { /// estimate when trading a token in a low-fee Uniswap v3 pool (0.05%) TradeResult low; /// estimate when trading a token in a medium-fee Uniswap v3 pool (0.3%) TradeResult medium; /// estimate when trading a token in a high-fee Uniswap v3 pool (1.0%) TradeResult high; } /// @notice Estimates the reward. Not intended to be called from other contracts. /// @dev Estimates the reward for given `owner` when selling `numTokensSold``token`s for `numEth` Ether. Also returns the individual components of the reward formula. /// @return avgBlock The volume-weighted average block for the `owner` and `token` /// @return htrs The Holding/Trading Ratio, Squared- estimate for this trade, percentage value range in fixed point range 0-100.0000. /// @return estimate The token reward estimate for this trade for every Uniswap v3 fee-tier. function estimateReward( address owner, address token, uint256 numEth, uint256 numTokensSold ) external view returns ( uint256 avgBlock, uint256 htrs, RewardEstimate memory estimate ); /// @notice Delegate call to multiple functions in this Router and return their results iff they all succeed /// @param data The function calls encoded /// @return results The results of the encoded function calls, in the same order function execute(bytes[] calldata data) external returns (bytes[] memory results); /// @notice Delegate call to multiple functions in this Router and return their results iff they all succeed /// @dev All `msg.value` will be wrapped to WETH before executing the functions. /// @param data The function calls encoded /// @return results The results of the encoded function calls, in the same order function executePayable(bytes[] calldata data) external payable returns (bytes[] memory results); struct OrderData { // The address of the token to be bought or sold address token; // if true, buy-order transfers WETH from caller and sell-order transfers WETHs back to caller without withdrawing // if false, it's assumed that executePayable is used to deposit/withdraw WETHs before order bool useWETH; // The exact amount of WETH to be spent when buying or the limit amount of WETH to be received when selling. uint256 numEth; // The exact amount of token to be sold when selling or the limit amount of token to be received when buying. uint256 numToken; // The block.timestamp when this order expires uint256 blockTimeDeadline; // The Uniswap v3 fee tier to use for the swap (500 = 0.05%, 3000 = 0.3%, 10000 = 1.0%) uint24 fee; } /// @notice Buys the tokens with WETH. Use the external pricefeed for pricing. Do not send ether to this function. /// @dev Buys the `buyOrder.numToken` tokens for all the `buyOrder.numEth` WETH, before `buyOrder.blockTimeDeadline` /// @param buyOrder.token The address of ERC20 token to be bought /// @param buyOrder.useWETH Whether to buy directly with caller's WETHs instead of depositing `msg.value` /// @param buyOrder.numEth The amount of WETH to spend. /// @param buyOrder.numToken The minimum amount of ERC20 tokens to be bought (the limit order) /// @param buyOrder.blockTimeDeadline The block timestamp when this buy-transaction expires function buy( OrderData calldata buyOrder ) payable external; /// @notice Sells the tokens the caller owns for WETH. Use the external pricefeed for pricing. Do not send ether to this function. /// @dev Sells the `sellOrder.numToken` tokens msg.sender owns, for `sellOrder.numEth` ether, before `sellOrder.blockTimeDeadline` /// @param sellOrder.token The address of ERC20 token to be sold /// @param sellOrder.useWETH Whether to transfer WETHs directly to caller instead of withdrawing them to Ether /// @param sellOrder.numToken The amount of ERC20 tokens to be sold /// @param sellOrder.numEth The minimum amount of ether to be received for exchange (the limit order) /// @param sellOrder.blockTimeDeadline The block timestamp when this sell-transaction expires function sell( OrderData calldata sellOrder ) payable external; /// @notice Transfer all the tokens msg.sender owns to msg.sender /// @param token The address of ERC20 token to be withdrawn function withdrawTokens(address token) external; /// @notice Migration the token position the msg.sender holds to the next version. /// @param token The address of ERC20 token position to be migrated /// @param nextVersion The address of the next Vanilla Router version. function migratePosition(address token, address nextVersion) external; }
// 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: MIT pragma solidity ^0.8.0; import "../IERC20.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 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) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _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.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: GPL-3.0-or-later pragma solidity ^0.8.4; interface IVanillaV1MigrationTarget02 { /// @notice Called by IVanillaV1Router02#migratePosition. /// @dev Router transfers the tokens before calling this function, so that balance can be verified. function migrateState(address owner, address token, uint256 ethSum, uint256 tokenSum, uint256 weightedBlockSum, uint256 latestBlock) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "./IVanillaV1Migration01.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IVanillaV1Token02 is IERC20, IVanillaV1Converter { function mint(address to, uint256 tradeReward) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface VanillaV1Token01 is IERC20 { function mint(address to, uint256 tradeReward) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; interface IVanillaV1MigrationState { /// @notice The current Merkle tree root for checking the eligibility for token conversion /// @dev tree leaves are tuples of (VNLv1-owner-address, VNLv1-token-balance), ordered as keccak256(abi.encodePacked(tokenOwner, ":", amount)) function stateRoot() external view returns (bytes32); /// @notice Gets the block.number which was used to calculate the `stateRoot()` (for off-chain verification) function blockNumber() external view returns (uint64); /// @notice Gets the current deadline for conversion as block.timestamp function conversionDeadline() external view returns (uint64); /// @notice Checks if `tokenOwner` owning `amount` of VNL v1s is eligible for token conversion. Needs a Merkle `proof`. /// @dev The proof must be generated from a Merkle tree where leaf data is formatted as "<address>:<VNL v1 balance>" before hashing, /// leaves and intermediate nodes are always hashed with keccak256 and then sorted. /// @param proof The proof that user is operating on the same state /// @param tokenOwner The address owning the VanillaV1Token01 tokens /// @param amount The amount of VanillaV1Token01 tokens (i.e. the balance of the tokenowner) /// @return true iff `tokenOwner` is eligible to convert `amount` tokens to VanillaV1Token02 function verifyEligibility(bytes32[] memory proof, address tokenOwner, uint256 amount) external view returns (bool); /// @notice Updates the Merkle tree for provable ownership of convertible VNL v1 tokens. Only for the owner. /// @dev Moves also the internal deadline forward 30 days /// @param newStateRoot The new Merkle tree root for checking the eligibility for token conversion /// @param blockNum The block.number whose state was used to calculate the `newStateRoot` function updateConvertibleState(bytes32 newStateRoot, uint64 blockNum) external; /// @notice thrown if non-owners try to modify state error UnauthorizedAccess(); /// @notice thrown if attempting to update migration state after conversion deadline error MigrationStateUpdateDisabled(); } interface IVanillaV1Converter { /// @notice Gets the address of the migration state contract function migrationState() external view returns (IVanillaV1MigrationState); /// @dev Emitted when VNL v1.01 is converted to v1.02 /// @param converter The owner of tokens. /// @param amount Number of converted tokens. event VNLConverted(address converter, uint256 amount); /// @notice Checks if all `msg.sender`s VanillaV1Token01's are eligible for token conversion. Needs a Merkle `proof`. /// @dev The proof must be generated from a Merkle tree where leaf data is formatted as "<address>:<VNL v1 balance>" before hashing, and leaves and intermediate nodes are always hashed with keccak256 and then sorted. /// @param proof The proof that user is operating on the same state /// @return convertible true if `msg.sender` is eligible to convert all VanillaV1Token01 tokens to VanillaV1Token02 and conversion window is open /// @return transferable true if `msg.sender`'s VanillaV1Token01 tokens are ready to be transferred for conversion function checkEligibility(bytes32[] memory proof) external view returns (bool convertible, bool transferable); /// @notice Converts _ALL_ `msg.sender`s VanillaV1Token01's to VanillaV1Token02 if eligible. The conversion is irreversible. /// @dev The proof must be generated from a Merkle tree where leaf data is formatted as "<address>:<VNL v1 balance>" before hashing, and leaves and intermediate nodes are always hashed with keccak256 and then sorted. /// @param proof The proof that user is operating on the same state function convertVNL(bytes32[] memory proof) external; /// @notice thrown when attempting to convert VNL after deadline error ConversionWindowClosed(); /// @notice thrown when attempting to convert 0 VNL error NoConvertibleVNL(); /// @notice thrown if for some reason VNL freezer balance doesn't match the transferred amount + old balance error FreezerBalanceMismatch(); /// @notice thrown if for some reason user holds VNL v1 tokens after conversion (i.e. transfer failed) error UnexpectedTokensAfterConversion(); /// @notice thrown if user provided incorrect proof for conversion eligibility error VerificationFailed(); }
// 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; 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.8.4; // This library is a derived work from @uniswap/v3-core/contracts/libraries/TickMath.sol // (https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/libraries/TickMath.sol). // The modifications are: // - fixed integer conversion issues which allows to compile the library with Solidity 0.8 // - pruned the function `getTickAtSqrtRatio` which isn't used in Vanilla /// @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(int256(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)); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; abstract contract VanillaV1Constants02 { error UnauthorizedReentrantAccess(); error UnauthorizedDelegateCall(); error UnauthorizedCallback(); error AllowanceExceeded(uint256 allowed, uint256 actual); error SlippageExceeded(uint256 expected, uint256 actual); error InvalidSwap(uint256 expected, int256 amountReceived); error InvalidUniswapState(); error UninitializedUniswapPool(address token, uint24 fee); error NoTokenPositionFound(address owner, address token); error TooManyTradesPerBlock(); error WrongTradingParameters(); error UnauthorizedValueSent(); error InvalidWethAccount(); error TradeExpired(); error TokenBalanceExceeded(uint256 tokens, uint112 balance); error UnapprovedMigrationTarget(address invalidVersion); // constant units for Q-number calculations (https://en.wikipedia.org/wiki/Q_(number_format)) uint256 internal constant Q32 = 2**32; uint256 internal constant Q64 = 2**64; uint256 internal constant Q128 = 2**128; uint256 internal constant Q192 = 2**192; uint32 internal constant MAX_TWAP_PERIOD = 5 minutes; }
// 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: GPL-3.0-or-later pragma solidity ^0.8.4; interface IVanillaV1Safelist01 { /// @notice Queries if given `token` address is safelisted. /// @param token The ERC-20 address /// @return true iff safelisted function isSafelisted(address token) external view returns (bool); /// @notice Queries the safelisted address of the next Vanilla version. /// @return The address of the next Vanilla version which implements IVanillaV1MigrationTarget02 function nextVersion() external view returns (address); /// @notice Emitted when tokens are added to the safelist /// @param tokens The ERC-20 addresses that are added to the safelist event TokensAdded (address[] tokens); /// @notice Emitted when tokens are removed from the safelist /// @param tokens The ERC-20 addresses that are added to the safelist event TokensRemoved (address[] tokens); /// @notice Thrown when non-owner attempting to modify safelist state error UnauthorizedAccess (); }
// SPDX-License-Identifier: MIT pragma solidity ^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); } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IPeripheryImmutableState","name":"_peripheryState","type":"address"},{"internalType":"contract VanillaV1API01","name":"_v1temp","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"allowed","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"AllowanceExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"int256","name":"amountReceived","type":"int256"}],"name":"InvalidSwap","type":"error"},{"inputs":[],"name":"InvalidUniswapState","type":"error"},{"inputs":[],"name":"InvalidWethAccount","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"NoTokenPositionFound","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"SlippageExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokens","type":"uint256"},{"internalType":"uint112","name":"balance","type":"uint112"}],"name":"TokenBalanceExceeded","type":"error"},{"inputs":[],"name":"TooManyTradesPerBlock","type":"error"},{"inputs":[],"name":"TradeExpired","type":"error"},{"inputs":[{"internalType":"address","name":"invalidVersion","type":"address"}],"name":"UnapprovedMigrationTarget","type":"error"},{"inputs":[],"name":"UnauthorizedCallback","type":"error"},{"inputs":[],"name":"UnauthorizedDelegateCall","type":"error"},{"inputs":[],"name":"UnauthorizedReentrantAccess","type":"error"},{"inputs":[],"name":"UnauthorizedValueSent","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"UninitializedUniswapPool","type":"error"},{"inputs":[],"name":"WrongTradingParameters","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"eth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"TokensSold","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"useWETH","type":"bool"},{"internalType":"uint256","name":"numEth","type":"uint256"},{"internalType":"uint256","name":"numToken","type":"uint256"},{"internalType":"uint256","name":"blockTimeDeadline","type":"uint256"},{"internalType":"uint24","name":"fee","type":"uint24"}],"internalType":"struct IVanillaV1Router02.OrderData","name":"buyOrder","type":"tuple"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"epoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"numEth","type":"uint256"},{"internalType":"uint256","name":"numTokensSold","type":"uint256"}],"name":"estimateReward","outputs":[{"internalType":"uint256","name":"avgBlock","type":"uint256"},{"internalType":"uint256","name":"htrs","type":"uint256"},{"components":[{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"twapPeriodInSeconds","type":"uint256"},{"internalType":"uint256","name":"profitablePrice","type":"uint256"},{"internalType":"uint256","name":"maxProfitablePrice","type":"uint256"},{"internalType":"uint256","name":"rewardableProfit","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"}],"internalType":"struct IVanillaV1Router02.TradeResult","name":"low","type":"tuple"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"twapPeriodInSeconds","type":"uint256"},{"internalType":"uint256","name":"profitablePrice","type":"uint256"},{"internalType":"uint256","name":"maxProfitablePrice","type":"uint256"},{"internalType":"uint256","name":"rewardableProfit","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"}],"internalType":"struct IVanillaV1Router02.TradeResult","name":"medium","type":"tuple"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"twapPeriodInSeconds","type":"uint256"},{"internalType":"uint256","name":"profitablePrice","type":"uint256"},{"internalType":"uint256","name":"maxProfitablePrice","type":"uint256"},{"internalType":"uint256","name":"rewardableProfit","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"}],"internalType":"struct IVanillaV1Router02.TradeResult","name":"high","type":"tuple"}],"internalType":"struct IVanillaV1Router02.RewardEstimate","name":"estimate","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"execute","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"executePayable","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"nextVersion","type":"address"}],"name":"migratePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"safeList","outputs":[{"internalType":"contract IVanillaV1Safelist01","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"useWETH","type":"bool"},{"internalType":"uint256","name":"numEth","type":"uint256"},{"internalType":"uint256","name":"numToken","type":"uint256"},{"internalType":"uint256","name":"blockTimeDeadline","type":"uint256"},{"internalType":"uint24","name":"fee","type":"uint24"}],"internalType":"struct IVanillaV1Router02.OrderData","name":"sellOrder","type":"tuple"}],"name":"sell","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"tokenPriceData","outputs":[{"internalType":"uint256","name":"weightedBlockSum","type":"uint256"},{"internalType":"uint112","name":"ethSum","type":"uint112"},{"internalType":"uint112","name":"tokenSum","type":"uint112"},{"internalType":"uint32","name":"latestBlock","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vnlContract","outputs":[{"internalType":"contract IVanillaV1Token02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101406040523480156200001257600080fd5b506040516200606e3803806200606e8339810160408190526200003591620004d9565b81806001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200007057600080fd5b505afa15801562000085573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000ab9190620004b3565b6001600160a01b031660a0816001600160a01b031660601b81525050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156200010157600080fd5b505afa15801562000116573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200013c9190620004b3565b6001600160601b0319606091821b16608052309081901b60c052600080546001600160a01b03191690911781556040805163cab8924960e01b815290518493503392916001600160a01b0385169163cab8924991600480820192602092909190829003018186803b158015620001b157600080fd5b505afa158015620001c6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001ec9190620004b3565b9050600082604051620001ff9062000489565b6001600160a01b039091168152602001604051809103906000f0801580156200022c573d6000803e3d6000fd5b50826040516200023c9062000497565b6001600160a01b03928316815291166020820152604001604051809103906000f08015801562000270573d6000803e3d6000fd5b509050806001600160a01b03166340c10f198462000302856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015620002c157600080fd5b505afa158015620002d6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002fc919062000517565b62000459565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156200034957600080fd5b505af11580156200035e573d6000803e3d6000fd5b50505050806001600160a01b0316610100816001600160a01b031660601b81525050836001600160a01b031663900cf0cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015620003ba57600080fd5b505afa158015620003cf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003f5919062000517565b60e05260405183906200040890620004a5565b6001600160a01b039091168152602001604051809103906000f08015801562000435573d6000803e3d6000fd5b5060601b6001600160601b031916610120525050600160025550620005bc92505050565b60008160556200046b82606462000551565b62000477919062000530565b62000483919062000573565b92915050565b6105c0806200407783390190565b6114f7806200463783390190565b6105408062005b2e83390190565b600060208284031215620004c5578081fd5b8151620004d281620005a3565b9392505050565b60008060408385031215620004ec578081fd5b8251620004f981620005a3565b60208401519092506200050c81620005a3565b809150509250929050565b60006020828403121562000529578081fd5b5051919050565b6000826200054c57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156200056e576200056e6200058d565b500290565b6000828210156200058857620005886200058d565b500390565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114620005b957600080fd5b50565b60805160601c60a05160601c60c05160601c60e0516101005160601c6101205160601c613a096200066e600039600081816102410152818161041801526120b301526000818161031101526113b50152600081816102bc015281816110d20152818161117401526111b801526000818161216001526123c901526000818160bb015281816105ba0152818161157101528181611609015281816117f90152611f73015260006118370152613a096000f3fe6080604052600436106100ab5760003560e01c80636b333a60116100645780636b333a601461022f5780637c30be4e1461027b578063900cf0cf146102aa578063c868bdbb146102ec578063cab89249146102ff578063fa461e331461033357600080fd5b80630bb96ff6146100fd57806338eea3861461011057806344471415146101af57806349df728c146101dc57806353a6cb78146101fc57806364a231ef1461021c57600080fd5b366100f857336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146100f657634e487b7160e01b600052600160045260246000fd5b005b600080fd5b6100f661010b366004613128565b610353565b34801561011c57600080fd5b5061017061012b366004612ea1565b6001602081815260009384526040808520909152918352912080549101546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1684565b6040516101a694939291909384526001600160701b0392831660208501529116604083015263ffffffff16606082015260800190565b60405180910390f35b3480156101bb57600080fd5b506101cf6101ca366004612f1e565b61039f565b6040516101a691906133ce565b3480156101e857600080fd5b506100f66101f7366004612e69565b6103cb565b34801561020857600080fd5b506100f6610217366004612ea1565b6103fb565b6101cf61022a366004612f1e565b61059b565b34801561023b57600080fd5b506102637f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101a6565b34801561028757600080fd5b5061029b610296366004612ed9565b61063c565b6040516101a6939291906134e7565b3480156102b657600080fd5b506102de7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016101a6565b6100f66102fa366004613128565b610728565b34801561030b57600080fd5b506102637f000000000000000000000000000000000000000000000000000000000000000081565b34801561033f57600080fd5b506100f661034e3660046130ad565b61076f565b806080013542811015610379576040516378ef33c160e01b815260040160405180910390fd5b600061038483610a35565b905061038f83610a5a565b61039a338285610ab4565b505050565b60606001600254146103b057600080fd5b600280556103bf338484610c09565b60016002559392505050565b3360006103d88284610d32565b905060006103e582610da3565b50509150506103f5848483610ddd565b50505050565b6001600160a01b03811615806104b35750806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630bafd60e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561046f57600080fd5b505afa158015610483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a79190612e85565b6001600160a01b031614155b156104e157604051637d13575160e01b81526001600160a01b03821660048201526024015b60405180910390fd5b3360006104ee8285610d32565b90506000806000806104ff85610da3565b9350935093509350610512888885610ddd565b604051637616f4f360e01b81526001600160a01b038781166004830152898116602483015260448201869052606482018590526084820184905260a48201839052881690637616f4f39060c401600060405180830381600087803b15801561057957600080fd5b505af115801561058d573d6000803e3d6000fd5b505050505050505050505050565b60606001600254146105ac57600080fd5b6002805534156106315760007f00000000000000000000000000000000000000000000000000000000000000009050806001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561061657600080fd5b505af115801561062a573d6000803e3d6000fd5b5050505050505b6103bf338484610c09565b600080610647612d60565b60006106538888610d32565b60408051608081018252825481526001909201546001600160701b038082166020850152600160701b82041691830191909152600160e01b900463ffffffff166060820152905060006106a988876101f4610e2f565b87815290506106b9868383610f66565b9085529550600091506106d190508887610bb8610e2f565b87815290506106e1868383610f66565b50602085015250600090506106f98887612710610e2f565b8781529050610709868383610f66565b5060408501525061071b905084611167565b9250509450945094915050565b80608001354281101561074e576040516378ef33c160e01b815260040160405180910390fd5b600061075983610a35565b905061076483610a5a565b6103f5338285611212565b6000546001600160a01b0316331461079a57604051637ae3640d60e11b815260040160405180910390fd5b6000831280156107aa5750600084125b156107c857604051631de3ccef60e01b815260040160405180910390fd5b600080600086136107e257846107dd8761392d565b6107ec565b856107ec8661392d565b909250905060008061080085870187613216565b915091508060600151826108149190613625565b60a082015160208301516040516370a0823160e01b81526001600160a01b0391821660048201529116906370a082319060240160206040518083038186803b15801561085f57600080fd5b505afa158015610873573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089791906131fe565b10156108c65760608101516040516371c4efed60e01b81526004810191909152602481018490526044016104d8565b80604001518411156108fc57806040015184604051635492412b60e11b81526004016104d8929190918252602082015260400190565b80516001600160a01b031630141561099a57608081015160405163a9059cbb60e01b8152336004820152602481018690526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561095c57600080fd5b505af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610994919061306e565b50610a2b565b608081015181516040516323b872dd60e01b81526001600160a01b039182166004820152336024820152604481018790529116906323b872dd90606401602060405180830381600087803b1580156109f157600080fd5b505af1158015610a05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a29919061306e565b505b5050505050505050565b6000610a476040830160208401613052565b15610a53575033919050565b5030919050565b60016002541415610ab1573415610a845760405163ca4c0aa560e01b815260040160405180910390fd5b610a946040820160208301613052565b610ab157604051635b44f25960e11b815260040160405180910390fd5b50565b6000610ac36020830183612e69565b6001600160a01b038086166000908152600160209081526040808320938516835292905281902091925083013590610afa816114a2565b6000610b1c8484606088013589610b1760c08b0160a08c016131db565b6114f4565b6001830154909150610b389084906001600160701b0316613625565b6001830180546001600160701b0319166001600160701b039283161790819055610b6b918391600160701b900416613625565b6001830180546001600160701b0392909216600160701b026dffffffffffffffffffffffffffff60701b19909216919091179055610ba9814361378c565b8254610bb59190613625565b825560408051848152602081018390526001600160a01b0386811692908a16917f6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b910160405180910390a350505050505050565b60608167ffffffffffffffff811115610c3257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c6557816020015b6060815260200190600190039081610c505790505b50905060005b82811015610d2157610ce330858584818110610c9757634e487b7160e01b600052603260045260246000fd5b9050602002810190610ca99190613537565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115cf92505050565b828281518110610d0357634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080610d19906138a6565b915050610c6b565b50610d2b846115f4565b9392505050565b6001600160a01b038281166000908152600160208181526040808420948616845293905291902090810154600160701b90046001600160701b0316610d9d576040516302e1ddb360e61b81526001600160a01b038085166004830152831660248201526044016104d8565b92915050565b6001810180548254600093849055929091556001600160701b0380821693600160701b83049091169291600160e01b900463ffffffff1690565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261039a908490611706565b610e5960405180606001604052806000815260200160008152602001600063ffffffff1681525090565b600080610e6686856117d8565b90925090506001600160a01b038216610ea65760405180606001604052806000815260200160008152602001600063ffffffff1681525092505050610d2b565b6000610eb1836118bd565b90508060600151610eea5760405180606001604052806000815260200160008152602001600063ffffffff168152509350505050610d2b565b600080610ef78584611b48565b915091508315610f4157604051806060016040528060008152602001610f268a856001600160a01b0316611d1f565b81526020018263ffffffff1681525095505050505050610d2b565b604051806060016040528060008152602001610f268a856001600160a01b0316611daf565b604080516080810182526000808252602082018190529181018290526060810191909152610f92612d92565b600084604001516001600160701b03168560000151610fb1919061368a565b905084604001516001600160701b031685602001516001600160701b031687610fda919061378c565b610fe4919061368a565b82604001818152505060008686604001516001600160701b03166110089190613822565b85518452604086015190915063ffffffff16156111035760408501805163ffffffff9081166020808701919091528701805160608701529151915160009261012c926110569291169061378c565b60408801516110679061012c613839565b63ffffffff16866040015161107c919061378c565b6110869190613625565b611090919061368a565b905060006110a2876000015183611e23565b9050846040015181116110b65760006110c5565b60408501516110c59082613822565b608086018190526110fb907f00000000000000000000000000000000000000000000000000000000000000009086904390611e39565b60a086015250505b61112886602001516001600160701b03168288604001516001600160701b0316611eb9565b6001600160701b0390811660208601528651604088015161114b92849116611eb9565b84526001600160701b0316604084015291959094509092509050565b60004382148061119657507f000000000000000000000000000000000000000000000000000000000000000043145b156111a357506000919050565b60006111af8343613822565b905060006111dd7f000000000000000000000000000000000000000000000000000000000000000043613822565b90506111e9818061378c565b6111f3838061378c565b61120090620f424061378c565b61120a919061368a565b949350505050565b60008061122b856112266020860186612e69565b610d32565b9050611236816114a2565b6001810154600160701b90046001600160701b03166060840135111561129057600181015460405163040b0e5160e31b815260608501356004820152600160701b9091046001600160701b031660248201526044016104d8565b60006112c26112a26020860186612e69565b606086013560408701356112bc60c0890160a08a016131db565b89611ec6565b604080516080810182528454815260018501546001600160701b038082166020840152600160701b82041692820192909252600160e01b90910463ffffffff166060808301919091529192506000918291611321918801359085610f66565b5060408201516001870180548451895560208501516001600160e01b0319909116600160701b6001600160701b03948516026001600160701b03191617921691909117905560a081015191935091501580159061138e575061138e6113896020880188612e69565b612091565b1561141a5760a08101516040516340c10f1960e01b815233600482015260248101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906340c10f1990604401600060405180830381600087803b15801561140157600080fd5b505af1158015611415573d6000803e3d6000fd5b505050505b6114276020870187612e69565b6001600160a01b0316886001600160a01b03167f34f38731fae2221a0127cde5769237f08a73e828efb7c9a19e4c6fa171ff763d8860600135866000015161146e8661212f565b60a087015160408051948552602085019390935291830152606082015260800160405180910390a350505195945050505050565b600181015443600160e01b90910463ffffffff16106114d4576040516313f0580960e01b815260040160405180910390fd5b60010180546001600160e01b0316600160e01b4363ffffffff1602179055565b600080600061150388856117d8565b90925090506001600160a01b0382166115455760405163e03ab9cf60e01b81526001600160a01b038916600482015262ffffff851660248201526044016104d8565b6040805160c0810182526001600160a01b038088168252306020830152918101899052606081018890527f00000000000000000000000000000000000000000000000000000000000000008216608082015290891660a082015281156115b6576115af8382612158565b93506115c3565b6115c083826123c1565b93505b50505095945050505050565b6060610d2b83836040518060600160405280602781526020016139ad602791396125b6565b6040516370a0823160e01b81523060048201527f0000000000000000000000000000000000000000000000000000000000000000906000906001600160a01b038316906370a0823190602401602060405180830381600087803b15801561165a57600080fd5b505af115801561166e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169291906131fe565b905080156116f557604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b1580156116dc57600080fd5b505af11580156116f0573d6000803e3d6000fd5b505050505b4780156103f5576103f5848261268a565b600061175b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127a39092919063ffffffff16565b80519091501561039a5780806020019051810190611779919061306e565b61039a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104d8565b604051630b4c774160e11b81526001600160a01b03838116600483018190527f00000000000000000000000000000000000000000000000000000000000000008083166024850181905262ffffff8616604486015260009492109290917f000000000000000000000000000000000000000000000000000000000000000090911690631698ee829060640160206040518083038186803b15801561187b57600080fd5b505afa15801561188f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b39190612e85565b9250509250929050565b604080516080810182526000808252602082018190529181018290526060810191909152600080836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561191d57600080fd5b505afa158015611931573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611955919061313f565b5050509350935050508061ffff166000141561199757505060408051608081018252600080825260208201819052918101829052606081019190915292915050565b60008161ffff168361ffff1660016119af919061363d565b6119b991906138e9565b60405163252c09d760e01b815261ffff82166004820152909150600090819081906001600160a01b0389169063252c09d79060240160806040518083038186803b158015611a0657600080fd5b505afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e91906132af565b935050925092508015611a895760405180608001604052808463ffffffff1681526020018360060b81526020018661ffff168152602001600115158152509650505050505050919050565b505060405163252c09d760e01b8152600060048201819052915081906001600160a01b0388169063252c09d79060240160806040518083038186803b158015611ad157600080fd5b505afa158015611ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0991906132af565b50506040805160808101825263ffffffff909316835260069190910b602083015261ffff90951694810194909452505060016060830152509392505050565b600080826040015161ffff1660011415611b6757506000905080611d18565b8251611b8590611b7d9063ffffffff1642613822565b61012c611e23565b60408051600280825260608201835292935060009290916020830190803683370190505090508181600081518110611bcd57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110611c0a57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0387169063883bdbfd90611c4e90859060040161342f565b60006040518083038186803b158015611c6657600080fd5b505afa158015611c7a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ca29190810190612f8e565b509050611d138363ffffffff1682600081518110611cd057634e487b7160e01b600052603260045260246000fd5b602002602001015183600181518110611cf957634e487b7160e01b600052603260045260246000fd5b6020026020010151611d0b91906137ab565b60060b6127b2565b935050505b9250929050565b600081611d2e57506000610d9d565b82611d3b57506000610d9d565b600160801b821015611d7157611d5583600160c01b61368a565b611d606002846136e1565b611d6a919061368a565b9050610d9d565b6000611d826401000000008461368a565b9050611d9284600160801b61368a565b611d9d6002836136e1565b611da7919061368a565b915050610d9d565b600081611dbe57506000610d9d565b6801000000000000000083108015611dd95750600160801b82105b15611df757611de96002836136e1565b611d6084600160c01b61378c565b6000611e086401000000008461368a565b9050611e156002826136e1565b611d9d85600160801b61378c565b6000818310611e325781610d2b565b5090919050565b600081611e485750600061120a565b83831415611e585750600061120a565b84831415611e685750600061120a565b6000611e748585613822565b90506000611e828786613822565b90508080611e90848061378c565b611e9a908761378c565b611ea4919061368a565b611eae919061368a565b979650505050505050565b600081611200848661378c565b611ef060405180606001604052806000815260200160008152602001600063ffffffff1681525090565b600080611efd88866117d8565b90925090506001600160a01b038216611f3f5760405163e03ab9cf60e01b81526001600160a01b038916600482015262ffffff861660248201526044016104d8565b6040805160c0810182523081526001600160a01b0386811660208301529181018990526060810188905289821660808201527f000000000000000000000000000000000000000000000000000000000000000090911660a08201526000611fa5846118bd565b90508060600151611fdf5760405163e03ab9cf60e01b81526001600160a01b038b16600482015262ffffff881660248201526044016104d8565b821561204557600080611ff28684611b48565b91509150600061200287866123c1565b905060405180606001604052808281526020016120288e866001600160a01b0316611d1f565b81526020018363ffffffff16815250975050505050505050612088565b6000806120528684611b48565b9150915060006120628786612158565b905060405180606001604052808281526020016120288e866001600160a01b0316611daf565b95945050505050565b60405163068acf9f60e31b81526001600160a01b0382811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906334567cf89060240160206040518083038186803b1580156120f757600080fd5b505afa15801561210b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9d919061306e565b60008160400151826000015111612147576000610d9d565b60408201518251610d9d9190613822565b6000805483907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b038083169116146121ab57604051630a9e32d360e41b815260040160405180910390fd5b306001600160a01b038216146121d4576040516311ac8bcf60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117825560a086015160208701516040516370a0823160e01b815290831660048201529116906370a082319060240160206040518083038186803b15801561223657600080fd5b505afa15801561224a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226e91906131fe565b90506000866001600160a01b031663128acb08876020015160008960400151600173fffd8963efd1fc6a506488495d951d5263988d266122ae91906137fa565b878c6040516020016122c192919061348c565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122f0959493929190613393565b6040805180830381600087803b15801561230957600080fd5b505af115801561231d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612341919061308a565b509050600081138061235e5750606086015161235c8261392d565b105b1561238c5760608601516040516304e510b960e51b81526004810191909152602481018290526044016104d8565b6123958161392d565b600080546001600160a01b0319166001600160a01b039590951694909417909355509095945050505050565b6000805483907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0380831691161461241457604051630a9e32d360e41b815260040160405180910390fd5b306001600160a01b0382161461243d576040516311ac8bcf60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117825560a086015160208701516040516370a0823160e01b815290831660048201529116906370a082319060240160206040518083038186803b15801561249f57600080fd5b505afa1580156124b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d791906131fe565b90506000866001600160a01b031663128acb088760200151600189604001516401000276a3600161250891906135fa565b878c60405160200161251b92919061348c565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161254a959493929190613393565b6040805180830381600087803b15801561256357600080fd5b505af1158015612577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259b919061308a565b915050600081138061235e5750606086015161235c8261392d565b6060833b6126155760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016104d8565b600080856001600160a01b0316856040516126309190613377565b600060405180830381855af49150503d806000811461266b576040519150601f19603f3d011682016040523d82523d6000602084013e612670565b606091505b50915091506126808282866127f5565b9695505050505050565b804710156126da5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016104d8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612727576040519150601f19603f3d011682016040523d82523d6000602084013e61272c565b606091505b505090508061039a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016104d8565b606061120a848460008561282e565b6000806127bf848461365c565b90506000831280156127d957506127d684846138c1565b15155b156127ec57806127e881613882565b9150505b61120a8161294b565b60608315612804575081610d2b565b8251156128145782518084602001fd5b8160405162461bcd60e51b81526004016104d89190613479565b60608247101561288f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104d8565b843b6128dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d8565b600080866001600160a01b031685876040516128f99190613377565b60006040518083038185875af1925050503d8060008114612936576040519150601f19603f3d011682016040523d82523d6000602084013e61293b565b606091505b5091509150611eae8282866127f5565b60008060008360020b12612962578260020b61296f565b8260020b61296f9061392d565b905061297e620d89e71961390c565b60020b8111156129b45760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016104d8565b6000600182166129c857600160801b6129da565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612a19576080612a14826ffff97272373d413259a46990580e213a61378c565b901c90505b6004821615612a43576080612a3e826ffff2e50f5f656932ef12357cf3c7fdcc61378c565b901c90505b6008821615612a6d576080612a68826fffe5caca7e10e4e61c3624eaa0941cd061378c565b901c90505b6010821615612a97576080612a92826fffcb9843d60f6159c9db58835c92664461378c565b901c90505b6020821615612ac1576080612abc826fff973b41fa98c081472e6896dfb254c061378c565b901c90505b6040821615612aeb576080612ae6826fff2ea16466c96a3843ec78b326b5286161378c565b901c90505b6080821615612b15576080612b10826ffe5dee046a99a2a811c461f1969c305361378c565b901c90505b610100821615612b40576080612b3b826ffcbe86c7900a88aedcffc83b479aa3a461378c565b901c90505b610200821615612b6b576080612b66826ff987a7253ac413176f2b074cf7815e5461378c565b901c90505b610400821615612b96576080612b91826ff3392b0822b70005940c7a398e4b70f361378c565b901c90505b610800821615612bc1576080612bbc826fe7159475a2c29b7443b29c7fa6e889d961378c565b901c90505b611000821615612bec576080612be7826fd097f3bdfd2022b8845ad8f792aa582561378c565b901c90505b612000821615612c17576080612c12826fa9f746462d870fdf8a65dc1f90e061e561378c565b901c90505b614000821615612c42576080612c3d826f70d869a156d2a1b890bb3df62baf32f761378c565b901c90505b618000821615612c6d576080612c68826f31be135f97d08fd981231505542fcfa661378c565b901c90505b62010000821615612c99576080612c94826f09aa508b5b7a84e1c677de54f3e99bc961378c565b901c90505b62020000821615612cc4576080612cbf826e5d6af8dedb81196699c329225ee60461378c565b901c90505b62040000821615612cee576080612ce9826d2216e584f5fa1ea926041bedfe9861378c565b901c90505b62080000821615612d16576080612d11826b048a170391f7dc42444e8fa261378c565b901c90505b60008460020b1315612d3157612d2e8160001961368a565b90505b612d40640100000000826138d5565b15612d4c576001612d4f565b60005b61120a9060ff16602083901c613625565b6040518060600160405280612d73612d92565b8152602001612d80612d92565b8152602001612d8d612d92565b905290565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600082601f830112612dd8578081fd5b81516020612ded612de8836135d6565b6135a5565b80838252828201915082860187848660051b8901011115612e0c578586fd5b855b85811015612e33578151612e2181613989565b84529284019290840190600101612e0e565b5090979650505050505050565b8051600681900b8114612e5257600080fd5b919050565b805161ffff81168114612e5257600080fd5b600060208284031215612e7a578081fd5b8135610d2b81613989565b600060208284031215612e96578081fd5b8151610d2b81613989565b60008060408385031215612eb3578081fd5b8235612ebe81613989565b91506020830135612ece81613989565b809150509250929050565b60008060008060808587031215612eee578182fd5b8435612ef981613989565b93506020850135612f0981613989565b93969395505050506040820135916060013590565b60008060208385031215612f30578182fd5b823567ffffffffffffffff80821115612f47578384fd5b818501915085601f830112612f5a578384fd5b813581811115612f68578485fd5b8660208260051b8501011115612f7c578485fd5b60209290920196919550909350505050565b60008060408385031215612fa0578182fd5b825167ffffffffffffffff80821115612fb7578384fd5b818501915085601f830112612fca578384fd5b81516020612fda612de8836135d6565b8083825282820191508286018a848660051b8901011115612ff9578889fd5b8896505b848710156130225761300e81612e40565b835260019690960195918301918301612ffd565b509188015191965090935050508082111561303b578283fd5b5061304885828601612dc8565b9150509250929050565b600060208284031215613063578081fd5b8135610d2b8161399e565b60006020828403121561307f578081fd5b8151610d2b8161399e565b6000806040838503121561309c578182fd5b505080516020909101519092909150565b600080600080606085870312156130c2578182fd5b8435935060208501359250604085013567ffffffffffffffff808211156130e7578384fd5b818701915087601f8301126130fa578384fd5b813581811115613108578485fd5b886020828501011115613119578485fd5b95989497505060200194505050565b600060c08284031215613139578081fd5b50919050565b600080600080600080600060e0888a031215613159578485fd5b875161316481613989565b8097505060208801518060020b811461317b578586fd5b955061318960408901612e57565b945061319760608901612e57565b93506131a560808901612e57565b925060a088015160ff811681146131ba578283fd5b60c08901519092506131cb8161399e565b8091505092959891949750929550565b6000602082840312156131ec578081fd5b813562ffffff81168114610d2b578182fd5b60006020828403121561320f578081fd5b5051919050565b60008082840360e0811215613229578283fd5b8335925060c0601f198201121561323e578182fd5b5061324761357c565b602084013561325581613989565b8152604084013561326581613989565b6020820152606084810135604083015260808501359082015260a084013561328c81613989565b608082015260c084013561329f81613989565b60a0820152919491935090915050565b600080600080608085870312156132c4578182fd5b845163ffffffff811681146132d7578283fd5b93506132e560208601612e40565b925060408501516132f581613989565b60608601519092506133068161399e565b939692955090935050565b60008151808452613329816020860160208601613856565b601f01601f19169290920160200192915050565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a08301525050565b60008251613389818460208701613856565b9190910192915050565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a060808201819052600090611eae90830184613311565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b8281101561342257603f19888603018452613410858351613311565b945092850192908501906001016133f4565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561346d57835163ffffffff168352928401929184019160010161344b565b50909695505050505050565b602081526000610d2b6020830184613311565b600060e08201905083825260018060a01b0380845116602084015280602085015116604084015260408401516060840152606084015160808401528060808501511660a08401528060a08501511660c0840152509392505050565b60006102808201905084825283602083015261350760408301845161333d565b602083015161351a61010084018261333d565b50604083015161352e6101c084018261333d565b50949350505050565b6000808335601e1984360301811261354d578283fd5b83018035915067ffffffffffffffff821115613567578283fd5b602001915036819003821315611d1857600080fd5b60405160c0810167ffffffffffffffff8111828210171561359f5761359f613973565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156135ce576135ce613973565b604052919050565b600067ffffffffffffffff8211156135f0576135f0613973565b5060051b60200190565b60006001600160a01b0382811684821680830382111561361c5761361c613947565b01949350505050565b6000821982111561363857613638613947565b500190565b600063ffffffff80831681851680830382111561361c5761361c613947565b60008261366b5761366b61395d565b600160ff1b82146000198414161561368557613685613947565b500590565b6000826136995761369961395d565b500490565b600181815b808511156136d95781600019048211156136bf576136bf613947565b808516156136cc57918102915b93841c93908002906136a3565b509250929050565b6000610d2b60ff8416836000826136fa57506001610d9d565b8161370757506000610d9d565b816001811461371d576002811461372757613743565b6001915050610d9d565b60ff84111561373857613738613947565b50506001821b610d9d565b5060208310610133831016604e8410600b8410161715613766575081810a610d9d565b613770838361369e565b806000190482111561378457613784613947565b029392505050565b60008160001904831182151516156137a6576137a6613947565b500290565b60008160060b8360060b82811281667fffffffffffff19018312811516156137d5576137d5613947565b81667fffffffffffff0183138116156137f0576137f0613947565b5090039392505050565b60006001600160a01b038381169083168181101561381a5761381a613947565b039392505050565b60008282101561383457613834613947565b500390565b600063ffffffff8381169083168181101561381a5761381a613947565b60005b83811015613871578181015183820152602001613859565b838111156103f55750506000910152565b60008160020b627fffff1981141561389c5761389c613947565b6000190192915050565b60006000198214156138ba576138ba613947565b5060010190565b6000826138d0576138d061395d565b500790565b6000826138e4576138e461395d565b500690565b600063ffffffff808416806139005761390061395d565b92169190910692915050565b60008160020b627fffff1981141561392657613926613947565b9003919050565b6000600160ff1b82141561394357613943613947565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ab157600080fd5b8015158114610ab157600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220125b5e0754d08f4072f9af8d1d6525dc83b54563d40f761354b40535efd6c54664736f6c6343000804003360a060405234801561001057600080fd5b506040516105c03803806105c083398101604081905261002f9161007a565b6001600160601b0319606082901b1660805261004e4262278d006100a8565b600160086101000a8154816001600160401b0302191690836001600160401b03160217905550506100cc565b60006020828403121561008b578081fd5b81516001600160a01b03811681146100a1578182fd5b9392505050565b600082198211156100c757634e487b7160e01b81526011600452602481fd5b500190565b60805160601c6104d66100ea600039600061018601526104d66000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806315f459991461005c5780633965c0831461008457806357e871e7146100b85780639588eca2146100cc578063ec18b9d7146100e3575b600080fd5b61006f61006a36600461032b565b6100f8565b60405190151581526020015b60405180910390f35b60015461009f90600160401b900467ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161007b565b60015461009f9067ffffffffffffffff1681565b6100d560005481565b60405190815260200161007b565b6100f66100f1366004610406565b61017b565b005b6040516bffffffffffffffffffffffff19606084901b166020820152601d60f91b603482015260358101829052600090819060550160408051808303601f190181529190528051602090910120600154909150600160401b900467ffffffffffffffff164210801561017257506101728560005483610252565b95945050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101c457604051631a27eac360e11b815260040160405180910390fd5b600154600160401b900467ffffffffffffffff1642106101f757604051632e197fdb60e01b815260040160405180910390fd5b60008290556001805467ffffffffffffffff191667ffffffffffffffff83161790556102264262278d00610441565b600160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505050565b600081815b855181101561030457600086828151811061028257634e487b7160e01b600052603260045260246000fd5b602002602001015190508083116102c45760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506102f1565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806102fc81610459565b915050610257565b509092149392505050565b80356001600160a01b038116811461032657600080fd5b919050565b60008060006060848603121561033f578283fd5b833567ffffffffffffffff80821115610356578485fd5b818601915086601f830112610369578485fd5b813560208282111561037d5761037d61048a565b8160051b604051601f19603f830116810181811086821117156103a2576103a261048a565b604052838152828101945085830182870184018c10156103c057898afd5b8996505b848710156103e25780358652600196909601959483019483016103c4565b5097506103f2905088820161030f565b955050505050604084013590509250925092565b60008060408385031215610418578182fd5b82359150602083013567ffffffffffffffff81168114610436578182fd5b809150509250929050565b6000821982111561045457610454610474565b500190565b600060001982141561046d5761046d610474565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220aa19bee754ff2c8cbd200aa96f5a7da5fb71f5dd86309c312ca1047cbd365ed064736f6c6343000804003360a06040523480156200001157600080fd5b50604051620014f7380380620014f7833981016040819052620000349162000188565b81816040518060400160405280600781526020016656616e696c6c6160c81b8152506040518060400160405280600381526020016215939360ea1b81525081600390805190602001906200008a929190620000e2565b508051620000a0906004906020840190620000e2565b5050600580546001600160a01b039485166001600160a01b03199182161790915560068054939094169216919091179091555050503360601b6080526200021c565b828054620000f090620001c6565b90600052602060002090601f0160209004810192826200011457600085556200015f565b82601f106200012f57805160ff19168380011785556200015f565b828001600101855582156200015f579182015b828111156200015f57825182559160200191906001019062000142565b506200016d92915062000171565b5090565b5b808211156200016d576000815560010162000172565b600080604083850312156200019b578182fd5b8251620001a88162000203565b6020840151909250620001bb8162000203565b809150509250929050565b600181811c90821680620001db57607f821691505b60208210811415620001fd57634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b03811681146200021957600080fd5b50565b60805160601c6112bc6200023b60003960006108c401526112bc6000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806339509351116100975780639a3483fe116100665780639a3483fe14610206578063a457c2d714610230578063a9059cbb14610243578063dd62ed3e1461025657600080fd5b806339509351146101af57806340c10f19146101c257806370a08231146101d557806395d89b41146101fe57600080fd5b806318160ddd116100d357806318160ddd1461016657806321f06ea01461017857806323b872dd1461018d578063313ce567146101a057600080fd5b806306fdde03146100fa578063095ea7b31461011857806312a2f7921461013b575b600080fd5b61010261028f565b60405161010f919061119d565b60405180910390f35b61012b610126366004610ffe565b610321565b604051901515815260200161010f565b60055461014e906001600160a01b031681565b6040516001600160a01b03909116815260200161010f565b6002545b60405190815260200161010f565b61018b610186366004611027565b610337565b005b61012b61019b366004610fc3565b6107bc565b604051600c815260200161010f565b61012b6101bd366004610ffe565b610872565b61018b6101d0366004610ffe565b6108a9565b61016a6101e3366004610f70565b6001600160a01b031660009081526020819052604090205490565b61010261091a565b610219610214366004611027565b610929565b60408051921515835290151560208301520161010f565b61012b61023e366004610ffe565b610ac7565b61012b610251366004610ffe565b610b62565b61016a610264366004610f91565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461029e9061121f565b80601f01602080910402602001604051908101604052809291908181526020018280546102ca9061121f565b80156103175780601f106102ec57610100808354040283529160200191610317565b820191906000526020600020905b8154815290600101906020018083116102fa57829003601f168201915b5050505050905090565b600061032e338484610b6f565b50600192915050565b600560009054906101000a90046001600160a01b03166001600160a01b0316633965c0836040518163ffffffff1660e01b815260040160206040518083038186803b15801561038557600080fd5b505afa158015610399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103bd919061111f565b67ffffffffffffffff1642106103e657604051639a651b9760e01b815260040160405180910390fd5b6006546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561042a57600080fd5b505afa15801561043e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104629190611107565b905080610482576040516302c9fb7160e11b815260040160405180910390fd5b6006546040516370a0823160e01b81523060048201819052916000916001600160a01b03909116906370a082319060240160206040518083038186803b1580156104cb57600080fd5b505afa1580156104df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105039190611107565b6006546040516323b872dd60e01b81523360048201526001600160a01b038581166024830152604482018790529293509116906323b872dd90606401602060405180830381600087803b15801561055957600080fd5b505af115801561056d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059191906110e7565b5061059c83826111f0565b6006546040516370a0823160e01b81526001600160a01b038581166004830152909116906370a082319060240160206040518083038186803b1580156105e157600080fd5b505afa1580156105f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106199190611107565b146106375760405163fb06cda160e01b815260040160405180910390fd5b6006546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561067b57600080fd5b505afa15801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611107565b11156106d257604051632fcb9be360e01b815260040160405180910390fd5b6005546040516315f4599960e01b81526001600160a01b03909116906315f459999061070690879033908890600401611147565b60206040518083038186803b15801561071e57600080fd5b505afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075691906110e7565b6107735760405163439cc0cd60e01b815260040160405180910390fd5b61077d3384610c93565b60408051338152602081018590527fc81072229ec6e4e2cb32e6d9fcfa0d4f4ac0b521ac84083648501b3e38274187910160405180910390a150505050565b60006107c9848484610c9d565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156108535760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61086785336108628685611208565b610b6f565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161032e9185906108629086906111f0565b604080518082019091526002815261633160f01b60208201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331461090b5760405162461bcd60e51b815260040161084a919061119d565b506109168282610e75565b5050565b60606004805461029e9061121f565b6006546040516370a0823160e01b8152336004820152600091829182916001600160a01b0316906370a082319060240160206040518083038186803b15801561097157600080fd5b505afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a99190611107565b6005546040516315f4599960e01b81529192506001600160a01b0316906315f45999906109de90879033908690600401611147565b60206040518083038186803b1580156109f657600080fd5b505afa158015610a0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2e91906110e7565b9250600081118015610abf5750600654604051636eb1769f60e11b815233600482015230602482015282916001600160a01b03169063dd62ed3e9060440160206040518083038186803b158015610a8457600080fd5b505afa158015610a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abc9190611107565b10155b915050915091565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610b495760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161084a565b610b5833856108628685611208565b5060019392505050565b600061032e338484610c9d565b6001600160a01b038316610bd15760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161084a565b6001600160a01b038216610c325760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161084a565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6109168282610e75565b6001600160a01b038316610d015760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161084a565b6001600160a01b038216610d635760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161084a565b6001600160a01b03831660009081526020819052604090205481811015610ddb5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161084a565b610de58282611208565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610e1b9084906111f0565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e6791815260200190565b60405180910390a350505050565b6001600160a01b038216610ecb5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161084a565b8060026000828254610edd91906111f0565b90915550506001600160a01b03821660009081526020819052604081208054839290610f0a9084906111f0565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b80356001600160a01b0381168114610f6b57600080fd5b919050565b600060208284031215610f81578081fd5b610f8a82610f54565b9392505050565b60008060408385031215610fa3578081fd5b610fac83610f54565b9150610fba60208401610f54565b90509250929050565b600080600060608486031215610fd7578081fd5b610fe084610f54565b9250610fee60208501610f54565b9150604084013590509250925092565b60008060408385031215611010578182fd5b61101983610f54565b946020939093013593505050565b60006020808385031215611039578182fd5b823567ffffffffffffffff80821115611050578384fd5b818501915085601f830112611063578384fd5b81358181111561107557611075611270565b8060051b604051601f19603f8301168101818110858211171561109a5761109a611270565b604052828152858101935084860182860187018a10156110b8578788fd5b8795505b838610156110da5780358552600195909501949386019386016110bc565b5098975050505050505050565b6000602082840312156110f8578081fd5b81518015158114610f8a578182fd5b600060208284031215611118578081fd5b5051919050565b600060208284031215611130578081fd5b815167ffffffffffffffff81168114610f8a578182fd5b606080825284519082018190526000906020906080840190828801845b8281101561118057815184529284019290840190600101611164565b5050506001600160a01b0395909516908301525060400152919050565b6000602080835283518082850152825b818110156111c9578581018301518582016040015282016111ad565b818111156111da5783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156112035761120361125a565b500190565b60008282101561121a5761121a61125a565b500390565b600181811c9082168061123357607f821691505b6020821081141561125457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220c8d7e4a499c1e318a423729cbe07d4452df1b3a922e79bc13db584fc88705fe264736f6c6343000804003360a060405234801561001057600080fd5b5060405161054038038061054083398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c6104aa6100966000396000818160e701526102b101526104aa6000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630bafd60e1461005157806334567cf8146100815780634360aa8d146100b4578063be4443c0146100c9575b600080fd5b600154610064906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100a461008f366004610377565b60006020819052908152604090205460ff1681565b6040519015158152602001610078565b6100c76100c2366004610398565b6100dc565b005b6100c76100d7366004610377565b6102a6565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461012557604051631a27eac360e11b815260040160405180910390fd5b8280156101e65760005b818110156101ab57600160008088888581811061015c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906101719190610377565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806101a38161044d565b91505061012f565b507f7d713019ad8a7d0879c2e785f8924ee9dd744ef744ec6b6d00391087054c5eb785856040516101dd929190610401565b60405180910390a15b81801561029e5760005b818110156102635760008086868481811061021b57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906102309190610377565b6001600160a01b031681526020810191909152604001600020805460ff191690558061025b8161044d565b9150506101f0565b507fe102daee3529f9c698745d764bee5eeb856656a86a4ec6ab687e94cfb0edc1308484604051610295929190610401565b60405180910390a15b505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102ef57604051631a27eac360e11b815260040160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b80356001600160a01b038116811461032857600080fd5b919050565b60008083601f84011261033e578182fd5b50813567ffffffffffffffff811115610355578182fd5b6020830191508360208260051b850101111561037057600080fd5b9250929050565b600060208284031215610388578081fd5b61039182610311565b9392505050565b600080600080604085870312156103ad578283fd5b843567ffffffffffffffff808211156103c4578485fd5b6103d08883890161032d565b909650945060208701359150808211156103e8578384fd5b506103f58782880161032d565b95989497509550505050565b60208082528181018390526000908460408401835b86811015610442576001600160a01b0361042f84610311565b1682529183019190830190600101610416565b509695505050505050565b600060001982141561046d57634e487b7160e01b81526011600452602481fd5b506001019056fea2646970667358221220fcc3a80eac67410b12df93b849f5d72a8722659bcb08bd28fefd8fd40a6c75b064736f6c63430008040033000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000e13e9010e818d48df1a0415021d9526ef845e2cd
Deployed Bytecode
0x6080604052600436106100ab5760003560e01c80636b333a60116100645780636b333a601461022f5780637c30be4e1461027b578063900cf0cf146102aa578063c868bdbb146102ec578063cab89249146102ff578063fa461e331461033357600080fd5b80630bb96ff6146100fd57806338eea3861461011057806344471415146101af57806349df728c146101dc57806353a6cb78146101fc57806364a231ef1461021c57600080fd5b366100f857336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216146100f657634e487b7160e01b600052600160045260246000fd5b005b600080fd5b6100f661010b366004613128565b610353565b34801561011c57600080fd5b5061017061012b366004612ea1565b6001602081815260009384526040808520909152918352912080549101546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1684565b6040516101a694939291909384526001600160701b0392831660208501529116604083015263ffffffff16606082015260800190565b60405180910390f35b3480156101bb57600080fd5b506101cf6101ca366004612f1e565b61039f565b6040516101a691906133ce565b3480156101e857600080fd5b506100f66101f7366004612e69565b6103cb565b34801561020857600080fd5b506100f6610217366004612ea1565b6103fb565b6101cf61022a366004612f1e565b61059b565b34801561023b57600080fd5b506102637f0000000000000000000000002d0338725b04533bf4f6d2b4c56f00861367951781565b6040516001600160a01b0390911681526020016101a6565b34801561028757600080fd5b5061029b610296366004612ed9565b61063c565b6040516101a6939291906134e7565b3480156102b657600080fd5b506102de7f0000000000000000000000000000000000000000000000000000000000b9295081565b6040519081526020016101a6565b6100f66102fa366004613128565b610728565b34801561030b57600080fd5b506102637f000000000000000000000000bf900809f4c73e5a3476eb183d8b06a27e61f8e581565b34801561033f57600080fd5b506100f661034e3660046130ad565b61076f565b806080013542811015610379576040516378ef33c160e01b815260040160405180910390fd5b600061038483610a35565b905061038f83610a5a565b61039a338285610ab4565b505050565b60606001600254146103b057600080fd5b600280556103bf338484610c09565b60016002559392505050565b3360006103d88284610d32565b905060006103e582610da3565b50509150506103f5848483610ddd565b50505050565b6001600160a01b03811615806104b35750806001600160a01b03167f0000000000000000000000002d0338725b04533bf4f6d2b4c56f0086136795176001600160a01b0316630bafd60e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561046f57600080fd5b505afa158015610483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a79190612e85565b6001600160a01b031614155b156104e157604051637d13575160e01b81526001600160a01b03821660048201526024015b60405180910390fd5b3360006104ee8285610d32565b90506000806000806104ff85610da3565b9350935093509350610512888885610ddd565b604051637616f4f360e01b81526001600160a01b038781166004830152898116602483015260448201869052606482018590526084820184905260a48201839052881690637616f4f39060c401600060405180830381600087803b15801561057957600080fd5b505af115801561058d573d6000803e3d6000fd5b505050505050505050505050565b60606001600254146105ac57600080fd5b6002805534156106315760007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29050806001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561061657600080fd5b505af115801561062a573d6000803e3d6000fd5b5050505050505b6103bf338484610c09565b600080610647612d60565b60006106538888610d32565b60408051608081018252825481526001909201546001600160701b038082166020850152600160701b82041691830191909152600160e01b900463ffffffff166060820152905060006106a988876101f4610e2f565b87815290506106b9868383610f66565b9085529550600091506106d190508887610bb8610e2f565b87815290506106e1868383610f66565b50602085015250600090506106f98887612710610e2f565b8781529050610709868383610f66565b5060408501525061071b905084611167565b9250509450945094915050565b80608001354281101561074e576040516378ef33c160e01b815260040160405180910390fd5b600061075983610a35565b905061076483610a5a565b6103f5338285611212565b6000546001600160a01b0316331461079a57604051637ae3640d60e11b815260040160405180910390fd5b6000831280156107aa5750600084125b156107c857604051631de3ccef60e01b815260040160405180910390fd5b600080600086136107e257846107dd8761392d565b6107ec565b856107ec8661392d565b909250905060008061080085870187613216565b915091508060600151826108149190613625565b60a082015160208301516040516370a0823160e01b81526001600160a01b0391821660048201529116906370a082319060240160206040518083038186803b15801561085f57600080fd5b505afa158015610873573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089791906131fe565b10156108c65760608101516040516371c4efed60e01b81526004810191909152602481018490526044016104d8565b80604001518411156108fc57806040015184604051635492412b60e11b81526004016104d8929190918252602082015260400190565b80516001600160a01b031630141561099a57608081015160405163a9059cbb60e01b8152336004820152602481018690526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561095c57600080fd5b505af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610994919061306e565b50610a2b565b608081015181516040516323b872dd60e01b81526001600160a01b039182166004820152336024820152604481018790529116906323b872dd90606401602060405180830381600087803b1580156109f157600080fd5b505af1158015610a05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a29919061306e565b505b5050505050505050565b6000610a476040830160208401613052565b15610a53575033919050565b5030919050565b60016002541415610ab1573415610a845760405163ca4c0aa560e01b815260040160405180910390fd5b610a946040820160208301613052565b610ab157604051635b44f25960e11b815260040160405180910390fd5b50565b6000610ac36020830183612e69565b6001600160a01b038086166000908152600160209081526040808320938516835292905281902091925083013590610afa816114a2565b6000610b1c8484606088013589610b1760c08b0160a08c016131db565b6114f4565b6001830154909150610b389084906001600160701b0316613625565b6001830180546001600160701b0319166001600160701b039283161790819055610b6b918391600160701b900416613625565b6001830180546001600160701b0392909216600160701b026dffffffffffffffffffffffffffff60701b19909216919091179055610ba9814361378c565b8254610bb59190613625565b825560408051848152602081018390526001600160a01b0386811692908a16917f6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b910160405180910390a350505050505050565b60608167ffffffffffffffff811115610c3257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c6557816020015b6060815260200190600190039081610c505790505b50905060005b82811015610d2157610ce330858584818110610c9757634e487b7160e01b600052603260045260246000fd5b9050602002810190610ca99190613537565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115cf92505050565b828281518110610d0357634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080610d19906138a6565b915050610c6b565b50610d2b846115f4565b9392505050565b6001600160a01b038281166000908152600160208181526040808420948616845293905291902090810154600160701b90046001600160701b0316610d9d576040516302e1ddb360e61b81526001600160a01b038085166004830152831660248201526044016104d8565b92915050565b6001810180548254600093849055929091556001600160701b0380821693600160701b83049091169291600160e01b900463ffffffff1690565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261039a908490611706565b610e5960405180606001604052806000815260200160008152602001600063ffffffff1681525090565b600080610e6686856117d8565b90925090506001600160a01b038216610ea65760405180606001604052806000815260200160008152602001600063ffffffff1681525092505050610d2b565b6000610eb1836118bd565b90508060600151610eea5760405180606001604052806000815260200160008152602001600063ffffffff168152509350505050610d2b565b600080610ef78584611b48565b915091508315610f4157604051806060016040528060008152602001610f268a856001600160a01b0316611d1f565b81526020018263ffffffff1681525095505050505050610d2b565b604051806060016040528060008152602001610f268a856001600160a01b0316611daf565b604080516080810182526000808252602082018190529181018290526060810191909152610f92612d92565b600084604001516001600160701b03168560000151610fb1919061368a565b905084604001516001600160701b031685602001516001600160701b031687610fda919061378c565b610fe4919061368a565b82604001818152505060008686604001516001600160701b03166110089190613822565b85518452604086015190915063ffffffff16156111035760408501805163ffffffff9081166020808701919091528701805160608701529151915160009261012c926110569291169061378c565b60408801516110679061012c613839565b63ffffffff16866040015161107c919061378c565b6110869190613625565b611090919061368a565b905060006110a2876000015183611e23565b9050846040015181116110b65760006110c5565b60408501516110c59082613822565b608086018190526110fb907f0000000000000000000000000000000000000000000000000000000000b929509086904390611e39565b60a086015250505b61112886602001516001600160701b03168288604001516001600160701b0316611eb9565b6001600160701b0390811660208601528651604088015161114b92849116611eb9565b84526001600160701b0316604084015291959094509092509050565b60004382148061119657507f0000000000000000000000000000000000000000000000000000000000b9295043145b156111a357506000919050565b60006111af8343613822565b905060006111dd7f0000000000000000000000000000000000000000000000000000000000b9295043613822565b90506111e9818061378c565b6111f3838061378c565b61120090620f424061378c565b61120a919061368a565b949350505050565b60008061122b856112266020860186612e69565b610d32565b9050611236816114a2565b6001810154600160701b90046001600160701b03166060840135111561129057600181015460405163040b0e5160e31b815260608501356004820152600160701b9091046001600160701b031660248201526044016104d8565b60006112c26112a26020860186612e69565b606086013560408701356112bc60c0890160a08a016131db565b89611ec6565b604080516080810182528454815260018501546001600160701b038082166020840152600160701b82041692820192909252600160e01b90910463ffffffff166060808301919091529192506000918291611321918801359085610f66565b5060408201516001870180548451895560208501516001600160e01b0319909116600160701b6001600160701b03948516026001600160701b03191617921691909117905560a081015191935091501580159061138e575061138e6113896020880188612e69565b612091565b1561141a5760a08101516040516340c10f1960e01b815233600482015260248101919091527f000000000000000000000000bf900809f4c73e5a3476eb183d8b06a27e61f8e56001600160a01b0316906340c10f1990604401600060405180830381600087803b15801561140157600080fd5b505af1158015611415573d6000803e3d6000fd5b505050505b6114276020870187612e69565b6001600160a01b0316886001600160a01b03167f34f38731fae2221a0127cde5769237f08a73e828efb7c9a19e4c6fa171ff763d8860600135866000015161146e8661212f565b60a087015160408051948552602085019390935291830152606082015260800160405180910390a350505195945050505050565b600181015443600160e01b90910463ffffffff16106114d4576040516313f0580960e01b815260040160405180910390fd5b60010180546001600160e01b0316600160e01b4363ffffffff1602179055565b600080600061150388856117d8565b90925090506001600160a01b0382166115455760405163e03ab9cf60e01b81526001600160a01b038916600482015262ffffff851660248201526044016104d8565b6040805160c0810182526001600160a01b038088168252306020830152918101899052606081018890527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28216608082015290891660a082015281156115b6576115af8382612158565b93506115c3565b6115c083826123c1565b93505b50505095945050505050565b6060610d2b83836040518060600160405280602781526020016139ad602791396125b6565b6040516370a0823160e01b81523060048201527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2906000906001600160a01b038316906370a0823190602401602060405180830381600087803b15801561165a57600080fd5b505af115801561166e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169291906131fe565b905080156116f557604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b1580156116dc57600080fd5b505af11580156116f0573d6000803e3d6000fd5b505050505b4780156103f5576103f5848261268a565b600061175b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127a39092919063ffffffff16565b80519091501561039a5780806020019051810190611779919061306e565b61039a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104d8565b604051630b4c774160e11b81526001600160a01b03838116600483018190527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28083166024850181905262ffffff8616604486015260009492109290917f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98490911690631698ee829060640160206040518083038186803b15801561187b57600080fd5b505afa15801561188f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b39190612e85565b9250509250929050565b604080516080810182526000808252602082018190529181018290526060810191909152600080836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561191d57600080fd5b505afa158015611931573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611955919061313f565b5050509350935050508061ffff166000141561199757505060408051608081018252600080825260208201819052918101829052606081019190915292915050565b60008161ffff168361ffff1660016119af919061363d565b6119b991906138e9565b60405163252c09d760e01b815261ffff82166004820152909150600090819081906001600160a01b0389169063252c09d79060240160806040518083038186803b158015611a0657600080fd5b505afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e91906132af565b935050925092508015611a895760405180608001604052808463ffffffff1681526020018360060b81526020018661ffff168152602001600115158152509650505050505050919050565b505060405163252c09d760e01b8152600060048201819052915081906001600160a01b0388169063252c09d79060240160806040518083038186803b158015611ad157600080fd5b505afa158015611ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0991906132af565b50506040805160808101825263ffffffff909316835260069190910b602083015261ffff90951694810194909452505060016060830152509392505050565b600080826040015161ffff1660011415611b6757506000905080611d18565b8251611b8590611b7d9063ffffffff1642613822565b61012c611e23565b60408051600280825260608201835292935060009290916020830190803683370190505090508181600081518110611bcd57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110611c0a57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0387169063883bdbfd90611c4e90859060040161342f565b60006040518083038186803b158015611c6657600080fd5b505afa158015611c7a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ca29190810190612f8e565b509050611d138363ffffffff1682600081518110611cd057634e487b7160e01b600052603260045260246000fd5b602002602001015183600181518110611cf957634e487b7160e01b600052603260045260246000fd5b6020026020010151611d0b91906137ab565b60060b6127b2565b935050505b9250929050565b600081611d2e57506000610d9d565b82611d3b57506000610d9d565b600160801b821015611d7157611d5583600160c01b61368a565b611d606002846136e1565b611d6a919061368a565b9050610d9d565b6000611d826401000000008461368a565b9050611d9284600160801b61368a565b611d9d6002836136e1565b611da7919061368a565b915050610d9d565b600081611dbe57506000610d9d565b6801000000000000000083108015611dd95750600160801b82105b15611df757611de96002836136e1565b611d6084600160c01b61378c565b6000611e086401000000008461368a565b9050611e156002826136e1565b611d9d85600160801b61378c565b6000818310611e325781610d2b565b5090919050565b600081611e485750600061120a565b83831415611e585750600061120a565b84831415611e685750600061120a565b6000611e748585613822565b90506000611e828786613822565b90508080611e90848061378c565b611e9a908761378c565b611ea4919061368a565b611eae919061368a565b979650505050505050565b600081611200848661378c565b611ef060405180606001604052806000815260200160008152602001600063ffffffff1681525090565b600080611efd88866117d8565b90925090506001600160a01b038216611f3f5760405163e03ab9cf60e01b81526001600160a01b038916600482015262ffffff861660248201526044016104d8565b6040805160c0810182523081526001600160a01b0386811660208301529181018990526060810188905289821660808201527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290911660a08201526000611fa5846118bd565b90508060600151611fdf5760405163e03ab9cf60e01b81526001600160a01b038b16600482015262ffffff881660248201526044016104d8565b821561204557600080611ff28684611b48565b91509150600061200287866123c1565b905060405180606001604052808281526020016120288e866001600160a01b0316611d1f565b81526020018363ffffffff16815250975050505050505050612088565b6000806120528684611b48565b9150915060006120628786612158565b905060405180606001604052808281526020016120288e866001600160a01b0316611daf565b95945050505050565b60405163068acf9f60e31b81526001600160a01b0382811660048301526000917f0000000000000000000000002d0338725b04533bf4f6d2b4c56f008613679517909116906334567cf89060240160206040518083038186803b1580156120f757600080fd5b505afa15801561210b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9d919061306e565b60008160400151826000015111612147576000610d9d565b60408201518251610d9d9190613822565b6000805483907f00000000000000000000000072c8b3aa6ed2ff68022691ecd21aeb1517cfaea6906001600160a01b038083169116146121ab57604051630a9e32d360e41b815260040160405180910390fd5b306001600160a01b038216146121d4576040516311ac8bcf60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117825560a086015160208701516040516370a0823160e01b815290831660048201529116906370a082319060240160206040518083038186803b15801561223657600080fd5b505afa15801561224a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226e91906131fe565b90506000866001600160a01b031663128acb08876020015160008960400151600173fffd8963efd1fc6a506488495d951d5263988d266122ae91906137fa565b878c6040516020016122c192919061348c565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122f0959493929190613393565b6040805180830381600087803b15801561230957600080fd5b505af115801561231d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612341919061308a565b509050600081138061235e5750606086015161235c8261392d565b105b1561238c5760608601516040516304e510b960e51b81526004810191909152602481018290526044016104d8565b6123958161392d565b600080546001600160a01b0319166001600160a01b039590951694909417909355509095945050505050565b6000805483907f00000000000000000000000072c8b3aa6ed2ff68022691ecd21aeb1517cfaea6906001600160a01b0380831691161461241457604051630a9e32d360e41b815260040160405180910390fd5b306001600160a01b0382161461243d576040516311ac8bcf60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117825560a086015160208701516040516370a0823160e01b815290831660048201529116906370a082319060240160206040518083038186803b15801561249f57600080fd5b505afa1580156124b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d791906131fe565b90506000866001600160a01b031663128acb088760200151600189604001516401000276a3600161250891906135fa565b878c60405160200161251b92919061348c565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161254a959493929190613393565b6040805180830381600087803b15801561256357600080fd5b505af1158015612577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259b919061308a565b915050600081138061235e5750606086015161235c8261392d565b6060833b6126155760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016104d8565b600080856001600160a01b0316856040516126309190613377565b600060405180830381855af49150503d806000811461266b576040519150601f19603f3d011682016040523d82523d6000602084013e612670565b606091505b50915091506126808282866127f5565b9695505050505050565b804710156126da5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016104d8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612727576040519150601f19603f3d011682016040523d82523d6000602084013e61272c565b606091505b505090508061039a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016104d8565b606061120a848460008561282e565b6000806127bf848461365c565b90506000831280156127d957506127d684846138c1565b15155b156127ec57806127e881613882565b9150505b61120a8161294b565b60608315612804575081610d2b565b8251156128145782518084602001fd5b8160405162461bcd60e51b81526004016104d89190613479565b60608247101561288f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104d8565b843b6128dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d8565b600080866001600160a01b031685876040516128f99190613377565b60006040518083038185875af1925050503d8060008114612936576040519150601f19603f3d011682016040523d82523d6000602084013e61293b565b606091505b5091509150611eae8282866127f5565b60008060008360020b12612962578260020b61296f565b8260020b61296f9061392d565b905061297e620d89e71961390c565b60020b8111156129b45760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016104d8565b6000600182166129c857600160801b6129da565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612a19576080612a14826ffff97272373d413259a46990580e213a61378c565b901c90505b6004821615612a43576080612a3e826ffff2e50f5f656932ef12357cf3c7fdcc61378c565b901c90505b6008821615612a6d576080612a68826fffe5caca7e10e4e61c3624eaa0941cd061378c565b901c90505b6010821615612a97576080612a92826fffcb9843d60f6159c9db58835c92664461378c565b901c90505b6020821615612ac1576080612abc826fff973b41fa98c081472e6896dfb254c061378c565b901c90505b6040821615612aeb576080612ae6826fff2ea16466c96a3843ec78b326b5286161378c565b901c90505b6080821615612b15576080612b10826ffe5dee046a99a2a811c461f1969c305361378c565b901c90505b610100821615612b40576080612b3b826ffcbe86c7900a88aedcffc83b479aa3a461378c565b901c90505b610200821615612b6b576080612b66826ff987a7253ac413176f2b074cf7815e5461378c565b901c90505b610400821615612b96576080612b91826ff3392b0822b70005940c7a398e4b70f361378c565b901c90505b610800821615612bc1576080612bbc826fe7159475a2c29b7443b29c7fa6e889d961378c565b901c90505b611000821615612bec576080612be7826fd097f3bdfd2022b8845ad8f792aa582561378c565b901c90505b612000821615612c17576080612c12826fa9f746462d870fdf8a65dc1f90e061e561378c565b901c90505b614000821615612c42576080612c3d826f70d869a156d2a1b890bb3df62baf32f761378c565b901c90505b618000821615612c6d576080612c68826f31be135f97d08fd981231505542fcfa661378c565b901c90505b62010000821615612c99576080612c94826f09aa508b5b7a84e1c677de54f3e99bc961378c565b901c90505b62020000821615612cc4576080612cbf826e5d6af8dedb81196699c329225ee60461378c565b901c90505b62040000821615612cee576080612ce9826d2216e584f5fa1ea926041bedfe9861378c565b901c90505b62080000821615612d16576080612d11826b048a170391f7dc42444e8fa261378c565b901c90505b60008460020b1315612d3157612d2e8160001961368a565b90505b612d40640100000000826138d5565b15612d4c576001612d4f565b60005b61120a9060ff16602083901c613625565b6040518060600160405280612d73612d92565b8152602001612d80612d92565b8152602001612d8d612d92565b905290565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600082601f830112612dd8578081fd5b81516020612ded612de8836135d6565b6135a5565b80838252828201915082860187848660051b8901011115612e0c578586fd5b855b85811015612e33578151612e2181613989565b84529284019290840190600101612e0e565b5090979650505050505050565b8051600681900b8114612e5257600080fd5b919050565b805161ffff81168114612e5257600080fd5b600060208284031215612e7a578081fd5b8135610d2b81613989565b600060208284031215612e96578081fd5b8151610d2b81613989565b60008060408385031215612eb3578081fd5b8235612ebe81613989565b91506020830135612ece81613989565b809150509250929050565b60008060008060808587031215612eee578182fd5b8435612ef981613989565b93506020850135612f0981613989565b93969395505050506040820135916060013590565b60008060208385031215612f30578182fd5b823567ffffffffffffffff80821115612f47578384fd5b818501915085601f830112612f5a578384fd5b813581811115612f68578485fd5b8660208260051b8501011115612f7c578485fd5b60209290920196919550909350505050565b60008060408385031215612fa0578182fd5b825167ffffffffffffffff80821115612fb7578384fd5b818501915085601f830112612fca578384fd5b81516020612fda612de8836135d6565b8083825282820191508286018a848660051b8901011115612ff9578889fd5b8896505b848710156130225761300e81612e40565b835260019690960195918301918301612ffd565b509188015191965090935050508082111561303b578283fd5b5061304885828601612dc8565b9150509250929050565b600060208284031215613063578081fd5b8135610d2b8161399e565b60006020828403121561307f578081fd5b8151610d2b8161399e565b6000806040838503121561309c578182fd5b505080516020909101519092909150565b600080600080606085870312156130c2578182fd5b8435935060208501359250604085013567ffffffffffffffff808211156130e7578384fd5b818701915087601f8301126130fa578384fd5b813581811115613108578485fd5b886020828501011115613119578485fd5b95989497505060200194505050565b600060c08284031215613139578081fd5b50919050565b600080600080600080600060e0888a031215613159578485fd5b875161316481613989565b8097505060208801518060020b811461317b578586fd5b955061318960408901612e57565b945061319760608901612e57565b93506131a560808901612e57565b925060a088015160ff811681146131ba578283fd5b60c08901519092506131cb8161399e565b8091505092959891949750929550565b6000602082840312156131ec578081fd5b813562ffffff81168114610d2b578182fd5b60006020828403121561320f578081fd5b5051919050565b60008082840360e0811215613229578283fd5b8335925060c0601f198201121561323e578182fd5b5061324761357c565b602084013561325581613989565b8152604084013561326581613989565b6020820152606084810135604083015260808501359082015260a084013561328c81613989565b608082015260c084013561329f81613989565b60a0820152919491935090915050565b600080600080608085870312156132c4578182fd5b845163ffffffff811681146132d7578283fd5b93506132e560208601612e40565b925060408501516132f581613989565b60608601519092506133068161399e565b939692955090935050565b60008151808452613329816020860160208601613856565b601f01601f19169290920160200192915050565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a08301525050565b60008251613389818460208701613856565b9190910192915050565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a060808201819052600090611eae90830184613311565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b8281101561342257603f19888603018452613410858351613311565b945092850192908501906001016133f4565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561346d57835163ffffffff168352928401929184019160010161344b565b50909695505050505050565b602081526000610d2b6020830184613311565b600060e08201905083825260018060a01b0380845116602084015280602085015116604084015260408401516060840152606084015160808401528060808501511660a08401528060a08501511660c0840152509392505050565b60006102808201905084825283602083015261350760408301845161333d565b602083015161351a61010084018261333d565b50604083015161352e6101c084018261333d565b50949350505050565b6000808335601e1984360301811261354d578283fd5b83018035915067ffffffffffffffff821115613567578283fd5b602001915036819003821315611d1857600080fd5b60405160c0810167ffffffffffffffff8111828210171561359f5761359f613973565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156135ce576135ce613973565b604052919050565b600067ffffffffffffffff8211156135f0576135f0613973565b5060051b60200190565b60006001600160a01b0382811684821680830382111561361c5761361c613947565b01949350505050565b6000821982111561363857613638613947565b500190565b600063ffffffff80831681851680830382111561361c5761361c613947565b60008261366b5761366b61395d565b600160ff1b82146000198414161561368557613685613947565b500590565b6000826136995761369961395d565b500490565b600181815b808511156136d95781600019048211156136bf576136bf613947565b808516156136cc57918102915b93841c93908002906136a3565b509250929050565b6000610d2b60ff8416836000826136fa57506001610d9d565b8161370757506000610d9d565b816001811461371d576002811461372757613743565b6001915050610d9d565b60ff84111561373857613738613947565b50506001821b610d9d565b5060208310610133831016604e8410600b8410161715613766575081810a610d9d565b613770838361369e565b806000190482111561378457613784613947565b029392505050565b60008160001904831182151516156137a6576137a6613947565b500290565b60008160060b8360060b82811281667fffffffffffff19018312811516156137d5576137d5613947565b81667fffffffffffff0183138116156137f0576137f0613947565b5090039392505050565b60006001600160a01b038381169083168181101561381a5761381a613947565b039392505050565b60008282101561383457613834613947565b500390565b600063ffffffff8381169083168181101561381a5761381a613947565b60005b83811015613871578181015183820152602001613859565b838111156103f55750506000910152565b60008160020b627fffff1981141561389c5761389c613947565b6000190192915050565b60006000198214156138ba576138ba613947565b5060010190565b6000826138d0576138d061395d565b500790565b6000826138e4576138e461395d565b500690565b600063ffffffff808416806139005761390061395d565b92169190910692915050565b60008160020b627fffff1981141561392657613926613947565b9003919050565b6000600160ff1b82141561394357613943613947565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ab157600080fd5b8015158114610ab157600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220125b5e0754d08f4072f9af8d1d6525dc83b54563d40f761354b40535efd6c54664736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000e13e9010e818d48df1a0415021d9526ef845e2cd
-----Decoded View---------------
Arg [0] : _peripheryState (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [1] : _v1temp (address): 0xE13E9010e818D48df1A0415021d9526ef845e2Cd
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [1] : 000000000000000000000000e13e9010e818d48df1a0415021d9526ef845e2cd
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 53.81% | $9.89 | 1,812.1469 | $17,922.13 | |
ETH | 34.02% | $259.11 | 43.7261 | $11,329.88 | |
ETH | 7.19% | $19.38 | 123.5664 | $2,394.72 | |
ETH | 2.04% | $97,836 | 0.00695114 | $680.07 | |
ETH | 0.82% | $0.548184 | 497.8067 | $272.89 | |
ETH | 0.74% | $979.35 | 0.2531 | $247.86 | |
ETH | 0.74% | $5,938.81 | 0.0413 | $245.01 | |
ETH | 0.52% | $0.001697 | 101,620.9715 | $172.43 | |
ETH | 0.11% | $0.488953 | 77.9492 | $38.11 | |
ETH | <0.01% | $0.465963 | 1 | $0.4659 |
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.