Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
UniswapV3ExactInputAction
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {IERC20} from "@openzeppelin-contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol"; import {IUniversalRouter} from "@uniswap-universal-router/contracts/interfaces/IUniversalRouter.sol"; import {IUniswapV3Factory} from "@uniswap-v3-core/contracts/interfaces/IUniswapV3Factory.sol"; import {Commands} from "@uniswap-universal-router/contracts/libraries/Commands.sol"; import {InstructionLib} from "../libraries/Instruction.sol"; import {UniswapV3OracleParameters} from "./libraries/UniswapV3OracleParameters.sol"; import {Interval} from "./schedules/Interval.sol"; import {OtimFee} from "./fee-models/OtimFee.sol"; import {IAction} from "./interfaces/IAction.sol"; import { IUniswapV3ExactInputAction, INSTRUCTION_TYPEHASH, ARGUMENTS_TYPEHASH } from "./interfaces/IUniswapV3ExactInputAction.sol"; import {InvalidArguments, InsufficientBalance, UniswapV3PoolDoesNotExist} from "./errors/Errors.sol"; /// @title UniswapV3ExactInputAction /// @author Otim Labs, Inc. /// @notice an Action that swaps tokens using Uniswap V3 exact input contract UniswapV3ExactInputAction is IAction, IUniswapV3ExactInputAction, Interval, OtimFee { using SafeERC20 for IERC20; /// @notice the Uniswap UniversalRouter contract IUniversalRouter public immutable router; /// @notice the Uniswap V3 factory contract IUniswapV3Factory public immutable uniswapV3Factory; /// @notice the address of the WETH9 token contract address public immutable wethAddress; /// @notice the UniversalRouter commands to wrap ETH then swap WETH for a given ERC20 bytes public constant ETH_TO_ERC20_COMMANDS = abi.encodePacked(uint8(Commands.WRAP_ETH), uint8(Commands.V3_SWAP_EXACT_IN)); /// @notice the UniversalRouter commands to swap a given ERC20 to WETH then unwrap to ETH bytes public constant ERC20_TO_ETH_COMMANDS = abi.encodePacked(uint8(Commands.V3_SWAP_EXACT_IN), uint8(Commands.UNWRAP_WETH)); /// @notice the UniversalRouter command to swap a given ERC20 for another ERC20 bytes public constant ERC20_TO_ERC20_COMMAND = abi.encodePacked(uint8(Commands.V3_SWAP_EXACT_IN)); constructor( address routerAddress, address factoryAddress, address wethAddress_, address feeTokenRegistryAddress, address treasuryAddress, uint256 gasConstant_ ) OtimFee(feeTokenRegistryAddress, treasuryAddress, gasConstant_) { router = IUniversalRouter(routerAddress); uniswapV3Factory = IUniswapV3Factory(factoryAddress); // slither-disable-next-line missing-zero-check wethAddress = wethAddress_; } /// @inheritdoc IAction function argumentsHash(bytes calldata arguments) public pure returns (bytes32, bytes32) { return (INSTRUCTION_TYPEHASH, hash(abi.decode(arguments, (UniswapV3ExactInput)))); } /// @inheritdoc IUniswapV3ExactInputAction function hash(UniswapV3ExactInput memory arguments) public pure returns (bytes32) { return keccak256( abi.encode( ARGUMENTS_TYPEHASH, arguments.recipient, arguments.tokenIn, arguments.tokenOut, arguments.feeTier, arguments.amountIn, arguments.floorAmountOut, arguments.meanPriceLookBack, arguments.maxPriceDeviationBPS, hash(arguments.schedule), hash(arguments.fee) ) ); } /// @inheritdoc IAction function execute( InstructionLib.Instruction calldata instruction, InstructionLib.Signature calldata, InstructionLib.ExecutionState calldata executionState ) external override returns (bool) { // initial gas measurement for fee calculation uint256 startGas = gasleft(); // decode the arguments from the instruction UniswapV3ExactInput memory arguments = abi.decode(instruction.arguments, (UniswapV3ExactInput)); // check if this is the first execution if (executionState.executionCount == 0) { // make sure arguments are well-formed if ( arguments.tokenIn == arguments.tokenOut || arguments.recipient == address(0) || arguments.amountIn == 0 || arguments.meanPriceLookBack == 0 || arguments.maxPriceDeviationBPS == 0 ) { revert InvalidArguments(); } checkStart(arguments.schedule); } else { checkInterval(arguments.schedule, executionState.lastExecuted); } // if swapping from ETH, set the internal tokenIn to WETH address internalTokenIn = arguments.tokenIn == address(0) ? wethAddress : arguments.tokenIn; // if swapping to ETH, set the internal tokenOut to WETH address internalTokenOut = arguments.tokenOut == address(0) ? wethAddress : arguments.tokenOut; // get the Uniswap V3 pool address for the given token pair and fee tier address poolAddress = uniswapV3Factory.getPool(internalTokenIn, internalTokenOut, arguments.feeTier); // if the pool does not exist, revert if (poolAddress == address(0)) { revert UniswapV3PoolDoesNotExist(); } // calculate the minimum amount out with TWAP deviation uint256 minAmountOutWithTwapDeviation = UniswapV3OracleParameters.getMinAmountOutWithTwapDeviation( poolAddress, internalTokenIn, internalTokenOut, arguments.feeTier, arguments.amountIn, arguments.meanPriceLookBack, arguments.maxPriceDeviationBPS ); // if the calculated minAmountOutWithTwapDeviation is less than the floorAmountOut, use the floorAmountOut uint256 minAmountOut = minAmountOutWithTwapDeviation < arguments.floorAmountOut ? arguments.floorAmountOut : minAmountOutWithTwapDeviation; // initialize variable to hold amount of ETH to send to the UniversalRouter // slither-disable-next-line uninitialized-local uint256 ethValue; // initialize variables to hold UniversalRouter commands and inputs bytes memory commands; bytes[] memory inputs; // check if input token is ETH if (arguments.tokenIn == address(0)) { // check that the user has enough ETH for the swap if (address(this).balance < arguments.amountIn) { revert InsufficientBalance(); } // send amountIn ETH to the UniversalRouter ethValue = arguments.amountIn; // encode commands and inputs to wrap the ETH then swap WETH for the ERC20, commands = ETH_TO_ERC20_COMMANDS; inputs = getEthToErc20Inputs(arguments, minAmountOut); } else { // check that the user has enough of the ERC20 for the swap if (IERC20(arguments.tokenIn).balanceOf(address(this)) < arguments.amountIn) { revert InsufficientBalance(); } // transfer ERC20 tokens to the UniversalRouter IERC20(arguments.tokenIn).safeTransfer(address(router), arguments.amountIn); // check if output token is ETH if (arguments.tokenOut == address(0)) { // encode commands and inputs to swap ERC20 for WETH then unwrap the WETH commands = ERC20_TO_ETH_COMMANDS; inputs = getErc20ToEthInputs(arguments, minAmountOut); } else { // encode command and inputs to swap ERC20 for another ERC20 commands = ERC20_TO_ERC20_COMMAND; inputs = getErc20ToErc20Inputs(arguments, minAmountOut); } } // call the UniversalRouter with the encoded commands and inputs router.execute{value: ethValue}(commands, inputs, block.timestamp); // charge the fee chargeFee(startGas - gasleft(), arguments.fee); // this Action has no auto-deactivation paths return false; } /// @notice encodes the inputs for wrapping ETH then swapping WETH for an ERC20 /// @param arguments - the UniswapV3ExactInput struct /// @param minAmountOut - the minimum amount out to set for the swap /// @return inputs - the encoded UniversalRouter inputs function getEthToErc20Inputs(UniswapV3ExactInput memory arguments, uint256 minAmountOut) internal view returns (bytes[] memory inputs) { inputs = new bytes[](2); // input for wrapping ETH // (address recipient,uint256 amount) inputs[0] = abi.encode(address(router), arguments.amountIn); // input for swapping WETH for an ERC20 // (address recipient,uint256 amountIn,uint256 amountOutMinimum,bytes path,bool payWithPermit2) inputs[1] = abi.encode( arguments.recipient, arguments.amountIn, minAmountOut, abi.encodePacked(wethAddress, arguments.feeTier, arguments.tokenOut), false ); } /// @notice encodes the inputs for swapping an ERC20 for WETH then unwrapping the WETH /// @param arguments - the UniswapV3ExactInput struct /// @param minAmountOut - the minimum amount out to set for the swap /// @return inputs - the encoded UniversalRouter inputs function getErc20ToEthInputs(UniswapV3ExactInput memory arguments, uint256 minAmountOut) internal view returns (bytes[] memory inputs) { inputs = new bytes[](2); // input for swapping an ERC20 for WETH // (address recipient,uint256 amountIn,uint256 amountOutMinimum,bytes path,bool payWithPermit2) inputs[0] = abi.encode( address(router), arguments.amountIn, minAmountOut, abi.encodePacked(arguments.tokenIn, arguments.feeTier, wethAddress), false ); // input for unwrapping WETH to ETH // (address recipient,uint256 amountMin) inputs[1] = abi.encode(arguments.recipient, minAmountOut); } /// @notice encodes the inputs for swapping an ERC20 for another ERC20 /// @param arguments - the UniswapV3ExactInput struct /// @param minAmountOut - the minimum amount out to set for the swap /// @return inputs - the encoded UniversalRouter inputs function getErc20ToErc20Inputs(UniswapV3ExactInput memory arguments, uint256 minAmountOut) internal pure returns (bytes[] memory inputs) { inputs = new bytes[](1); // input for swapping an ERC20 for another ERC20 // (address recipient,uint256 amountIn,uint256 amountOutMinimum,bytes path,bool payWithPermit2) inputs[0] = abi.encode( arguments.recipient, arguments.amountIn, minAmountOut, abi.encodePacked(arguments.tokenIn, arguments.feeTier, arguments.tokenOut), false ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful. */ function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) { return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful. */ function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) { return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.24; interface IUniversalRouter { /// @notice Thrown when a required command has failed error ExecutionFailed(uint256 commandIndex, bytes message); /// @notice Thrown when attempting to send ETH directly to the contract error ETHNotAccepted(); /// @notice Thrown when executing commands with an expired deadline error TransactionDeadlinePassed(); /// @notice Thrown when attempting to execute commands and an incorrect number of inputs are provided error LengthMismatch(); // @notice Thrown when an address that isn't WETH tries to send ETH to the router without calldata error InvalidEthSender(); /// @notice Executes encoded commands along with provided inputs. Reverts if deadline has expired. /// @param commands A set of concatenated commands, each 1 byte in length /// @param inputs An array of byte strings containing abi encoded inputs for each command /// @param deadline The deadline by which the transaction must be executed function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.24; /// @title Commands /// @notice Command Flags used to decode commands library Commands { // Masks to extract certain bits of commands bytes1 internal constant FLAG_ALLOW_REVERT = 0x80; bytes1 internal constant COMMAND_TYPE_MASK = 0x3f; // Command Types. Maximum supported command at this moment is 0x3f. // The commands are executed in nested if blocks to minimise gas consumption // Command Types where value<=0x07, executed in the first nested-if block uint256 constant V3_SWAP_EXACT_IN = 0x00; uint256 constant V3_SWAP_EXACT_OUT = 0x01; uint256 constant PERMIT2_TRANSFER_FROM = 0x02; uint256 constant PERMIT2_PERMIT_BATCH = 0x03; uint256 constant SWEEP = 0x04; uint256 constant TRANSFER = 0x05; uint256 constant PAY_PORTION = 0x06; // COMMAND_PLACEHOLDER = 0x07; // Command Types where 0x08<=value<=0x0f, executed in the second nested-if block uint256 constant V2_SWAP_EXACT_IN = 0x08; uint256 constant V2_SWAP_EXACT_OUT = 0x09; uint256 constant PERMIT2_PERMIT = 0x0a; uint256 constant WRAP_ETH = 0x0b; uint256 constant UNWRAP_WETH = 0x0c; uint256 constant PERMIT2_TRANSFER_FROM_BATCH = 0x0d; uint256 constant BALANCE_CHECK_ERC20 = 0x0e; // COMMAND_PLACEHOLDER = 0x0f; // Command Types where 0x10<=value<=0x20, executed in the third nested-if block uint256 constant V4_SWAP = 0x10; uint256 constant V3_POSITION_MANAGER_PERMIT = 0x11; uint256 constant V3_POSITION_MANAGER_CALL = 0x12; uint256 constant V4_INITIALIZE_POOL = 0x13; uint256 constant V4_POSITION_MANAGER_CALL = 0x14; // COMMAND_PLACEHOLDER = 0x15 -> 0x20 // Command Types where 0x21<=value<=0x3f uint256 constant EXECUTE_SUB_PLAN = 0x21; // COMMAND_PLACEHOLDER for 0x22 to 0x3f }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {Constants} from "./Constants.sol"; /// @title InstructionLib /// @author Otim Labs, Inc. /// @notice a library defining the Instruction datatype and util functions library InstructionLib { /// @notice defines a signature struct Signature { uint8 v; bytes32 r; bytes32 s; } /// @notice defines the ExecutionState datatype /// @param deactivated - whether the Instruction has been deactivated /// @param executionCount - the number of times the Instruction has been executed /// @param lastExecuted - the unix timestamp of the last time the Instruction was executed struct ExecutionState { bool deactivated; uint120 executionCount; uint120 lastExecuted; } /// @notice defines the Instruction datatype /// @param salt - a number to ensure the uniqueness of the Instruction /// @param maxExecutions - the maximum number of times the Instruction can be executed /// @param action - the address of the Action contract to be executed /// @param arguments - the arguments to be passed to the Action contract struct Instruction { uint256 salt; uint256 maxExecutions; address action; bytes arguments; } /// @notice abi.encodes and hashes an Instruction struct to create a unique Instruction identifier /// @param instruction - an Instruction struct to hash /// @return instructionId - unique identifier for the Instruction function id(Instruction calldata instruction) internal pure returns (bytes32) { return keccak256(abi.encode(instruction)); } /// @notice calculates the EIP-712 hash for activating an Instruction /// @param instruction - an Instruction struct to hash /// @param domainSeparator - the EIP-712 domain separator for the verifying contract /// @return hash - EIP-712 hash for activating `instruction` function signingHash( Instruction calldata instruction, bytes32 domainSeparator, bytes32 instructionTypeHash, bytes32 argumentsHash ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( Constants.EIP712_PREFIX, domainSeparator, keccak256( abi.encode( instructionTypeHash, instruction.salt, instruction.maxExecutions, instruction.action, argumentsHash ) ) ) ); } /// @notice defines a deactivation instruction /// @param instructionId - the unique identifier of the Instruction to deactivate struct InstructionDeactivation { bytes32 instructionId; } /// @notice the EIP-712 type-hash for an InstructionDeactivation bytes32 public constant DEACTIVATION_TYPEHASH = keccak256("InstructionDeactivation(bytes32 instructionId)"); /// @notice calculates the EIP-712 hash for a InstructionDeactivation /// @param deactivation - an InstructionDeactivation struct to hash /// @param domainSeparator - the EIP-712 domain separator for the verifying contract /// @return hash - EIP-712 hash for the `deactivation` function signingHash(InstructionDeactivation calldata deactivation, bytes32 domainSeparator) internal pure returns (bytes32) { return keccak256( abi.encodePacked( Constants.EIP712_PREFIX, domainSeparator, keccak256(abi.encode(DEACTIVATION_TYPEHASH, deactivation.instructionId)) ) ); } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {TickMath} from "@uniswap-v3-core/contracts/libraries/TickMath.sol"; import {FullMath} from "@uniswap-v3-core/contracts/libraries/FullMath.sol"; import {IUniswapV3Pool} from "@uniswap-v3-core/contracts/interfaces/IUniswapV3Pool.sol"; /// @title UniswapV3OracleParameters /// @author Otim Labs, Inc. /// @notice a library for calculating reasonable Uniswap V3 swap parameters based on recent price data library UniswapV3OracleParameters { /// @notice the number of basis points per unit uint256 public constant BPS_PER_UNIT = 10000; /// @notice the number of hundredth basis points per unit uint256 public constant HUNDREDTH_BPS_PER_UNIT = BPS_PER_UNIT * 100; /// @notice calculates a reasonable minAmountOut for a swap based on the recent mean price of the Uniswap V3 pool /// @param poolAddress - the address of the Uniswap V3 pool /// @param tokenIn - the address of the input token /// @param tokenOut - the address of the output token /// @param feeTier - the fee tier of the Uniswap V3 pool (in hundredth basis points) /// @param amountIn - the amount of tokenIn to swap /// @param meanPriceLookBack - the number of seconds to look back for calculating the mean price ratio /// @param maxPriceDeviationBPS - the maximum price deviation in basis points /// @return minAmountOut - the minimum amount of tokenOut to receive after the swap function getMinAmountOutWithTwapDeviation( address poolAddress, address tokenIn, address tokenOut, uint24 feeTier, uint256 amountIn, uint32 meanPriceLookBack, uint32 maxPriceDeviationBPS ) internal view returns (uint256 minAmountOut) { // get the mean sqrt ratio over the look back period uint256 meanSqrtRatioX96 = getMeanSqrtRatioX96(poolAddress, meanPriceLookBack); // square the mean sqrt ratio to get the mean ratio (in X192 format) uint256 meanRatioX192 = meanSqrtRatioX96 * meanSqrtRatioX96; // calculate the amountIn after the fee is deducted (feeTier is denominated in hundredth basis points) amountIn *= HUNDREDTH_BPS_PER_UNIT - feeTier; amountIn /= HUNDREDTH_BPS_PER_UNIT; // if zeroForOne, multiply amountIn by the mean ratio, otherwise divide amountIn by the mean ratio minAmountOut = tokenIn < tokenOut ? FullMath.mulDiv(amountIn, meanRatioX192, 1 << 192) : FullMath.mulDiv(amountIn, 1 << 192, meanRatioX192); // adjust the minAmountOut based on the user-defined maximum price deviation denominated in basis points minAmountOut *= BPS_PER_UNIT - maxPriceDeviationBPS; minAmountOut /= BPS_PER_UNIT; } /// @notice calculates the mean sqrt ratio X96 of a Uniswap V3 pool over a certain look back period /// @param poolAddress - the address of the Uniswap V3 pool /// @param meanPriceLookBack - the number of seconds to look back for calculating the mean price ratio /// @return meanSqrtRatioX96 - the mean sqrt ratio X96 of the Uniswap V3 pool over the look back period function getMeanSqrtRatioX96(address poolAddress, uint32 meanPriceLookBack) internal view returns (uint160 meanSqrtRatioX96) { // get cumulative tick data from the Uniswap V3 pool over the look back period uint32[] memory secondsAgos = new uint32[](2); secondsAgos[0] = meanPriceLookBack; secondsAgos[1] = 0; // slither-disable-next-line unused-return (int56[] memory tickCumulatives,) = IUniswapV3Pool(poolAddress).observe(secondsAgos); // calculate mean tick over look back period int56 tickDelta = tickCumulatives[1] - tickCumulatives[0]; int24 meanTick = int24(tickDelta / int32(meanPriceLookBack)); /// @dev round down if the tickDelta is negative and not divisible by meanPriceLookBack if (tickDelta < 0 && (tickDelta % int32(meanPriceLookBack) != 0)) meanTick--; // convert mean tick to mean sqrt price meanSqrtRatioX96 = TickMath.getSqrtRatioAtTick(meanTick); } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {IInterval, SCHEDULE_TYPEHASH} from "./interfaces/IInterval.sol"; /// @title Interval /// @author Otim Labs, Inc. /// @notice Interval schedule implementation abstract contract Interval is IInterval { /// @inheritdoc IInterval function hash(Schedule memory schedule) public pure returns (bytes32) { return keccak256( abi.encode(SCHEDULE_TYPEHASH, schedule.startAt, schedule.startBy, schedule.interval, schedule.timeout) ); } /// @inheritdoc IInterval function checkStart(Schedule memory schedule) public view override { if (block.timestamp < schedule.startAt) { revert ExecutionTooEarly(); } else if (schedule.startBy < block.timestamp && schedule.startBy != 0) { revert ExecutionTooLate(); } } /// @inheritdoc IInterval function checkInterval(Schedule memory schedule, uint256 lastExecuted) public view override { if (block.timestamp <= lastExecuted + schedule.interval) { revert ExecutionTooEarly(); } else if (lastExecuted + schedule.interval + schedule.timeout < block.timestamp && schedule.timeout != 0) { revert ExecutionTooLate(); } } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {IERC20} from "@openzeppelin-contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol"; import {IFeeTokenRegistry} from "../../infrastructure/interfaces/IFeeTokenRegistry.sol"; import {ITreasury} from "../../infrastructure/interfaces/ITreasury.sol"; import {IOtimFee, FEE_TYPEHASH} from "./interfaces/IOtimFee.sol"; /// @title OtimFee /// @author Otim Labs, Inc. /// @notice abstract contract for the Otim centralized fee model abstract contract OtimFee is IOtimFee { using SafeERC20 for IERC20; /// @notice the Otim fee token registry contract for converting wei to ERC20 tokens IFeeTokenRegistry public immutable feeTokenRegistry; /// @notice the Otim treasury contract that receives fees ITreasury public immutable treasury; /// @notice the gas constant used to calculate the fee uint256 public immutable gasConstant; constructor(address feeTokenRegistryAddress, address treasuryAddress, uint256 gasConstant_) { feeTokenRegistry = IFeeTokenRegistry(feeTokenRegistryAddress); treasury = ITreasury(treasuryAddress); gasConstant = gasConstant_; } /// @inheritdoc IOtimFee function hash(Fee memory fee) public pure returns (bytes32) { return keccak256( abi.encode(FEE_TYPEHASH, fee.token, fee.maxBaseFeePerGas, fee.maxPriorityFeePerGas, fee.executionFee) ); } /// @inheritdoc IOtimFee function chargeFee(uint256 gasUsed, Fee memory fee) public override { // fee.executionFee == 0 is a magic value signifying a sponsored Instruction if (fee.executionFee == 0) return; // check if the base fee is too high if (block.basefee > fee.maxBaseFeePerGas && fee.maxBaseFeePerGas != 0) { revert BaseFeePerGasTooHigh(); } // check if the priority fee is too high if (tx.gasprice - block.basefee > fee.maxPriorityFeePerGas) { revert PriorityFeePerGasTooHigh(); } // calculate the total cost of the gas used in the transaction uint256 weiGasCost = (gasUsed + gasConstant) * tx.gasprice; // if fee.token is address(0), the fee is paid in native currency if (fee.token == address(0)) { // calculate the fee cost based on the gas used and the additional fee uint256 weiTotalCost = weiGasCost + fee.executionFee; // check if the user has enough balance to pay the fee if (address(this).balance < weiTotalCost) { revert InsufficientFeeBalance(); } // transfer to the treasury contract // slither-disable-next-line arbitrary-send-eth treasury.deposit{value: weiTotalCost}(); } else { // calculate the fee cost based on the cost of the gas used (denominated in the fee token) and the execution fee uint256 tokenTotalCost = feeTokenRegistry.weiToToken(fee.token, weiGasCost) + fee.executionFee; // check if the user has enough balance to pay the fee if (IERC20(fee.token).balanceOf(address(this)) < tokenTotalCost) { revert InsufficientFeeBalance(); } // transfer to the treasury contract IERC20(fee.token).safeTransfer(address(treasury), tokenTotalCost); } } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {InstructionLib} from "../../libraries/Instruction.sol"; /// @title IAction /// @author Otim Labs, Inc. /// @notice interface for Action contracts interface IAction { /// @notice returns the EIP-712 type hash for the Action-specific Instruction and the EIP-712 hash of the Action-specific Instruction arguments /// @param arguments - encoded Instruction arguments /// @return instructionTypeHash - EIP-712 type hash for the Action-specific Instruction /// @return argumentsTypeHash - EIP-712 hash of the Action-specific Instruction arguments function argumentsHash(bytes calldata arguments) external returns (bytes32, bytes32); /// @notice execute Action logic with Instruction arguments /// @param instruction - Instruction /// @param signature - Signature over the Instruction signing hash /// @param executionState - ExecutionState /// @return deactivate - whether the Instruction should be automatically deactivated function execute( InstructionLib.Instruction calldata instruction, InstructionLib.Signature calldata signature, InstructionLib.ExecutionState calldata executionState ) external returns (bool); }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; import {IInterval} from "../schedules/interfaces/IInterval.sol"; import {IOtimFee} from "../fee-models/interfaces/IOtimFee.sol"; bytes32 constant INSTRUCTION_TYPEHASH = keccak256( "Instruction(uint256 salt,uint256 maxExecutions,address action,UniswapV3ExactInput uniswapV3ExactInput)Fee(address token,uint256 maxBaseFeePerGas,uint256 maxPriorityFeePerGas,uint256 executionFee)Schedule(uint256 startAt,uint256 startBy,uint256 interval,uint256 timeout)UniswapV3ExactInput(address recipient,address tokenIn,address tokenOut,uint24 feeTier,uint256 amountIn,uint256 floorAmountOut,uint32 meanPriceLookBack,uint32 maxPriceDeviationBPS,Schedule schedule,Fee fee)" ); bytes32 constant ARGUMENTS_TYPEHASH = keccak256( "UniswapV3ExactInput(address recipient,address tokenIn,address tokenOut,uint24 feeTier,uint256 amountIn,uint256 floorAmountOut,uint32 meanPriceLookBack,uint32 maxPriceDeviationBPS,Schedule schedule,Fee fee)Fee(address token,uint256 maxBaseFeePerGas,uint256 maxPriorityFeePerGas,uint256 executionFee)Schedule(uint256 startAt,uint256 startBy,uint256 interval,uint256 timeout)" ); /// @title IUniswapV3ExactInputAction /// @author Otim Labs, Inc. /// @notice interface for UniswapV3ExactInputAction contract interface IUniswapV3ExactInputAction is IInterval, IOtimFee { /// @notice arguments for the UniswapV3ExactInputAction contract /// @param recipient - the address to send tokenOut to /// @param tokenIn - the address of the input token /// @param tokenOut - the address of the output token /// @param feeTier - the fee tier for the Uniswap V3 pool /// @param amountIn - the amount of tokenIn to swap /// @param floorAmountOut - the absolute minimum amount of tokenOut to receive each time the swap is executed /// @param meanPriceLookBack - the number of seconds to look back for calculating the mean price /// @param maxPriceDeviationBPS - the maximum price deviation in basis points /// @param schedule - the schedule parameters for the swap /// @param fee - the fee Otim will charge for the swap struct UniswapV3ExactInput { address recipient; address tokenIn; address tokenOut; uint24 feeTier; uint256 amountIn; uint256 floorAmountOut; uint32 meanPriceLookBack; uint32 maxPriceDeviationBPS; Schedule schedule; Fee fee; } /// @notice calculates the EIP-712 hash of the UniswapV3ExactInput struct function hash(UniswapV3ExactInput memory uniswapV3ExactInput) external pure returns (bytes32); }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; error InvalidArguments(); error InsufficientBalance(); error BalanceOverThreshold(); error BalanceUnderThreshold(); error UniswapV3PoolDoesNotExist();
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; /// @title Constants /// @author Otim Labs, Inc. /// @notice a library defining constants used throughout the protocol library Constants { /// @notice the EIP-712 signature prefix bytes2 public constant EIP712_PREFIX = 0x1901; /// @notice the EIP-7702 delegation designator prefix bytes3 public constant EIP7702_PREFIX = 0xef0100; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { error T(); error R(); /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { unchecked { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); if (absTick > uint256(int256(MAX_TICK))) revert T(); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { unchecked { // second inequality must be < because the price can never reach the price at the max tick if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R(); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol'; import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol'; import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol'; import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol'; import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol'; import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol'; import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolErrors, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; bytes32 constant SCHEDULE_TYPEHASH = keccak256("Schedule(uint256 startAt,uint256 startBy,uint256 interval,uint256 timeout)"); /// @title IInterval /// @author Otim Labs, Inc. /// @notice interface for the Interval schedule interface IInterval { /// @notice interval schedule struct /// @param startAt - the timestamp the action can start at /// @param startBy - the timestamp the action must start by /// @param interval - the number of seconds between each execution /// @param timeout - the number of seconds after the interval the action can still be executed struct Schedule { uint256 startAt; uint256 startBy; uint256 interval; uint256 timeout; } /// @notice calculates the EIP-712 hash of the Schedule struct /// @param schedule - the schedule to hash /// @return hash - the EIP-712 hash of the Schedule function hash(Schedule memory schedule) external pure returns (bytes32); /// @notice checks the start time of the schedule /// @param schedule - the schedule to check function checkStart(Schedule memory schedule) external view; /// @notice checks the interval of the schedule /// @param schedule - the schedule to check /// @param lastExecuted - the last time the action was executed function checkInterval(Schedule memory schedule, uint256 lastExecuted) external view; error ExecutionTooEarly(); error ExecutionTooLate(); }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; /// @title FeeTokenRegistry /// @author Otim Labs, Inc. /// @notice interface for the FeeTokenRegistry contract interface IFeeTokenRegistry { /// @notice fee token data struct /// @param priceFeed - a price feed of the form <token>/ETH /// @param heartbeat - the time in seconds between price feed updates /// @param priceFeedDecimals - the number of decimals for the price feed /// @param tokenDecimals - the number of decimals for the token /// @param registered - whether the token is registered struct FeeTokenData { address priceFeed; uint40 heartbeat; uint8 priceFeedDecimals; uint8 tokenDecimals; bool registered; } /// @notice emitted when a fee token is added event FeeTokenAdded( address indexed token, address indexed priceFeed, uint40 heartbeat, uint8 priceFeedDecimals, uint8 tokenDecimals ); /// @notice emitted when a fee token is removed event FeeTokenRemoved( address indexed token, address indexed priceFeed, uint40 heartbeat, uint8 priceFeedDecimals, uint8 tokenDecimals ); error InvalidFeeTokenData(); error PriceFeedNotInitialized(); error FeeTokenAlreadyRegistered(); error FeeTokenNotRegistered(); error InvalidPrice(); error StalePrice(); /// @notice adds a fee token to the registry /// @param token - the ERC20 token address /// @param priceFeed - the price feed address /// @param heartbeat - the time in seconds between price feed updates function addFeeToken(address token, address priceFeed, uint40 heartbeat) external; /// @notice removes a fee token from the registry /// @param token - the ERC20 token address function removeFeeToken(address token) external; /// @notice converts a wei amount to a token amount /// @param token - the ERC20 token address to convert to /// @param weiAmount - the amount of wei to convert /// @return tokenAmount - converted token amount function weiToToken(address token, uint256 weiAmount) external view returns (uint256); }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; /// @title ITreasury /// @author Otim Labs, Inc. /// @notice interface for Treasury contract interface ITreasury { /// @notice thrown when the owner tries to withdraw to the zero address error InvalidTarget(); /// @notice thrown when the withdrawl fails error WithdrawalFailed(bytes result); /// @notice thrown when the owner tries to withdraw more than the contract balance error InsufficientBalance(); /// @notice deposit ether into the treasury function deposit() external payable; /// @notice withdraw ether from the treasury /// @param to - the address to withdraw to /// @param value - the amount to withdraw function withdraw(address to, uint256 value) external; /// @notice withdraw ERC20 tokens from the treasury /// @param token - the ERC20 token to withdraw /// @param to - the address to withdraw to /// @param value - the amount to withdraw function withdrawERC20(address token, address to, uint256 value) external; }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.26; bytes32 constant FEE_TYPEHASH = keccak256("Fee(address token,uint256 maxBaseFeePerGas,uint256 maxPriorityFeePerGas,uint256 executionFee)"); /// @title IOtimFee /// @author Otim Labs, Inc. /// @notice interface for the OtimFee contract interface IOtimFee { /// @notice fee struct /// @param token - the token to be used for the fee (address(0) for native currency) /// @param maxBaseFeePerGas - the maximum basefee per gas the user is willing to pay /// @param maxPriorityFeePerGas - the maximum priority fee per gas the user is willing to pay /// @param executionFee - fixed fee to be paid for each execution struct Fee { address token; uint256 maxBaseFeePerGas; uint256 maxPriorityFeePerGas; uint256 executionFee; } /// @notice calculates the EIP-712 hash of the Fee struct function hash(Fee memory fee) external pure returns (bytes32); /// @notice charges a fee for the Instruction execution /// @param gasUsed - amount of gas used during the Instruction execution /// @param fee - additional fee to be paid function chargeFee(uint256 gasUsed, Fee memory fee) external; error InsufficientFeeBalance(); error BaseFeePerGasTooHigh(); error PriorityFeePerGasTooHigh(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@chainlink-contracts/=dependencies/smartcontractkit-chainlink-2.22.0/contracts/", "@openzeppelin-contracts/=dependencies/@openzeppelin-contracts-5.3.0/", "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.3.0/", "@uniswap-universal-router/=dependencies/@uniswap-universal-router-2.0.0/", "@uniswap-v3-core/=dependencies/@uniswap-v3-core-1.0.2-solc-0.8-simulate/", "@uniswap-v3-periphery/=dependencies/@uniswap-v3-periphery-1.4.4/", "forge-std/=dependencies/forge-std-1.9.7/", "@openzeppelin-contracts-5.3.0/=dependencies/@openzeppelin-contracts-5.3.0/", "@uniswap-universal-router-2.0.0/=dependencies/@uniswap-universal-router-2.0.0/", "@uniswap-v3-core-1.0.2-solc-0.8-simulate/=dependencies/@uniswap-v3-core-1.0.2-solc-0.8-simulate/contracts/", "@uniswap-v3-periphery-1.4.4/=dependencies/@uniswap-v3-periphery-1.4.4/contracts/", "@uniswap/=dependencies/@uniswap-v3-periphery-1.4.4/node_modules/@uniswap/", "ds-test/=dependencies/@uniswap-universal-router-2.0.0/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=dependencies/@uniswap-universal-router-2.0.0/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-gas-snapshot/=dependencies/@uniswap-universal-router-2.0.0/lib/permit2/lib/forge-gas-snapshot/src/", "forge-std-1.9.7/=dependencies/forge-std-1.9.7/src/", "openzeppelin-contracts/=dependencies/@uniswap-universal-router-2.0.0/lib/permit2/lib/openzeppelin-contracts/", "permit2/=dependencies/@uniswap-universal-router-2.0.0/lib/permit2/", "smartcontractkit-chainlink-2.22.0/=dependencies/smartcontractkit-chainlink-2.22.0/", "solmate/=dependencies/@uniswap-universal-router-2.0.0/lib/solmate/src/", "v3-periphery/=dependencies/@uniswap-universal-router-2.0.0/lib/v3-periphery/contracts/", "v4-core/=dependencies/@uniswap-universal-router-2.0.0/lib/v4-periphery/lib/v4-core/src/", "v4-periphery/=dependencies/@uniswap-universal-router-2.0.0/lib/v4-periphery/" ], "optimizer": { "enabled": true, "runs": 1000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": false }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"routerAddress","type":"address"},{"internalType":"address","name":"factoryAddress","type":"address"},{"internalType":"address","name":"wethAddress_","type":"address"},{"internalType":"address","name":"feeTokenRegistryAddress","type":"address"},{"internalType":"address","name":"treasuryAddress","type":"address"},{"internalType":"uint256","name":"gasConstant_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BaseFeePerGasTooHigh","type":"error"},{"inputs":[],"name":"ExecutionTooEarly","type":"error"},{"inputs":[],"name":"ExecutionTooLate","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InsufficientFeeBalance","type":"error"},{"inputs":[],"name":"InvalidArguments","type":"error"},{"inputs":[],"name":"PriorityFeePerGasTooHigh","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"T","type":"error"},{"inputs":[],"name":"UniswapV3PoolDoesNotExist","type":"error"},{"inputs":[],"name":"ERC20_TO_ERC20_COMMAND","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ERC20_TO_ETH_COMMANDS","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_TO_ERC20_COMMANDS","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"arguments","type":"bytes"}],"name":"argumentsHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasUsed","type":"uint256"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"maxBaseFeePerGas","type":"uint256"},{"internalType":"uint256","name":"maxPriorityFeePerGas","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"internalType":"struct IOtimFee.Fee","name":"fee","type":"tuple"}],"name":"chargeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"startAt","type":"uint256"},{"internalType":"uint256","name":"startBy","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IInterval.Schedule","name":"schedule","type":"tuple"},{"internalType":"uint256","name":"lastExecuted","type":"uint256"}],"name":"checkInterval","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"startAt","type":"uint256"},{"internalType":"uint256","name":"startBy","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IInterval.Schedule","name":"schedule","type":"tuple"}],"name":"checkStart","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"maxExecutions","type":"uint256"},{"internalType":"address","name":"action","type":"address"},{"internalType":"bytes","name":"arguments","type":"bytes"}],"internalType":"struct InstructionLib.Instruction","name":"instruction","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct InstructionLib.Signature","name":"","type":"tuple"},{"components":[{"internalType":"bool","name":"deactivated","type":"bool"},{"internalType":"uint120","name":"executionCount","type":"uint120"},{"internalType":"uint120","name":"lastExecuted","type":"uint120"}],"internalType":"struct InstructionLib.ExecutionState","name":"executionState","type":"tuple"}],"name":"execute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeTokenRegistry","outputs":[{"internalType":"contract IFeeTokenRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasConstant","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint24","name":"feeTier","type":"uint24"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"floorAmountOut","type":"uint256"},{"internalType":"uint32","name":"meanPriceLookBack","type":"uint32"},{"internalType":"uint32","name":"maxPriceDeviationBPS","type":"uint32"},{"components":[{"internalType":"uint256","name":"startAt","type":"uint256"},{"internalType":"uint256","name":"startBy","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IInterval.Schedule","name":"schedule","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"maxBaseFeePerGas","type":"uint256"},{"internalType":"uint256","name":"maxPriorityFeePerGas","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"internalType":"struct IOtimFee.Fee","name":"fee","type":"tuple"}],"internalType":"struct IUniswapV3ExactInputAction.UniswapV3ExactInput","name":"arguments","type":"tuple"}],"name":"hash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"startAt","type":"uint256"},{"internalType":"uint256","name":"startBy","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IInterval.Schedule","name":"schedule","type":"tuple"}],"name":"hash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"maxBaseFeePerGas","type":"uint256"},{"internalType":"uint256","name":"maxPriorityFeePerGas","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"internalType":"struct IOtimFee.Fee","name":"fee","type":"tuple"}],"name":"hash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IUniversalRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"contract ITreasury","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV3Factory","outputs":[{"internalType":"contract IUniswapV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610140604052348015610010575f80fd5b506040516123b23803806123b283398101604081905261002f91610078565b6001600160a01b0392831660805290821660a05260c05292831660e0529082166101005216610120526100e1565b80516001600160a01b0381168114610073575f80fd5b919050565b5f805f805f8060c0878903121561008d575f80fd5b6100968761005d565b95506100a46020880161005d565b94506100b26040880161005d565b93506100c06060880161005d565b92506100ce6080880161005d565b915060a087015190509295509295509295565b60805160a05160c05160e051610100516101205161222f6101835f395f818161016b015281816105490152818161058d0152818161105e015261121c01525f81816101aa015261060301525f81816102dd01528181610807015281816108e501528181610ff401526111eb01525f818161011e0152610a7f01525f81816101d101528181610af60152610cc401525f81816102800152610bb3015261222f5ff3fe608060405234801561000f575f80fd5b5060043610610115575f3560e01c80639fcd91b3116100ad578063d607eb951161007d578063f4543ecd11610063578063f4543ecd146102d0578063f887ea40146102d8578063fd89ea0c146102ff575f80fd5b8063d607eb95146102aa578063d808980b146102bd575f80fd5b80639fcd91b31461023e578063adf9843614610266578063aebfab1b1461027b578063b7f9bc1d146102a2575f80fd5b806361d027b3116100e857806361d027b3146101cc57806369179de3146101f35780638dccf7b21461021657806399d0dd371461022b575f80fd5b80632cb0f8a21461011957806330137460146101535780634f0e0ef3146101665780635b549182146101a5575b5f80fd5b6101407f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b610140610161366004611b7c565b610312565b61018d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161014a565b61018d7f000000000000000000000000000000000000000000000000000000000000000081565b61018d7f000000000000000000000000000000000000000000000000000000000000000081565b610206610201366004611c50565b610402565b604051901515815260200161014a565b610229610224366004611cb0565b61097c565b005b610229610239366004611cca565b6109d5565b61025161024c366004611cf5565b610cf0565b6040805192835260208301919091520161014a565b61026e610d2e565b60405161014a9190611d91565b61018d7f000000000000000000000000000000000000000000000000000000000000000081565b61026e610d4d565b6101406102b8366004611cb0565b610d68565b6102296102cb366004611da3565b610dcf565b61026e610e4f565b61018d7f000000000000000000000000000000000000000000000000000000000000000081565b61014061030d366004611dcc565b610e6a565b5f7fa4ab0194b963377c2dff8699651fb7fb751af0eed5f7a0a26a5517ca5886e3d4825f015183602001518460400151856060015186608001518760a001518860c001518960e001516103698b6101000151610d68565b6103778c6101200151610e6a565b60408051602081019c909c526001600160a01b039a8b16908c015297891660608b015297909516608089015262ffffff90931660a088015260c087019190915260e086015263ffffffff90811661010086015216610120840152610140830191909152610160820152610180015b604051602081830303815290604052805190602001209050919050565b5f805a90505f6104156060870187611de6565b8101906104229190611b7c565b90506104346040850160208601611e29565b6effffffffffffffffffffffffffffff165f036104f85780604001516001600160a01b031681602001516001600160a01b0316148061047b575080516001600160a01b0316155b8061048857506080810151155b8061049b575060c081015163ffffffff16155b806104ae575060e081015163ffffffff16155b156104e5576040517f5f6f132c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104f381610100015161097c565b610528565b610100810151610528906105126060870160408801611e29565b6effffffffffffffffffffffffffffff16610dcf565b60208101515f906001600160a01b031615610547578160200151610569565b7f00000000000000000000000000000000000000000000000000000000000000005b60408301519091505f906001600160a01b03161561058b5782604001516105ad565b7f00000000000000000000000000000000000000000000000000000000000000005b60608401516040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152838116602483015262ffffff90921660448201529192505f917f000000000000000000000000000000000000000000000000000000000000000090911690631698ee8290606401602060405180830381865afa15801561064a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066e9190611e57565b90506001600160a01b0381166106b0576040517f9ae3f2ce00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106d0828585886060015189608001518a60c001518b60e00151610eda565b90505f8560a0015182106106e457816106ea565b8560a001515b90505f6060805f6001600160a01b031689602001516001600160a01b03160361077257886080015147101561073257604051631e9acf1760e31b815260040160405180910390fd5b6080890151604051600b60f81b60208201525f6021820152909350602201604051602081830303815290604052915061076b8985610fb6565b90506108b5565b608089015160208a01516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156107bf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e39190611e72565b101561080257604051631e9acf1760e31b815260040160405180910390fd5b6108487f00000000000000000000000000000000000000000000000000000000000000008a608001518b602001516001600160a01b031661113c9092919063ffffffff16565b60408901516001600160a01b031661088b576040515f6020820152600360fa1b6021820152602201604051602081830303815290604052915061076b89856111bc565b6040515f602082015260210160405160208183030381529060405291506108b28985611313565b90505b6040517f3593564c0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633593564c90859061092090869086904290600401611e89565b5f604051808303818588803b158015610937575f80fd5b505af1158015610949573d5f803e3d5ffd5b50505050506109675a61095c908c611f1b565b8a61012001516109d5565b5f9a50505050505050505050505b9392505050565b805142101561099e57604051637b8e04ab60e11b815260040160405180910390fd5b4281602001511080156109b45750602081015115155b156109d25760405163d05e9a0760e01b815260040160405180910390fd5b50565b80606001515f036109e4575050565b8060200151481180156109fa5750602081015115155b15610a31576040517f2f3d0a5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810151610a40483a611f1b565b1115610a78576040517f8ef482f600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f3a610aa47f000000000000000000000000000000000000000000000000000000000000000085611f34565b610aae9190611f47565b82519091506001600160a01b0316610b6a575f826060015182610ad19190611f34565b905080471015610af457604051637806a4f560e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004015f604051808303818588803b158015610b4d575f80fd5b505af1158015610b5f573d5f803e3d5ffd5b505050505050505050565b606082015182516040517fd251f7ba0000000000000000000000000000000000000000000000000000000081526001600160a01b039182166004820152602481018490525f92917f0000000000000000000000000000000000000000000000000000000000000000169063d251f7ba90604401602060405180830381865afa158015610bf8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c1c9190611e72565b610c269190611f34565b83516040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610c70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c949190611e72565b1015610cb357604051637806a4f560e11b815260040160405180910390fd5b8251610ce9906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008361113c565b505b505050565b5f807ff672ec087076e2e246d90899ddb0336232cc072c38023dbeb2414adc97674076610d2261016185870187611b7c565b915091505b9250929050565b6040515f60208201526021015b60405160208183030381529060405281565b6040515f6020820152600360fa1b6021820152602201610d3b565b5f7f6f697cbff83ca681149412207d4b9758e8c5bcdba5728b0b89301b116f85c830825f01518360200151846040015185606001516040516020016103e5959493929190948552602085019390935260408401919091526060830152608082015260a00190565b6040820151610dde9082611f34565b4211610dfd57604051637b8e04ab60e11b815260040160405180910390fd5b428260600151836040015183610e139190611f34565b610e1d9190611f34565b108015610e2d5750606082015115155b15610e4b5760405163d05e9a0760e01b815260040160405180910390fd5b5050565b604051600b60f81b60208201525f6021820152602201610d3b565b5f7f7aff6c7b9b8aafff555894be6cfd4a6211fc7adbcd97db18b05d4a51ed7482a0825f01518360200151846040015185606001516040516020016103e59594939291909485526001600160a01b0393909316602085015260408401919091526060830152608082015260a00190565b5f80610ee689856113fd565b6001600160a01b031690505f610efc8280611f47565b905062ffffff8716610f116127106064611f47565b610f1b9190611f1b565b610f259087611f47565b9550610f346127106064611f47565b610f3e9087611f72565b9550876001600160a01b0316896001600160a01b031610610f6d57610f6886600160c01b8361159d565b610f7c565b610f7c8682600160c01b61159d565b9250610f9063ffffffff8516612710611f1b565b610f9a9084611f47565b9250610fa861271084611f72565b9a9950505050505050505050565b6040805160028082526060828101909352816020015b6060815260200190600190039081610fcc579050506080840151604080516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016602082015290810191909152909150606001604051602081830303815290604052815f8151811061104757611047611f85565b6020026020010181905250825f01518360800151837f0000000000000000000000000000000000000000000000000000000000000000866060015187604001516040516020016110e793929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f1981840301815290829052611109949392915f90602001611f99565b6040516020818303038152906040528160018151811061112b5761112b611f85565b602002602001018190525092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610ceb908490611647565b6040805160028082526060828101909352816020015b60608152602001906001900390816111d25790505090507f0000000000000000000000000000000000000000000000000000000000000000836080015183856020015186606001517f000000000000000000000000000000000000000000000000000000000000000060405160200161129b93929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f19818403018152908290526112bd949392915f90602001611f99565b604051602081830303815290604052815f815181106112de576112de611f85565b6020026020010181905250825f0151826040516020016111099291906001600160a01b03929092168252602082015260400190565b604080516001808252818301909252606091816020015b606081526020019060019003908161132a579050509050825f01518360800151838560200151866060015187604001516040516020016113ba93929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f19818403018152908290526113dc949392915f90602001611f99565b604051602081830303815290604052815f8151811061112b5761112b611f85565b6040805160028082526060820183525f928392919060208301908036833701905050905082815f8151811061143457611434611f85565b602002602001019063ffffffff16908163ffffffff16815250505f8160018151811061146257611462611f85565b63ffffffff909216602092830291909101909101526040517f883bdbfd0000000000000000000000000000000000000000000000000000000081525f906001600160a01b0386169063883bdbfd906114be908590600401611fda565b5f60405180830381865afa1580156114d8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526114ff91908101906120b8565b5090505f815f8151811061151557611515611f85565b60200260200101518260018151811061153057611530611f85565b60200260200101516115429190612184565b90505f611553600387900b836121b1565b90505f8260060b1280156115765750611570600387900b836121ed565b60060b15155b1561158957806115858161220e565b9150505b611592816116d0565b979650505050505050565b5f80805f19858709858702925082811083820303915050805f036115d1575f84116115c6575f80fd5b508290049050610975565b8084116115dc575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f8060205f8451602086015f885af180611666576040513d5f823e3d81fd5b50505f513d9150811561167d57806001141561168a565b6001600160a01b0384163b155b15610ce9576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240160405180910390fd5b5f805f8360020b126116e5578260020b6116ec565b8260020b5f035b9050620d89e881111561172b576040517f2bc80f3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f816001165f0361174d5770010000000000000000000000000000000061175f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611793576ffff97272373d413259a46990580e213a0260801c5b60048216156117b2576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156117d1576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b60108216156117f0576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561180f576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561182e576fff2ea16466c96a3843ec78b326b528610260801c5b608082161561184d576ffe5dee046a99a2a811c461f1969c30530260801c5b61010082161561186d576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b61020082161561188d576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156118ad576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156118cd576fe7159475a2c29b7443b29c7fa6e889d90260801c5b6110008216156118ed576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561190d576fa9f746462d870fdf8a65dc1f90e061e50260801c5b61400082161561192d576f70d869a156d2a1b890bb3df62baf32f70260801c5b61800082161561194d576f31be135f97d08fd981231505542fcfa60260801c5b6201000082161561196e576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b6202000082161561198e576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156119ad576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156119ca576b048a170391f7dc42444e8fa20260801c5b5f8460020b13156119e957805f19816119e5576119e5611f5e565b0490505b6401000000008106156119fd5760016119ff565b5f5b60ff16602082901c0192505050919050565b634e487b7160e01b5f52604160045260245ffd5b6040516080810167ffffffffffffffff81118282101715611a4857611a48611a11565b60405290565b604051610140810167ffffffffffffffff81118282101715611a4857611a48611a11565b604051601f8201601f1916810167ffffffffffffffff81118282101715611a9b57611a9b611a11565b604052919050565b6001600160a01b03811681146109d2575f80fd5b8035611ac281611aa3565b919050565b803562ffffff81168114611ac2575f80fd5b803563ffffffff81168114611ac2575f80fd5b5f60808284031215611afc575f80fd5b611b04611a25565b8235815260208084013590820152604080840135908201526060928301359281019290925250919050565b5f60808284031215611b3f575f80fd5b611b47611a25565b90508135611b5481611aa3565b8152602082810135908201526040808301359082015260609182013591810191909152919050565b5f610200828403128015611b8e575f80fd5b50611b97611a4e565b611ba083611ab7565b8152611bae60208401611ab7565b6020820152611bbf60408401611ab7565b6040820152611bd060608401611ac7565b60608201526080838101359082015260a08084013590820152611bf560c08401611ad9565b60c0820152611c0660e08401611ad9565b60e0820152611c19846101008501611aec565b610100820152611c2d846101808501611b2f565b6101208201529392505050565b5f60608284031215611c4a575f80fd5b50919050565b5f805f60e08486031215611c62575f80fd5b833567ffffffffffffffff811115611c78575f80fd5b840160808187031215611c89575f80fd5b9250611c988560208601611c3a565b9150611ca78560808601611c3a565b90509250925092565b5f60808284031215611cc0575f80fd5b6109758383611aec565b5f8060a08385031215611cdb575f80fd5b82359150611cec8460208501611b2f565b90509250929050565b5f8060208385031215611d06575f80fd5b823567ffffffffffffffff811115611d1c575f80fd5b8301601f81018513611d2c575f80fd5b803567ffffffffffffffff811115611d42575f80fd5b856020828401011115611d53575f80fd5b6020919091019590945092505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6109756020830184611d63565b5f8060a08385031215611db4575f80fd5b611dbe8484611aec565b946080939093013593505050565b5f60808284031215611ddc575f80fd5b6109758383611b2f565b5f808335601e19843603018112611dfb575f80fd5b83018035915067ffffffffffffffff821115611e15575f80fd5b602001915036819003821315610d27575f80fd5b5f60208284031215611e39575f80fd5b81356effffffffffffffffffffffffffffff81168114610975575f80fd5b5f60208284031215611e67575f80fd5b815161097581611aa3565b5f60208284031215611e82575f80fd5b5051919050565b606081525f611e9b6060830186611d63565b828103602084015280855180835260208301915060208160051b840101602088015f5b83811015611ef057601f19868403018552611eda838351611d63565b6020958601959093509190910190600101611ebe565b505080945050505050826040830152949350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611f2e57611f2e611f07565b92915050565b80820180821115611f2e57611f2e611f07565b8082028115828204841417611f2e57611f2e611f07565b634e487b7160e01b5f52601260045260245ffd5b5f82611f8057611f80611f5e565b500490565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b038616815284602082015283604082015260a060608201525f611fc660a0830185611d63565b905082151560808301529695505050505050565b602080825282518282018190525f918401906040840190835b8181101561201757835163ffffffff16835260209384019390920191600101611ff3565b509095945050505050565b5f67ffffffffffffffff82111561203b5761203b611a11565b5060051b60200190565b5f82601f830112612054575f80fd5b815161206761206282612022565b611a72565b8082825260208201915060208360051b860101925085831115612088575f80fd5b602085015b838110156120ae5780516120a081611aa3565b83526020928301920161208d565b5095945050505050565b5f80604083850312156120c9575f80fd5b825167ffffffffffffffff8111156120df575f80fd5b8301601f810185136120ef575f80fd5b80516120fd61206282612022565b8082825260208201915060208360051b85010192508783111561211e575f80fd5b6020840193505b8284101561214e5783518060060b811461213d575f80fd5b825260209384019390910190612125565b80955050505050602083015167ffffffffffffffff81111561216e575f80fd5b61217a85828601612045565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715611f2e57611f2e611f07565b5f8160060b8360060b806121c7576121c7611f5e565b667fffffffffffff1982145f19821416156121e4576121e4611f07565b90059392505050565b5f8260060b806121ff576121ff611f5e565b808360060b0791505092915050565b5f8160020b627fffff19810361222657612226611f07565b5f1901929150505600000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a972a2c093456c7298c3527fc87de41f89a2ebae0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d000000000000000000000000000000000000000000000000000000000001a1f8
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610115575f3560e01c80639fcd91b3116100ad578063d607eb951161007d578063f4543ecd11610063578063f4543ecd146102d0578063f887ea40146102d8578063fd89ea0c146102ff575f80fd5b8063d607eb95146102aa578063d808980b146102bd575f80fd5b80639fcd91b31461023e578063adf9843614610266578063aebfab1b1461027b578063b7f9bc1d146102a2575f80fd5b806361d027b3116100e857806361d027b3146101cc57806369179de3146101f35780638dccf7b21461021657806399d0dd371461022b575f80fd5b80632cb0f8a21461011957806330137460146101535780634f0e0ef3146101665780635b549182146101a5575b5f80fd5b6101407f000000000000000000000000000000000000000000000000000000000001a1f881565b6040519081526020015b60405180910390f35b610140610161366004611b7c565b610312565b61018d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b03909116815260200161014a565b61018d7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b61018d7f0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d81565b610206610201366004611c50565b610402565b604051901515815260200161014a565b610229610224366004611cb0565b61097c565b005b610229610239366004611cca565b6109d5565b61025161024c366004611cf5565b610cf0565b6040805192835260208301919091520161014a565b61026e610d2e565b60405161014a9190611d91565b61018d7f000000000000000000000000a972a2c093456c7298c3527fc87de41f89a2ebae81565b61026e610d4d565b6101406102b8366004611cb0565b610d68565b6102296102cb366004611da3565b610dcf565b61026e610e4f565b61018d7f00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af81565b61014061030d366004611dcc565b610e6a565b5f7fa4ab0194b963377c2dff8699651fb7fb751af0eed5f7a0a26a5517ca5886e3d4825f015183602001518460400151856060015186608001518760a001518860c001518960e001516103698b6101000151610d68565b6103778c6101200151610e6a565b60408051602081019c909c526001600160a01b039a8b16908c015297891660608b015297909516608089015262ffffff90931660a088015260c087019190915260e086015263ffffffff90811661010086015216610120840152610140830191909152610160820152610180015b604051602081830303815290604052805190602001209050919050565b5f805a90505f6104156060870187611de6565b8101906104229190611b7c565b90506104346040850160208601611e29565b6effffffffffffffffffffffffffffff165f036104f85780604001516001600160a01b031681602001516001600160a01b0316148061047b575080516001600160a01b0316155b8061048857506080810151155b8061049b575060c081015163ffffffff16155b806104ae575060e081015163ffffffff16155b156104e5576040517f5f6f132c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104f381610100015161097c565b610528565b610100810151610528906105126060870160408801611e29565b6effffffffffffffffffffffffffffff16610dcf565b60208101515f906001600160a01b031615610547578160200151610569565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b60408301519091505f906001600160a01b03161561058b5782604001516105ad565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b60608401516040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152838116602483015262ffffff90921660448201529192505f917f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98490911690631698ee8290606401602060405180830381865afa15801561064a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066e9190611e57565b90506001600160a01b0381166106b0576040517f9ae3f2ce00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106d0828585886060015189608001518a60c001518b60e00151610eda565b90505f8560a0015182106106e457816106ea565b8560a001515b90505f6060805f6001600160a01b031689602001516001600160a01b03160361077257886080015147101561073257604051631e9acf1760e31b815260040160405180910390fd5b6080890151604051600b60f81b60208201525f6021820152909350602201604051602081830303815290604052915061076b8985610fb6565b90506108b5565b608089015160208a01516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156107bf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e39190611e72565b101561080257604051631e9acf1760e31b815260040160405180910390fd5b6108487f00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af8a608001518b602001516001600160a01b031661113c9092919063ffffffff16565b60408901516001600160a01b031661088b576040515f6020820152600360fa1b6021820152602201604051602081830303815290604052915061076b89856111bc565b6040515f602082015260210160405160208183030381529060405291506108b28985611313565b90505b6040517f3593564c0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af1690633593564c90859061092090869086904290600401611e89565b5f604051808303818588803b158015610937575f80fd5b505af1158015610949573d5f803e3d5ffd5b50505050506109675a61095c908c611f1b565b8a61012001516109d5565b5f9a50505050505050505050505b9392505050565b805142101561099e57604051637b8e04ab60e11b815260040160405180910390fd5b4281602001511080156109b45750602081015115155b156109d25760405163d05e9a0760e01b815260040160405180910390fd5b50565b80606001515f036109e4575050565b8060200151481180156109fa5750602081015115155b15610a31576040517f2f3d0a5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810151610a40483a611f1b565b1115610a78576040517f8ef482f600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f3a610aa47f000000000000000000000000000000000000000000000000000000000001a1f885611f34565b610aae9190611f47565b82519091506001600160a01b0316610b6a575f826060015182610ad19190611f34565b905080471015610af457604051637806a4f560e11b815260040160405180910390fd5b7f0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d6001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004015f604051808303818588803b158015610b4d575f80fd5b505af1158015610b5f573d5f803e3d5ffd5b505050505050505050565b606082015182516040517fd251f7ba0000000000000000000000000000000000000000000000000000000081526001600160a01b039182166004820152602481018490525f92917f000000000000000000000000a972a2c093456c7298c3527fc87de41f89a2ebae169063d251f7ba90604401602060405180830381865afa158015610bf8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c1c9190611e72565b610c269190611f34565b83516040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610c70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c949190611e72565b1015610cb357604051637806a4f560e11b815260040160405180910390fd5b8251610ce9906001600160a01b03167f0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d8361113c565b505b505050565b5f807ff672ec087076e2e246d90899ddb0336232cc072c38023dbeb2414adc97674076610d2261016185870187611b7c565b915091505b9250929050565b6040515f60208201526021015b60405160208183030381529060405281565b6040515f6020820152600360fa1b6021820152602201610d3b565b5f7f6f697cbff83ca681149412207d4b9758e8c5bcdba5728b0b89301b116f85c830825f01518360200151846040015185606001516040516020016103e5959493929190948552602085019390935260408401919091526060830152608082015260a00190565b6040820151610dde9082611f34565b4211610dfd57604051637b8e04ab60e11b815260040160405180910390fd5b428260600151836040015183610e139190611f34565b610e1d9190611f34565b108015610e2d5750606082015115155b15610e4b5760405163d05e9a0760e01b815260040160405180910390fd5b5050565b604051600b60f81b60208201525f6021820152602201610d3b565b5f7f7aff6c7b9b8aafff555894be6cfd4a6211fc7adbcd97db18b05d4a51ed7482a0825f01518360200151846040015185606001516040516020016103e59594939291909485526001600160a01b0393909316602085015260408401919091526060830152608082015260a00190565b5f80610ee689856113fd565b6001600160a01b031690505f610efc8280611f47565b905062ffffff8716610f116127106064611f47565b610f1b9190611f1b565b610f259087611f47565b9550610f346127106064611f47565b610f3e9087611f72565b9550876001600160a01b0316896001600160a01b031610610f6d57610f6886600160c01b8361159d565b610f7c565b610f7c8682600160c01b61159d565b9250610f9063ffffffff8516612710611f1b565b610f9a9084611f47565b9250610fa861271084611f72565b9a9950505050505050505050565b6040805160028082526060828101909352816020015b6060815260200190600190039081610fcc579050506080840151604080516001600160a01b037f00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af16602082015290810191909152909150606001604051602081830303815290604052815f8151811061104757611047611f85565b6020026020010181905250825f01518360800151837f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2866060015187604001516040516020016110e793929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f1981840301815290829052611109949392915f90602001611f99565b6040516020818303038152906040528160018151811061112b5761112b611f85565b602002602001018190525092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610ceb908490611647565b6040805160028082526060828101909352816020015b60608152602001906001900390816111d25790505090507f00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af836080015183856020015186606001517f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc260405160200161129b93929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f19818403018152908290526112bd949392915f90602001611f99565b604051602081830303815290604052815f815181106112de576112de611f85565b6020026020010181905250825f0151826040516020016111099291906001600160a01b03929092168252602082015260400190565b604080516001808252818301909252606091816020015b606081526020019060019003908161132a579050509050825f01518360800151838560200151866060015187604001516040516020016113ba93929190606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b60408051601f19818403018152908290526113dc949392915f90602001611f99565b604051602081830303815290604052815f8151811061112b5761112b611f85565b6040805160028082526060820183525f928392919060208301908036833701905050905082815f8151811061143457611434611f85565b602002602001019063ffffffff16908163ffffffff16815250505f8160018151811061146257611462611f85565b63ffffffff909216602092830291909101909101526040517f883bdbfd0000000000000000000000000000000000000000000000000000000081525f906001600160a01b0386169063883bdbfd906114be908590600401611fda565b5f60405180830381865afa1580156114d8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526114ff91908101906120b8565b5090505f815f8151811061151557611515611f85565b60200260200101518260018151811061153057611530611f85565b60200260200101516115429190612184565b90505f611553600387900b836121b1565b90505f8260060b1280156115765750611570600387900b836121ed565b60060b15155b1561158957806115858161220e565b9150505b611592816116d0565b979650505050505050565b5f80805f19858709858702925082811083820303915050805f036115d1575f84116115c6575f80fd5b508290049050610975565b8084116115dc575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f8060205f8451602086015f885af180611666576040513d5f823e3d81fd5b50505f513d9150811561167d57806001141561168a565b6001600160a01b0384163b155b15610ce9576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240160405180910390fd5b5f805f8360020b126116e5578260020b6116ec565b8260020b5f035b9050620d89e881111561172b576040517f2bc80f3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f816001165f0361174d5770010000000000000000000000000000000061175f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611793576ffff97272373d413259a46990580e213a0260801c5b60048216156117b2576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156117d1576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b60108216156117f0576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561180f576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561182e576fff2ea16466c96a3843ec78b326b528610260801c5b608082161561184d576ffe5dee046a99a2a811c461f1969c30530260801c5b61010082161561186d576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b61020082161561188d576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156118ad576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156118cd576fe7159475a2c29b7443b29c7fa6e889d90260801c5b6110008216156118ed576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561190d576fa9f746462d870fdf8a65dc1f90e061e50260801c5b61400082161561192d576f70d869a156d2a1b890bb3df62baf32f70260801c5b61800082161561194d576f31be135f97d08fd981231505542fcfa60260801c5b6201000082161561196e576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b6202000082161561198e576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156119ad576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156119ca576b048a170391f7dc42444e8fa20260801c5b5f8460020b13156119e957805f19816119e5576119e5611f5e565b0490505b6401000000008106156119fd5760016119ff565b5f5b60ff16602082901c0192505050919050565b634e487b7160e01b5f52604160045260245ffd5b6040516080810167ffffffffffffffff81118282101715611a4857611a48611a11565b60405290565b604051610140810167ffffffffffffffff81118282101715611a4857611a48611a11565b604051601f8201601f1916810167ffffffffffffffff81118282101715611a9b57611a9b611a11565b604052919050565b6001600160a01b03811681146109d2575f80fd5b8035611ac281611aa3565b919050565b803562ffffff81168114611ac2575f80fd5b803563ffffffff81168114611ac2575f80fd5b5f60808284031215611afc575f80fd5b611b04611a25565b8235815260208084013590820152604080840135908201526060928301359281019290925250919050565b5f60808284031215611b3f575f80fd5b611b47611a25565b90508135611b5481611aa3565b8152602082810135908201526040808301359082015260609182013591810191909152919050565b5f610200828403128015611b8e575f80fd5b50611b97611a4e565b611ba083611ab7565b8152611bae60208401611ab7565b6020820152611bbf60408401611ab7565b6040820152611bd060608401611ac7565b60608201526080838101359082015260a08084013590820152611bf560c08401611ad9565b60c0820152611c0660e08401611ad9565b60e0820152611c19846101008501611aec565b610100820152611c2d846101808501611b2f565b6101208201529392505050565b5f60608284031215611c4a575f80fd5b50919050565b5f805f60e08486031215611c62575f80fd5b833567ffffffffffffffff811115611c78575f80fd5b840160808187031215611c89575f80fd5b9250611c988560208601611c3a565b9150611ca78560808601611c3a565b90509250925092565b5f60808284031215611cc0575f80fd5b6109758383611aec565b5f8060a08385031215611cdb575f80fd5b82359150611cec8460208501611b2f565b90509250929050565b5f8060208385031215611d06575f80fd5b823567ffffffffffffffff811115611d1c575f80fd5b8301601f81018513611d2c575f80fd5b803567ffffffffffffffff811115611d42575f80fd5b856020828401011115611d53575f80fd5b6020919091019590945092505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6109756020830184611d63565b5f8060a08385031215611db4575f80fd5b611dbe8484611aec565b946080939093013593505050565b5f60808284031215611ddc575f80fd5b6109758383611b2f565b5f808335601e19843603018112611dfb575f80fd5b83018035915067ffffffffffffffff821115611e15575f80fd5b602001915036819003821315610d27575f80fd5b5f60208284031215611e39575f80fd5b81356effffffffffffffffffffffffffffff81168114610975575f80fd5b5f60208284031215611e67575f80fd5b815161097581611aa3565b5f60208284031215611e82575f80fd5b5051919050565b606081525f611e9b6060830186611d63565b828103602084015280855180835260208301915060208160051b840101602088015f5b83811015611ef057601f19868403018552611eda838351611d63565b6020958601959093509190910190600101611ebe565b505080945050505050826040830152949350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611f2e57611f2e611f07565b92915050565b80820180821115611f2e57611f2e611f07565b8082028115828204841417611f2e57611f2e611f07565b634e487b7160e01b5f52601260045260245ffd5b5f82611f8057611f80611f5e565b500490565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b038616815284602082015283604082015260a060608201525f611fc660a0830185611d63565b905082151560808301529695505050505050565b602080825282518282018190525f918401906040840190835b8181101561201757835163ffffffff16835260209384019390920191600101611ff3565b509095945050505050565b5f67ffffffffffffffff82111561203b5761203b611a11565b5060051b60200190565b5f82601f830112612054575f80fd5b815161206761206282612022565b611a72565b8082825260208201915060208360051b860101925085831115612088575f80fd5b602085015b838110156120ae5780516120a081611aa3565b83526020928301920161208d565b5095945050505050565b5f80604083850312156120c9575f80fd5b825167ffffffffffffffff8111156120df575f80fd5b8301601f810185136120ef575f80fd5b80516120fd61206282612022565b8082825260208201915060208360051b85010192508783111561211e575f80fd5b6020840193505b8284101561214e5783518060060b811461213d575f80fd5b825260209384019390910190612125565b80955050505050602083015167ffffffffffffffff81111561216e575f80fd5b61217a85828601612045565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715611f2e57611f2e611f07565b5f8160060b8360060b806121c7576121c7611f5e565b667fffffffffffff1982145f19821416156121e4576121e4611f07565b90059392505050565b5f8260060b806121ff576121ff611f5e565b808360060b0791505092915050565b5f8160020b627fffff19810361222657612226611f07565b5f19019291505056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a972a2c093456c7298c3527fc87de41f89a2ebae0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d000000000000000000000000000000000000000000000000000000000001a1f8
-----Decoded View---------------
Arg [0] : routerAddress (address): 0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af
Arg [1] : factoryAddress (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
Arg [2] : wethAddress_ (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : feeTokenRegistryAddress (address): 0xa972A2C093456c7298C3527fc87DE41F89A2eBaE
Arg [4] : treasuryAddress (address): 0x1FDdC4EEEc10E3317B27563Ad0126285A329350d
Arg [5] : gasConstant_ (uint256): 107000
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 00000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af
Arg [1] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 000000000000000000000000a972a2c093456c7298c3527fc87de41f89a2ebae
Arg [4] : 0000000000000000000000001fddc4eeec10e3317b27563ad0126285a329350d
Arg [5] : 000000000000000000000000000000000000000000000000000000000001a1f8
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.