Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Multichain Info
No addresses found
Loading...
Loading
Contract Name:
KSZapValidator
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import {KSRescue} from 'ks-growth-utils-sc/contracts/KSRescue.sol'; import {IKSZapValidator} from 'contracts/interfaces/zap/validators/IKSZapValidator.sol'; import {IBasePositionManager} from 'contracts/interfaces/ks_elastic/IBasePositionManager.sol'; import {IUniswapv3NFT} from 'contracts/interfaces/uniswapv3/IUniswapv3NFT.sol'; import {IERC20} from 'openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Contains main logics of a validator when zapping into KyberSwap Elastic/Classic pools /// and Uniswap v2/v3 + clones contract KSZapValidator is IKSZapValidator, KSRescue { /// @notice Prepare and return validation data before zap, calling internal functions to do the work /// @param _dexType type of dex/pool supported by this validator /// @param _zapInfo related info of zap to generate data function prepareValidationData( uint8 _dexType, bytes calldata _zapInfo ) external view override returns (bytes memory) { if (_dexType == uint8(DexType.UniswapV3)) { return _getUniswapV3ValidationData(_zapInfo); } if (_dexType == uint8(DexType.UniswapV2)) { return _getUniswapV2ValidationData(_zapInfo); } return new bytes(0); } /// @notice Validate result after zapping into pool, given initial data and data to validate /// @param _dexType type of dex/pool supported by this validator /// @param _extraData contains data to compares, for example: min liquidity /// @param _initialData contains initial data before zapping /// @param _zapResults contains zap results from executor function validateData( uint8 _dexType, bytes calldata _extraData, bytes calldata _initialData, bytes calldata _zapResults ) external view override returns (bool) { if (_dexType == uint8(DexType.UniswapV3)) { return _validateUniswapV3Result(_extraData, _initialData); } if (_dexType == uint8(DexType.UniswapV2)) { return _validateUniswapV2Result(_extraData, _initialData); } return true; } // ======================= Prepare data for validation ======================= /// @notice Generate initial data for validation for KyberSwap Classic and Uniswap v2 /// in order to validate, we need to get the initial LP balance of the recipient /// @param zapInfo contains info of zap with KyberSwap Classic/Uniswap v2 /// should be (pool_address, recipient_address) function _getClassicValidationData(bytes calldata zapInfo) internal view returns (bytes memory) { ClassicValidationData memory data; data.initialData = abi.decode(zapInfo, (ClassicZapData)); data.initialLiquidity = uint128(IERC20(data.initialData.pool).balanceOf(data.initialData.recipient)); return abi.encode(data); } /// @notice Generate initial data for validation for KyberSwap Elastic /// 2 cases: minting a new position or increase liquidity /// - minting a new position: /// + posID in zapInfo should be 0, then replaced with the expected posID /// + isNewPosition is true /// + initialLiquidity is 0 /// - increase liquidity: /// + isNewPosition is false /// + initialLiquidity is the current position liquidity, fetched from Position Manager function _getElasticValidationData(bytes calldata zapInfo) internal view returns (bytes memory) { ElasticValidationData memory data; data.initialData = abi.decode(zapInfo, (ElasticZapData)); if (data.initialData.posID == 0) { // minting new position, posID should be nextTokenId data.initialData.posID = IBasePositionManager(data.initialData.posManager).nextTokenId(); data.isNewPosition = true; data.initialLiquidity = 0; } else { data.isNewPosition = false; (IBasePositionManager.Position memory pos,) = IBasePositionManager(data.initialData.posManager).positions((data.initialData.posID)); data.initialLiquidity = pos.liquidity; } return abi.encode(data); } /// @notice Generate initial data for validation for Uniswap v3 /// 2 cases: minting a new position or increase liquidity /// - minting a new position: /// + posID in zapInfo should be 0, then replaced with the curren totalSupply /// + isNewPosition is true /// + initialLiquidity is 0 /// - increase liquidity: /// + isNewPosition is false /// + initialLiquidity is the current position liquidity, fetched from Position Manager function _getUniswapV3ValidationData(bytes calldata zapInfo) internal view returns (bytes memory) { ElasticValidationData memory data; data.initialData = abi.decode(zapInfo, (ElasticZapData)); if (data.initialData.posID == 0) { // minting new position, temporary store the total supply here data.initialData.posID = IUniswapv3NFT(data.initialData.posManager).totalSupply(); data.isNewPosition = true; data.initialLiquidity = 0; } else { data.isNewPosition = false; (,,,,,,, data.initialLiquidity,,,,) = IUniswapv3NFT(data.initialData.posManager).positions(data.initialData.posID); } return abi.encode(data); } /// @notice Generate initial data for validation for Uniswap v2 /// in order to validate, we need to get the initial LP balance of the recipient /// @param zapInfo contains info of zap with Uniswap v2 /// should be (pool_address, recipient_address) function _getUniswapV2ValidationData(bytes calldata zapInfo) internal view returns (bytes memory) { UniswapV2ValidationData memory data; data.initialData = abi.decode(zapInfo, (UniswapV2ZapData)); data.initialLiquidity = uint128(IERC20(data.initialData.pool).balanceOf(data.initialData.recipient)); return abi.encode(data); } // ======================= Validate data after zap ======================= /// @notice Validate result for zapping into KyberSwap Classic/Uniswap v2 /// - _extraData is the minLiquidity (for validation) /// - to validate, fetch the current LP balance of the recipient /// then compares with the initialLiquidity, make sure the increment is expected (>= minLiquidity) /// @param _extraData just the minLiquidity value, uint128 /// @param _initialData contains initial data before zap, including initialLiquidity function _validateClassicResult( bytes calldata _extraData, bytes calldata _initialData ) internal view returns (bool) { ClassicValidationData memory data = abi.decode(_initialData, (ClassicValidationData)); // getting new lp balance, make sure it should be increased uint256 lpBalanceAfter = IERC20(data.initialData.pool).balanceOf(data.initialData.recipient); if (lpBalanceAfter < data.initialLiquidity) return false; // validate increment in liquidity with min expectation uint256 minLiquidity = uint256(abi.decode(_extraData, (uint128))); require(minLiquidity > 0, 'zero min_liquidity'); return (lpBalanceAfter - data.initialLiquidity) >= minLiquidity; } /// @notice Validate result for zapping into KyberSwap Elastic /// 2 cases: /// - new position: /// + _extraData contains (recipient, posTickLower, posTickLower, minLiquidity) where: /// (+) recipient is the owner of the posID /// (+) posTickLower, posTickUpper are matched with position's tickLower/tickUpper /// (+) pool is matched with position's pool /// (+) minLiquidity <= pos.liquidity /// - increase liquidity: /// + _extraData contains minLiquidity, where: /// (+) minLiquidity <= (pos.liquidity - initialLiquidity) function _validateElasticResult( bytes calldata _extraData, bytes calldata _initialData ) internal view returns (bool) { ElasticValidationData memory data = abi.decode(_initialData, (ElasticValidationData)); IBasePositionManager posManager = IBasePositionManager(data.initialData.posManager); if (data.isNewPosition) { // minting a new position, need to validate many data ElasticExtraData memory extraData = abi.decode(_extraData, (ElasticExtraData)); // require owner of the pos id is the recipient if (posManager.ownerOf(data.initialData.posID) != extraData.recipient) return false; // getting pos info from Position Manager (IBasePositionManager.Position memory pos,) = posManager.positions((data.initialData.posID)); // tick ranges should match if (extraData.posTickLower != pos.tickLower || extraData.posTickUpper != pos.tickUpper) { return false; } // poolId should correspond to the pool address if (posManager.addressToPoolId(data.initialData.pool) != pos.poolId) return false; // new liquidity should match expectation require(extraData.minLiquidity > 0, 'zero min_liquidity'); return pos.liquidity >= extraData.minLiquidity; } else { // not a new position, only need to verify liquidty increment // getting new position liquidity, make sure it is increased (IBasePositionManager.Position memory pos,) = posManager.positions((data.initialData.posID)); if (pos.liquidity < data.initialLiquidity) return false; // validate increment in liquidity with min expectation uint128 minLiquidity = abi.decode(_extraData, (uint128)); require(minLiquidity > 0, 'zero min_liquidity'); return pos.liquidity - data.initialLiquidity >= minLiquidity; } } /// @notice Validate result for zapping into Uniswap V3 /// 2 cases: /// - new position: /// + posID is the totalSupply, need to fetch the corresponding posID /// + _extraData contains (recipient, posTickLower, posTickLower, minLiquidity) where: /// (+) recipient is the owner of the posID /// (+) posTickLower, posTickUpper are matched with position's tickLower/tickUpper /// (+) pool is matched with position's pool /// (+) minLiquidity <= pos.liquidity /// - increase liquidity: /// + _extraData contains minLiquidity, where: /// (+) minLiquidity <= (pos.liquidity - initialLiquidity) function _validateUniswapV3Result( bytes calldata _extraData, bytes calldata _initialData ) internal view returns (bool) { ElasticValidationData memory data = abi.decode(_initialData, (ElasticValidationData)); IUniswapv3NFT posManager = IUniswapv3NFT(data.initialData.posManager); if (data.isNewPosition) { // minting a new position, need to validate many data // Calculate the posID and replace, it should be the last index data.initialData.posID = posManager.tokenByIndex(data.initialData.posID); ElasticExtraData memory extraData = abi.decode(_extraData, (ElasticExtraData)); // require owner of the pos id is the recipient if (posManager.ownerOf(data.initialData.posID) != extraData.recipient) return false; // getting pos info from Position Manager (,,,,, int24 tickLower, int24 tickUpper, uint128 liquidity,,,,) = posManager.positions(data.initialData.posID); // tick ranges should match if (extraData.posTickLower != tickLower || extraData.posTickUpper != tickUpper) { return false; } // TODO: poolId should correspond to the pool address // if (posManager.addressToPoolId(data.initialData.pool) != pos.poolId) return false; // new liquidity should match expectation require(extraData.minLiquidity > 0, 'zero min_liquidity'); return liquidity >= extraData.minLiquidity; } else { // not a new position, only need to verify liquidty increment // getting new position liquidity, make sure it is increased (,,,,,,, uint128 newLiquidity,,,,) = posManager.positions(data.initialData.posID); if (newLiquidity < data.initialLiquidity) return false; // validate increment in liquidity with min expectation uint128 minLiquidity = abi.decode(_extraData, (uint128)); require(minLiquidity > 0, 'zero min_liquidity'); return newLiquidity - data.initialLiquidity >= minLiquidity; } } /// @notice Validate result for zapping into Uniswap v2 /// - _extraData is the minLiquidity (for validation) /// - to validate, fetch the current LP balance of the recipient /// then compares with the initialLiquidity, make sure the increment is expected (>= minLiquidity) /// @param _extraData just the minLiquidity value, uint256 /// @param _initialData contains initial data before zap, including initialLiquidity function _validateUniswapV2Result( bytes calldata _extraData, bytes calldata _initialData ) internal view returns (bool) { UniswapV2ValidationData memory data = abi.decode(_initialData, (UniswapV2ValidationData)); // getting new lp balance, make sure it should be increased uint256 lpBalanceAfter = IERC20(data.initialData.pool).balanceOf(data.initialData.recipient); if (lpBalanceAfter < data.initialLiquidity) return false; // validate increment in liquidity with min expectation uint256 minLiquidity = uint256(abi.decode(_extraData, (uint256))); require(minLiquidity > 0, 'zero min_liquidity'); return (lpBalanceAfter - data.initialLiquidity) >= minLiquidity; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {KyberSwapRole} from '@src/KyberSwapRole.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; abstract contract KSRescue is KyberSwapRole { using SafeERC20 for IERC20; address private constant ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); function rescueFunds(address token, uint256 amount, address recipient) external onlyOwner { require(recipient != address(0), 'KSRescue: invalid recipient'); if (amount == 0) amount = _getAvailableAmount(token); if (amount > 0) { if (_isETH(token)) { (bool success,) = recipient.call{value: amount}(''); require(success, 'KSRescue: ETH_TRANSFER_FAILED'); } else { IERC20(token).safeTransfer(recipient, amount); } } } function _getAvailableAmount(address token) internal view virtual returns (uint256 amount) { if (_isETH(token)) { amount = address(this).balance; } else { amount = IERC20(token).balanceOf(address(this)); } if (amount > 0) --amount; } function _isETH(address token) internal pure returns (bool) { return (token == ETH_ADDRESS); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import {IZapValidator} from 'contracts/interfaces/zap/validators/IZapValidator.sol'; interface IKSZapValidator is IZapValidator { /// @notice Only need pool address and recipient to get data struct ClassicZapData { address pool; address recipient; } /// @notice Return KS Classic Zap Data, and initial liquidity of the recipient struct ClassicValidationData { ClassicZapData initialData; uint128 initialLiquidity; } /// @notice Contains pool, posManage address /// posID = 0 -> minting a new position, otherwise increasing to existing one struct ElasticZapData { address pool; address posManager; uint256 posID; } /// @notice Return data for validation purpose /// In case minting a new position: /// - In case Elastic: it calculates the expected posID and update the value /// - In case Uniswap v3: it calculates the current total supply struct ElasticValidationData { ElasticZapData initialData; bool isNewPosition; uint128 initialLiquidity; } /// @notice Extra data to be used for validation after zapping struct ElasticExtraData { address recipient; int24 posTickLower; int24 posTickUpper; uint128 minLiquidity; } /// @notice Only need pool address and recipient to get data struct UniswapV2ZapData { address pool; address recipient; } /// @notice Return Uniswap V2 Zap Data, and initial liquidity of the recipient struct UniswapV2ValidationData { UniswapV2ZapData initialData; uint256 initialLiquidity; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; interface IBasePositionManager { struct Position { // the nonce for permits uint96 nonce; // the address that is approved for spending this token address operator; // the ID of the pool with which this token is connected uint80 poolId; // the tick range of the position int24 tickLower; int24 tickUpper; // the liquidity of the position uint128 liquidity; // the current rToken that the position owed uint256 rTokenOwed; // fee growth per unit of liquidity as of the last update to liquidity uint256 feeGrowthInsideLast; } struct PoolInfo { address token0; uint16 fee; address token1; } struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; int24[2] ticksPrevious; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } struct IncreaseLiquidityParams { uint256 tokenId; int24[2] ticksPrevious; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } struct RemoveLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } struct BurnRTokenParams { uint256 tokenId; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } function nextTokenId() external view returns (uint256); function ownerOf(uint256 tokenId) external view returns (address); function positions( uint256 tokenId ) external view returns (Position memory pos, PoolInfo memory info); function addressToPoolId(address pool) external view returns (uint80); function WETH() external view returns (address); function tokenByIndex(uint256 index) external view returns (uint256); function totalSupply() external view returns (uint256); function mint( MintParams calldata params ) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); function addLiquidity( IncreaseLiquidityParams calldata params ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1, uint256 additionalRTokenOwed); function removeLiquidity( RemoveLiquidityParams calldata params ) external returns (uint256 amount0, uint256 amount1, uint256 additionalRTokenOwed); function syncFeeGrowth(uint256 tokenId) external returns (uint256 additionalRTokenOwed); function burnRTokens( BurnRTokenParams calldata params ) external returns (uint256 rTokenQty, uint256 amount0, uint256 amount1); function transferAllTokens(address token, uint256 minAmount, address recipient) external payable; function unwrapWeth(uint256 minAmount, address recipient) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; interface IUniswapv3NFT { function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } function mint( MintParams calldata params ) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } function increaseLiquidity( IncreaseLiquidityParams calldata params ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } function decreaseLiquidity( DecreaseLiquidityParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } function collect( CollectParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); function sweepToken(address token, uint256 amountMinimum, address recipient) external payable; function transferFrom(address from, address to, uint256 tokenId) external; function approve(address spender, uint256 tokenId) external; function setApprovalForAll(address operator, bool approved) external; function WETH9() external view returns (address); function ownerOf(uint256 tokenId) external view returns (address); function tokenByIndex(uint256 index) external view returns (uint256); function totalSupply() external view returns (uint256); }
// 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 pragma solidity ^0.8.0; import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; import {Pausable} from '@openzeppelin/contracts/security/Pausable.sol'; abstract contract KyberSwapRole is Ownable, Pausable { mapping(address => bool) public operators; mapping(address => bool) public guardians; /** * @dev Emitted when the an user was grant or revoke operator role. */ event UpdateOperator(address user, bool grantOrRevoke); /** * @dev Emitted when the an user was grant or revoke guardian role. */ event UpdateGuardian(address user, bool grantOrRevoke); /** * @dev Modifier to make a function callable only when caller is operator. * * Requirements: * * - Caller must have operator role. */ modifier onlyOperator() { require(operators[msg.sender], 'KyberSwapRole: not operator'); _; } /** * @dev Modifier to make a function callable only when caller is guardian. * * Requirements: * * - Caller must have guardian role. */ modifier onlyGuardian() { require(guardians[msg.sender], 'KyberSwapRole: not guardian'); _; } /** * @dev Update Operator role for user. * Can only be called by the current owner. */ function updateOperator(address user, bool grantOrRevoke) external onlyOwner { operators[user] = grantOrRevoke; emit UpdateOperator(user, grantOrRevoke); } /** * @dev Update Guardian role for user. * Can only be called by the current owner. */ function updateGuardian(address user, bool grantOrRevoke) external onlyOwner { guardians[user] = grantOrRevoke; emit UpdateGuardian(user, grantOrRevoke); } /** * @dev Enable logic for contract. * Can only be called by the current owner. */ function enableLogic() external onlyOwner { _unpause(); } /** * @dev Disable logic for contract. * Can only be called by the guardians. */ function disableLogic() external onlyGuardian { _pause(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import {IZapDexEnum} from 'contracts/interfaces/zap/common/IZapDexEnum.sol'; interface IZapValidator is IZapDexEnum { function prepareValidationData( uint8 _dexType, bytes calldata _zapInfo ) external view returns (bytes memory validationData); function validateData( uint8 _dexType, bytes calldata _extraData, bytes calldata _initialData, bytes calldata _zapResults ) external view returns (bool isValid); }
// SPDX-License-Identifier: MIT 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() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >= 0.8.0; interface IZapDexEnum { enum DexType { UniswapV2, UniswapV3 } enum SrcType { ERC20Token, ERC721Token, ERC1155Token } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin/=lib/openzeppelin-contracts/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "ks-growth-utils-sc/=lib/ks-growth-utils-sc/", "@openzeppelin/=lib/ks-growth-utils-sc/lib/openzeppelin-contracts/", "@src/=lib/ks-growth-utils-sc/contracts/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": true, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"UpdateGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"UpdateOperator","type":"event"},{"inputs":[],"name":"disableLogic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableLogic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guardians","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"operators","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_dexType","type":"uint8"},{"internalType":"bytes","name":"_zapInfo","type":"bytes"}],"name":"prepareValidationData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"updateGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"updateOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_dexType","type":"uint8"},{"internalType":"bytes","name":"_extraData","type":"bytes"},{"internalType":"bytes","name":"_initialData","type":"bytes"},{"internalType":"bytes","name":"_zapResults","type":"bytes"}],"name":"validateData","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001a3361002c565b6000805460ff60a01b1916905561007c565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611a288061008b6000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063c6256bef11610066578063c6256bef146101a7578063e83aa3a8146101c7578063f2fde38b146101da578063f9338d18146101ed57600080fd5b80638da5cb5b146101715780639dd392391461018c578063af0a35571461019457600080fd5b80630633b14a146100d457806313e7c9d81461010c5780635c975abb1461012f5780636d44a3b214610141578063715018a61461015657806388f4950f1461015e575b600080fd5b6100f76100e2366004611290565b60026020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100f761011a366004611290565b60016020526000908152604090205460ff1681565b600054600160a01b900460ff166100f7565b61015461014f3660046112bb565b6101f5565b005b61015461028c565b61015461016c3660046112bb565b6102c2565b6000546040516001600160a01b039091168152602001610103565b610154610348565b6100f76101a236600461134e565b6103af565b6101ba6101b53660046113f9565b6103f3565b60405161010391906114a4565b6101546101d53660046114b7565b61043c565b6101546101e8366004611290565b6105ba565b610154610655565b6000546001600160a01b031633146102285760405162461bcd60e51b815260040161021f906114f9565b60405180910390fd5b6001600160a01b038216600081815260016020908152604091829020805460ff19168515159081179091558251938452908301527f2ee52be9d342458b3d25e07faada7ff9bc06723b4aa24edb6321ac1316b8a9dd91015b60405180910390a15050565b6000546001600160a01b031633146102b65760405162461bcd60e51b815260040161021f906114f9565b6102c06000610687565b565b6000546001600160a01b031633146102ec5760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b038216600081815260026020908152604091829020805460ff19168515159081179091558251938452908301527f25d7ce8d7e0b3990938766275ee2d54fbe81347d287bfbf0429838409a889fdc9101610280565b3360009081526002602052604090205460ff166103a75760405162461bcd60e51b815260206004820152601b60248201527f4b7962657253776170526f6c653a206e6f7420677561726469616e0000000000604482015260640161021f565b6102c06106d7565b600060ff8816600114156103d0576103c98787878761077c565b90506103e8565b60ff88166103e4576103c987878787610b30565b5060015b979650505050505050565b606060ff8416600114156104125761040b8383610c30565b9050610435565b60ff84166104245761040b8383610e1d565b506040805160008152602081019091525b9392505050565b6000546001600160a01b031633146104665760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b0381166104bc5760405162461bcd60e51b815260206004820152601b60248201527f4b535265736375653a20696e76616c696420726563697069656e740000000000604482015260640161021f565b816104cd576104ca83610f19565b91505b81156105b55773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03841614156105a1576000816001600160a01b03168360405160006040518083038185875af1925050503d8060008114610545576040519150601f19603f3d011682016040523d82523d6000602084013e61054a565b606091505b505090508061059b5760405162461bcd60e51b815260206004820152601d60248201527f4b535265736375653a204554485f5452414e534645525f4641494c4544000000604482015260640161021f565b50505050565b6105b56001600160a01b0384168284610fd8565b505050565b6000546001600160a01b031633146105e45760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b0381166106495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161021f565b61065281610687565b50565b6000546001600160a01b0316331461067f5760405162461bcd60e51b815260040161021f906114f9565b6102c061102a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600054600160a01b900460ff16156107245760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161021f565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861075f3390565b6040516001600160a01b03909116815260200160405180910390a1565b60008061078b838501856115f9565b8051602090810151908201519192509015610a035781516040908101519051634f6ccce760e01b815260048101919091526001600160a01b03821690634f6ccce79060240160206040518083038186803b1580156107e857600080fd5b505afa1580156107fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610820919061164c565b825160400152600061083487890189611674565b8051845160409081015190516331a9108f60e11b81529293506001600160a01b039182169291851691636352211e916108739160040190815260200190565b60206040518083038186803b15801561088b57600080fd5b505afa15801561089f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c39190611712565b6001600160a01b0316146108dd5760009350505050610b28565b6000806000846001600160a01b03166399fbab888760000151604001516040518263ffffffff1660e01b815260040161091891815260200190565b6101806040518083038186803b15801561093157600080fd5b505afa158015610945573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109699190611758565b5050505097509750975050505050508260020b846020015160020b14158061099b57508160020b846040015160020b14155b156109af5760009650505050505050610b28565b600084606001516001600160801b0316116109dc5760405162461bcd60e51b815260040161021f90611839565b83606001516001600160801b0316816001600160801b031610159650505050505050610b28565b8151604090810151905163133f757160e31b81526000916001600160a01b038416916399fbab8891610a3b9160040190815260200190565b6101806040518083038186803b158015610a5457600080fd5b505afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190611758565b5050505097505050505050505082604001516001600160801b0316816001600160801b03161015610ac35760009350505050610b28565b6000610ad1888a018a611865565b90506000816001600160801b031611610afc5760405162461bcd60e51b815260040161021f90611839565b806001600160801b0316846040015183610b169190611898565b6001600160801b031610159450505050505b949350505050565b600080610b3f83850185611902565b805180516020909101516040516370a0823160e01b81526001600160a01b0391821660048201529293506000929116906370a082319060240160206040518083038186803b158015610b9057600080fd5b505afa158015610ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc8919061164c565b90508160200151811015610be157600092505050610b28565b6000610bef8789018961193a565b905060008111610c115760405162461bcd60e51b815260040161021f90611839565b80836020015183610c229190611953565b101598975050505050505050565b6040805160c081018252600060608281018281526080840183905260a0840183905283526020830182905292820152610c6b8385018561196a565b80825260400151610d0c578060000151602001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cb757600080fd5b505afa158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef919061164c565b815160409081019190915260016020830152600090820152610db5565b6000602082810191909152815190810151604091820151915163133f757160e31b815260048101929092526001600160a01b0316906399fbab88906024016101806040518083038186803b158015610d6357600080fd5b505afa158015610d77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9b9190611758565b505050506001600160801b03166040890152505050505050505b60408051825180516001600160a01b03908116602080850191909152828101519091168385015290830151606083015283015115156080820152908201516001600160801b031660a082015260c0015b60405160208183030381529060405291505092915050565b6060610e48604080516080810182526000918101828152606082018390528152602081019190915290565b610e5483850185611986565b80825280516020909101516040516370a0823160e01b81526001600160a01b0391821660048201529116906370a082319060240160206040518083038186803b158015610ea057600080fd5b505afa158015610eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed8919061164c565b6001600160801b0316602082810191825260408051845180516001600160a01b03908116838601529301519092169082015290516060820152608001610e05565b600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0383161415610f47575047610fc1565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a082319060240160206040518083038186803b158015610f8657600080fd5b505afa158015610f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbe919061164c565b90505b8015610fd357610fd0816119a2565b90505b919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b59084906110ae565b600054600160a01b900460ff1661107a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161021f565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa3361075f565b6000611103826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111809092919063ffffffff16565b8051909150156105b5578080602001905181019061112191906119b9565b6105b55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161021f565b6060610b28848460008585843b6111d95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161021f565b600080866001600160a01b031685876040516111f591906119d6565b60006040518083038185875af1925050503d8060008114611232576040519150601f19603f3d011682016040523d82523d6000602084013e611237565b606091505b50915091506103e882828660608315611251575081610435565b8251156112615782518084602001fd5b8160405162461bcd60e51b815260040161021f91906114a4565b6001600160a01b038116811461065257600080fd5b6000602082840312156112a257600080fd5b81356104358161127b565b801515811461065257600080fd5b600080604083850312156112ce57600080fd5b82356112d98161127b565b915060208301356112e9816112ad565b809150509250929050565b803560ff81168114610fd357600080fd5b60008083601f84011261131757600080fd5b50813567ffffffffffffffff81111561132f57600080fd5b60208301915083602082850101111561134757600080fd5b9250929050565b60008060008060008060006080888a03121561136957600080fd5b611372886112f4565b9650602088013567ffffffffffffffff8082111561138f57600080fd5b61139b8b838c01611305565b909850965060408a01359150808211156113b457600080fd5b6113c08b838c01611305565b909650945060608a01359150808211156113d957600080fd5b506113e68a828b01611305565b989b979a50959850939692959293505050565b60008060006040848603121561140e57600080fd5b611417846112f4565b9250602084013567ffffffffffffffff81111561143357600080fd5b61143f86828701611305565b9497909650939450505050565b60005b8381101561146757818101518382015260200161144f565b8381111561059b5750506000910152565b6000815180845261149081602086016020860161144c565b601f01601f19169290920160200192915050565b6020815260006104356020830184611478565b6000806000606084860312156114cc57600080fd5b83356114d78161127b565b92506020840135915060408401356114ee8161127b565b809150509250925092565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6040516060810167ffffffffffffffff8111828210171561155f57634e487b7160e01b600052604160045260246000fd5b60405290565b6040805190810167ffffffffffffffff8111828210171561155f57634e487b7160e01b600052604160045260246000fd5b6000606082840312156115a857600080fd5b6115b061152e565b905081356115bd8161127b565b815260208201356115cd8161127b565b806020830152506040820135604082015292915050565b6001600160801b038116811461065257600080fd5b600060a0828403121561160b57600080fd5b61161361152e565b61161d8484611596565b8152606083013561162d816112ad565b60208201526080830135611640816115e4565b60408201529392505050565b60006020828403121561165e57600080fd5b5051919050565b8060020b811461065257600080fd5b60006080828403121561168657600080fd5b6040516080810181811067ffffffffffffffff821117156116b757634e487b7160e01b600052604160045260246000fd5b60405282356116c58161127b565b815260208301356116d581611665565b602082015260408301356116e881611665565b604082015260608301356116fb816115e4565b60608201529392505050565b8051610fd38161127b565b60006020828403121561172457600080fd5b81516104358161127b565b805162ffffff81168114610fd357600080fd5b8051610fd381611665565b8051610fd3816115e4565b6000806000806000806000806000806000806101808d8f03121561177b57600080fd5b8c516bffffffffffffffffffffffff8116811461179757600080fd5b9b506117a560208e01611707565b9a506117b360408e01611707565b99506117c160608e01611707565b98506117cf60808e0161172f565b97506117dd60a08e01611742565b96506117eb60c08e01611742565b95506117f960e08e0161174d565b94506101008d015193506101208d015192506118186101408e0161174d565b91506118276101608e0161174d565b90509295989b509295989b509295989b565b6020808252601290820152717a65726f206d696e5f6c697175696469747960701b604082015260600190565b60006020828403121561187757600080fd5b8135610435816115e4565b634e487b7160e01b600052601160045260246000fd5b60006001600160801b03838116908316818110156118b8576118b8611882565b039392505050565b6000604082840312156118d257600080fd5b6118da611565565b905081356118e78161127b565b815260208201356118f78161127b565b602082015292915050565b60006060828403121561191457600080fd5b61191c611565565b61192684846118c0565b815260409290920135602083015250919050565b60006020828403121561194c57600080fd5b5035919050565b60008282101561196557611965611882565b500390565b60006060828403121561197c57600080fd5b6104358383611596565b60006040828403121561199857600080fd5b61043583836118c0565b6000816119b1576119b1611882565b506000190190565b6000602082840312156119cb57600080fd5b8151610435816112ad565b600082516119e881846020870161144c565b919091019291505056fea2646970667358221220a061a3df01d68af5fe688f6be4ed12138c90970bd9b5b95e0c68fae4723a708e64736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063c6256bef11610066578063c6256bef146101a7578063e83aa3a8146101c7578063f2fde38b146101da578063f9338d18146101ed57600080fd5b80638da5cb5b146101715780639dd392391461018c578063af0a35571461019457600080fd5b80630633b14a146100d457806313e7c9d81461010c5780635c975abb1461012f5780636d44a3b214610141578063715018a61461015657806388f4950f1461015e575b600080fd5b6100f76100e2366004611290565b60026020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100f761011a366004611290565b60016020526000908152604090205460ff1681565b600054600160a01b900460ff166100f7565b61015461014f3660046112bb565b6101f5565b005b61015461028c565b61015461016c3660046112bb565b6102c2565b6000546040516001600160a01b039091168152602001610103565b610154610348565b6100f76101a236600461134e565b6103af565b6101ba6101b53660046113f9565b6103f3565b60405161010391906114a4565b6101546101d53660046114b7565b61043c565b6101546101e8366004611290565b6105ba565b610154610655565b6000546001600160a01b031633146102285760405162461bcd60e51b815260040161021f906114f9565b60405180910390fd5b6001600160a01b038216600081815260016020908152604091829020805460ff19168515159081179091558251938452908301527f2ee52be9d342458b3d25e07faada7ff9bc06723b4aa24edb6321ac1316b8a9dd91015b60405180910390a15050565b6000546001600160a01b031633146102b65760405162461bcd60e51b815260040161021f906114f9565b6102c06000610687565b565b6000546001600160a01b031633146102ec5760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b038216600081815260026020908152604091829020805460ff19168515159081179091558251938452908301527f25d7ce8d7e0b3990938766275ee2d54fbe81347d287bfbf0429838409a889fdc9101610280565b3360009081526002602052604090205460ff166103a75760405162461bcd60e51b815260206004820152601b60248201527f4b7962657253776170526f6c653a206e6f7420677561726469616e0000000000604482015260640161021f565b6102c06106d7565b600060ff8816600114156103d0576103c98787878761077c565b90506103e8565b60ff88166103e4576103c987878787610b30565b5060015b979650505050505050565b606060ff8416600114156104125761040b8383610c30565b9050610435565b60ff84166104245761040b8383610e1d565b506040805160008152602081019091525b9392505050565b6000546001600160a01b031633146104665760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b0381166104bc5760405162461bcd60e51b815260206004820152601b60248201527f4b535265736375653a20696e76616c696420726563697069656e740000000000604482015260640161021f565b816104cd576104ca83610f19565b91505b81156105b55773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03841614156105a1576000816001600160a01b03168360405160006040518083038185875af1925050503d8060008114610545576040519150601f19603f3d011682016040523d82523d6000602084013e61054a565b606091505b505090508061059b5760405162461bcd60e51b815260206004820152601d60248201527f4b535265736375653a204554485f5452414e534645525f4641494c4544000000604482015260640161021f565b50505050565b6105b56001600160a01b0384168284610fd8565b505050565b6000546001600160a01b031633146105e45760405162461bcd60e51b815260040161021f906114f9565b6001600160a01b0381166106495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161021f565b61065281610687565b50565b6000546001600160a01b0316331461067f5760405162461bcd60e51b815260040161021f906114f9565b6102c061102a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600054600160a01b900460ff16156107245760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161021f565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861075f3390565b6040516001600160a01b03909116815260200160405180910390a1565b60008061078b838501856115f9565b8051602090810151908201519192509015610a035781516040908101519051634f6ccce760e01b815260048101919091526001600160a01b03821690634f6ccce79060240160206040518083038186803b1580156107e857600080fd5b505afa1580156107fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610820919061164c565b825160400152600061083487890189611674565b8051845160409081015190516331a9108f60e11b81529293506001600160a01b039182169291851691636352211e916108739160040190815260200190565b60206040518083038186803b15801561088b57600080fd5b505afa15801561089f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c39190611712565b6001600160a01b0316146108dd5760009350505050610b28565b6000806000846001600160a01b03166399fbab888760000151604001516040518263ffffffff1660e01b815260040161091891815260200190565b6101806040518083038186803b15801561093157600080fd5b505afa158015610945573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109699190611758565b5050505097509750975050505050508260020b846020015160020b14158061099b57508160020b846040015160020b14155b156109af5760009650505050505050610b28565b600084606001516001600160801b0316116109dc5760405162461bcd60e51b815260040161021f90611839565b83606001516001600160801b0316816001600160801b031610159650505050505050610b28565b8151604090810151905163133f757160e31b81526000916001600160a01b038416916399fbab8891610a3b9160040190815260200190565b6101806040518083038186803b158015610a5457600080fd5b505afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190611758565b5050505097505050505050505082604001516001600160801b0316816001600160801b03161015610ac35760009350505050610b28565b6000610ad1888a018a611865565b90506000816001600160801b031611610afc5760405162461bcd60e51b815260040161021f90611839565b806001600160801b0316846040015183610b169190611898565b6001600160801b031610159450505050505b949350505050565b600080610b3f83850185611902565b805180516020909101516040516370a0823160e01b81526001600160a01b0391821660048201529293506000929116906370a082319060240160206040518083038186803b158015610b9057600080fd5b505afa158015610ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc8919061164c565b90508160200151811015610be157600092505050610b28565b6000610bef8789018961193a565b905060008111610c115760405162461bcd60e51b815260040161021f90611839565b80836020015183610c229190611953565b101598975050505050505050565b6040805160c081018252600060608281018281526080840183905260a0840183905283526020830182905292820152610c6b8385018561196a565b80825260400151610d0c578060000151602001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cb757600080fd5b505afa158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef919061164c565b815160409081019190915260016020830152600090820152610db5565b6000602082810191909152815190810151604091820151915163133f757160e31b815260048101929092526001600160a01b0316906399fbab88906024016101806040518083038186803b158015610d6357600080fd5b505afa158015610d77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9b9190611758565b505050506001600160801b03166040890152505050505050505b60408051825180516001600160a01b03908116602080850191909152828101519091168385015290830151606083015283015115156080820152908201516001600160801b031660a082015260c0015b60405160208183030381529060405291505092915050565b6060610e48604080516080810182526000918101828152606082018390528152602081019190915290565b610e5483850185611986565b80825280516020909101516040516370a0823160e01b81526001600160a01b0391821660048201529116906370a082319060240160206040518083038186803b158015610ea057600080fd5b505afa158015610eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed8919061164c565b6001600160801b0316602082810191825260408051845180516001600160a01b03908116838601529301519092169082015290516060820152608001610e05565b600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0383161415610f47575047610fc1565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a082319060240160206040518083038186803b158015610f8657600080fd5b505afa158015610f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbe919061164c565b90505b8015610fd357610fd0816119a2565b90505b919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b59084906110ae565b600054600160a01b900460ff1661107a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161021f565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa3361075f565b6000611103826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111809092919063ffffffff16565b8051909150156105b5578080602001905181019061112191906119b9565b6105b55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161021f565b6060610b28848460008585843b6111d95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161021f565b600080866001600160a01b031685876040516111f591906119d6565b60006040518083038185875af1925050503d8060008114611232576040519150601f19603f3d011682016040523d82523d6000602084013e611237565b606091505b50915091506103e882828660608315611251575081610435565b8251156112615782518084602001fd5b8160405162461bcd60e51b815260040161021f91906114a4565b6001600160a01b038116811461065257600080fd5b6000602082840312156112a257600080fd5b81356104358161127b565b801515811461065257600080fd5b600080604083850312156112ce57600080fd5b82356112d98161127b565b915060208301356112e9816112ad565b809150509250929050565b803560ff81168114610fd357600080fd5b60008083601f84011261131757600080fd5b50813567ffffffffffffffff81111561132f57600080fd5b60208301915083602082850101111561134757600080fd5b9250929050565b60008060008060008060006080888a03121561136957600080fd5b611372886112f4565b9650602088013567ffffffffffffffff8082111561138f57600080fd5b61139b8b838c01611305565b909850965060408a01359150808211156113b457600080fd5b6113c08b838c01611305565b909650945060608a01359150808211156113d957600080fd5b506113e68a828b01611305565b989b979a50959850939692959293505050565b60008060006040848603121561140e57600080fd5b611417846112f4565b9250602084013567ffffffffffffffff81111561143357600080fd5b61143f86828701611305565b9497909650939450505050565b60005b8381101561146757818101518382015260200161144f565b8381111561059b5750506000910152565b6000815180845261149081602086016020860161144c565b601f01601f19169290920160200192915050565b6020815260006104356020830184611478565b6000806000606084860312156114cc57600080fd5b83356114d78161127b565b92506020840135915060408401356114ee8161127b565b809150509250925092565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6040516060810167ffffffffffffffff8111828210171561155f57634e487b7160e01b600052604160045260246000fd5b60405290565b6040805190810167ffffffffffffffff8111828210171561155f57634e487b7160e01b600052604160045260246000fd5b6000606082840312156115a857600080fd5b6115b061152e565b905081356115bd8161127b565b815260208201356115cd8161127b565b806020830152506040820135604082015292915050565b6001600160801b038116811461065257600080fd5b600060a0828403121561160b57600080fd5b61161361152e565b61161d8484611596565b8152606083013561162d816112ad565b60208201526080830135611640816115e4565b60408201529392505050565b60006020828403121561165e57600080fd5b5051919050565b8060020b811461065257600080fd5b60006080828403121561168657600080fd5b6040516080810181811067ffffffffffffffff821117156116b757634e487b7160e01b600052604160045260246000fd5b60405282356116c58161127b565b815260208301356116d581611665565b602082015260408301356116e881611665565b604082015260608301356116fb816115e4565b60608201529392505050565b8051610fd38161127b565b60006020828403121561172457600080fd5b81516104358161127b565b805162ffffff81168114610fd357600080fd5b8051610fd381611665565b8051610fd3816115e4565b6000806000806000806000806000806000806101808d8f03121561177b57600080fd5b8c516bffffffffffffffffffffffff8116811461179757600080fd5b9b506117a560208e01611707565b9a506117b360408e01611707565b99506117c160608e01611707565b98506117cf60808e0161172f565b97506117dd60a08e01611742565b96506117eb60c08e01611742565b95506117f960e08e0161174d565b94506101008d015193506101208d015192506118186101408e0161174d565b91506118276101608e0161174d565b90509295989b509295989b509295989b565b6020808252601290820152717a65726f206d696e5f6c697175696469747960701b604082015260600190565b60006020828403121561187757600080fd5b8135610435816115e4565b634e487b7160e01b600052601160045260246000fd5b60006001600160801b03838116908316818110156118b8576118b8611882565b039392505050565b6000604082840312156118d257600080fd5b6118da611565565b905081356118e78161127b565b815260208201356118f78161127b565b602082015292915050565b60006060828403121561191457600080fd5b61191c611565565b61192684846118c0565b815260409290920135602083015250919050565b60006020828403121561194c57600080fd5b5035919050565b60008282101561196557611965611882565b500390565b60006060828403121561197c57600080fd5b6104358383611596565b60006040828403121561199857600080fd5b61043583836118c0565b6000816119b1576119b1611882565b506000190190565b6000602082840312156119cb57600080fd5b8151610435816112ad565b600082516119e881846020870161144c565b919091019291505056fea2646970667358221220a061a3df01d68af5fe688f6be4ed12138c90970bd9b5b95e0c68fae4723a708e64736f6c63430008090033
Loading...
Loading
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.