Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
2900217 | 18 days ago | Contract Creation | 0 S |
Loading...
Loading
Contract Name:
KyberSwapV2Swapper
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v3-helpers/contracts/utils/BytesHelpers.sol'; import '@mimic-fi/v3-connectors/contracts/interfaces/kyberswap/IKyberSwapV2Connector.sol'; import './BaseSwapTask.sol'; import '../interfaces/swap/IKyberSwapV2Swapper.sol'; /** * @title KyberSwap v2 swapper * @dev Task that extends the base swap task to use KyberSwap v2 */ contract KyberSwapV2Swapper is IKyberSwapV2Swapper, BaseSwapTask { using FixedPoint for uint256; using BytesHelpers for bytes; // Execution type for relayers bytes32 public constant override EXECUTION_TYPE = keccak256('KYBER_SWAP_V2_SWAPPER'); /** * @dev KyberSwap v2 swap config. Only used in the initializer. */ struct KyberSwapV2SwapConfig { BaseSwapConfig baseSwapConfig; } /** * @dev Initializes the KyberSwap v2 swapper * @param config KyberSwap v2 swap config */ function initialize(KyberSwapV2SwapConfig memory config) external virtual initializer { __KyberSwapV2Swapper_init(config); } /** * @dev Initializes the KyberSwap v2 swapper. It does call upper contracts initializers. * @param config KyberSwap v2 swap config */ function __KyberSwapV2Swapper_init(KyberSwapV2SwapConfig memory config) internal onlyInitializing { __BaseSwapTask_init(config.baseSwapConfig); __KyberSwapV2Swapper_init_unchained(config); } /** * @dev Initializes the KyberSwap v2 swapper. It does not call upper contracts initializers. * @param config KyberSwap v2 swap config */ function __KyberSwapV2Swapper_init_unchained(KyberSwapV2SwapConfig memory config) internal onlyInitializing { // solhint-disable-previous-line no-empty-blocks } /** * @dev Executes the KyberSwap V2 swapper task */ function call(address tokenIn, uint256 amountIn, uint256 slippage, bytes memory data) external override authP(authParams(tokenIn, amountIn, slippage)) { if (amountIn == 0) amountIn = getTaskAmount(tokenIn); _beforeKyberSwapV2Swapper(tokenIn, amountIn, slippage); address tokenOut = getTokenOut(tokenIn); uint256 price = _getPrice(tokenIn, tokenOut); uint256 minAmountOut = amountIn.mulUp(price).mulUp(FixedPoint.ONE - slippage); bytes memory connectorData = abi.encodeWithSelector( IKyberSwapV2Connector.execute.selector, tokenIn, tokenOut, amountIn, minAmountOut, data ); bytes memory result = ISmartVault(smartVault).execute(connector, connectorData); _afterKyberSwapV2Swapper(tokenIn, amountIn, slippage, tokenOut, result.toUint256()); } /** * @dev Before KyberSwap v2 swapper hook */ function _beforeKyberSwapV2Swapper(address token, uint256 amount, uint256 slippage) internal virtual { _beforeBaseSwapTask(token, amount, slippage); } /** * @dev After KyberSwap v2 swapper hook */ function _afterKyberSwapV2Swapper( address tokenIn, uint256 amountIn, uint256 slippage, address tokenOut, uint256 amountOut ) internal virtual { _afterBaseSwapTask(tokenIn, amountIn, slippage, tokenOut, amountOut); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.17; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import './AuthorizedHelpers.sol'; import './interfaces/IAuthorized.sol'; import './interfaces/IAuthorizer.sol'; /** * @title Authorized * @dev Implementation using an authorizer as its access-control mechanism. It offers `auth` and `authP` modifiers to * tag its own functions in order to control who can access them against the authorizer referenced. */ contract Authorized is IAuthorized, Initializable, AuthorizedHelpers { // Authorizer reference address public override authorizer; /** * @dev Modifier that should be used to tag protected functions */ modifier auth() { _authenticate(msg.sender, msg.sig); _; } /** * @dev Modifier that should be used to tag protected functions with params */ modifier authP(uint256[] memory params) { _authenticate(msg.sender, msg.sig, params); _; } /** * @dev Creates a new authorized contract. Note that initializers are disabled at creation time. */ constructor() { _disableInitializers(); } /** * @dev Initializes the authorized contract. It does call upper contracts initializers. * @param _authorizer Address of the authorizer to be set */ function __Authorized_init(address _authorizer) internal onlyInitializing { __Authorized_init_unchained(_authorizer); } /** * @dev Initializes the authorized contract. It does not call upper contracts initializers. * @param _authorizer Address of the authorizer to be set */ function __Authorized_init_unchained(address _authorizer) internal onlyInitializing { authorizer = _authorizer; } /** * @dev Reverts if `who` is not allowed to call `what` * @param who Address to be authenticated * @param what Function selector to be authenticated */ function _authenticate(address who, bytes4 what) internal view { _authenticate(who, what, new uint256[](0)); } /** * @dev Reverts if `who` is not allowed to call `what` with `how` * @param who Address to be authenticated * @param what Function selector to be authenticated * @param how Params to be authenticated */ function _authenticate(address who, bytes4 what, uint256[] memory how) internal view { if (!_isAuthorized(who, what, how)) revert AuthSenderNotAllowed(who, what, how); } /** * @dev Tells whether `who` has any permission on this contract * @param who Address asking permissions for */ function _hasPermissions(address who) internal view returns (bool) { return IAuthorizer(authorizer).hasPermissions(who, address(this)); } /** * @dev Tells whether `who` is allowed to call `what` * @param who Address asking permission for * @param what Function selector asking permission for */ function _isAuthorized(address who, bytes4 what) internal view returns (bool) { return _isAuthorized(who, what, new uint256[](0)); } /** * @dev Tells whether `who` is allowed to call `what` with `how` * @param who Address asking permission for * @param what Function selector asking permission for * @param how Params asking permission for */ function _isAuthorized(address who, bytes4 what, uint256[] memory how) internal view returns (bool) { return IAuthorizer(authorizer).isAuthorized(who, address(this), what, how); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.17; /** * @title AuthorizedHelpers * @dev Syntax sugar methods to operate with authorizer params easily */ contract AuthorizedHelpers { function authParams(address p1) internal pure returns (uint256[] memory r) { return authParams(uint256(uint160(p1))); } function authParams(bytes32 p1) internal pure returns (uint256[] memory r) { return authParams(uint256(p1)); } function authParams(uint256 p1) internal pure returns (uint256[] memory r) { r = new uint256[](1); r[0] = p1; } function authParams(address p1, bool p2) internal pure returns (uint256[] memory r) { r = new uint256[](2); r[0] = uint256(uint160(p1)); r[1] = p2 ? 1 : 0; } function authParams(address p1, uint256 p2) internal pure returns (uint256[] memory r) { r = new uint256[](2); r[0] = uint256(uint160(p1)); r[1] = p2; } function authParams(address p1, address p2) internal pure returns (uint256[] memory r) { r = new uint256[](2); r[0] = uint256(uint160(p1)); r[1] = uint256(uint160(p2)); } function authParams(bytes32 p1, bytes32 p2) internal pure returns (uint256[] memory r) { r = new uint256[](2); r[0] = uint256(p1); r[1] = uint256(p2); } function authParams(address p1, address p2, uint256 p3) internal pure returns (uint256[] memory r) { r = new uint256[](3); r[0] = uint256(uint160(p1)); r[1] = uint256(uint160(p2)); r[2] = p3; } function authParams(address p1, address p2, address p3) internal pure returns (uint256[] memory r) { r = new uint256[](3); r[0] = uint256(uint160(p1)); r[1] = uint256(uint160(p2)); r[2] = uint256(uint160(p3)); } function authParams(address p1, address p2, bytes4 p3) internal pure returns (uint256[] memory r) { r = new uint256[](3); r[0] = uint256(uint160(p1)); r[1] = uint256(uint160(p2)); r[2] = uint256(uint32(p3)); } function authParams(address p1, uint256 p2, uint256 p3) internal pure returns (uint256[] memory r) { r = new uint256[](3); r[0] = uint256(uint160(p1)); r[1] = p2; r[2] = p3; } function authParams(uint256 p1, uint256 p2, uint256 p3, uint256 p4) internal pure returns (uint256[] memory r) { r = new uint256[](4); r[0] = p1; r[1] = p2; r[2] = p3; r[3] = p4; } function authParams(address p1, address p2, uint256 p3, uint256 p4) internal pure returns (uint256[] memory r) { r = new uint256[](4); r[0] = uint256(uint160(p1)); r[1] = uint256(uint160(p2)); r[2] = p3; r[3] = p4; } function authParams(address p1, uint256 p2, address p3, uint256 p4) internal pure returns (uint256[] memory r) { r = new uint256[](4); r[0] = uint256(uint160(p1)); r[1] = p2; r[2] = uint256(uint160(p3)); r[3] = p4; } function authParams(address p1, uint256 p2, uint256 p3, uint256 p4) internal pure returns (uint256[] memory r) { r = new uint256[](4); r[0] = uint256(uint160(p1)); r[1] = p2; r[2] = p3; r[3] = p4; } function authParams(bytes32 p1, address p2, uint256 p3, bool p4) internal pure returns (uint256[] memory r) { r = new uint256[](4); r[0] = uint256(p1); r[1] = uint256(uint160(p2)); r[2] = p3; r[3] = p4 ? 1 : 0; } function authParams(address p1, uint256 p2, uint256 p3, uint256 p4, uint256 p5) internal pure returns (uint256[] memory r) { r = new uint256[](5); r[0] = uint256(uint160(p1)); r[1] = p2; r[2] = p3; r[3] = p4; r[4] = p5; } function authParams(address p1, bytes32 p2) internal pure returns (uint256[] memory r) { r = new uint256[](2); r[0] = uint256(uint160(p1)); r[1] = uint256(p2); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; /** * @dev Authorized interface */ interface IAuthorized { /** * @dev Sender `who` is not allowed to call `what` with `how` */ error AuthSenderNotAllowed(address who, bytes4 what, uint256[] how); /** * @dev Tells the address of the authorizer reference */ function authorizer() external view returns (address); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; /** * @dev Authorizer interface */ interface IAuthorizer { /** * @dev Permission change * @param where Address of the contract to change a permission for * @param changes List of permission changes to be executed */ struct PermissionChange { address where; GrantPermission[] grants; RevokePermission[] revokes; } /** * @dev Grant permission data * @param who Address to be authorized * @param what Function selector to be authorized * @param params List of params to restrict the given permission */ struct GrantPermission { address who; bytes4 what; Param[] params; } /** * @dev Revoke permission data * @param who Address to be unauthorized * @param what Function selector to be unauthorized */ struct RevokePermission { address who; bytes4 what; } /** * @dev Params used to validate permissions params against * @param op ID of the operation to compute in order to validate a permission param * @param value Comparison value */ struct Param { uint8 op; uint248 value; } /** * @dev Sender is not authorized to call `what` on `where` with `how` */ error AuthorizerSenderNotAllowed(address who, address where, bytes4 what, uint256[] how); /** * @dev The operation param is invalid */ error AuthorizerInvalidParamOp(uint8 op); /** * @dev Emitted every time `who`'s permission to perform `what` on `where` is granted with `params` */ event Authorized(address indexed who, address indexed where, bytes4 indexed what, Param[] params); /** * @dev Emitted every time `who`'s permission to perform `what` on `where` is revoked */ event Unauthorized(address indexed who, address indexed where, bytes4 indexed what); /** * @dev Tells whether `who` has any permission on `where` * @param who Address asking permission for * @param where Target address asking permission for */ function hasPermissions(address who, address where) external view returns (bool); /** * @dev Tells the number of permissions `who` has on `where` * @param who Address asking permission for * @param where Target address asking permission for */ function getPermissionsLength(address who, address where) external view returns (uint256); /** * @dev Tells whether `who` has permission to call `what` on `where`. Note `how` is not evaluated here, * which means `who` might be authorized on or not depending on the call at the moment of the execution * @param who Address asking permission for * @param where Target address asking permission for * @param what Function selector asking permission for */ function hasPermission(address who, address where, bytes4 what) external view returns (bool); /** * @dev Tells whether `who` is allowed to call `what` on `where` with `how` * @param who Address asking permission for * @param where Target address asking permission for * @param what Function selector asking permission for * @param how Params asking permission for */ function isAuthorized(address who, address where, bytes4 what, uint256[] memory how) external view returns (bool); /** * @dev Tells the params set for a given permission * @param who Address asking permission params of * @param where Target address asking permission params of * @param what Function selector asking permission params of */ function getPermissionParams(address who, address where, bytes4 what) external view returns (Param[] memory); /** * @dev Executes a list of permission changes * @param changes List of permission changes to be executed */ function changePermissions(PermissionChange[] memory changes) external; /** * @dev Authorizes `who` to call `what` on `where` restricted by `params` * @param who Address to be authorized * @param where Target address to be granted for * @param what Function selector to be granted * @param params Optional params to restrict a permission attempt */ function authorize(address who, address where, bytes4 what, Param[] memory params) external; /** * @dev Unauthorizes `who` to call `what` on `where`. Sender must be authorized. * @param who Address to be authorized * @param where Target address to be revoked for * @param what Function selector to be revoked */ function unauthorize(address who, address where, bytes4 what) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; /** * @title KyberSwap V2 connector interface */ interface IKyberSwapV2Connector { /** * @dev The token in is the same as the token out */ error KyberSwapV2SwapSameToken(address token); /** * @dev The amount out is lower than the minimum amount out */ error KyberSwapV2BadAmountOut(uint256 amountOut, uint256 minAmountOut); /** * @dev The post token in balance is lower than the previous token in balance minus the amount in */ error KyberSwapV2BadPostTokenInBalance(uint256 postBalanceIn, uint256 preBalanceIn, uint256 amountIn); /** * @dev Tells the reference to KyberSwap aggregation router v2 */ function kyberSwapV2Router() external view returns (address); /** * @dev Executes a token swap in KyberSwap V2 * @param tokenIn Token to be sent * @param tokenOut Token to be received * @param amountIn Amount of token in to be swapped * @param minAmountOut Minimum amount of token out willing to receive * @param data Calldata to be sent to the KyberSwap aggregation router */ function execute(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes memory data) external returns (uint256 amountOut); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; /** * @title FixedPoint * @dev Math library to operate with fixed point values with 18 decimals */ library FixedPoint { // 1 in fixed point value: 18 decimal places uint256 internal constant ONE = 1e18; /** * @dev Multiplication overflow */ error FixedPointMulOverflow(uint256 a, uint256 b); /** * @dev Division by zero */ error FixedPointZeroDivision(); /** * @dev Division internal error */ error FixedPointDivInternal(uint256 a, uint256 aInflated); /** * @dev Multiplies two fixed point numbers rounding down */ function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { uint256 product = a * b; if (a != 0 && product / a != b) revert FixedPointMulOverflow(a, b); return product / ONE; } } /** * @dev Multiplies two fixed point numbers rounding up */ function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { uint256 product = a * b; if (a != 0 && product / a != b) revert FixedPointMulOverflow(a, b); return product == 0 ? 0 : (((product - 1) / ONE) + 1); } } /** * @dev Divides two fixed point numbers rounding down */ function divDown(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { if (b == 0) revert FixedPointZeroDivision(); if (a == 0) return 0; uint256 aInflated = a * ONE; if (aInflated / a != ONE) revert FixedPointDivInternal(a, aInflated); return aInflated / b; } } /** * @dev Divides two fixed point numbers rounding up */ function divUp(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { if (b == 0) revert FixedPointZeroDivision(); if (a == 0) return 0; uint256 aInflated = a * ONE; if (aInflated / a != ONE) revert FixedPointDivInternal(a, aInflated); return ((aInflated - 1) / b) + 1; } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; /** * @title BytesHelpers * @dev Provides a list of Bytes helper methods */ library BytesHelpers { /** * @dev The length is shorter than start plus 32 */ error BytesOutOfBounds(uint256 start, uint256 length); /** * @dev Concatenates an address to a bytes array */ function concat(bytes memory self, address value) internal pure returns (bytes memory) { return abi.encodePacked(self, value); } /** * @dev Concatenates an uint24 to a bytes array */ function concat(bytes memory self, uint24 value) internal pure returns (bytes memory) { return abi.encodePacked(self, value); } /** * @dev Decodes a bytes array into an uint256 */ function toUint256(bytes memory self) internal pure returns (uint256) { return toUint256(self, 0); } /** * @dev Reads an uint256 from a bytes array starting at a given position */ function toUint256(bytes memory self, uint256 start) internal pure returns (uint256 result) { if (self.length < start + 32) revert BytesOutOfBounds(start, self.length); assembly { result := mload(add(add(self, 0x20), start)) } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; /** * @title Denominations * @dev Provides a list of ground denominations for those tokens that cannot be represented by an ERC20. * For now, the only needed is the native token that could be ETH, MATIC, or other depending on the layer being operated. */ library Denominations { address internal constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // Fiat currencies follow https://en.wikipedia.org/wiki/ISO_4217 address internal constant USD = address(840); function isNativeToken(address token) internal pure returns (bool) { return token == NATIVE_TOKEN; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import '@mimic-fi/v3-authorizer/contracts/interfaces/IAuthorized.sol'; /** * @title IPriceOracle * @dev Price oracle interface * * Tells the price of a token (base) in a given quote based the following rule: the response is expressed using the * corresponding number of decimals so that when performing a fixed point product of it by a `base` amount it results * in a value expressed in `quote` decimals. For example, if `base` is ETH and `quote` is USDC, then the returned * value is expected to be expressed using 6 decimals: * * FixedPoint.mul(X[ETH], price[USDC/ETH]) = FixedPoint.mul(X[18], price[6]) = X * price [6] */ interface IPriceOracle is IAuthorized { /** * @dev Price data * @param base Token to rate * @param quote Token used for the price rate * @param rate Price of a token (base) expressed in `quote` * @param deadline Expiration timestamp until when the given quote is considered valid */ struct PriceData { address base; address quote; uint256 rate; uint256 deadline; } /** * @dev The signer is not allowed */ error PriceOracleInvalidSigner(address signer); /** * @dev The feed for the given (base, quote) pair doesn't exist */ error PriceOracleMissingFeed(address base, address quote); /** * @dev The price deadline is in the past */ error PriceOracleOutdatedPrice(address base, address quote, uint256 deadline, uint256 currentTimestamp); /** * @dev The base decimals are bigger than the quote decimals plus the fixed point decimals */ error PriceOracleBaseDecimalsTooBig(address base, uint256 baseDecimals, address quote, uint256 quoteDecimals); /** * @dev The inverse feed decimals are bigger than the maximum inverse feed decimals */ error PriceOracleInverseFeedDecimalsTooBig(address inverseFeed, uint256 inverseFeedDecimals); /** * @dev The quote feed decimals are bigger than the base feed decimals plus the fixed point decimals */ error PriceOracleQuoteFeedDecimalsTooBig(uint256 quoteFeedDecimals, uint256 baseFeedDecimals); /** * @dev Emitted every time a signer is changed */ event SignerSet(address indexed signer, bool allowed); /** * @dev Emitted every time a feed is set for (base, quote) pair */ event FeedSet(address indexed base, address indexed quote, address feed); /** * @dev Tells whether an address is as an allowed signer or not * @param signer Address of the signer being queried */ function isSignerAllowed(address signer) external view returns (bool); /** * @dev Tells the list of allowed signers */ function getAllowedSigners() external view returns (address[] memory); /** * @dev Tells the digest expected to be signed by the off-chain oracle signers for a list of prices * @param prices List of prices to be signed */ function getPricesDigest(PriceData[] memory prices) external view returns (bytes32); /** * @dev Tells the price of a token `base` expressed in a token `quote` * @param base Token to rate * @param quote Token used for the price rate */ function getPrice(address base, address quote) external view returns (uint256); /** * @dev Tells the price of a token `base` expressed in a token `quote` * @param base Token to rate * @param quote Token used for the price rate * @param data Encoded data to validate in order to compute the requested rate */ function getPrice(address base, address quote, bytes memory data) external view returns (uint256); /** * @dev Tells the feed address for (base, quote) pair. It returns the zero address if there is no one set. * @param base Token to be rated * @param quote Token used for the price rate */ function getFeed(address base, address quote) external view returns (address); /** * @dev Sets a signer condition * @param signer Address of the signer to be set * @param allowed Whether the requested signer is allowed */ function setSigner(address signer, bool allowed) external; /** * @dev Sets a feed for a (base, quote) pair * @param base Token base to be set * @param quote Token quote to be set * @param feed Feed to be set */ function setFeed(address base, address quote, address feed) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import '@mimic-fi/v3-authorizer/contracts/interfaces/IAuthorized.sol'; /** * @dev Smart Vault interface */ interface ISmartVault is IAuthorized { /** * @dev The smart vault is paused */ error SmartVaultPaused(); /** * @dev The smart vault is unpaused */ error SmartVaultUnpaused(); /** * @dev The token is zero */ error SmartVaultTokenZero(); /** * @dev The amount is zero */ error SmartVaultAmountZero(); /** * @dev The recipient is zero */ error SmartVaultRecipientZero(); /** * @dev The connector is deprecated */ error SmartVaultConnectorDeprecated(address connector); /** * @dev The connector is not registered */ error SmartVaultConnectorNotRegistered(address connector); /** * @dev The connector is not stateless */ error SmartVaultConnectorNotStateless(address connector); /** * @dev The connector ID is zero */ error SmartVaultBalanceConnectorIdZero(); /** * @dev The balance connector's balance is lower than the requested amount to be deducted */ error SmartVaultBalanceConnectorInsufficientBalance(bytes32 id, address token, uint256 balance, uint256 amount); /** * @dev The smart vault's native token balance is lower than the requested amount to be deducted */ error SmartVaultInsufficientNativeTokenBalance(uint256 balance, uint256 amount); /** * @dev Emitted every time a smart vault is paused */ event Paused(); /** * @dev Emitted every time a smart vault is unpaused */ event Unpaused(); /** * @dev Emitted every time the price oracle is set */ event PriceOracleSet(address indexed priceOracle); /** * @dev Emitted every time a connector check is overridden */ event ConnectorCheckOverridden(address indexed connector, bool ignored); /** * @dev Emitted every time a balance connector is updated */ event BalanceConnectorUpdated(bytes32 indexed id, address indexed token, uint256 amount, bool added); /** * @dev Emitted every time `execute` is called */ event Executed(address indexed connector, bytes data, bytes result); /** * @dev Emitted every time `call` is called */ event Called(address indexed target, bytes data, uint256 value, bytes result); /** * @dev Emitted every time `wrap` is called */ event Wrapped(uint256 amount); /** * @dev Emitted every time `unwrap` is called */ event Unwrapped(uint256 amount); /** * @dev Emitted every time `collect` is called */ event Collected(address indexed token, address indexed from, uint256 amount); /** * @dev Emitted every time `withdraw` is called */ event Withdrawn(address indexed token, address indexed recipient, uint256 amount, uint256 fee); /** * @dev Tells if the smart vault is paused or not */ function isPaused() external view returns (bool); /** * @dev Tells the address of the price oracle */ function priceOracle() external view returns (address); /** * @dev Tells the address of the Mimic's registry */ function registry() external view returns (address); /** * @dev Tells the address of the Mimic's fee controller */ function feeController() external view returns (address); /** * @dev Tells the address of the wrapped native token */ function wrappedNativeToken() external view returns (address); /** * @dev Tells if a connector check is ignored * @param connector Address of the connector being queried */ function isConnectorCheckIgnored(address connector) external view returns (bool); /** * @dev Tells the balance to a balance connector for a token * @param id Balance connector identifier * @param token Address of the token querying the balance connector for */ function getBalanceConnector(bytes32 id, address token) external view returns (uint256); /** * @dev Tells whether someone has any permission over the smart vault */ function hasPermissions(address who) external view returns (bool); /** * @dev Pauses a smart vault */ function pause() external; /** * @dev Unpauses a smart vault */ function unpause() external; /** * @dev Sets the price oracle * @param newPriceOracle Address of the new price oracle to be set */ function setPriceOracle(address newPriceOracle) external; /** * @dev Overrides connector checks * @param connector Address of the connector to override its check * @param ignored Whether the connector check should be ignored */ function overrideConnectorCheck(address connector, bool ignored) external; /** * @dev Updates a balance connector * @param id Balance connector identifier to be updated * @param token Address of the token to update the balance connector for * @param amount Amount to be updated to the balance connector * @param add Whether the balance connector should be increased or decreased */ function updateBalanceConnector(bytes32 id, address token, uint256 amount, bool add) external; /** * @dev Executes a connector inside of the Smart Vault context * @param connector Address of the connector that will be executed * @param data Call data to be used for the delegate-call * @return result Call response if it was successful, otherwise it reverts */ function execute(address connector, bytes memory data) external returns (bytes memory result); /** * @dev Executes an arbitrary call from the Smart Vault * @param target Address where the call will be sent * @param data Call data to be used for the call * @param value Value in wei that will be attached to the call * @return result Call response if it was successful, otherwise it reverts */ function call(address target, bytes memory data, uint256 value) external returns (bytes memory result); /** * @dev Wrap an amount of native tokens to the wrapped ERC20 version of it * @param amount Amount of native tokens to be wrapped */ function wrap(uint256 amount) external; /** * @dev Unwrap an amount of wrapped native tokens * @param amount Amount of wrapped native tokens to unwrapped */ function unwrap(uint256 amount) external; /** * @dev Collect tokens from an external account to the Smart Vault * @param token Address of the token to be collected * @param from Address where the tokens will be transferred from * @param amount Amount of tokens to be transferred */ function collect(address token, address from, uint256 amount) external; /** * @dev Withdraw tokens to an external account * @param token Address of the token to be withdrawn * @param recipient Address where the tokens will be transferred to * @param amount Amount of tokens to withdraw */ function withdraw(address token, address recipient, uint256 amount) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// 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 AddressUpgradeable { /** * @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.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // ---------------------------------------------------------------------------- // DateTime Library v2.0 // // A gas-efficient Solidity date and time library // // https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary // // Tested date range 1970/01/01 to 2345/12/31 // // Conventions: // Unit | Range | Notes // :-------- |:-------------:|:----- // timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC // year | 1970 ... 2345 | // month | 1 ... 12 | // day | 1 ... 31 | // hour | 0 ... 23 | // minute | 0 ... 59 | // second | 0 ... 59 | // dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday // // // Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence. // ---------------------------------------------------------------------------- library DateTime { uint256 constant SECONDS_PER_DAY = 24 * 60 * 60; uint256 constant SECONDS_PER_HOUR = 60 * 60; uint256 constant SECONDS_PER_MINUTE = 60; int256 constant OFFSET19700101 = 2440588; uint256 constant DOW_MON = 1; uint256 constant DOW_TUE = 2; uint256 constant DOW_WED = 3; uint256 constant DOW_THU = 4; uint256 constant DOW_FRI = 5; uint256 constant DOW_SAT = 6; uint256 constant DOW_SUN = 7; // ------------------------------------------------------------------------ // Calculate the number of days from 1970/01/01 to year/month/day using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and subtracting the offset 2440588 so that 1970/01/01 is day 0 // // days = day // - 32075 // + 1461 * (year + 4800 + (month - 14) / 12) / 4 // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12 // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4 // - offset // ------------------------------------------------------------------------ function _daysFromDate(uint256 year, uint256 month, uint256 day) internal pure returns (uint256 _days) { require(year >= 1970); int256 _year = int256(year); int256 _month = int256(month); int256 _day = int256(day); int256 __days = _day - 32075 + (1461 * (_year + 4800 + (_month - 14) / 12)) / 4 + (367 * (_month - 2 - ((_month - 14) / 12) * 12)) / 12 - (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) / 4 - OFFSET19700101; _days = uint256(__days); } // ------------------------------------------------------------------------ // Calculate year/month/day from the number of days since 1970/01/01 using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and adding the offset 2440588 so that 1970/01/01 is day 0 // // int L = days + 68569 + offset // int N = 4 * L / 146097 // L = L - (146097 * N + 3) / 4 // year = 4000 * (L + 1) / 1461001 // L = L - 1461 * year / 4 + 31 // month = 80 * L / 2447 // dd = L - 2447 * month / 80 // L = month / 11 // month = month + 2 - 12 * L // year = 100 * (N - 49) + year + L // ------------------------------------------------------------------------ function _daysToDate(uint256 _days) internal pure returns (uint256 year, uint256 month, uint256 day) { unchecked { int256 __days = int256(_days); int256 L = __days + 68569 + OFFSET19700101; int256 N = (4 * L) / 146097; L = L - (146097 * N + 3) / 4; int256 _year = (4000 * (L + 1)) / 1461001; L = L - (1461 * _year) / 4 + 31; int256 _month = (80 * L) / 2447; int256 _day = L - (2447 * _month) / 80; L = _month / 11; _month = _month + 2 - 12 * L; _year = 100 * (N - 49) + _year + L; year = uint256(_year); month = uint256(_month); day = uint256(_day); } } function timestampFromDate(uint256 year, uint256 month, uint256 day) internal pure returns (uint256 timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY; } function timestampFromDateTime( uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, uint256 second ) internal pure returns (uint256 timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second; } function timestampToDate(uint256 timestamp) internal pure returns (uint256 year, uint256 month, uint256 day) { unchecked { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } } function timestampToDateTime(uint256 timestamp) internal pure returns (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, uint256 second) { unchecked { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint256 secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; secs = secs % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; second = secs % SECONDS_PER_MINUTE; } } function isValidDate(uint256 year, uint256 month, uint256 day) internal pure returns (bool valid) { if (year >= 1970 && month > 0 && month <= 12) { uint256 daysInMonth = _getDaysInMonth(year, month); if (day > 0 && day <= daysInMonth) { valid = true; } } } function isValidDateTime(uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, uint256 second) internal pure returns (bool valid) { if (isValidDate(year, month, day)) { if (hour < 24 && minute < 60 && second < 60) { valid = true; } } } function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) { (uint256 year,,) = _daysToDate(timestamp / SECONDS_PER_DAY); leapYear = _isLeapYear(year); } function _isLeapYear(uint256 year) internal pure returns (bool leapYear) { leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); } function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) { weekDay = getDayOfWeek(timestamp) <= DOW_FRI; } function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) { weekEnd = getDayOfWeek(timestamp) >= DOW_SAT; } function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) { (uint256 year, uint256 month,) = _daysToDate(timestamp / SECONDS_PER_DAY); daysInMonth = _getDaysInMonth(year, month); } function _getDaysInMonth(uint256 year, uint256 month) internal pure returns (uint256 daysInMonth) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { daysInMonth = 31; } else if (month != 2) { daysInMonth = 30; } else { daysInMonth = _isLeapYear(year) ? 29 : 28; } } // 1 = Monday, 7 = Sunday function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) { uint256 _days = timestamp / SECONDS_PER_DAY; dayOfWeek = ((_days + 3) % 7) + 1; } function getYear(uint256 timestamp) internal pure returns (uint256 year) { (year,,) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getMonth(uint256 timestamp) internal pure returns (uint256 month) { (, month,) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getDay(uint256 timestamp) internal pure returns (uint256 day) { (,, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getHour(uint256 timestamp) internal pure returns (uint256 hour) { uint256 secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; } function getMinute(uint256 timestamp) internal pure returns (uint256 minute) { uint256 secs = timestamp % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; } function getSecond(uint256 timestamp) internal pure returns (uint256 second) { second = timestamp % SECONDS_PER_MINUTE; } function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) { (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY); year += _years; uint256 daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp >= timestamp); } function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) { (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY); month += _months; year += (month - 1) / 12; month = ((month - 1) % 12) + 1; uint256 daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp >= timestamp); } function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp + _days * SECONDS_PER_DAY; require(newTimestamp >= timestamp); } function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp + _hours * SECONDS_PER_HOUR; require(newTimestamp >= timestamp); } function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE; require(newTimestamp >= timestamp); } function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp + _seconds; require(newTimestamp >= timestamp); } function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) { (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY); year -= _years; uint256 daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp <= timestamp); } function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) { (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint256 yearMonth = year * 12 + (month - 1) - _months; year = yearMonth / 12; month = (yearMonth % 12) + 1; uint256 daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp <= timestamp); } function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp - _days * SECONDS_PER_DAY; require(newTimestamp <= timestamp); } function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp - _hours * SECONDS_PER_HOUR; require(newTimestamp <= timestamp); } function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE; require(newTimestamp <= timestamp); } function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) { newTimestamp = timestamp - _seconds; require(newTimestamp <= timestamp); } function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) { require(fromTimestamp <= toTimestamp); (uint256 fromYear,,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY); (uint256 toYear,,) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _years = toYear - fromYear; } function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) { require(fromTimestamp <= toTimestamp); (uint256 fromYear, uint256 fromMonth,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY); (uint256 toYear, uint256 toMonth,) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth; } function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) { require(fromTimestamp <= toTimestamp); _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY; } function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) { require(fromTimestamp <= toTimestamp); _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR; } function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) { require(fromTimestamp <= toTimestamp); _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE; } function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) { require(fromTimestamp <= toTimestamp); _seconds = toTimestamp - fromTimestamp; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v3-helpers/contracts/utils/Denominations.sol'; import '@mimic-fi/v3-price-oracle/contracts/interfaces/IPriceOracle.sol'; import '@mimic-fi/v3-smart-vault/contracts/interfaces/ISmartVault.sol'; import '../interfaces/base/IBaseTask.sol'; /** * @title BaseTask * @dev Base task implementation with a Smart Vault reference and using the Authorizer */ abstract contract BaseTask is IBaseTask, Authorized { // Smart Vault reference address public override smartVault; // Optional balance connector id for the previous task in the workflow bytes32 internal previousBalanceConnectorId; // Optional balance connector id for the next task in the workflow bytes32 internal nextBalanceConnectorId; /** * @dev Base task config. Only used in the initializer. * @param smartVault Address of the smart vault this task will reference, it cannot be changed once set * @param previousBalanceConnectorId Balance connector id for the previous task in the workflow * @param nextBalanceConnectorId Balance connector id for the next task in the workflow */ struct BaseConfig { address smartVault; bytes32 previousBalanceConnectorId; bytes32 nextBalanceConnectorId; } /** * @dev Initializes the base task. It does call upper contracts initializers. * @param config Base task config */ function __BaseTask_init(BaseConfig memory config) internal onlyInitializing { __Authorized_init(ISmartVault(config.smartVault).authorizer()); __BaseTask_init_unchained(config); } /** * @dev Initializes the base task. It does not call upper contracts initializers. * @param config Base task config */ function __BaseTask_init_unchained(BaseConfig memory config) internal onlyInitializing { smartVault = config.smartVault; _setBalanceConnectors(config.previousBalanceConnectorId, config.nextBalanceConnectorId); } /** * @dev Tells the address from where the token amounts to execute this task are fetched. * Since by default tasks are supposed to use balance connectors, the tokens source has to be the smart vault. * In case a task does not need to rely on a previous balance connector, it must override this function to specify * where it is getting its tokens from. */ function getTokensSource() external view virtual override returns (address) { return smartVault; } /** * @dev Tells the amount a task should use for a token. By default tasks are expected to use balance connectors. * In case a task relies on an external tokens source, it must override how the task amount is calculated. * @param token Address of the token being queried */ function getTaskAmount(address token) public view virtual override returns (uint256) { return ISmartVault(smartVault).getBalanceConnector(previousBalanceConnectorId, token); } /** * @dev Tells the previous and next balance connectors id of the previous task in the workflow */ function getBalanceConnectors() external view returns (bytes32 previous, bytes32 next) { previous = previousBalanceConnectorId; next = nextBalanceConnectorId; } /** * @dev Sets the balance connectors * @param previous Balance connector id of the previous task in the workflow * @param next Balance connector id of the next task in the workflow */ function setBalanceConnectors(bytes32 previous, bytes32 next) external override authP(authParams(previous, next)) { _setBalanceConnectors(previous, next); } /** * @dev Tells the wrapped native token address if the given address is the native token * @param token Address of the token to be checked */ function _wrappedIfNative(address token) internal view returns (address) { return Denominations.isNativeToken(token) ? _wrappedNativeToken() : token; } /** * @dev Tells whether a token is the native or the wrapped native token * @param token Address of the token to be checked */ function _isWrappedOrNative(address token) internal view returns (bool) { return Denominations.isNativeToken(token) || token == _wrappedNativeToken(); } /** * @dev Tells the wrapped native token address */ function _wrappedNativeToken() internal view returns (address) { return ISmartVault(smartVault).wrappedNativeToken(); } /** * @dev Fetches a base/quote price from the smart vault's price oracle * @param base Token to rate * @param quote Token used for the price rate */ function _getPrice(address base, address quote) internal view virtual returns (uint256) { address priceOracle = ISmartVault(smartVault).priceOracle(); if (priceOracle == address(0)) revert TaskSmartVaultPriceOracleNotSet(smartVault); bytes memory extraCallData = _decodeExtraCallData(); return extraCallData.length == 0 ? IPriceOracle(priceOracle).getPrice(_wrappedIfNative(base), _wrappedIfNative(quote)) : IPriceOracle(priceOracle).getPrice(_wrappedIfNative(base), _wrappedIfNative(quote), extraCallData); } /** * @dev Before base task hook */ function _beforeBaseTask(address token, uint256 amount) internal virtual { _decreaseBalanceConnector(token, amount); } /** * @dev After base task hook */ function _afterBaseTask(address, uint256) internal virtual { emit Executed(); } /** * @dev Decreases the previous balance connector in the smart vault if defined * @param token Address of the token to update the previous balance connector of * @param amount Amount to be updated */ function _decreaseBalanceConnector(address token, uint256 amount) internal { if (previousBalanceConnectorId != bytes32(0)) { ISmartVault(smartVault).updateBalanceConnector(previousBalanceConnectorId, token, amount, false); } } /** * @dev Increases the next balance connector in the smart vault if defined * @param token Address of the token to update the next balance connector of * @param amount Amount to be updated */ function _increaseBalanceConnector(address token, uint256 amount) internal { if (nextBalanceConnectorId != bytes32(0)) { ISmartVault(smartVault).updateBalanceConnector(nextBalanceConnectorId, token, amount, true); } } /** * @dev Sets the balance connectors * @param previous Balance connector id of the previous task in the workflow * @param next Balance connector id of the next task in the workflow */ function _setBalanceConnectors(bytes32 previous, bytes32 next) internal virtual { if (previous == next && previous != bytes32(0)) revert TaskSameBalanceConnectors(previous); previousBalanceConnectorId = previous; nextBalanceConnectorId = next; emit BalanceConnectorsSet(previous, next); } /** * @dev Decodes any potential extra calldata stored in the calldata space. Tasks relying on the extra calldata * pattern, assume that the last word of the calldata stores the extra calldata length so it can be decoded. Note * that tasks relying on this pattern must contemplate this function may return bogus data if no extra calldata * was given. */ function _decodeExtraCallData() private pure returns (bytes memory data) { uint256 length = uint256(_decodeLastCallDataWord()); if (msg.data.length < length) return new bytes(0); data = new bytes(length); assembly { calldatacopy(add(data, 0x20), sub(sub(calldatasize(), length), 0x20), length) } } /** * @dev Returns the last calldata word. This function returns zero if the calldata is not long enough. */ function _decodeLastCallDataWord() private pure returns (bytes32 result) { if (msg.data.length < 36) return bytes32(0); assembly { result := calldataload(sub(calldatasize(), 0x20)) } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.17; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v3-smart-vault/contracts/interfaces/ISmartVault.sol'; import '../interfaces/base/IGasLimitedTask.sol'; /** * @dev Gas config for tasks. It allows setting different gas-related configs, specially useful to control relayed txs. */ abstract contract GasLimitedTask is IGasLimitedTask, Authorized { using FixedPoint for uint256; // Variable used to allow a better developer experience to reimburse tx gas cost // solhint-disable-next-line var-name-mixedcase uint256 private __initialGas__; // Gas limits config GasLimitConfig internal gasLimits; /** * @dev Gas limits config * @param gasPriceLimit Gas price limit expressed in the native token * @param priorityFeeLimit Priority fee limit expressed in the native token * @param txCostLimit Transaction cost limit to be set * @param txCostLimitPct Transaction cost limit percentage to be set */ struct GasLimitConfig { uint256 gasPriceLimit; uint256 priorityFeeLimit; uint256 txCostLimit; uint256 txCostLimitPct; } /** * @dev Initializes the gas limited task. It does call upper contracts initializers. * @param config Gas limited task config */ function __GasLimitedTask_init(GasLimitConfig memory config) internal onlyInitializing { __GasLimitedTask_init_unchained(config); } /** * @dev Initializes the gas limited task. It does not call upper contracts initializers. * @param config Gas limited task config */ function __GasLimitedTask_init_unchained(GasLimitConfig memory config) internal onlyInitializing { _setGasLimits(config.gasPriceLimit, config.priorityFeeLimit, config.txCostLimit, config.txCostLimitPct); } /** * @dev Tells the gas limits config */ function getGasLimits() external view returns (uint256 gasPriceLimit, uint256 priorityFeeLimit, uint256 txCostLimit, uint256 txCostLimitPct) { return (gasLimits.gasPriceLimit, gasLimits.priorityFeeLimit, gasLimits.txCostLimit, gasLimits.txCostLimitPct); } /** * @dev Sets the gas limits config * @param newGasPriceLimit New gas price limit to be set * @param newPriorityFeeLimit New priority fee limit to be set * @param newTxCostLimit New tx cost limit to be set * @param newTxCostLimitPct New tx cost percentage limit to be set */ function setGasLimits( uint256 newGasPriceLimit, uint256 newPriorityFeeLimit, uint256 newTxCostLimit, uint256 newTxCostLimitPct ) external override authP(authParams(newGasPriceLimit, newPriorityFeeLimit, newTxCostLimit, newTxCostLimitPct)) { _setGasLimits(newGasPriceLimit, newPriorityFeeLimit, newTxCostLimit, newTxCostLimitPct); } /** * @dev Fetches a base/quote price */ function _getPrice(address base, address quote) internal view virtual returns (uint256); /** * @dev Initializes gas limited tasks and validates gas price limit */ function _beforeGasLimitedTask(address, uint256) internal virtual { __initialGas__ = gasleft(); GasLimitConfig memory config = gasLimits; bool isGasPriceAllowed = config.gasPriceLimit == 0 || tx.gasprice <= config.gasPriceLimit; if (!isGasPriceAllowed) revert TaskGasPriceLimitExceeded(tx.gasprice, config.gasPriceLimit); if (config.priorityFeeLimit > 0) { uint256 priorityFee = tx.gasprice - block.basefee; bool isPriorityFeeAllowed = priorityFee <= config.priorityFeeLimit; if (!isPriorityFeeAllowed) revert TaskPriorityFeeLimitExceeded(priorityFee, config.priorityFeeLimit); } } /** * @dev Validates transaction cost limit */ function _afterGasLimitedTask(address token, uint256 amount) internal virtual { if (__initialGas__ == 0) revert TaskGasNotInitialized(); GasLimitConfig memory config = gasLimits; uint256 totalGas = __initialGas__ - gasleft(); uint256 totalCost = totalGas * tx.gasprice; bool isTxCostAllowed = config.txCostLimit == 0 || totalCost <= config.txCostLimit; if (!isTxCostAllowed) revert TaskTxCostLimitExceeded(totalCost, config.txCostLimit); delete __initialGas__; if (config.txCostLimitPct > 0 && amount > 0) { uint256 price = _getPrice(ISmartVault(this.smartVault()).wrappedNativeToken(), token); uint256 totalCostInToken = totalCost.mulUp(price); uint256 txCostPct = totalCostInToken.divUp(amount); if (txCostPct > config.txCostLimitPct) revert TaskTxCostLimitPctExceeded(txCostPct, config.txCostLimitPct); } } /** * @dev Sets the gas limits config * @param newGasPriceLimit New gas price limit to be set * @param newPriorityFeeLimit New priority fee limit to be set * @param newTxCostLimit New tx cost limit to be set * @param newTxCostLimitPct New tx cost percentage limit to be set */ function _setGasLimits( uint256 newGasPriceLimit, uint256 newPriorityFeeLimit, uint256 newTxCostLimit, uint256 newTxCostLimitPct ) internal { if (newTxCostLimitPct > FixedPoint.ONE) revert TaskTxCostLimitPctAboveOne(); gasLimits.gasPriceLimit = newGasPriceLimit; gasLimits.priorityFeeLimit = newPriorityFeeLimit; gasLimits.txCostLimit = newTxCostLimit; gasLimits.txCostLimitPct = newTxCostLimitPct; emit GasLimitsSet(newGasPriceLimit, newPriorityFeeLimit, newTxCostLimit, newTxCostLimitPct); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.17; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '../interfaces/base/IPausableTask.sol'; /** * @dev Pausable config for tasks */ abstract contract PausableTask is IPausableTask, Authorized { using FixedPoint for uint256; // Whether the task is paused or not bool public override isPaused; /** * @dev Initializes the pausable task. It does call upper contracts initializers. */ function __PausableTask_init() internal onlyInitializing { __PausableTask_init_unchained(); } /** * @dev Initializes the pausable task. It does not call upper contracts initializers. */ function __PausableTask_init_unchained() internal onlyInitializing { // solhint-disable-previous-line no-empty-blocks } /** * @dev Pauses a task */ function pause() external override auth { if (isPaused) revert TaskPaused(); isPaused = true; emit Paused(); } /** * @dev Unpauses a task */ function unpause() external override auth { if (!isPaused) revert TaskUnpaused(); isPaused = false; emit Unpaused(); } /** * @dev Before pausable task hook */ function _beforePausableTask(address, uint256) internal virtual { if (isPaused) revert TaskPaused(); } /** * @dev After pausable task hook */ function _afterPausableTask(address, uint256) internal virtual { // solhint-disable-previous-line no-empty-blocks } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.3; import '@quant-finance/solidity-datetime/contracts/DateTime.sol'; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '../interfaces/base/ITimeLockedTask.sol'; /** * @dev Time lock config for tasks. It allows limiting the frequency of a task. */ abstract contract TimeLockedTask is ITimeLockedTask, Authorized { using DateTime for uint256; uint256 private constant DAYS_28 = 60 * 60 * 24 * 28; /** * @dev Time-locks supports different frequency modes * @param Seconds To indicate the execution must occur every certain number of seconds * @param OnDay To indicate the execution must occur on day number from 1 to 28 every certain months * @param OnLastMonthDay To indicate the execution must occur on the last day of the month every certain months */ enum Mode { Seconds, OnDay, OnLastMonthDay } // Time lock mode Mode internal _mode; // Time lock frequency uint256 internal _frequency; // Future timestamp since when the task can be executed uint256 internal _allowedAt; // Next future timestamp since when the task can be executed to be set, only used internally uint256 internal _nextAllowedAt; // Period in seconds during when a time-locked task can be executed since the allowed timestamp uint256 internal _window; /** * @dev Time lock config params. Only used in the initializer. * @param mode Time lock mode * @param frequency Time lock frequency value * @param allowedAt Time lock allowed date * @param window Time lock execution window */ struct TimeLockConfig { uint8 mode; uint256 frequency; uint256 allowedAt; uint256 window; } /** * @dev Initializes the time locked task. It does not call upper contracts initializers. * @param config Time locked task config */ function __TimeLockedTask_init(TimeLockConfig memory config) internal onlyInitializing { __TimeLockedTask_init_unchained(config); } /** * @dev Initializes the time locked task. It does call upper contracts initializers. * @param config Time locked task config */ function __TimeLockedTask_init_unchained(TimeLockConfig memory config) internal onlyInitializing { _setTimeLock(config.mode, config.frequency, config.allowedAt, config.window); } /** * @dev Tells the time-lock related information */ function getTimeLock() external view returns (uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window) { return (uint8(_mode), _frequency, _allowedAt, _window); } /** * @dev Sets a new time lock */ function setTimeLock(uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window) external override authP(authParams(mode, frequency, allowedAt, window)) { _setTimeLock(mode, frequency, allowedAt, window); } /** * @dev Before time locked task hook */ function _beforeTimeLockedTask(address, uint256) internal virtual { // Load storage variables Mode mode = _mode; uint256 frequency = _frequency; uint256 allowedAt = _allowedAt; uint256 window = _window; // First we check the current timestamp is not in the past if (block.timestamp < allowedAt) revert TaskTimeLockActive(block.timestamp, allowedAt); if (mode == Mode.Seconds) { if (frequency == 0) return; // If no window is set, the next allowed date is simply moved the number of seconds set as frequency. // Otherwise, the offset must be validated and the next allowed date is set to the next period. if (window == 0) _nextAllowedAt = block.timestamp + frequency; else { uint256 diff = block.timestamp - allowedAt; uint256 periods = diff / frequency; uint256 offset = diff - (periods * frequency); if (offset > window) revert TaskTimeLockActive(block.timestamp, allowedAt); _nextAllowedAt = allowedAt + ((periods + 1) * frequency); } } else { if (block.timestamp >= allowedAt && block.timestamp <= allowedAt + window) { // Check the current timestamp has not passed the allowed date set _nextAllowedAt = _getNextAllowedDate(allowedAt, frequency); } else { // Check the current timestamp is not before the current allowed date uint256 currentAllowedDay = mode == Mode.OnDay ? allowedAt.getDay() : block.timestamp.getDaysInMonth(); uint256 currentAllowedAt = _getCurrentAllowedDate(allowedAt, currentAllowedDay); if (block.timestamp < currentAllowedAt) revert TaskTimeLockActive(block.timestamp, currentAllowedAt); // Check the current timestamp has not passed the allowed execution window uint256 extendedCurrentAllowedAt = currentAllowedAt + window; bool exceedsExecutionWindow = block.timestamp > extendedCurrentAllowedAt; if (exceedsExecutionWindow) revert TaskTimeLockActive(block.timestamp, extendedCurrentAllowedAt); // Finally set the next allowed date to the corresponding number of months from the current date _nextAllowedAt = _getNextAllowedDate(currentAllowedAt, frequency); } } } /** * @dev After time locked task hook */ function _afterTimeLockedTask(address, uint256) internal virtual { if (_nextAllowedAt == 0) return; _setTimeLockAllowedAt(_nextAllowedAt); _nextAllowedAt = 0; } /** * @dev Sets a new time lock */ function _setTimeLock(uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window) internal { if (mode == uint8(Mode.Seconds)) { // The execution window and timestamp are optional, but both must be given or none // If given the execution window cannot be larger than the number of seconds // Also, if these are given the frequency must be checked as well, otherwise it could be unsetting the lock if (window > 0 || allowedAt > 0) { if (frequency == 0) revert TaskInvalidFrequency(mode, frequency); if (window == 0 || window > frequency) revert TaskInvalidAllowedWindow(mode, window); if (allowedAt == 0) revert TaskInvalidAllowedDate(mode, allowedAt); } } else { // The other modes can be "on-day" or "on-last-day" where the frequency represents a number of months // There is no limit for the frequency, it simply cannot be zero if (frequency == 0) revert TaskInvalidFrequency(mode, frequency); // The execution window cannot be larger than the number of months considering months of 28 days if (window == 0 || window > frequency * DAYS_28) revert TaskInvalidAllowedWindow(mode, window); // The allowed date cannot be zero if (allowedAt == 0) revert TaskInvalidAllowedDate(mode, allowedAt); // If the mode is "on-day", the allowed date must be valid for every month, then the allowed day cannot be // larger than 28. But if the mode is "on-last-day", the allowed date day must be the last day of the month if (mode == uint8(Mode.OnDay)) { if (allowedAt.getDay() > 28) revert TaskInvalidAllowedDate(mode, allowedAt); } else if (mode == uint8(Mode.OnLastMonthDay)) { if (allowedAt.getDay() != allowedAt.getDaysInMonth()) revert TaskInvalidAllowedDate(mode, allowedAt); } else { revert TaskInvalidFrequencyMode(mode); } } _mode = Mode(mode); _frequency = frequency; _allowedAt = allowedAt; _window = window; emit TimeLockSet(mode, frequency, allowedAt, window); } /** * @dev Sets the time-lock execution allowed timestamp * @param allowedAt New execution allowed timestamp to be set */ function _setTimeLockAllowedAt(uint256 allowedAt) internal { _allowedAt = allowedAt; emit TimeLockAllowedAtSet(allowedAt); } /** * @dev Tells the corresponding allowed date based on a current timestamp */ function _getCurrentAllowedDate(uint256 allowedAt, uint256 day) private view returns (uint256) { (uint256 year, uint256 month, ) = block.timestamp.timestampToDate(); return _getAllowedDateFor(allowedAt, year, month, day); } /** * @dev Tells the next allowed date based on a current allowed date considering a number of months to increase */ function _getNextAllowedDate(uint256 allowedAt, uint256 monthsToIncrease) private view returns (uint256) { (uint256 year, uint256 month, uint256 day) = allowedAt.timestampToDate(); uint256 increasedMonth = month + monthsToIncrease; uint256 nextMonth = increasedMonth % 12; uint256 nextYear = year + (increasedMonth / 12); uint256 nextDay = _mode == Mode.OnLastMonthDay ? DateTime._getDaysInMonth(nextYear, nextMonth) : day; return _getAllowedDateFor(allowedAt, nextYear, nextMonth, nextDay); } /** * @dev Builds an allowed date using a specific year, month, and day */ function _getAllowedDateFor(uint256 allowedAt, uint256 year, uint256 month, uint256 day) private pure returns (uint256) { return DateTime.timestampFromDateTime( year, month, day, allowedAt.getHour(), allowedAt.getMinute(), allowedAt.getSecond() ); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.3; import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '../interfaces/base/ITokenIndexedTask.sol'; /** * @dev Token indexed task. It defines a token acceptance list to tell which are the tokens supported by the * task. Tokens acceptance can be configured either as an allow list or as a deny list. */ abstract contract TokenIndexedTask is ITokenIndexedTask, Authorized { using EnumerableSet for EnumerableSet.AddressSet; // Acceptance list type TokensAcceptanceType public override tokensAcceptanceType; // Enumerable set of tokens included in the acceptance list EnumerableSet.AddressSet internal _tokens; /** * @dev Token index config. Only used in the initializer. * @param acceptanceType Token acceptance type to be set * @param tokens List of token addresses to be set for the acceptance list */ struct TokenIndexConfig { TokensAcceptanceType acceptanceType; address[] tokens; } /** * @dev Initializes the token indexed task. It does not call upper contracts initializers. * @param config Token indexed task config */ function __TokenIndexedTask_init(TokenIndexConfig memory config) internal onlyInitializing { __TokenIndexedTask_init_unchained(config); } /** * @dev Initializes the token indexed task. It does call upper contracts initializers. * @param config Token indexed task config */ function __TokenIndexedTask_init_unchained(TokenIndexConfig memory config) internal onlyInitializing { _setTokensAcceptanceType(config.acceptanceType); for (uint256 i = 0; i < config.tokens.length; i++) { _setTokenAcceptanceList(config.tokens[i], true); } } /** * @dev Tells whether a token is allowed or not * @param token Address of the token being queried */ function isTokenAllowed(address token) public view override returns (bool) { bool containsToken = _tokens.contains(token); return tokensAcceptanceType == TokensAcceptanceType.AllowList ? containsToken : !containsToken; } /** * @dev Sets the tokens acceptance type of the task * @param newTokensAcceptanceType New token acceptance type to be set */ function setTokensAcceptanceType(TokensAcceptanceType newTokensAcceptanceType) external override authP(authParams(uint8(newTokensAcceptanceType))) { _setTokensAcceptanceType(newTokensAcceptanceType); } /** * @dev Updates the list of tokens of the tokens acceptance list * @param tokens List of tokens to be updated from the acceptance list * @param added Whether each of the given tokens should be added or removed from the list */ function setTokensAcceptanceList(address[] memory tokens, bool[] memory added) external override auth { if (tokens.length != added.length) revert TaskAcceptanceInputLengthMismatch(); for (uint256 i = 0; i < tokens.length; i++) { _setTokenAcceptanceList(tokens[i], added[i]); } } /** * @dev Before token indexed task hook */ function _beforeTokenIndexedTask(address token, uint256) internal virtual { if (!isTokenAllowed(token)) revert TaskTokenNotAllowed(token); } /** * @dev After token indexed task hook */ function _afterTokenIndexedTask(address token, uint256) internal virtual { // solhint-disable-previous-line no-empty-blocks } /** * @dev Sets the tokens acceptance type of the task * @param newTokensAcceptanceType New token acceptance type to be set */ function _setTokensAcceptanceType(TokensAcceptanceType newTokensAcceptanceType) internal { tokensAcceptanceType = newTokensAcceptanceType; emit TokensAcceptanceTypeSet(newTokensAcceptanceType); } /** * @dev Updates a token from the tokens acceptance list * @param token Token to be updated from the acceptance list * @param added Whether the token should be added or removed from the list */ function _setTokenAcceptanceList(address token, bool added) internal { if (token == address(0)) revert TaskAcceptanceTokenZero(); added ? _tokens.add(token) : _tokens.remove(token); emit TokensAcceptanceListSet(token, added); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.3; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '../interfaces/base/ITokenThresholdTask.sol'; /** * @dev Token threshold task. It mainly works with token threshold configs that can be used to tell if * a specific token amount is compliant with certain minimum or maximum values. Token threshold tasks * make use of a default threshold config as a fallback in case there is no custom threshold defined for the token * being evaluated. */ abstract contract TokenThresholdTask is ITokenThresholdTask, Authorized { using FixedPoint for uint256; // Default threshold Threshold internal _defaultThreshold; // Custom thresholds per token mapping (address => Threshold) internal _customThresholds; /** * @dev Threshold defined by a token address and min/max values */ struct Threshold { address token; uint256 min; uint256 max; } /** * @dev Custom token threshold config. Only used in the initializer. */ struct CustomThresholdConfig { address token; Threshold threshold; } /** * @dev Token threshold config. Only used in the initializer. * @param defaultThreshold Default threshold to be set * @param customThresholdConfigs List of custom threshold configs to be set */ struct TokenThresholdConfig { Threshold defaultThreshold; CustomThresholdConfig[] customThresholdConfigs; } /** * @dev Initializes the token threshold task. It does not call upper contracts initializers. * @param config Token threshold task config */ function __TokenThresholdTask_init(TokenThresholdConfig memory config) internal onlyInitializing { __TokenThresholdTask_init_unchained(config); } /** * @dev Initializes the token threshold task. It does call upper contracts initializers. * @param config Token threshold task config */ function __TokenThresholdTask_init_unchained(TokenThresholdConfig memory config) internal onlyInitializing { Threshold memory defaultThreshold = config.defaultThreshold; _setDefaultTokenThreshold(defaultThreshold.token, defaultThreshold.min, defaultThreshold.max); for (uint256 i = 0; i < config.customThresholdConfigs.length; i++) { CustomThresholdConfig memory customThresholdConfig = config.customThresholdConfigs[i]; Threshold memory custom = customThresholdConfig.threshold; _setCustomTokenThreshold(customThresholdConfig.token, custom.token, custom.min, custom.max); } } /** * @dev Tells the default token threshold */ function defaultTokenThreshold() external view override returns (address thresholdToken, uint256 min, uint256 max) { Threshold memory threshold = _defaultThreshold; return (threshold.token, threshold.min, threshold.max); } /** * @dev Tells the token threshold defined for a specific token * @param token Address of the token being queried */ function customTokenThreshold(address token) external view override returns (address thresholdToken, uint256 min, uint256 max) { Threshold memory threshold = _customThresholds[token]; return (threshold.token, threshold.min, threshold.max); } /** * @dev Tells the threshold that should be used for a token, it prioritizes custom thresholds over the default one * @param token Address of the token being queried */ function getTokenThreshold(address token) external view virtual override returns (address thresholdToken, uint256 min, uint256 max) { Threshold memory threshold = _getTokenThreshold(token); return (threshold.token, threshold.min, threshold.max); } /** * @dev Sets a new default threshold config * @param thresholdToken New threshold token to be set * @param min New threshold minimum to be set * @param max New threshold maximum to be set */ function setDefaultTokenThreshold(address thresholdToken, uint256 min, uint256 max) external override authP(authParams(thresholdToken, min, max)) { _setDefaultTokenThreshold(thresholdToken, min, max); } /** * @dev Sets a custom token threshold * @param token Address of the token to set a custom threshold for * @param thresholdToken New custom threshold token to be set * @param min New custom threshold minimum to be set * @param max New custom threshold maximum to be set */ function setCustomTokenThreshold(address token, address thresholdToken, uint256 min, uint256 max) external override authP(authParams(token, thresholdToken, min, max)) { _setCustomTokenThreshold(token, thresholdToken, min, max); } /** * @dev Fetches a base/quote price */ function _getPrice(address base, address quote) internal view virtual returns (uint256); /** * @dev Tells the threshold that should be used for a token, it prioritizes custom thresholds over the default one * @param token Address of the token being queried */ function _getTokenThreshold(address token) internal view returns (Threshold memory) { Threshold storage customThreshold = _customThresholds[token]; return customThreshold.token == address(0) ? _defaultThreshold : customThreshold; } /** * @dev Before token threshold task hook */ function _beforeTokenThresholdTask(address token, uint256 amount) internal virtual { Threshold memory threshold = _getTokenThreshold(token); if (threshold.token == address(0)) return; uint256 convertedAmount = threshold.token == token ? amount : amount.mulDown(_getPrice(token, threshold.token)); bool isValid = convertedAmount >= threshold.min && (threshold.max == 0 || convertedAmount <= threshold.max); if (!isValid) revert TaskTokenThresholdNotMet(threshold.token, convertedAmount, threshold.min, threshold.max); } /** * @dev After token threshold task hook */ function _afterTokenThresholdTask(address, uint256) internal virtual { // solhint-disable-previous-line no-empty-blocks } /** * @dev Sets a new default threshold config * @param thresholdToken New threshold token to be set * @param min New threshold minimum to be set * @param max New threshold maximum to be set */ function _setDefaultTokenThreshold(address thresholdToken, uint256 min, uint256 max) internal { _setTokenThreshold(_defaultThreshold, thresholdToken, min, max); emit DefaultTokenThresholdSet(thresholdToken, min, max); } /** * @dev Sets a custom of tokens thresholds * @param token Address of the token to set a custom threshold for * @param thresholdToken New custom threshold token to be set * @param min New custom threshold minimum to be set * @param max New custom threshold maximum to be set */ function _setCustomTokenThreshold(address token, address thresholdToken, uint256 min, uint256 max) internal { if (token == address(0)) revert TaskThresholdTokenZero(); _setTokenThreshold(_customThresholds[token], thresholdToken, min, max); emit CustomTokenThresholdSet(token, thresholdToken, min, max); } /** * @dev Sets a threshold * @param threshold Threshold to be updated * @param token New threshold token to be set * @param min New threshold minimum to be set * @param max New threshold maximum to be set */ function _setTokenThreshold(Threshold storage threshold, address token, uint256 min, uint256 max) private { // If there is no threshold, all values must be zero bool isZeroThreshold = token == address(0) && min == 0 && max == 0; bool isNonZeroThreshold = token != address(0) && (max == 0 || max >= min); if (!isZeroThreshold && !isNonZeroThreshold) revert TaskInvalidThresholdInput(token, min, max); threshold.token = token; threshold.min = min; threshold.max = max; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.17; import '@mimic-fi/v3-authorizer/contracts/Authorized.sol'; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '../interfaces/base/IVolumeLimitedTask.sol'; /** * @dev Volume limit config for tasks. It allows setting volume limit per period of time. */ abstract contract VolumeLimitedTask is IVolumeLimitedTask, Authorized { using FixedPoint for uint256; // Default volume limit VolumeLimit internal _defaultVolumeLimit; // Custom volume limits per token mapping (address => VolumeLimit) internal _customVolumeLimits; /** * @dev Volume limit config * @param token Address to measure the volume limit */ struct VolumeLimit { address token; uint256 amount; uint256 accrued; uint256 period; uint256 nextResetTime; } /** * @dev Volume limit params. Only used in the initializer. */ struct VolumeLimitParams { address token; uint256 amount; uint256 period; } /** * @dev Custom token volume limit config. Only used in the initializer. */ struct CustomVolumeLimitConfig { address token; VolumeLimitParams volumeLimit; } /** * @dev Volume limit config. Only used in the initializer. */ struct VolumeLimitConfig { VolumeLimitParams defaultVolumeLimit; CustomVolumeLimitConfig[] customVolumeLimitConfigs; } /** * @dev Initializes the volume limited task. It does call upper contracts initializers. * @param config Volume limited task config */ function __VolumeLimitedTask_init(VolumeLimitConfig memory config) internal onlyInitializing { __VolumeLimitedTask_init_unchained(config); } /** * @dev Initializes the volume limited task. It does not call upper contracts initializers. * @param config Volume limited task config */ function __VolumeLimitedTask_init_unchained(VolumeLimitConfig memory config) internal onlyInitializing { VolumeLimitParams memory defaultLimit = config.defaultVolumeLimit; _setDefaultVolumeLimit(defaultLimit.token, defaultLimit.amount, defaultLimit.period); for (uint256 i = 0; i < config.customVolumeLimitConfigs.length; i++) { CustomVolumeLimitConfig memory customVolumeLimitConfig = config.customVolumeLimitConfigs[i]; VolumeLimitParams memory custom = customVolumeLimitConfig.volumeLimit; _setCustomVolumeLimit(customVolumeLimitConfig.token, custom.token, custom.amount, custom.period); } } /** * @dev Tells the default volume limit set */ function defaultVolumeLimit() external view override returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime) { VolumeLimit memory limit = _defaultVolumeLimit; return (limit.token, limit.amount, limit.accrued, limit.period, limit.nextResetTime); } /** * @dev Tells the custom volume limit set for a specific token * @param token Address of the token being queried */ function customVolumeLimit(address token) external view override returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime) { VolumeLimit memory limit = _customVolumeLimits[token]; return (limit.token, limit.amount, limit.accrued, limit.period, limit.nextResetTime); } /** * @dev Tells the volume limit that should be used for a token, it prioritizes custom limits over the default one * @param token Address of the token being queried */ function getVolumeLimit(address token) external view override returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime) { VolumeLimit memory limit = _getVolumeLimit(token); return (limit.token, limit.amount, limit.accrued, limit.period, limit.nextResetTime); } /** * @dev Sets a the default volume limit config * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function setDefaultVolumeLimit(address limitToken, uint256 limitAmount, uint256 limitPeriod) external override authP(authParams(limitToken, limitAmount, limitPeriod)) { _setDefaultVolumeLimit(limitToken, limitAmount, limitPeriod); } /** * @dev Sets a custom volume limit * @param token Address of the token to set a custom volume limit for * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function setCustomVolumeLimit(address token, address limitToken, uint256 limitAmount, uint256 limitPeriod) external override authP(authParams(token, limitToken, limitAmount, limitPeriod)) { _setCustomVolumeLimit(token, limitToken, limitAmount, limitPeriod); } /** * @dev Fetches a base/quote price */ function _getPrice(address base, address quote) internal view virtual returns (uint256); /** * @dev Tells the volume limit that should be used for a token, it prioritizes custom limits over the default one * @param token Address of the token being queried */ function _getVolumeLimit(address token) internal view returns (VolumeLimit storage) { VolumeLimit storage customLimit = _customVolumeLimits[token]; return customLimit.token == address(0) ? _defaultVolumeLimit : customLimit; } /** * @dev Before volume limited task hook */ function _beforeVolumeLimitedTask(address token, uint256 amount) internal virtual { VolumeLimit memory limit = _getVolumeLimit(token); if (limit.token == address(0)) return; uint256 amountInLimitToken = limit.token == token ? amount : amount.mulDown(_getPrice(token, limit.token)); uint256 processedVolume = amountInLimitToken + (block.timestamp < limit.nextResetTime ? limit.accrued : 0); if (processedVolume > limit.amount) revert TaskVolumeLimitExceeded(limit.token, limit.amount, processedVolume); } /** * @dev After volume limited task hook */ function _afterVolumeLimitedTask(address token, uint256 amount) internal virtual { VolumeLimit storage limit = _getVolumeLimit(token); if (limit.token == address(0)) return; uint256 amountInLimitToken = limit.token == token ? amount : amount.mulDown(_getPrice(token, limit.token)); if (block.timestamp >= limit.nextResetTime) { limit.accrued = 0; limit.nextResetTime = block.timestamp + limit.period; } limit.accrued += amountInLimitToken; } /** * @dev Sets the default volume limit * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function _setDefaultVolumeLimit(address limitToken, uint256 limitAmount, uint256 limitPeriod) internal { _setVolumeLimit(_defaultVolumeLimit, limitToken, limitAmount, limitPeriod); emit DefaultVolumeLimitSet(limitToken, limitAmount, limitPeriod); } /** * @dev Sets a custom volume limit * @param token Address of the token to set a custom volume limit for * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function _setCustomVolumeLimit(address token, address limitToken, uint256 limitAmount, uint256 limitPeriod) internal { if (token == address(0)) revert TaskVolumeLimitTokenZero(); _setVolumeLimit(_customVolumeLimits[token], limitToken, limitAmount, limitPeriod); emit CustomVolumeLimitSet(token, limitToken, limitAmount, limitPeriod); } /** * @dev Sets a volume limit * @param limit Volume limit to be updated * @param token Address of the token to measure the volume limit * @param amount Amount of tokens to be applied for the volume limit * @param period Frequency to Amount of tokens to be applied for the volume limit */ function _setVolumeLimit(VolumeLimit storage limit, address token, uint256 amount, uint256 period) private { // If there is no limit, all values must be zero bool isZeroLimit = token == address(0) && amount == 0 && period == 0; bool isNonZeroLimit = token != address(0) && amount > 0 && period > 0; if (!isZeroLimit && !isNonZeroLimit) revert TaskInvalidVolumeLimitInput(token, amount, period); // Changing the period only affects the end time of the next period, but not the end date of the current one limit.period = period; // Changing the amount does not affect the totalizator, it only applies when updating the accrued amount. // Note that it can happen that the new amount is lower than the accrued amount if the amount is lowered. // However, there shouldn't be any accounting issues with that. limit.amount = amount; // Therefore, only clean the totalizators if the limit is being removed if (isZeroLimit) { limit.accrued = 0; limit.nextResetTime = 0; } else { // If limit is not zero, set the next reset time if it wasn't set already // Otherwise, if the token is being changed the accrued amount must be updated accordingly if (limit.nextResetTime == 0) { limit.accrued = 0; limit.nextResetTime = block.timestamp + period; } else if (limit.token != token) { uint256 price = _getPrice(limit.token, token); limit.accrued = limit.accrued.mulDown(price); } } // Finally simply set the new requested token limit.token = token; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import '@mimic-fi/v3-authorizer/contracts/interfaces/IAuthorized.sol'; /** * @dev Base task interface */ interface IBaseTask is IAuthorized { // Execution type serves for relayers in order to distinguish how each task must be executed // solhint-disable-next-line func-name-mixedcase function EXECUTION_TYPE() external view returns (bytes32); /** * @dev The balance connectors are the same */ error TaskSameBalanceConnectors(bytes32 connectorId); /** * @dev The smart vault's price oracle is not set */ error TaskSmartVaultPriceOracleNotSet(address smartVault); /** * @dev Emitted every time a task is executed */ event Executed(); /** * @dev Emitted every time the balance connectors are set */ event BalanceConnectorsSet(bytes32 indexed previous, bytes32 indexed next); /** * @dev Tells the address of the Smart Vault tied to it, it cannot be changed */ function smartVault() external view returns (address); /** * @dev Tells the address from where the token amounts to execute this task are fetched. * This address must be the Smart Vault in case the previous balance connector is set. */ function getTokensSource() external view returns (address); /** * @dev Tells the amount a task should use for a token * @param token Address of the token being queried */ function getTaskAmount(address token) external view returns (uint256); /** * @dev Tells the previous and next balance connectors id of the previous task in the workflow */ function getBalanceConnectors() external view returns (bytes32 previous, bytes32 next); /** * @dev Sets the balance connector IDs * @param previous Balance connector id of the previous task in the workflow * @param next Balance connector id of the next task in the workflow */ function setBalanceConnectors(bytes32 previous, bytes32 next) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Gas limited task interface */ interface IGasLimitedTask is IBaseTask { /** * @dev The tx initial gas cache has not been initialized */ error TaskGasNotInitialized(); /** * @dev The gas price used is greater than the limit */ error TaskGasPriceLimitExceeded(uint256 gasPrice, uint256 gasPriceLimit); /** * @dev The priority fee used is greater than the priority fee limit */ error TaskPriorityFeeLimitExceeded(uint256 priorityFee, uint256 priorityFeeLimit); /** * @dev The transaction cost is greater than the transaction cost limit */ error TaskTxCostLimitExceeded(uint256 txCost, uint256 txCostLimit); /** * @dev The transaction cost percentage is greater than the transaction cost limit percentage */ error TaskTxCostLimitPctExceeded(uint256 txCostPct, uint256 txCostLimitPct); /** * @dev The new transaction cost limit percentage is greater than one */ error TaskTxCostLimitPctAboveOne(); /** * @dev Emitted every time the gas limits are set */ event GasLimitsSet(uint256 gasPriceLimit, uint256 priorityFeeLimit, uint256 txCostLimit, uint256 txCostLimitPct); /** * @dev Tells the gas limits config */ function getGasLimits() external view returns (uint256 gasPriceLimit, uint256 priorityFeeLimit, uint256 txCostLimit, uint256 txCostLimitPct); /** * @dev Sets the gas limits config * @param newGasPriceLimit New gas price limit to be set * @param newPriorityFeeLimit New priority fee limit to be set * @param newTxCostLimit New tx cost limit to be set * @param newTxCostLimitPct New tx cost percentage limit to be set */ function setGasLimits( uint256 newGasPriceLimit, uint256 newPriorityFeeLimit, uint256 newTxCostLimit, uint256 newTxCostLimitPct ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Pausable task interface */ interface IPausableTask is IBaseTask { /** * @dev The task is paused */ error TaskPaused(); /** * @dev The task is unpaused */ error TaskUnpaused(); /** * @dev Emitted every time a task is paused */ event Paused(); /** * @dev Emitted every time a task is unpaused */ event Unpaused(); /** * @dev Tells the task is paused or not */ function isPaused() external view returns (bool); /** * @dev Pauses a task */ function pause() external; /** * @dev Unpauses a task */ function unpause() external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Time-locked task interface */ interface ITimeLockedTask is IBaseTask { /** * @dev The time lock frequency mode requested is invalid */ error TaskInvalidFrequencyMode(uint8 mode); /** * @dev The time lock frequency is not valid */ error TaskInvalidFrequency(uint8 mode, uint256 frequency); /** * @dev The time lock allowed date is not valid */ error TaskInvalidAllowedDate(uint8 mode, uint256 date); /** * @dev The time lock allowed window is not valid */ error TaskInvalidAllowedWindow(uint8 mode, uint256 window); /** * @dev The time lock is still active */ error TaskTimeLockActive(uint256 currentTimestamp, uint256 expiration); /** * @dev Emitted every time a new time lock is set */ event TimeLockSet(uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window); /** * @dev Emitted every time a new expiration timestamp is set */ event TimeLockAllowedAtSet(uint256 allowedAt); /** * @dev Tells all the time-lock related information */ function getTimeLock() external view returns (uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window); /** * @dev Sets the time-lock * @param mode Time lock mode * @param frequency Time lock frequency * @param allowedAt Future timestamp since when the task can be executed * @param window Period in seconds during when a time-locked task can be executed since the allowed timestamp */ function setTimeLock(uint8 mode, uint256 frequency, uint256 allowedAt, uint256 window) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Token indexed task interface */ interface ITokenIndexedTask is IBaseTask { /** * @dev Acceptance list types: either deny-list to express "all except" or allow-list to express "only" */ enum TokensAcceptanceType { DenyList, AllowList } /** * @dev The acceptance token is zero */ error TaskAcceptanceTokenZero(); /** * @dev The tokens acceptance input length mismatch */ error TaskAcceptanceInputLengthMismatch(); /** * @dev The token is not allowed */ error TaskTokenNotAllowed(address token); /** * @dev Emitted every time a tokens acceptance type is set */ event TokensAcceptanceTypeSet(TokensAcceptanceType acceptanceType); /** * @dev Emitted every time a token is added or removed from the acceptance list */ event TokensAcceptanceListSet(address indexed token, bool added); /** * @dev Tells the acceptance type of the config */ function tokensAcceptanceType() external view returns (TokensAcceptanceType); /** * @dev Tells whether a token is allowed or not * @param token Address of the token being queried */ function isTokenAllowed(address token) external view returns (bool); /** * @dev Sets the tokens acceptance type of the task * @param newTokensAcceptanceType New token acceptance type to be set */ function setTokensAcceptanceType(TokensAcceptanceType newTokensAcceptanceType) external; /** * @dev Updates the list of tokens of the tokens acceptance list * @param tokens List of tokens to be updated from the acceptance list * @param added Whether each of the given tokens should be added or removed from the list */ function setTokensAcceptanceList(address[] memory tokens, bool[] memory added) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General External License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General External License for more details. // You should have received a copy of the GNU General External License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Token threshold task interface */ interface ITokenThresholdTask is IBaseTask { /** * @dev The token threshold token is zero */ error TaskThresholdTokenZero(); /** * @dev The token threshold to be set is invalid */ error TaskInvalidThresholdInput(address token, uint256 min, uint256 max); /** * @dev The token threshold has not been met */ error TaskTokenThresholdNotMet(address token, uint256 amount, uint256 min, uint256 max); /** * @dev Emitted every time a default threshold is set */ event DefaultTokenThresholdSet(address token, uint256 min, uint256 max); /** * @dev Emitted every time a token threshold is set */ event CustomTokenThresholdSet(address indexed token, address thresholdToken, uint256 min, uint256 max); /** * @dev Tells the default token threshold */ function defaultTokenThreshold() external view returns (address thresholdToken, uint256 min, uint256 max); /** * @dev Tells the custom threshold defined for a specific token * @param token Address of the token being queried */ function customTokenThreshold(address token) external view returns (address thresholdToken, uint256 min, uint256 max); /** * @dev Tells the threshold that should be used for a token * @param token Address of the token being queried */ function getTokenThreshold(address token) external view returns (address thresholdToken, uint256 min, uint256 max); /** * @dev Sets a new default threshold config * @param thresholdToken New threshold token to be set * @param min New threshold minimum to be set * @param max New threshold maximum to be set */ function setDefaultTokenThreshold(address thresholdToken, uint256 min, uint256 max) external; /** * @dev Sets a custom token threshold * @param token Address of the token to set a custom threshold * @param thresholdToken New custom threshold token to be set * @param min New custom threshold minimum to be set * @param max New custom threshold maximum to be set */ function setCustomTokenThreshold(address token, address thresholdToken, uint256 min, uint256 max) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseTask.sol'; /** * @dev Volume limited task interface */ interface IVolumeLimitedTask is IBaseTask { /** * @dev The volume limit token is zero */ error TaskVolumeLimitTokenZero(); /** * @dev The volume limit to be set is invalid */ error TaskInvalidVolumeLimitInput(address token, uint256 amount, uint256 period); /** * @dev The volume limit has been exceeded */ error TaskVolumeLimitExceeded(address token, uint256 limit, uint256 volume); /** * @dev Emitted every time a default volume limit is set */ event DefaultVolumeLimitSet(address indexed limitToken, uint256 amount, uint256 period); /** * @dev Emitted every time a custom volume limit is set */ event CustomVolumeLimitSet(address indexed token, address indexed limitToken, uint256 amount, uint256 period); /** * @dev Tells the default volume limit set */ function defaultVolumeLimit() external view returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime); /** * @dev Tells the custom volume limit set for a specific token * @param token Address of the token being queried */ function customVolumeLimit(address token) external view returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime); /** * @dev Tells the volume limit that should be used for a token * @param token Address of the token being queried */ function getVolumeLimit(address token) external view returns (address limitToken, uint256 amount, uint256 accrued, uint256 period, uint256 nextResetTime); /** * @dev Sets a the default volume limit config * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function setDefaultVolumeLimit(address limitToken, uint256 limitAmount, uint256 limitPeriod) external; /** * @dev Sets a custom volume limit * @param token Address of the token to set a custom volume limit for * @param limitToken Address of the token to measure the volume limit * @param limitAmount Amount of tokens to be applied for the volume limit * @param limitPeriod Frequency to Amount of tokens to be applied for the volume limit */ function setCustomVolumeLimit(address token, address limitToken, uint256 limitAmount, uint256 limitPeriod) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './base/IBaseTask.sol'; import './base/IPausableTask.sol'; import './base/IGasLimitedTask.sol'; import './base/ITimeLockedTask.sol'; import './base/ITokenIndexedTask.sol'; import './base/ITokenThresholdTask.sol'; import './base/IVolumeLimitedTask.sol'; // solhint-disable no-empty-blocks /** * @dev Task interface */ interface ITask is IBaseTask, IPausableTask, IGasLimitedTask, ITimeLockedTask, ITokenIndexedTask, ITokenThresholdTask, IVolumeLimitedTask { }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import '../ITask.sol'; /** * @dev Base swap task interface */ interface IBaseSwapTask is ITask { /** * @dev The token is zero */ error TaskTokenZero(); /** * @dev The amount is zero */ error TaskAmountZero(); /** * @dev The connector is zero */ error TaskConnectorZero(); /** * @dev The token out is not set */ error TaskTokenOutNotSet(); /** * @dev The slippage to be set is greater than one */ error TaskSlippageAboveOne(); /** * @dev The slippage is greater than the maximum slippage */ error TaskSlippageAboveMax(uint256 slippage, uint256 maxSlippage); /** * @dev Emitted every time the connector is set */ event ConnectorSet(address indexed connector); /** * @dev Emitted every time the default token out is set */ event DefaultTokenOutSet(address indexed tokenOut); /** * @dev Emitted every time the default max slippage is set */ event DefaultMaxSlippageSet(uint256 maxSlippage); /** * @dev Emitted every time a custom token out is set */ event CustomTokenOutSet(address indexed token, address tokenOut); /** * @dev Emitted every time a custom max slippage is set */ event CustomMaxSlippageSet(address indexed token, uint256 maxSlippage); /** * @dev Tells the connector tied to the task */ function connector() external view returns (address); /** * @dev Tells the default token out */ function defaultTokenOut() external view returns (address); /** * @dev Tells the default max slippage */ function defaultMaxSlippage() external view returns (uint256); /** * @dev Tells the token out defined for a specific token * @param token Address of the token being queried */ function customTokenOut(address token) external view returns (address); /** * @dev Tells the max slippage defined for a specific token * @param token Address of the token being queried */ function customMaxSlippage(address token) external view returns (uint256); /** * @dev Tells the token out that should be used for a token */ function getTokenOut(address token) external view returns (address); /** * @dev Tells the max slippage that should be used for a token */ function getMaxSlippage(address token) external view returns (uint256); /** * @dev Sets a new connector * @param newConnector Address of the connector to be set */ function setConnector(address newConnector) external; /** * @dev Sets the default token out * @param tokenOut Address of the default token out to be set */ function setDefaultTokenOut(address tokenOut) external; /** * @dev Sets the default max slippage * @param maxSlippage Default max slippage to be set */ function setDefaultMaxSlippage(uint256 maxSlippage) external; /** * @dev Sets a custom token out * @param token Address of the token to set a custom token out for * @param tokenOut Address of the token out to be set */ function setCustomTokenOut(address token, address tokenOut) external; /** * @dev Sets a custom max slippage * @param token Address of the token to set a custom max slippage for * @param maxSlippage Max slippage to be set */ function setCustomMaxSlippage(address token, uint256 maxSlippage) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >=0.8.0; import './IBaseSwapTask.sol'; /** * @dev KyberSwap swapper task interface */ interface IKyberSwapV2Swapper is IBaseSwapTask { /** * @dev Execution function */ function call(address tokenIn, uint256 amountIn, uint256 slippage, bytes memory data) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; import '@mimic-fi/v3-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v3-helpers/contracts/utils/Denominations.sol'; import '../Task.sol'; import '../interfaces/swap/IBaseSwapTask.sol'; /** * @title Base swap task * @dev Task that offers the basic components for more detailed swap tasks */ abstract contract BaseSwapTask is IBaseSwapTask, Task { using FixedPoint for uint256; // Connector address address public override connector; // Default token out address public override defaultTokenOut; // Default maximum slippage in fixed point uint256 public override defaultMaxSlippage; // Token out per token mapping (address => address) public override customTokenOut; // Maximum slippage per token address mapping (address => uint256) public override customMaxSlippage; /** * @dev Custom token out config. Only used in the initializer. */ struct CustomTokenOut { address token; address tokenOut; } /** * @dev Custom max slippage config. Only used in the initializer. */ struct CustomMaxSlippage { address token; uint256 maxSlippage; } /** * @dev Base swap config. Only used in the initializer. */ struct BaseSwapConfig { address connector; address tokenOut; uint256 maxSlippage; CustomTokenOut[] customTokensOut; CustomMaxSlippage[] customMaxSlippages; TaskConfig taskConfig; } /** * @dev Initializes the base swap task. It does call upper contracts initializers. * @param config Base swap config */ function __BaseSwapTask_init(BaseSwapConfig memory config) internal onlyInitializing { __Task_init(config.taskConfig); __BaseSwapTask_init_unchained(config); } /** * @dev Initializes the base swap task. It does not call upper contracts initializers. * @param config Base swap config */ function __BaseSwapTask_init_unchained(BaseSwapConfig memory config) internal onlyInitializing { _setConnector(config.connector); _setDefaultTokenOut(config.tokenOut); _setDefaultMaxSlippage(config.maxSlippage); for (uint256 i = 0; i < config.customTokensOut.length; i++) { _setCustomTokenOut(config.customTokensOut[i].token, config.customTokensOut[i].tokenOut); } for (uint256 i = 0; i < config.customMaxSlippages.length; i++) { _setCustomMaxSlippage(config.customMaxSlippages[i].token, config.customMaxSlippages[i].maxSlippage); } } /** * @dev Tells the token out that should be used for a token */ function getTokenOut(address token) public view virtual override returns (address) { address tokenOut = customTokenOut[token]; return tokenOut == address(0) ? defaultTokenOut : tokenOut; } /** * @dev Tells the max slippage that should be used for a token */ function getMaxSlippage(address token) public view virtual override returns (uint256) { uint256 maxSlippage = customMaxSlippage[token]; return maxSlippage == 0 ? defaultMaxSlippage : maxSlippage; } /** * @dev Sets a new connector * @param newConnector Address of the connector to be set */ function setConnector(address newConnector) external override authP(authParams(newConnector)) { _setConnector(newConnector); } /** * @dev Sets the default token out * @param tokenOut Address of the default token out to be set */ function setDefaultTokenOut(address tokenOut) external override authP(authParams(tokenOut)) { _setDefaultTokenOut(tokenOut); } /** * @dev Sets the default max slippage * @param maxSlippage Default max slippage to be set */ function setDefaultMaxSlippage(uint256 maxSlippage) external override authP(authParams(maxSlippage)) { _setDefaultMaxSlippage(maxSlippage); } /** * @dev Sets a custom token out * @param token Address of the token to set a custom token out for * @param tokenOut Address of the token out to be set */ function setCustomTokenOut(address token, address tokenOut) external override authP(authParams(token, tokenOut)) { _setCustomTokenOut(token, tokenOut); } /** * @dev Sets a custom max slippage * @param token Address of the token to set a custom max slippage for * @param maxSlippage Max slippage to be set */ function setCustomMaxSlippage(address token, uint256 maxSlippage) external override authP(authParams(token, maxSlippage)) { _setCustomMaxSlippage(token, maxSlippage); } /** * @dev Before base swap task hook */ function _beforeBaseSwapTask(address token, uint256 amount, uint256 slippage) internal virtual { _beforeTask(token, amount); if (token == address(0)) revert TaskTokenZero(); if (amount == 0) revert TaskAmountZero(); if (getTokenOut(token) == address(0)) revert TaskTokenOutNotSet(); uint256 maxSlippage = getMaxSlippage(token); if (slippage > maxSlippage) revert TaskSlippageAboveMax(slippage, maxSlippage); } /** * @dev After base swap task hook */ function _afterBaseSwapTask(address tokenIn, uint256 amountIn, uint256, address tokenOut, uint256 amountOut) internal virtual { _increaseBalanceConnector(tokenOut, amountOut); _afterTask(tokenIn, amountIn); } /** * @dev Sets a new connector * @param newConnector Address of the connector to be set */ function _setConnector(address newConnector) internal { if (newConnector == address(0)) revert TaskConnectorZero(); connector = newConnector; emit ConnectorSet(newConnector); } /** * @dev Sets the default token out * @param tokenOut Default token out to be set */ function _setDefaultTokenOut(address tokenOut) internal { defaultTokenOut = tokenOut; emit DefaultTokenOutSet(tokenOut); } /** * @dev Sets the default max slippage * @param maxSlippage Default max slippage to be set */ function _setDefaultMaxSlippage(uint256 maxSlippage) internal { if (maxSlippage > FixedPoint.ONE) revert TaskSlippageAboveOne(); defaultMaxSlippage = maxSlippage; emit DefaultMaxSlippageSet(maxSlippage); } /** * @dev Sets a custom token out for a token * @param token Address of the token to set the custom token out for * @param tokenOut Address of the token out to be set */ function _setCustomTokenOut(address token, address tokenOut) internal { if (token == address(0)) revert TaskTokenZero(); customTokenOut[token] = tokenOut; emit CustomTokenOutSet(token, tokenOut); } /** * @dev Sets a custom max slippage for a token * @param token Address of the token to set the custom max slippage for * @param maxSlippage Max slippage to be set */ function _setCustomMaxSlippage(address token, uint256 maxSlippage) internal { if (token == address(0)) revert TaskTokenZero(); if (maxSlippage > FixedPoint.ONE) revert TaskSlippageAboveOne(); customMaxSlippage[token] = maxSlippage; emit CustomMaxSlippageSet(token, maxSlippage); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; import './interfaces/ITask.sol'; import './base/BaseTask.sol'; import './base/PausableTask.sol'; import './base/GasLimitedTask.sol'; import './base/TimeLockedTask.sol'; import './base/TokenIndexedTask.sol'; import './base/TokenThresholdTask.sol'; import './base/VolumeLimitedTask.sol'; /** * @title Task * @dev Shared components across all tasks */ abstract contract Task is ITask, BaseTask, PausableTask, GasLimitedTask, TimeLockedTask, TokenIndexedTask, TokenThresholdTask, VolumeLimitedTask { /** * @dev Task config. Only used in the initializer. */ struct TaskConfig { BaseConfig baseConfig; GasLimitConfig gasLimitConfig; TimeLockConfig timeLockConfig; TokenIndexConfig tokenIndexConfig; TokenThresholdConfig tokenThresholdConfig; VolumeLimitConfig volumeLimitConfig; } /** * @dev Initializes the task. It does call upper contracts initializers. * @param config Task config */ function __Task_init(TaskConfig memory config) internal onlyInitializing { __BaseTask_init(config.baseConfig); __PausableTask_init(); __GasLimitedTask_init(config.gasLimitConfig); __TimeLockedTask_init(config.timeLockConfig); __TokenIndexedTask_init(config.tokenIndexConfig); __TokenThresholdTask_init(config.tokenThresholdConfig); __VolumeLimitedTask_init(config.volumeLimitConfig); __Task_init_unchained(config); } /** * @dev Initializes the task. It does not call upper contracts initializers. * @param config Task config */ function __Task_init_unchained(TaskConfig memory config) internal onlyInitializing { // solhint-disable-previous-line no-empty-blocks } /** * @dev Fetches a base/quote price */ function _getPrice(address base, address quote) internal view override(BaseTask, GasLimitedTask, TokenThresholdTask, VolumeLimitedTask) returns (uint256) { return BaseTask._getPrice(base, quote); } /** * @dev Before task hook */ function _beforeTask(address token, uint256 amount) internal virtual { _beforeBaseTask(token, amount); _beforePausableTask(token, amount); _beforeGasLimitedTask(token, amount); _beforeTimeLockedTask(token, amount); _beforeTokenIndexedTask(token, amount); _beforeTokenThresholdTask(token, amount); _beforeVolumeLimitedTask(token, amount); } /** * @dev After task hook */ function _afterTask(address token, uint256 amount) internal virtual { _afterVolumeLimitedTask(token, amount); _afterTokenThresholdTask(token, amount); _afterTokenIndexedTask(token, amount); _afterTimeLockedTask(token, amount); _afterGasLimitedTask(token, amount); _afterPausableTask(token, amount); _afterBaseTask(token, amount); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; contract KyberSwapV2ConnectorMock { event LogExecute(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes data); function execute(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes memory data) external returns (uint256) { emit LogExecute(tokenIn, tokenOut, amountIn, minAmountOut, data); return minAmountOut; } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"bytes4","name":"what","type":"bytes4"},{"internalType":"uint256[]","name":"how","type":"uint256[]"}],"name":"AuthSenderNotAllowed","type":"error"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"BytesOutOfBounds","type":"error"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"aInflated","type":"uint256"}],"name":"FixedPointDivInternal","type":"error"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"FixedPointMulOverflow","type":"error"},{"inputs":[],"name":"FixedPointZeroDivision","type":"error"},{"inputs":[],"name":"TaskAcceptanceInputLengthMismatch","type":"error"},{"inputs":[],"name":"TaskAcceptanceTokenZero","type":"error"},{"inputs":[],"name":"TaskAmountZero","type":"error"},{"inputs":[],"name":"TaskConnectorZero","type":"error"},{"inputs":[],"name":"TaskGasNotInitialized","type":"error"},{"inputs":[{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"uint256","name":"gasPriceLimit","type":"uint256"}],"name":"TaskGasPriceLimitExceeded","type":"error"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"date","type":"uint256"}],"name":"TaskInvalidAllowedDate","type":"error"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"window","type":"uint256"}],"name":"TaskInvalidAllowedWindow","type":"error"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"frequency","type":"uint256"}],"name":"TaskInvalidFrequency","type":"error"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"}],"name":"TaskInvalidFrequencyMode","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"TaskInvalidThresholdInput","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"TaskInvalidVolumeLimitInput","type":"error"},{"inputs":[],"name":"TaskPaused","type":"error"},{"inputs":[{"internalType":"uint256","name":"priorityFee","type":"uint256"},{"internalType":"uint256","name":"priorityFeeLimit","type":"uint256"}],"name":"TaskPriorityFeeLimitExceeded","type":"error"},{"inputs":[{"internalType":"bytes32","name":"connectorId","type":"bytes32"}],"name":"TaskSameBalanceConnectors","type":"error"},{"inputs":[{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"TaskSlippageAboveMax","type":"error"},{"inputs":[],"name":"TaskSlippageAboveOne","type":"error"},{"inputs":[{"internalType":"address","name":"smartVault","type":"address"}],"name":"TaskSmartVaultPriceOracleNotSet","type":"error"},{"inputs":[],"name":"TaskThresholdTokenZero","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentTimestamp","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"TaskTimeLockActive","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TaskTokenNotAllowed","type":"error"},{"inputs":[],"name":"TaskTokenOutNotSet","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"TaskTokenThresholdNotMet","type":"error"},{"inputs":[],"name":"TaskTokenZero","type":"error"},{"inputs":[{"internalType":"uint256","name":"txCost","type":"uint256"},{"internalType":"uint256","name":"txCostLimit","type":"uint256"}],"name":"TaskTxCostLimitExceeded","type":"error"},{"inputs":[],"name":"TaskTxCostLimitPctAboveOne","type":"error"},{"inputs":[{"internalType":"uint256","name":"txCostPct","type":"uint256"},{"internalType":"uint256","name":"txCostLimitPct","type":"uint256"}],"name":"TaskTxCostLimitPctExceeded","type":"error"},{"inputs":[],"name":"TaskUnpaused","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"volume","type":"uint256"}],"name":"TaskVolumeLimitExceeded","type":"error"},{"inputs":[],"name":"TaskVolumeLimitTokenZero","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"previous","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"next","type":"bytes32"}],"name":"BalanceConnectorsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"connector","type":"address"}],"name":"ConnectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"CustomMaxSlippageSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"}],"name":"CustomTokenOutSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"thresholdToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"min","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"max","type":"uint256"}],"name":"CustomTokenThresholdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"limitToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"CustomVolumeLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"DefaultMaxSlippageSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"}],"name":"DefaultTokenOutSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"min","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"max","type":"uint256"}],"name":"DefaultTokenThresholdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"limitToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"DefaultVolumeLimitSet","type":"event"},{"anonymous":false,"inputs":[],"name":"Executed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"gasPriceLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priorityFeeLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"txCostLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"txCostLimitPct","type":"uint256"}],"name":"GasLimitsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"allowedAt","type":"uint256"}],"name":"TimeLockAllowedAtSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"mode","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"frequency","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"allowedAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"window","type":"uint256"}],"name":"TimeLockSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"added","type":"bool"}],"name":"TokensAcceptanceListSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum ITokenIndexedTask.TokensAcceptanceType","name":"acceptanceType","type":"uint8"}],"name":"TokensAcceptanceTypeSet","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpaused","type":"event"},{"inputs":[],"name":"EXECUTION_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"authorizer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"call","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"customMaxSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"customTokenOut","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"customTokenThreshold","outputs":[{"internalType":"address","name":"thresholdToken","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"customVolumeLimit","outputs":[{"internalType":"address","name":"limitToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"accrued","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultMaxSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultTokenOut","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultTokenThreshold","outputs":[{"internalType":"address","name":"thresholdToken","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultVolumeLimit","outputs":[{"internalType":"address","name":"limitToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"accrued","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceConnectors","outputs":[{"internalType":"bytes32","name":"previous","type":"bytes32"},{"internalType":"bytes32","name":"next","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGasLimits","outputs":[{"internalType":"uint256","name":"gasPriceLimit","type":"uint256"},{"internalType":"uint256","name":"priorityFeeLimit","type":"uint256"},{"internalType":"uint256","name":"txCostLimit","type":"uint256"},{"internalType":"uint256","name":"txCostLimitPct","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getMaxSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTaskAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimeLock","outputs":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"frequency","type":"uint256"},{"internalType":"uint256","name":"allowedAt","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenOut","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenThreshold","outputs":[{"internalType":"address","name":"thresholdToken","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokensSource","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getVolumeLimit","outputs":[{"internalType":"address","name":"limitToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"accrued","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"connector","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"}],"internalType":"struct BaseSwapTask.CustomTokenOut[]","name":"customTokensOut","type":"tuple[]"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"internalType":"struct BaseSwapTask.CustomMaxSlippage[]","name":"customMaxSlippages","type":"tuple[]"},{"components":[{"components":[{"internalType":"address","name":"smartVault","type":"address"},{"internalType":"bytes32","name":"previousBalanceConnectorId","type":"bytes32"},{"internalType":"bytes32","name":"nextBalanceConnectorId","type":"bytes32"}],"internalType":"struct BaseTask.BaseConfig","name":"baseConfig","type":"tuple"},{"components":[{"internalType":"uint256","name":"gasPriceLimit","type":"uint256"},{"internalType":"uint256","name":"priorityFeeLimit","type":"uint256"},{"internalType":"uint256","name":"txCostLimit","type":"uint256"},{"internalType":"uint256","name":"txCostLimitPct","type":"uint256"}],"internalType":"struct GasLimitedTask.GasLimitConfig","name":"gasLimitConfig","type":"tuple"},{"components":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"frequency","type":"uint256"},{"internalType":"uint256","name":"allowedAt","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"internalType":"struct TimeLockedTask.TimeLockConfig","name":"timeLockConfig","type":"tuple"},{"components":[{"internalType":"enum ITokenIndexedTask.TokensAcceptanceType","name":"acceptanceType","type":"uint8"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"internalType":"struct TokenIndexedTask.TokenIndexConfig","name":"tokenIndexConfig","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"internalType":"struct TokenThresholdTask.Threshold","name":"defaultThreshold","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"internalType":"struct TokenThresholdTask.Threshold","name":"threshold","type":"tuple"}],"internalType":"struct TokenThresholdTask.CustomThresholdConfig[]","name":"customThresholdConfigs","type":"tuple[]"}],"internalType":"struct TokenThresholdTask.TokenThresholdConfig","name":"tokenThresholdConfig","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"internalType":"struct VolumeLimitedTask.VolumeLimitParams","name":"defaultVolumeLimit","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"internalType":"struct VolumeLimitedTask.VolumeLimitParams","name":"volumeLimit","type":"tuple"}],"internalType":"struct VolumeLimitedTask.CustomVolumeLimitConfig[]","name":"customVolumeLimitConfigs","type":"tuple[]"}],"internalType":"struct VolumeLimitedTask.VolumeLimitConfig","name":"volumeLimitConfig","type":"tuple"}],"internalType":"struct Task.TaskConfig","name":"taskConfig","type":"tuple"}],"internalType":"struct BaseSwapTask.BaseSwapConfig","name":"baseSwapConfig","type":"tuple"}],"internalType":"struct KyberSwapV2Swapper.KyberSwapV2SwapConfig","name":"config","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"previous","type":"bytes32"},{"internalType":"bytes32","name":"next","type":"bytes32"}],"name":"setBalanceConnectors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newConnector","type":"address"}],"name":"setConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"setCustomMaxSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"setCustomTokenOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"thresholdToken","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"setCustomTokenThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"limitToken","type":"address"},{"internalType":"uint256","name":"limitAmount","type":"uint256"},{"internalType":"uint256","name":"limitPeriod","type":"uint256"}],"name":"setCustomVolumeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"setDefaultMaxSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"}],"name":"setDefaultTokenOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"thresholdToken","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"setDefaultTokenThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"limitToken","type":"address"},{"internalType":"uint256","name":"limitAmount","type":"uint256"},{"internalType":"uint256","name":"limitPeriod","type":"uint256"}],"name":"setDefaultVolumeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newGasPriceLimit","type":"uint256"},{"internalType":"uint256","name":"newPriorityFeeLimit","type":"uint256"},{"internalType":"uint256","name":"newTxCostLimit","type":"uint256"},{"internalType":"uint256","name":"newTxCostLimitPct","type":"uint256"}],"name":"setGasLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint256","name":"frequency","type":"uint256"},{"internalType":"uint256","name":"allowedAt","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"name":"setTimeLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bool[]","name":"added","type":"bool[]"}],"name":"setTokensAcceptanceList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ITokenIndexedTask.TokensAcceptanceType","name":"newTokensAcceptanceType","type":"uint8"}],"name":"setTokensAcceptanceType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"smartVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensAcceptanceType","outputs":[{"internalType":"enum ITokenIndexedTask.TokensAcceptanceType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61521a80620000f36000396000f3fe608060405234801561001057600080fd5b50600436106102de5760003560e01c80637125590a11610186578063a5900c4d116100e3578063d09edf3111610097578063d86483e111610071578063d86483e1146107b0578063e6b5be98146107c3578063f9eaee0d146107d657600080fd5b8063d09edf3114610771578063d3feb6021461078a578063d45a76cf1461079d57600080fd5b8063b96e422c116100c8578063b96e422c14610744578063c267621e1461074d578063c47590e41461075e57600080fd5b8063a5900c4d146106cd578063b187bd261461072757600080fd5b806390333ba81161013a578063a0c3774f1161011f578063a0c3774f14610674578063a2c4564414610687578063a33741771461069a57600080fd5b806390333ba8146106425780639eebe7cd1461065557600080fd5b80638456cb591161016b5780638456cb5914610614578063849f94151461061c5780638a5215861461062f57600080fd5b80637125590a146105ee57806383f3084f1461060157600080fd5b8063423a4b401161023f57806351a424b1116101f357806363560086116101cd578063635600861461056657806363e133bc146105795780636aacaad8146105a257600080fd5b806351a424b1146104e75780635670e2ce1461051f5780635ea54eee1461053a57600080fd5b8063445780991161022457806344578099146104745780634a45a3a81461049f5780634fd49efd146104d457600080fd5b8063423a4b401461044757806342d4693e1461045a57600080fd5b80632384c32d1161029657806330eae5721161027b57806330eae572146104195780633b191c971461042c5780633f4ba83a1461043f57600080fd5b80632384c32d146103f35780632be5f0c71461040657600080fd5b8063119a5e96116102c7578063119a5e961461030b578063219723841461033c578063221a8c681461034f57600080fd5b80630fe105e8146102e357806310188aef146102f8575b600080fd5b6102f66102f1366004614389565b6107e9565b005b6102f66103063660046143e2565b610822565b61031361084f565b6040805160ff909516855260208501939093529183015260608201526080015b60405180910390f35b6102f661034a36600461457e565b610886565b6103c161035d3660046143e2565b6001600160a01b039081166000908152601b6020908152604091829020825160a08101845281549094168085526001820154928501839052600282015493850184905260038201546060860181905260049092015460809095018590529491939091565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a001610333565b6102f6610401366004614642565b610936565b6102f6610414366004614688565b610965565b6102f66104273660046146d0565b610990565b6102f661043a366004614b1a565b6109cd565b6102f6610af3565b6102f6610455366004614642565b610b7a565b600f546104679060ff1681565b6040516103339190614c3f565b6104876104823660046143e2565b610ba9565b6040516001600160a01b039091168152602001610333565b6104c67fd961d2c576a822c4229dd095af018f3639ff977b0c392c14be8e47ff0a93e02f81565b604051908152602001610333565b600154610487906001600160a01b031681565b6104fa6104f53660046143e2565b610be6565b604080516001600160a01b039094168452602084019290925290820152606001610333565b60025460035460408051928352602083019190915201610333565b600654600754600854600954604080519485526020850193909352918301526060820152608001610333565b6102f66105743660046143e2565b610c0f565b6104876105873660046143e2565b601f602052600090815260409020546001600160a01b031681565b6103c16040805160a0810182526016546001600160a01b03168082526017546020830181905260185493830184905260195460608401819052601a546080909401849052919490939290565b6102f66105fc366004614c67565b610c38565b601c54610487906001600160a01b031681565b6102f6610c63565b6102f661062a366004614cb1565b610cd5565b601d54610487906001600160a01b031681565b6102f6610650366004614d52565b610e81565b6104c66106633660046143e2565b602080526000908152604090205481565b6104c66106823660046143e2565b610eb4565b6102f6610695366004614d87565b610f4b565b6104fa604080516060810182526012546001600160a01b0316808252601354602083018190526014549290930182905292565b6104fa6106db3660046143e2565b6001600160a01b03808216600090815260156020908152604091829020825160608101845281549094168085526001820154928501839052600290910154939092018390529093909250565b6004546107349060ff1681565b6040519015158152602001610333565b6104c6601e5481565b6001546001600160a01b0316610487565b6102f661076c366004614da0565b610f74565b600054610487906201000090046001600160a01b031681565b6102f6610798366004614d52565b610f9f565b6103c16107ab3660046143e2565b610fcc565b6104c66107be3660046143e2565b61103b565b6102f66107d1366004614dcc565b611069565b6107346107e43660046143e2565b611098565b6107f88460ff168484846110cd565b61080f336000356001600160e01b03191683611178565b61081b858585856111bf565b5050505050565b61082b81611464565b610842336000356001600160e01b03191683611178565b61084b82611478565b5050565b600a5460009081908190819060ff16600281111561086f5761086f614c29565b600b54600c54600e54935093509350935090919293565b61089c336000356001600160e01b031916611502565b80518251146108d7576040517f5d32021a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109315761091f8382815181106108f8576108f8614dfe565b602002602001015183838151811061091257610912614dfe565b602002602001015161151e565b8061092981614e2a565b9150506108da565b505050565b610942848484846115c8565b610959336000356001600160e01b03191683611178565b61081b85858585611631565b61096f82826116ea565b610986336000356001600160e01b03191683611178565b6109318383611762565b6109ad8160018111156109a5576109a5614c29565b60ff166117e9565b6109c4336000356001600160e01b03191683611178565b61084b82611830565b600054610100900460ff16158080156109ed5750600054600160ff909116105b80610a075750303b158015610a07575060005460ff166001145b610a7e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff191660011790558015610aa1576000805461ff0019166101001790555b610aaa8261188d565b801561084b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b610b09336000356001600160e01b031916611502565b60045460ff16610b45576040517f9e6558bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004805460ff191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d1693390600090a1565b610b86848484846115c8565b610b9d336000356001600160e01b03191683611178565b61081b858585856118fd565b6001600160a01b038082166000908152601f60205260408120549091168015610bd25780610bdf565b601d546001600160a01b03165b9392505050565b600080600080610bf5856119bd565b805160208201516040909201519097919650945092505050565b610c1881611464565b610c2f336000356001600160e01b03191683611178565b61084b82611a48565b610c428282611a92565b610c59336000356001600160e01b03191683611178565b6109318383611aec565b610c79336000356001600160e01b031916611502565b60045460ff1615610c9d5760405163181e462560e31b815260040160405180910390fd5b6004805460ff191660011790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e75290600090a1565b610ce0848484611b6f565b610cf7336000356001600160e01b03191683611178565b83600003610d0b57610d0885610eb4565b93505b610d16858585611c01565b6000610d2186610ba9565b90506000610d2f8783611c0c565b90506000610d58610d4887670de0b6b3a7640000614e43565b610d528985611c18565b90611c18565b9050600063f48221a360e01b89858a858a604051602401610d7d959493929190614ea6565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990941693909317909252600154601c5492517f1cff79cd0000000000000000000000000000000000000000000000000000000081529193506000926001600160a01b0391821692631cff79cd92610e179216908690600401614ede565b6000604051808303816000875af1158015610e36573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5e9190810190614f00565b9050610e758a8a8a88610e7086611c8b565b611c98565b50505050505050505050565b610e8c838383611b6f565b610ea3336000356001600160e01b03191683611178565b610eae848484611ca5565b50505050565b6001546002546040517ebc489400000000000000000000000000000000000000000000000000000000815260048101919091526001600160a01b038381166024830152600092169062bc489490604401602060405180830381865afa158015610f21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f459190614f6e565b92915050565b610f54816117e9565b610f6b336000356001600160e01b03191683611178565b61084b82611cfb565b610f7e8282611d59565b610f95336000356001600160e01b03191683611178565b6109318383611db6565b610faa838383611b6f565b610fc1336000356001600160e01b03191683611178565b610eae848484611e50565b600080600080600080610fde87611eac565b6040805160a08101825282546001600160a01b031680825260018401546020830181905260028501549383018490526003850154606084018190526004909501546080909301839052909b909a5091985091965090945092505050565b6001600160a01b0381166000908152602080526040812054801561105f5780610bdf565b601e549392505050565b611075848484846110cd565b61108c336000356001600160e01b03191683611178565b61081b85858585611ee0565b6000806110a6601084611f7b565b90506001600f5460ff1660018111156110c1576110c1614c29565b14610f45578015610bdf565b60408051600480825260a0820190925260609160208201608080368337019050509050848160008151811061110457611104614dfe565b602002602001018181525050838160018151811061112457611124614dfe565b602002602001018181525050828160028151811061114457611144614dfe565b602002602001018181525050818160038151811061116457611164614dfe565b602002602001018181525050949350505050565b611183838383611f9d565b610931578282826040517f960c80da000000000000000000000000000000000000000000000000000000008152600401610a7593929190614fc2565b60ff84166112705760008111806111d65750600082115b1561126b57826000036112085760405163bea499cb60e01b815260ff8516600482015260248101849052604401610a75565b80158061121457508281115b1561123e57604051639e12fccf60e01b815260ff8516600482015260248101829052604401610a75565b8160000361126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b6113cd565b8260000361129d5760405163bea499cb60e01b815260ff8516600482015260248101849052604401610a75565b8015806112b557506112b26224ea0084614ff4565b81115b156112df57604051639e12fccf60e01b815260ff8516600482015260248101829052604401610a75565b8160000361130c57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b60001960ff85160161134e57601c61132383612033565b111561126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b60011960ff851601611396576113638261204a565b61136c83612033565b1461126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b6040517f33a738bc00000000000000000000000000000000000000000000000000000000815260ff85166004820152602401610a75565b8360ff1660028111156113e2576113e2614c29565b600a805460ff191660018360028111156113fe576113fe614c29565b0217905550600b839055600c829055600e8190556040805160ff8616815260208101859052908101839052606081018290527f182fd6fa2a8560221614c1396dd4fcc78d26dfacf821a6afb61d25876057e412906080015b60405180910390a150505050565b6060610f45826001600160a01b03166117e9565b6001600160a01b0381166114b8576040517f05579e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601c80546001600160a01b0319166001600160a01b0383169081179091556040517f47fc0d82886e91fbb050eba4ff32c0c0d7fa2b4efffceba283e42975d9c894ff90600090a250565b60408051600081526020810190915261084b9083908390611178565b6001600160a01b03821661155e576040517fc41a13ec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806115735761156e60108361206d565b61157e565b61157e601083612082565b50816001600160a01b03167f6264362e9de26efefda321dfaeb4e4a9090deef40c5435fad8e9e2e306889a1c826040516115bc911515815260200190565b60405180910390a25050565b60408051600480825260a0820190925260609160208201608080368337019050509050846001600160a01b03168160008151811061160857611608614dfe565b602002602001018181525050836001600160a01b03168160018151811061112457611124614dfe565b6001600160a01b038416611671576040517fe7ba3e4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260156020526040902061169590848484612097565b604080516001600160a01b03858116825260208201859052918101839052908516907ff099617c054d3a65e02a9c3b786f23cc03d5982bc7cfae84dff0408049cf17079060600160405180910390a250505050565b6040805160028082526060808301845292602083019080368337019050509050826001600160a01b03168160008151811061172757611727614dfe565b602002602001018181525050816001600160a01b03168160018151811061175057611750614dfe565b60200260200101818152505092915050565b6001600160a01b03821661178957604051636070789160e11b815260040160405180910390fd5b6001600160a01b038281166000818152601f602090815260409182902080546001600160a01b0319169486169485179055905192835290917fbc16ba530cb55504440780f3299eeddb2fa4e53e1c0157065dd7c3186acbe4f791016115bc565b60408051600180825281830190925260609160208083019080368337019050509050818160008151811061181f5761181f614dfe565b602002602001018181525050919050565b600f805482919060ff19166001838181111561184e5761184e614c29565b02179055507f216b6a9618d607ba436d0f2e17e9a83e70929adff805ac2385d67401360e551a816040516118829190614c3f565b60405180910390a150565b600054610100900460ff166118e65760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b80516118f190612167565b6118fa816121d6565b50565b6001600160a01b03841661193d576040517f1de0c9c700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0384166000908152601b602052604090206119619084848461222f565b826001600160a01b0316846001600160a01b03167f1b5c5e27ed5443e409bae85849d41d7bf12d5352e8fddb3728b6408f836e144884846040516119af929190918252602082015260400190565b60405180910390a350505050565b6119ea604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b6001600160a01b038083166000908152601560205260409020805490911615611a135780611a16565b60125b6040805160608101825282546001600160a01b0316815260018301546020820152600290920154908201529392505050565b601d80546001600160a01b0319166001600160a01b0383169081179091556040517fc602525ddc64aed298026bfa5d65c18e59363c878dfc0c2794cf734659975a4590600090a250565b60408051600280825260608083018452926020830190803683370190505090508260001c81600081518110611ac957611ac9614dfe565b6020026020010181815250508160001c8160018151811061175057611750614dfe565b8082148015611afa57508115155b15611b34576040517f0fb49edb00000000000000000000000000000000000000000000000000000000815260048101839052602401610a75565b60028290556003819055604051819083907ff950a929751d87db181a0a517df21bb3ecd433abba584594402db4b58a55483590600090a35050565b60408051600380825260808201909252606091602082018380368337019050509050836001600160a01b031681600081518110611bae57611bae614dfe565b6020026020010181815250508281600181518110611bce57611bce614dfe565b6020026020010181815250508181600281518110611bee57611bee614dfe565b6020026020010181815250509392505050565b61093183838361238e565b6000610bdf8383612495565b60008282028315801590611c3b575082848281611c3757611c3761500b565b0414155b15611c6357604051637472527d60e11b81526004810185905260248101849052604401610a75565b8015611c8057670de0b6b3a7640000600019820104600101611c83565b60005b949350505050565b6000610f45826000612694565b61081b85858585856126f1565b611cb2601684848461222f565b60408051838152602081018390526001600160a01b038516917f6324b5f18e615697a2b44f16d7a649deb0bbbc7cb09dad4c610306105730e7d9910160405180910390a2505050565b670de0b6b3a7640000811115611d245760405163c2b0b62d60e01b815260040160405180910390fd5b601e8190556040518181527f9d7fb23d29de0d70dcfe20a01c58666eefae48719fb87d134888f2aa0ceb8cf890602001611882565b6040805160028082526060808301845292602083019080368337019050509050826001600160a01b031681600081518110611d9657611d96614dfe565b602002602001018181525050818160018151811061175057611750614dfe565b6001600160a01b038216611ddd57604051636070789160e11b815260040160405180910390fd5b670de0b6b3a7640000811115611e065760405163c2b0b62d60e01b815260040160405180910390fd5b6001600160a01b0382166000818152602080805260409182902084905590518381527f25248fa26970dc87f28fbed41688b6d37840ba02ef39849728307257033f1ed391016115bc565b611e5d6012848484612097565b604080516001600160a01b0385168152602081018490529081018290527fa80953bdc344b2ebd0bcdd001a3418a8fd1b858bdecf12a4ba5a9366ad65d3459060600160405180910390a1505050565b6001600160a01b038082166000908152601b602052604081208054919290911615611ed75780610bdf565b60169392505050565b670de0b6b3a7640000811115611f22576040517fce57496100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60068490556007839055600882905560098190556040805185815260208101859052908101839052606081018290527f746dc5eb53c5de07c40b06d428506d6982ea10c423ac2875abfc44038927d69190608001611456565b6001600160a01b03811660009081526001830160205260408120541515610bdf565b600080546040517f28522895000000000000000000000000000000000000000000000000000000008152620100009091046001600160a01b031690632852289590611ff2908790309088908890600401615021565b602060405180830381865afa15801561200f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c839190615067565b6000611c836120456201518084615084565b612705565b6000808061205e6120456201518086615084565b5091509150611c8382826127a1565b6000610bdf836001600160a01b038416612827565b6000610bdf836001600160a01b038416612921565b60006001600160a01b0384161580156120ae575082155b80156120b8575081155b905060006001600160a01b038516158015906120dc57508215806120dc5750838310155b9050811580156120ea575080155b1561213a576040517fca1f04830000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810185905260448101849052606401610a75565b505083546001600160a01b0319166001600160a01b03939093169290921783556001830155600290910155565b600054610100900460ff166121c05760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6121cd8160a00151612970565b6118fa81612a1d565b600054610100900460ff166118fa5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b60006001600160a01b038416158015612246575082155b8015612250575081155b905060006001600160a01b0385161580159061226c5750600084115b80156122785750600083115b905081158015612286575080155b156122d6576040517ff5deb5dc0000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810185905260448101849052606401610a75565b600386018390556001860184905581156122fd576000600287018190556004870155612369565b8560040154600003612324576000600287015561231a8342615098565b6004870155612369565b85546001600160a01b03868116911614612369578554600090612350906001600160a01b031687611c0c565b60028801549091506123629082612b78565b6002880155505b505083546001600160a01b0319166001600160a01b0393909316929092179092555050565b6123988383612bd5565b6001600160a01b0383166123bf57604051636070789160e11b815260040160405180910390fd5b816000036123f9576040517f1463acbe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061240484610ba9565b6001600160a01b031603612444576040517f9a79b62c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061244f8461103b565b905080821115610eae576040517fb56ce4490000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610a75565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f91906150ab565b90506001600160a01b038116612560576001546040517f38d2baae0000000000000000000000000000000000000000000000000000000081526001600160a01b039091166004820152602401610a75565b600061256a612c1b565b905080516000146125fb57816001600160a01b031663355efdd961258d87612c9b565b61259687612c9b565b846040518463ffffffff1660e01b81526004016125b5939291906150c8565b602060405180830381865afa1580156125d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f69190614f6e565b61268b565b816001600160a01b031663ac41865a61261387612c9b565b61261c87612c9b565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015612667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268b9190614f6e565b95945050505050565b60006126a1826020615098565b835110156126e85782516040517f9b722da7000000000000000000000000000000000000000000000000000000008152610a75918491600401918252602082015260400190565b50016020015190565b6126fb8282612ccf565b61081b8585612d55565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f84605002816127625761276261500b565b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b600081600114806127b25750816003145b806127bd5750816005145b806127c85750816007145b806127d35750816008145b806127de575081600a145b806127e9575081600c145b156127f65750601f610f45565b816002146128065750601e610f45565b61280f83612d7d565b61281a57601c61281d565b601d5b60ff169392505050565b6000818152600183016020526040812054801561291057600061284b600183614e43565b855490915060009061285f90600190614e43565b90508181146128c457600086600001828154811061287f5761287f614dfe565b90600052602060002001549050808760000184815481106128a2576128a2614dfe565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806128d5576128d56150f4565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610f45565b6000915050610f45565b5092915050565b600081815260018301602052604081205461296857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f45565b506000610f45565b600054610100900460ff166129c95760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b80516129d490612db9565b6129dc612e89565b6129e98160200151612eec565b6129f68160400151612f4e565b612a038160600151612fb0565b612a108160800151613012565b6118f18160a00151613074565b600054610100900460ff16612a765760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051612a8190611478565b612a8e8160200151611a48565b612a9b8160400151611cfb565b60005b816060015151811015612b0957612af782606001518281518110612ac457612ac4614dfe565b60200260200101516000015183606001518381518110612ae657612ae6614dfe565b602002602001015160200151611762565b80612b0181614e2a565b915050612a9e565b5060005b81608001515181101561084b57612b6682608001518281518110612b3357612b33614dfe565b60200260200101516000015183608001518381518110612b5557612b55614dfe565b602002602001015160200151611db6565b80612b7081614e2a565b915050612b0d565b60008282028315801590612b9b575082848281612b9757612b9761500b565b0414155b15612bc357604051637472527d60e11b81526004810185905260248101849052604401610a75565b670de0b6b3a764000090049392505050565b612bdf82826130d6565b612be982826130e0565b612bf38282613104565b612bfd82826131f0565b612c0782826133df565b612c118282613429565b61084b8282613516565b60606000612c2761362c565b905036811115612c4557505060408051600081526020810190915290565b8067ffffffffffffffff811115612c5e57612c5e6143ff565b6040519080825280601f01601f191660200182016040528015612c88576020820181803683370190505b5091508060208236030360208401375090565b600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03831614612cc75781610f45565b610f45613647565b6003541561084b576001805460035460405163eb056bbb60e01b815260048101919091526001600160a01b03858116602483015260448201859052606482019390935291169063eb056bbb906084015b600060405180830381600087803b158015612d3957600080fd5b505af1158015612d4d573d6000803e3d6000fd5b505050505050565b612d5f82826136d3565b612d698282613775565b612d738282613797565b61084b82826139e1565b6000612d8a60048361510a565b158015612da05750612d9d60648361510a565b15155b80610f455750612db26101908361510a565b1592915050565b600054610100900460ff16612e125760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b612e8081600001516001600160a01b031663d09edf316040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e7b91906150ab565b613a0e565b6118fa81613a70565b600054610100900460ff16612ee25760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b612eea613afe565b565b600054610100900460ff16612f455760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613b57565b600054610100900460ff16612fa75760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613bcc565b600054610100900460ff166130095760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613c41565b600054610100900460ff1661306b5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613cef565b600054610100900460ff166130cd5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613dcd565b61084b8282613eab565b60045460ff161561084b5760405163181e462560e31b815260040160405180910390fd5b5a600555604080516080810182526006548082526007546020830152600854928201929092526009546060820152906000901580613143575081513a11155b9050806131885781516040517fcbb35eb70000000000000000000000000000000000000000000000000000000081523a60048201526024810191909152604401610a75565b602082015115610eae57600061319e483a614e43565b602084015190915081111580612d4d5760208401516040517f56e5387f000000000000000000000000000000000000000000000000000000008152610a75918491600401918252602082015260400190565b600a54600b54600c54600e5460ff909316924282111561322c5760405163013ce60b60e01b815242600482015260248101839052604401610a75565b600084600281111561324057613240614c29565b036132f9578260000361325557505050505050565b8060000361326f576132678342615098565b600d55612d4d565b600061327b8342614e43565b905060006132898583615084565b905060006132978683614ff4565b6132a19084614e43565b9050838111156132cd5760405163013ce60b60e01b815242600482015260248101869052604401610a75565b856132d9836001615098565b6132e39190614ff4565b6132ed9086615098565b600d5550612d4d915050565b814210158015613312575061330e8183615098565b4211155b15613321576132678284613efe565b6000600185600281111561333757613337614c29565b1461334a576133454261204a565b613353565b61335383612033565b905060006133618483613f96565b90508042101561338d5760405163013ce60b60e01b815242600482015260248101829052604401610a75565b60006133998483615098565b905042811080156133c65760405163013ce60b60e01b815242600482015260248101839052604401610a75565b6133d08388613efe565b600d5550505050505050505050565b6133e882611098565b61084b576040517f7a2410450000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610a75565b6000613434836119bd565b80519091506001600160a01b031661344b57505050565b6000836001600160a01b031682600001516001600160a01b0316146134875761348261347b858460000151611c0c565b8490612b78565b613489565b825b90506000826020015182101580156134b15750604083015115806134b1575082604001518211155b90508061081b578251602084015160408086015190517f7c63a4b00000000000000000000000000000000000000000000000000000000081526001600160a01b0390931660048401526024830185905260448301919091526064820152608401610a75565b600061352183611eac565b6040805160a08101825282546001600160a01b03168082526001840154602083015260028401549282019290925260038301546060820152600490920154608083015290915061357057505050565b6000836001600160a01b031682600001516001600160a01b0316146135a5576135a061347b858460000151611c0c565b6135a7565b825b90506000826080015142106135bd5760006135c3565b82604001515b6135cd9083615098565b9050826020015181111561081b57825160208401516040517fb8858d5d0000000000000000000000000000000000000000000000000000000081526001600160a01b039092166004830152602482015260448101829052606401610a75565b6000602436101561363d5750600090565b50601f1936013590565b600154604080517f17fcb39b00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b0316916317fcb39b9160048083019260209291908290030181865afa1580156136aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ce91906150ab565b905090565b60006136de83611eac565b80549091506001600160a01b03166136f557505050565b80546000906001600160a01b0385811691161461372b5781546137269061347b9086906001600160a01b0316611c0c565b61372d565b825b905081600401544210613756576000600283015560038201546137509042615098565b60048301555b8082600201600082825461376a9190615098565b909155505050505050565b600d54600003613783575050565b61378e600d54613fb5565b50506000600d55565b6005546000036137d3576040517f1f5b8fc600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516080810182526006548152600754602082015260085491810191909152600954606082015260005a60055461380c9190614e43565b9050600061381a3a83614ff4565b90506000836040015160001480613835575083604001518211155b90508061387f578184604001516040517faf258ef2000000000000000000000000000000000000000000000000000000008152600401610a75929190918252602082015260400190565b60006005556060840151158015906138975750600085115b15612d4d57600061396a306001600160a01b0316634fd49efd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061390391906150ab565b6001600160a01b03166317fcb39b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613940573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396491906150ab565b88611c0c565b905060006139788483611c18565b905060006139868289613fea565b905086606001518111156139d65760608701516040517f0297747f000000000000000000000000000000000000000000000000000000008152610a75918391600401918252602082015260400190565b505050505050505050565b6040517f68f46c45a243a0e9065a97649faf9a5afe1692f2679e650c2f853b9cd734cc0e90600090a15050565b600054610100900460ff16613a675760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa816140b3565b600054610100900460ff16613ac95760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051600180546001600160a01b0319166001600160a01b03909216919091179055602081015160408201516118fa9190611aec565b600054610100900460ff16612eea5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b600054610100900460ff16613bb05760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa8160000151826020015183604001518460600151611ee0565b600054610100900460ff16613c255760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81600001518260200151836040015184606001516111bf565b600054610100900460ff16613c9a5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051613ca590611830565b60005b81602001515181101561084b57613cdd82602001518281518110613cce57613cce614dfe565b6020026020010151600161151e565b80613ce781614e2a565b915050613ca8565b600054610100900460ff16613d485760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051805160208201516040830151613d61929190611e50565b60005b82602001515181101561093157600083602001518281518110613d8957613d89614dfe565b60200260200101519050600081602001519050613db88260000151826000015183602001518460400151611631565b50508080613dc590614e2a565b915050613d64565b600054610100900460ff16613e265760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051805160208201516040830151613e3f929190611ca5565b60005b82602001515181101561093157600083602001518281518110613e6757613e67614dfe565b60200260200101519050600081602001519050613e9682600001518260000151836020015184604001516118fd565b50508080613ea390614e2a565b915050613e42565b6002541561084b5760015460025460405163eb056bbb60e01b815260048101919091526001600160a01b03848116602483015260448201849052600060648301529091169063eb056bbb90608401612d1f565b600080600080613f0d8661414c565b919450925090506000613f208684615098565b90506000613f2f600c8361510a565b90506000613f3e600c84615084565b613f489087615098565b905060006002600a5460ff166002811115613f6557613f65614c29565b14613f705784613f7a565b613f7a82846127a1565b9050613f888a83858461416b565b9a9950505050505050505050565b6000806000613fa44261414c565b509150915061268b8583838761416b565b600c8190556040518181527ff90744bee56935ec5acc9de37b89c0c545298c667ee417bd9469e9c6836ad06490602001611882565b600081600003614026576040517fb8a2f92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260000361403657506000610f45565b670de0b6b3a7640000838102908482816140525761405261500b565b0414614094576040517fea7b49e60000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610a75565b8260018203816140a6576140a661500b565b0460010191505092915050565b600054610100900460ff1661410c5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b600080546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000808061415e620151808504612705565b9196909550909350915050565b600061268b84848461417c89614193565b6141858a6141b1565b61418e8b6141cd565b6141da565b6000806141a3620151808461510a565b9050610bdf610e1082615084565b6000806141c0610e108461510a565b9050610bdf603c82615084565b6000610f45603c8361510a565b6000816141e8603c85614ff4565b6141f4610e1087614ff4565b620151806142038b8b8b614236565b61420d9190614ff4565b6142179190615098565b6142219190615098565b61422b9190615098565b979650505050505050565b60006107b284101561424757600080fd5b838383600062253d8c60046064600c614261600e8861511e565b61426b919061513e565b6142778861132461516c565b614281919061516c565b61428b919061513e565b614296906003615194565b6142a0919061513e565b600c806142ae600e8861511e565b6142b8919061513e565b6142c390600c615194565b6142ce60028861511e565b6142d8919061511e565b6142e49061016f615194565b6142ee919061513e565b6004600c6142fd600e8961511e565b614307919061513e565b614313896112c061516c565b61431d919061516c565b614329906105b5615194565b614333919061513e565b61433f617d4b8761511e565b614349919061516c565b614353919061516c565b61435d919061511e565b614367919061511e565b98975050505050505050565b803560ff8116811461438457600080fd5b919050565b6000806000806080858703121561439f57600080fd5b6143a885614373565b966020860135965060408601359560600135945092505050565b6001600160a01b03811681146118fa57600080fd5b8035614384816143c2565b6000602082840312156143f457600080fd5b8135610bdf816143c2565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715614438576144386143ff565b60405290565b6040516080810167ffffffffffffffff81118282101715614438576144386143ff565b60405160c0810167ffffffffffffffff81118282101715614438576144386143ff565b6040516020810167ffffffffffffffff81118282101715614438576144386143ff565b604051601f8201601f1916810167ffffffffffffffff811182821017156144d0576144d06143ff565b604052919050565b600067ffffffffffffffff8211156144f2576144f26143ff565b5060051b60200190565b600082601f83011261450d57600080fd5b8135602061452261451d836144d8565b6144a7565b82815260059290921b8401810191818101908684111561454157600080fd5b8286015b84811015614565578035614558816143c2565b8352918301918301614545565b509695505050505050565b80151581146118fa57600080fd5b6000806040838503121561459157600080fd5b823567ffffffffffffffff808211156145a957600080fd5b6145b5868387016144fc565b93506020915081850135818111156145cc57600080fd5b85019050601f810186136145df57600080fd5b80356145ed61451d826144d8565b81815260059190911b8201830190838101908883111561460c57600080fd5b928401925b8284101561463357833561462481614570565b82529284019290840190614611565b80955050505050509250929050565b6000806000806080858703121561465857600080fd5b8435614663816143c2565b93506020850135614673816143c2565b93969395505050506040820135916060013590565b6000806040838503121561469b57600080fd5b82356146a6816143c2565b915060208301356146b6816143c2565b809150509250929050565b80356002811061438457600080fd5b6000602082840312156146e257600080fd5b610bdf826146c1565b600082601f8301126146fc57600080fd5b8135602061470c61451d836144d8565b82815260069290921b8401810191818101908684111561472b57600080fd5b8286015b8481101561456557604081890312156147485760008081fd5b614750614415565b813561475b816143c2565b81528185013561476a816143c2565b8186015283529183019160400161472f565b600082601f83011261478d57600080fd5b8135602061479d61451d836144d8565b82815260069290921b840181019181810190868411156147bc57600080fd5b8286015b8481101561456557604081890312156147d95760008081fd5b6147e1614415565b81356147ec816143c2565b815281850135858201528352918301916040016147c0565b60006060828403121561481657600080fd5b6040516060810181811067ffffffffffffffff82111715614839576148396143ff565b604052905080823561484a816143c2565b8082525060208301356020820152604083013560408201525092915050565b60006080828403121561487b57600080fd5b61488361443e565b90508135815260208201356020820152604082013560408201526060820135606082015292915050565b6000608082840312156148bf57600080fd5b6148c761443e565b90506148d282614373565b815260208201356020820152604082013560408201526060820135606082015292915050565b60006040828403121561490a57600080fd5b614912614415565b905061491d826146c1565b8152602082013567ffffffffffffffff81111561493957600080fd5b614945848285016144fc565b60208301525092915050565b60006080828403121561496357600080fd5b61496b614415565b90508135614978816143c2565b81526149878360208401614804565b602082015292915050565b600060808083850312156149a557600080fd5b6149ad614415565b91506149b98484614804565b8252606083013567ffffffffffffffff8111156149d557600080fd5b8301601f810185136149e657600080fd5b803560206149f661451d836144d8565b82815260079290921b83018101918181019088841115614a1557600080fd5b938201935b83851015614a3b57614a2c8986614951565b82529385019390820190614a1a565b808388015250505050505092915050565b60006101c08284031215614a5f57600080fd5b614a67614461565b9050614a738383614804565b8152614a828360608401614869565b6020820152614a948360e084016148ad565b604082015261016082013567ffffffffffffffff80821115614ab557600080fd5b614ac1858386016148f8565b6060840152610180840135915080821115614adb57600080fd5b614ae785838601614992565b60808401526101a0840135915080821115614b0157600080fd5b50614b0e84828501614992565b60a08301525092915050565b600060208284031215614b2c57600080fd5b813567ffffffffffffffff80821115614b4457600080fd5b9083019060208286031215614b5857600080fd5b614b60614484565b823582811115614b6f57600080fd5b929092019160c08387031215614b8457600080fd5b614b8c614461565b614b95846143d7565b8152614ba3602085016143d7565b602082015260408401356040820152606084013583811115614bc457600080fd5b614bd0888287016146eb565b606083015250608084013583811115614be857600080fd5b614bf48882870161477c565b60808301525060a084013583811115614c0c57600080fd5b614c1888828701614a4c565b60a083015250815295945050505050565b634e487b7160e01b600052602160045260246000fd5b6020810160028310614c6157634e487b7160e01b600052602160045260246000fd5b91905290565b60008060408385031215614c7a57600080fd5b50508035926020909101359150565b600067ffffffffffffffff821115614ca357614ca36143ff565b50601f01601f191660200190565b60008060008060808587031215614cc757600080fd5b8435614cd2816143c2565b93506020850135925060408501359150606085013567ffffffffffffffff811115614cfc57600080fd5b8501601f81018713614d0d57600080fd5b8035614d1b61451d82614c89565b818152886020838501011115614d3057600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b600080600060608486031215614d6757600080fd5b8335614d72816143c2565b95602085013595506040909401359392505050565b600060208284031215614d9957600080fd5b5035919050565b60008060408385031215614db357600080fd5b8235614dbe816143c2565b946020939093013593505050565b60008060008060808587031215614de257600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614e3c57614e3c614e14565b5060010190565b81810381811115610f4557610f45614e14565b60005b83811015614e71578181015183820152602001614e59565b50506000910152565b60008151808452614e92816020860160208601614e56565b601f01601f19169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261422b60a0830184614e7a565b6001600160a01b0383168152604060208201526000611c836040830184614e7a565b600060208284031215614f1257600080fd5b815167ffffffffffffffff811115614f2957600080fd5b8201601f81018413614f3a57600080fd5b8051614f4861451d82614c89565b818152856020838501011115614f5d57600080fd5b61268b826020830160208601614e56565b600060208284031215614f8057600080fd5b5051919050565b600081518084526020808501945080840160005b83811015614fb757815187529582019590820190600101614f9b565b509495945050505050565b6001600160a01b03841681526001600160e01b03198316602082015260606040820152600061268b6060830184614f87565b8082028115828204841417610f4557610f45614e14565b634e487b7160e01b600052601260045260246000fd5b60006001600160a01b0380871683528086166020840152506001600160e01b0319841660408301526080606083015261505d6080830184614f87565b9695505050505050565b60006020828403121561507957600080fd5b8151610bdf81614570565b6000826150935761509361500b565b500490565b80820180821115610f4557610f45614e14565b6000602082840312156150bd57600080fd5b8151610bdf816143c2565b60006001600160a01b0380861683528085166020840152506060604083015261268b6060830184614e7a565b634e487b7160e01b600052603160045260246000fd5b6000826151195761511961500b565b500690565b818103600083128015838313168383128216171561291a5761291a614e14565b60008261514d5761514d61500b565b600160ff1b82146000198414161561516757615167614e14565b500590565b808201828112600083128015821682158216171561518c5761518c614e14565b505092915050565b80820260008212600160ff1b841416156151b0576151b0614e14565b8181058314821517610f4557610f45614e1456fe496e697469616c697a61626c653a20636f6e7472616374206973206e6f742069a26469706673582212207ebc0965d39562de338c189c90e7078df656f793cbb9970d16e2cb0b8516f37a64736f6c63430008110033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102de5760003560e01c80637125590a11610186578063a5900c4d116100e3578063d09edf3111610097578063d86483e111610071578063d86483e1146107b0578063e6b5be98146107c3578063f9eaee0d146107d657600080fd5b8063d09edf3114610771578063d3feb6021461078a578063d45a76cf1461079d57600080fd5b8063b96e422c116100c8578063b96e422c14610744578063c267621e1461074d578063c47590e41461075e57600080fd5b8063a5900c4d146106cd578063b187bd261461072757600080fd5b806390333ba81161013a578063a0c3774f1161011f578063a0c3774f14610674578063a2c4564414610687578063a33741771461069a57600080fd5b806390333ba8146106425780639eebe7cd1461065557600080fd5b80638456cb591161016b5780638456cb5914610614578063849f94151461061c5780638a5215861461062f57600080fd5b80637125590a146105ee57806383f3084f1461060157600080fd5b8063423a4b401161023f57806351a424b1116101f357806363560086116101cd578063635600861461056657806363e133bc146105795780636aacaad8146105a257600080fd5b806351a424b1146104e75780635670e2ce1461051f5780635ea54eee1461053a57600080fd5b8063445780991161022457806344578099146104745780634a45a3a81461049f5780634fd49efd146104d457600080fd5b8063423a4b401461044757806342d4693e1461045a57600080fd5b80632384c32d1161029657806330eae5721161027b57806330eae572146104195780633b191c971461042c5780633f4ba83a1461043f57600080fd5b80632384c32d146103f35780632be5f0c71461040657600080fd5b8063119a5e96116102c7578063119a5e961461030b578063219723841461033c578063221a8c681461034f57600080fd5b80630fe105e8146102e357806310188aef146102f8575b600080fd5b6102f66102f1366004614389565b6107e9565b005b6102f66103063660046143e2565b610822565b61031361084f565b6040805160ff909516855260208501939093529183015260608201526080015b60405180910390f35b6102f661034a36600461457e565b610886565b6103c161035d3660046143e2565b6001600160a01b039081166000908152601b6020908152604091829020825160a08101845281549094168085526001820154928501839052600282015493850184905260038201546060860181905260049092015460809095018590529491939091565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a001610333565b6102f6610401366004614642565b610936565b6102f6610414366004614688565b610965565b6102f66104273660046146d0565b610990565b6102f661043a366004614b1a565b6109cd565b6102f6610af3565b6102f6610455366004614642565b610b7a565b600f546104679060ff1681565b6040516103339190614c3f565b6104876104823660046143e2565b610ba9565b6040516001600160a01b039091168152602001610333565b6104c67fd961d2c576a822c4229dd095af018f3639ff977b0c392c14be8e47ff0a93e02f81565b604051908152602001610333565b600154610487906001600160a01b031681565b6104fa6104f53660046143e2565b610be6565b604080516001600160a01b039094168452602084019290925290820152606001610333565b60025460035460408051928352602083019190915201610333565b600654600754600854600954604080519485526020850193909352918301526060820152608001610333565b6102f66105743660046143e2565b610c0f565b6104876105873660046143e2565b601f602052600090815260409020546001600160a01b031681565b6103c16040805160a0810182526016546001600160a01b03168082526017546020830181905260185493830184905260195460608401819052601a546080909401849052919490939290565b6102f66105fc366004614c67565b610c38565b601c54610487906001600160a01b031681565b6102f6610c63565b6102f661062a366004614cb1565b610cd5565b601d54610487906001600160a01b031681565b6102f6610650366004614d52565b610e81565b6104c66106633660046143e2565b602080526000908152604090205481565b6104c66106823660046143e2565b610eb4565b6102f6610695366004614d87565b610f4b565b6104fa604080516060810182526012546001600160a01b0316808252601354602083018190526014549290930182905292565b6104fa6106db3660046143e2565b6001600160a01b03808216600090815260156020908152604091829020825160608101845281549094168085526001820154928501839052600290910154939092018390529093909250565b6004546107349060ff1681565b6040519015158152602001610333565b6104c6601e5481565b6001546001600160a01b0316610487565b6102f661076c366004614da0565b610f74565b600054610487906201000090046001600160a01b031681565b6102f6610798366004614d52565b610f9f565b6103c16107ab3660046143e2565b610fcc565b6104c66107be3660046143e2565b61103b565b6102f66107d1366004614dcc565b611069565b6107346107e43660046143e2565b611098565b6107f88460ff168484846110cd565b61080f336000356001600160e01b03191683611178565b61081b858585856111bf565b5050505050565b61082b81611464565b610842336000356001600160e01b03191683611178565b61084b82611478565b5050565b600a5460009081908190819060ff16600281111561086f5761086f614c29565b600b54600c54600e54935093509350935090919293565b61089c336000356001600160e01b031916611502565b80518251146108d7576040517f5d32021a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109315761091f8382815181106108f8576108f8614dfe565b602002602001015183838151811061091257610912614dfe565b602002602001015161151e565b8061092981614e2a565b9150506108da565b505050565b610942848484846115c8565b610959336000356001600160e01b03191683611178565b61081b85858585611631565b61096f82826116ea565b610986336000356001600160e01b03191683611178565b6109318383611762565b6109ad8160018111156109a5576109a5614c29565b60ff166117e9565b6109c4336000356001600160e01b03191683611178565b61084b82611830565b600054610100900460ff16158080156109ed5750600054600160ff909116105b80610a075750303b158015610a07575060005460ff166001145b610a7e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff191660011790558015610aa1576000805461ff0019166101001790555b610aaa8261188d565b801561084b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b610b09336000356001600160e01b031916611502565b60045460ff16610b45576040517f9e6558bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004805460ff191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d1693390600090a1565b610b86848484846115c8565b610b9d336000356001600160e01b03191683611178565b61081b858585856118fd565b6001600160a01b038082166000908152601f60205260408120549091168015610bd25780610bdf565b601d546001600160a01b03165b9392505050565b600080600080610bf5856119bd565b805160208201516040909201519097919650945092505050565b610c1881611464565b610c2f336000356001600160e01b03191683611178565b61084b82611a48565b610c428282611a92565b610c59336000356001600160e01b03191683611178565b6109318383611aec565b610c79336000356001600160e01b031916611502565b60045460ff1615610c9d5760405163181e462560e31b815260040160405180910390fd5b6004805460ff191660011790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e75290600090a1565b610ce0848484611b6f565b610cf7336000356001600160e01b03191683611178565b83600003610d0b57610d0885610eb4565b93505b610d16858585611c01565b6000610d2186610ba9565b90506000610d2f8783611c0c565b90506000610d58610d4887670de0b6b3a7640000614e43565b610d528985611c18565b90611c18565b9050600063f48221a360e01b89858a858a604051602401610d7d959493929190614ea6565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990941693909317909252600154601c5492517f1cff79cd0000000000000000000000000000000000000000000000000000000081529193506000926001600160a01b0391821692631cff79cd92610e179216908690600401614ede565b6000604051808303816000875af1158015610e36573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5e9190810190614f00565b9050610e758a8a8a88610e7086611c8b565b611c98565b50505050505050505050565b610e8c838383611b6f565b610ea3336000356001600160e01b03191683611178565b610eae848484611ca5565b50505050565b6001546002546040517ebc489400000000000000000000000000000000000000000000000000000000815260048101919091526001600160a01b038381166024830152600092169062bc489490604401602060405180830381865afa158015610f21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f459190614f6e565b92915050565b610f54816117e9565b610f6b336000356001600160e01b03191683611178565b61084b82611cfb565b610f7e8282611d59565b610f95336000356001600160e01b03191683611178565b6109318383611db6565b610faa838383611b6f565b610fc1336000356001600160e01b03191683611178565b610eae848484611e50565b600080600080600080610fde87611eac565b6040805160a08101825282546001600160a01b031680825260018401546020830181905260028501549383018490526003850154606084018190526004909501546080909301839052909b909a5091985091965090945092505050565b6001600160a01b0381166000908152602080526040812054801561105f5780610bdf565b601e549392505050565b611075848484846110cd565b61108c336000356001600160e01b03191683611178565b61081b85858585611ee0565b6000806110a6601084611f7b565b90506001600f5460ff1660018111156110c1576110c1614c29565b14610f45578015610bdf565b60408051600480825260a0820190925260609160208201608080368337019050509050848160008151811061110457611104614dfe565b602002602001018181525050838160018151811061112457611124614dfe565b602002602001018181525050828160028151811061114457611144614dfe565b602002602001018181525050818160038151811061116457611164614dfe565b602002602001018181525050949350505050565b611183838383611f9d565b610931578282826040517f960c80da000000000000000000000000000000000000000000000000000000008152600401610a7593929190614fc2565b60ff84166112705760008111806111d65750600082115b1561126b57826000036112085760405163bea499cb60e01b815260ff8516600482015260248101849052604401610a75565b80158061121457508281115b1561123e57604051639e12fccf60e01b815260ff8516600482015260248101829052604401610a75565b8160000361126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b6113cd565b8260000361129d5760405163bea499cb60e01b815260ff8516600482015260248101849052604401610a75565b8015806112b557506112b26224ea0084614ff4565b81115b156112df57604051639e12fccf60e01b815260ff8516600482015260248101829052604401610a75565b8160000361130c57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b60001960ff85160161134e57601c61132383612033565b111561126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b60011960ff851601611396576113638261204a565b61136c83612033565b1461126b57604051635686bf5960e11b815260ff8516600482015260248101839052604401610a75565b6040517f33a738bc00000000000000000000000000000000000000000000000000000000815260ff85166004820152602401610a75565b8360ff1660028111156113e2576113e2614c29565b600a805460ff191660018360028111156113fe576113fe614c29565b0217905550600b839055600c829055600e8190556040805160ff8616815260208101859052908101839052606081018290527f182fd6fa2a8560221614c1396dd4fcc78d26dfacf821a6afb61d25876057e412906080015b60405180910390a150505050565b6060610f45826001600160a01b03166117e9565b6001600160a01b0381166114b8576040517f05579e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601c80546001600160a01b0319166001600160a01b0383169081179091556040517f47fc0d82886e91fbb050eba4ff32c0c0d7fa2b4efffceba283e42975d9c894ff90600090a250565b60408051600081526020810190915261084b9083908390611178565b6001600160a01b03821661155e576040517fc41a13ec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806115735761156e60108361206d565b61157e565b61157e601083612082565b50816001600160a01b03167f6264362e9de26efefda321dfaeb4e4a9090deef40c5435fad8e9e2e306889a1c826040516115bc911515815260200190565b60405180910390a25050565b60408051600480825260a0820190925260609160208201608080368337019050509050846001600160a01b03168160008151811061160857611608614dfe565b602002602001018181525050836001600160a01b03168160018151811061112457611124614dfe565b6001600160a01b038416611671576040517fe7ba3e4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260156020526040902061169590848484612097565b604080516001600160a01b03858116825260208201859052918101839052908516907ff099617c054d3a65e02a9c3b786f23cc03d5982bc7cfae84dff0408049cf17079060600160405180910390a250505050565b6040805160028082526060808301845292602083019080368337019050509050826001600160a01b03168160008151811061172757611727614dfe565b602002602001018181525050816001600160a01b03168160018151811061175057611750614dfe565b60200260200101818152505092915050565b6001600160a01b03821661178957604051636070789160e11b815260040160405180910390fd5b6001600160a01b038281166000818152601f602090815260409182902080546001600160a01b0319169486169485179055905192835290917fbc16ba530cb55504440780f3299eeddb2fa4e53e1c0157065dd7c3186acbe4f791016115bc565b60408051600180825281830190925260609160208083019080368337019050509050818160008151811061181f5761181f614dfe565b602002602001018181525050919050565b600f805482919060ff19166001838181111561184e5761184e614c29565b02179055507f216b6a9618d607ba436d0f2e17e9a83e70929adff805ac2385d67401360e551a816040516118829190614c3f565b60405180910390a150565b600054610100900460ff166118e65760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b80516118f190612167565b6118fa816121d6565b50565b6001600160a01b03841661193d576040517f1de0c9c700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0384166000908152601b602052604090206119619084848461222f565b826001600160a01b0316846001600160a01b03167f1b5c5e27ed5443e409bae85849d41d7bf12d5352e8fddb3728b6408f836e144884846040516119af929190918252602082015260400190565b60405180910390a350505050565b6119ea604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b6001600160a01b038083166000908152601560205260409020805490911615611a135780611a16565b60125b6040805160608101825282546001600160a01b0316815260018301546020820152600290920154908201529392505050565b601d80546001600160a01b0319166001600160a01b0383169081179091556040517fc602525ddc64aed298026bfa5d65c18e59363c878dfc0c2794cf734659975a4590600090a250565b60408051600280825260608083018452926020830190803683370190505090508260001c81600081518110611ac957611ac9614dfe565b6020026020010181815250508160001c8160018151811061175057611750614dfe565b8082148015611afa57508115155b15611b34576040517f0fb49edb00000000000000000000000000000000000000000000000000000000815260048101839052602401610a75565b60028290556003819055604051819083907ff950a929751d87db181a0a517df21bb3ecd433abba584594402db4b58a55483590600090a35050565b60408051600380825260808201909252606091602082018380368337019050509050836001600160a01b031681600081518110611bae57611bae614dfe565b6020026020010181815250508281600181518110611bce57611bce614dfe565b6020026020010181815250508181600281518110611bee57611bee614dfe565b6020026020010181815250509392505050565b61093183838361238e565b6000610bdf8383612495565b60008282028315801590611c3b575082848281611c3757611c3761500b565b0414155b15611c6357604051637472527d60e11b81526004810185905260248101849052604401610a75565b8015611c8057670de0b6b3a7640000600019820104600101611c83565b60005b949350505050565b6000610f45826000612694565b61081b85858585856126f1565b611cb2601684848461222f565b60408051838152602081018390526001600160a01b038516917f6324b5f18e615697a2b44f16d7a649deb0bbbc7cb09dad4c610306105730e7d9910160405180910390a2505050565b670de0b6b3a7640000811115611d245760405163c2b0b62d60e01b815260040160405180910390fd5b601e8190556040518181527f9d7fb23d29de0d70dcfe20a01c58666eefae48719fb87d134888f2aa0ceb8cf890602001611882565b6040805160028082526060808301845292602083019080368337019050509050826001600160a01b031681600081518110611d9657611d96614dfe565b602002602001018181525050818160018151811061175057611750614dfe565b6001600160a01b038216611ddd57604051636070789160e11b815260040160405180910390fd5b670de0b6b3a7640000811115611e065760405163c2b0b62d60e01b815260040160405180910390fd5b6001600160a01b0382166000818152602080805260409182902084905590518381527f25248fa26970dc87f28fbed41688b6d37840ba02ef39849728307257033f1ed391016115bc565b611e5d6012848484612097565b604080516001600160a01b0385168152602081018490529081018290527fa80953bdc344b2ebd0bcdd001a3418a8fd1b858bdecf12a4ba5a9366ad65d3459060600160405180910390a1505050565b6001600160a01b038082166000908152601b602052604081208054919290911615611ed75780610bdf565b60169392505050565b670de0b6b3a7640000811115611f22576040517fce57496100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60068490556007839055600882905560098190556040805185815260208101859052908101839052606081018290527f746dc5eb53c5de07c40b06d428506d6982ea10c423ac2875abfc44038927d69190608001611456565b6001600160a01b03811660009081526001830160205260408120541515610bdf565b600080546040517f28522895000000000000000000000000000000000000000000000000000000008152620100009091046001600160a01b031690632852289590611ff2908790309088908890600401615021565b602060405180830381865afa15801561200f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c839190615067565b6000611c836120456201518084615084565b612705565b6000808061205e6120456201518086615084565b5091509150611c8382826127a1565b6000610bdf836001600160a01b038416612827565b6000610bdf836001600160a01b038416612921565b60006001600160a01b0384161580156120ae575082155b80156120b8575081155b905060006001600160a01b038516158015906120dc57508215806120dc5750838310155b9050811580156120ea575080155b1561213a576040517fca1f04830000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810185905260448101849052606401610a75565b505083546001600160a01b0319166001600160a01b03939093169290921783556001830155600290910155565b600054610100900460ff166121c05760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6121cd8160a00151612970565b6118fa81612a1d565b600054610100900460ff166118fa5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b60006001600160a01b038416158015612246575082155b8015612250575081155b905060006001600160a01b0385161580159061226c5750600084115b80156122785750600083115b905081158015612286575080155b156122d6576040517ff5deb5dc0000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810185905260448101849052606401610a75565b600386018390556001860184905581156122fd576000600287018190556004870155612369565b8560040154600003612324576000600287015561231a8342615098565b6004870155612369565b85546001600160a01b03868116911614612369578554600090612350906001600160a01b031687611c0c565b60028801549091506123629082612b78565b6002880155505b505083546001600160a01b0319166001600160a01b0393909316929092179092555050565b6123988383612bd5565b6001600160a01b0383166123bf57604051636070789160e11b815260040160405180910390fd5b816000036123f9576040517f1463acbe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061240484610ba9565b6001600160a01b031603612444576040517f9a79b62c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061244f8461103b565b905080821115610eae576040517fb56ce4490000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610a75565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f91906150ab565b90506001600160a01b038116612560576001546040517f38d2baae0000000000000000000000000000000000000000000000000000000081526001600160a01b039091166004820152602401610a75565b600061256a612c1b565b905080516000146125fb57816001600160a01b031663355efdd961258d87612c9b565b61259687612c9b565b846040518463ffffffff1660e01b81526004016125b5939291906150c8565b602060405180830381865afa1580156125d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f69190614f6e565b61268b565b816001600160a01b031663ac41865a61261387612c9b565b61261c87612c9b565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015612667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268b9190614f6e565b95945050505050565b60006126a1826020615098565b835110156126e85782516040517f9b722da7000000000000000000000000000000000000000000000000000000008152610a75918491600401918252602082015260400190565b50016020015190565b6126fb8282612ccf565b61081b8585612d55565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f84605002816127625761276261500b565b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b600081600114806127b25750816003145b806127bd5750816005145b806127c85750816007145b806127d35750816008145b806127de575081600a145b806127e9575081600c145b156127f65750601f610f45565b816002146128065750601e610f45565b61280f83612d7d565b61281a57601c61281d565b601d5b60ff169392505050565b6000818152600183016020526040812054801561291057600061284b600183614e43565b855490915060009061285f90600190614e43565b90508181146128c457600086600001828154811061287f5761287f614dfe565b90600052602060002001549050808760000184815481106128a2576128a2614dfe565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806128d5576128d56150f4565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610f45565b6000915050610f45565b5092915050565b600081815260018301602052604081205461296857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f45565b506000610f45565b600054610100900460ff166129c95760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b80516129d490612db9565b6129dc612e89565b6129e98160200151612eec565b6129f68160400151612f4e565b612a038160600151612fb0565b612a108160800151613012565b6118f18160a00151613074565b600054610100900460ff16612a765760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051612a8190611478565b612a8e8160200151611a48565b612a9b8160400151611cfb565b60005b816060015151811015612b0957612af782606001518281518110612ac457612ac4614dfe565b60200260200101516000015183606001518381518110612ae657612ae6614dfe565b602002602001015160200151611762565b80612b0181614e2a565b915050612a9e565b5060005b81608001515181101561084b57612b6682608001518281518110612b3357612b33614dfe565b60200260200101516000015183608001518381518110612b5557612b55614dfe565b602002602001015160200151611db6565b80612b7081614e2a565b915050612b0d565b60008282028315801590612b9b575082848281612b9757612b9761500b565b0414155b15612bc357604051637472527d60e11b81526004810185905260248101849052604401610a75565b670de0b6b3a764000090049392505050565b612bdf82826130d6565b612be982826130e0565b612bf38282613104565b612bfd82826131f0565b612c0782826133df565b612c118282613429565b61084b8282613516565b60606000612c2761362c565b905036811115612c4557505060408051600081526020810190915290565b8067ffffffffffffffff811115612c5e57612c5e6143ff565b6040519080825280601f01601f191660200182016040528015612c88576020820181803683370190505b5091508060208236030360208401375090565b600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03831614612cc75781610f45565b610f45613647565b6003541561084b576001805460035460405163eb056bbb60e01b815260048101919091526001600160a01b03858116602483015260448201859052606482019390935291169063eb056bbb906084015b600060405180830381600087803b158015612d3957600080fd5b505af1158015612d4d573d6000803e3d6000fd5b505050505050565b612d5f82826136d3565b612d698282613775565b612d738282613797565b61084b82826139e1565b6000612d8a60048361510a565b158015612da05750612d9d60648361510a565b15155b80610f455750612db26101908361510a565b1592915050565b600054610100900460ff16612e125760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b612e8081600001516001600160a01b031663d09edf316040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e7b91906150ab565b613a0e565b6118fa81613a70565b600054610100900460ff16612ee25760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b612eea613afe565b565b600054610100900460ff16612f455760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613b57565b600054610100900460ff16612fa75760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613bcc565b600054610100900460ff166130095760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613c41565b600054610100900460ff1661306b5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613cef565b600054610100900460ff166130cd5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81613dcd565b61084b8282613eab565b60045460ff161561084b5760405163181e462560e31b815260040160405180910390fd5b5a600555604080516080810182526006548082526007546020830152600854928201929092526009546060820152906000901580613143575081513a11155b9050806131885781516040517fcbb35eb70000000000000000000000000000000000000000000000000000000081523a60048201526024810191909152604401610a75565b602082015115610eae57600061319e483a614e43565b602084015190915081111580612d4d5760208401516040517f56e5387f000000000000000000000000000000000000000000000000000000008152610a75918491600401918252602082015260400190565b600a54600b54600c54600e5460ff909316924282111561322c5760405163013ce60b60e01b815242600482015260248101839052604401610a75565b600084600281111561324057613240614c29565b036132f9578260000361325557505050505050565b8060000361326f576132678342615098565b600d55612d4d565b600061327b8342614e43565b905060006132898583615084565b905060006132978683614ff4565b6132a19084614e43565b9050838111156132cd5760405163013ce60b60e01b815242600482015260248101869052604401610a75565b856132d9836001615098565b6132e39190614ff4565b6132ed9086615098565b600d5550612d4d915050565b814210158015613312575061330e8183615098565b4211155b15613321576132678284613efe565b6000600185600281111561333757613337614c29565b1461334a576133454261204a565b613353565b61335383612033565b905060006133618483613f96565b90508042101561338d5760405163013ce60b60e01b815242600482015260248101829052604401610a75565b60006133998483615098565b905042811080156133c65760405163013ce60b60e01b815242600482015260248101839052604401610a75565b6133d08388613efe565b600d5550505050505050505050565b6133e882611098565b61084b576040517f7a2410450000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610a75565b6000613434836119bd565b80519091506001600160a01b031661344b57505050565b6000836001600160a01b031682600001516001600160a01b0316146134875761348261347b858460000151611c0c565b8490612b78565b613489565b825b90506000826020015182101580156134b15750604083015115806134b1575082604001518211155b90508061081b578251602084015160408086015190517f7c63a4b00000000000000000000000000000000000000000000000000000000081526001600160a01b0390931660048401526024830185905260448301919091526064820152608401610a75565b600061352183611eac565b6040805160a08101825282546001600160a01b03168082526001840154602083015260028401549282019290925260038301546060820152600490920154608083015290915061357057505050565b6000836001600160a01b031682600001516001600160a01b0316146135a5576135a061347b858460000151611c0c565b6135a7565b825b90506000826080015142106135bd5760006135c3565b82604001515b6135cd9083615098565b9050826020015181111561081b57825160208401516040517fb8858d5d0000000000000000000000000000000000000000000000000000000081526001600160a01b039092166004830152602482015260448101829052606401610a75565b6000602436101561363d5750600090565b50601f1936013590565b600154604080517f17fcb39b00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b0316916317fcb39b9160048083019260209291908290030181865afa1580156136aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ce91906150ab565b905090565b60006136de83611eac565b80549091506001600160a01b03166136f557505050565b80546000906001600160a01b0385811691161461372b5781546137269061347b9086906001600160a01b0316611c0c565b61372d565b825b905081600401544210613756576000600283015560038201546137509042615098565b60048301555b8082600201600082825461376a9190615098565b909155505050505050565b600d54600003613783575050565b61378e600d54613fb5565b50506000600d55565b6005546000036137d3576040517f1f5b8fc600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516080810182526006548152600754602082015260085491810191909152600954606082015260005a60055461380c9190614e43565b9050600061381a3a83614ff4565b90506000836040015160001480613835575083604001518211155b90508061387f578184604001516040517faf258ef2000000000000000000000000000000000000000000000000000000008152600401610a75929190918252602082015260400190565b60006005556060840151158015906138975750600085115b15612d4d57600061396a306001600160a01b0316634fd49efd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061390391906150ab565b6001600160a01b03166317fcb39b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613940573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396491906150ab565b88611c0c565b905060006139788483611c18565b905060006139868289613fea565b905086606001518111156139d65760608701516040517f0297747f000000000000000000000000000000000000000000000000000000008152610a75918391600401918252602082015260400190565b505050505050505050565b6040517f68f46c45a243a0e9065a97649faf9a5afe1692f2679e650c2f853b9cd734cc0e90600090a15050565b600054610100900460ff16613a675760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa816140b3565b600054610100900460ff16613ac95760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051600180546001600160a01b0319166001600160a01b03909216919091179055602081015160408201516118fa9190611aec565b600054610100900460ff16612eea5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b600054610100900460ff16613bb05760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa8160000151826020015183604001518460600151611ee0565b600054610100900460ff16613c255760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b6118fa81600001518260200151836040015184606001516111bf565b600054610100900460ff16613c9a5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051613ca590611830565b60005b81602001515181101561084b57613cdd82602001518281518110613cce57613cce614dfe565b6020026020010151600161151e565b80613ce781614e2a565b915050613ca8565b600054610100900460ff16613d485760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051805160208201516040830151613d61929190611e50565b60005b82602001515181101561093157600083602001518281518110613d8957613d89614dfe565b60200260200101519050600081602001519050613db88260000151826000015183602001518460400151611631565b50508080613dc590614e2a565b915050613d64565b600054610100900460ff16613e265760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b8051805160208201516040830151613e3f929190611ca5565b60005b82602001515181101561093157600083602001518281518110613e6757613e67614dfe565b60200260200101519050600081602001519050613e9682600001518260000151836020015184604001516118fd565b50508080613ea390614e2a565b915050613e42565b6002541561084b5760015460025460405163eb056bbb60e01b815260048101919091526001600160a01b03848116602483015260448201849052600060648301529091169063eb056bbb90608401612d1f565b600080600080613f0d8661414c565b919450925090506000613f208684615098565b90506000613f2f600c8361510a565b90506000613f3e600c84615084565b613f489087615098565b905060006002600a5460ff166002811115613f6557613f65614c29565b14613f705784613f7a565b613f7a82846127a1565b9050613f888a83858461416b565b9a9950505050505050505050565b6000806000613fa44261414c565b509150915061268b8583838761416b565b600c8190556040518181527ff90744bee56935ec5acc9de37b89c0c545298c667ee417bd9469e9c6836ad06490602001611882565b600081600003614026576040517fb8a2f92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260000361403657506000610f45565b670de0b6b3a7640000838102908482816140525761405261500b565b0414614094576040517fea7b49e60000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610a75565b8260018203816140a6576140a661500b565b0460010191505092915050565b600054610100900460ff1661410c5760405162461bcd60e51b815260206004820152602b60248201526000805160206151c583398151915260448201526a6e697469616c697a696e6760a81b6064820152608401610a75565b600080546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000808061415e620151808504612705565b9196909550909350915050565b600061268b84848461417c89614193565b6141858a6141b1565b61418e8b6141cd565b6141da565b6000806141a3620151808461510a565b9050610bdf610e1082615084565b6000806141c0610e108461510a565b9050610bdf603c82615084565b6000610f45603c8361510a565b6000816141e8603c85614ff4565b6141f4610e1087614ff4565b620151806142038b8b8b614236565b61420d9190614ff4565b6142179190615098565b6142219190615098565b61422b9190615098565b979650505050505050565b60006107b284101561424757600080fd5b838383600062253d8c60046064600c614261600e8861511e565b61426b919061513e565b6142778861132461516c565b614281919061516c565b61428b919061513e565b614296906003615194565b6142a0919061513e565b600c806142ae600e8861511e565b6142b8919061513e565b6142c390600c615194565b6142ce60028861511e565b6142d8919061511e565b6142e49061016f615194565b6142ee919061513e565b6004600c6142fd600e8961511e565b614307919061513e565b614313896112c061516c565b61431d919061516c565b614329906105b5615194565b614333919061513e565b61433f617d4b8761511e565b614349919061516c565b614353919061516c565b61435d919061511e565b614367919061511e565b98975050505050505050565b803560ff8116811461438457600080fd5b919050565b6000806000806080858703121561439f57600080fd5b6143a885614373565b966020860135965060408601359560600135945092505050565b6001600160a01b03811681146118fa57600080fd5b8035614384816143c2565b6000602082840312156143f457600080fd5b8135610bdf816143c2565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715614438576144386143ff565b60405290565b6040516080810167ffffffffffffffff81118282101715614438576144386143ff565b60405160c0810167ffffffffffffffff81118282101715614438576144386143ff565b6040516020810167ffffffffffffffff81118282101715614438576144386143ff565b604051601f8201601f1916810167ffffffffffffffff811182821017156144d0576144d06143ff565b604052919050565b600067ffffffffffffffff8211156144f2576144f26143ff565b5060051b60200190565b600082601f83011261450d57600080fd5b8135602061452261451d836144d8565b6144a7565b82815260059290921b8401810191818101908684111561454157600080fd5b8286015b84811015614565578035614558816143c2565b8352918301918301614545565b509695505050505050565b80151581146118fa57600080fd5b6000806040838503121561459157600080fd5b823567ffffffffffffffff808211156145a957600080fd5b6145b5868387016144fc565b93506020915081850135818111156145cc57600080fd5b85019050601f810186136145df57600080fd5b80356145ed61451d826144d8565b81815260059190911b8201830190838101908883111561460c57600080fd5b928401925b8284101561463357833561462481614570565b82529284019290840190614611565b80955050505050509250929050565b6000806000806080858703121561465857600080fd5b8435614663816143c2565b93506020850135614673816143c2565b93969395505050506040820135916060013590565b6000806040838503121561469b57600080fd5b82356146a6816143c2565b915060208301356146b6816143c2565b809150509250929050565b80356002811061438457600080fd5b6000602082840312156146e257600080fd5b610bdf826146c1565b600082601f8301126146fc57600080fd5b8135602061470c61451d836144d8565b82815260069290921b8401810191818101908684111561472b57600080fd5b8286015b8481101561456557604081890312156147485760008081fd5b614750614415565b813561475b816143c2565b81528185013561476a816143c2565b8186015283529183019160400161472f565b600082601f83011261478d57600080fd5b8135602061479d61451d836144d8565b82815260069290921b840181019181810190868411156147bc57600080fd5b8286015b8481101561456557604081890312156147d95760008081fd5b6147e1614415565b81356147ec816143c2565b815281850135858201528352918301916040016147c0565b60006060828403121561481657600080fd5b6040516060810181811067ffffffffffffffff82111715614839576148396143ff565b604052905080823561484a816143c2565b8082525060208301356020820152604083013560408201525092915050565b60006080828403121561487b57600080fd5b61488361443e565b90508135815260208201356020820152604082013560408201526060820135606082015292915050565b6000608082840312156148bf57600080fd5b6148c761443e565b90506148d282614373565b815260208201356020820152604082013560408201526060820135606082015292915050565b60006040828403121561490a57600080fd5b614912614415565b905061491d826146c1565b8152602082013567ffffffffffffffff81111561493957600080fd5b614945848285016144fc565b60208301525092915050565b60006080828403121561496357600080fd5b61496b614415565b90508135614978816143c2565b81526149878360208401614804565b602082015292915050565b600060808083850312156149a557600080fd5b6149ad614415565b91506149b98484614804565b8252606083013567ffffffffffffffff8111156149d557600080fd5b8301601f810185136149e657600080fd5b803560206149f661451d836144d8565b82815260079290921b83018101918181019088841115614a1557600080fd5b938201935b83851015614a3b57614a2c8986614951565b82529385019390820190614a1a565b808388015250505050505092915050565b60006101c08284031215614a5f57600080fd5b614a67614461565b9050614a738383614804565b8152614a828360608401614869565b6020820152614a948360e084016148ad565b604082015261016082013567ffffffffffffffff80821115614ab557600080fd5b614ac1858386016148f8565b6060840152610180840135915080821115614adb57600080fd5b614ae785838601614992565b60808401526101a0840135915080821115614b0157600080fd5b50614b0e84828501614992565b60a08301525092915050565b600060208284031215614b2c57600080fd5b813567ffffffffffffffff80821115614b4457600080fd5b9083019060208286031215614b5857600080fd5b614b60614484565b823582811115614b6f57600080fd5b929092019160c08387031215614b8457600080fd5b614b8c614461565b614b95846143d7565b8152614ba3602085016143d7565b602082015260408401356040820152606084013583811115614bc457600080fd5b614bd0888287016146eb565b606083015250608084013583811115614be857600080fd5b614bf48882870161477c565b60808301525060a084013583811115614c0c57600080fd5b614c1888828701614a4c565b60a083015250815295945050505050565b634e487b7160e01b600052602160045260246000fd5b6020810160028310614c6157634e487b7160e01b600052602160045260246000fd5b91905290565b60008060408385031215614c7a57600080fd5b50508035926020909101359150565b600067ffffffffffffffff821115614ca357614ca36143ff565b50601f01601f191660200190565b60008060008060808587031215614cc757600080fd5b8435614cd2816143c2565b93506020850135925060408501359150606085013567ffffffffffffffff811115614cfc57600080fd5b8501601f81018713614d0d57600080fd5b8035614d1b61451d82614c89565b818152886020838501011115614d3057600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b600080600060608486031215614d6757600080fd5b8335614d72816143c2565b95602085013595506040909401359392505050565b600060208284031215614d9957600080fd5b5035919050565b60008060408385031215614db357600080fd5b8235614dbe816143c2565b946020939093013593505050565b60008060008060808587031215614de257600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614e3c57614e3c614e14565b5060010190565b81810381811115610f4557610f45614e14565b60005b83811015614e71578181015183820152602001614e59565b50506000910152565b60008151808452614e92816020860160208601614e56565b601f01601f19169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261422b60a0830184614e7a565b6001600160a01b0383168152604060208201526000611c836040830184614e7a565b600060208284031215614f1257600080fd5b815167ffffffffffffffff811115614f2957600080fd5b8201601f81018413614f3a57600080fd5b8051614f4861451d82614c89565b818152856020838501011115614f5d57600080fd5b61268b826020830160208601614e56565b600060208284031215614f8057600080fd5b5051919050565b600081518084526020808501945080840160005b83811015614fb757815187529582019590820190600101614f9b565b509495945050505050565b6001600160a01b03841681526001600160e01b03198316602082015260606040820152600061268b6060830184614f87565b8082028115828204841417610f4557610f45614e14565b634e487b7160e01b600052601260045260246000fd5b60006001600160a01b0380871683528086166020840152506001600160e01b0319841660408301526080606083015261505d6080830184614f87565b9695505050505050565b60006020828403121561507957600080fd5b8151610bdf81614570565b6000826150935761509361500b565b500490565b80820180821115610f4557610f45614e14565b6000602082840312156150bd57600080fd5b8151610bdf816143c2565b60006001600160a01b0380861683528085166020840152506060604083015261268b6060830184614e7a565b634e487b7160e01b600052603160045260246000fd5b6000826151195761511961500b565b500690565b818103600083128015838313168383128216171561291a5761291a614e14565b60008261514d5761514d61500b565b600160ff1b82146000198414161561516757615167614e14565b500590565b808201828112600083128015821682158216171561518c5761518c614e14565b505092915050565b80820260008212600160ff1b841416156151b0576151b0614e14565b8181058314821517610f4557610f45614e1456fe496e697469616c697a61626c653a20636f6e7472616374206973206e6f742069a26469706673582212207ebc0965d39562de338c189c90e7078df656f793cbb9970d16e2cb0b8516f37a64736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.