Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Latest 22 from a total of 22 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Execute | 1407087 | 10 days ago | IN | 0 S | 0.00016623 | ||||
Execute | 1407072 | 10 days ago | IN | 1 S | 0.00016591 | ||||
Execute | 1398437 | 11 days ago | IN | 0.2 S | 0.00079246 | ||||
Execute | 1398415 | 11 days ago | IN | 0 S | 0.00016126 | ||||
Execute | 1398406 | 11 days ago | IN | 0.001 S | 0.00016148 | ||||
Execute | 1398201 | 11 days ago | IN | 0 S | 0.00016126 | ||||
Execute | 1397715 | 11 days ago | IN | 0 S | 0.00074675 | ||||
Execute | 1397508 | 11 days ago | IN | 1 S | 0.00081127 | ||||
Execute | 1397484 | 11 days ago | IN | 0 S | 0.00015198 | ||||
Execute | 1397466 | 11 days ago | IN | 0 S | 0.00013296 | ||||
Execute | 1397152 | 11 days ago | IN | 1 S | 0.00014669 | ||||
Execute | 1397120 | 11 days ago | IN | 1 S | 0.00016176 | ||||
Execute | 1396880 | 11 days ago | IN | 0 S | 0.00016135 | ||||
Execute | 1396857 | 11 days ago | IN | 1 S | 0.00014669 | ||||
Execute | 1396837 | 11 days ago | IN | 1 S | 0.00016176 | ||||
Execute | 1396811 | 11 days ago | IN | 0 S | 0.00016135 | ||||
Execute | 1396685 | 11 days ago | IN | 1 S | 0.00014669 | ||||
Execute | 1396667 | 11 days ago | IN | 1 S | 0.00016176 | ||||
Execute | 1395688 | 11 days ago | IN | 1 S | 0.00016175 | ||||
Execute | 1395524 | 11 days ago | IN | 100 S | 0.00015109 | ||||
Execute | 1394622 | 11 days ago | IN | 0 S | 0.00013296 | ||||
Execute | 1394525 | 11 days ago | IN | 0.1 S | 0.00015084 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
1407087 | 10 days ago | 0.99980001 S | ||||
1407087 | 10 days ago | 0.99980001 S | ||||
1407072 | 10 days ago | 1 S | ||||
1398437 | 11 days ago | 0.15200032 S | ||||
1398437 | 11 days ago | 0.15200032 S | ||||
1398437 | 11 days ago | 0.2 S | ||||
1398415 | 11 days ago | 0.000994 S | ||||
1398415 | 11 days ago | 0.000994 S | ||||
1398406 | 11 days ago | 0.001 S | ||||
1398201 | 11 days ago | 0.0097353 S | ||||
1398201 | 11 days ago | 0.0097353 S | ||||
1397715 | 11 days ago | 2.03773628 S | ||||
1397715 | 11 days ago | 2.03773628 S | ||||
1397508 | 11 days ago | 0.96414442 S | ||||
1397508 | 11 days ago | 0.96414442 S | ||||
1397508 | 11 days ago | 1 S | ||||
1397152 | 11 days ago | 1 S | ||||
1397120 | 11 days ago | 1 S | ||||
1396880 | 11 days ago | 1.98801802 S | ||||
1396880 | 11 days ago | 1.98801802 S | ||||
1396857 | 11 days ago | 1 S | ||||
1396837 | 11 days ago | 1 S | ||||
1396811 | 11 days ago | 1.98801802 S | ||||
1396811 | 11 days ago | 1.98801802 S | ||||
1396685 | 11 days ago | 1 S |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
UniversalRouter
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 2633 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; // Command implementations import {Dispatcher} from './base/Dispatcher.sol'; import {RewardsCollector} from './base/RewardsCollector.sol'; import {RouterParameters, RouterImmutables} from './base/RouterImmutables.sol'; import {Commands} from './libraries/Commands.sol'; import {IUniversalRouter} from './interfaces/IUniversalRouter.sol'; contract UniversalRouter is RouterImmutables, IUniversalRouter, Dispatcher, RewardsCollector { modifier checkDeadline(uint256 deadline) { if (block.timestamp > deadline) revert TransactionDeadlinePassed(); _; } constructor(RouterParameters memory params) RouterImmutables(params) {} /// @inheritdoc IUniversalRouter function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable checkDeadline(deadline) { execute(commands, inputs); } /// @inheritdoc Dispatcher function execute(bytes calldata commands, bytes[] calldata inputs) public payable override isNotLocked { bool success; bytes memory output; uint256 numCommands = commands.length; if (inputs.length != numCommands) revert LENGTH_MISMATCH(); /// @dev loop through all given commands, execute them and pass along outputs as defined for (uint256 commandIndex = 0; commandIndex < numCommands;) { bytes1 command = commands[commandIndex]; bytes calldata input = inputs[commandIndex]; (success, output) = dispatch(command, input); if (!success && successRequired(command)) { revert ExecutionFailed({commandIndex: commandIndex, message: output}); } unchecked { commandIndex++; } } } function successRequired(bytes1 command) internal pure returns (bool) { return command & Commands.FLAG_ALLOW_REVERT == 0; } /// @notice To receive ETH from WETH and NFT protocols receive() external payable {} }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {V2SwapRouter} from '../modules/uniswap/v2/V2SwapRouter.sol'; import {V3SwapRouter} from '../modules/uniswap/v3/V3SwapRouter.sol'; import {BytesLib} from '../modules/uniswap/v3/BytesLib.sol'; import {Payments} from '../modules/Payments.sol'; import {RouterImmutables} from '../base/RouterImmutables.sol'; import {Callbacks} from '../base/Callbacks.sol'; import {Commands} from '../libraries/Commands.sol'; import {LockAndMsgSender} from './LockAndMsgSender.sol'; import {ERC721} from 'solmate/src/tokens/ERC721.sol'; import {ERC1155} from 'solmate/src/tokens/ERC1155.sol'; import {ERC20} from 'solmate/src/tokens/ERC20.sol'; import {IAllowanceTransfer} from 'permit2/src/interfaces/IAllowanceTransfer.sol'; import {ICryptoPunksMarket} from '../interfaces/external/ICryptoPunksMarket.sol'; import {SwapRoute} from "../libraries/SwapRoute.sol"; /// @title Decodes and Executes Commands /// @notice Called by the UniversalRouter contract to efficiently decode and execute a singular command abstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, Callbacks, LockAndMsgSender { using BytesLib for bytes; error InvalidCommandType(uint256 commandType); error BuyPunkFailed(); error InvalidOwnerERC721(); error InvalidOwnerERC1155(); error BalanceTooLow(); /// @notice Decodes and executes the given command with the given inputs /// @param commandType The command type to execute /// @param inputs The inputs to execute the command with /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons /// @return success True on success of the command, false on failure /// @return output The outputs or error messages, if any, from the command function dispatch(bytes1 commandType, bytes calldata inputs) internal returns (bool success, bytes memory output) { uint256 command = uint8(commandType & Commands.COMMAND_TYPE_MASK); success = true; if (command < Commands.FOURTH_IF_BOUNDARY) { if (command < Commands.SECOND_IF_BOUNDARY) { // 0x00 <= command < 0x08 if (command < Commands.FIRST_IF_BOUNDARY) { if (command == Commands.V3_SWAP_EXACT_IN) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; uint256 amountIn; uint256 amountOutMin; bool payerIsUser; assembly { recipient := calldataload(inputs.offset) amountIn := calldataload(add(inputs.offset, 0x20)) amountOutMin := calldataload(add(inputs.offset, 0x40)) // 0x60 offset is the path, decoded below payerIsUser := calldataload(add(inputs.offset, 0x80)) } bytes calldata path = inputs.toBytes(3); address payer = payerIsUser ? lockedBy : address(this); v3SwapExactInput(map(recipient), amountIn, amountOutMin, path, payer); } else if (command == Commands.V3_SWAP_EXACT_OUT) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; uint256 amountOut; uint256 amountInMax; bool payerIsUser; assembly { recipient := calldataload(inputs.offset) amountOut := calldataload(add(inputs.offset, 0x20)) amountInMax := calldataload(add(inputs.offset, 0x40)) // 0x60 offset is the path, decoded below payerIsUser := calldataload(add(inputs.offset, 0x80)) } bytes calldata path = inputs.toBytes(3); address payer = payerIsUser ? lockedBy : address(this); v3SwapExactOutput(map(recipient), amountOut, amountInMax, path, payer); } else if (command == Commands.PERMIT2_TRANSFER_FROM) { // equivalent: abi.decode(inputs, (address, address, uint160)) address token; address recipient; uint160 amount; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) amount := calldataload(add(inputs.offset, 0x40)) } permit2TransferFrom(token, lockedBy, map(recipient), amount); } else if (command == Commands.PERMIT2_PERMIT_BATCH) { (IAllowanceTransfer.PermitBatch memory permitBatch,) = abi.decode(inputs, (IAllowanceTransfer.PermitBatch, bytes)); bytes calldata data = inputs.toBytes(1); PERMIT2.permit(lockedBy, permitBatch, data); } else if (command == Commands.SWEEP) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; address recipient; uint160 amountMin; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) amountMin := calldataload(add(inputs.offset, 0x40)) } Payments.sweep(token, map(recipient), amountMin); } else if (command == Commands.TRANSFER) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; address recipient; uint256 value; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) value := calldataload(add(inputs.offset, 0x40)) } Payments.pay(token, map(recipient), value); } else if (command == Commands.PAY_PORTION) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; address recipient; uint256 bips; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) bips := calldataload(add(inputs.offset, 0x40)) } Payments.payPortion(token, map(recipient), bips); } else { // placeholder area for command 0x07 revert InvalidCommandType(command); } // 0x08 <= command < 0x10 } else { if (command == Commands.V2_SWAP_EXACT_IN) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; uint256 amountIn; uint256 amountOutMin; bool payerIsUser; assembly { recipient := calldataload(inputs.offset) amountIn := calldataload(add(inputs.offset, 0x20)) amountOutMin := calldataload(add(inputs.offset, 0x40)) // 0x60 offset is the path, decoded below payerIsUser := calldataload(add(inputs.offset, 0x80)) } bytes calldata path = inputs.toBytes(3); (SwapRoute.Route[] memory pathDecoded) = abi.decode(path, (SwapRoute.Route[])); address payer = payerIsUser ? lockedBy : address(this); v2SwapExactInput(map(recipient), amountIn, amountOutMin, pathDecoded, payer); } else if (command == Commands.V2_SWAP_EXACT_OUT) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; uint256 amountOut; uint256 amountInMax; bool payerIsUser; assembly { recipient := calldataload(inputs.offset) amountOut := calldataload(add(inputs.offset, 0x20)) amountInMax := calldataload(add(inputs.offset, 0x40)) // 0x60 offset is the path, decoded below payerIsUser := calldataload(add(inputs.offset, 0x80)) } bytes calldata path = inputs.toBytes(3); (SwapRoute.Route[] memory pathDecoded) = abi.decode(path, (SwapRoute.Route[])); address payer = payerIsUser ? lockedBy : address(this); v2SwapExactOutput(map(recipient), amountOut, amountInMax, pathDecoded, payer); } else if (command == Commands.PERMIT2_PERMIT) { // equivalent: abi.decode(inputs, (IAllowanceTransfer.PermitSingle, bytes)) IAllowanceTransfer.PermitSingle calldata permitSingle; assembly { permitSingle := inputs.offset } bytes calldata data = inputs.toBytes(6); // PermitSingle takes first 6 slots (0..5) PERMIT2.permit(lockedBy, permitSingle, data); } else if (command == Commands.WRAP_ETH) { // equivalent: abi.decode(inputs, (address, uint256)) address recipient; uint256 amountMin; assembly { recipient := calldataload(inputs.offset) amountMin := calldataload(add(inputs.offset, 0x20)) } Payments.wrapETH(map(recipient), amountMin); } else if (command == Commands.UNWRAP_WETH) { // equivalent: abi.decode(inputs, (address, uint256)) address recipient; uint256 amountMin; assembly { recipient := calldataload(inputs.offset) amountMin := calldataload(add(inputs.offset, 0x20)) } Payments.unwrapWETH9(map(recipient), amountMin); } else if (command == Commands.PERMIT2_TRANSFER_FROM_BATCH) { (IAllowanceTransfer.AllowanceTransferDetails[] memory batchDetails) = abi.decode(inputs, (IAllowanceTransfer.AllowanceTransferDetails[])); permit2TransferFrom(batchDetails, lockedBy); } else if (command == Commands.BALANCE_CHECK_ERC20) { // equivalent: abi.decode(inputs, (address, address, uint256)) address owner; address token; uint256 minBalance; assembly { owner := calldataload(inputs.offset) token := calldataload(add(inputs.offset, 0x20)) minBalance := calldataload(add(inputs.offset, 0x40)) } success = (ERC20(token).balanceOf(owner) >= minBalance); if (!success) output = abi.encodePacked(BalanceTooLow.selector); } else { // placeholder area for command 0x0f revert InvalidCommandType(command); } } // 0x10 <= command } else { // 0x10 <= command < 0x18 if (command < Commands.THIRD_IF_BOUNDARY) { if (command == Commands.SEAPORT_V1_5) { /// @dev Seaport 1.4 and 1.5 allow for orders to be created by contracts. /// These orders pass control to the contract offerers during fufillment, /// allowing them to perform any number of destructive actions as a holder of the NFT. /// Integrators should be aware that in some scenarios: e.g. purchasing an NFT that allows the holder /// to claim another NFT, the contract offerer can "steal" the claim during order fufillment. /// For some such purchases, an OWNER_CHECK command can be prepended to ensure that all tokens have the desired owner at the end of the transaction. /// This is also outlined in the Seaport documentation: https://github.com/ProjectOpenSea/seaport/blob/main/docs/SeaportDocumentation.md (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = SEAPORT_V1_5.call{value: value}(data); } else if (command == Commands.LOOKS_RARE_V2) { // equivalent: abi.decode(inputs, (uint256, bytes)) uint256 value; assembly { value := calldataload(inputs.offset) } bytes calldata data = inputs.toBytes(1); (success, output) = LOOKS_RARE_V2.call{value: value}(data); } else if (command == Commands.NFTX) { // equivalent: abi.decode(inputs, (uint256, bytes)) (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = NFTX_ZAP.call{value: value}(data); } else if (command == Commands.CRYPTOPUNKS) { // equivalent: abi.decode(inputs, (uint256, address, uint256)) uint256 punkId; address recipient; uint256 value; assembly { punkId := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) value := calldataload(add(inputs.offset, 0x40)) } (success, output) = CRYPTOPUNKS.call{value: value}( abi.encodeWithSelector(ICryptoPunksMarket.buyPunk.selector, punkId) ); if (success) ICryptoPunksMarket(CRYPTOPUNKS).transferPunk(map(recipient), punkId); else output = abi.encodePacked(BuyPunkFailed.selector); } else if (command == Commands.OWNER_CHECK_721) { // equivalent: abi.decode(inputs, (address, address, uint256)) address owner; address token; uint256 id; assembly { owner := calldataload(inputs.offset) token := calldataload(add(inputs.offset, 0x20)) id := calldataload(add(inputs.offset, 0x40)) } success = (ERC721(token).ownerOf(id) == owner); if (!success) output = abi.encodePacked(InvalidOwnerERC721.selector); } else if (command == Commands.OWNER_CHECK_1155) { // equivalent: abi.decode(inputs, (address, address, uint256, uint256)) address owner; address token; uint256 id; uint256 minBalance; assembly { owner := calldataload(inputs.offset) token := calldataload(add(inputs.offset, 0x20)) id := calldataload(add(inputs.offset, 0x40)) minBalance := calldataload(add(inputs.offset, 0x60)) } success = (ERC1155(token).balanceOf(owner, id) >= minBalance); if (!success) output = abi.encodePacked(InvalidOwnerERC1155.selector); } else if (command == Commands.SWEEP_ERC721) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; address recipient; uint256 id; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) id := calldataload(add(inputs.offset, 0x40)) } Payments.sweepERC721(token, map(recipient), id); } // 0x18 <= command < 0x1f } else { if (command == Commands.X2Y2_721) { (success, output) = callAndTransfer721(inputs, X2Y2); } else if (command == Commands.SUDOSWAP) { // equivalent: abi.decode(inputs, (uint256, bytes)) (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = SUDOSWAP.call{value: value}(data); } else if (command == Commands.NFT20) { // equivalent: abi.decode(inputs, (uint256, bytes)) (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = NFT20_ZAP.call{value: value}(data); } else if (command == Commands.X2Y2_1155) { (success, output) = callAndTransfer1155(inputs, X2Y2); } else if (command == Commands.FOUNDATION) { (success, output) = callAndTransfer721(inputs, FOUNDATION); } else if (command == Commands.SWEEP_ERC1155) { // equivalent: abi.decode(inputs, (address, address, uint256, uint256)) address token; address recipient; uint256 id; uint256 amount; assembly { token := calldataload(inputs.offset) recipient := calldataload(add(inputs.offset, 0x20)) id := calldataload(add(inputs.offset, 0x40)) amount := calldataload(add(inputs.offset, 0x60)) } Payments.sweepERC1155(token, map(recipient), id, amount); } else if (command == Commands.ELEMENT_MARKET) { // equivalent: abi.decode(inputs, (uint256, bytes)) (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = ELEMENT_MARKET.call{value: value}(data); } else { // placeholder for command 0x1f revert InvalidCommandType(command); } } } // 0x20 <= command } else { if (command == Commands.SEAPORT_V1_4) { /// @dev Seaport 1.4 and 1.5 allow for orders to be created by contracts. /// These orders pass control to the contract offerers during fufillment, /// allowing them to perform any number of destructive actions as a holder of the NFT. /// Integrators should be aware that in some scenarios: e.g. purchasing an NFT that allows the holder /// to claim another NFT, the contract offerer can "steal" the claim during order fufillment. /// For some such purchases, an OWNER_CHECK command can be prepended to ensure that all tokens have the desired owner at the end of the transaction. /// This is also outlined in the Seaport documentation: https://github.com/ProjectOpenSea/seaport/blob/main/docs/SeaportDocumentation.md (uint256 value, bytes calldata data) = getValueAndData(inputs); (success, output) = SEAPORT_V1_4.call{value: value}(data); } else if (command == Commands.EXECUTE_SUB_PLAN) { bytes calldata _commands = inputs.toBytes(0); bytes[] calldata _inputs = inputs.toBytesArray(1); (success, output) = (address(this)).call(abi.encodeWithSelector(Dispatcher.execute.selector, _commands, _inputs)); } else if (command == Commands.APPROVE_ERC20) { ERC20 token; RouterImmutables.Spenders spender; assembly { token := calldataload(inputs.offset) spender := calldataload(add(inputs.offset, 0x20)) } Payments.approveERC20(token, spender); } else { // placeholder area for commands 0x22-0x3f revert InvalidCommandType(command); } } } /// @notice Executes encoded commands along with provided inputs. /// @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 function execute(bytes calldata commands, bytes[] calldata inputs) external payable virtual; /// @notice Performs a call to purchase an ERC721, then transfers the ERC721 to a specified recipient /// @param inputs The inputs for the protocol and ERC721 transfer, encoded /// @param protocol The protocol to pass the calldata to /// @return success True on success of the command, false on failure /// @return output The outputs or error messages, if any, from the command function callAndTransfer721(bytes calldata inputs, address protocol) internal returns (bool success, bytes memory output) { // equivalent: abi.decode(inputs, (uint256, bytes, address, address, uint256)) (uint256 value, bytes calldata data) = getValueAndData(inputs); address recipient; address token; uint256 id; assembly { // 0x00 and 0x20 offsets are value and data, above recipient := calldataload(add(inputs.offset, 0x40)) token := calldataload(add(inputs.offset, 0x60)) id := calldataload(add(inputs.offset, 0x80)) } (success, output) = protocol.call{value: value}(data); if (success) ERC721(token).safeTransferFrom(address(this), map(recipient), id); } /// @notice Performs a call to purchase an ERC1155, then transfers the ERC1155 to a specified recipient /// @param inputs The inputs for the protocol and ERC1155 transfer, encoded /// @param protocol The protocol to pass the calldata to /// @return success True on success of the command, false on failure /// @return output The outputs or error messages, if any, from the command function callAndTransfer1155(bytes calldata inputs, address protocol) internal returns (bool success, bytes memory output) { // equivalent: abi.decode(inputs, (uint256, bytes, address, address, uint256, uint256)) (uint256 value, bytes calldata data) = getValueAndData(inputs); address recipient; address token; uint256 id; uint256 amount; assembly { // 0x00 and 0x20 offsets are value and data, above recipient := calldataload(add(inputs.offset, 0x40)) token := calldataload(add(inputs.offset, 0x60)) id := calldataload(add(inputs.offset, 0x80)) amount := calldataload(add(inputs.offset, 0xa0)) } (success, output) = protocol.call{value: value}(data); if (success) ERC1155(token).safeTransferFrom(address(this), map(recipient), id, amount, new bytes(0)); } /// @notice Helper function to extract `value` and `data` parameters from input bytes string /// @dev The helper assumes that `value` is the first parameter, and `data` is the second /// @param inputs The bytes string beginning with value and data parameters /// @return value The 256 bit integer value /// @return data The data bytes string function getValueAndData(bytes calldata inputs) internal pure returns (uint256 value, bytes calldata data) { assembly { value := calldataload(inputs.offset) } data = inputs.toBytes(1); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.15; import {ERC20} from 'solmate/src/tokens/ERC20.sol'; import {SafeTransferLib} from 'solmate/src/utils/SafeTransferLib.sol'; import {RouterImmutables} from './RouterImmutables.sol'; import {IRewardsCollector} from '../interfaces/IRewardsCollector.sol'; abstract contract RewardsCollector is IRewardsCollector, RouterImmutables { using SafeTransferLib for ERC20; event RewardsSent(uint256 amount); error UnableToClaim(); /// @inheritdoc IRewardsCollector function collectRewards(bytes calldata looksRareClaim) external { (bool success,) = LOOKS_RARE_REWARDS_DISTRIBUTOR.call(looksRareClaim); if (!success) revert UnableToClaim(); uint256 balance = LOOKS_RARE_TOKEN.balanceOf(address(this)); LOOKS_RARE_TOKEN.transfer(ROUTER_REWARDS_DISTRIBUTOR, balance); emit RewardsSent(balance); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {IWETH9} from "../interfaces/external/IWETH9.sol"; import {IRamsesV3Factory} from "../../core/interfaces/IRamsesV3Factory.sol"; struct RouterParameters { address permit2; address weth9; address seaportV1_5; address seaportV1_4; address openseaConduit; address nftxZap; address x2y2; address foundation; address sudoswap; address elementMarket; address nft20Zap; address cryptopunks; address looksRareV2; address routerRewardsDistributor; address looksRareRewardsDistributor; address looksRareToken; address v2Factory; address v3Factory; bytes32 pairInitCodeHash; bytes32 poolInitCodeHash; } /// @title Router Immutable Storage contract /// @notice Used along with the `RouterParameters` struct for ease of cross-chain deployment contract RouterImmutables { /// @dev WETH9 address IWETH9 internal immutable WETH9; /// @dev Permit2 address IAllowanceTransfer internal immutable PERMIT2; /// @dev Seaport 1.5 address address internal immutable SEAPORT_V1_5; /// @dev Seaport 1.4 address address internal immutable SEAPORT_V1_4; /// @dev The address of OpenSea's conduit used in both Seaport 1.4 and Seaport 1.5 address internal immutable OPENSEA_CONDUIT; /// @dev The address of NFTX zap contract for interfacing with vaults address internal immutable NFTX_ZAP; /// @dev The address of X2Y2 address internal immutable X2Y2; // @dev The address of Foundation address internal immutable FOUNDATION; // @dev The address of Sudoswap's router address internal immutable SUDOSWAP; // @dev The address of Element Market address internal immutable ELEMENT_MARKET; // @dev the address of NFT20's zap contract address internal immutable NFT20_ZAP; // @dev the address of Larva Lab's cryptopunks marketplace address internal immutable CRYPTOPUNKS; /// @dev The address of LooksRareV2 address internal immutable LOOKS_RARE_V2; /// @dev The address of LooksRare token ERC20 internal immutable LOOKS_RARE_TOKEN; /// @dev The address of LooksRare rewards distributor address internal immutable LOOKS_RARE_REWARDS_DISTRIBUTOR; /// @dev The address of router rewards distributor address internal immutable ROUTER_REWARDS_DISTRIBUTOR; /// @dev The address of UniswapV2Factory address internal immutable UNISWAP_V2_FACTORY; /// @dev The UniswapV2Pair initcodehash bytes32 internal immutable UNISWAP_V2_PAIR_INIT_CODE_HASH; /// @dev The address of UniswapV3Factory address internal immutable UNISWAP_V3_FACTORY; /// @dev The UniswapV3Pool initcodehash bytes32 internal immutable UNISWAP_V3_POOL_INIT_CODE_HASH; /// @dev Store the deployer address needed for create2 salts address internal immutable RAMSES_V3_DEPLOYER; enum Spenders { OSConduit, Sudoswap } constructor(RouterParameters memory params) { PERMIT2 = IAllowanceTransfer(params.permit2); WETH9 = IWETH9(params.weth9); SEAPORT_V1_5 = params.seaportV1_5; SEAPORT_V1_4 = params.seaportV1_4; OPENSEA_CONDUIT = params.openseaConduit; NFTX_ZAP = params.nftxZap; X2Y2 = params.x2y2; FOUNDATION = params.foundation; SUDOSWAP = params.sudoswap; ELEMENT_MARKET = params.elementMarket; NFT20_ZAP = params.nft20Zap; CRYPTOPUNKS = params.cryptopunks; LOOKS_RARE_V2 = params.looksRareV2; LOOKS_RARE_TOKEN = ERC20(params.looksRareToken); LOOKS_RARE_REWARDS_DISTRIBUTOR = params.looksRareRewardsDistributor; ROUTER_REWARDS_DISTRIBUTOR = params.routerRewardsDistributor; UNISWAP_V2_FACTORY = params.v2Factory; UNISWAP_V2_PAIR_INIT_CODE_HASH = params.pairInitCodeHash; UNISWAP_V3_FACTORY = params.v3Factory; UNISWAP_V3_POOL_INIT_CODE_HASH = params.poolInitCodeHash; RAMSES_V3_DEPLOYER = IRamsesV3Factory(UNISWAP_V3_FACTORY).ramsesV3PoolDeployer(); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; /// @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. // Command Types where value<0x08, 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; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant FIRST_IF_BOUNDARY = 0x08; // 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; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant SECOND_IF_BOUNDARY = 0x10; // Command Types where 0x10<=value<0x18, executed in the third nested-if block uint256 constant SEAPORT_V1_5 = 0x10; uint256 constant LOOKS_RARE_V2 = 0x11; uint256 constant NFTX = 0x12; uint256 constant CRYPTOPUNKS = 0x13; // 0x14; uint256 constant OWNER_CHECK_721 = 0x15; uint256 constant OWNER_CHECK_1155 = 0x16; uint256 constant SWEEP_ERC721 = 0x17; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant THIRD_IF_BOUNDARY = 0x18; // Command Types where 0x18<=value<=0x1f, executed in the final nested-if block uint256 constant X2Y2_721 = 0x18; uint256 constant SUDOSWAP = 0x19; uint256 constant NFT20 = 0x1a; uint256 constant X2Y2_1155 = 0x1b; uint256 constant FOUNDATION = 0x1c; uint256 constant SWEEP_ERC1155 = 0x1d; uint256 constant ELEMENT_MARKET = 0x1e; // COMMAND_PLACEHOLDER = 0x1f; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant FOURTH_IF_BOUNDARY = 0x20; // Command Types where 0x20<=value uint256 constant SEAPORT_V1_4 = 0x20; uint256 constant EXECUTE_SUB_PLAN = 0x21; uint256 constant APPROVE_ERC20 = 0x22; // COMMAND_PLACEHOLDER for 0x23 to 0x3f (all unused) }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IERC721Receiver} from '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import {IERC1155Receiver} from '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol'; import {IRewardsCollector} from './IRewardsCollector.sol'; interface IUniversalRouter is IRewardsCollector, IERC721Receiver, IERC1155Receiver { /// @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 LENGTH_MISMATCH(); /// @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-3.0-or-later pragma solidity ^0.8.17; import {IPair} from "./../../../../../interfaces/IPair.sol"; import {RamsesLegacyLibrary} from "./RamsesLegacyLibrary.sol"; import {RouterImmutables} from "../../../base/RouterImmutables.sol"; import {Payments} from "../../Payments.sol"; import {Permit2Payments} from "../../Permit2Payments.sol"; import {Constants} from "../../../libraries/Constants.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SwapRoute} from "../../../libraries/SwapRoute.sol"; import {IPairFactory} from "./../../../../../interfaces/IPairFactory.sol"; /// @title Router for Uniswap v2 Trades abstract contract V2SwapRouter is RouterImmutables, Permit2Payments { error V2TooLittleReceived(); error V2TooMuchRequested(); error V2INVALID_PATH(); function _v2Swap( SwapRoute.Route[] memory path, address recipient, address pair ) private { unchecked { // cached to save on duplicate operations (address token0, ) = RamsesLegacyLibrary.sortTokens( path[0].from, path[0].to ); uint256 lastIndex = path.length - 1; for (uint256 i; i < path.length; i++) { (address input, address output) = (path[i].from, path[i].to); ( uint256 decimals0, uint256 decimals1, uint256 reserve0, uint256 reserve1, , , ) = IPair(pair).metadata(); ( uint256 reserveInput, uint256 reserveOutput, uint256 decimalsInput, uint256 decimalsOutput ) = input == token0 ? (reserve0, reserve1, decimals0, decimals1) : (reserve1, reserve0, decimals1, decimals0); uint256 amountInput = ERC20(input).balanceOf(pair) - reserveInput; amountInput -= (amountInput * IPairFactory(UNISWAP_V2_FACTORY).pairFee(pair)) / 1_000_000; uint256 amountOutput = RamsesLegacyLibrary.getAmountOut( amountInput, reserveInput, reserveOutput, path[i].stable, decimalsInput, decimalsOutput ); (uint256 amount0Out, uint256 amount1Out) = input == token0 ? (uint256(0), amountOutput) : (amountOutput, uint256(0)); address nextPair; (nextPair, token0) = i < lastIndex ? RamsesLegacyLibrary.pairAndToken0For( UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, output, path[i + 1].to, path[i + 1].stable ) : (recipient, address(0)); IPair(pair).swap( amount0Out, amount1Out, nextPair, new bytes(0) ); pair = nextPair; } } } /// @notice Performs a Uniswap v2 exact input swap /// @param recipient The recipient of the output tokens /// @param amountIn The amount of input tokens for the trade /// @param amountOutMinimum The minimum desired amount of output tokens /// @param path The path of the trade as an array of token addresses /// @param payer The address that will be paying the input function v2SwapExactInput( address recipient, uint256 amountIn, uint256 amountOutMinimum, SwapRoute.Route[] memory path, address payer ) internal { address firstPair = RamsesLegacyLibrary.pairFor( UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, path[0].from, path[0].to, path[0].stable ); if ( amountIn != Constants.ALREADY_PAID // amountIn of 0 to signal that the pair already has the tokens ) { payOrPermit2Transfer(path[0].from, payer, firstPair, amountIn); } ERC20 tokenOut = ERC20(path[path.length - 1].to); uint256 balanceBefore = tokenOut.balanceOf(recipient); _v2Swap(path, recipient, firstPair); uint256 amountOut = tokenOut.balanceOf(recipient) - balanceBefore; if (amountOut < amountOutMinimum) revert V2TooLittleReceived(); } /// @notice Performs a Uniswap v2 exact output swap /// @param recipient The recipient of the output tokens /// @param amountOut The amount of output tokens to receive for the trade /// @param amountInMaximum The maximum desired amount of input tokens /// @param path The path of the trade as an array of token addresses /// @param payer The address that will be paying the input function v2SwapExactOutput( address recipient, uint256 amountOut, uint256 amountInMaximum, SwapRoute.Route[] memory path, address payer ) internal { (uint256 amountIn, address firstPair) = RamsesLegacyLibrary .getAmountInMultihop( UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, amountOut, path ); if (amountIn > amountInMaximum) revert V2TooMuchRequested(); payOrPermit2Transfer(path[0].from, payer, firstPair, amountIn); _v2Swap(path, recipient, firstPair); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {V3Path} from "./V3Path.sol"; import {BytesLib} from "./BytesLib.sol"; import {SafeCast} from "./../../../../core/libraries/SafeCast.sol"; import {IRamsesV3Pool} from "./../../../../core/interfaces/IRamsesV3Pool.sol"; import {IUniswapV3SwapCallback} from "./../../../../core/interfaces/callback/IUniswapV3SwapCallback.sol"; import {Constants} from "../../../libraries/Constants.sol"; import {RouterImmutables} from "../../../base/RouterImmutables.sol"; import {Permit2Payments} from "../../Permit2Payments.sol"; import {Constants} from "../../../libraries/Constants.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {IRamsesV3Factory} from "../../../../core/interfaces/IRamsesV3Factory.sol"; /// @title Router for Uniswap v3 Trades abstract contract V3SwapRouter is RouterImmutables, Permit2Payments, IUniswapV3SwapCallback { using V3Path for bytes; using BytesLib for bytes; using SafeCast for uint256; error V3InvalidSwap(); error V3TooLittleReceived(); error V3TooMuchRequested(); error V3InvalidAmountOut(); error V3InvalidCaller(); /// @dev Used as the placeholder value for maxAmountIn, because the computed amount in for an exact output swap /// @dev can never actually be this value uint256 private constant DEFAULT_MAX_AMOUNT_IN = type(uint256).max; /// @dev Transient storage variable used for checking slippage uint256 private maxAmountInCached = DEFAULT_MAX_AMOUNT_IN; /// @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; function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external { /// @dev swaps entirely within 0-liquidity regions are not supported if (amount0Delta <= 0 && amount1Delta <= 0) revert V3InvalidSwap(); (, address payer) = abi.decode(data, (bytes, address)); bytes calldata path = data.toBytes(0); /// @dev because exact output swaps are executed in reverse order, in this case tokenOut is actually tokenIn (address tokenIn, int24 tickSpacing, address tokenOut) = path .decodeFirstPool(); if (computePoolAddress(tokenIn, tokenOut, tickSpacing) != msg.sender) revert V3InvalidCaller(); (bool isExactInput, uint256 amountToPay) = amount0Delta > 0 ? (tokenIn < tokenOut, uint256(amount0Delta)) : (tokenOut < tokenIn, uint256(amount1Delta)); if (isExactInput) { /// @dev Pay the pool (msg.sender) payOrPermit2Transfer(tokenIn, payer, msg.sender, amountToPay); } else { /// @dev either initiate the next swap or pay if (path.hasMultiplePools()) { /// @dev this is an intermediate step so the payer is actually this contract path = path.skipToken(); _swap(-amountToPay.toInt256(), msg.sender, path, payer, false); } else { if (amountToPay > maxAmountInCached) revert V3TooMuchRequested(); /// @dev note that because exact output swaps are executed in reverse order, tokenOut is actually tokenIn payOrPermit2Transfer(tokenOut, payer, msg.sender, amountToPay); } } } /// @notice Performs a Uniswap v3 exact input swap /// @param recipient The recipient of the output tokens /// @param amountIn The amount of input tokens for the trade /// @param amountOutMinimum The minimum desired amount of output tokens /// @param path The path of the trade as a bytes string /// @param payer The address that will be paying the input function v3SwapExactInput( address recipient, uint256 amountIn, uint256 amountOutMinimum, bytes calldata path, address payer ) internal { /// @dev use amountIn == Constants.CONTRACT_BALANCE as a flag to swap the entire balance of the contract if (amountIn == Constants.CONTRACT_BALANCE) { address tokenIn = path.decodeFirstToken(); amountIn = ERC20(tokenIn).balanceOf(address(this)); } uint256 amountOut; while (true) { bool hasMultiplePools = path.hasMultiplePools(); /// @dev the outputs of prior swaps become the inputs to subsequent ones (int256 amount0Delta, int256 amount1Delta, bool zeroForOne) = _swap( amountIn.toInt256(), /// @dev for intermediate swaps, this contract custodies hasMultiplePools ? address(this) : recipient, /// @dev only the first pool is needed path.getFirstPool(), /// @dev for intermediate swaps, this contract custodies payer, true ); amountIn = uint256(-(zeroForOne ? amount1Delta : amount0Delta)); /// @dev decide whether to continue or terminate if (hasMultiplePools) { payer = address(this); path = path.skipToken(); } else { amountOut = amountIn; break; } } if (amountOut < amountOutMinimum) revert V3TooLittleReceived(); } /// @notice Performs a Uniswap v3 exact output swap /// @param recipient The recipient of the output tokens /// @param amountOut The amount of output tokens to receive for the trade /// @param amountInMaximum The maximum desired amount of input tokens /// @param path The path of the trade as a bytes string /// @param payer The address that will be paying the input function v3SwapExactOutput( address recipient, uint256 amountOut, uint256 amountInMaximum, bytes calldata path, address payer ) internal { maxAmountInCached = amountInMaximum; (int256 amount0Delta, int256 amount1Delta, bool zeroForOne) = _swap( -amountOut.toInt256(), recipient, path, payer, false ); uint256 amountOutReceived = zeroForOne ? uint256(-amount1Delta) : uint256(-amount0Delta); if (amountOutReceived != amountOut) revert V3InvalidAmountOut(); maxAmountInCached = DEFAULT_MAX_AMOUNT_IN; } /// @dev Performs a single swap for both exactIn and exactOut /// For exactIn, `amount` is `amountIn`. For exactOut, `amount` is `-amountOut` function _swap( int256 amount, address recipient, bytes calldata path, address payer, bool isExactIn ) private returns (int256 amount0Delta, int256 amount1Delta, bool zeroForOne) { (address tokenIn, int24 tickSpacing, address tokenOut) = path .decodeFirstPool(); zeroForOne = isExactIn ? tokenIn < tokenOut : tokenOut < tokenIn; (amount0Delta, amount1Delta) = IRamsesV3Pool( computePoolAddress(tokenIn, tokenOut, tickSpacing) ).swap( recipient, zeroForOne, amount, (zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1), abi.encode(path, payer) ); } function computePoolAddress( address tokenA, address tokenB, int24 tickspacing ) private view returns (address pool) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex"ff", RAMSES_V3_DEPLOYER, keccak256(abi.encode(tokenA, tokenB, tickspacing)), UNISWAP_V3_POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: GPL-3.0-or-later /// @title Library for Bytes Manipulation pragma solidity ^0.8.0; import {Constants} from '../../../libraries/Constants.sol'; library BytesLib { error SliceOutOfBounds(); /// @notice Returns the address starting at byte 0 /// @dev length and overflow checks must be carried out before calling /// @param _bytes The input bytes string to slice /// @return _address The address starting at byte 0 function toAddress(bytes calldata _bytes) internal pure returns (address _address) { if (_bytes.length < Constants.ADDR_SIZE) revert SliceOutOfBounds(); assembly { _address := shr(96, calldataload(_bytes.offset)) } } /// @notice Returns the pool details starting at byte 0 /// @dev length and overflow checks must be carried out before calling /// @param _bytes The input bytes string to slice /// @return token0 The address at byte 0 /// @return tickSpacing The int24 starting at byte 20 /// @return token1 The address at byte 23 function toPool(bytes calldata _bytes) internal pure returns (address token0, int24 tickSpacing, address token1) { if (_bytes.length < Constants.V3_POP_OFFSET) revert SliceOutOfBounds(); assembly { let firstWord := calldataload(_bytes.offset) token0 := shr(96, firstWord) tickSpacing := and(shr(72, firstWord), 0xffffff) token1 := shr(96, calldataload(add(_bytes.offset, 23))) } } /// @notice Decode the `_arg`-th element in `_bytes` as a dynamic array /// @dev The decoding of `length` and `offset` is universal, /// whereas the type declaration of `res` instructs the compiler how to read it. /// @param _bytes The input bytes string to slice /// @param _arg The index of the argument to extract /// @return length Length of the array /// @return offset Pointer to the data part of the array function toLengthOffset(bytes calldata _bytes, uint256 _arg) internal pure returns (uint256 length, uint256 offset) { uint256 relativeOffset; assembly { // The offset of the `_arg`-th element is `32 * arg`, which stores the offset of the length pointer. // shl(5, x) is equivalent to mul(32, x) let lengthPtr := add(_bytes.offset, calldataload(add(_bytes.offset, shl(5, _arg)))) length := calldataload(lengthPtr) offset := add(lengthPtr, 0x20) relativeOffset := sub(offset, _bytes.offset) } if (_bytes.length < length + relativeOffset) revert SliceOutOfBounds(); } /// @notice Decode the `_arg`-th element in `_bytes` as `bytes` /// @param _bytes The input bytes string to extract a bytes string from /// @param _arg The index of the argument to extract function toBytes(bytes calldata _bytes, uint256 _arg) internal pure returns (bytes calldata res) { (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg); assembly { res.length := length res.offset := offset } } /// @notice Decode the `_arg`-th element in `_bytes` as `address[]` /// @param _bytes The input bytes string to extract an address array from /// @param _arg The index of the argument to extract function toAddressArray(bytes calldata _bytes, uint256 _arg) internal pure returns (address[] calldata res) { (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg); assembly { res.length := length res.offset := offset } } /// @notice Decode the `_arg`-th element in `_bytes` as `bytes[]` /// @param _bytes The input bytes string to extract a bytes array from /// @param _arg The index of the argument to extract function toBytesArray(bytes calldata _bytes, uint256 _arg) internal pure returns (bytes[] calldata res) { (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg); assembly { res.length := length res.offset := offset } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {Constants} from "../libraries/Constants.sol"; import {RouterImmutables} from "../base/RouterImmutables.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {ERC721} from "solmate/src/tokens/ERC721.sol"; import {ERC1155} from "solmate/src/tokens/ERC1155.sol"; /// @title Payments contract /// @notice Performs various operations around the payment of ETH and tokens abstract contract Payments is RouterImmutables { using SafeTransferLib for ERC20; using SafeTransferLib for address; error INSUFFICIENT_TOKEN(); error INSUFFICIENT_ETH(); error INVALID_BIPS(); error INVALID_SPENDER(); uint256 internal constant FEE_BIPS_BASE = 10_000; /// @notice Pays an amount of ETH or ERC20 to a recipient /// @param token The token to pay (can be ETH using Constants.ETH) /// @param recipient The address that will receive the payment /// @param value The amount to pay function pay(address token, address recipient, uint256 value) internal { if (token == Constants.ETH) { recipient.safeTransferETH(value); } else { if (value == Constants.CONTRACT_BALANCE) { value = ERC20(token).balanceOf(address(this)); } ERC20(token).safeTransfer(recipient, value); } } /// @notice Approves a protocol to spend ERC20s in the router /// @param token The token to approve /// @param spender Which protocol to approve function approveERC20(ERC20 token, Spenders spender) internal { // check spender is one of our approved spenders address spenderAddress; /// @dev use 0 = Opensea Conduit for both Seaport v1.4 and v1.5 if (spender == Spenders.OSConduit) spenderAddress = OPENSEA_CONDUIT; else if (spender == Spenders.Sudoswap) spenderAddress = SUDOSWAP; else revert INVALID_SPENDER(); // set approval token.safeApprove(spenderAddress, type(uint256).max); } /// @notice Pays a proportion of the contract's ETH or ERC20 to a recipient /// @param token The token to pay (can be ETH using Constants.ETH) /// @param recipient The address that will receive payment /// @param bips Portion in bips of whole balance of the contract function payPortion( address token, address recipient, uint256 bips ) internal { if (bips == 0 || bips > FEE_BIPS_BASE) revert INVALID_BIPS(); if (token == Constants.ETH) { uint256 balance = address(this).balance; uint256 amount = (balance * bips) / FEE_BIPS_BASE; recipient.safeTransferETH(amount); } else { uint256 balance = ERC20(token).balanceOf(address(this)); uint256 amount = (balance * bips) / FEE_BIPS_BASE; ERC20(token).safeTransfer(recipient, amount); } } /// @notice Sweeps all of the contract's ERC20 or ETH to an address /// @param token The token to sweep (can be ETH using Constants.ETH) /// @param recipient The address that will receive payment /// @param amountMinimum The minimum desired amount function sweep( address token, address recipient, uint256 amountMinimum ) internal { uint256 balance; if (token == Constants.ETH) { balance = address(this).balance; if (balance < amountMinimum) revert INSUFFICIENT_ETH(); if (balance > 0) recipient.safeTransferETH(balance); } else { balance = ERC20(token).balanceOf(address(this)); if (balance < amountMinimum) revert INSUFFICIENT_TOKEN(); if (balance > 0) ERC20(token).safeTransfer(recipient, balance); } } /// @notice Sweeps an ERC721 to a recipient from the contract /// @param token The ERC721 token to sweep /// @param recipient The address that will receive payment /// @param id The ID of the ERC721 to sweep function sweepERC721( address token, address recipient, uint256 id ) internal { ERC721(token).safeTransferFrom(address(this), recipient, id); } /// @notice Sweeps all of the contract's ERC1155 to an address /// @param token The ERC1155 token to sweep /// @param recipient The address that will receive payment /// @param id The ID of the ERC1155 to sweep /// @param amountMinimum The minimum desired amount function sweepERC1155( address token, address recipient, uint256 id, uint256 amountMinimum ) internal { uint256 balance = ERC1155(token).balanceOf(address(this), id); if (balance < amountMinimum) revert INSUFFICIENT_TOKEN(); ERC1155(token).safeTransferFrom( address(this), recipient, id, balance, bytes("") ); } /// @notice Wraps an amount of ETH into WETH /// @param recipient The recipient of the WETH /// @param amount The amount to wrap (can be CONTRACT_BALANCE) function wrapETH(address recipient, uint256 amount) internal { if (amount == Constants.CONTRACT_BALANCE) { amount = address(this).balance; } else if (amount > address(this).balance) { revert INSUFFICIENT_ETH(); } if (amount > 0) { WETH9.deposit{value: amount}(); if (recipient != address(this)) { WETH9.transfer(recipient, amount); } } } /// @notice Unwraps all of the contract's WETH into ETH /// @param recipient The recipient of the ETH /// @param amountMinimum The minimum amount of ETH desired function unwrapWETH9(address recipient, uint256 amountMinimum) internal { uint256 value = WETH9.balanceOf(address(this)); if (value < amountMinimum) { revert INSUFFICIENT_ETH(); } if (value > 0) { WETH9.withdraw(value); if (recipient != address(this)) { recipient.safeTransferETH(value); } } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IERC721Receiver} from '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import {IERC1155Receiver} from '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol'; import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol'; /// @title ERC Callback Support /// @notice Implements various functions introduced by a variety of ERCs for security reasons. /// All are called by external contracts to ensure that this contract safely supports the ERC in question. contract Callbacks is IERC721Receiver, IERC1155Receiver { function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { return this.onERC721Received.selector; } function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external pure returns (bytes4) { return this.onERC1155BatchReceived.selector; } function supportsInterface(bytes4 interfaceId) external pure returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {Constants} from '../libraries/Constants.sol'; contract LockAndMsgSender { error ContractLocked(); address internal constant NOT_LOCKED_FLAG = address(0); address internal lockedBy = NOT_LOCKED_FLAG; modifier isNotLocked() { if (msg.sender != address(this)) { if (lockedBy != NOT_LOCKED_FLAG) revert ContractLocked(); lockedBy = msg.sender; _; lockedBy = NOT_LOCKED_FLAG; } else { _; } } /// @notice Calculates the recipient address for a command /// @param recipient The recipient or recipient-flag for the command /// @return output The resultant recipient for the command function map(address recipient) internal view returns (address) { if (recipient == Constants.MSG_SENDER) { return lockedBy; } else if (recipient == Constants.ADDRESS_THIS) { return address(this); } else { return recipient; } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*////////////////////////////////////////////////////////////// ERC721 BALANCE/OWNER STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) internal _ownerOf; mapping(address => uint256) internal _balanceOf; function ownerOf(uint256 id) public view virtual returns (address owner) { require((owner = _ownerOf[id]) != address(0), "NOT_MINTED"); } function balanceOf(address owner) public view virtual returns (uint256) { require(owner != address(0), "ZERO_ADDRESS"); return _balanceOf[owner]; } /*////////////////////////////////////////////////////////////// ERC721 APPROVAL STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = _ownerOf[id]; require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom( address from, address to, uint256 id ) public virtual { require(from == _ownerOf[id], "WRONG_FROM"); require(to != address(0), "INVALID_RECIPIENT"); require( msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id], "NOT_AUTHORIZED" ); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _balanceOf[from]--; _balanceOf[to]++; } _ownerOf[id] = to; delete getApproved[id]; emit Transfer(from, to, id); } function safeTransferFrom( address from, address to, uint256 id ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom( address from, address to, uint256 id, bytes calldata data ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721 interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 id) internal virtual { require(to != address(0), "INVALID_RECIPIENT"); require(_ownerOf[id] == address(0), "ALREADY_MINTED"); // Counter overflow is incredibly unrealistic. unchecked { _balanceOf[to]++; } _ownerOf[id] = to; emit Transfer(address(0), to, id); } function _burn(uint256 id) internal virtual { address owner = _ownerOf[id]; require(owner != address(0), "NOT_MINTED"); // Ownership check above ensures no underflow. unchecked { _balanceOf[owner]--; } delete _ownerOf[id]; delete getApproved[id]; emit Transfer(owner, address(0), id); } /*////////////////////////////////////////////////////////////// INTERNAL SAFE MINT LOGIC //////////////////////////////////////////////////////////////*/ function _safeMint(address to, uint256 id) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function _safeMint( address to, uint256 id, bytes memory data ) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } } /// @notice A generic interface for a contract which properly accepts ERC721 tokens. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721TokenReceiver { function onERC721Received( address, address, uint256, bytes calldata ) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Minimalist and gas efficient standard ERC1155 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol) abstract contract ERC1155 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event TransferSingle( address indexed operator, address indexed from, address indexed to, uint256 id, uint256 amount ); event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] amounts ); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); event URI(string value, uint256 indexed id); /*////////////////////////////////////////////////////////////// ERC1155 STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => mapping(uint256 => uint256)) public balanceOf; mapping(address => mapping(address => bool)) public isApprovedForAll; /*////////////////////////////////////////////////////////////// METADATA LOGIC //////////////////////////////////////////////////////////////*/ function uri(uint256 id) public view virtual returns (string memory); /*////////////////////////////////////////////////////////////// ERC1155 LOGIC //////////////////////////////////////////////////////////////*/ function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) public virtual { require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED"); balanceOf[from][id] -= amount; balanceOf[to][id] += amount; emit TransferSingle(msg.sender, from, to, id, amount); require( to.code.length == 0 ? to != address(0) : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, amount, data) == ERC1155TokenReceiver.onERC1155Received.selector, "UNSAFE_RECIPIENT" ); } function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) public virtual { require(ids.length == amounts.length, "LENGTH_MISMATCH"); require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED"); // Storing these outside the loop saves ~15 gas per iteration. uint256 id; uint256 amount; for (uint256 i = 0; i < ids.length; ) { id = ids[i]; amount = amounts[i]; balanceOf[from][id] -= amount; balanceOf[to][id] += amount; // An array can't have a total length // larger than the max uint256 value. unchecked { ++i; } } emit TransferBatch(msg.sender, from, to, ids, amounts); require( to.code.length == 0 ? to != address(0) : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) == ERC1155TokenReceiver.onERC1155BatchReceived.selector, "UNSAFE_RECIPIENT" ); } function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) public view virtual returns (uint256[] memory balances) { require(owners.length == ids.length, "LENGTH_MISMATCH"); balances = new uint256[](owners.length); // Unchecked because the only math done is incrementing // the array index counter which cannot possibly overflow. unchecked { for (uint256 i = 0; i < owners.length; ++i) { balances[i] = balanceOf[owners[i]][ids[i]]; } } } /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155 interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { balanceOf[to][id] += amount; emit TransferSingle(msg.sender, address(0), to, id, amount); require( to.code.length == 0 ? to != address(0) : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, amount, data) == ERC1155TokenReceiver.onERC1155Received.selector, "UNSAFE_RECIPIENT" ); } function _batchMint( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { uint256 idsLength = ids.length; // Saves MLOADs. require(idsLength == amounts.length, "LENGTH_MISMATCH"); for (uint256 i = 0; i < idsLength; ) { balanceOf[to][ids[i]] += amounts[i]; // An array can't have a total length // larger than the max uint256 value. unchecked { ++i; } } emit TransferBatch(msg.sender, address(0), to, ids, amounts); require( to.code.length == 0 ? to != address(0) : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) == ERC1155TokenReceiver.onERC1155BatchReceived.selector, "UNSAFE_RECIPIENT" ); } function _batchBurn( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { uint256 idsLength = ids.length; // Saves MLOADs. require(idsLength == amounts.length, "LENGTH_MISMATCH"); for (uint256 i = 0; i < idsLength; ) { balanceOf[from][ids[i]] -= amounts[i]; // An array can't have a total length // larger than the max uint256 value. unchecked { ++i; } } emit TransferBatch(msg.sender, from, address(0), ids, amounts); } function _burn( address from, uint256 id, uint256 amount ) internal virtual { balanceOf[from][id] -= amount; emit TransferSingle(msg.sender, from, address(0), id, amount); } } /// @notice A generic interface for a contract which properly accepts ERC1155 tokens. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol) abstract contract ERC1155TokenReceiver { function onERC1155Received( address, address, uint256, uint256, bytes calldata ) external virtual returns (bytes4) { return ERC1155TokenReceiver.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] calldata, uint256[] calldata, bytes calldata ) external virtual returns (bytes4) { return ERC1155TokenReceiver.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; /// @title AllowanceTransfer /// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts /// @dev Requires user's token approval on the Permit2 contract interface IAllowanceTransfer { /// @notice Thrown when an allowance on a token has expired. /// @param deadline The timestamp at which the allowed amount is no longer valid error AllowanceExpired(uint256 deadline); /// @notice Thrown when an allowance on a token has been depleted. /// @param amount The maximum amount allowed error InsufficientAllowance(uint256 amount); /// @notice Thrown when too many nonces are invalidated. error ExcessiveInvalidation(); /// @notice Emits an event when the owner successfully invalidates an ordered nonce. event NonceInvalidation( address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce ); /// @notice Emits an event when the owner successfully sets permissions on a token for the spender. event Approval( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration ); /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender. event Permit( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration, uint48 nonce ); /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function. event Lockdown(address indexed owner, address token, address spender); /// @notice The permit data for a token struct PermitDetails { // ERC20 token address address token; // the maximum amount allowed to spend uint160 amount; // timestamp at which a spender's token allowances become invalid uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice The permit message signed for a single token allownce struct PermitSingle { // the permit data for a single token alownce PermitDetails details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The permit message signed for multiple token allowances struct PermitBatch { // the permit data for multiple token allowances PermitDetails[] details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The saved permissions /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message /// @dev Setting amount to type(uint160).max sets an unlimited approval struct PackedAllowance { // amount allowed uint160 amount; // permission expiry uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice A token spender pair. struct TokenSpenderPair { // the token the spender is approved address token; // the spender address address spender; } /// @notice Details for a token transfer. struct AllowanceTransferDetails { // the owner of the token address from; // the recipient of the token address to; // the amount of the token uint160 amount; // the token to be transferred address token; } /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval. /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress] /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals. function allowance(address user, address token, address spender) external view returns (uint160 amount, uint48 expiration, uint48 nonce); /// @notice Approves the spender to use up to amount of the specified token up until the expiration /// @param token The token to approve /// @param spender The spender address to approve /// @param amount The approved amount of the token /// @param expiration The timestamp at which the approval is no longer valid /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve /// @dev Setting amount to type(uint160).max sets an unlimited approval function approve(address token, address spender, uint160 amount, uint48 expiration) external; /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitSingle Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external; /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitBatch Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external; /// @notice Transfer approved tokens from one address to another /// @param from The address to transfer from /// @param to The address of the recipient /// @param amount The amount of the token to transfer /// @param token The token address to transfer /// @dev Requires the from address to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(address from, address to, uint160 amount, address token) external; /// @notice Transfer approved tokens in a batch /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers /// @dev Requires the from addresses to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external; /// @notice Enables performing a "lockdown" of the sender's Permit2 identity /// by batch revoking approvals /// @param approvals Array of approvals to revoke. function lockdown(TokenSpenderPair[] calldata approvals) external; /// @notice Invalidate nonces for a given (token, spender) pair /// @param token The token to invalidate nonces for /// @param spender The spender to invalidate nonces for /// @param newNonce The new nonce to set. Invalidates all nonces less than it. /// @dev Can't invalidate more than 2**16 nonces per transaction. function invalidateNonces(address token, address spender, uint48 newNonce) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; /// @title Interface for CryptoPunksMarket interface ICryptoPunksMarket { /// @notice Buy a cryptopunk function buyPunk(uint256 punkIndex) external payable; /// @notice Transfer a cryptopunk to another address function transferPunk(address to, uint256 punkIndex) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; library SwapRoute { struct Route { address from; address to; bool stable; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.15; import {ERC20} from 'solmate/src/tokens/ERC20.sol'; /// @title LooksRare Rewards Collector /// @notice Implements a permissionless call to fetch LooksRare rewards earned by Universal Router users /// and transfers them to an external rewards distributor contract interface IRewardsCollector { /// @notice Fetches users' LooksRare rewards and sends them to the distributor contract /// @param looksRareClaim The data required by LooksRare to claim reward tokens function collectRewards(bytes calldata looksRareClaim) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Ramses V3 Factory /// @notice The Ramses V3 Factory facilitates creation of Ramses V3 pools and control over the protocol fees interface IRamsesV3Factory { error IT(); /// @dev Fee Too Large error FTL(); error A0(); error F0(); error PE(); /// @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 tickspacing amount is enabled for pool creation via the factory /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param fee The fee, denominated in hundredths of a bip event TickSpacingEnabled(int24 indexed tickSpacing, uint24 indexed fee); /// @notice Emitted when the protocol fee is changed /// @param feeProtocolOld The previous value of the protocol fee /// @param feeProtocolNew The updated value of the protocol fee event SetFeeProtocol(uint8 feeProtocolOld, uint8 feeProtocolNew); /// @notice Emitted when the protocol fee is changed /// @param pool The pool address /// @param feeProtocolOld The previous value of the protocol fee /// @param feeProtocolNew The updated value of the protocol fee event SetPoolFeeProtocol(address pool, uint8 feeProtocolOld, uint8 feeProtocolNew); /// @notice Emitted when a pool's fee is changed /// @param pool The pool address /// @param newFee The updated value of the protocol fee event FeeAdjustment(address pool, uint24 newFee); /// @notice Emitted when the fee collector is changed /// @param oldFeeCollector The previous implementation /// @param newFeeCollector The new implementation event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector); /// @notice Returns the PoolDeployer address /// @return The address of the PoolDeployer contract function ramsesV3PoolDeployer() external returns (address); /// @notice Returns the fee amount for a given tickSpacing, if enabled, or 0 if not enabled /// @dev A tickSpacing can never be removed, so this value should be hard coded or cached in the calling context /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tickSpacing The enabled tickSpacing. Returns 0 in case of unenabled tickSpacing /// @return initialFee The initial fee function tickSpacingInitialFee(int24 tickSpacing) external view returns (uint24 initialFee); /// @notice Returns the pool address for a given pair of tokens and a tickSpacing, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param tickSpacing The tickSpacing of the pool /// @return pool The pool address function getPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param tickSpacing The desired tickSpacing for the pool /// @param sqrtPriceX96 initial sqrtPriceX96 of the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. /// @dev The call will revert if the pool already exists, the tickSpacing is invalid, or the token arguments are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, int24 tickSpacing, uint160 sqrtPriceX96 ) external returns (address pool); /// @notice Enables a tickSpacing with the given initialFee amount /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @dev tickSpacings may never be removed once enabled /// @param tickSpacing The spacing between ticks to be enforced for all pools created /// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6) function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external; /// @notice returns the default protocol fee. /// @return _feeProtocol the default feeProtocol function feeProtocol() external view returns (uint8 _feeProtocol); /// @notice returns the % of fees directed to governance /// @dev if the fee is 0, or the pool is uninitialized this will return the Factory's default feeProtocol /// @param pool the address of the pool /// @return _feeProtocol the feeProtocol for the pool function poolFeeProtocol(address pool) external view returns (uint8 _feeProtocol); /// @notice Sets the default protocol's % share of the fees /// @param _feeProtocol new default protocol fee for token0 and token1 function setFeeProtocol(uint8 _feeProtocol) external; /// @notice Get the parameters to be used in constructing the pool, set transiently during pool creation. /// @dev Called by the pool constructor to fetch the parameters of the pool /// @return factory The factory address /// @return token0 The first token of the pool by address sort order /// @return token1 The second token of the pool by address sort order /// @return fee The initialized feetier of the pool, denominated in hundredths of a bip /// @return tickSpacing The minimum number of ticks between initialized ticks function parameters() external view returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing); /// @notice Sets the fee collector address /// @param _feeCollector the fee collector address function setFeeCollector(address _feeCollector) external; /// @notice sets the swap fee for a specific pool /// @param _pool address of the pool /// @param _fee the fee to be assigned to the pool, scaled to 1_000_000 = 100% function setFee(address _pool, uint24 _fee) external; /// @notice Returns the address of the fee collector contract /// @dev Fee collector decides where the protocol fees go (fee distributor, treasury, etc.) function feeCollector() external view returns (address); /// @notice sets the feeProtocol of a specific pool /// @param pool address of the pool /// @param _feeProtocol the fee protocol to assign function setPoolFeeProtocol(address pool, uint8 _feeProtocol) external; /// @notice sets the feeProtocol upon a gauge's creation /// @param pool address of the pool function gaugeFeeSplitEnable(address pool) external; /// @notice sets the the voter address /// @param _voter the address of the voter function setVoter(address _voter) external; function initialize(address poolDeployer) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC-721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC-721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC-1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC-1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; interface IPair { error NOT_AUTHORIZED(); error UNSTABLE_RATIO(); /// @dev safe transfer failed error STF(); error OVERFLOW(); /// @dev skim disabled error SD(); /// @dev insufficient liquidity minted error ILM(); /// @dev insufficient liquidity burned error ILB(); /// @dev insufficient output amount error IOA(); /// @dev insufficient input amount error IIA(); error IL(); error IT(); error K(); event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); /// @notice initialize the pool, called only once programatically function initialize( address _token0, address _token1, bool _stable ) external; /// @notice calculate the current reserves of the pool and their last 'seen' timestamp /// @return _reserve0 amount of token0 in reserves /// @return _reserve1 amount of token1 in reserves /// @return _blockTimestampLast the timestamp when the pool was last updated function getReserves() external view returns ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast ); /// @notice mint the pair tokens (LPs) /// @param to where to mint the LP tokens to /// @return liquidity amount of LP tokens to mint function mint(address to) external returns (uint256 liquidity); /// @notice burn the pair tokens (LPs) /// @param to where to send the underlying /// @return amount0 amount of amount0 /// @return amount1 amount of amount1 function burn( address to ) external returns (uint256 amount0, uint256 amount1); /// @notice direct swap through the pool function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; /// @notice force balances to match reserves, can be used to harvest rebases from rebasing tokens or other external factors /// @param to where to send the excess tokens to function skim(address to) external; /// @notice force reserves to match balances, prevents skim excess if skim is enabled function sync() external; /// @notice set the pair fees contract address function setFeeRecipient(address _pairFees) external; /// @notice set the feesplit variable function setFeeSplit(uint256 _feeSplit) external; /// @notice sets the swap fee of the pair /// @dev max of 10_000 (10%) /// @param _fee the fee function setFee(uint256 _fee) external; /// @notice 'mint' the fees as LP tokens /// @dev this is used for protocol/voter fees function mintFee() external; /// @notice calculates the amount of tokens to receive post swap /// @param amountIn the token amount /// @param tokenIn the address of the token function getAmountOut( uint256 amountIn, address tokenIn ) external view returns (uint256 amountOut); /// @notice returns various metadata about the pair function metadata() external view returns ( uint256 _decimals0, uint256 _decimals1, uint256 _reserve0, uint256 _reserve1, bool _stable, address _token0, address _token1 ); /// @notice returns the feeSplit of the pair function feeSplit() external view returns (uint256); /// @notice returns the fee of the pair function fee() external view returns (uint256); /// @notice returns the feeRecipient of the pair function feeRecipient() external view returns (address); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.0; import {IPair} from "./../../../../../interfaces/IPair.sol"; import {SwapRoute} from "../../../libraries/SwapRoute.sol"; import {IPairFactory} from "./../../../../../interfaces/IPairFactory.sol"; /// @title Ramses legacy Helper Library /// @notice Calculates the recipient address for a command library RamsesLegacyLibrary { error INVALID_RESERVES(); error INVALID_PATH(); /// @notice Calculates the address for a pair without making any external calls /// @param factory The address of the factory /// @param initCodeHash The hash of the pair initcode /// @param tokenA One of the tokens in the pair /// @param tokenB The other token in the pair /// @param stable If pair is xy(x^2 + y^2) /// @return pair The resultant pair address function pairFor( address factory, bytes32 initCodeHash, address tokenA, address tokenB, bool stable ) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = pairForPreSorted(factory, initCodeHash, token0, token1, stable); } /// @notice Calculates the address for a pair and the pair's token0 /// @param factory The address of the factory /// @param initCodeHash The hash of the pair initcode /// @param tokenA One of the tokens in the pair /// @param tokenB The other token in the pair /// @param stable If pair is xy(x^2 + y^2) /// @return pair The resultant pair address /// @return token0 The token considered token0 in this pair function pairAndToken0For( address factory, bytes32 initCodeHash, address tokenA, address tokenB, bool stable ) internal pure returns (address pair, address token0) { address token1; (token0, token1) = sortTokens(tokenA, tokenB); pair = pairForPreSorted(factory, initCodeHash, token0, token1, stable); } /// @notice Calculates the address for a pair assuming the input tokens are pre-sorted /// @param factory The address of the factory /// @param initCodeHash The hash of the pair initcode /// @param token0 The pair's token0 /// @param token1 The pair's token1 /// @param stable If pair is xy(x^2 + y^2) /// @return pair The resultant pair address function pairForPreSorted( address factory, bytes32 initCodeHash, address token0, address token1, bool stable ) private pure returns (address pair) { pair = address( uint160( uint256( keccak256( abi.encodePacked( hex"ff", factory, keccak256(abi.encodePacked(token0, token1, stable)), initCodeHash ) ) ) ) ); } /// @notice Calculates the address for a pair and fetches the reserves for each token /// @param factory The address of the factory /// @param initCodeHash The hash of the pair initcode /// @param tokenA One of the tokens in the pair /// @param tokenB The other token in the pair /// @param stable If pair is xy(x^2 + y^2) /// @return pair The resultant pair address /// @return reserveA The reserves for tokenA /// @return reserveB The reserves for tokenB function pairAndReservesFor( address factory, bytes32 initCodeHash, address tokenA, address tokenB, bool stable ) private view returns ( address pair, uint256 reserveA, uint256 reserveB, uint256 decimalsA, uint256 decimalsB ) { address token0; (pair, token0) = pairAndToken0For( factory, initCodeHash, tokenA, tokenB, stable ); ( uint256 decimals0, uint256 decimals1, uint256 reserve0, uint256 reserve1, , , ) = IPair(pair).metadata(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); if (stable) { (decimalsA, decimalsB) = tokenA == token0 ? (decimals0, decimals1) : (decimals1, decimals0); } } /// @notice Given an input asset amount returns the maximum output amount of the other asset /// @param amountIn The token input amount /// @param reserveIn The reserves available of the input token /// @param reserveOut The reserves available of the output token /// @return amountOut The output amount of the output token function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut, bool stable, uint256 decimalsIn, uint256 decimalsOut ) internal pure returns (uint256 amountOut) { if (stable) { uint256 k = _k(reserveIn, reserveOut, decimalsIn, decimalsOut); reserveIn = (reserveIn * 1e18) / decimalsIn; reserveOut = (reserveOut * 1e18) / decimalsOut; amountIn = (amountIn * 1e18) / decimalsIn; uint256 y = reserveOut - _get_y( amountIn + reserveIn, k, reserveOut, decimalsIn, decimalsOut ); amountOut = (y * decimalsOut) / 1e18; } else { amountOut = (amountIn * reserveOut) / (reserveIn + amountIn); } } /// @notice Returns the input amount needed for a desired output amount in a single-hop trade /// @param amountOut The desired output amount /// @param reserveIn The reserves available of the input token /// @param reserveOut The reserves available of the output token /// @return amountIn The input amount of the input token function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut, uint256 decimalsIn, uint256 decimalsOut, bool stable ) internal pure returns (uint256 amountIn) { if (reserveIn == 0 || reserveOut == 0) revert INVALID_RESERVES(); if (stable) { uint256 k = _k(reserveIn, reserveOut, decimalsIn, decimalsOut); reserveIn = (reserveIn * 1e18) / decimalsIn; reserveOut = (reserveOut * 1e18) / decimalsOut; amountOut = (amountOut * 1e18) / decimalsIn; uint256 y = _get_y( reserveOut - amountOut, k, reserveIn, decimalsIn, decimalsOut ) - reserveIn; amountIn = (y * decimalsIn) / 1e18; } else { amountIn = (reserveIn * amountOut) / (reserveOut - amountOut); } } // fetches and sorts the reserves for a pair function getReserves( address factory, bytes32 initCodeHash, address tokenA, address tokenB, bool stable ) internal view returns (uint256 reserveA, uint256 reserveB, uint256 decimalsA, uint256 decimalsB) { (address token0, ) = sortTokens(tokenA, tokenB); (uint256 decimals0, uint256 decimals1, uint256 reserve0, uint256 reserve1, , , ) = IPair( pairFor(factory, initCodeHash, tokenA, tokenB, stable) ).metadata(); (reserveA, reserveB, decimalsA, decimalsB) = tokenA == token0 ? (reserve0, reserve1, decimals0, decimals1) : (reserve1, reserve0, decimals1, decimals0); } /// @notice Returns the input amount needed for a desired output amount in a multi-hop trade /// @param factory The address of the v2 factory /// @param initCodeHash The hash of the pair initcode /// @param amountOut The desired output amount /// @param path The path of the multi-hop trade /// @return amount The input amount of the input token /// @return pair The first pair in the trade function getAmountInMultihop( address factory, bytes32 initCodeHash, uint256 amountOut, SwapRoute.Route[] memory path ) internal view returns (uint256 amount, address pair) { if (path.length < 2) revert INVALID_PATH(); amount = amountOut; for (uint256 i = path.length - 1; i > 0; i--) { uint256 reserveIn; uint256 reserveOut; uint256 decimalsIn; uint256 decimalsOut; ( pair, reserveIn, reserveOut, decimalsIn, decimalsOut ) = pairAndReservesFor( factory, initCodeHash, path[i].from, path[i].to, path[i].stable ); amount = getAmountIn( amount, reserveIn, reserveOut, decimalsIn, decimalsOut, path[i].stable ); amount += (amount * IPairFactory(factory).pairFee(pair)) / 1_000_000; } } /// @notice Sorts two tokens to return token0 and token1 /// @param tokenA The first token to sort /// @param tokenB The other token to sort /// @return token0 The smaller token by address value /// @return token1 The larger token by address value function sortTokens( address tokenA, address tokenB ) internal pure returns (address token0, address token1) { (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); } /// @notice solve k = xy(x^2 + y^2) /// @param reserve0 The reserves available of token0 /// @param reserve1 The reserves available of token1 /// @param decimals0 10** decimals of the token0 /// @param decimals1 10**decimals of the token1 /// @return k function _k( uint256 reserve0, uint256 reserve1, uint256 decimals0, uint256 decimals1 ) internal pure returns (uint256 k) { uint256 _x = (reserve0 * 1e18) / decimals0; uint256 _y = (reserve1 * 1e18) / decimals1; uint256 _a = (_x * _y) / 1e18; uint256 _b = ((_x * _x) / 1e18 + (_y * _y) / 1e18); k = (_a * _b) / 1e18; } function _f(uint256 x0, uint256 y) internal pure returns (uint256) { uint256 _a = (x0 * y) / 1e18; uint256 _b = ((x0 * x0) / 1e18 + (y * y) / 1e18); return (_a * _b) / 1e18; } function _d(uint256 x0, uint256 y) internal pure returns (uint256) { return (3 * x0 * ((y * y) / 1e18)) / 1e18 + ((((x0 * x0) / 1e18) * x0) / 1e18); } function _get_y( uint256 x0, uint256 xy, uint256 y, uint256 decimals0, uint256 decimals1 ) internal pure returns (uint256 _y) { for (uint256 i = 0; i < 255; i++) { uint256 k = _f(x0, y); if (k < xy) { uint256 dy = ((xy - k) * 1e18) / _d(x0, y); if (dy == 0) { if (k == xy) { return y; } if (_k(x0, y + 1, decimals0, decimals1) > xy) { return y + 1; } dy = 1; } y = y + dy; } else { uint256 dy = ((k - xy) * 1e18) / _d(x0, y); if (dy == 0) { if (k == xy || _f(x0, y - 1) < xy) { return y; } dy = 1; } y = y - dy; } } } }
pragma solidity ^0.8.17; import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol"; import {SafeCast160} from "permit2/src/libraries/SafeCast160.sol"; import {Payments} from "./Payments.sol"; import {Constants} from "../libraries/Constants.sol"; import {RouterImmutables} from "../base/RouterImmutables.sol"; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; /// @title Payments through Permit2 /// @notice Performs interactions with Permit2 to transfer tokens abstract contract Permit2Payments is Payments { using SafeCast160 for uint256; error FromAddressIsNotOwner(); /// @notice Performs a transferFrom on Permit2 /// @param token The token to transfer /// @param from The address to transfer from /// @param to The recipient of the transfer /// @param amount The amount to transfer function permit2TransferFrom( address token, address from, address to, uint160 amount ) internal { (uint160 allowed, uint48 expiration, ) = PERMIT2.allowance( from, token, to ); if (allowed == 0 || expiration < block.timestamp) { IERC20(token).transferFrom(from, to, amount); } else { PERMIT2.transferFrom(from, to, amount, token); } } /// @notice Performs a batch transferFrom on Permit2 /// @param batchDetails An array detailing each of the transfers that should occur function permit2TransferFrom( IAllowanceTransfer.AllowanceTransferDetails[] memory batchDetails, address owner ) internal { uint256 batchLength = batchDetails.length; for (uint256 i = 0; i < batchLength; ++i) { if (batchDetails[i].from != owner) revert FromAddressIsNotOwner(); } PERMIT2.transferFrom(batchDetails); } /// @notice Either performs a regular payment or transferFrom on Permit2, depending on the payer address /// @param token The token to transfer /// @param payer The address to pay for the transfer /// @param recipient The recipient of the transfer /// @param amount The amount to transfer function payOrPermit2Transfer( address token, address payer, address recipient, uint256 amount ) internal { if (payer == address(this)) pay(token, recipient, amount); else permit2TransferFrom(token, payer, recipient, amount.toUint160()); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IWETH9} from "../interfaces/external/IWETH9.sol"; /// @title Constant state /// @notice Constant state used by the Universal Router library Constants { /// @dev Used for identifying cases when this contract's balance of a token is to be used as an input /// This value is equivalent to 1<<255, i.e. a singular 1 in the most significant bit. uint256 internal constant CONTRACT_BALANCE = 0x8000000000000000000000000000000000000000000000000000000000000000; /// @dev Used for identifying cases when a v2 pair has already received input tokens uint256 internal constant ALREADY_PAID = 0; /// @dev Used as a flag for identifying the transfer of ETH instead of a token address internal constant ETH = address(0); /// @dev Used as a flag for identifying that msg.sender should be used, saves gas by sending more 0 bytes address internal constant MSG_SENDER = address(1); /// @dev Used as a flag for identifying address(this) should be used, saves gas by sending more 0 bytes address internal constant ADDRESS_THIS = address(2); /// @dev The length of the bytes encoded address uint256 internal constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 internal constant V3_FEE_SIZE = 3; /// @dev The offset of a single token address (20) and pool fee (3) uint256 internal constant NEXT_V3_POOL_OFFSET = ADDR_SIZE + V3_FEE_SIZE; /// @dev The offset of an encoded pool key /// Token (20) + Fee (3) + Token (20) = 43 uint256 internal constant V3_POP_OFFSET = NEXT_V3_POOL_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 internal constant MULTIPLE_V3_POOLS_MIN_LENGTH = V3_POP_OFFSET + NEXT_V3_POOL_OFFSET; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; interface IPairFactory { error FEE_TOO_HIGH(); error ZERO_FEE(); /// @dev invalid assortment error IA(); /// @dev zero address error ZA(); /// @dev pair exists error PE(); error NOT_AUTHORIZED(); error INVALID_FEE_SPLIT(); event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); event SetFee(uint256 indexed fee); event SetPairFee(address indexed pair, uint256 indexed fee); event SetFeeSplit(uint256 indexed _feeSplit); event SetPairFeeSplit(address indexed pair, uint256 indexed _feeSplit); event SkimStatus(address indexed _pair, bool indexed _status); event NewTreasury(address indexed _caller, address indexed _newTreasury); event FeeSplitWhenNoGauge(address indexed _caller, bool indexed _status); event SetFeeRecipient(address indexed pair, address indexed feeRecipient); /// @notice returns the total length of legacy pairs /// @return _length the length function allPairsLength() external view returns (uint256 _length); /// @notice calculates if the address is a legacy pair /// @param pair the address to check /// @return _boolean the bool return function isPair(address pair) external view returns (bool _boolean); /// @notice calculates the pairCodeHash /// @return _hash the pair code hash function pairCodeHash() external view returns (bytes32 _hash); /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param stable whether it uses the stable curve /// @return _pair the address of the pair function getPair( address tokenA, address tokenB, bool stable ) external view returns (address _pair); /// @notice creates a new legacy pair /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param stable whether it uses the stable curve /// @return pair the address of the created pair function createPair( address tokenA, address tokenB, bool stable ) external returns (address pair); /// @notice the address of the voter /// @return _voter the address of the voter function voter() external view returns (address _voter); /// @notice returns the address of a pair based on the index /// @param _index the index to check for a pair /// @return _pair the address of the pair at the index function allPairs(uint256 _index) external view returns (address _pair); /// @notice the swap fee of a pair /// @param _pair the address of the pair /// @return _fee the fee function pairFee(address _pair) external view returns (uint256 _fee); /// @notice the split of fees /// @return _split the feeSplit function feeSplit() external view returns (uint256 _split); /// @notice sets the swap fee for a pair /// @param _pair the address of the pair /// @param _fee the fee for the pair function setPairFee(address _pair, uint256 _fee) external; /// @notice set the swap fees of the pair /// @param _fee the fee, scaled to MAX 10% of 100_000 function setFee(uint256 _fee) external; /// @notice the address for the treasury /// @return _treasury address of the treasury function treasury() external view returns (address _treasury); /// @notice sets the pairFees contract /// @param _pair the address of the pair /// @param _pairFees the address of the new Pair Fees function setFeeRecipient(address _pair, address _pairFees) external; /// @notice sets the feeSplit for a pair /// @param _pair the address of the pair /// @param _feeSplit the feeSplit function setPairFeeSplit(address _pair, uint256 _feeSplit) external; /// @notice whether there is feeSplit when there's no gauge /// @return _boolean whether there is a feesplit when no gauge function feeSplitWhenNoGauge() external view returns (bool _boolean); /// @notice whether a pair can be skimmed /// @param _pair the pair address /// @return _boolean whether skim is enabled function skimEnabled(address _pair) external view returns (bool _boolean); /// @notice set whether skim is enabled for a specific pair function setSkimEnabled(address _pair, bool _status) external; /// @notice sets a new treasury address /// @param _treasury the new treasury address function setTreasury(address _treasury) external; /// @notice set whether there should be a feesplit without gauges /// @param status whether enabled or not function setFeeSplitWhenNoGauge(bool status) external; /// @notice sets the feesSplit globally /// @param _feeSplit the fee split function setFeeSplit(uint256 _feeSplit) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.0; import {BytesLib} from './BytesLib.sol'; import {Constants} from '../../../libraries/Constants.sol'; /// @title Functions for manipulating path data for multihop swaps library V3Path { using BytesLib for bytes; /// @notice Returns true iff the path contains two or more pools /// @param path The encoded swap path /// @return True if path contains two or more pools, otherwise false function hasMultiplePools(bytes calldata path) internal pure returns (bool) { return path.length >= Constants.MULTIPLE_V3_POOLS_MIN_LENGTH; } /// @notice Decodes the first pool in path /// @param path The bytes encoded swap path /// @return tokenIn The first token of the given pool /// @return tickSpacing The tickSpacing of the pool /// @return tokenOut The second token of the given pool function decodeFirstPool(bytes calldata path) internal pure returns (address,int24,address) { return path.toPool(); } /// @notice Gets the segment corresponding to the first pool in the path /// @param path The bytes encoded swap path /// @return The segment containing all data necessary to target the first pool in the path function getFirstPool(bytes calldata path) internal pure returns (bytes calldata) { return path[:Constants.V3_POP_OFFSET]; } function decodeFirstToken(bytes calldata path) internal pure returns (address tokenA) { tokenA = path.toAddress(); } /// @notice Skips a token + fee element /// @param path The swap path function skipToken(bytes calldata path) internal pure returns (bytes calldata) { return path[Constants.NEXT_V3_POOL_OFFSET:]; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2 ** 255); z = int256(y); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IRamsesV3PoolImmutables} from './pool/IRamsesV3PoolImmutables.sol'; import {IRamsesV3PoolState} from './pool/IRamsesV3PoolState.sol'; import {IRamsesV3PoolDerivedState} from './pool/IRamsesV3PoolDerivedState.sol'; import {IRamsesV3PoolActions} from './pool/IRamsesV3PoolActions.sol'; import {IRamsesV3PoolOwnerActions} from './pool/IRamsesV3PoolOwnerActions.sol'; import {IRamsesV3PoolErrors} from './pool/IRamsesV3PoolErrors.sol'; import {IRamsesV3PoolEvents} from './pool/IRamsesV3PoolEvents.sol'; /// @title The interface for a Ramses V3 Pool /// @notice A Ramses 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 IRamsesV3Pool is IRamsesV3PoolImmutables, IRamsesV3PoolState, IRamsesV3PoolDerivedState, IRamsesV3PoolActions, IRamsesV3PoolOwnerActions, IRamsesV3PoolErrors, IRamsesV3PoolEvents { /// @notice if a new period, advance on interaction function _advancePeriod() external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @dev original UniswapV3 callbacks maintained to ensure seamless integrations /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; }
// SPDX-License-Identifier: 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); }
// 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 pragma solidity ^0.8.17; library SafeCast160 { /// @notice Thrown when a valude greater than type(uint160).max is cast to uint160 error UnsafeCast(); /// @notice Safely casts uint256 to uint160 /// @param value The uint256 to be cast function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) revert UnsafeCast(); return uint160(value); } }
// 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: 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 IRamsesV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IRamsesV3Factory 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 IRamsesV3PoolState { /// @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 ); /// @notice get the period seconds in range of a specific position /// @param period the period number /// @param owner owner address /// @param index position index /// @param tickLower lower bound of range /// @param tickUpper upper bound of range /// @return periodSecondsInsideX96 seconds the position was not in range for the period function positionPeriodSecondsInRange( uint256 period, address owner, uint256 index, int24 tickLower, int24 tickUpper ) external view returns (uint256 periodSecondsInsideX96); }
// 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 IRamsesV3PoolDerivedState { /// @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 IRamsesV3PoolActions { /// @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 index The index 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, uint256 index, 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 index The index of the position to be 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, uint256 index, 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 index The index for which the liquidity will be burned /// @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( uint256 index, 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 IRamsesV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees function setFeeProtocol() 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); function setFee(uint24 _fee) external; }
// 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 IRamsesV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); error SPL(); }
// 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 IRamsesV3PoolEvents { /// @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); }
{ "remappings": [ "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "forge-std/=dependencies/forge-std-1.9.4/src/", "permit2/=lib/permit2/", "@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/", "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/", "hardhat/=node_modules/hardhat/", "solmate/=node_modules/solmate/" ], "optimizer": { "enabled": true, "runs": 2633 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"components":[{"internalType":"address","name":"permit2","type":"address"},{"internalType":"address","name":"weth9","type":"address"},{"internalType":"address","name":"seaportV1_5","type":"address"},{"internalType":"address","name":"seaportV1_4","type":"address"},{"internalType":"address","name":"openseaConduit","type":"address"},{"internalType":"address","name":"nftxZap","type":"address"},{"internalType":"address","name":"x2y2","type":"address"},{"internalType":"address","name":"foundation","type":"address"},{"internalType":"address","name":"sudoswap","type":"address"},{"internalType":"address","name":"elementMarket","type":"address"},{"internalType":"address","name":"nft20Zap","type":"address"},{"internalType":"address","name":"cryptopunks","type":"address"},{"internalType":"address","name":"looksRareV2","type":"address"},{"internalType":"address","name":"routerRewardsDistributor","type":"address"},{"internalType":"address","name":"looksRareRewardsDistributor","type":"address"},{"internalType":"address","name":"looksRareToken","type":"address"},{"internalType":"address","name":"v2Factory","type":"address"},{"internalType":"address","name":"v3Factory","type":"address"},{"internalType":"bytes32","name":"pairInitCodeHash","type":"bytes32"},{"internalType":"bytes32","name":"poolInitCodeHash","type":"bytes32"}],"internalType":"struct RouterParameters","name":"params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BalanceTooLow","type":"error"},{"inputs":[],"name":"BuyPunkFailed","type":"error"},{"inputs":[],"name":"ContractLocked","type":"error"},{"inputs":[],"name":"ETHNotAccepted","type":"error"},{"inputs":[{"internalType":"uint256","name":"commandIndex","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"ExecutionFailed","type":"error"},{"inputs":[],"name":"FromAddressIsNotOwner","type":"error"},{"inputs":[],"name":"INSUFFICIENT_ETH","type":"error"},{"inputs":[],"name":"INSUFFICIENT_TOKEN","type":"error"},{"inputs":[],"name":"INVALID_BIPS","type":"error"},{"inputs":[],"name":"INVALID_PATH","type":"error"},{"inputs":[],"name":"INVALID_RESERVES","type":"error"},{"inputs":[],"name":"INVALID_SPENDER","type":"error"},{"inputs":[{"internalType":"uint256","name":"commandType","type":"uint256"}],"name":"InvalidCommandType","type":"error"},{"inputs":[],"name":"InvalidOwnerERC1155","type":"error"},{"inputs":[],"name":"InvalidOwnerERC721","type":"error"},{"inputs":[],"name":"LENGTH_MISMATCH","type":"error"},{"inputs":[],"name":"SliceOutOfBounds","type":"error"},{"inputs":[],"name":"TransactionDeadlinePassed","type":"error"},{"inputs":[],"name":"UnableToClaim","type":"error"},{"inputs":[],"name":"UnsafeCast","type":"error"},{"inputs":[],"name":"V2INVALID_PATH","type":"error"},{"inputs":[],"name":"V2TooLittleReceived","type":"error"},{"inputs":[],"name":"V2TooMuchRequested","type":"error"},{"inputs":[],"name":"V3InvalidAmountOut","type":"error"},{"inputs":[],"name":"V3InvalidCaller","type":"error"},{"inputs":[],"name":"V3InvalidSwap","type":"error"},{"inputs":[],"name":"V3TooLittleReceived","type":"error"},{"inputs":[],"name":"V3TooMuchRequested","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsSent","type":"event"},{"inputs":[{"internalType":"bytes","name":"looksRareClaim","type":"bytes"}],"name":"collectRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"commands","type":"bytes"},{"internalType":"bytes[]","name":"inputs","type":"bytes[]"}],"name":"execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"commands","type":"bytes"},{"internalType":"bytes[]","name":"inputs","type":"bytes[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
61032060405234610403576102806145ab80380380916100218261032061042e565b61032039126104035760405161028081016001600160401b0381118282101761041a575f91602091604052610057610320610451565b8082526100678361032001610451565b82840152610076610360610451565b6040830152610086610380610451565b60608301526100966103a0610451565b60808301526100a66103c0610451565b60a08301526100b66103e0610451565b60c08301526100c6610400610451565b60e08301526100d6610420610451565b6101008301526100e7610440610451565b6101208301526100f8610460610451565b610140830152610109610480610451565b61016083015261011a6104a0610451565b61018083015261012b6104c0610451565b6101a083015261013c6104e0610451565b6101c083015261014d610500610451565b6101e083015261015e610520610451565b61020083015261016f610540610451565b61022083810191825261056051610240808601918252610580516102608088019182526001600160a01b0396871660a090815289890151881660809081526040808b01518a1660c090815260608c01518b1660e0908152928c01518b16610100908152938c01518b16610120908152908c01518b16610140908152928c01518b16610160908152938c01518b16610180908152908c01518b166101a0908152928c01518b166101c0908152938c01518b166101e0908152908c01518b16610200908152908c01518b16909852918a0151891690945292880151871690529290950151841661028052516102a05290519091166102c081905290516102e0529051635fa4d14960e11b815292839160049183915af190811561040f575f916103d1575b50610300525f195f55600180546001600160a01b031916905560405161414590816104668239608051818181611c6a0152611dd7015260a051818181610fb101528181611b0501528181611fa20152613585015260c05181612242015260e05181612b2901526101005181612cc1015261012051816122f201526101405181818161272a01526128320152610160518161293a0152610180518181816127840152612d9e01526101a05181612ac301526101c051816127dc01526101e0518161232e0152610200518161229a0152610220518161044401526102405181610400015261026051816104ac0152610280518181816114be015281816116a001528181613a040152613b8101526102a05181818161149d015281816116c20152613b6001526102c0518150506102e05181613133015261030051816130f30152f35b90506020813d602011610407575b816103ec6020938361042e565b81010312610403576103fd90610451565b5f610291565b5f80fd5b3d91506103df565b6040513d5f823e3d90fd5b634e487b7160e01b5f52604160045260245ffd5b601f909101601f19168101906001600160401b0382119082101761041a57604052565b51906001600160a01b03821682036104035756fe60e080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816301ffc9a71461081557508063150b7a02146107a657806324856bc31461070f5780633593564c146105ec578063709a1cc2146103b9578063bc197c8114610306578063f23a6e61146102975763fa461e3314610080575f61000f565b346101b15760606003193601126101b15760243560043560443567ffffffffffffffff81116101b1576100b7903690600401610924565b5f83139182158061028d575b610265578181016040828203126101b15781359067ffffffffffffffff82116101b1576100f1918301612f09565b506020810135916001600160a01b0383168093036101b157610112916137a5565b601790602b831061023d578035968760601c9561013f62ffffff8585013560601c9a60481c168a89613082565b6001600160a01b0333911603610215571561020b57508685105b1561016d5750505061001a9350339161318a565b91935091939482602b0180602b116101f75784106101b557508282116101b1578101910390600160ff1b8410156101b15761001a936101ac3391612f4f565b6131f5565b5f80fd5b925050505f9291925482116101cf5761001a92339161318a565b7f739dbe52000000000000000000000000000000000000000000000000000000005f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b9550848710610159565b7f32b13d91000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f3b99b53d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f316cf0eb000000000000000000000000000000000000000000000000000000005f5260045ffd5b505f8513156100c3565b346101b15760a06003193601126101b1576102b06108e4565b506102b96108fa565b5060843567ffffffffffffffff81116101b1576102da903690600401610924565b505060206040517ff23a6e61000000000000000000000000000000000000000000000000000000008152f35b346101b15760a06003193601126101b15761031f6108e4565b506103286108fa565b5060443567ffffffffffffffff81116101b157610349903690600401610952565b505060643567ffffffffffffffff81116101b15761036b903690600401610952565b505060843567ffffffffffffffff81116101b15761038d903690600401610924565b505060206040517fbc197c81000000000000000000000000000000000000000000000000000000008152f35b346101b15760206003193601126101b15760043567ffffffffffffffff81116101b1575f6103ec81923690600401610924565b9081604051928392833781018381520390827f00000000000000000000000000000000000000000000000000000000000000005af1610429612ecd565b50156105c4576040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602082602481845afa918215610585575f92610590575b506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660048201526024810183905290602090829060449082905f905af1801561058557610527575b7f1e8f03f716bc104bf7d728131967a0c771e85ab54d09c1e2d6ed9e0bc4e2a16c602083604051908152a1005b6020813d60201161057d575b8161054060209383612e8e565b810103126101b1577f1e8f03f716bc104bf7d728131967a0c771e85ab54d09c1e2d6ed9e0bc4e2a16c91610575602092612efc565b5091506104fa565b3d9150610533565b6040513d5f823e3d90fd5b9091506020813d6020116105bc575b816105ac60209383612e8e565b810103126101b157519082610483565b3d915061059f565b7f7d529919000000000000000000000000000000000000000000000000000000005f5260045ffd5b60606003193601126101b15760043567ffffffffffffffff81116101b157610618903690600401610924565b60243567ffffffffffffffff81116101b157610638903690600401610952565b9160443542116106e7573330146106de57600154936001600160a01b0385166106b65761068c947fffffffffffffffffffffffff0000000000000000000000000000000000000000339116176001556109a8565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055005b7f6f5ffb7e000000000000000000000000000000000000000000000000000000005f5260045ffd5b61001a936109a8565b7f5bf6f916000000000000000000000000000000000000000000000000000000005f5260045ffd5b60406003193601126101b15760043567ffffffffffffffff81116101b15761073b903690600401610924565b60243567ffffffffffffffff81116101b15761075b903690600401610952565b913330146106de57600154936001600160a01b0385166106b65761068c947fffffffffffffffffffffffff0000000000000000000000000000000000000000339116176001556109a8565b346101b15760806003193601126101b1576107bf6108e4565b506107c86108fa565b5060643567ffffffffffffffff81116101b1576107e9903690600401610924565b505060206040517f150b7a02000000000000000000000000000000000000000000000000000000008152f35b346101b15760206003193601126101b157600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101b157817f4e2312e000000000000000000000000000000000000000000000000000000000602093149081156108ba575b8115610890575b5015158152f35b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610889565b7f150b7a020000000000000000000000000000000000000000000000000000000081149150610882565b600435906001600160a01b03821682036101b157565b602435906001600160a01b03821682036101b157565b35906001600160a01b03821682036101b157565b9181601f840112156101b15782359167ffffffffffffffff83116101b157602083818601950101116101b157565b9181601f840112156101b15782359167ffffffffffffffff83116101b1576020808501948460051b0101116101b157565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b9193909293608052828403612e1a575f915b83831015612e1357828101359185841015612dff578360051b608051013590601e196080513603018212156101b1578160805101359067ffffffffffffffff82116101b15760208360805101019782360389136101b15760609760019560f888901c603f166020811015612aed5760108110156121fd5760088110156113f55780610d855750610a53604087608051010135958c6137e3565b909560a0886080510101355f14610d7b57610a7b6001600160a01b03600154169d5b35613342565b9c91878160a052600160ff1b8314610d08575b50505b604260c052602b600160ff1b8210156101b15760c0518810610d015730915b8882116101b1576040916001600160a01b035f60a0513595610b88610b1f610b3385610af58b60601c601760a051013560601c62ffffff8183109e60481c1691613082565b16968a8614610ce6576401000276a49b5b878b519485938d6020860152606085019060a051612f5f565b91168b83015203601f198101835282612e8e565b8488519a8b98899788967f128acb080000000000000000000000000000000000000000000000000000000088521660048701528b6024870152604486015216606484015260a0608484015260a4830190610983565b03925af1908115610585575f905f92610caa575b610bac935015610ca35750612f4f565b60c0519095908110610bf3573090806017116101b15760a0805160170190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe90195610a91565b5097959296936060919995929a509160805101013511610c7b575b159081610c6c575b50610c255750600101916109ba565b90610c686040519283927f2c4029e90000000000000000000000000000000000000000000000000000000084526004840152604060248401526044830190610983565b0390fd5b600160ff1b915016155f610c16565b7f39d35496000000000000000000000000000000000000000000000000000000005f5260045ffd5b9050612f4f565b9150506040823d8211610cde575b81610cc560409383612e8e565b810103126101b157816020610bac935191015191610b9c565b3d9150610cb8565b73fffd8963efd1fc6a506488495d951d5263988d259b610b06565b8d91610ab0565b60149192501061023d576020602491604051928380926370a0823160e01b82523060048301523560601c5afa908115610585575f91610d4a575b505f80610a8e565b90506020813d8211610d73575b81610d6460209383612e8e565b810103126101b157515f610d42565b3d9150610d57565b610a7b309d610a75565b6001819c929a98959996949c9b97939b145f14610e5c5750610db060408360805101013593826137e3565b608051840160a0013515610e50576060610dd66001600160a01b03600154169435613342565b946080510101355f55600160ff1b8510156101b157610df8936101ac86612f4f565b90919015610e415750610e0a90612f4f565b03610e19575f195f555b610c0e565b7fd4e0248e000000000000000000000000000000000000000000000000000000005f5260045ffd5b610e4b9150612f4f565b610e0a565b6060610dd63094610a75565b60028103610e975750610e1492506001600160a01b0360015416610e90604060608560805101013594608051010135613342565b913561357b565b909190600381036111645750608051810183810160208101949092916040908403126101b157833567ffffffffffffffff81116101b157608051830101936060858503126101b15760405193610eec85612e72565b602086013567ffffffffffffffff81116101b15760209087010187601f820112156101b157803590610f1d82612f93565b92610f2b6040519485612e8e565b82845260208085019360071b830101918a83116101b157602001925b8284106110ff57505050508452610f6060408601610910565b956020850196875260606040860196013586526040846080510101359067ffffffffffffffff82116101b1576020610fa192610fa796608051010101612f09565b506137c6565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016936001600160a01b036001541695853b156101b15795939291906040519687957f2a2d80d100000000000000000000000000000000000000000000000000000000875260048701526060602487015260c48601945194606060648801528551809152602060e488019601905f905b8082106110a1575050505f96948694889486946001600160a01b0361107c95511660848701525160a4860152600319858403016044860152612f5f565b03925af1801561058557611091575b50610c0e565b5f61109b91612e8e565b5f61108b565b91975091929394956020608060019265ffffffffffff60608c516001600160a01b0381511684526001600160a01b0386820151168685015282604082015116604085015201511660608201520198019201899796959493929161103f565b6080602085840301126101b157602060809160405161111d81612e42565b61112687610910565b8152611133838801610910565b8382015261114360408801612fab565b604082015261115460608801612fab565b6060820152815201930192610f47565b9092506004810361129a57506001600160a01b0380606061118c604086608051010135613342565b946080510101351691351680155f146111ed5750479081106111c557806111b5575b5050610c0e565b6111be91613800565b5f806111ae565b7f6e7343dc000000000000000000000000000000000000000000000000000000005f5260045ffd5b91604051916370a0823160e01b8352306004840152602083602481875afa928315610585575f93611267575b50821061123f578161122e575b505050610c0e565b61123792613d33565b5f8080611226565b7f6a4320c5000000000000000000000000000000000000000000000000000000005f5260045ffd5b9092506020813d8211611292575b8161128260209383612e8e565b810103126101b15751915f611219565b3d9150611275565b600581036112c65750608051610e149201606081013591906112bf9060400135613342565b90356134ce565b600681036113ca57506112e9604060608460805101013593608051010135613342565b90821580156113bf575b61139757356001600160a01b03168061131e5750612710611317610e14934761349d565b0490613800565b90604051926370a0823160e01b8452306004850152602084602481865afa938415610585575f94611362575b5061135b61271091610e149561349d565b0491613d33565b93506020843d821161138f575b8161137c60209383612e8e565b810103126101b15792519261135b61134a565b3d915061136f565b7f0c798a50000000000000000000000000000000000000000000000000000000005f5260045ffd5b5061271083116112f3565b7fd76a1e9e000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b6008819c939b97949c9a98959996929a145f14611660575061142c61142360408560805101013592846137e3565b90810190612fbe565b9160a0846080510101355f14611656576114526001600160a01b03600154169135613342565b906114e26001600160a01b036114678661346f565b51511661149a6001600160a01b0360206114808961346f565b51015116604061148f8961346f565b510151151592613deb565b907f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613e0d565b928381611631575b505083515f198101915081116101f757602061150e6001600160a01b03928661347c565b5101511692604051916370a0823160e01b83526001600160a01b03811691826004850152602084602481895afa938415610585575f946115f6575b509361155891602094956138b2565b6024604051809581936370a0823160e01b835260048301525afa918215610585575f926115c2575b506060611594929360805101013592613490565b1015610c0e577f849eaf98000000000000000000000000000000000000000000000000000000005f5260045ffd5b91506020823d82116115ee575b816115dc60209383612e8e565b810103126101b1579051906060611580565b3d91506115cf565b919350936020823d8211611629575b8161161260209383612e8e565b810103126101b15790519093909290611558611549565b3d9150611605565b61164e926001600160a01b036116468861346f565b51511661318a565b5f80836114ea565b6114523091610a75565b91929160098103611ac1575061142361167991846137e3565b608051820160a0013515611ab75761169d6001600160a01b03600154169335613342565b907f0000000000000000000000000000000000000000000000000000000000000000937f0000000000000000000000000000000000000000000000000000000000000000935f946002845110611a8f576040826080510101359684515f1981019081116101f75791906001600160a01b038116835b6117705750505050606090608051010135851161174857610e149484611743926001600160a01b036116468661346f565b6138b2565b7f8ab0bc16000000000000000000000000000000000000000000000000000000005f5260045ffd5b909192988998506001600160a01b036117898a8961347c565b515116906001600160a01b0360206117a18c8b61347c565b510151169060406117b28c8b61347c565b5101511515925f90846117d46117c95f9684613deb565b818c8c9a939a613e0d565b6001600160a01b03811696604051937f392f37e900000000000000000000000000000000000000000000000000000000855260e0856004818c5afa948515610585575f915f935f925f98611a45575b506001600160a01b031614908115611a3f5795945b611a23575b5050509d61184b908d61347c565b5160400151151591801592838015611a1b575b6119f357156119ca5761187386858484613ebc565b92670de0b6b3a76400008202918204670de0b6b3a76400001417156101f7578361189c916134b0565b90670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f757856118c8916134b0565b91670de0b6b3a7640000850294808604670de0b6b3a764000014901517156101f757670de0b6b3a76400009584836119199361191461191e9761190e856119239c6134b0565b90613490565b613f4f565b613490565b61349d565b045b604051917f841fa66b0000000000000000000000000000000000000000000000000000000083526004830152602082602481865afa918215610585575f92611994575b50620f424061197a611981938361349d565b049061317d565b9880156101f7575f190192919083611712565b91506020823d82116119c2575b816119ae60209383612e8e565b810103126101b157905190620f4240611968565b3d91506119a1565b6119ee95506119e89350849250936119e2919461349d565b92613490565b906134b0565b611925565b7fc6acfef5000000000000000000000000000000000000000000000000000000005f5260045ffd5b50821561185e565b91975091945015611a3a57945b94925f808061183d565b611a30565b94611838565b91945096506001600160a01b039250611a75915060e03d8111611a88575b611a6d8183612e8e565b81019061386d565b5050509294919390949394929790611823565b503d611a63565b7fd8e76d79000000000000000000000000000000000000000000000000000000005f5260045ffd5b61169d3093610a75565b909290600a8103611c215750608051820160e08101358101602081810135956040830194939092611af692919003018661317d565b1161023d576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906001600160a01b036001541694823b156101b1576001600160a01b039561107c611b88955f979360c089956040519b8c9a8b998a987f2b67b570000000000000000000000000000000000000000000000000000000008a5260048a0152610910565b1660248701526001600160a01b03611ba66040836080510101610910565b16604487015265ffffffffffff611bc36060836080510101612fab565b16606487015265ffffffffffff611bdf60808381510101612fab565b1660848701526001600160a01b03611bfd60a0836080510101610910565b1660a487015260805101013560c485015261010060e4850152610104840191612f5f565b91929091600b8103611db8575050906040611c43916080510101359135613342565b81600160ff1b8103611d8957504791505b81611c60575050610c0e565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691823b156101b1576040517fd0e30db00000000000000000000000000000000000000000000000000000000081525f8160048185885af1801561058557611d79575b50306001600160a01b03831603611ce4575b506111ae565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015290602090829060449082905f905af1801561058557611d41575b8080611cde565b6020813d8211611d71575b81611d5960209383612e8e565b810103126101b157611d6a90612efc565b505f611d3a565b3d9150611d4c565b5f611d8391612e8e565b5f611ccc565b471015611c54577f6e7343dc000000000000000000000000000000000000000000000000000000005f5260045ffd5b600c8103611ef3575050611dcc9035613342565b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604051916370a0823160e01b8352306004840152602083602481855afa928315610585575f93611ebf575b50608051016040013582106111c55781611e3e57505050610c0e565b803b156101b1575f80916024604051809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528760048401525af1801561058557611eaf575b50306001600160a01b03831603611e9f575b80611226565b611ea891613800565b5f80611e99565b5f611eb991612e8e565b5f611e87565b9092506020813d8211611eeb575b81611eda60209383612e8e565b810103126101b15751916040611e22565b3d9150611ecd565b600d8103612127575060805183019081019260208085019391928503126101b157359067ffffffffffffffff82116101b157608051010181603f820112156101b157602081013591611f4483612f93565b93611f526040519586612e8e565b8385526020850192602080859660071b830101019283116101b157604001925b8284106120c257505050506001600160a01b03600154168251905f5b828110612077575050506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690813b156101b1576040517f0d58b1db00000000000000000000000000000000000000000000000000000000815260206004820152925160248401819052839160448301915f905b80821061202e5750505091815f81819503925af18015610585576110915750610c0e565b91935091602060806001926001600160a01b036060885182815116845282868201511686850152826040820151166040850152015116606082015201940192018593929161200a565b816001600160a01b0361208a838861347c565b5151160361209a57600101611f8e565b7fe7002877000000000000000000000000000000000000000000000000000000005f5260045ffd5b6080602085840301126101b15760206080916040516120e081612e42565b6120e987610910565b81526120f6838801610910565b8382015261210660408801610910565b604082015261211760608801610910565b6060820152815201930192611f72565b91935050600e81036113ca57506001600160a01b03604051926370a0823160e01b8452351660048301526020826024816001600160a01b03604086608051010135165afa918215610585575f926121c9575b506080510160600135111580610e145791506040517fa3281672000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b91610c0e565b9091506020813d82116121f5575b816121e460209383612e8e565b810103126101b15751906060612179565b3d91506121d7565b6018819c959996949c9b939b9a98929a105f14612715576010810361226c575050505f9293509061222f8392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601181036122c4575050505f929350906122878392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b6012810361231c575050505f929350906122df8392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b919250906013810361246857505050357f0000000000000000000000000000000000000000000000000000000000000000925f8060405160208101907f8264fe9800000000000000000000000000000000000000000000000000000000825285602482015260248152612390604482612e8e565b5190606085608051010135885af1916123a7612ecd565b94831561242b5760406001600160a01b036123c9921693608051010135613342565b90823b156101b1576040517f8b72a2ec0000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152905f908290604490829084905af18015610585576110915750610c0e565b50505091506040517fae9bdf00000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b91949291601581036125685750506020604060246001600160a01b0394825195869384927f6352211e0000000000000000000000000000000000000000000000000000000084526060816080510101356004850152608051010135165afa918215610585575f92612523575b506001600160a01b038091351691161480610e145791506040517f7dbe7e89000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b9091506020813d8211612560575b8161253e60209383612e8e565b810103126101b1576001600160a01b036125588192612f7f565b9291506124d4565b3d9150612531565b601681036126655750506040517efdd58e0000000000000000000000000000000000000000000000000000000081526080516001600160a01b03923592909216600482015290820160600135602482015290602082806044810103816001600160a01b03604086608051010135165afa918215610585575f92612631575b50608080519091010135111580610e145791506040517f483a6929000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b9091506020813d821161265d575b8161264c60209383612e8e565b810103126101b157519060806125e6565b3d915061263f565b909290601714612676575050610c0e565b6001600160a01b0361268f604083608051010135613342565b92351691823b156101b1576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526080513060048301526001600160a01b0390921660248201529101606001356044820152905f9082908183816064810103925af1801561058557612705575b806111ae565b5f61270f91612e8e565b5f6126ff565b9190601883036127565750505061274f9293507f0000000000000000000000000000000000000000000000000000000000000000916133a8565b9190610c0e565b601983036127ae575050505f929350906127718392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601a8303612806575050505f929350906127c98392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601b8303612922575050508161281f5f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1809261285d612ecd565b9161286a575b5091610c0e565b6001600160a01b0360808281510101351661288c606083608051010135613342565b6040519091602061289d8184612e8e565b5f8352601f198101903690840137803b156101b157612903935f8094604051968795869485937ff242432a00000000000000000000000000000000000000000000000000000000855260a060c08360805101013592608051010135903060048701613374565b03925af180156105855715612863575f61291c91612e8e565b5f612863565b909195601c87145f1461295f5750505061274f9293507f0000000000000000000000000000000000000000000000000000000000000000916133a8565b9290939195601d81145f14612a90575050606082608051010135916001600160a01b03612993604083608051010135613342565b923516604051917efdd58e000000000000000000000000000000000000000000000000000000008352602083806129e4883060048401602090939291936001600160a01b0360408201951681520152565b0381855afa928315610585575f93612a5c575b506080908151010135821061123f5760405193612a15602086612e8e565b5f8552813b156101b1575f809461107c604051978896879586947ff242432a0000000000000000000000000000000000000000000000000000000086523060048701613374565b9092506020813d8211612a88575b81612a7760209383612e8e565b810103126101b157519160806129f7565b3d9150612a6a565b92509250929350601e81145f146113ca575081612ab05f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b6020819c96959997929a98949c9b939b145f14612b53575050505081612b165f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b60218103612c8e57505050612b73612b6b83856137a5565b9390946137c6565b90612bb46040519460208601967f24856bc3000000000000000000000000000000000000000000000000000000008852604060248801526064870191612f5f565b927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858503016044860152818452602084019160208160051b86010194845f90601e19813603015b848310612c325750505050505050509181612c235f9493859403601f198101835282612e8e565b519082305af1906121c3612ecd565b9091929394959697601f198582030188528835828112156101b1578301906020823592019167ffffffffffffffff81116101b15780360383136101b157612c7e60209283928b95612f5f565b9a01980196959493019190612bfc565b91959492935090602281036113ca575060805101604001356002811015612deb57829080612d905750505f6044602092827f0000000000000000000000000000000000000000000000000000000000000000915b6001600160a01b03604051937f095ea7b300000000000000000000000000000000000000000000000000000000855216600484015281196024840152355af13d15601f3d11835f5114161716610e145760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152fd5b03612dc3575f6044602092827f000000000000000000000000000000000000000000000000000000000000000091612ce2565b7f49b65b0d000000000000000000000000000000000000000000000000000000005f5260045ffd5b634e487b7160e01b5f52602160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5092505050565b7f899ef10d000000000000000000000000000000000000000000000000000000005f5260045ffd5b6080810190811067ffffffffffffffff821117612e5e57604052565b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117612e5e57604052565b90601f601f19910116810190811067ffffffffffffffff821117612e5e57604052565b67ffffffffffffffff8111612e5e57601f01601f191660200190565b3d15612ef7573d90612ede82612eb1565b91612eec6040519384612e8e565b82523d5f602084013e565b606090565b519081151582036101b157565b81601f820112156101b157803590612f2082612eb1565b92612f2e6040519485612e8e565b828452602083830101116101b157815f926020809301838601378301015290565b600160ff1b81146101f7575f0390565b601f8260209493601f1993818652868601375f8582860101520116010190565b51906001600160a01b03821682036101b157565b67ffffffffffffffff8111612e5e5760051b60200190565b359065ffffffffffff821682036101b157565b6020818303126101b15780359067ffffffffffffffff82116101b1570181601f820112156101b157803590612ff282612f93565b926130006040519485612e8e565b828452602060608186019402830101918183116101b157602001925b82841061302a575050505090565b6060848303126101b1576040519061304182612e72565b61304a85610910565b825261305860208601610910565b602083015260408501359081151582036101b157826020926040606095015281520193019261301c565b906001600160a01b039283821684841611613175575b836040519281602085019516855216604083015260020b6060820152606081526130c3608082612e8e565b5190206040517fff00000000000000000000000000000000000000000000000000000000000000602082019081527f000000000000000000000000000000000000000000000000000000000000000060601b6bffffffffffffffffffffffff1916602183015260358201929092527f0000000000000000000000000000000000000000000000000000000000000000605582015261316e81607581015b03601f198101835282612e8e565b5190201690565b919091613098565b919082018092116101f757565b909291906001600160a01b03841630036131aa576131a893506134ce565b565b91926001600160a01b0384116131cd576001600160a01b036131a894169261357b565b7fc4bd89a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b939290602b821061023d578235938460601c92601785013560601c9380851094859760481c62ffffff169061322992613082565b6001600160a01b031692845f146040966001600160a01b0380956132865f966132d995613327576401000276a4925b846132728e51978f94899560208701526060860191612f5f565b91168d83015203601f198101855284612e8e565b89519b8c998a9889977f128acb080000000000000000000000000000000000000000000000000000000089521660048801526024870152604486015216606484015260a0608484015260a4830190610983565b03925af18015610585575f925f916132f057509192565b9250506040823d60401161331f575b8161330c60409383612e8e565b810103126101b157602082519201519192565b3d91506132ff565b73fffd8963efd1fc6a506488495d951d5263988d2592613258565b6001600160a01b038116600181036133655750506001600160a01b036001541690565b60020361337157503090565b90565b91926001600160a01b0360a09481613371989794168552166020840152604083015260608201528160808201520190610983565b915f91906133b78392856137c6565b816040519283928337810184815203918535905af1916133d5612ecd565b91836133de5750565b6001600160a01b03606082013516906133fa6040820135613342565b823b156101b1576040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03919091166024820152608091909101356044820152905f908290606490829084905af18015610585576134655750565b5f6131a891612e8e565b805115612dff5760200190565b8051821015612dff5760209160051b010190565b919082039182116101f757565b818102929181159184041417156101f757565b81156134ba570490565b634e487b7160e01b5f52601260045260245ffd5b9091906001600160a01b0316806134e957506131a891613800565b600160ff1b82146134ff575b916131a892613d33565b9050604051916370a0823160e01b8352306004840152602083602481855afa8015610585575f90613534575b909250906134f5565b506020833d602011613560575b8161354e60209383612e8e565b810103126101b1576131a8925161352b565b3d9150613541565b519065ffffffffffff821682036101b157565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690604051917f927da1050000000000000000000000000000000000000000000000000000000083526001600160a01b0380805f96169384600487015216958660248601521692836044820152606081606481855afa908115610585575f905f9261373f575b506001600160a01b03161590811561372c575b50156136c5575060649083602094956001600160a01b0360405198899687957f23b872dd000000000000000000000000000000000000000000000000000000008752600487015260248601521660448401525af180156136b85761367f575050565b6020823d6020116136b0575b8161369860209383612e8e565b810103126136ad57506136aa90612efc565b50565b80fd5b3d915061368b565b50604051903d90823e3d90fd5b809293503b156101b1575f60849281956001600160a01b0360405198899788967f36c785160000000000000000000000000000000000000000000000000000000088526004880152602487015216604485015260648401525af18015610585576134655750565b905065ffffffffffff429116105f61361d565b9150506060813d60601161379d575b8161375b60609383612e8e565b810103126101b15780516001600160a01b03811681036101b1576001600160a01b0390613796604061378f60208601613568565b9401613568565b509061360a565b3d915061374e565b9182358301916137bf60208435958186019503018561317d565b1161023d57565b9160208301358301916137bf60208435958186019503018561317d565b9160608301358301916137bf60208435958186019503018561317d565b5f80809381935af11561380f57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152fd5b908160e09103126101b15780519160208201519160408101519160608201519161389960808201612efc565b9161337160c06138ab60a08501612f7f565b9301612f7f565b92916138e86001600160a01b036138c88661346f565b5151166001600160a01b0360206138de8861346f565b5101511690613deb565b505f19855101945f906020925b8151831015613d29576001600160a01b03613910848461347c565b5151166001600160a01b0385613926868661347c565b51015116906040517f392f37e900000000000000000000000000000000000000000000000000000000815260e0816004816001600160a01b038c165afa908115610585575f905f905f905f94613d01575b506001600160a01b0387168503613cfb579291905b604051926370a0823160e01b84526001600160a01b038c1660048501528a84602481895afa938415610585575f94613ccc575b506040517f841fa66b0000000000000000000000000000000000000000000000000000000081526001600160a01b038d1660048201528b816024816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa8015610585575f90613c9c575b620f424091508686030204948581860303946040613a518d8d61347c565b51015115613c7057613a6584868585613ebc565b96670de0b6b3a76400008302838104670de0b6b3a764000014841517156101f75786613a90916134b0565b93670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f75785613abc916134b0565b9287670de0b6b3a7640000810204670de0b6b3a76400001492031417156101f75761190e8385836001600160a01b039961191461191e97613b0b613b109b670de0b6b3a7640000809e026134b0565b61317d565b04935b1603613c69575f5b89851015613c6057613ba5613b5b600187016040613b506001600160a01b038b613b45858c61347c565b51015116928961347c565b510151151594613deb565b8194917f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613e0d565b915b9660405190613bb68883612e8e565b5f8252601f19880136898401376001600160a01b0381163b156101b157613c32945f6001600160a01b038195604051988996879586937f022c0d9f00000000000000000000000000000000000000000000000000000000855260048501526024840152838a166044840152608060648401526084830190610983565b0393165af191821561058557600192613c50575b50920191936138f5565b5f613c5a91612e8e565b5f613c46565b8791505f613ba7565b5f91613b1b565b5092506001600160a01b0394506119e8915092613c90613c96948261349d565b9261317d565b93613b13565b508b81813d8311613cc5575b613cb28183612e8e565b810103126101b157620f42409051613a33565b503d613ca8565b9093508a81813d8311613cf4575b613ce48183612e8e565b810103126101b15751925f6139bf565b503d613cda565b9161398c565b92505050613d1d915060e03d8111611a8857611a6d8183612e8e565b5050509291905f613977565b5050505050509050565b5f91826044926020956001600160a01b03604051947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af13d15601f3d1160015f511416171615613d8d57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152fd5b6001600160a01b0382166001600160a01b038216105f14613e095791565b9091565b929161316e91926001600160a01b03956bffffffffffffffffffffffff196040519281602085019560601b16855260601b166034830152151560f81b604882015260298152613e5d604982612e8e565b519020613160604051938492602084019687916bffffffffffffffffffffffff19605594927fff00000000000000000000000000000000000000000000000000000000000000855260601b166001840152601583015260358201520190565b9091670de0b6b3a7640000820291808304670de0b6b3a764000014901517156101f757613ee8916134b0565b670de0b6b3a7640000820291808304670de0b6b3a764000014901517156101f757613f45613f22670de0b6b3a764000094613f4b946134b0565b8461197a81613f3d81613f35868961349d565b04968061349d565b04928061349d565b9061349d565b0490565b9192949390945f955f945b60ff8610613f6a57505050505050565b613f7481866140a4565b8281101561401857613f868184613490565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f757613fb684916119e8858a6140c8565b918215613fd5575b5050613fcc9060019261317d565b955b0194613f5a565b14905061400f57600181018082116101f75782613ff48686848a613ebc565b116140055750600182613fcc613fbe565b9750505050505050565b96505050505050565b6140228382613490565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f75761405284916119e8858a6140c8565b91821561406e575b505061406890600192613490565b95613fce565b1490508015614087575b61400f5760018261406861405a565b505f1981018181116101f75761409e8391876140a4565b10614078565b613f4b90613f45670de0b6b3a7640000938461197a81613f3d81613f35868961349d565b806003026003810482036101f75761197a670de0b6b3a76400006140fc8193826140f5886133719961349d565b049061349d565b049282614109828061349d565b0461349d56fea2646970667358221220b4ea8bd3b8c3955de4776473bb3b83ec91ad1289eff1568230c7925a52be6b9464736f6c634300081c0033000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ed55fa4772cbb9f45ea8118a39cf640df2fdb2dc000000000000000000000000000000000000000000000000000000000000000045abd56e0874f11d842a55bc9bba133f39d9d0489dc6d4577701e8f47faf7151
Deployed Bytecode
0x60e080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816301ffc9a71461081557508063150b7a02146107a657806324856bc31461070f5780633593564c146105ec578063709a1cc2146103b9578063bc197c8114610306578063f23a6e61146102975763fa461e3314610080575f61000f565b346101b15760606003193601126101b15760243560043560443567ffffffffffffffff81116101b1576100b7903690600401610924565b5f83139182158061028d575b610265578181016040828203126101b15781359067ffffffffffffffff82116101b1576100f1918301612f09565b506020810135916001600160a01b0383168093036101b157610112916137a5565b601790602b831061023d578035968760601c9561013f62ffffff8585013560601c9a60481c168a89613082565b6001600160a01b0333911603610215571561020b57508685105b1561016d5750505061001a9350339161318a565b91935091939482602b0180602b116101f75784106101b557508282116101b1578101910390600160ff1b8410156101b15761001a936101ac3391612f4f565b6131f5565b5f80fd5b925050505f9291925482116101cf5761001a92339161318a565b7f739dbe52000000000000000000000000000000000000000000000000000000005f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b9550848710610159565b7f32b13d91000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f3b99b53d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f316cf0eb000000000000000000000000000000000000000000000000000000005f5260045ffd5b505f8513156100c3565b346101b15760a06003193601126101b1576102b06108e4565b506102b96108fa565b5060843567ffffffffffffffff81116101b1576102da903690600401610924565b505060206040517ff23a6e61000000000000000000000000000000000000000000000000000000008152f35b346101b15760a06003193601126101b15761031f6108e4565b506103286108fa565b5060443567ffffffffffffffff81116101b157610349903690600401610952565b505060643567ffffffffffffffff81116101b15761036b903690600401610952565b505060843567ffffffffffffffff81116101b15761038d903690600401610924565b505060206040517fbc197c81000000000000000000000000000000000000000000000000000000008152f35b346101b15760206003193601126101b15760043567ffffffffffffffff81116101b1575f6103ec81923690600401610924565b9081604051928392833781018381520390827f00000000000000000000000000000000000000000000000000000000000000005af1610429612ecd565b50156105c4576040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602082602481845afa918215610585575f92610590575b506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660048201526024810183905290602090829060449082905f905af1801561058557610527575b7f1e8f03f716bc104bf7d728131967a0c771e85ab54d09c1e2d6ed9e0bc4e2a16c602083604051908152a1005b6020813d60201161057d575b8161054060209383612e8e565b810103126101b1577f1e8f03f716bc104bf7d728131967a0c771e85ab54d09c1e2d6ed9e0bc4e2a16c91610575602092612efc565b5091506104fa565b3d9150610533565b6040513d5f823e3d90fd5b9091506020813d6020116105bc575b816105ac60209383612e8e565b810103126101b157519082610483565b3d915061059f565b7f7d529919000000000000000000000000000000000000000000000000000000005f5260045ffd5b60606003193601126101b15760043567ffffffffffffffff81116101b157610618903690600401610924565b60243567ffffffffffffffff81116101b157610638903690600401610952565b9160443542116106e7573330146106de57600154936001600160a01b0385166106b65761068c947fffffffffffffffffffffffff0000000000000000000000000000000000000000339116176001556109a8565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055005b7f6f5ffb7e000000000000000000000000000000000000000000000000000000005f5260045ffd5b61001a936109a8565b7f5bf6f916000000000000000000000000000000000000000000000000000000005f5260045ffd5b60406003193601126101b15760043567ffffffffffffffff81116101b15761073b903690600401610924565b60243567ffffffffffffffff81116101b15761075b903690600401610952565b913330146106de57600154936001600160a01b0385166106b65761068c947fffffffffffffffffffffffff0000000000000000000000000000000000000000339116176001556109a8565b346101b15760806003193601126101b1576107bf6108e4565b506107c86108fa565b5060643567ffffffffffffffff81116101b1576107e9903690600401610924565b505060206040517f150b7a02000000000000000000000000000000000000000000000000000000008152f35b346101b15760206003193601126101b157600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101b157817f4e2312e000000000000000000000000000000000000000000000000000000000602093149081156108ba575b8115610890575b5015158152f35b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610889565b7f150b7a020000000000000000000000000000000000000000000000000000000081149150610882565b600435906001600160a01b03821682036101b157565b602435906001600160a01b03821682036101b157565b35906001600160a01b03821682036101b157565b9181601f840112156101b15782359167ffffffffffffffff83116101b157602083818601950101116101b157565b9181601f840112156101b15782359167ffffffffffffffff83116101b1576020808501948460051b0101116101b157565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b9193909293608052828403612e1a575f915b83831015612e1357828101359185841015612dff578360051b608051013590601e196080513603018212156101b1578160805101359067ffffffffffffffff82116101b15760208360805101019782360389136101b15760609760019560f888901c603f166020811015612aed5760108110156121fd5760088110156113f55780610d855750610a53604087608051010135958c6137e3565b909560a0886080510101355f14610d7b57610a7b6001600160a01b03600154169d5b35613342565b9c91878160a052600160ff1b8314610d08575b50505b604260c052602b600160ff1b8210156101b15760c0518810610d015730915b8882116101b1576040916001600160a01b035f60a0513595610b88610b1f610b3385610af58b60601c601760a051013560601c62ffffff8183109e60481c1691613082565b16968a8614610ce6576401000276a49b5b878b519485938d6020860152606085019060a051612f5f565b91168b83015203601f198101835282612e8e565b8488519a8b98899788967f128acb080000000000000000000000000000000000000000000000000000000088521660048701528b6024870152604486015216606484015260a0608484015260a4830190610983565b03925af1908115610585575f905f92610caa575b610bac935015610ca35750612f4f565b60c0519095908110610bf3573090806017116101b15760a0805160170190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe90195610a91565b5097959296936060919995929a509160805101013511610c7b575b159081610c6c575b50610c255750600101916109ba565b90610c686040519283927f2c4029e90000000000000000000000000000000000000000000000000000000084526004840152604060248401526044830190610983565b0390fd5b600160ff1b915016155f610c16565b7f39d35496000000000000000000000000000000000000000000000000000000005f5260045ffd5b9050612f4f565b9150506040823d8211610cde575b81610cc560409383612e8e565b810103126101b157816020610bac935191015191610b9c565b3d9150610cb8565b73fffd8963efd1fc6a506488495d951d5263988d259b610b06565b8d91610ab0565b60149192501061023d576020602491604051928380926370a0823160e01b82523060048301523560601c5afa908115610585575f91610d4a575b505f80610a8e565b90506020813d8211610d73575b81610d6460209383612e8e565b810103126101b157515f610d42565b3d9150610d57565b610a7b309d610a75565b6001819c929a98959996949c9b97939b145f14610e5c5750610db060408360805101013593826137e3565b608051840160a0013515610e50576060610dd66001600160a01b03600154169435613342565b946080510101355f55600160ff1b8510156101b157610df8936101ac86612f4f565b90919015610e415750610e0a90612f4f565b03610e19575f195f555b610c0e565b7fd4e0248e000000000000000000000000000000000000000000000000000000005f5260045ffd5b610e4b9150612f4f565b610e0a565b6060610dd63094610a75565b60028103610e975750610e1492506001600160a01b0360015416610e90604060608560805101013594608051010135613342565b913561357b565b909190600381036111645750608051810183810160208101949092916040908403126101b157833567ffffffffffffffff81116101b157608051830101936060858503126101b15760405193610eec85612e72565b602086013567ffffffffffffffff81116101b15760209087010187601f820112156101b157803590610f1d82612f93565b92610f2b6040519485612e8e565b82845260208085019360071b830101918a83116101b157602001925b8284106110ff57505050508452610f6060408601610910565b956020850196875260606040860196013586526040846080510101359067ffffffffffffffff82116101b1576020610fa192610fa796608051010101612f09565b506137c6565b6001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316936001600160a01b036001541695853b156101b15795939291906040519687957f2a2d80d100000000000000000000000000000000000000000000000000000000875260048701526060602487015260c48601945194606060648801528551809152602060e488019601905f905b8082106110a1575050505f96948694889486946001600160a01b0361107c95511660848701525160a4860152600319858403016044860152612f5f565b03925af1801561058557611091575b50610c0e565b5f61109b91612e8e565b5f61108b565b91975091929394956020608060019265ffffffffffff60608c516001600160a01b0381511684526001600160a01b0386820151168685015282604082015116604085015201511660608201520198019201899796959493929161103f565b6080602085840301126101b157602060809160405161111d81612e42565b61112687610910565b8152611133838801610910565b8382015261114360408801612fab565b604082015261115460608801612fab565b6060820152815201930192610f47565b9092506004810361129a57506001600160a01b0380606061118c604086608051010135613342565b946080510101351691351680155f146111ed5750479081106111c557806111b5575b5050610c0e565b6111be91613800565b5f806111ae565b7f6e7343dc000000000000000000000000000000000000000000000000000000005f5260045ffd5b91604051916370a0823160e01b8352306004840152602083602481875afa928315610585575f93611267575b50821061123f578161122e575b505050610c0e565b61123792613d33565b5f8080611226565b7f6a4320c5000000000000000000000000000000000000000000000000000000005f5260045ffd5b9092506020813d8211611292575b8161128260209383612e8e565b810103126101b15751915f611219565b3d9150611275565b600581036112c65750608051610e149201606081013591906112bf9060400135613342565b90356134ce565b600681036113ca57506112e9604060608460805101013593608051010135613342565b90821580156113bf575b61139757356001600160a01b03168061131e5750612710611317610e14934761349d565b0490613800565b90604051926370a0823160e01b8452306004850152602084602481865afa938415610585575f94611362575b5061135b61271091610e149561349d565b0491613d33565b93506020843d821161138f575b8161137c60209383612e8e565b810103126101b15792519261135b61134a565b3d915061136f565b7f0c798a50000000000000000000000000000000000000000000000000000000005f5260045ffd5b5061271083116112f3565b7fd76a1e9e000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b6008819c939b97949c9a98959996929a145f14611660575061142c61142360408560805101013592846137e3565b90810190612fbe565b9160a0846080510101355f14611656576114526001600160a01b03600154169135613342565b906114e26001600160a01b036114678661346f565b51511661149a6001600160a01b0360206114808961346f565b51015116604061148f8961346f565b510151151592613deb565b907f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613e0d565b928381611631575b505083515f198101915081116101f757602061150e6001600160a01b03928661347c565b5101511692604051916370a0823160e01b83526001600160a01b03811691826004850152602084602481895afa938415610585575f946115f6575b509361155891602094956138b2565b6024604051809581936370a0823160e01b835260048301525afa918215610585575f926115c2575b506060611594929360805101013592613490565b1015610c0e577f849eaf98000000000000000000000000000000000000000000000000000000005f5260045ffd5b91506020823d82116115ee575b816115dc60209383612e8e565b810103126101b1579051906060611580565b3d91506115cf565b919350936020823d8211611629575b8161161260209383612e8e565b810103126101b15790519093909290611558611549565b3d9150611605565b61164e926001600160a01b036116468861346f565b51511661318a565b5f80836114ea565b6114523091610a75565b91929160098103611ac1575061142361167991846137e3565b608051820160a0013515611ab75761169d6001600160a01b03600154169335613342565b907f0000000000000000000000000000000000000000000000000000000000000000937f0000000000000000000000000000000000000000000000000000000000000000935f946002845110611a8f576040826080510101359684515f1981019081116101f75791906001600160a01b038116835b6117705750505050606090608051010135851161174857610e149484611743926001600160a01b036116468661346f565b6138b2565b7f8ab0bc16000000000000000000000000000000000000000000000000000000005f5260045ffd5b909192988998506001600160a01b036117898a8961347c565b515116906001600160a01b0360206117a18c8b61347c565b510151169060406117b28c8b61347c565b5101511515925f90846117d46117c95f9684613deb565b818c8c9a939a613e0d565b6001600160a01b03811696604051937f392f37e900000000000000000000000000000000000000000000000000000000855260e0856004818c5afa948515610585575f915f935f925f98611a45575b506001600160a01b031614908115611a3f5795945b611a23575b5050509d61184b908d61347c565b5160400151151591801592838015611a1b575b6119f357156119ca5761187386858484613ebc565b92670de0b6b3a76400008202918204670de0b6b3a76400001417156101f7578361189c916134b0565b90670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f757856118c8916134b0565b91670de0b6b3a7640000850294808604670de0b6b3a764000014901517156101f757670de0b6b3a76400009584836119199361191461191e9761190e856119239c6134b0565b90613490565b613f4f565b613490565b61349d565b045b604051917f841fa66b0000000000000000000000000000000000000000000000000000000083526004830152602082602481865afa918215610585575f92611994575b50620f424061197a611981938361349d565b049061317d565b9880156101f7575f190192919083611712565b91506020823d82116119c2575b816119ae60209383612e8e565b810103126101b157905190620f4240611968565b3d91506119a1565b6119ee95506119e89350849250936119e2919461349d565b92613490565b906134b0565b611925565b7fc6acfef5000000000000000000000000000000000000000000000000000000005f5260045ffd5b50821561185e565b91975091945015611a3a57945b94925f808061183d565b611a30565b94611838565b91945096506001600160a01b039250611a75915060e03d8111611a88575b611a6d8183612e8e565b81019061386d565b5050509294919390949394929790611823565b503d611a63565b7fd8e76d79000000000000000000000000000000000000000000000000000000005f5260045ffd5b61169d3093610a75565b909290600a8103611c215750608051820160e08101358101602081810135956040830194939092611af692919003018661317d565b1161023d576001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316906001600160a01b036001541694823b156101b1576001600160a01b039561107c611b88955f979360c089956040519b8c9a8b998a987f2b67b570000000000000000000000000000000000000000000000000000000008a5260048a0152610910565b1660248701526001600160a01b03611ba66040836080510101610910565b16604487015265ffffffffffff611bc36060836080510101612fab565b16606487015265ffffffffffff611bdf60808381510101612fab565b1660848701526001600160a01b03611bfd60a0836080510101610910565b1660a487015260805101013560c485015261010060e4850152610104840191612f5f565b91929091600b8103611db8575050906040611c43916080510101359135613342565b81600160ff1b8103611d8957504791505b81611c60575050610c0e565b6001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381691823b156101b1576040517fd0e30db00000000000000000000000000000000000000000000000000000000081525f8160048185885af1801561058557611d79575b50306001600160a01b03831603611ce4575b506111ae565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015290602090829060449082905f905af1801561058557611d41575b8080611cde565b6020813d8211611d71575b81611d5960209383612e8e565b810103126101b157611d6a90612efc565b505f611d3a565b3d9150611d4c565b5f611d8391612e8e565b5f611ccc565b471015611c54577f6e7343dc000000000000000000000000000000000000000000000000000000005f5260045ffd5b600c8103611ef3575050611dcc9035613342565b906001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3816604051916370a0823160e01b8352306004840152602083602481855afa928315610585575f93611ebf575b50608051016040013582106111c55781611e3e57505050610c0e565b803b156101b1575f80916024604051809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528760048401525af1801561058557611eaf575b50306001600160a01b03831603611e9f575b80611226565b611ea891613800565b5f80611e99565b5f611eb991612e8e565b5f611e87565b9092506020813d8211611eeb575b81611eda60209383612e8e565b810103126101b15751916040611e22565b3d9150611ecd565b600d8103612127575060805183019081019260208085019391928503126101b157359067ffffffffffffffff82116101b157608051010181603f820112156101b157602081013591611f4483612f93565b93611f526040519586612e8e565b8385526020850192602080859660071b830101019283116101b157604001925b8284106120c257505050506001600160a01b03600154168251905f5b828110612077575050506001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba31690813b156101b1576040517f0d58b1db00000000000000000000000000000000000000000000000000000000815260206004820152925160248401819052839160448301915f905b80821061202e5750505091815f81819503925af18015610585576110915750610c0e565b91935091602060806001926001600160a01b036060885182815116845282868201511686850152826040820151166040850152015116606082015201940192018593929161200a565b816001600160a01b0361208a838861347c565b5151160361209a57600101611f8e565b7fe7002877000000000000000000000000000000000000000000000000000000005f5260045ffd5b6080602085840301126101b15760206080916040516120e081612e42565b6120e987610910565b81526120f6838801610910565b8382015261210660408801610910565b604082015261211760608801610910565b6060820152815201930192611f72565b91935050600e81036113ca57506001600160a01b03604051926370a0823160e01b8452351660048301526020826024816001600160a01b03604086608051010135165afa918215610585575f926121c9575b506080510160600135111580610e145791506040517fa3281672000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b91610c0e565b9091506020813d82116121f5575b816121e460209383612e8e565b810103126101b15751906060612179565b3d91506121d7565b6018819c959996949c9b939b9a98929a105f14612715576010810361226c575050505f9293509061222f8392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601181036122c4575050505f929350906122878392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b6012810361231c575050505f929350906122df8392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b919250906013810361246857505050357f0000000000000000000000000000000000000000000000000000000000000000925f8060405160208101907f8264fe9800000000000000000000000000000000000000000000000000000000825285602482015260248152612390604482612e8e565b5190606085608051010135885af1916123a7612ecd565b94831561242b5760406001600160a01b036123c9921693608051010135613342565b90823b156101b1576040517f8b72a2ec0000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152905f908290604490829084905af18015610585576110915750610c0e565b50505091506040517fae9bdf00000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b91949291601581036125685750506020604060246001600160a01b0394825195869384927f6352211e0000000000000000000000000000000000000000000000000000000084526060816080510101356004850152608051010135165afa918215610585575f92612523575b506001600160a01b038091351691161480610e145791506040517f7dbe7e89000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b9091506020813d8211612560575b8161253e60209383612e8e565b810103126101b1576001600160a01b036125588192612f7f565b9291506124d4565b3d9150612531565b601681036126655750506040517efdd58e0000000000000000000000000000000000000000000000000000000081526080516001600160a01b03923592909216600482015290820160600135602482015290602082806044810103816001600160a01b03604086608051010135165afa918215610585575f92612631575b50608080519091010135111580610e145791506040517f483a6929000000000000000000000000000000000000000000000000000000006020820152600481526121c3602482612e8e565b9091506020813d821161265d575b8161264c60209383612e8e565b810103126101b157519060806125e6565b3d915061263f565b909290601714612676575050610c0e565b6001600160a01b0361268f604083608051010135613342565b92351691823b156101b1576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526080513060048301526001600160a01b0390921660248201529101606001356044820152905f9082908183816064810103925af1801561058557612705575b806111ae565b5f61270f91612e8e565b5f6126ff565b9190601883036127565750505061274f9293507f0000000000000000000000000000000000000000000000000000000000000000916133a8565b9190610c0e565b601983036127ae575050505f929350906127718392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601a8303612806575050505f929350906127c98392826137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b601b8303612922575050508161281f5f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1809261285d612ecd565b9161286a575b5091610c0e565b6001600160a01b0360808281510101351661288c606083608051010135613342565b6040519091602061289d8184612e8e565b5f8352601f198101903690840137803b156101b157612903935f8094604051968795869485937ff242432a00000000000000000000000000000000000000000000000000000000855260a060c08360805101013592608051010135903060048701613374565b03925af180156105855715612863575f61291c91612e8e565b5f612863565b909195601c87145f1461295f5750505061274f9293507f0000000000000000000000000000000000000000000000000000000000000000916133a8565b9290939195601d81145f14612a90575050606082608051010135916001600160a01b03612993604083608051010135613342565b923516604051917efdd58e000000000000000000000000000000000000000000000000000000008352602083806129e4883060048401602090939291936001600160a01b0360408201951681520152565b0381855afa928315610585575f93612a5c575b506080908151010135821061123f5760405193612a15602086612e8e565b5f8552813b156101b1575f809461107c604051978896879586947ff242432a0000000000000000000000000000000000000000000000000000000086523060048701613374565b9092506020813d8211612a88575b81612a7760209383612e8e565b810103126101b157519160806129f7565b3d9150612a6a565b92509250929350601e81145f146113ca575081612ab05f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b6020819c96959997929a98949c9b939b145f14612b53575050505081612b165f939284936137c6565b81604051928392833781018481520391357f00000000000000000000000000000000000000000000000000000000000000005af1906121c3612ecd565b60218103612c8e57505050612b73612b6b83856137a5565b9390946137c6565b90612bb46040519460208601967f24856bc3000000000000000000000000000000000000000000000000000000008852604060248801526064870191612f5f565b927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858503016044860152818452602084019160208160051b86010194845f90601e19813603015b848310612c325750505050505050509181612c235f9493859403601f198101835282612e8e565b519082305af1906121c3612ecd565b9091929394959697601f198582030188528835828112156101b1578301906020823592019167ffffffffffffffff81116101b15780360383136101b157612c7e60209283928b95612f5f565b9a01980196959493019190612bfc565b91959492935090602281036113ca575060805101604001356002811015612deb57829080612d905750505f6044602092827f0000000000000000000000000000000000000000000000000000000000000000915b6001600160a01b03604051937f095ea7b300000000000000000000000000000000000000000000000000000000855216600484015281196024840152355af13d15601f3d11835f5114161716610e145760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152fd5b03612dc3575f6044602092827f000000000000000000000000000000000000000000000000000000000000000091612ce2565b7f49b65b0d000000000000000000000000000000000000000000000000000000005f5260045ffd5b634e487b7160e01b5f52602160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5092505050565b7f899ef10d000000000000000000000000000000000000000000000000000000005f5260045ffd5b6080810190811067ffffffffffffffff821117612e5e57604052565b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117612e5e57604052565b90601f601f19910116810190811067ffffffffffffffff821117612e5e57604052565b67ffffffffffffffff8111612e5e57601f01601f191660200190565b3d15612ef7573d90612ede82612eb1565b91612eec6040519384612e8e565b82523d5f602084013e565b606090565b519081151582036101b157565b81601f820112156101b157803590612f2082612eb1565b92612f2e6040519485612e8e565b828452602083830101116101b157815f926020809301838601378301015290565b600160ff1b81146101f7575f0390565b601f8260209493601f1993818652868601375f8582860101520116010190565b51906001600160a01b03821682036101b157565b67ffffffffffffffff8111612e5e5760051b60200190565b359065ffffffffffff821682036101b157565b6020818303126101b15780359067ffffffffffffffff82116101b1570181601f820112156101b157803590612ff282612f93565b926130006040519485612e8e565b828452602060608186019402830101918183116101b157602001925b82841061302a575050505090565b6060848303126101b1576040519061304182612e72565b61304a85610910565b825261305860208601610910565b602083015260408501359081151582036101b157826020926040606095015281520193019261301c565b906001600160a01b039283821684841611613175575b836040519281602085019516855216604083015260020b6060820152606081526130c3608082612e8e565b5190206040517fff00000000000000000000000000000000000000000000000000000000000000602082019081527f000000000000000000000000c1747e43f2e07c0c146fd070320430c551d7715660601b6bffffffffffffffffffffffff1916602183015260358201929092527f45abd56e0874f11d842a55bc9bba133f39d9d0489dc6d4577701e8f47faf7151605582015261316e81607581015b03601f198101835282612e8e565b5190201690565b919091613098565b919082018092116101f757565b909291906001600160a01b03841630036131aa576131a893506134ce565b565b91926001600160a01b0384116131cd576001600160a01b036131a894169261357b565b7fc4bd89a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b939290602b821061023d578235938460601c92601785013560601c9380851094859760481c62ffffff169061322992613082565b6001600160a01b031692845f146040966001600160a01b0380956132865f966132d995613327576401000276a4925b846132728e51978f94899560208701526060860191612f5f565b91168d83015203601f198101855284612e8e565b89519b8c998a9889977f128acb080000000000000000000000000000000000000000000000000000000089521660048801526024870152604486015216606484015260a0608484015260a4830190610983565b03925af18015610585575f925f916132f057509192565b9250506040823d60401161331f575b8161330c60409383612e8e565b810103126101b157602082519201519192565b3d91506132ff565b73fffd8963efd1fc6a506488495d951d5263988d2592613258565b6001600160a01b038116600181036133655750506001600160a01b036001541690565b60020361337157503090565b90565b91926001600160a01b0360a09481613371989794168552166020840152604083015260608201528160808201520190610983565b915f91906133b78392856137c6565b816040519283928337810184815203918535905af1916133d5612ecd565b91836133de5750565b6001600160a01b03606082013516906133fa6040820135613342565b823b156101b1576040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03919091166024820152608091909101356044820152905f908290606490829084905af18015610585576134655750565b5f6131a891612e8e565b805115612dff5760200190565b8051821015612dff5760209160051b010190565b919082039182116101f757565b818102929181159184041417156101f757565b81156134ba570490565b634e487b7160e01b5f52601260045260245ffd5b9091906001600160a01b0316806134e957506131a891613800565b600160ff1b82146134ff575b916131a892613d33565b9050604051916370a0823160e01b8352306004840152602083602481855afa8015610585575f90613534575b909250906134f5565b506020833d602011613560575b8161354e60209383612e8e565b810103126101b1576131a8925161352b565b3d9150613541565b519065ffffffffffff821682036101b157565b6001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba31690604051917f927da1050000000000000000000000000000000000000000000000000000000083526001600160a01b0380805f96169384600487015216958660248601521692836044820152606081606481855afa908115610585575f905f9261373f575b506001600160a01b03161590811561372c575b50156136c5575060649083602094956001600160a01b0360405198899687957f23b872dd000000000000000000000000000000000000000000000000000000008752600487015260248601521660448401525af180156136b85761367f575050565b6020823d6020116136b0575b8161369860209383612e8e565b810103126136ad57506136aa90612efc565b50565b80fd5b3d915061368b565b50604051903d90823e3d90fd5b809293503b156101b1575f60849281956001600160a01b0360405198899788967f36c785160000000000000000000000000000000000000000000000000000000088526004880152602487015216604485015260648401525af18015610585576134655750565b905065ffffffffffff429116105f61361d565b9150506060813d60601161379d575b8161375b60609383612e8e565b810103126101b15780516001600160a01b03811681036101b1576001600160a01b0390613796604061378f60208601613568565b9401613568565b509061360a565b3d915061374e565b9182358301916137bf60208435958186019503018561317d565b1161023d57565b9160208301358301916137bf60208435958186019503018561317d565b9160608301358301916137bf60208435958186019503018561317d565b5f80809381935af11561380f57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152fd5b908160e09103126101b15780519160208201519160408101519160608201519161389960808201612efc565b9161337160c06138ab60a08501612f7f565b9301612f7f565b92916138e86001600160a01b036138c88661346f565b5151166001600160a01b0360206138de8861346f565b5101511690613deb565b505f19855101945f906020925b8151831015613d29576001600160a01b03613910848461347c565b5151166001600160a01b0385613926868661347c565b51015116906040517f392f37e900000000000000000000000000000000000000000000000000000000815260e0816004816001600160a01b038c165afa908115610585575f905f905f905f94613d01575b506001600160a01b0387168503613cfb579291905b604051926370a0823160e01b84526001600160a01b038c1660048501528a84602481895afa938415610585575f94613ccc575b506040517f841fa66b0000000000000000000000000000000000000000000000000000000081526001600160a01b038d1660048201528b816024816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa8015610585575f90613c9c575b620f424091508686030204948581860303946040613a518d8d61347c565b51015115613c7057613a6584868585613ebc565b96670de0b6b3a76400008302838104670de0b6b3a764000014841517156101f75786613a90916134b0565b93670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f75785613abc916134b0565b9287670de0b6b3a7640000810204670de0b6b3a76400001492031417156101f75761190e8385836001600160a01b039961191461191e97613b0b613b109b670de0b6b3a7640000809e026134b0565b61317d565b04935b1603613c69575f5b89851015613c6057613ba5613b5b600187016040613b506001600160a01b038b613b45858c61347c565b51015116928961347c565b510151151594613deb565b8194917f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613e0d565b915b9660405190613bb68883612e8e565b5f8252601f19880136898401376001600160a01b0381163b156101b157613c32945f6001600160a01b038195604051988996879586937f022c0d9f00000000000000000000000000000000000000000000000000000000855260048501526024840152838a166044840152608060648401526084830190610983565b0393165af191821561058557600192613c50575b50920191936138f5565b5f613c5a91612e8e565b5f613c46565b8791505f613ba7565b5f91613b1b565b5092506001600160a01b0394506119e8915092613c90613c96948261349d565b9261317d565b93613b13565b508b81813d8311613cc5575b613cb28183612e8e565b810103126101b157620f42409051613a33565b503d613ca8565b9093508a81813d8311613cf4575b613ce48183612e8e565b810103126101b15751925f6139bf565b503d613cda565b9161398c565b92505050613d1d915060e03d8111611a8857611a6d8183612e8e565b5050509291905f613977565b5050505050509050565b5f91826044926020956001600160a01b03604051947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af13d15601f3d1160015f511416171615613d8d57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152fd5b6001600160a01b0382166001600160a01b038216105f14613e095791565b9091565b929161316e91926001600160a01b03956bffffffffffffffffffffffff196040519281602085019560601b16855260601b166034830152151560f81b604882015260298152613e5d604982612e8e565b519020613160604051938492602084019687916bffffffffffffffffffffffff19605594927fff00000000000000000000000000000000000000000000000000000000000000855260601b166001840152601583015260358201520190565b9091670de0b6b3a7640000820291808304670de0b6b3a764000014901517156101f757613ee8916134b0565b670de0b6b3a7640000820291808304670de0b6b3a764000014901517156101f757613f45613f22670de0b6b3a764000094613f4b946134b0565b8461197a81613f3d81613f35868961349d565b04968061349d565b04928061349d565b9061349d565b0490565b9192949390945f955f945b60ff8610613f6a57505050505050565b613f7481866140a4565b8281101561401857613f868184613490565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f757613fb684916119e8858a6140c8565b918215613fd5575b5050613fcc9060019261317d565b955b0194613f5a565b14905061400f57600181018082116101f75782613ff48686848a613ebc565b116140055750600182613fcc613fbe565b9750505050505050565b96505050505050565b6140228382613490565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101f75761405284916119e8858a6140c8565b91821561406e575b505061406890600192613490565b95613fce565b1490508015614087575b61400f5760018261406861405a565b505f1981018181116101f75761409e8391876140a4565b10614078565b613f4b90613f45670de0b6b3a7640000938461197a81613f3d81613f35868961349d565b806003026003810482036101f75761197a670de0b6b3a76400006140fc8193826140f5886133719961349d565b049061349d565b049282614109828061349d565b0461349d56fea2646970667358221220b4ea8bd3b8c3955de4776473bb3b83ec91ad1289eff1568230c7925a52be6b9464736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ed55fa4772cbb9f45ea8118a39cf640df2fdb2dc000000000000000000000000000000000000000000000000000000000000000045abd56e0874f11d842a55bc9bba133f39d9d0489dc6d4577701e8f47faf7151
-----Decoded View---------------
Arg [0] : params (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
-----Encoded View---------------
20 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [1] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [14] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [15] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [17] : 000000000000000000000000ed55fa4772cbb9f45ea8118a39cf640df2fdb2dc
Arg [18] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [19] : 45abd56e0874f11d842a55bc9bba133f39d9d0489dc6d4577701e8f47faf7151
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.