Source Code
Overview
S Balance
S Value
$0.00Cross-Chain Transactions
Loading...
Loading
Contract Name:
ZapV1
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {IUniswapPair} from "./interfaces/IUniswapPair.sol";
import {IUniswapRouter02} from "./interfaces/IUniswapRouter02.sol";
import {IWETH} from "./interfaces/IWETH.sol";
import {Babylonian} from "./libraries/Babylonian.sol";
/*
* @author Inspiration from the work of Zapper and Beefy.
* Implemented and modified for Uniswap.
*/
contract ZapV1 is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
// Interface for Wrapped ETH (WETH)
IWETH public WETH;
// UniswapRouter interface
IUniswapRouter02 public uniswapRouter;
// Maximum integer (used for managing allowance)
uint256 public constant MAX_INT = 2**256 - 1;
// Minimum amount for a swap (derived from Uniswap)
uint256 public constant MINIMUM_AMOUNT = 1000;
// Maximum reverse zap ratio (100 --> 1%, 1000 --> 0.1%)
uint256 public maxZapReverseRatio;
// Address UniswapRouter
address private uniswapRouterAddress;
// Address Wrapped ETH (WETH)
address private WETHAddress;
// Owner recovers token
event AdminTokenRecovery(address indexed tokenAddress, uint256 amountTokens);
// Owner changes the maxZapReverseRatio
event NewMaxZapReverseRatio(uint256 maxZapReverseRatio);
// tokenToZap = 0x00 address if ETH
event ZapIn(
address indexed tokenToZap,
address indexed lpToken,
uint256 tokenAmountIn,
uint256 lpTokenAmountReceived,
address indexed user
);
// token0ToZap = 0x00 address if ETH
event ZapInRebalancing(
address indexed token0ToZap,
address indexed token1ToZap,
address lpToken,
uint256 token0AmountIn,
uint256 token1AmountIn,
uint256 lpTokenAmountReceived,
address indexed user
);
// tokenToReceive = 0x00 address if ETH
event ZapOut(
address indexed lpToken,
address indexed tokenToReceive,
uint256 lpTokenAmount,
uint256 tokenAmountReceived,
address indexed user
);
/*
* @notice Fallback for WETH
*/
receive() external payable {
assert(msg.sender == WETHAddress);
}
/*
* @notice Constructor
* @param _WETHAddress: address of the WETH contract
* @param _uniswapRouter: address of the UniswapRouter
* @param _maxZapReverseRatio: maximum zap ratio
*/
constructor(
address _WETHAddress,
address _uniswapRouter,
uint256 _maxZapReverseRatio
) {
WETHAddress = _WETHAddress;
WETH = IWETH(_WETHAddress);
uniswapRouterAddress = _uniswapRouter;
uniswapRouter = IUniswapRouter02(_uniswapRouter);
maxZapReverseRatio = _maxZapReverseRatio;
}
/*
* @notice Zap ETH in a WETH pool (e.g. WETH/token)
* @param _lpToken: LP token address (e.g. TOKEN/ETH)
* @param _tokenAmountOutMin: minimum token amount (e.g. TOKEN) to receive in the intermediary swap (e.g. ETH --> TOKEN)
*/
function zapInETH(address _lpToken, uint256 _tokenAmountOutMin) external payable nonReentrant {
WETH.deposit{value: msg.value}();
// Call zap function
uint256 lpTokenAmountTransferred = _zapIn(WETHAddress, msg.value, _lpToken, _tokenAmountOutMin);
// Emit event
emit ZapIn(
address(0x0000000000000000000000000000000000000000),
_lpToken,
msg.value,
lpTokenAmountTransferred,
address(msg.sender)
);
}
/*
* @notice Zap a token in (e.g. token/other token)
* @param _tokenToZap: token to zap
* @param _tokenAmountIn: amount of token to swap
* @param _lpToken: LP token address (e.g. TOKEN/BUSD)
* @param _tokenAmountOutMin: minimum token to receive (e.g. TOKEN) in the intermediary swap (e.g. BUSD --> TOKEN)
*/
function zapInToken(
address _tokenToZap,
uint256 _tokenAmountIn,
address _lpToken,
uint256 _tokenAmountOutMin
) external nonReentrant {
// Transfer tokens to this contract
IERC20(_tokenToZap).safeTransferFrom(address(msg.sender), address(this), _tokenAmountIn);
// Call zap function
uint256 lpTokenAmountTransferred = _zapIn(_tokenToZap, _tokenAmountIn, _lpToken, _tokenAmountOutMin);
// Emit event
emit ZapIn(_tokenToZap, _lpToken, _tokenAmountIn, lpTokenAmountTransferred, address(msg.sender));
}
/*
* @notice Zap two tokens in, rebalance them to 50-50, before adding them to LP
* @param _token0ToZap: address of token0 to zap
* @param _token1ToZap: address of token1 to zap
* @param _token0AmountIn: amount of token0 to zap
* @param _token1AmountIn: amount of token1 to zap
* @param _lpToken: LP token address (token0/token1)
* @param _tokenAmountInMax: maximum token amount to sell (in token to sell in the intermediary swap)
* @param _tokenAmountOutMin: minimum token to receive in the intermediary swap
* @param _isToken0Sold: whether token0 is expected to be sold (if false, sell token1)
*/
function zapInTokenRebalancing(
address _token0ToZap,
address _token1ToZap,
uint256 _token0AmountIn,
uint256 _token1AmountIn,
address _lpToken,
uint256 _tokenAmountInMax,
uint256 _tokenAmountOutMin,
bool _isToken0Sold
) external nonReentrant {
// Transfer tokens to this contract
IERC20(_token0ToZap).safeTransferFrom(address(msg.sender), address(this), _token0AmountIn);
IERC20(_token1ToZap).safeTransferFrom(address(msg.sender), address(this), _token1AmountIn);
// Call zapIn function
uint256 lpTokenAmountTransferred = _zapInRebalancing(
_token0ToZap,
_token1ToZap,
_token0AmountIn,
_token1AmountIn,
_lpToken,
_tokenAmountInMax,
_tokenAmountOutMin,
_isToken0Sold
);
// Emit event
emit ZapInRebalancing(
_token0ToZap,
_token1ToZap,
_lpToken,
_token0AmountIn,
_token1AmountIn,
lpTokenAmountTransferred,
address(msg.sender)
);
}
/*
* @notice Zap 1 token and ETH, rebalance them to 50-50, before adding them to LP
* @param _token1ToZap: address of token1 to zap
* @param _token1AmountIn: amount of token1 to zap
* @param _lpToken: LP token address
* @param _tokenAmountInMax: maximum token amount to sell (in token to sell in the intermediary swap)
* @param _tokenAmountOutMin: minimum token to receive in the intermediary swap
* @param _isToken0Sold: whether token0 is expected to be sold (if false, sell token1)
*/
function zapInETHRebalancing(
address _token1ToZap,
uint256 _token1AmountIn,
address _lpToken,
uint256 _tokenAmountInMax,
uint256 _tokenAmountOutMin,
bool _isToken0Sold
) external payable nonReentrant {
WETH.deposit{value: msg.value}();
IERC20(_token1ToZap).safeTransferFrom(address(msg.sender), address(this), _token1AmountIn);
// Call zapIn function
uint256 lpTokenAmountTransferred = _zapInRebalancing(
WETHAddress,
_token1ToZap,
msg.value,
_token1AmountIn,
_lpToken,
_tokenAmountInMax,
_tokenAmountOutMin,
_isToken0Sold
);
// Emit event
emit ZapInRebalancing(
address(0x0000000000000000000000000000000000000000),
_token1ToZap,
_lpToken,
msg.value,
_token1AmountIn,
lpTokenAmountTransferred,
address(msg.sender)
);
}
/*
* @notice Zap a LP token out to receive ETH
* @param _lpToken: LP token address (e.g. TOKEN/WETH)
* @param _lpTokenAmount: amount of LP tokens to zap out
* @param _tokenAmountOutMin: minimum amount to receive (in ETH/WETH) in the intermediary swap (e.g. TOKEN --> ETH)
*/
function zapOutETH(
address _lpToken,
uint256 _lpTokenAmount,
uint256 _tokenAmountOutMin
) external nonReentrant {
// Transfer LP token to this address
IERC20(_lpToken).safeTransferFrom(address(msg.sender), address(_lpToken), _lpTokenAmount);
// Call zapOut
uint256 tokenAmountToTransfer = _zapOut(_lpToken, WETHAddress, _tokenAmountOutMin);
// Unwrap ETH
WETH.withdraw(tokenAmountToTransfer);
// Transfer ETH to the msg.sender
(bool success, ) = msg.sender.call{value: tokenAmountToTransfer}(new bytes(0));
require(success, "ETH: transfer fail");
// Emit event
emit ZapOut(
_lpToken,
address(0x0000000000000000000000000000000000000000),
_lpTokenAmount,
tokenAmountToTransfer,
address(msg.sender)
);
}
/*
* @notice Zap a LP token out (to receive a token)
* @param _lpToken: LP token address (e.g. TOKEN/BUSD)
* @param _tokenToReceive: one of the 2 tokens from the LP (e.g. TOKEN or BUSD)
* @param _lpTokenAmount: amount of LP tokens to zap out
* @param _tokenAmountOutMin: minimum token to receive (e.g. TOKEN) in the intermediary swap (e.g. BUSD --> TOKEN)
*/
function zapOutToken(
address _lpToken,
address _tokenToReceive,
uint256 _lpTokenAmount,
uint256 _tokenAmountOutMin
) external nonReentrant {
// Transfer LP token to this address
IERC20(_lpToken).safeTransferFrom(address(msg.sender), address(_lpToken), _lpTokenAmount);
uint256 tokenAmountToTransfer = _zapOut(_lpToken, _tokenToReceive, _tokenAmountOutMin);
IERC20(_tokenToReceive).safeTransfer(address(msg.sender), tokenAmountToTransfer);
emit ZapOut(_lpToken, _tokenToReceive, _lpTokenAmount, tokenAmountToTransfer, msg.sender);
}
/**
* @notice It allows the owner to change the risk parameter for quantities
* @param _maxZapInverseRatio: new inverse ratio
* @dev This function is only callable by owner.
*/
function updateMaxZapInverseRatio(uint256 _maxZapInverseRatio) external onlyOwner {
maxZapReverseRatio = _maxZapInverseRatio;
emit NewMaxZapReverseRatio(_maxZapInverseRatio);
}
/**
* @notice It allows the owner to recover wrong tokens sent to the contract
* @param _tokenAddress: the address of the token to withdraw (18 decimals)
* @param _tokenAmount: the number of token amount to withdraw
* @dev This function is only callable by owner.
*/
function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount);
emit AdminTokenRecovery(_tokenAddress, _tokenAmount);
}
/*
* @notice View the details for single zap
* @dev Use WETH for _tokenToZap (if ETH is the input)
* @param _tokenToZap: address of the token to zap
* @param _tokenAmountIn: amount of token to zap inputed
* @param _lpToken: address of the LP token
* @return swapAmountIn: amount that is expected to get swapped in intermediary swap
* @return swapAmountOut: amount that is expected to get received in intermediary swap
* @return swapTokenOut: token address of the token that is used in the intermediary swap
*/
function estimateZapInSwap(
address _tokenToZap,
uint256 _tokenAmountIn,
address _lpToken
)
external
view
returns (
uint256 swapAmountIn,
uint256 swapAmountOut,
address swapTokenOut
)
{
address token0 = IUniswapPair(_lpToken).token0();
address token1 = IUniswapPair(_lpToken).token1();
require(_tokenToZap == token0 || _tokenToZap == token1, "Zap: Wrong tokens");
// Convert to uint256 (from uint112)
(uint256 reserveA, uint256 reserveB, ) = IUniswapPair(_lpToken).getReserves();
if (token0 == _tokenToZap) {
swapTokenOut = token1;
swapAmountIn = _calculateAmountToSwap(_tokenAmountIn, reserveA, reserveB);
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveA, reserveB);
} else {
swapTokenOut = token0;
swapAmountIn = _calculateAmountToSwap(_tokenAmountIn, reserveB, reserveA);
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveB, reserveA);
}
return (swapAmountIn, swapAmountOut, swapTokenOut);
}
/*
* @notice View the details for a rebalancing zap
* @dev Use WETH for _token0ToZap (if ETH is the input)
* @param _token0ToZap: address of the token0 to zap
* @param _token1ToZap: address of the token0 to zap
* @param _token0AmountIn: amount for token0 to zap
* @param _token1AmountIn: amount for token1 to zap
* @param _lpToken: address of the LP token
* @return swapAmountIn: amount that is expected to get swapped in intermediary swap
* @return swapAmountOut: amount that is expected to get received in intermediary swap
* @return isToken0Sold: whether the token0 is sold (false --> token1 is sold in the intermediary swap)
*/
function estimateZapInRebalancingSwap(
address _token0ToZap,
address _token1ToZap,
uint256 _token0AmountIn,
uint256 _token1AmountIn,
address _lpToken
)
external
view
returns (
uint256 swapAmountIn,
uint256 swapAmountOut,
bool sellToken0
)
{
require(
_token0ToZap == IUniswapPair(_lpToken).token0() || _token0ToZap == IUniswapPair(_lpToken).token1(),
"Zap: Wrong token0"
);
require(
_token1ToZap == IUniswapPair(_lpToken).token0() || _token1ToZap == IUniswapPair(_lpToken).token1(),
"Zap: Wrong token1"
);
require(_token0ToZap != _token1ToZap, "Zap: Same tokens");
// Convert to uint256 (from uint112)
(uint256 reserveA, uint256 reserveB, ) = IUniswapPair(_lpToken).getReserves();
if (_token0ToZap == IUniswapPair(_lpToken).token0()) {
sellToken0 = (_token0AmountIn * reserveB > _token1AmountIn * reserveA) ? true : false;
// Calculate the amount that is expected to be swapped
swapAmountIn = _calculateAmountToSwapForRebalancing(
_token0AmountIn,
_token1AmountIn,
reserveA,
reserveB,
sellToken0
);
// Calculate the amount expected to be received in the intermediary swap
if (sellToken0) {
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveA, reserveB);
} else {
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveB, reserveA);
}
} else {
sellToken0 = (_token0AmountIn * reserveA > _token1AmountIn * reserveB) ? true : false;
// Calculate the amount that is expected to be swapped
swapAmountIn = _calculateAmountToSwapForRebalancing(
_token0AmountIn,
_token1AmountIn,
reserveB,
reserveA,
sellToken0
);
// Calculate the amount expected to be received in the intermediary swap
if (sellToken0) {
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveB, reserveA);
} else {
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveA, reserveB);
}
}
return (swapAmountIn, swapAmountOut, sellToken0);
}
/*
* @notice View the details for single zap
* @dev Use WETH for _tokenToReceive (if ETH is the asset to be received)
* @param _lpToken: address of the LP token to zap out
* @param _lpTokenAmount: amount of LP token to zap out
* @param _tokenToReceive: token address to receive
* @return swapAmountIn: amount that is expected to get swapped for intermediary swap
* @return swapAmountOut: amount that is expected to get received for intermediary swap
* @return swapTokenOut: address of the token that is sold in the intermediary swap
*/
function estimateZapOutSwap(
address _lpToken,
uint256 _lpTokenAmount,
address _tokenToReceive
)
external
view
returns (
uint256 swapAmountIn,
uint256 swapAmountOut,
address swapTokenOut
)
{
address token0 = IUniswapPair(_lpToken).token0();
address token1 = IUniswapPair(_lpToken).token1();
require(_tokenToReceive == token0 || _tokenToReceive == token1, "Zap: Token not in LP");
// Convert to uint256 (from uint112)
(uint256 reserveA, uint256 reserveB, ) = IUniswapPair(_lpToken).getReserves();
if (token1 == _tokenToReceive) {
// sell token0
uint256 tokenAmountIn = (_lpTokenAmount * reserveA) / IUniswapPair(_lpToken).totalSupply();
swapAmountIn = _calculateAmountToSwap(tokenAmountIn, reserveA, reserveB);
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveA, reserveB);
swapTokenOut = token0;
} else {
// sell token1
uint256 tokenAmountIn = (_lpTokenAmount * reserveB) / IUniswapPair(_lpToken).totalSupply();
swapAmountIn = _calculateAmountToSwap(tokenAmountIn, reserveB, reserveA);
swapAmountOut = uniswapRouter.getAmountOut(swapAmountIn, reserveB, reserveA);
swapTokenOut = token1;
}
return (swapAmountIn, swapAmountOut, swapTokenOut);
}
/*
* @notice Zap a token in (e.g. token/other token)
* @param _tokenToZap: token to zap
* @param _tokenAmountIn: amount of token to swap
* @param _lpToken: LP token address
* @param _tokenAmountOutMin: minimum token to receive in the intermediary swap
*/
function _zapIn(
address _tokenToZap,
uint256 _tokenAmountIn,
address _lpToken,
uint256 _tokenAmountOutMin
) internal returns (uint256 lpTokenReceived) {
require(_tokenAmountIn >= MINIMUM_AMOUNT, "Zap: Amount too low");
address token0 = IUniswapPair(_lpToken).token0();
address token1 = IUniswapPair(_lpToken).token1();
require(_tokenToZap == token0 || _tokenToZap == token1, "Zap: Wrong tokens");
// Retrieve the path
address[] memory path = new address[](2);
path[0] = _tokenToZap;
// Initiates an estimation to swap
uint256 swapAmountIn;
{
// Convert to uint256 (from uint112)
(uint256 reserveA, uint256 reserveB, ) = IUniswapPair(_lpToken).getReserves();
require((reserveA >= MINIMUM_AMOUNT) && (reserveB >= MINIMUM_AMOUNT), "Zap: Reserves too low");
if (token0 == _tokenToZap) {
swapAmountIn = _calculateAmountToSwap(_tokenAmountIn, reserveA, reserveB);
path[1] = token1;
require(reserveA / swapAmountIn >= maxZapReverseRatio, "Zap: Quantity higher than limit");
} else {
swapAmountIn = _calculateAmountToSwap(_tokenAmountIn, reserveB, reserveA);
path[1] = token0;
require(reserveB / swapAmountIn >= maxZapReverseRatio, "Zap: Quantity higher than limit");
}
}
// Approve token to zap if necessary
_approveTokenIfNeeded(_tokenToZap);
uint256[] memory swapedAmounts = uniswapRouter.swapExactTokensForTokens(
swapAmountIn,
_tokenAmountOutMin,
path,
address(this),
block.timestamp
);
// Approve other token if necessary
if (token0 == _tokenToZap) {
_approveTokenIfNeeded(token1);
} else {
_approveTokenIfNeeded(token0);
}
// Add liquidity and retrieve the amount of LP received by the sender
(, , lpTokenReceived) = uniswapRouter.addLiquidity(
path[0],
path[1],
_tokenAmountIn - swapedAmounts[0],
swapedAmounts[1],
1,
1,
address(msg.sender),
block.timestamp
);
return lpTokenReceived;
}
/*
* @notice Zap two tokens in, rebalance them to 50-50, before adding them to LP
* @param _token0ToZap: address of token0 to zap
* @param _token1ToZap: address of token1 to zap
* @param _token0AmountIn: amount of token0 to zap
* @param _token1AmountIn: amount of token1 to zap
* @param _lpToken: LP token address
* @param _tokenAmountInMax: maximum token amount to sell (in token to sell in the intermediary swap)
* @param _tokenAmountOutMin: minimum token to receive in the intermediary swap
* @param _isToken0Sold: whether token0 is expected to be sold (if false, sell token1)
*/
function _zapInRebalancing(
address _token0ToZap,
address _token1ToZap,
uint256 _token0AmountIn,
uint256 _token1AmountIn,
address _lpToken,
uint256 _tokenAmountInMax,
uint256 _tokenAmountOutMin,
bool _isToken0Sold
) internal returns (uint256 lpTokenReceived) {
require(
_token0ToZap == IUniswapPair(_lpToken).token0() || _token0ToZap == IUniswapPair(_lpToken).token1(),
"Zap: Wrong token0"
);
require(
_token1ToZap == IUniswapPair(_lpToken).token0() || _token1ToZap == IUniswapPair(_lpToken).token1(),
"Zap: Wrong token1"
);
require(_token0ToZap != _token1ToZap, "Zap: Same tokens");
// Initiates an estimation to swap
uint256 swapAmountIn;
{
// Convert to uint256 (from uint112)
(uint256 reserveA, uint256 reserveB, ) = IUniswapPair(_lpToken).getReserves();
require((reserveA >= MINIMUM_AMOUNT) && (reserveB >= MINIMUM_AMOUNT), "Zap: Reserves too low");
if (_token0ToZap == IUniswapPair(_lpToken).token0()) {
swapAmountIn = _calculateAmountToSwapForRebalancing(
_token0AmountIn,
_token1AmountIn,
reserveA,
reserveB,
_isToken0Sold
);
require(reserveA / swapAmountIn >= maxZapReverseRatio, "Zap: Quantity higher than limit");
} else {
swapAmountIn = _calculateAmountToSwapForRebalancing(
_token0AmountIn,
_token1AmountIn,
reserveB,
reserveA,
_isToken0Sold
);
require(reserveB / swapAmountIn >= maxZapReverseRatio, "Zap: Quantity higher than limit");
}
}
require(swapAmountIn <= _tokenAmountInMax, "Zap: Amount to swap too high");
address[] memory path = new address[](2);
// Define path for swapping and check whether to approve token to sell in intermediary swap
if (_isToken0Sold) {
path[0] = _token0ToZap;
path[1] = _token1ToZap;
_approveTokenIfNeeded(_token0ToZap);
} else {
path[0] = _token1ToZap;
path[1] = _token0ToZap;
_approveTokenIfNeeded(_token1ToZap);
}
// Execute the swap and retrieve quantity received
uint256[] memory swapedAmounts = uniswapRouter.swapExactTokensForTokens(
swapAmountIn,
_tokenAmountOutMin,
path,
address(this),
block.timestamp
);
// Check whether to approve other token and add liquidity to LP
if (_isToken0Sold) {
_approveTokenIfNeeded(_token1ToZap);
(, , lpTokenReceived) = uniswapRouter.addLiquidity(
path[0],
path[1],
(_token0AmountIn - swapedAmounts[0]),
(_token1AmountIn + swapedAmounts[1]),
1,
1,
address(msg.sender),
block.timestamp
);
} else {
_approveTokenIfNeeded(_token0ToZap);
(, , lpTokenReceived) = uniswapRouter.addLiquidity(
path[0],
path[1],
(_token1AmountIn - swapedAmounts[0]),
(_token0AmountIn + swapedAmounts[1]),
1,
1,
address(msg.sender),
block.timestamp
);
}
return lpTokenReceived;
}
/*
* @notice Zap a LP token out to a token (e.g. token/other token)
* @param _lpToken: LP token address
* @param _tokenToReceive: token address
* @param _tokenAmountOutMin: minimum token to receive in the intermediary swap
*/
function _zapOut(
address _lpToken,
address _tokenToReceive,
uint256 _tokenAmountOutMin
) internal returns (uint256) {
address token0 = IUniswapPair(_lpToken).token0();
address token1 = IUniswapPair(_lpToken).token1();
require(_tokenToReceive == token0 || _tokenToReceive == token1, "Zap: Token not in LP");
// Burn all LP tokens to receive the two tokens to this address
(uint256 amount0, uint256 amount1) = IUniswapPair(_lpToken).burn(address(this));
require(amount0 >= MINIMUM_AMOUNT, "UniswapRouter: INSUFFICIENT_A_AMOUNT");
require(amount1 >= MINIMUM_AMOUNT, "UniswapRouter: INSUFFICIENT_B_AMOUNT");
address[] memory path = new address[](2);
path[1] = _tokenToReceive;
uint256 swapAmountIn;
if (token0 == _tokenToReceive) {
path[0] = token1;
swapAmountIn = IERC20(token1).balanceOf(address(this));
// Approve token to sell if necessary
_approveTokenIfNeeded(token1);
} else {
path[0] = token0;
swapAmountIn = IERC20(token0).balanceOf(address(this));
// Approve token to sell if necessary
_approveTokenIfNeeded(token0);
}
// Swap tokens
uniswapRouter.swapExactTokensForTokens(swapAmountIn, _tokenAmountOutMin, path, address(this), block.timestamp);
// Return full balance for the token to receive by the sender
return IERC20(_tokenToReceive).balanceOf(address(this));
}
/*
* @notice Allows to zap a token in (e.g. token/other token)
* @param _token: token address
*/
function _approveTokenIfNeeded(address _token) private {
if (IERC20(_token).allowance(address(this), uniswapRouterAddress) < 1e24) {
// Re-approve
IERC20(_token).safeApprove(uniswapRouterAddress, MAX_INT);
}
}
/*
* @notice Calculate the swap amount to get the price at 50/50 split
* @param _token0AmountIn: amount of token 0
* @param _reserve0: amount in reserve for token0
* @param _reserve1: amount in reserve for token1
* @return amountToSwap: swapped amount (in token0)
*/
function _calculateAmountToSwap(
uint256 _token0AmountIn,
uint256 _reserve0,
uint256 _reserve1
) private view returns (uint256 amountToSwap) {
uint256 halfToken0Amount = _token0AmountIn / 2;
uint256 nominator = uniswapRouter.getAmountOut(halfToken0Amount, _reserve0, _reserve1);
uint256 denominator = uniswapRouter.quote(
halfToken0Amount,
_reserve0 + halfToken0Amount,
_reserve1 - nominator
);
// Adjustment for price impact
amountToSwap =
_token0AmountIn -
Babylonian.sqrt((halfToken0Amount * halfToken0Amount * nominator) / denominator);
return amountToSwap;
}
/*
* @notice Calculate the amount to swap to get the tokens at a 50/50 split
* @param _token0AmountIn: amount of token 0
* @param _token1AmountIn: amount of token 1
* @param _reserve0: amount in reserve for token0
* @param _reserve1: amount in reserve for token1
* @param _isToken0Sold: whether token0 is expected to be sold (if false, sell token1)
* @return amountToSwap: swapped amount in token0 (if _isToken0Sold is true) or token1 (if _isToken0Sold is false)
*/
function _calculateAmountToSwapForRebalancing(
uint256 _token0AmountIn,
uint256 _token1AmountIn,
uint256 _reserve0,
uint256 _reserve1,
bool _isToken0Sold
) private view returns (uint256 amountToSwap) {
bool sellToken0 = (_token0AmountIn * _reserve1 > _token1AmountIn * _reserve0) ? true : false;
require(sellToken0 == _isToken0Sold, "Zap: Wrong trade direction");
if (sellToken0) {
uint256 token0AmountToSell = (_token0AmountIn - (_token1AmountIn * _reserve0) / _reserve1) / 2;
uint256 nominator = uniswapRouter.getAmountOut(token0AmountToSell, _reserve0, _reserve1);
uint256 denominator = uniswapRouter.quote(
token0AmountToSell,
_reserve0 + token0AmountToSell,
_reserve1 - nominator
);
// Calculate the amount to sell (in token0)
token0AmountToSell =
(_token0AmountIn - (_token1AmountIn * (_reserve0 + token0AmountToSell)) / (_reserve1 - nominator)) /
2;
// Adjustment for price impact
amountToSwap =
2 *
token0AmountToSell -
Babylonian.sqrt((token0AmountToSell * token0AmountToSell * nominator) / denominator);
} else {
uint256 token1AmountToSell = (_token1AmountIn - (_token0AmountIn * _reserve1) / _reserve0) / 2;
uint256 nominator = uniswapRouter.getAmountOut(token1AmountToSell, _reserve1, _reserve0);
uint256 denominator = uniswapRouter.quote(
token1AmountToSell,
_reserve1 + token1AmountToSell,
_reserve0 - nominator
);
// Calculate the amount to sell (in token1)
token1AmountToSell =
(_token1AmountIn - ((_token0AmountIn * (_reserve1 + token1AmountToSell)) / (_reserve0 - nominator))) /
2;
// Adjustment for price impact
amountToSwap =
2 *
token1AmountToSell -
Babylonian.sqrt((token1AmountToSell * token1AmountToSell * nominator) / denominator);
}
return amountToSwap;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.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;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
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'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
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");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// 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 cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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://consensys.net/diligence/blog/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.8.0/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");
(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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0;
interface IUniswapPair {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);
function mint(address to) external returns (uint256 liquidity);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2;
interface IUniswapRouter01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) external pure returns (uint256 amountB);
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountOut);
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2;
import "./IUniswapRouter01.sol";
interface IUniswapRouter02 is IUniswapRouter01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
/*
* @author Uniswap
* @notice Library from Uniswap
*/
library Babylonian {
function sqrt(uint256 x) internal pure returns (uint256) {
if (x == 0) return 0;
uint256 xx = x;
uint256 r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r <<= 32;
}
if (xx >= 0x100000000) {
xx >>= 32;
r <<= 16;
}
if (xx >= 0x10000) {
xx >>= 16;
r <<= 8;
}
if (xx >= 0x100) {
xx >>= 8;
r <<= 4;
}
if (xx >= 0x10) {
xx >>= 4;
r <<= 2;
}
if (xx >= 0x8) {
r <<= 1;
}
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
uint256 r1 = x / r;
return (r < r1 ? r : r1);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_WETHAddress","type":"address"},{"internalType":"address","name":"_uniswapRouter","type":"address"},{"internalType":"uint256","name":"_maxZapReverseRatio","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountTokens","type":"uint256"}],"name":"AdminTokenRecovery","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxZapReverseRatio","type":"uint256"}],"name":"NewMaxZapReverseRatio","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenToZap","type":"address"},{"indexed":true,"internalType":"address","name":"lpToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokenAmountReceived","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"ZapIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0ToZap","type":"address"},{"indexed":true,"internalType":"address","name":"token1ToZap","type":"address"},{"indexed":false,"internalType":"address","name":"lpToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"token0AmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token1AmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokenAmountReceived","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"ZapInRebalancing","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lpToken","type":"address"},{"indexed":true,"internalType":"address","name":"tokenToReceive","type":"address"},{"indexed":false,"internalType":"uint256","name":"lpTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmountReceived","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"ZapOut","type":"event"},{"inputs":[],"name":"MAX_INT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token0ToZap","type":"address"},{"internalType":"address","name":"_token1ToZap","type":"address"},{"internalType":"uint256","name":"_token0AmountIn","type":"uint256"},{"internalType":"uint256","name":"_token1AmountIn","type":"uint256"},{"internalType":"address","name":"_lpToken","type":"address"}],"name":"estimateZapInRebalancingSwap","outputs":[{"internalType":"uint256","name":"swapAmountIn","type":"uint256"},{"internalType":"uint256","name":"swapAmountOut","type":"uint256"},{"internalType":"bool","name":"sellToken0","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenToZap","type":"address"},{"internalType":"uint256","name":"_tokenAmountIn","type":"uint256"},{"internalType":"address","name":"_lpToken","type":"address"}],"name":"estimateZapInSwap","outputs":[{"internalType":"uint256","name":"swapAmountIn","type":"uint256"},{"internalType":"uint256","name":"swapAmountOut","type":"uint256"},{"internalType":"address","name":"swapTokenOut","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_lpTokenAmount","type":"uint256"},{"internalType":"address","name":"_tokenToReceive","type":"address"}],"name":"estimateZapOutSwap","outputs":[{"internalType":"uint256","name":"swapAmountIn","type":"uint256"},{"internalType":"uint256","name":"swapAmountOut","type":"uint256"},{"internalType":"address","name":"swapTokenOut","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxZapReverseRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"recoverWrongTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapRouter","outputs":[{"internalType":"contract IUniswapRouter02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxZapInverseRatio","type":"uint256"}],"name":"updateMaxZapInverseRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"}],"name":"zapInETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token1ToZap","type":"address"},{"internalType":"uint256","name":"_token1AmountIn","type":"uint256"},{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_tokenAmountInMax","type":"uint256"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"},{"internalType":"bool","name":"_isToken0Sold","type":"bool"}],"name":"zapInETHRebalancing","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenToZap","type":"address"},{"internalType":"uint256","name":"_tokenAmountIn","type":"uint256"},{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"}],"name":"zapInToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token0ToZap","type":"address"},{"internalType":"address","name":"_token1ToZap","type":"address"},{"internalType":"uint256","name":"_token0AmountIn","type":"uint256"},{"internalType":"uint256","name":"_token1AmountIn","type":"uint256"},{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_tokenAmountInMax","type":"uint256"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"},{"internalType":"bool","name":"_isToken0Sold","type":"bool"}],"name":"zapInTokenRebalancing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"uint256","name":"_lpTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"}],"name":"zapOutETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"address","name":"_tokenToReceive","type":"address"},{"internalType":"uint256","name":"_lpTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_tokenAmountOutMin","type":"uint256"}],"name":"zapOutToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60806040523480156200001157600080fd5b5060405162003ed038038062003ed0833981016040819052620000349162000102565b6200003f3362000095565b60018055600680546001600160a01b039485166001600160a01b03199182168117909255600280548216909217909155600580549390941692811683179093556003805490931690911790915560045562000143565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000fd57600080fd5b919050565b6000806000606084860312156200011857600080fd5b6200012384620000e5565b92506200013360208501620000e5565b9150604084015190509250925092565b613d7d80620001536000396000f3fe6080604052600436106101185760003560e01c8063735de9f7116100a05780638c0cc5ce116100645780638c0cc5ce146103345780638da5cb5b14610347578063ad5c464814610365578063b421e91e14610385578063f2fde38b146103a557600080fd5b8063735de9f71461026c5780637db9b1f4146102a457806382c98b2d146102b757806384b73115146102f457806387e3f21c1461031457600080fd5b80632dabc536116100e75780632dabc536146101b35780632f883da4146101d35780633b0a48bb146102175780633f138d4b14610237578063715018a61461025757600080fd5b8063098d32281461013e5780630f4e4e6314610167578063257d9bb81461017d5780632b4652eb1461019357600080fd5b36610139576006546001600160a01b0316331461013757610137613686565b005b600080fd5b34801561014a57600080fd5b5061015460001981565b6040519081526020015b60405180910390f35b34801561017357600080fd5b5061015460045481565b34801561018957600080fd5b506101546103e881565b34801561019f57600080fd5b506101376101ae36600461369c565b6103c5565b3480156101bf57600080fd5b506101376101ce3660046136ca565b610408565b3480156101df57600080fd5b506101f36101ee3660046136ff565b6105a5565b6040805193845260208401929092526001600160a01b03169082015260600161015e565b34801561022357600080fd5b506101f36102323660046136ff565b61099f565b34801561024357600080fd5b50610137610252366004613741565b610c9f565b34801561026357600080fd5b50610137610d02565b34801561027857600080fd5b5060035461028c906001600160a01b031681565b6040516001600160a01b03909116815260200161015e565b6101376102b2366004613741565b610d16565b3480156102c357600080fd5b506102d76102d236600461376d565b610dfd565b60408051938452602084019290925215159082015260600161015e565b34801561030057600080fd5b5061013761030f3660046137cc565b6113b2565b34801561032057600080fd5b5061013761032f366004613812565b61144e565b610137610342366004613868565b6114d3565b34801561035357600080fd5b506000546001600160a01b031661028c565b34801561037157600080fd5b5060025461028c906001600160a01b031681565b34801561039157600080fd5b506101376103a03660046138cf565b6115e9565b3480156103b157600080fd5b506101376103c0366004613954565b61169f565b6103cd611718565b60048190556040518181527fc7e29c44236bfea8bef0d337e382f5f27ec5bc4d425d82437f115f9b59d2ba799060200160405180910390a150565b610410611772565b6104256001600160a01b0384163385856117cb565b6006546000906104409085906001600160a01b031684611836565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561048757600080fd5b505af115801561049b573d6000803e3d6000fd5b50506040805160008082526020820192839052935033925084916104bf91906139b2565b60006040518083038185875af1925050503d80600081146104fc576040519150601f19603f3d011682016040523d82523d6000602084013e610501565b606091505b505090508061054c5760405162461bcd60e51b81526020600482015260126024820152711155120e881d1c985b9cd9995c8819985a5b60721b60448201526064015b60405180910390fd5b604080518581526020810184905233916000916001600160a01b038916917f20ef8a4c975ec6c340089d8171a0f9c6a6324b11e3ecc4353155186f6c638c28910160405180910390a450506105a060018055565b505050565b600080600080866001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060d91906139ce565b90506000876001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561064f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067391906139ce565b9050816001600160a01b0316866001600160a01b031614806106a65750806001600160a01b0316866001600160a01b0316145b6106e95760405162461bcd60e51b815260206004820152601460248201527305a61703a20546f6b656e206e6f7420696e204c560641b6044820152606401610543565b600080896001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561072a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074e9190613a07565b506001600160701b031691506001600160701b03169150876001600160a01b0316836001600160a01b03160361088a5760008a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e29190613a4c565b6107ec848c613a7b565b6107f69190613a98565b9050610803818484611d25565b600354604051630153543560e21b81526004810183905260248101869052604481018590529199506001600160a01b03169063054d50d490606401602060405180830381865afa15801561085b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087f9190613a4c565b965084955050610992565b60008a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190613a4c565b6108f8838c613a7b565b6109029190613a98565b905061090f818385611d25565b600354604051630153543560e21b81526004810183905260248101859052604481018690529199506001600160a01b03169063054d50d490606401602060405180830381865afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b9190613a4c565b9650839550505b5050505093509350939050565b600080600080846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0791906139ce565b90506000856001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6d91906139ce565b9050816001600160a01b0316886001600160a01b03161480610aa05750806001600160a01b0316886001600160a01b0316145b610ae05760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e7360781b6044820152606401610543565b600080876001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b459190613a07565b506001600160701b031691506001600160701b03169150896001600160a01b0316846001600160a01b031603610c0657829450610b83898383611d25565b600354604051630153543560e21b81526004810183905260248101859052604481018490529198506001600160a01b03169063054d50d490606401602060405180830381865afa158015610bdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190613a4c565b9550610992565b839450610c14898284611d25565b600354604051630153543560e21b81526004810183905260248101849052604481018590529198506001600160a01b03169063054d50d490606401602060405180830381865afa158015610c6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c909190613a4c565b95505050505093509350939050565b610ca7611718565b610cbb6001600160a01b0383163383611e8c565b816001600160a01b03167f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab7812982604051610cf691815260200190565b60405180910390a25050565b610d0a611718565b610d146000611ebc565b565b610d1e611772565b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610d6e57600080fd5b505af1158015610d82573d6000803e3d6000fd5b505060065460009350610da392506001600160a01b03169050348585611f0c565b604080513481526020810183905291925033916001600160a01b038616916000917fa71185a0ff368de4e9e445d8601c4fbd50d9b674e4e43f5f8feafb8d64a2e13e910160405180910390a450610df960018055565b5050565b6000806000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6491906139ce565b6001600160a01b0316886001600160a01b03161480610ef55750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee091906139ce565b6001600160a01b0316886001600160a01b0316145b610f355760405162461bcd60e51b815260206004820152601160248201527005a61703a2057726f6e6720746f6b656e3607c1b6044820152606401610543565b836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9791906139ce565b6001600160a01b0316876001600160a01b031614806110285750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101391906139ce565b6001600160a01b0316876001600160a01b0316145b6110685760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e3160781b6044820152606401610543565b866001600160a01b0316886001600160a01b0316036110bc5760405162461bcd60e51b815260206004820152601060248201526f5a61703a2053616d6520746f6b656e7360801b6044820152606401610543565b600080856001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156110fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111219190613a07565b506001600160701b031691506001600160701b03169150856001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611176573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119a91906139ce565b6001600160a01b03168a6001600160a01b0316036112ae576111bc8288613a7b565b6111c6828a613a7b565b116111d25760006111d5565b60015b92506111e4888884848761246a565b9450821561126f57600354604051630153543560e21b81526004810187905260248101849052604481018390526001600160a01b039091169063054d50d4906064015b602060405180830381865afa158015611244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112689190613a4c565b93506113a5565b600354604051630153543560e21b81526004810187905260248101839052604481018490526001600160a01b039091169063054d50d490606401611227565b6112b88188613a7b565b6112c2838a613a7b565b116112ce5760006112d1565b60015b92506112e0888883858761246a565b9450821561132757600354604051630153543560e21b81526004810187905260248101839052604481018490526001600160a01b039091169063054d50d490606401611227565b600354604051630153543560e21b81526004810187905260248101849052604481018390526001600160a01b039091169063054d50d490606401602060405180830381865afa15801561137e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a29190613a4c565b93505b5050955095509592505050565b6113ba611772565b6113cf6001600160a01b0385163386856117cb565b60006113dc858584611836565b90506113f26001600160a01b0385163383611e8c565b604080518481526020810183905233916001600160a01b0387811692908916917f20ef8a4c975ec6c340089d8171a0f9c6a6324b11e3ecc4353155186f6c638c2891015b60405180910390a45061144860018055565b50505050565b611456611772565b61146b6001600160a01b0385163330866117cb565b600061147985858585611f0c565b9050336001600160a01b0316836001600160a01b0316866001600160a01b03167fa71185a0ff368de4e9e445d8601c4fbd50d9b674e4e43f5f8feafb8d64a2e13e8785604051611436929190918252602082015260400190565b6114db611772565b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561152b57600080fd5b505af115801561153f573d6000803e3d6000fd5b5061155b935050506001600160a01b03881690503330886117cb565b60065460009061157a906001600160a01b03168834898989898961285f565b604080516001600160a01b038881168252346020830152918101899052606081018390529192503391908916906000907f4ff29158e89c3af93365bf0fa1d14c5768109fb139f24b97c8a7d510b2d5e3f69060800160405180910390a4506115e160018055565b505050505050565b6115f1611772565b6116066001600160a01b0389163330896117cb565b61161b6001600160a01b0388163330886117cb565b600061162d898989898989898961285f565b604080516001600160a01b038881168252602082018b90529181018990526060810183905291925033918a8216918c16907f4ff29158e89c3af93365bf0fa1d14c5768109fb139f24b97c8a7d510b2d5e3f69060800160405180910390a45061169560018055565b5050505050505050565b6116a7611718565b6001600160a01b03811661170c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610543565b61171581611ebc565b50565b6000546001600160a01b03163314610d145760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610543565b6002600154036117c45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610543565b6002600155565b6040516001600160a01b03808516602483015283166044820152606481018290526114489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613102565b600080846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b91906139ce565b90506000856001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190191906139ce565b9050816001600160a01b0316856001600160a01b031614806119345750806001600160a01b0316856001600160a01b0316145b6119775760405162461bcd60e51b815260206004820152601460248201527305a61703a20546f6b656e206e6f7420696e204c560641b6044820152606401610543565b60405163226bf2d160e21b815230600482015260009081906001600160a01b038916906389afcb449060240160408051808303816000875af11580156119c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e59190613aba565b915091506103e8821015611a475760405162461bcd60e51b8152602060048201526024808201527f556e6973776170526f757465723a20494e53554646494349454e545f415f414d60448201526313d5539560e21b6064820152608401610543565b6103e8811015611aa55760405162461bcd60e51b8152602060048201526024808201527f556e6973776170526f757465723a20494e53554646494349454e545f425f414d60448201526313d5539560e21b6064820152608401610543565b6040805160028082526060820183526000926020830190803683370190505090508781600181518110611ada57611ada613ade565b6001600160a01b03928316602091820292909201015260009089811690871603611b99578482600081518110611b1257611b12613ade565b6001600160a01b0392831660209182029290920101526040516370a0823160e01b8152306004820152908616906370a0823190602401602060405180830381865afa158015611b65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b899190613a4c565b9050611b94856131d7565b611c2f565b8582600081518110611bad57611bad613ade565b6001600160a01b0392831660209182029290920101526040516370a0823160e01b8152306004820152908716906370a0823190602401602060405180830381865afa158015611c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c249190613a4c565b9050611c2f866131d7565b6003546040516338ed173960e01b81526001600160a01b03909116906338ed173990611c679084908c90879030904290600401613af4565b6000604051808303816000875af1158015611c86573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611cae9190810190613b65565b506040516370a0823160e01b81523060048201526001600160a01b038a16906370a0823190602401602060405180830381865afa158015611cf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d179190613a4c565b9a9950505050505050505050565b600080611d33600286613a98565b600354604051630153543560e21b81526004810183905260248101879052604481018690529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa158015611d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db49190613a4c565b6003549091506000906001600160a01b031663ad615dec84611dd6818a613c23565b611de0868a613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa158015611e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4d9190613a4c565b9050611e778183611e5e8680613a7b565b611e689190613a7b565b611e729190613a98565b613278565b611e819088613c36565b979650505050505050565b6040516001600160a01b0383166024820152604481018290526105a090849063a9059cbb60e01b906064016117ff565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006103e8841015611f565760405162461bcd60e51b81526020600482015260136024820152725a61703a20416d6f756e7420746f6f206c6f7760681b6044820152606401610543565b6000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fba91906139ce565b90506000846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202091906139ce565b9050816001600160a01b0316876001600160a01b031614806120535750806001600160a01b0316876001600160a01b0316145b6120935760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e7360781b6044820152606401610543565b60408051600280825260608201835260009260208301908036833701905050905087816000815181106120c8576120c8613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250506000806000886001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f9190613a07565b506001600160701b031691506001600160701b031691506103e8821015801561217a57506103e88110155b6121be5760405162461bcd60e51b81526020600482015260156024820152745a61703a20526573657276657320746f6f206c6f7760581b6044820152606401610543565b8a6001600160a01b0316866001600160a01b031603612240576121e28a8383611d25565b925084846001815181106121f8576121f8613ade565b6001600160a01b039092166020928302919091019091015260045461221d8484613a98565b101561223b5760405162461bcd60e51b815260040161054390613c49565b6122a4565b61224b8a8284611d25565b9250858460018151811061226157612261613ade565b6001600160a01b03909216602092830291909101909101526004546122868483613a98565b10156122a45760405162461bcd60e51b815260040161054390613c49565b50506122af896131d7565b6003546040516338ed173960e01b81526000916001600160a01b0316906338ed1739906122e89085908b90889030904290600401613af4565b6000604051808303816000875af1158015612307573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261232f9190810190613b65565b9050896001600160a01b0316856001600160a01b03160361235857612353846131d7565b612361565b612361856131d7565b60035483516001600160a01b039091169063e8e3370090859060009061238957612389613ade565b6020026020010151856001815181106123a4576123a4613ade565b6020026020010151846000815181106123bf576123bf613ade565b60200260200101518d6123d29190613c36565b856001815181106123e5576123e5613ade565b602002602001015160018033426040518963ffffffff1660e01b8152600401612415989796959493929190613c80565b6060604051808303816000875af1158015612434573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124589190613cc9565b9750505050505050505b949350505050565b6000806124778587613a7b565b6124818589613a7b565b1161248d576000612490565b60015b9050821515811515146124e55760405162461bcd60e51b815260206004820152601a60248201527f5a61703a2057726f6e6720747261646520646972656374696f6e0000000000006044820152606401610543565b80156126a25760006002856124fa888a613a7b565b6125049190613a98565b61250e908a613c36565b6125189190613a98565b600354604051630153543560e21b81526004810183905260248101899052604481018890529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa158015612575573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125999190613a4c565b6003549091506000906001600160a01b031663ad615dec846125bb818c613c23565b6125c5868c613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa15801561260e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126329190613a4c565b905060026126408389613c36565b61264a858b613c23565b612654908c613a7b565b61265e9190613a98565b612668908c613c36565b6126729190613a98565b92506126838183611e5e8680613a7b565b61268e846002613a7b565b6126989190613c36565b9450505050612855565b60006002866126b1878b613a7b565b6126bb9190613a98565b6126c59089613c36565b6126cf9190613a98565b600354604051630153543560e21b81526004810183905260248101889052604481018990529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa15801561272c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127509190613a4c565b6003549091506000906001600160a01b031663ad615dec84612772818b613c23565b61277c868d613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa1580156127c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e99190613a4c565b905060026127f7838a613c36565b612801858a613c23565b61280b908d613a7b565b6128159190613a98565b61281f908b613c36565b6128299190613a98565b925061283a8183611e5e8680613a7b565b612845846002613a7b565b61284f9190613c36565b94505050505b5095945050505050565b6000846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561289f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c391906139ce565b6001600160a01b0316896001600160a01b031614806129545750846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561291b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293f91906139ce565b6001600160a01b0316896001600160a01b0316145b6129945760405162461bcd60e51b815260206004820152601160248201527005a61703a2057726f6e6720746f6b656e3607c1b6044820152606401610543565b846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f691906139ce565b6001600160a01b0316886001600160a01b03161480612a875750846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7291906139ce565b6001600160a01b0316886001600160a01b0316145b612ac75760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e3160781b6044820152606401610543565b876001600160a01b0316896001600160a01b031603612b1b5760405162461bcd60e51b815260206004820152601060248201526f5a61703a2053616d6520746f6b656e7360801b6044820152606401610543565b6000806000876001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015612b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b829190613a07565b506001600160701b031691506001600160701b031691506103e88210158015612bad57506103e88110155b612bf15760405162461bcd60e51b81526020600482015260156024820152745a61703a20526573657276657320746f6f206c6f7760581b6044820152606401610543565b876001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5391906139ce565b6001600160a01b03168c6001600160a01b031603612cab57612c788a8a84848961246a565b600454909350612c888484613a98565b1015612ca65760405162461bcd60e51b815260040161054390613c49565b612ce6565b612cb88a8a83858961246a565b600454909350612cc88483613a98565b1015612ce65760405162461bcd60e51b815260040161054390613c49565b505084811115612d385760405162461bcd60e51b815260206004820152601c60248201527f5a61703a20416d6f756e7420746f207377617020746f6f2068696768000000006044820152606401610543565b6040805160028082526060820183526000926020830190803683370190505090508315612dd5578a81600081518110612d7357612d73613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250508981600181518110612da757612da7613ade565b60200260200101906001600160a01b031690816001600160a01b031681525050612dd08b6131d7565b612e46565b8981600081518110612de957612de9613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250508a81600181518110612e1d57612e1d613ade565b60200260200101906001600160a01b031690816001600160a01b031681525050612e468a6131d7565b6003546040516338ed173960e01b81526000916001600160a01b0316906338ed173990612e7f9086908a90879030904290600401613af4565b6000604051808303816000875af1158015612e9e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ec69190810190613b65565b90508415612fe357612ed78b6131d7565b60035482516001600160a01b039091169063e8e33700908490600090612eff57612eff613ade565b602002602001015184600181518110612f1a57612f1a613ade565b602002602001015184600081518110612f3557612f35613ade565b60200260200101518e612f489190613c36565b85600181518110612f5b57612f5b613ade565b60200260200101518e612f6e9190613c23565b60018033426040518963ffffffff1660e01b8152600401612f96989796959493929190613c80565b6060604051808303816000875af1158015612fb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd99190613cc9565b95506130f3915050565b612fec8c6131d7565b60035482516001600160a01b039091169063e8e3370090849060009061301457613014613ade565b60200260200101518460018151811061302f5761302f613ade565b60200260200101518460008151811061304a5761304a613ade565b60200260200101518d61305d9190613c36565b8560018151811061307057613070613ade565b60200260200101518f6130839190613c23565b60018033426040518963ffffffff1660e01b81526004016130ab989796959493929190613c80565b6060604051808303816000875af11580156130ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ee9190613cc9565b955050505b50505098975050505050505050565b6000613157826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133f99092919063ffffffff16565b90508051600014806131785750808060200190518101906131789190613cf7565b6105a05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610543565b600554604051636eb1769f60e11b81523060048201526001600160a01b03918216602482015269d3c21bcecceda10000009183169063dd62ed3e90604401602060405180830381865afa158015613232573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132569190613a4c565b101561171557600554611715906001600160a01b038381169116600019613408565b60008160000361328a57506000919050565b816001600160801b82106132a35760809190911c9060401b5b6801000000000000000082106132be5760409190911c9060201b5b64010000000082106132d55760209190911c9060101b5b6201000082106132ea5760109190911c9060081b5b61010082106132fe5760089190911c9060041b5b601082106133115760049190911c9060021b5b6008821061331d5760011b5b60016133298286613a98565b6133339083613c23565b901c905060016133438286613a98565b61334d9083613c23565b901c9050600161335d8286613a98565b6133679083613c23565b901c905060016133778286613a98565b6133819083613c23565b901c905060016133918286613a98565b61339b9083613c23565b901c905060016133ab8286613a98565b6133b59083613c23565b901c905060016133c58286613a98565b6133cf9083613c23565b901c905060006133df8286613a98565b90508082106133ee57806133f0565b815b95945050505050565b6060612462848460008561351d565b8015806134825750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561345c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134809190613a4c565b155b6134ed5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610543565b6040516001600160a01b0383166024820152604481018290526105a090849063095ea7b360e01b906064016117ff565b60608247101561357e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610543565b600080866001600160a01b0316858760405161359a91906139b2565b60006040518083038185875af1925050503d80600081146135d7576040519150601f19603f3d011682016040523d82523d6000602084013e6135dc565b606091505b5091509150611e818783838760608315613657578251600003613650576001600160a01b0385163b6136505760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610543565b5081612462565b612462838381511561366c5781518083602001fd5b8060405162461bcd60e51b81526004016105439190613d14565b634e487b7160e01b600052600160045260246000fd5b6000602082840312156136ae57600080fd5b5035919050565b6001600160a01b038116811461171557600080fd5b6000806000606084860312156136df57600080fd5b83356136ea816136b5565b95602085013595506040909401359392505050565b60008060006060848603121561371457600080fd5b833561371f816136b5565b9250602084013591506040840135613736816136b5565b809150509250925092565b6000806040838503121561375457600080fd5b823561375f816136b5565b946020939093013593505050565b600080600080600060a0868803121561378557600080fd5b8535613790816136b5565b945060208601356137a0816136b5565b9350604086013592506060860135915060808601356137be816136b5565b809150509295509295909350565b600080600080608085870312156137e257600080fd5b84356137ed816136b5565b935060208501356137fd816136b5565b93969395505050506040820135916060013590565b6000806000806080858703121561382857600080fd5b8435613833816136b5565b935060208501359250604085013561384a816136b5565b9396929550929360600135925050565b801515811461171557600080fd5b60008060008060008060c0878903121561388157600080fd5b863561388c816136b5565b95506020870135945060408701356138a3816136b5565b9350606087013592506080870135915060a08701356138c18161385a565b809150509295509295509295565b600080600080600080600080610100898b0312156138ec57600080fd5b88356138f7816136b5565b97506020890135613907816136b5565b965060408901359550606089013594506080890135613925816136b5565b935060a0890135925060c0890135915060e08901356139438161385a565b809150509295985092959890939650565b60006020828403121561396657600080fd5b8135613971816136b5565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156139a9578181015183820152602001613991565b50506000910152565b600082516139c481846020870161398e565b9190910192915050565b6000602082840312156139e057600080fd5b8151613971816136b5565b80516001600160701b0381168114613a0257600080fd5b919050565b600080600060608486031215613a1c57600080fd5b613a25846139eb565b9250613a33602085016139eb565b9150604084015163ffffffff8116811461373657600080fd5b600060208284031215613a5e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417613a9257613a92613a65565b92915050565b600082613ab557634e487b7160e01b600052601260045260246000fd5b500490565b60008060408385031215613acd57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052603260045260246000fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015613b445784516001600160a01b031683529383019391830191600101613b1f565b50506001600160a01b03969096166060850152505050608001529392505050565b60006020808385031215613b7857600080fd5b825167ffffffffffffffff80821115613b9057600080fd5b818501915085601f830112613ba457600080fd5b815181811115613bb657613bb6613978565b8060051b604051601f19603f83011681018181108582111715613bdb57613bdb613978565b604052918252848201925083810185019188831115613bf957600080fd5b938501935b82851015613c1757845184529385019392850192613bfe565b98975050505050505050565b80820180821115613a9257613a92613a65565b81810381811115613a9257613a92613a65565b6020808252601f908201527f5a61703a205175616e7469747920686967686572207468616e206c696d697400604082015260600190565b6001600160a01b039889168152968816602088015260408701959095526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b600080600060608486031215613cde57600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215613d0957600080fd5b81516139718161385a565b6020815260008251806020840152613d3381604085016020870161398e565b601f01601f1916919091016040019291505056fea264697066735822122017bfcb549b7a617b768b1cbfa169f638a7d82ddd786673cfe18d8730d87bbf0164736f6c63430008130033000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad380000000000000000000000001d368773735ee1e678950b7a97bca2cafb330cdc0000000000000000000000000000000000000000000000000000000000000002
Deployed Bytecode
0x6080604052600436106101185760003560e01c8063735de9f7116100a05780638c0cc5ce116100645780638c0cc5ce146103345780638da5cb5b14610347578063ad5c464814610365578063b421e91e14610385578063f2fde38b146103a557600080fd5b8063735de9f71461026c5780637db9b1f4146102a457806382c98b2d146102b757806384b73115146102f457806387e3f21c1461031457600080fd5b80632dabc536116100e75780632dabc536146101b35780632f883da4146101d35780633b0a48bb146102175780633f138d4b14610237578063715018a61461025757600080fd5b8063098d32281461013e5780630f4e4e6314610167578063257d9bb81461017d5780632b4652eb1461019357600080fd5b36610139576006546001600160a01b0316331461013757610137613686565b005b600080fd5b34801561014a57600080fd5b5061015460001981565b6040519081526020015b60405180910390f35b34801561017357600080fd5b5061015460045481565b34801561018957600080fd5b506101546103e881565b34801561019f57600080fd5b506101376101ae36600461369c565b6103c5565b3480156101bf57600080fd5b506101376101ce3660046136ca565b610408565b3480156101df57600080fd5b506101f36101ee3660046136ff565b6105a5565b6040805193845260208401929092526001600160a01b03169082015260600161015e565b34801561022357600080fd5b506101f36102323660046136ff565b61099f565b34801561024357600080fd5b50610137610252366004613741565b610c9f565b34801561026357600080fd5b50610137610d02565b34801561027857600080fd5b5060035461028c906001600160a01b031681565b6040516001600160a01b03909116815260200161015e565b6101376102b2366004613741565b610d16565b3480156102c357600080fd5b506102d76102d236600461376d565b610dfd565b60408051938452602084019290925215159082015260600161015e565b34801561030057600080fd5b5061013761030f3660046137cc565b6113b2565b34801561032057600080fd5b5061013761032f366004613812565b61144e565b610137610342366004613868565b6114d3565b34801561035357600080fd5b506000546001600160a01b031661028c565b34801561037157600080fd5b5060025461028c906001600160a01b031681565b34801561039157600080fd5b506101376103a03660046138cf565b6115e9565b3480156103b157600080fd5b506101376103c0366004613954565b61169f565b6103cd611718565b60048190556040518181527fc7e29c44236bfea8bef0d337e382f5f27ec5bc4d425d82437f115f9b59d2ba799060200160405180910390a150565b610410611772565b6104256001600160a01b0384163385856117cb565b6006546000906104409085906001600160a01b031684611836565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561048757600080fd5b505af115801561049b573d6000803e3d6000fd5b50506040805160008082526020820192839052935033925084916104bf91906139b2565b60006040518083038185875af1925050503d80600081146104fc576040519150601f19603f3d011682016040523d82523d6000602084013e610501565b606091505b505090508061054c5760405162461bcd60e51b81526020600482015260126024820152711155120e881d1c985b9cd9995c8819985a5b60721b60448201526064015b60405180910390fd5b604080518581526020810184905233916000916001600160a01b038916917f20ef8a4c975ec6c340089d8171a0f9c6a6324b11e3ecc4353155186f6c638c28910160405180910390a450506105a060018055565b505050565b600080600080866001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060d91906139ce565b90506000876001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561064f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067391906139ce565b9050816001600160a01b0316866001600160a01b031614806106a65750806001600160a01b0316866001600160a01b0316145b6106e95760405162461bcd60e51b815260206004820152601460248201527305a61703a20546f6b656e206e6f7420696e204c560641b6044820152606401610543565b600080896001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561072a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074e9190613a07565b506001600160701b031691506001600160701b03169150876001600160a01b0316836001600160a01b03160361088a5760008a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e29190613a4c565b6107ec848c613a7b565b6107f69190613a98565b9050610803818484611d25565b600354604051630153543560e21b81526004810183905260248101869052604481018590529199506001600160a01b03169063054d50d490606401602060405180830381865afa15801561085b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087f9190613a4c565b965084955050610992565b60008a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190613a4c565b6108f8838c613a7b565b6109029190613a98565b905061090f818385611d25565b600354604051630153543560e21b81526004810183905260248101859052604481018690529199506001600160a01b03169063054d50d490606401602060405180830381865afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b9190613a4c565b9650839550505b5050505093509350939050565b600080600080846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0791906139ce565b90506000856001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6d91906139ce565b9050816001600160a01b0316886001600160a01b03161480610aa05750806001600160a01b0316886001600160a01b0316145b610ae05760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e7360781b6044820152606401610543565b600080876001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b459190613a07565b506001600160701b031691506001600160701b03169150896001600160a01b0316846001600160a01b031603610c0657829450610b83898383611d25565b600354604051630153543560e21b81526004810183905260248101859052604481018490529198506001600160a01b03169063054d50d490606401602060405180830381865afa158015610bdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190613a4c565b9550610992565b839450610c14898284611d25565b600354604051630153543560e21b81526004810183905260248101849052604481018590529198506001600160a01b03169063054d50d490606401602060405180830381865afa158015610c6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c909190613a4c565b95505050505093509350939050565b610ca7611718565b610cbb6001600160a01b0383163383611e8c565b816001600160a01b03167f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab7812982604051610cf691815260200190565b60405180910390a25050565b610d0a611718565b610d146000611ebc565b565b610d1e611772565b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610d6e57600080fd5b505af1158015610d82573d6000803e3d6000fd5b505060065460009350610da392506001600160a01b03169050348585611f0c565b604080513481526020810183905291925033916001600160a01b038616916000917fa71185a0ff368de4e9e445d8601c4fbd50d9b674e4e43f5f8feafb8d64a2e13e910160405180910390a450610df960018055565b5050565b6000806000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6491906139ce565b6001600160a01b0316886001600160a01b03161480610ef55750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee091906139ce565b6001600160a01b0316886001600160a01b0316145b610f355760405162461bcd60e51b815260206004820152601160248201527005a61703a2057726f6e6720746f6b656e3607c1b6044820152606401610543565b836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9791906139ce565b6001600160a01b0316876001600160a01b031614806110285750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101391906139ce565b6001600160a01b0316876001600160a01b0316145b6110685760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e3160781b6044820152606401610543565b866001600160a01b0316886001600160a01b0316036110bc5760405162461bcd60e51b815260206004820152601060248201526f5a61703a2053616d6520746f6b656e7360801b6044820152606401610543565b600080856001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156110fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111219190613a07565b506001600160701b031691506001600160701b03169150856001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611176573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119a91906139ce565b6001600160a01b03168a6001600160a01b0316036112ae576111bc8288613a7b565b6111c6828a613a7b565b116111d25760006111d5565b60015b92506111e4888884848761246a565b9450821561126f57600354604051630153543560e21b81526004810187905260248101849052604481018390526001600160a01b039091169063054d50d4906064015b602060405180830381865afa158015611244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112689190613a4c565b93506113a5565b600354604051630153543560e21b81526004810187905260248101839052604481018490526001600160a01b039091169063054d50d490606401611227565b6112b88188613a7b565b6112c2838a613a7b565b116112ce5760006112d1565b60015b92506112e0888883858761246a565b9450821561132757600354604051630153543560e21b81526004810187905260248101839052604481018490526001600160a01b039091169063054d50d490606401611227565b600354604051630153543560e21b81526004810187905260248101849052604481018390526001600160a01b039091169063054d50d490606401602060405180830381865afa15801561137e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a29190613a4c565b93505b5050955095509592505050565b6113ba611772565b6113cf6001600160a01b0385163386856117cb565b60006113dc858584611836565b90506113f26001600160a01b0385163383611e8c565b604080518481526020810183905233916001600160a01b0387811692908916917f20ef8a4c975ec6c340089d8171a0f9c6a6324b11e3ecc4353155186f6c638c2891015b60405180910390a45061144860018055565b50505050565b611456611772565b61146b6001600160a01b0385163330866117cb565b600061147985858585611f0c565b9050336001600160a01b0316836001600160a01b0316866001600160a01b03167fa71185a0ff368de4e9e445d8601c4fbd50d9b674e4e43f5f8feafb8d64a2e13e8785604051611436929190918252602082015260400190565b6114db611772565b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561152b57600080fd5b505af115801561153f573d6000803e3d6000fd5b5061155b935050506001600160a01b03881690503330886117cb565b60065460009061157a906001600160a01b03168834898989898961285f565b604080516001600160a01b038881168252346020830152918101899052606081018390529192503391908916906000907f4ff29158e89c3af93365bf0fa1d14c5768109fb139f24b97c8a7d510b2d5e3f69060800160405180910390a4506115e160018055565b505050505050565b6115f1611772565b6116066001600160a01b0389163330896117cb565b61161b6001600160a01b0388163330886117cb565b600061162d898989898989898961285f565b604080516001600160a01b038881168252602082018b90529181018990526060810183905291925033918a8216918c16907f4ff29158e89c3af93365bf0fa1d14c5768109fb139f24b97c8a7d510b2d5e3f69060800160405180910390a45061169560018055565b5050505050505050565b6116a7611718565b6001600160a01b03811661170c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610543565b61171581611ebc565b50565b6000546001600160a01b03163314610d145760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610543565b6002600154036117c45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610543565b6002600155565b6040516001600160a01b03808516602483015283166044820152606481018290526114489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613102565b600080846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b91906139ce565b90506000856001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190191906139ce565b9050816001600160a01b0316856001600160a01b031614806119345750806001600160a01b0316856001600160a01b0316145b6119775760405162461bcd60e51b815260206004820152601460248201527305a61703a20546f6b656e206e6f7420696e204c560641b6044820152606401610543565b60405163226bf2d160e21b815230600482015260009081906001600160a01b038916906389afcb449060240160408051808303816000875af11580156119c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e59190613aba565b915091506103e8821015611a475760405162461bcd60e51b8152602060048201526024808201527f556e6973776170526f757465723a20494e53554646494349454e545f415f414d60448201526313d5539560e21b6064820152608401610543565b6103e8811015611aa55760405162461bcd60e51b8152602060048201526024808201527f556e6973776170526f757465723a20494e53554646494349454e545f425f414d60448201526313d5539560e21b6064820152608401610543565b6040805160028082526060820183526000926020830190803683370190505090508781600181518110611ada57611ada613ade565b6001600160a01b03928316602091820292909201015260009089811690871603611b99578482600081518110611b1257611b12613ade565b6001600160a01b0392831660209182029290920101526040516370a0823160e01b8152306004820152908616906370a0823190602401602060405180830381865afa158015611b65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b899190613a4c565b9050611b94856131d7565b611c2f565b8582600081518110611bad57611bad613ade565b6001600160a01b0392831660209182029290920101526040516370a0823160e01b8152306004820152908716906370a0823190602401602060405180830381865afa158015611c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c249190613a4c565b9050611c2f866131d7565b6003546040516338ed173960e01b81526001600160a01b03909116906338ed173990611c679084908c90879030904290600401613af4565b6000604051808303816000875af1158015611c86573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611cae9190810190613b65565b506040516370a0823160e01b81523060048201526001600160a01b038a16906370a0823190602401602060405180830381865afa158015611cf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d179190613a4c565b9a9950505050505050505050565b600080611d33600286613a98565b600354604051630153543560e21b81526004810183905260248101879052604481018690529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa158015611d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db49190613a4c565b6003549091506000906001600160a01b031663ad615dec84611dd6818a613c23565b611de0868a613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa158015611e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4d9190613a4c565b9050611e778183611e5e8680613a7b565b611e689190613a7b565b611e729190613a98565b613278565b611e819088613c36565b979650505050505050565b6040516001600160a01b0383166024820152604481018290526105a090849063a9059cbb60e01b906064016117ff565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006103e8841015611f565760405162461bcd60e51b81526020600482015260136024820152725a61703a20416d6f756e7420746f6f206c6f7760681b6044820152606401610543565b6000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fba91906139ce565b90506000846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202091906139ce565b9050816001600160a01b0316876001600160a01b031614806120535750806001600160a01b0316876001600160a01b0316145b6120935760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e7360781b6044820152606401610543565b60408051600280825260608201835260009260208301908036833701905050905087816000815181106120c8576120c8613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250506000806000886001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f9190613a07565b506001600160701b031691506001600160701b031691506103e8821015801561217a57506103e88110155b6121be5760405162461bcd60e51b81526020600482015260156024820152745a61703a20526573657276657320746f6f206c6f7760581b6044820152606401610543565b8a6001600160a01b0316866001600160a01b031603612240576121e28a8383611d25565b925084846001815181106121f8576121f8613ade565b6001600160a01b039092166020928302919091019091015260045461221d8484613a98565b101561223b5760405162461bcd60e51b815260040161054390613c49565b6122a4565b61224b8a8284611d25565b9250858460018151811061226157612261613ade565b6001600160a01b03909216602092830291909101909101526004546122868483613a98565b10156122a45760405162461bcd60e51b815260040161054390613c49565b50506122af896131d7565b6003546040516338ed173960e01b81526000916001600160a01b0316906338ed1739906122e89085908b90889030904290600401613af4565b6000604051808303816000875af1158015612307573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261232f9190810190613b65565b9050896001600160a01b0316856001600160a01b03160361235857612353846131d7565b612361565b612361856131d7565b60035483516001600160a01b039091169063e8e3370090859060009061238957612389613ade565b6020026020010151856001815181106123a4576123a4613ade565b6020026020010151846000815181106123bf576123bf613ade565b60200260200101518d6123d29190613c36565b856001815181106123e5576123e5613ade565b602002602001015160018033426040518963ffffffff1660e01b8152600401612415989796959493929190613c80565b6060604051808303816000875af1158015612434573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124589190613cc9565b9750505050505050505b949350505050565b6000806124778587613a7b565b6124818589613a7b565b1161248d576000612490565b60015b9050821515811515146124e55760405162461bcd60e51b815260206004820152601a60248201527f5a61703a2057726f6e6720747261646520646972656374696f6e0000000000006044820152606401610543565b80156126a25760006002856124fa888a613a7b565b6125049190613a98565b61250e908a613c36565b6125189190613a98565b600354604051630153543560e21b81526004810183905260248101899052604481018890529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa158015612575573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125999190613a4c565b6003549091506000906001600160a01b031663ad615dec846125bb818c613c23565b6125c5868c613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa15801561260e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126329190613a4c565b905060026126408389613c36565b61264a858b613c23565b612654908c613a7b565b61265e9190613a98565b612668908c613c36565b6126729190613a98565b92506126838183611e5e8680613a7b565b61268e846002613a7b565b6126989190613c36565b9450505050612855565b60006002866126b1878b613a7b565b6126bb9190613a98565b6126c59089613c36565b6126cf9190613a98565b600354604051630153543560e21b81526004810183905260248101889052604481018990529192506000916001600160a01b039091169063054d50d490606401602060405180830381865afa15801561272c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127509190613a4c565b6003549091506000906001600160a01b031663ad615dec84612772818b613c23565b61277c868d613c36565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa1580156127c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e99190613a4c565b905060026127f7838a613c36565b612801858a613c23565b61280b908d613a7b565b6128159190613a98565b61281f908b613c36565b6128299190613a98565b925061283a8183611e5e8680613a7b565b612845846002613a7b565b61284f9190613c36565b94505050505b5095945050505050565b6000846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561289f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c391906139ce565b6001600160a01b0316896001600160a01b031614806129545750846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561291b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293f91906139ce565b6001600160a01b0316896001600160a01b0316145b6129945760405162461bcd60e51b815260206004820152601160248201527005a61703a2057726f6e6720746f6b656e3607c1b6044820152606401610543565b846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f691906139ce565b6001600160a01b0316886001600160a01b03161480612a875750846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7291906139ce565b6001600160a01b0316886001600160a01b0316145b612ac75760405162461bcd60e51b81526020600482015260116024820152705a61703a2057726f6e6720746f6b656e3160781b6044820152606401610543565b876001600160a01b0316896001600160a01b031603612b1b5760405162461bcd60e51b815260206004820152601060248201526f5a61703a2053616d6520746f6b656e7360801b6044820152606401610543565b6000806000876001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015612b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b829190613a07565b506001600160701b031691506001600160701b031691506103e88210158015612bad57506103e88110155b612bf15760405162461bcd60e51b81526020600482015260156024820152745a61703a20526573657276657320746f6f206c6f7760581b6044820152606401610543565b876001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5391906139ce565b6001600160a01b03168c6001600160a01b031603612cab57612c788a8a84848961246a565b600454909350612c888484613a98565b1015612ca65760405162461bcd60e51b815260040161054390613c49565b612ce6565b612cb88a8a83858961246a565b600454909350612cc88483613a98565b1015612ce65760405162461bcd60e51b815260040161054390613c49565b505084811115612d385760405162461bcd60e51b815260206004820152601c60248201527f5a61703a20416d6f756e7420746f207377617020746f6f2068696768000000006044820152606401610543565b6040805160028082526060820183526000926020830190803683370190505090508315612dd5578a81600081518110612d7357612d73613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250508981600181518110612da757612da7613ade565b60200260200101906001600160a01b031690816001600160a01b031681525050612dd08b6131d7565b612e46565b8981600081518110612de957612de9613ade565b60200260200101906001600160a01b031690816001600160a01b0316815250508a81600181518110612e1d57612e1d613ade565b60200260200101906001600160a01b031690816001600160a01b031681525050612e468a6131d7565b6003546040516338ed173960e01b81526000916001600160a01b0316906338ed173990612e7f9086908a90879030904290600401613af4565b6000604051808303816000875af1158015612e9e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ec69190810190613b65565b90508415612fe357612ed78b6131d7565b60035482516001600160a01b039091169063e8e33700908490600090612eff57612eff613ade565b602002602001015184600181518110612f1a57612f1a613ade565b602002602001015184600081518110612f3557612f35613ade565b60200260200101518e612f489190613c36565b85600181518110612f5b57612f5b613ade565b60200260200101518e612f6e9190613c23565b60018033426040518963ffffffff1660e01b8152600401612f96989796959493929190613c80565b6060604051808303816000875af1158015612fb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd99190613cc9565b95506130f3915050565b612fec8c6131d7565b60035482516001600160a01b039091169063e8e3370090849060009061301457613014613ade565b60200260200101518460018151811061302f5761302f613ade565b60200260200101518460008151811061304a5761304a613ade565b60200260200101518d61305d9190613c36565b8560018151811061307057613070613ade565b60200260200101518f6130839190613c23565b60018033426040518963ffffffff1660e01b81526004016130ab989796959493929190613c80565b6060604051808303816000875af11580156130ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ee9190613cc9565b955050505b50505098975050505050505050565b6000613157826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133f99092919063ffffffff16565b90508051600014806131785750808060200190518101906131789190613cf7565b6105a05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610543565b600554604051636eb1769f60e11b81523060048201526001600160a01b03918216602482015269d3c21bcecceda10000009183169063dd62ed3e90604401602060405180830381865afa158015613232573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132569190613a4c565b101561171557600554611715906001600160a01b038381169116600019613408565b60008160000361328a57506000919050565b816001600160801b82106132a35760809190911c9060401b5b6801000000000000000082106132be5760409190911c9060201b5b64010000000082106132d55760209190911c9060101b5b6201000082106132ea5760109190911c9060081b5b61010082106132fe5760089190911c9060041b5b601082106133115760049190911c9060021b5b6008821061331d5760011b5b60016133298286613a98565b6133339083613c23565b901c905060016133438286613a98565b61334d9083613c23565b901c9050600161335d8286613a98565b6133679083613c23565b901c905060016133778286613a98565b6133819083613c23565b901c905060016133918286613a98565b61339b9083613c23565b901c905060016133ab8286613a98565b6133b59083613c23565b901c905060016133c58286613a98565b6133cf9083613c23565b901c905060006133df8286613a98565b90508082106133ee57806133f0565b815b95945050505050565b6060612462848460008561351d565b8015806134825750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561345c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134809190613a4c565b155b6134ed5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610543565b6040516001600160a01b0383166024820152604481018290526105a090849063095ea7b360e01b906064016117ff565b60608247101561357e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610543565b600080866001600160a01b0316858760405161359a91906139b2565b60006040518083038185875af1925050503d80600081146135d7576040519150601f19603f3d011682016040523d82523d6000602084013e6135dc565b606091505b5091509150611e818783838760608315613657578251600003613650576001600160a01b0385163b6136505760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610543565b5081612462565b612462838381511561366c5781518083602001fd5b8060405162461bcd60e51b81526004016105439190613d14565b634e487b7160e01b600052600160045260246000fd5b6000602082840312156136ae57600080fd5b5035919050565b6001600160a01b038116811461171557600080fd5b6000806000606084860312156136df57600080fd5b83356136ea816136b5565b95602085013595506040909401359392505050565b60008060006060848603121561371457600080fd5b833561371f816136b5565b9250602084013591506040840135613736816136b5565b809150509250925092565b6000806040838503121561375457600080fd5b823561375f816136b5565b946020939093013593505050565b600080600080600060a0868803121561378557600080fd5b8535613790816136b5565b945060208601356137a0816136b5565b9350604086013592506060860135915060808601356137be816136b5565b809150509295509295909350565b600080600080608085870312156137e257600080fd5b84356137ed816136b5565b935060208501356137fd816136b5565b93969395505050506040820135916060013590565b6000806000806080858703121561382857600080fd5b8435613833816136b5565b935060208501359250604085013561384a816136b5565b9396929550929360600135925050565b801515811461171557600080fd5b60008060008060008060c0878903121561388157600080fd5b863561388c816136b5565b95506020870135945060408701356138a3816136b5565b9350606087013592506080870135915060a08701356138c18161385a565b809150509295509295509295565b600080600080600080600080610100898b0312156138ec57600080fd5b88356138f7816136b5565b97506020890135613907816136b5565b965060408901359550606089013594506080890135613925816136b5565b935060a0890135925060c0890135915060e08901356139438161385a565b809150509295985092959890939650565b60006020828403121561396657600080fd5b8135613971816136b5565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156139a9578181015183820152602001613991565b50506000910152565b600082516139c481846020870161398e565b9190910192915050565b6000602082840312156139e057600080fd5b8151613971816136b5565b80516001600160701b0381168114613a0257600080fd5b919050565b600080600060608486031215613a1c57600080fd5b613a25846139eb565b9250613a33602085016139eb565b9150604084015163ffffffff8116811461373657600080fd5b600060208284031215613a5e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417613a9257613a92613a65565b92915050565b600082613ab557634e487b7160e01b600052601260045260246000fd5b500490565b60008060408385031215613acd57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052603260045260246000fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015613b445784516001600160a01b031683529383019391830191600101613b1f565b50506001600160a01b03969096166060850152505050608001529392505050565b60006020808385031215613b7857600080fd5b825167ffffffffffffffff80821115613b9057600080fd5b818501915085601f830112613ba457600080fd5b815181811115613bb657613bb6613978565b8060051b604051601f19603f83011681018181108582111715613bdb57613bdb613978565b604052918252848201925083810185019188831115613bf957600080fd5b938501935b82851015613c1757845184529385019392850192613bfe565b98975050505050505050565b80820180821115613a9257613a92613a65565b81810381811115613a9257613a92613a65565b6020808252601f908201527f5a61703a205175616e7469747920686967686572207468616e206c696d697400604082015260600190565b6001600160a01b039889168152968816602088015260408701959095526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b600080600060608486031215613cde57600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215613d0957600080fd5b81516139718161385a565b6020815260008251806020840152613d3381604085016020870161398e565b601f01601f1916919091016040019291505056fea264697066735822122017bfcb549b7a617b768b1cbfa169f638a7d82ddd786673cfe18d8730d87bbf0164736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad380000000000000000000000001d368773735ee1e678950b7a97bca2cafb330cdc0000000000000000000000000000000000000000000000000000000000000002
-----Decoded View---------------
Arg [0] : _WETHAddress (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
Arg [1] : _uniswapRouter (address): 0x1D368773735ee1E678950B7A97bcA2CafB330CDc
Arg [2] : _maxZapReverseRatio (uint256): 2
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [1] : 0000000000000000000000001d368773735ee1e678950b7a97bca2cafb330cdc
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000002
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.