Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 3,477 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Execute Meta Txn | 20642243 | 85 days ago | IN | 0 ETH | 0.00198753 | ||||
Execute Meta Txn | 20642226 | 85 days ago | IN | 0 ETH | 0.00337452 | ||||
Execute Meta Txn | 20642207 | 85 days ago | IN | 0 ETH | 0.00248791 | ||||
Execute Meta Txn | 20642187 | 85 days ago | IN | 0 ETH | 0.00379674 | ||||
Execute Meta Txn | 20642181 | 85 days ago | IN | 0 ETH | 0.00196686 | ||||
Execute Meta Txn | 20642180 | 85 days ago | IN | 0 ETH | 0.0027222 | ||||
Execute Meta Txn | 20642176 | 85 days ago | IN | 0 ETH | 0.00324723 | ||||
Execute Meta Txn | 20642139 | 85 days ago | IN | 0 ETH | 0.00536827 | ||||
Execute Meta Txn | 20642088 | 85 days ago | IN | 0 ETH | 0.00469459 | ||||
Execute Meta Txn | 20642087 | 85 days ago | IN | 0 ETH | 0.00152274 | ||||
Execute Meta Txn | 20642027 | 85 days ago | IN | 0 ETH | 0.00121018 | ||||
Execute Meta Txn | 20642024 | 85 days ago | IN | 0 ETH | 0.00101896 | ||||
Execute Meta Txn | 20641975 | 85 days ago | IN | 0 ETH | 0.00171061 | ||||
Execute Meta Txn | 20641962 | 85 days ago | IN | 0 ETH | 0.00116389 | ||||
Execute Meta Txn | 20641899 | 85 days ago | IN | 0 ETH | 0.00120933 | ||||
Execute Meta Txn | 20641882 | 85 days ago | IN | 0 ETH | 0.00199381 | ||||
Execute Meta Txn | 20641873 | 85 days ago | IN | 0 ETH | 0.00123824 | ||||
Execute Meta Txn | 20641851 | 85 days ago | IN | 0 ETH | 0.00124603 | ||||
Execute Meta Txn | 20641842 | 85 days ago | IN | 0 ETH | 0.00110717 | ||||
Execute Meta Txn | 20641840 | 85 days ago | IN | 0 ETH | 0.0009956 | ||||
Execute Meta Txn | 20641837 | 85 days ago | IN | 0 ETH | 0.00097665 | ||||
Execute Meta Txn | 20641837 | 85 days ago | IN | 0 ETH | 0.00093903 | ||||
Execute Meta Txn | 20641830 | 85 days ago | IN | 0 ETH | 0.00217484 | ||||
Execute Meta Txn | 20641828 | 85 days ago | IN | 0 ETH | 0.00086091 | ||||
Execute Meta Txn | 20641828 | 85 days ago | IN | 0 ETH | 0.00090345 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
20642243 | 85 days ago | 0.03251377 ETH | ||||
20642243 | 85 days ago | 0.00008148 ETH | ||||
20642243 | 85 days ago | 0.0001309 ETH | ||||
20642243 | 85 days ago | 0.00212969 ETH | ||||
20642243 | 85 days ago | 0.03485586 ETH | ||||
20642181 | 85 days ago | 0.20014483 ETH | ||||
20642181 | 85 days ago | 0.0029654 ETH | ||||
20642181 | 85 days ago | 0.20311024 ETH | ||||
20642139 | 85 days ago | 2.04836075 ETH | ||||
20642139 | 85 days ago | 2.04836075 ETH | ||||
20642088 | 85 days ago | 0.67697541 ETH | ||||
20642088 | 85 days ago | 0.67697541 ETH | ||||
20642087 | 85 days ago | 8.01832454 ETH | ||||
20642087 | 85 days ago | 8.01832454 ETH | ||||
20642024 | 85 days ago | 0.25020022 ETH | ||||
20642024 | 85 days ago | 0.00156091 ETH | ||||
20642024 | 85 days ago | 0.25176114 ETH | ||||
20641899 | 85 days ago | 0.31733575 ETH | ||||
20641899 | 85 days ago | 0.00220483 ETH | ||||
20641899 | 85 days ago | 0.31954058 ETH | ||||
20641873 | 85 days ago | 0.19764086 ETH | ||||
20641873 | 85 days ago | 0.00189559 ETH | ||||
20641873 | 85 days ago | 0.19953645 ETH | ||||
20641857 | 85 days ago | 0.90742143 ETH | ||||
20641857 | 85 days ago | 0.90742143 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
MainnetSettlerMetaTxn
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 10000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 >=0.8.25 ^0.8.17 ^0.8.25; // lib/forge-std/src/interfaces/IERC20.sol /// @dev Interface of the ERC20 standard as defined in the EIP. /// @dev This includes the optional name, symbol, and decimals metadata. interface IERC20 { /// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`). event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value` /// is the new allowance. event Approval(address indexed owner, address indexed spender, uint256 value); /// @notice Returns the amount of tokens in existence. function totalSupply() external view returns (uint256); /// @notice Returns the amount of tokens owned by `account`. function balanceOf(address account) external view returns (uint256); /// @notice Moves `amount` tokens from the caller's account to `to`. function transfer(address to, uint256 amount) external returns (bool); /// @notice Returns the remaining number of tokens that `spender` is allowed /// to spend on behalf of `owner` function allowance(address owner, address spender) external view returns (uint256); /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens. /// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address spender, uint256 amount) external returns (bool); /// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism. /// `amount` is then deducted from the caller's allowance. function transferFrom(address from, address to, uint256 amount) external returns (bool); /// @notice Returns the name of the token. function name() external view returns (string memory); /// @notice Returns the symbol of the token. function symbol() external view returns (string memory); /// @notice Returns the decimals places of the token. function decimals() external view returns (uint8); } // lib/permit2/src/interfaces/IEIP712.sol interface IEIP712 { function DOMAIN_SEPARATOR() external view returns (bytes32); } // src/Context.sol abstract contract AbstractContext { function _msgSender() internal view virtual returns (address); function _msgData() internal view virtual returns (bytes calldata); function _isForwarded() internal view virtual returns (bool); } abstract contract Context is AbstractContext { function _msgSender() internal view virtual override returns (address) { return msg.sender; } function _msgData() internal view virtual override returns (bytes calldata) { return msg.data; } function _isForwarded() internal view virtual override returns (bool) { return false; } } // src/IERC721Owner.sol interface IERC721Owner { function ownerOf(uint256) external view returns (address); } // src/allowanceholder/IAllowanceHolder.sol interface IAllowanceHolder { /// @notice Executes against `target` with the `data` payload. Prior to execution, token permits /// are temporarily stored for the duration of the transaction. These permits can be /// consumed by the `operator` during the execution /// @notice `operator` consumes the funds during its operations by calling back into /// `AllowanceHolder` with `transferFrom`, consuming a token permit. /// @dev Neither `exec` nor `transferFrom` check that `token` contains code. /// @dev msg.sender is forwarded to target appended to the msg data (similar to ERC-2771) /// @param operator An address which is allowed to consume the token permits /// @param token The ERC20 token the caller has authorised to be consumed /// @param amount The quantity of `token` the caller has authorised to be consumed /// @param target A contract to execute operations with `data` /// @param data The data to forward to `target` /// @return result The returndata from calling `target` with `data` /// @notice If calling `target` with `data` reverts, the revert is propagated function exec(address operator, address token, uint256 amount, address payable target, bytes calldata data) external payable returns (bytes memory result); /// @notice The counterpart to `exec` which allows for the consumption of token permits later /// during execution /// @dev *DOES NOT* check that `token` contains code. This function vacuously succeeds if /// `token` is empty. /// @dev can only be called by the `operator` previously registered in `exec` /// @param token The ERC20 token to transfer /// @param owner The owner of tokens to transfer /// @param recipient The destination/beneficiary of the ERC20 `transferFrom` /// @param amount The quantity of `token` to transfer` /// @return true function transferFrom(address token, address owner, address recipient, uint256 amount) external returns (bool); } // src/core/univ3forks/PancakeSwapV3.sol address constant pancakeSwapV3Factory = 0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9; bytes32 constant pancakeSwapV3InitHash = 0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2; uint8 constant pancakeSwapV3ForkId = 1; interface IPancakeSwapV3Callback { function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; } // src/core/univ3forks/SolidlyV3.sol address constant solidlyV3Factory = 0x70Fe4a44EA505cFa3A57b95cF2862D4fd5F0f687; bytes32 constant solidlyV3InitHash = 0xe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf; uint8 constant solidlyV3ForkId = 3; interface ISolidlyV3Callback { function solidlyV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; } // src/core/univ3forks/SushiswapV3.sol address constant sushiswapV3MainnetFactory = 0xbACEB8eC6b9355Dfc0269C18bac9d6E2Bdc29C4F; address constant sushiswapV3Factory = 0xc35DADB65012eC5796536bD9864eD8773aBc74C4; // Base, Linea address constant sushiswapV3ArbitrumFactory = 0x1af415a1EbA07a4986a52B6f2e7dE7003D82231e; //address constant sushiswapV3AvalancheFactory = 0x3e603C14aF37EBdaD31709C4f848Fc6aD5BEc715; //address constant sushiswapV3BlastFactory = 0x7680D4B43f3d1d54d6cfEeB2169463bFa7a6cf0d; //address constant sushiswapV3BnbFactory = 0x126555dd55a39328F69400d6aE4F782Bd4C34ABb; address constant sushiswapV3OptimismFactory = 0x9c6522117e2ed1fE5bdb72bb0eD5E3f2bdE7DBe0; address constant sushiswapV3PolygonFactory = 0x917933899c6a5F8E37F31E19f92CdBFF7e8FF0e2; address constant sushiswapV3ScrollFactory = 0x46B3fDF7b5CDe91Ac049936bF0bDb12c5d22202e; //bytes32 constant sushiswapV3BlastInitHash = 0x8e13daee7f5a62e37e71bf852bcd44e7d16b90617ed2b17c24c2ee62411c5bae; uint8 constant sushiswapV3ForkId = 2; // src/core/univ3forks/UniswapV3.sol address constant uniswapV3MainnetFactory = 0x1F98431c8aD98523631AE4a59f267346ea31F984; address constant uniswapV3SepoliaFactory = 0x0227628f3F023bb0B980b67D528571c95c6DaC1c; address constant uniswapV3BaseFactory = 0x33128a8fC17869897dcE68Ed026d694621f6FDfD; address constant uniswapV3BnbFactory = 0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7; address constant uniswapV3AvalancheFactory = 0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD; address constant uniswapV3BlastFactory = 0x792edAdE80af5fC680d96a2eD80A44247D2Cf6Fd; address constant uniswapV3ScrollFactory = 0x70C62C8b8e801124A4Aa81ce07b637A3e83cb919; bytes32 constant uniswapV3InitHash = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; uint8 constant uniswapV3ForkId = 0; interface IUniswapV3Callback { function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; } // src/utils/FreeMemory.sol abstract contract FreeMemory { modifier DANGEROUS_freeMemory() { uint256 freeMemPtr; assembly ("memory-safe") { freeMemPtr := mload(0x40) } _; assembly ("memory-safe") { mstore(0x40, freeMemPtr) } } } // src/utils/Panic.sol library Panic { function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) // selector for `Panic(uint256)` mstore(0x20, code) revert(0x1c, 0x24) } } // https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require uint8 internal constant GENERIC = 0x00; uint8 internal constant ASSERT_FAIL = 0x01; uint8 internal constant ARITHMETIC_OVERFLOW = 0x11; uint8 internal constant DIVISION_BY_ZERO = 0x12; uint8 internal constant ENUM_CAST = 0x21; uint8 internal constant CORRUPT_STORAGE_ARRAY = 0x22; uint8 internal constant POP_EMPTY_ARRAY = 0x31; uint8 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; uint8 internal constant OUT_OF_MEMORY = 0x41; uint8 internal constant ZERO_FUNCTION_POINTER = 0x51; } // src/utils/Revert.sol library Revert { function _revert(bytes memory reason) internal pure { assembly ("memory-safe") { revert(add(reason, 0x20), mload(reason)) } } function maybeRevert(bool success, bytes memory reason) internal pure { if (!success) { _revert(reason); } } } // src/utils/UnsafeMath.sol library UnsafeMath { function unsafeInc(uint256 x) internal pure returns (uint256) { unchecked { return x + 1; } } function unsafeInc(int256 x) internal pure returns (int256) { unchecked { return x + 1; } } function unsafeNeg(int256 x) internal pure returns (int256) { unchecked { return -x; } } function unsafeDiv(uint256 numerator, uint256 denominator) internal pure returns (uint256 quotient) { assembly ("memory-safe") { quotient := div(numerator, denominator) } } function unsafeDiv(int256 numerator, int256 denominator) internal pure returns (int256 quotient) { assembly ("memory-safe") { quotient := sdiv(numerator, denominator) } } function unsafeMod(uint256 numerator, uint256 denominator) internal pure returns (uint256 remainder) { assembly ("memory-safe") { remainder := mod(numerator, denominator) } } function unsafeMod(int256 numerator, int256 denominator) internal pure returns (int256 remainder) { assembly ("memory-safe") { remainder := smod(numerator, denominator) } } function unsafeMulMod(uint256 a, uint256 b, uint256 m) internal pure returns (uint256 r) { assembly ("memory-safe") { r := mulmod(a, b, m) } } function unsafeAddMod(uint256 a, uint256 b, uint256 m) internal pure returns (uint256 r) { assembly ("memory-safe") { r := addmod(a, b, m) } } } // lib/permit2/src/interfaces/ISignatureTransfer.sol /// @title SignatureTransfer /// @notice Handles ERC20 token transfers through signature based actions /// @dev Requires user's token approval on the Permit2 contract interface ISignatureTransfer is IEIP712 { /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount /// @param maxAmount The maximum amount a spender can request to transfer error InvalidAmount(uint256 maxAmount); /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred error LengthMismatch(); /// @notice Emits an event when the owner successfully invalidates an unordered nonce. event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask); /// @notice The token and amount details for a transfer signed in the permit transfer signature struct TokenPermissions { // ERC20 token address address token; // the maximum amount that can be spent uint256 amount; } /// @notice The signed permit message for a single token transfer struct PermitTransferFrom { TokenPermissions permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice Specifies the recipient address and amount for batched transfers. /// @dev Recipients and amounts correspond to the index of the signed token permissions array. /// @dev Reverts if the requested amount is greater than the permitted signed amount. struct SignatureTransferDetails { // recipient address address to; // spender requested amount uint256 requestedAmount; } /// @notice Used to reconstruct the signed permit message for multiple token transfers /// @dev Do not need to pass in spender address as it is required that it is msg.sender /// @dev Note that a user still signs over a spender address struct PermitBatchTransferFrom { // the tokens and corresponding amounts permitted for a transfer TokenPermissions[] permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce /// @dev It returns a uint256 bitmap /// @dev The index, or wordPosition is capped at type(uint248).max function nonceBitmap(address, uint256) external view returns (uint256); /// @notice Transfers a token using a signed permit message /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param signature The signature to verify function permitTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers a token using a signed permit message /// @notice Includes extra data provided by the caller to verify signature over /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param signature The signature to verify function permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @notice Includes extra data provided by the caller to verify signature over /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Invalidates the bits specified in mask for the bitmap at the word position /// @dev The wordPos is maxed at type(uint248).max /// @param wordPos A number to index the nonceBitmap at /// @param mask A bitmap masked against msg.sender's current bitmap at the word position function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external; } // src/core/SettlerErrors.sol /// @notice Thrown when an offset is not the expected value error InvalidOffset(); /// @notice Thrown when a validating a target contract to avoid certain types of targets error ConfusedDeputy(); /// @notice Thrown when a target contract is invalid given the context error InvalidTarget(); /// @notice Thrown when validating the caller against the expected caller error InvalidSender(); /// @notice Thrown in cases when using a Trusted Forwarder / AllowanceHolder is not allowed error ForwarderNotAllowed(); /// @notice Thrown when a signature length is not the expected length error InvalidSignatureLen(); /// @notice Thrown when a slippage limit is exceeded error TooMuchSlippage(IERC20 token, uint256 expected, uint256 actual); /// @notice Thrown when a byte array that is supposed to encode a function from ISettlerActions is /// not recognized in context. error ActionInvalid(uint256 i, bytes4 action, bytes data); /// @notice Thrown when the encoded fork ID as part of UniswapV3 fork path is not on the list of /// recognized forks for this chain. error UnknownForkId(uint8 forkId); /// @notice Thrown when an AllowanceHolder transfer's permit is past its deadline error SignatureExpired(uint256 deadline); /// @notice An internal error that should never be thrown. Thrown when a callback reenters the /// entrypoint and attempts to clobber the existing callback. error ReentrantCallback(uint256 callbackInt); /// @notice An internal error that should never be thrown. This error can only be thrown by /// non-metatx-supporting Settler instances. Thrown when a callback-requiring liquidity /// source is called, but Settler never receives the callback. error CallbackNotSpent(uint256 callbackInt); /// @notice Thrown when a metatransaction has reentrancy. error ReentrantMetatransaction(bytes32 oldWitness); /// @notice Thrown when any transaction has reentrancy, not just taker-submitted or metatransaction. error ReentrantPayer(address oldPayer); /// @notice An internal error that should never be thrown. Thrown when a metatransaction fails to /// spend a coupon. error WitnessNotSpent(bytes32 oldWitness); /// @notice An internal error that should never be thrown. Thrown when the payer is unset /// unexpectedly. error PayerSpent(); // src/vendor/SafeTransferLib.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 { uint32 private constant _TRANSFER_FROM_FAILED_SELECTOR = 0x7939f424; // bytes4(keccak256("TransferFromFailed()")) uint32 private constant _TRANSFER_FAILED_SELECTOR = 0x90b8ec18; // bytes4(keccak256("TransferFailed()")) uint32 private constant _APPROVE_FAILED_SELECTOR = 0x3e3f8f73; // bytes4(keccak256("ApproveFailed()")) /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address payable to, uint256 amount) internal { assembly ("memory-safe") { // Transfer the ETH and store if it succeeded or not. if iszero(call(gas(), to, amount, 0, 0, 0, 0)) { let freeMemoryPointer := mload(0x40) returndatacopy(freeMemoryPointer, 0, returndatasize()) revert(freeMemoryPointer, returndatasize()) } } } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom(IERC20 token, address from, address to, uint256 amount) internal { assembly ("memory-safe") { // 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. // 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. if iszero(call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)) { returndatacopy(freeMemoryPointer, 0, returndatasize()) revert(freeMemoryPointer, returndatasize()) } // We check that the call either returned exactly 1 (can't just be non-zero data), or had no // return data. if iszero(or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize()))) { mstore(0, _TRANSFER_FROM_FAILED_SELECTOR) revert(0x1c, 0x04) } } } function safeTransfer(IERC20 token, address to, uint256 amount) internal { assembly ("memory-safe") { // 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. // 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. if iszero(call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)) { returndatacopy(freeMemoryPointer, 0, returndatasize()) revert(freeMemoryPointer, returndatasize()) } // We check that the call either returned exactly 1 (can't just be non-zero data), or had no // return data. if iszero(or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize()))) { mstore(0, _TRANSFER_FAILED_SELECTOR) revert(0x1c, 0x04) } } } function safeApprove(IERC20 token, address to, uint256 amount) internal { assembly ("memory-safe") { // 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. // 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. if iszero(call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)) { returndatacopy(freeMemoryPointer, 0, returndatasize()) revert(freeMemoryPointer, returndatasize()) } // We check that the call either returned exactly 1 (can't just be non-zero data), or had no // return data. if iszero(or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize()))) { mstore(0, _APPROVE_FAILED_SELECTOR) revert(0x1c, 0x04) } } } function safeApproveIfBelow(IERC20 token, address spender, uint256 amount) internal { uint256 allowance = token.allowance(address(this), spender); if (allowance < amount) { if (allowance != 0) { safeApprove(token, spender, 0); } safeApprove(token, spender, type(uint256).max); } } } // src/ISettlerActions.sol interface ISettlerActions { /// @dev Transfer funds from msg.sender Permit2. function TRANSFER_FROM(address recipient, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig) external; /// @dev Transfer funds from metatransaction requestor into the Settler contract using Permit2. Only for use in `Settler.executeMetaTxn` where the signature is provided as calldata function METATXN_TRANSFER_FROM(address recipient, ISignatureTransfer.PermitTransferFrom memory permit) external; /// @dev Settle an RfqOrder between maker and taker transfering funds directly between the parties // Post-req: Payout if recipient != taker function RFQ_VIP( address recipient, ISignatureTransfer.PermitTransferFrom memory makerPermit, address maker, bytes memory makerSig, ISignatureTransfer.PermitTransferFrom memory takerPermit, bytes memory takerSig ) external; /// @dev Settle an RfqOrder between maker and taker transfering funds directly between the parties for the entire amount function METATXN_RFQ_VIP( address recipient, ISignatureTransfer.PermitTransferFrom memory makerPermit, address maker, bytes memory makerSig, ISignatureTransfer.PermitTransferFrom memory takerPermit ) external; /// @dev Settle an RfqOrder between Maker and Settler. Transfering funds from the Settler contract to maker. /// Retaining funds in the settler contract. // Pre-req: Funded // Post-req: Payout function RFQ( address recipient, ISignatureTransfer.PermitTransferFrom memory permit, address maker, bytes memory makerSig, address takerToken, uint256 maxTakerAmount ) external; /// @dev Trades against UniswapV3 using the contracts balance for funding // Pre-req: Funded // Post-req: Payout function UNISWAPV3(address recipient, uint256 bps, bytes memory path, uint256 amountOutMin) external; /// @dev Trades against UniswapV3 using user funds via Permit2 for funding function UNISWAPV3_VIP( address recipient, bytes memory path, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 amountOutMin ) external; function MAKERPSM(address recipient, address gemToken, uint256 bps, address psm, bool buyGem) external; function CURVE_TRICRYPTO_VIP( address recipient, uint80 poolInfo, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) external; function METATXN_CURVE_TRICRYPTO_VIP( address recipient, uint80 poolInfo, ISignatureTransfer.PermitTransferFrom memory permit, uint256 minBuyAmount ) external; function DODOV1(address sellToken, uint256 bps, address pool, bool quoteForBase, uint256 minBuyAmount) external; function DODOV2( address recipient, address sellToken, uint256 bps, address pool, bool quoteForBase, uint256 minBuyAmount ) external; function VELODROME(address recipient, uint256 bps, address pool, uint24 swapInfo, uint256 minBuyAmount) external; /// @dev Trades against UniswapV3 using user funds via Permit2 for funding. Metatransaction variant. Signature is over all actions. function METATXN_UNISWAPV3_VIP( address recipient, bytes memory path, ISignatureTransfer.PermitTransferFrom memory permit, uint256 amountOutMin ) external; /// @dev Trades against MaverickV2 using the contracts balance for funding /// This action does not use the MaverickV2 callback, so it takes an arbitrary pool address to make calls against. /// Passing `tokenAIn` as a parameter actually saves gas relative to introspecting the pool's `tokenA()` accessor. function MAVERICKV2( address recipient, address sellToken, uint256 bps, address pool, bool tokenAIn, uint256 minBuyAmount ) external; /// @dev Trades against MaverickV2, spending the taker's coupon inside the callback /// This action requires the use of the MaverickV2 callback, so we take the MaverickV2 CREATE2 salt as an argument to derive the pool address from the trusted factory and inithash. /// @param salt is formed as `keccak256(abi.encode(feeAIn, feeBIn, tickSpacing, lookback, tokenA, tokenB, kinds, address(0)))` function MAVERICKV2_VIP( address recipient, bytes32 salt, bool tokenAIn, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) external; /// @dev Trades against MaverickV2, spending the taker's coupon inside the callback; metatransaction variant function METATXN_MAVERICKV2_VIP( address recipient, bytes32 salt, bool tokenAIn, ISignatureTransfer.PermitTransferFrom memory permit, uint256 minBuyAmount ) external; /// @dev Trades against UniswapV2 using the contracts balance for funding /// @param swapInfo is encoded as the upper 16 bits as the fee of the pool in bps, the second /// lowest bit as "sell token has transfer fee", and the lowest bit as the /// "token0 for token1" flag. function UNISWAPV2( address recipient, address sellToken, uint256 bps, address pool, uint24 swapInfo, uint256 amountOutMin ) external; function POSITIVE_SLIPPAGE(address recipient, address token, uint256 expectedAmount) external; /// @dev Trades against a basic AMM which follows the approval, transferFrom(msg.sender) interaction // Pre-req: Funded // Post-req: Payout function BASIC(address sellToken, uint256 bps, address pool, uint256 offset, bytes calldata data) external; } // src/allowanceholder/AllowanceHolderContext.sol abstract contract AllowanceHolderContext is Context { IAllowanceHolder internal constant _ALLOWANCE_HOLDER = IAllowanceHolder(0x0000000000001fF3684f28c67538d4D072C22734); function _isForwarded() internal view virtual override returns (bool) { return super._isForwarded() || super._msgSender() == address(_ALLOWANCE_HOLDER); } function _msgSender() internal view virtual override returns (address sender) { sender = super._msgSender(); if (sender == address(_ALLOWANCE_HOLDER)) { // ERC-2771 like usage where the _trusted_ `AllowanceHolder` has appended the appropriate // msg.sender to the msg data assembly ("memory-safe") { sender := shr(0x60, calldataload(sub(calldatasize(), 0x14))) } } } // this is here to avoid foot-guns and make it very explicit that we intend // to pass the confused deputy check in AllowanceHolder function balanceOf(address) external pure { assembly ("memory-safe") { mstore8(0x00, 0x00) return(0x00, 0x01) } } } // src/utils/AddressDerivation.sol library AddressDerivation { using UnsafeMath for uint256; uint256 internal constant _SECP256K1_P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F; uint256 internal constant _SECP256K1_N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141; uint256 internal constant SECP256K1_GX = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798; uint256 internal constant SECP256K1_GY = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8; error InvalidCurve(uint256 x, uint256 y); // keccak256(abi.encodePacked(ECMUL([x, y], k)))[12:] function deriveEOA(uint256 x, uint256 y, uint256 k) internal pure returns (address) { if (k == 0) { Panic.panic(Panic.DIVISION_BY_ZERO); } if (k >= _SECP256K1_N || x >= _SECP256K1_P || y >= _SECP256K1_P) { Panic.panic(Panic.ARITHMETIC_OVERFLOW); } // +/-7 are neither square nor cube mod p, so we only have to check one // coordinate against 0. if it is 0, then the other is too (the point at // infinity) or the point is invalid if ( x == 0 || y.unsafeMulMod(y, _SECP256K1_P) != x.unsafeMulMod(x, _SECP256K1_P).unsafeMulMod(x, _SECP256K1_P).unsafeAddMod(7, _SECP256K1_P) ) { revert InvalidCurve(x, y); } unchecked { // https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384 return ecrecover( bytes32(0), uint8(27 + (y & 1)), bytes32(x), bytes32(UnsafeMath.unsafeMulMod(x, k, _SECP256K1_N)) ); } } // keccak256(RLP([deployer, nonce]))[12:] function deriveContract(address deployer, uint64 nonce) internal pure returns (address result) { if (nonce == 0) { assembly ("memory-safe") { mstore( 0x00, or( 0xd694000000000000000000000000000000000000000080, shl(8, and(0xffffffffffffffffffffffffffffffffffffffff, deployer)) ) ) result := keccak256(0x09, 0x17) } } else if (nonce < 0x80) { assembly ("memory-safe") { // we don't care about dirty bits in `deployer`; they'll be overwritten later mstore(0x14, deployer) mstore(0x00, 0xd694) mstore8(0x34, nonce) result := keccak256(0x1e, 0x17) } } else { // compute ceil(log_256(nonce)) + 1 uint256 nonceLength = 8; unchecked { if ((uint256(nonce) >> 32) != 0) { nonceLength += 32; if (nonce == type(uint64).max) { Panic.panic(Panic.ARITHMETIC_OVERFLOW); } } if ((uint256(nonce) >> 8) >= (1 << nonceLength)) { nonceLength += 16; } if (uint256(nonce) >= (1 << nonceLength)) { nonceLength += 8; } // ceil if ((uint256(nonce) << 8) >= (1 << nonceLength)) { nonceLength += 8; } // bytes, not bits nonceLength >>= 3; } assembly ("memory-safe") { // we don't care about dirty bits in `deployer` or `nonce`. they'll be overwritten later mstore(nonceLength, nonce) mstore8(0x20, add(0x7f, nonceLength)) mstore(0x00, deployer) mstore8(0x0a, add(0xd5, nonceLength)) mstore8(0x0b, 0x94) result := keccak256(0x0a, add(0x16, nonceLength)) } } } // keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, initHash))[12:] function deriveDeterministicContract(address deployer, bytes32 salt, bytes32 initHash) internal pure returns (address result) { assembly ("memory-safe") { let ptr := mload(0x40) // we don't care about dirty bits in `deployer`; they'll be overwritten later mstore(ptr, deployer) mstore8(add(ptr, 0x0b), 0xff) mstore(add(ptr, 0x20), salt) mstore(add(ptr, 0x40), initHash) result := keccak256(add(ptr, 0x0b), 0x55) } } } // src/vendor/FullMath.sol /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv library FullMath { using UnsafeMath for uint256; /// @notice 512-bit multiply [prod1 prod0] = a * b /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return prod0 Least significant 256 bits of the product /// @return prod1 Most significant 256 bits of the product /// @return remainder Remainder of full-precision division function _mulDivSetup(uint256 a, uint256 b, uint256 denominator) private pure returns (uint256 prod0, uint256 prod1, uint256 remainder) { // Compute the product mod 2**256 and mod 2**256 - 1 then use the Chinese // Remainder Theorem to reconstruct the 512 bit result. The result is stored // in two 256 variables such that product = prod1 * 2**256 + prod0 assembly ("memory-safe") { // Full-precision multiplication { let mm := mulmod(a, b, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } remainder := mulmod(a, b, denominator) } } /// @notice 512-bit by 256-bit division. /// @param prod0 Least significant 256 bits of the product /// @param prod1 Most significant 256 bits of the product /// @param denominator The divisor /// @param remainder Remainder of full-precision division /// @return The 256-bit result /// @dev Overflow and division by zero aren't checked and are GIGO errors function _mulDivInvert(uint256 prod0, uint256 prod1, uint256 denominator, uint256 remainder) private pure returns (uint256) { uint256 inv; assembly ("memory-safe") { // Make division exact by rounding [prod1 prod0] down to a multiple of // denominator // Subtract 256 bit number from 512 bit number prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) // Factor powers of two out of denominator { // Compute largest power of two divisor of denominator. // Always >= 1. let twos := and(sub(0, denominator), denominator) // Divide denominator by power of two denominator := div(denominator, twos) // Divide [prod1 prod0] by the factors of two prod0 := div(prod0, twos) // Shift in bits from prod1 into prod0. For this we need to flip `twos` // such that it is 2**256 / twos. // If twos is zero, then it becomes one twos := add(div(sub(0, twos), twos), 1) prod0 := or(prod0, mul(prod1, twos)) } // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse modulo 2**256 // such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct correct for // four bits. That is, denominator * inv = 1 mod 2**4 inv := xor(mul(3, denominator), 2) // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**8 inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**16 inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**32 inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**64 inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**128 inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2**256 } // Because the division is now exact we can divide by multiplying with the // modular inverse of denominator. This will give us the correct result // modulo 2**256. Since the precoditions guarantee that the outcome is less // than 2**256, this is the final result. We don't need to compute the high // bits of the result and prod1 is no longer required. unchecked { return prod0 * inv; } } /// @notice Calculates a×b÷denominator with full precision then rounds towards 0. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return The 256-bit result function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256) { (uint256 prod0, uint256 prod1, uint256 remainder) = _mulDivSetup(a, b, denominator); // Make sure the result is less than 2**256. // Also prevents denominator == 0 if (denominator <= prod1) { Panic.panic(denominator == 0 ? Panic.DIVISION_BY_ZERO : Panic.ARITHMETIC_OVERFLOW); } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { return prod0.unsafeDiv(denominator); } return _mulDivInvert(prod0, prod1, denominator, remainder); } /// @notice Calculates a×b÷denominator with full precision then rounds towards 0. Overflowing a uint256 or denominator == 0 are GIGO errors /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return The 256-bit result function unsafeMulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256) { (uint256 prod0, uint256 prod1, uint256 remainder) = _mulDivSetup(a, b, denominator); // Overflow and zero-division checks are skipped // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { return prod0.unsafeDiv(denominator); } return _mulDivInvert(prod0, prod1, denominator, remainder); } } // src/core/MakerPSM.sol interface IPSM { /// @dev Get the fee for selling DAI to USDC in PSM /// @return tout toll out [wad] function tout() external view returns (uint256); /// @dev Get the address of the underlying vault powering PSM /// @return address of gemJoin contract function gemJoin() external view returns (address); /// @dev Sell USDC for DAI /// @param usr The address of the account trading USDC for DAI. /// @param gemAmt The amount of USDC to sell in USDC base units function sellGem(address usr, uint256 gemAmt) external; /// @dev Buy USDC for DAI /// @param usr The address of the account trading DAI for USDC /// @param gemAmt The amount of USDC to buy in USDC base units function buyGem(address usr, uint256 gemAmt) external; } abstract contract MakerPSM { using UnsafeMath for uint256; using SafeTransferLib for IERC20; // Maker units https://github.com/makerdao/dss/blob/master/DEVELOPING.md // wad: fixed point decimal with 18 decimals (for basic quantities, e.g. balances) uint256 internal constant WAD = 10 ** 18; IERC20 internal constant DAI = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); constructor() { assert(block.chainid == 1 || block.chainid == 31337); } function sellToMakerPsm(address recipient, IERC20 gemToken, uint256 bps, IPSM psm, bool buyGem) internal { if (buyGem) { // phantom overflow can't happen here because DAI has decimals = 18 uint256 sellAmount = (DAI.balanceOf(address(this)) * bps).unsafeDiv(10_000); unchecked { uint256 feeDivisor = psm.tout() + WAD; // eg. 1.001 * 10 ** 18 with 0.1% fee [tout is in wad]; // overflow can't happen at all because DAI is reasonable and PSM prohibits gemToken with decimals > 18 uint256 buyAmount = (sellAmount * 10 ** uint256(gemToken.decimals())).unsafeDiv(feeDivisor); DAI.safeApproveIfBelow(address(psm), sellAmount); psm.buyGem(recipient, buyAmount); } } else { // phantom overflow can't happen here because PSM prohibits gemToken with decimals > 18 uint256 sellAmount = (gemToken.balanceOf(address(this)) * bps).unsafeDiv(10_000); gemToken.safeApproveIfBelow(psm.gemJoin(), sellAmount); psm.sellGem(recipient, sellAmount); } } } // src/core/Permit2PaymentAbstract.sol abstract contract Permit2PaymentAbstract is AbstractContext { string internal constant TOKEN_PERMISSIONS_TYPE = "TokenPermissions(address token,uint256 amount)"; function _isRestrictedTarget(address) internal view virtual returns (bool); function _operator() internal view virtual returns (address); function _permitToTransferDetails(ISignatureTransfer.PermitTransferFrom memory permit, address recipient) internal pure virtual returns (ISignatureTransfer.SignatureTransferDetails memory transferDetails, address token, uint256 amount); function _transferFromIKnowWhatImDoing( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, address from, bytes32 witness, string memory witnessTypeString, bytes memory sig, bool isForwarded ) internal virtual; function _transferFromIKnowWhatImDoing( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, address from, bytes32 witness, string memory witnessTypeString, bytes memory sig ) internal virtual; function _transferFrom( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, bytes memory sig, bool isForwarded ) internal virtual; function _transferFrom( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, bytes memory sig ) internal virtual; function _setOperatorAndCall( address target, bytes memory data, uint32 selector, function (bytes calldata) internal returns (bytes memory) callback ) internal virtual returns (bytes memory); modifier metaTx(address msgSender, bytes32 witness) virtual; modifier takerSubmitted() virtual; function _allowanceHolderTransferFrom(address token, address owner, address recipient, uint256 amount) internal virtual; } // src/SettlerAbstract.sol abstract contract SettlerAbstract is Permit2PaymentAbstract { // Permit2 Witness for meta transactions string internal constant SLIPPAGE_AND_ACTIONS_TYPE = "SlippageAndActions(address recipient,address buyToken,uint256 minAmountOut,bytes[] actions)"; bytes32 internal constant SLIPPAGE_AND_ACTIONS_TYPEHASH = 0x615e8d716cef7295e75dd3f1f10d679914ad6d7759e8e9459f0109ef75241701; constructor() { assert(SLIPPAGE_AND_ACTIONS_TYPEHASH == keccak256(bytes(SLIPPAGE_AND_ACTIONS_TYPE))); } function _hasMetaTxn() internal pure virtual returns (bool); function _dispatch(uint256 i, bytes4 action, bytes calldata data) internal virtual returns (bool); } // src/core/UniswapV2.sol interface IUniV2Pair { function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112, uint112, uint32); function swap(uint256, uint256, address, bytes calldata) external; } abstract contract UniswapV2 { using UnsafeMath for uint256; // bytes4(keccak256("getReserves()")) uint32 private constant UNI_PAIR_RESERVES_SELECTOR = 0x0902f1ac; // bytes4(keccak256("swap(uint256,uint256,address,bytes)")) uint32 private constant UNI_PAIR_SWAP_SELECTOR = 0x022c0d9f; // bytes4(keccak256("transfer(address,uint256)")) uint32 private constant ERC20_TRANSFER_SELECTOR = 0xa9059cbb; // bytes4(keccak256("balanceOf(address)")) uint32 private constant ERC20_BALANCEOF_SELECTOR = 0x70a08231; /// @dev Sell a token for another token using UniswapV2. function sellToUniswapV2( address recipient, address sellToken, uint256 bps, address pool, uint24 swapInfo, uint256 minBuyAmount ) internal { // Preventing calls to Permit2 or AH is not explicitly required as neither of these contracts implement the `swap` nor `transfer` selector // |7|6|5|4|3|2|1|0| - bit positions in swapInfo (uint8) // |0|0|0|0|0|0|F|Z| - Z: zeroForOne flag, F: sellTokenHasFee flag bool zeroForOne = (swapInfo & 1) == 1; // Extract the least significant bit (bit 0) bool sellTokenHasFee = (swapInfo & 2) >> 1 == 1; // Extract the second least significant bit (bit 1) and shift it right uint256 feeBps = swapInfo >> 8; uint256 sellAmount; uint256 buyAmount; // If bps is zero we assume there are no funds within this contract, skip the updating sellAmount. // This case occurs if the pool is being chained, in which the funds have been sent directly to the pool if (bps != 0) { // We don't care about phantom overflow here because reserves are // limited to 112 bits. Any token balance that would overflow here would // also break UniV2. // It is *possible* to set `bps` above the basis and therefore // cause an overflow on this multiplication. However, `bps` is // passed as authenticated calldata, so this is a GIGO error that we // do not attempt to fix. unchecked { sellAmount = (IERC20(sellToken).balanceOf(address(this)) * bps).unsafeDiv(10_000); } } assembly ("memory-safe") { let ptr := mload(0x40) // transfer sellAmount (a non zero amount) of sellToken to the pool if sellAmount { mstore(ptr, ERC20_TRANSFER_SELECTOR) mstore(add(ptr, 0x20), pool) mstore(add(ptr, 0x40), sellAmount) // ...||ERC20_TRANSFER_SELECTOR|pool|sellAmount| if iszero(call(gas(), sellToken, 0, add(ptr, 0x1c), 0x44, 0x00, 0x20)) { bubbleRevert(ptr) } if iszero(or(iszero(returndatasize()), and(iszero(lt(returndatasize(), 0x20)), eq(mload(0x00), 1)))) { revert(0, 0) } } // get pool reserves let sellReserve let buyReserve mstore(0x00, UNI_PAIR_RESERVES_SELECTOR) // ||UNI_PAIR_RESERVES_SELECTOR| if iszero(staticcall(gas(), pool, 0x1c, 0x04, 0x00, 0x40)) { bubbleRevert(ptr) } if lt(returndatasize(), 0x40) { revert(0, 0) } { let r := shl(5, zeroForOne) buyReserve := mload(r) sellReserve := mload(xor(0x20, r)) } // Update the sell amount in the following cases: // the funds are in the pool already (flagged by sellAmount being 0) // the sell token has a fee (flagged by sellTokenHasFee) if or(iszero(sellAmount), sellTokenHasFee) { // retrieve the sellToken balance of the pool mstore(0x00, ERC20_BALANCEOF_SELECTOR) mstore(0x20, and(0xffffffffffffffffffffffffffffffffffffffff, pool)) // ||ERC20_BALANCEOF_SELECTOR|pool| if iszero(staticcall(gas(), sellToken, 0x1c, 0x24, 0x00, 0x20)) { bubbleRevert(ptr) } if lt(returndatasize(), 0x20) { revert(0, 0) } let bal := mload(0x00) // determine real sellAmount by comparing pool's sellToken balance to reserve amount if lt(bal, sellReserve) { mstore(0x00, 0x4e487b71) // selector for `Panic(uint256)` mstore(0x20, 0x11) // panic code for arithmetic underflow revert(0x1c, 0x24) } sellAmount := sub(bal, sellReserve) } // compute buyAmount based on sellAmount and reserves let sellAmountWithFee := mul(sellAmount, sub(10000, feeBps)) buyAmount := div(mul(sellAmountWithFee, buyReserve), add(sellAmountWithFee, mul(sellReserve, 10000))) let swapCalldata := add(ptr, 0x1c) // set up swap call selector and empty callback data mstore(ptr, UNI_PAIR_SWAP_SELECTOR) mstore(add(ptr, 0x80), 0x80) // offset to length of data mstore(add(ptr, 0xa0), 0) // length of data // set amount0Out and amount1Out { // If `zeroForOne`, offset is 0x24, else 0x04 let offset := add(0x04, shl(5, zeroForOne)) mstore(add(swapCalldata, offset), buyAmount) mstore(add(swapCalldata, xor(0x20, offset)), 0) } mstore(add(swapCalldata, 0x44), and(0xffffffffffffffffffffffffffffffffffffffff, recipient)) // ...||UNI_PAIR_SWAP_SELECTOR|amount0Out|amount1Out|recipient|data| // perform swap at the pool sending bought tokens to the recipient if iszero(call(gas(), pool, 0, swapCalldata, 0xa4, 0, 0)) { bubbleRevert(swapCalldata) } // revert with the return data from the most recent call function bubbleRevert(p) { returndatacopy(p, 0, returndatasize()) revert(p, returndatasize()) } } if (buyAmount < minBuyAmount) { revert TooMuchSlippage( IERC20(zeroForOne ? IUniV2Pair(pool).token1() : IUniV2Pair(pool).token0()), minBuyAmount, buyAmount ); } } } // src/core/Velodrome.sol interface IVelodromePair { function metadata() external view returns ( uint256 basis0, uint256 basis1, uint256 reserve0, uint256 reserve1, bool stable, IERC20 token0, IERC20 token1 ); function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; } abstract contract Velodrome { using UnsafeMath for uint256; using SafeTransferLib for IERC20; uint256 private constant _BASIS = 1 ether; // This is the `k = x^3 * y + y^3 * x` constant function function _k(uint256 x, uint256 y) private pure returns (uint256) { unchecked { return _k(x, y, x * x / _BASIS); } } function _k(uint256 x, uint256 y, uint256 x_squared) private pure returns (uint256) { unchecked { return _k(x, y, x_squared, y * y / _BASIS); } } function _k(uint256 x, uint256 y, uint256 x_squared, uint256 y_squared) private pure returns (uint256) { unchecked { return x * y / _BASIS * (x_squared + y_squared) / _BASIS; } } // For numerically approximating a solution to the `k = x^3 * y + y^3 * x` constant function // using Newton-Raphson, this is `∂k/∂y = 3 * x * y^2 + x^3`. function _d(uint256 y, uint256 three_x0, uint256 x0_cubed) private pure returns (uint256) { unchecked { return _d(y, three_x0, x0_cubed, y * y / _BASIS); } } function _d(uint256 y, uint256 three_x0, uint256 x0_cubed, uint256 y_squared) private pure returns (uint256) { unchecked { return y_squared * three_x0 / _BASIS + x0_cubed; } } error NotConverged(); // Using Newton-Raphson iterations, compute the smallest `new_y` such that `_k(x0, new_y) >= // xy`. As a function of `y`, we find the root of `_k(x0, y) - xy`. function _get_y(uint256 x0, uint256 xy, uint256 y) private pure returns (uint256) { unchecked { uint256 three_x0 = 3 * x0; uint256 x0_squared = x0 * x0 / _BASIS; uint256 x0_cubed = x0_squared * x0 / _BASIS; for (uint256 i; i < 255; i++) { uint256 y_squared = y * y / _BASIS; uint256 k = _k(x0, y, x0_squared, y_squared); if (k < xy) { // there are two cases where dy == 0 // case 1: The y is converged and we find the correct answer // case 2: _d(x0, y) is too large compare to (xy - k) and the rounding error // screwed us. // In this case, we need to increase y by 1 uint256 dy = ((xy - k) * _BASIS).unsafeDiv(_d(y, three_x0, x0_cubed, y_squared)); if (dy == 0) { if (k == xy) { // We found the correct answer. Return y return y; } if (_k(x0, y + 1, x0_squared) > xy) { // If _k(x0, y + 1) > xy, then we are close to the correct answer. // There's no closer answer than y + 1 return y + 1; } dy = 1; } y += dy; } else { uint256 dy = ((k - xy) * _BASIS).unsafeDiv(_d(y, three_x0, x0_cubed, y_squared)); if (dy == 0) { if (k == xy || _k(x0, y - 1, x0_squared) < xy) { // Likewise, if k == xy, we found the correct answer. // If _k(x0, y - 1) < xy, then we are close to the correct answer. // There's no closer answer than "y" // It's worth mentioning that we need to find y where _k(x0, y) >= xy // As a result, we can't return y - 1 even it's closer to the correct answer return y; } dy = 1; } y -= dy; } } revert NotConverged(); } } function sellToVelodrome(address recipient, uint256 bps, IVelodromePair pair, uint24 swapInfo, uint256 minAmountOut) internal { // Preventing calls to Permit2 or AH is not explicitly required as neither of these contracts implement the `swap` nor `transfer` selector // |7|6|5|4|3|2|1|0| - bit positions in swapInfo (uint8) // |0|0|0|0|0|0|F|Z| - Z: zeroForOne flag, F: sellTokenHasFee flag bool zeroForOne = (swapInfo & 1) == 1; // Extract the least significant bit (bit 0) bool sellTokenHasFee = (swapInfo & 2) >> 1 == 1; // Extract the second least significant bit (bit 1) and shift it right uint256 feeBps = swapInfo >> 8; ( uint256 sellBasis, uint256 buyBasis, uint256 sellReserve, uint256 buyReserve, bool stable, IERC20 sellToken, IERC20 buyToken ) = pair.metadata(); assert(stable); if (!zeroForOne) { (sellBasis, buyBasis, sellReserve, buyReserve, sellToken, buyToken) = (buyBasis, sellBasis, buyReserve, sellReserve, buyToken, sellToken); } uint256 buyAmount; unchecked { // Compute sell amount in native units uint256 sellAmount; if (bps != 0) { // It must be possible to square the sell token balance of the pool, otherwise it // will revert with an overflow. Therefore, it can't be so large that multiplying by // a "reasonable" `bps` value could overflow. We don't care to protect against // unreasonable `bps` values because that just means the taker is griefing themself. sellAmount = sellToken.balanceOf(address(this)) * bps / 10_000; } if (sellAmount != 0) { sellToken.safeTransfer(address(pair), sellAmount); } if (sellAmount == 0 || sellTokenHasFee) { sellAmount = sellToken.balanceOf(address(pair)) - sellReserve; } // Apply the fee sellAmount -= sellAmount * feeBps / 10_000; // can't overflow // Convert everything from native units to `_BASIS` sellReserve = (sellReserve * _BASIS).unsafeDiv(sellBasis); buyReserve = (buyReserve * _BASIS).unsafeDiv(buyBasis); sellAmount = (sellAmount * _BASIS).unsafeDiv(sellBasis); // Solve the constant function numerically to get `buyAmount` from `sellAmount` buyAmount = buyReserve - _get_y(sellAmount + sellReserve, _k(sellReserve, buyReserve), buyReserve); // Convert `buyAmount` from `_BASIS` to native units buyAmount = buyAmount * buyBasis / _BASIS; } if (buyAmount < minAmountOut) { revert TooMuchSlippage(sellToken, minAmountOut, buyAmount); } { (uint256 buyAmount0, uint256 buyAmount1) = zeroForOne ? (uint256(0), buyAmount) : (buyAmount, uint256(0)); pair.swap(buyAmount0, buyAmount1, recipient, new bytes(0)); } } } // src/core/RfqOrderSettlement.sol abstract contract RfqOrderSettlement is SettlerAbstract { using SafeTransferLib for IERC20; using FullMath for uint256; struct Consideration { address token; uint256 amount; address counterparty; bool partialFillAllowed; } string internal constant CONSIDERATION_TYPE = "Consideration(address token,uint256 amount,address counterparty,bool partialFillAllowed)"; // `string.concat` isn't recognized by solc as compile-time constant, but `abi.encodePacked` is string internal constant CONSIDERATION_WITNESS = string(abi.encodePacked("Consideration consideration)", CONSIDERATION_TYPE, TOKEN_PERMISSIONS_TYPE)); bytes32 internal constant CONSIDERATION_TYPEHASH = 0x7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa; string internal constant RFQ_ORDER_TYPE = "RfqOrder(Consideration makerConsideration,Consideration takerConsideration)"; string internal constant RFQ_ORDER_TYPE_RECURSIVE = string(abi.encodePacked(RFQ_ORDER_TYPE, CONSIDERATION_TYPE)); bytes32 internal constant RFQ_ORDER_TYPEHASH = 0x49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a7598276; function _hashConsideration(Consideration memory consideration) internal pure returns (bytes32 result) { assembly ("memory-safe") { let ptr := sub(consideration, 0x20) let oldValue := mload(ptr) mstore(ptr, CONSIDERATION_TYPEHASH) result := keccak256(ptr, 0xa0) mstore(ptr, oldValue) } } function _logRfqOrder(bytes32 makerConsiderationHash, bytes32 takerConsiderationHash, uint128 makerFilledAmount) private { assembly ("memory-safe") { mstore(0x00, RFQ_ORDER_TYPEHASH) mstore(0x20, makerConsiderationHash) let ptr := mload(0x40) mstore(0x40, takerConsiderationHash) let orderHash := keccak256(0x00, 0x60) mstore(0x40, ptr) mstore(0x10, makerFilledAmount) mstore(0x00, orderHash) log0(0x00, 0x30) } } constructor() { assert(CONSIDERATION_TYPEHASH == keccak256(bytes(CONSIDERATION_TYPE))); assert(RFQ_ORDER_TYPEHASH == keccak256(bytes(RFQ_ORDER_TYPE_RECURSIVE))); } /// @dev Settle an RfqOrder between maker and taker transfering funds directly between the counterparties. Either /// two Permit2 signatures are consumed, with the maker Permit2 containing a witness of the RfqOrder, or /// AllowanceHolder is supported for the taker payment. The Maker has signed the same order as the /// Taker. Submission may be directly by the taker or via a third party with the Taker signing a witness. /// @dev if used, the taker's witness is not calculated nor verified here as calling function is trusted function fillRfqOrderVIP( address recipient, ISignatureTransfer.PermitTransferFrom memory makerPermit, address maker, bytes memory makerSig, ISignatureTransfer.PermitTransferFrom memory takerPermit, bytes memory takerSig ) internal { ( ISignatureTransfer.SignatureTransferDetails memory makerTransferDetails, address makerToken, uint256 makerAmount ) = _permitToTransferDetails(makerPermit, recipient); ( ISignatureTransfer.SignatureTransferDetails memory takerTransferDetails, address takerToken, uint256 takerAmount ) = _permitToTransferDetails(takerPermit, maker); bytes32 witness = _hashConsideration( Consideration({ token: takerToken, amount: takerAmount, counterparty: _msgSender(), partialFillAllowed: false }) ); _transferFrom(takerPermit, takerTransferDetails, takerSig); _transferFromIKnowWhatImDoing( makerPermit, makerTransferDetails, maker, witness, CONSIDERATION_WITNESS, makerSig, false ); _logRfqOrder( witness, _hashConsideration( Consideration({token: makerToken, amount: makerAmount, counterparty: maker, partialFillAllowed: false}) ), uint128(makerAmount) ); } /// @dev Settle an RfqOrder between maker and Settler retaining funds in this contract. /// @dev pre-condition: msgSender has been authenticated against the requestor /// One Permit2 signature is consumed, with the maker Permit2 containing a witness of the RfqOrder. // In this variant, Maker pays recipient and Settler pays Maker function fillRfqOrderSelfFunded( address recipient, ISignatureTransfer.PermitTransferFrom memory permit, address maker, bytes memory makerSig, IERC20 takerToken, uint256 maxTakerAmount ) internal { // Compute witnesses. These are based on the quoted maximum amounts. We will modify them // later to adjust for the actual settled amount, which may be modified by encountered // slippage. (ISignatureTransfer.SignatureTransferDetails memory transferDetails, address makerToken, uint256 makerAmount) = _permitToTransferDetails(permit, recipient); bytes32 takerWitness = _hashConsideration( Consideration({token: makerToken, amount: makerAmount, counterparty: maker, partialFillAllowed: true}) ); bytes32 makerWitness = _hashConsideration( Consideration({ token: address(takerToken), amount: maxTakerAmount, counterparty: _msgSender(), partialFillAllowed: true }) ); // Now we adjust the transfer amounts to compensate for encountered slippage. Rounding is // performed in the maker's favor. uint256 takerAmount = takerToken.balanceOf(address(this)); if (takerAmount > maxTakerAmount) { takerAmount = maxTakerAmount; } transferDetails.requestedAmount = makerAmount = makerAmount.unsafeMulDiv(takerAmount, maxTakerAmount); // Now that we have all the relevant information, make the transfers and log the order. takerToken.safeTransfer(maker, takerAmount); _transferFromIKnowWhatImDoing( permit, transferDetails, maker, makerWitness, CONSIDERATION_WITNESS, makerSig, false ); _logRfqOrder(makerWitness, takerWitness, uint128(makerAmount)); } } // src/core/CurveTricrypto.sol interface ICurveTricrypto { function exchange_extended( uint256 sellIndex, uint256 buyIndex, uint256 sellAmount, uint256 minBuyAmount, bool useEth, address payer, address receiver, bytes32 callbackSelector ) external returns (uint256 buyAmount); } interface ICurveTricryptoCallback { // The function name/selector is arbitrary, but the arguments are controlled by the pool function curveTricryptoSwapCallback( address payer, address receiver, IERC20 sellToken, uint256 sellAmount, uint256 buyAmount ) external; } abstract contract CurveTricrypto is SettlerAbstract { using UnsafeMath for uint256; using SafeTransferLib for IERC20; using AddressDerivation for address; function _curveFactory() internal virtual returns (address); // uint256 private constant codePrefixLen = 0x539d; // bytes32 private constant codePrefixHash = 0xec96085e693058e09a27755c07882ced27117a3161b1fdaf131a14c7db9978b7; function sellToCurveTricryptoVIP( address recipient, uint80 poolInfo, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) internal { uint64 factoryNonce = uint64(poolInfo >> 16); uint8 sellIndex = uint8(poolInfo >> 8); uint8 buyIndex = uint8(poolInfo); address pool = _curveFactory().deriveContract(factoryNonce); /* bytes32 codePrefixHashActual; assembly ("memory-safe") { let ptr := mload(0x40) extcodecopy(pool, ptr, 0x00, codePrefixLen) codePrefixHashActual := keccak256(ptr, codePrefixLen) } if (codePrefixHashActual != codePrefixHash) { revert ConfusedDeputy(); } */ bool isForwarded = _isForwarded(); assembly ("memory-safe") { tstore(0x00, isForwarded) tstore(0x01, mload(add(0x20, permit))) // nonce tstore(0x02, mload(add(0x40, permit))) // deadline for { let src := add(0x20, sig) let end { let len := mload(sig) end := add(len, src) tstore(0x03, len) } let dst := 0x04 } lt(src, end) { src := add(0x20, src) dst := add(0x01, dst) } { tstore(dst, mload(src)) } } _setOperatorAndCall( pool, abi.encodeCall( ICurveTricrypto.exchange_extended, ( sellIndex, buyIndex, permit.permitted.amount, minBuyAmount, false, address(0), // payer recipient, bytes32(ICurveTricryptoCallback.curveTricryptoSwapCallback.selector) ) ), uint32(ICurveTricryptoCallback.curveTricryptoSwapCallback.selector), _curveTricryptoSwapCallback ); } function _curveTricryptoSwapCallback(bytes calldata data) private returns (bytes memory) { require(data.length == 0xa0); address payer; IERC20 sellToken; uint256 sellAmount; assembly ("memory-safe") { payer := calldataload(data.offset) let err := shr(0xa0, payer) sellToken := calldataload(add(0x40, data.offset)) err := or(shr(0xa0, sellToken), err) sellAmount := calldataload(add(0x60, data.offset)) if err { revert(0x00, 0x00) } } curveTricryptoSwapCallback(payer, address(0), sellToken, sellAmount, 0); return new bytes(0); } function curveTricryptoSwapCallback(address payer, address, IERC20 sellToken, uint256 sellAmount, uint256) private { assert(payer == address(0)); bool isForwarded; uint256 nonce; uint256 deadline; bytes memory sig; assembly ("memory-safe") { isForwarded := tload(0x00) tstore(0x00, 0x00) nonce := tload(0x01) tstore(0x01, 0x00) deadline := tload(0x02) tstore(0x02, 0x00) sig := mload(0x40) for { let dst := add(0x20, sig) let end { let len := tload(0x03) end := add(dst, len) mstore(sig, len) mstore(0x40, end) } let src := 0x04 } lt(dst, end) { src := add(0x01, src) dst := add(0x20, dst) } { mstore(dst, tload(src)) tstore(src, 0x00) } } ISignatureTransfer.PermitTransferFrom memory permit = ISignatureTransfer.PermitTransferFrom({ permitted: ISignatureTransfer.TokenPermissions({token: address(sellToken), amount: sellAmount}), nonce: nonce, deadline: deadline }); (ISignatureTransfer.SignatureTransferDetails memory transferDetails,,) = _permitToTransferDetails(permit, msg.sender); _transferFrom(permit, transferDetails, sig, isForwarded); } } // src/core/DodoV1.sol interface IDodoV1 { function sellBaseToken(uint256 amount, uint256 minReceiveQuote, bytes calldata data) external returns (uint256); function buyBaseToken(uint256 amount, uint256 maxPayQuote, bytes calldata data) external returns (uint256); function _R_STATUS_() external view returns (uint8); function _QUOTE_BALANCE_() external view returns (uint256); function _BASE_BALANCE_() external view returns (uint256); function _K_() external view returns (uint256); function _MT_FEE_RATE_() external view returns (uint256); function _LP_FEE_RATE_() external view returns (uint256); function getExpectedTarget() external view returns (uint256 baseTarget, uint256 quoteTarget); function getOraclePrice() external view returns (uint256); } library Math { function divCeil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 quotient = a / b; unchecked { uint256 remainder = a - quotient * b; if (remainder > 0) { return quotient + 1; } else { return quotient; } } } function sqrt(uint256 x) internal pure returns (uint256 y) { unchecked { uint256 z = x / 2 + 1; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } } library DecimalMath { using Math for uint256; uint256 constant ONE = 10 ** 18; function mul(uint256 target, uint256 d) internal pure returns (uint256) { unchecked { return target * d / ONE; } } function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) { unchecked { return (target * d).divCeil(ONE); } } function divFloor(uint256 target, uint256 d) internal pure returns (uint256) { unchecked { return target * ONE / d; } } function divCeil(uint256 target, uint256 d) internal pure returns (uint256) { unchecked { return (target * ONE).divCeil(d); } } } library DodoMath { using Math for uint256; /* Integrate dodo curve fron V1 to V2 require V0>=V1>=V2>0 res = (1-k)i(V1-V2)+ikV0*V0(1/V2-1/V1) let V1-V2=delta res = i*delta*(1-k+k(V0^2/V1/V2)) */ function _GeneralIntegrate(uint256 V0, uint256 V1, uint256 V2, uint256 i, uint256 k) internal pure returns (uint256) { unchecked { uint256 fairAmount = DecimalMath.mul(i, V1 - V2); // i*delta uint256 V0V0V1V2 = DecimalMath.divCeil(V0 * V0 / V1, V2); uint256 penalty = DecimalMath.mul(k, V0V0V1V2); // k(V0^2/V1/V2) return DecimalMath.mul(fairAmount, DecimalMath.ONE - k + penalty); } } /* The same with integration expression above, we have: i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2) Given Q1 and deltaB, solve Q2 This is a quadratic function and the standard version is aQ2^2 + bQ2 + c = 0, where a=1-k -b=(1-k)Q1-kQ0^2/Q1+i*deltaB c=-kQ0^2 and Q2=(-b+sqrt(b^2+4(1-k)kQ0^2))/2(1-k) note: another root is negative, abondan if deltaBSig=true, then Q2>Q1 if deltaBSig=false, then Q2<Q1 */ function _SolveQuadraticFunctionForTrade(uint256 Q0, uint256 Q1, uint256 ideltaB, bool deltaBSig, uint256 k) internal pure returns (uint256) { unchecked { // calculate -b value and sig // -b = (1-k)Q1-kQ0^2/Q1+i*deltaB uint256 kQ02Q1 = DecimalMath.mul(k, Q0) * Q0 / Q1; // kQ0^2/Q1 uint256 b = DecimalMath.mul(DecimalMath.ONE - k, Q1); // (1-k)Q1 bool minusbSig = true; if (deltaBSig) { b += ideltaB; // (1-k)Q1+i*deltaB } else { kQ02Q1 += ideltaB; // i*deltaB+kQ0^2/Q1 } if (b >= kQ02Q1) { b -= kQ02Q1; minusbSig = true; } else { b = kQ02Q1 - b; minusbSig = false; } // calculate sqrt uint256 squareRoot = DecimalMath.mul((DecimalMath.ONE - k) * 4, DecimalMath.mul(k, Q0) * Q0); // 4(1-k)kQ0^2 squareRoot = (b * b + squareRoot).sqrt(); // sqrt(b*b+4(1-k)kQ0*Q0) // final res uint256 denominator = (DecimalMath.ONE - k) * 2; // 2(1-k) uint256 numerator; if (minusbSig) { numerator = b + squareRoot; } else { numerator = squareRoot - b; } if (deltaBSig) { return DecimalMath.divFloor(numerator, denominator); } else { return DecimalMath.divCeil(numerator, denominator); } } } /* Start from the integration function i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2) Assume Q2=Q0, Given Q1 and deltaB, solve Q0 let fairAmount = i*deltaB */ function _SolveQuadraticFunctionForTarget(uint256 V1, uint256 k, uint256 fairAmount) internal pure returns (uint256 V0) { unchecked { // V0 = V1+V1*(sqrt-1)/2k uint256 sqrt = DecimalMath.divCeil(DecimalMath.mul(k, fairAmount) * 4, V1); sqrt = ((sqrt + DecimalMath.ONE) * DecimalMath.ONE).sqrt(); uint256 premium = DecimalMath.divCeil(sqrt - DecimalMath.ONE, k * 2); // V0 is greater than or equal to V1 according to the solution return DecimalMath.mul(V1, DecimalMath.ONE + premium); } } } abstract contract DodoSellHelper { using Math for uint256; enum RStatus { ONE, ABOVE_ONE, BELOW_ONE } struct DodoState { uint256 oraclePrice; uint256 K; uint256 B; uint256 Q; uint256 baseTarget; uint256 quoteTarget; RStatus rStatus; } function dodoQuerySellQuoteToken(IDodoV1 dodo, uint256 amount) internal view returns (uint256) { DodoState memory state; (state.baseTarget, state.quoteTarget) = dodo.getExpectedTarget(); state.rStatus = RStatus(dodo._R_STATUS_()); state.oraclePrice = dodo.getOraclePrice(); state.Q = dodo._QUOTE_BALANCE_(); state.B = dodo._BASE_BALANCE_(); state.K = dodo._K_(); unchecked { uint256 boughtAmount; // Determine the status (RStatus) and calculate the amount based on the // state if (state.rStatus == RStatus.ONE) { boughtAmount = _ROneSellQuoteToken(amount, state); } else if (state.rStatus == RStatus.ABOVE_ONE) { boughtAmount = _RAboveSellQuoteToken(amount, state); } else { uint256 backOneBase = state.B - state.baseTarget; uint256 backOneQuote = state.quoteTarget - state.Q; if (amount <= backOneQuote) { boughtAmount = _RBelowSellQuoteToken(amount, state); } else { boughtAmount = backOneBase + _ROneSellQuoteToken(amount - backOneQuote, state); } } // Calculate fees return DecimalMath.divFloor(boughtAmount, DecimalMath.ONE + dodo._MT_FEE_RATE_() + dodo._LP_FEE_RATE_()); } } function _ROneSellQuoteToken(uint256 amount, DodoState memory state) private pure returns (uint256 receiveBaseToken) { unchecked { uint256 i = DecimalMath.divFloor(DecimalMath.ONE, state.oraclePrice); uint256 B2 = DodoMath._SolveQuadraticFunctionForTrade( state.baseTarget, state.baseTarget, DecimalMath.mul(i, amount), false, state.K ); return state.baseTarget - B2; } } function _RAboveSellQuoteToken(uint256 amount, DodoState memory state) private pure returns (uint256 receieBaseToken) { unchecked { uint256 i = DecimalMath.divFloor(DecimalMath.ONE, state.oraclePrice); uint256 B2 = DodoMath._SolveQuadraticFunctionForTrade( state.baseTarget, state.B, DecimalMath.mul(i, amount), false, state.K ); return state.B - B2; } } function _RBelowSellQuoteToken(uint256 amount, DodoState memory state) private pure returns (uint256 receiveBaseToken) { unchecked { uint256 Q1 = state.Q + amount; uint256 i = DecimalMath.divFloor(DecimalMath.ONE, state.oraclePrice); return DodoMath._GeneralIntegrate(state.quoteTarget, Q1, state.Q, i, state.K); } } } abstract contract DodoV1 is SettlerAbstract, DodoSellHelper { using FullMath for uint256; using SafeTransferLib for IERC20; function sellToDodoV1(IERC20 sellToken, uint256 bps, IDodoV1 dodo, bool quoteForBase, uint256 minBuyAmount) internal { uint256 sellAmount = sellToken.balanceOf(address(this)).mulDiv(bps, 10_000); sellToken.safeApproveIfBelow(address(dodo), sellAmount); if (quoteForBase) { uint256 buyAmount = dodoQuerySellQuoteToken(dodo, sellAmount); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(sellToken, minBuyAmount, buyAmount); } dodo.buyBaseToken(buyAmount, sellAmount, new bytes(0)); } else { dodo.sellBaseToken(sellAmount, minBuyAmount, new bytes(0)); } } } // src/core/DodoV2.sol interface IDodoV2 { function sellBase(address to) external returns (uint256 receiveQuoteAmount); function sellQuote(address to) external returns (uint256 receiveBaseAmount); function _BASE_TOKEN_() external view returns (IERC20); function _QUOTE_TOKEN_() external view returns (IERC20); } abstract contract DodoV2 is SettlerAbstract { using FullMath for uint256; using SafeTransferLib for IERC20; function sellToDodoV2( address recipient, IERC20 sellToken, uint256 bps, IDodoV2 dodo, bool quoteForBase, uint256 minBuyAmount ) internal returns (uint256 buyAmount) { if (bps != 0) { uint256 sellAmount = sellToken.balanceOf(address(this)).mulDiv(bps, 10_000); sellToken.safeTransfer(address(dodo), sellAmount); } if (quoteForBase) { buyAmount = dodo.sellQuote(recipient); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(dodo._BASE_TOKEN_(), minBuyAmount, buyAmount); } } else { buyAmount = dodo.sellBase(recipient); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(dodo._QUOTE_TOKEN_(), minBuyAmount, buyAmount); } } } } // src/core/MaverickV2.sol // Maverick AMM V2 is not open-source. The source code was disclosed to the // developers of 0x Settler confidentially and recompiled privately. The // deployed bytecode inithash matches the privately recompiled inithash. bytes32 constant maverickV2InitHash = 0xbb7b783eb4b8ca46925c5384a6b9919df57cb83da8f76e37291f58d0dd5c439a; // https://docs.mav.xyz/technical-reference/contract-addresses/v2-contract-addresses // For chains: mainnet, base, bnb, arbitrum, scroll, sepolia address constant maverickV2Factory = 0x0A7e848Aca42d879EF06507Fca0E7b33A0a63c1e; interface IMaverickV2Pool { /** * @notice Parameters for swap. * @param amount Amount of the token that is either the input if exactOutput is false * or the output if exactOutput is true. * @param tokenAIn Boolean indicating whether tokenA is the input. * @param exactOutput Boolean indicating whether the amount specified is * the exact output amount (true). * @param tickLimit The furthest tick a swap will execute in. If no limit * is desired, value should be set to type(int32).max for a tokenAIn swap * and type(int32).min for a swap where tokenB is the input. */ struct SwapParams { uint256 amount; bool tokenAIn; bool exactOutput; int32 tickLimit; } /** * @notice Swap tokenA/tokenB assets in the pool. The swap user has two * options for funding their swap. * - The user can push the input token amount to the pool before calling * the swap function. In order to avoid having the pool call the callback, * the user should pass a zero-length `data` bytes object with the swap * call. * - The user can send the input token amount to the pool when the pool * calls the `maverickV2SwapCallback` function on the calling contract. * That callback has input parameters that specify the token address of the * input token, the input and output amounts, and the bytes data sent to * the swap function. * @dev If the users elects to do a callback-based swap, the output * assets will be sent before the callback is called, allowing the user to * execute flash swaps. However, the pool does have reentrancy protection, * so a swapper will not be able to interact with the same pool again * while they are in the callback function. * @param recipient The address to receive the output tokens. * @param params Parameters containing the details of the swap * @param data Bytes information that gets passed to the callback. */ function swap(address recipient, SwapParams calldata params, bytes calldata data) external returns (uint256 amountIn, uint256 amountOut); /** * @notice Pool tokenA. Address of tokenA is such that tokenA < tokenB. */ function tokenA() external view returns (IERC20); /** * @notice Pool tokenB. */ function tokenB() external view returns (IERC20); /** * @notice State of the pool. * @param reserveA Pool tokenA balanceOf at end of last operation * @param reserveB Pool tokenB balanceOf at end of last operation * @param lastTwaD8 Value of log time weighted average price at last block. * Value is 8-decimal scale and is in the fractional tick domain. E.g. a * value of 12.3e8 indicates the TWAP was 3/10ths of the way into the 12th * tick. * @param lastLogPriceD8 Value of log price at last block. Value is * 8-decimal scale and is in the fractional tick domain. E.g. a value of * 12.3e8 indicates the price was 3/10ths of the way into the 12th tick. * @param lastTimestamp Last block.timestamp value in seconds for latest * swap transaction. * @param activeTick Current tick position that contains the active bins. * @param isLocked Pool isLocked, E.g., locked or unlocked; isLocked values * defined in Pool.sol. * @param binCounter Index of the last bin created. * @param protocolFeeRatioD3 Ratio of the swap fee that is kept for the * protocol. */ struct State { uint128 reserveA; uint128 reserveB; int64 lastTwaD8; int64 lastLogPriceD8; uint40 lastTimestamp; int32 activeTick; bool isLocked; uint32 binCounter; uint8 protocolFeeRatioD3; } /** * @notice External function to get the state of the pool. */ function getState() external view returns (State memory); } interface IMaverickV2SwapCallback { function maverickV2SwapCallback(IERC20 tokenIn, uint256 amountIn, uint256 amountOut, bytes calldata data) external; } abstract contract MaverickV2 is SettlerAbstract { using UnsafeMath for uint256; using SafeTransferLib for IERC20; function _encodeSwapCallback(ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig) internal view returns (bytes memory result) { bool isForwarded = _isForwarded(); assembly ("memory-safe") { result := mload(0x40) mcopy(add(0x20, result), mload(permit), 0x40) mcopy(add(0x60, result), add(0x20, permit), 0x40) mstore8(add(0xa0, result), isForwarded) let sigLength := mload(sig) mcopy(add(0xa1, result), add(0x20, sig), sigLength) mstore(result, add(0x81, sigLength)) mstore(0x40, add(sigLength, add(0xa1, result))) } } function sellToMaverickV2VIP( address recipient, bytes32 salt, bool tokenAIn, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) internal returns (uint256 buyAmount) { bytes memory swapCallbackData = _encodeSwapCallback(permit, sig); address pool = AddressDerivation.deriveDeterministicContract(maverickV2Factory, salt, maverickV2InitHash); (, buyAmount) = abi.decode( _setOperatorAndCall( pool, abi.encodeCall( IMaverickV2Pool.swap, ( recipient, IMaverickV2Pool.SwapParams({ amount: permit.permitted.amount, tokenAIn: tokenAIn, exactOutput: false, // TODO: actually set a tick limit so that we can partial fill tickLimit: tokenAIn ? type(int32).max : type(int32).min }), swapCallbackData ) ), uint32(IMaverickV2SwapCallback.maverickV2SwapCallback.selector), _maverickV2Callback ), (uint256, uint256) ); if (buyAmount < minBuyAmount) { IERC20 buyToken = tokenAIn ? IMaverickV2Pool(pool).tokenB() : IMaverickV2Pool(pool).tokenA(); revert TooMuchSlippage(buyToken, minBuyAmount, buyAmount); } } function sellToMaverickV2( address recipient, IERC20 sellToken, uint256 bps, IMaverickV2Pool pool, bool tokenAIn, uint256 minBuyAmount ) internal returns (uint256 buyAmount) { uint256 sellAmount; if (bps != 0) { unchecked { // We don't care about phantom overflow here because reserves // are limited to 128 bits. Any token balance that would // overflow here would also break MaverickV2. sellAmount = (sellToken.balanceOf(address(this)) * bps).unsafeDiv(10_000); } } if (sellAmount == 0) { sellAmount = sellToken.balanceOf(address(pool)); IMaverickV2Pool.State memory poolState = pool.getState(); unchecked { sellAmount -= tokenAIn ? poolState.reserveA : poolState.reserveB; } } else { sellToken.safeTransfer(address(pool), sellAmount); } (, buyAmount) = pool.swap( recipient, IMaverickV2Pool.SwapParams({ amount: sellAmount, tokenAIn: tokenAIn, exactOutput: false, // TODO: actually set a tick limit so that we can partial fill tickLimit: tokenAIn ? type(int32).max : type(int32).min }), new bytes(0) ); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(tokenAIn ? pool.tokenB() : pool.tokenA(), minBuyAmount, buyAmount); } } function _maverickV2Callback(bytes calldata data) private returns (bytes memory) { require(data.length >= 0xa0); IERC20 tokenIn; uint256 amountIn; assembly ("memory-safe") { // we don't bother checking for dirty bits because we trust the // initcode (by its hash) to produce well-behaved bytecode that // produces strict ABI-encoded calldata tokenIn := calldataload(data.offset) amountIn := calldataload(add(0x20, data.offset)) // likewise, we don't bother to perform the indirection to find the // nested data. we just index directly to it because we know that // the pool follows strict ABI encoding data.length := calldataload(add(0x80, data.offset)) data.offset := add(0xa0, data.offset) } maverickV2SwapCallback( tokenIn, amountIn, // forgefmt: disable-next-line 0 /* we didn't bother loading `amountOut` because we don't use it */, data ); return new bytes(0); } // forgefmt: disable-next-line function maverickV2SwapCallback(IERC20 tokenIn, uint256 amountIn, uint256 /* amountOut */, bytes calldata data) private { ISignatureTransfer.PermitTransferFrom calldata permit; bool isForwarded; assembly ("memory-safe") { permit := data.offset isForwarded := and(0x01, calldataload(add(0x61, data.offset))) data.offset := add(0x81, data.offset) data.length := sub(data.length, 0x81) } assert(tokenIn == IERC20(permit.permitted.token)); _transferFrom( permit, ISignatureTransfer.SignatureTransferDetails({to: msg.sender, requestedAmount: amountIn}), data, isForwarded ); } } // src/core/Permit2Payment.sol library TransientStorage { // bytes32(uint256(keccak256("operator slot")) - 1) bytes32 private constant _OPERATOR_SLOT = 0x009355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe9; // bytes32(uint256(keccak256("witness slot")) - 1) bytes32 private constant _WITNESS_SLOT = 0x1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa; // bytes32(uint256(keccak256("payer slot")) - 1) bytes32 private constant _PAYER_SLOT = 0x46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde893; // We assume (and our CI enforces) that internal function pointers cannot be // greater than 2 bytes. On chains not supporting the ViaIR pipeline, not // supporting EOF, and where the Spurious Dragon size limit is not enforced, // it might be possible to violate this assumption. However, our // `foundry.toml` enforces the use of the IR pipeline, so the point is moot. // // `operator` must not be `address(0)`. This is not checked. // `callback` must not be zero. This is checked in `_invokeCallback`. function setOperatorAndCallback( address operator, uint32 selector, function (bytes calldata) internal returns (bytes memory) callback ) internal { address currentSigner; assembly ("memory-safe") { currentSigner := tload(_PAYER_SLOT) } if (operator == currentSigner) { revert ConfusedDeputy(); } uint256 callbackInt; assembly ("memory-safe") { callbackInt := tload(_OPERATOR_SLOT) } if (callbackInt != 0) { // It should be impossible to reach this error because the first thing the fallback does // is clear the operator. It's also not possible to reenter the entrypoint function // because `_PAYER_SLOT` is an implicit reentrancy guard. revert ReentrantCallback(callbackInt); } assembly ("memory-safe") { tstore( _OPERATOR_SLOT, or( shl(0xe0, selector), or(shl(0xa0, and(0xffff, callback)), and(0xffffffffffffffffffffffffffffffffffffffff, operator)) ) ) } } function checkSpentOperatorAndCallback() internal view { uint256 callbackInt; assembly ("memory-safe") { callbackInt := tload(_OPERATOR_SLOT) } if (callbackInt != 0) { revert CallbackNotSpent(callbackInt); } } function getAndClearOperatorAndCallback() internal returns (bytes4 selector, function (bytes calldata) internal returns (bytes memory) callback, address operator) { assembly ("memory-safe") { selector := tload(_OPERATOR_SLOT) callback := and(0xffff, shr(0xa0, selector)) operator := selector tstore(_OPERATOR_SLOT, 0x00) } } // `newWitness` must not be `bytes32(0)`. This is not checked. function setWitness(bytes32 newWitness) internal { bytes32 currentWitness; assembly ("memory-safe") { currentWitness := tload(_WITNESS_SLOT) } if (currentWitness != bytes32(0)) { // It should be impossible to reach this error because the first thing a metatransaction // does on entry is to spend the `witness` (either directly or via a callback) revert ReentrantMetatransaction(currentWitness); } assembly ("memory-safe") { tstore(_WITNESS_SLOT, newWitness) } } function checkSpentWitness() internal view { bytes32 currentWitness; assembly ("memory-safe") { currentWitness := tload(_WITNESS_SLOT) } if (currentWitness != bytes32(0)) { revert WitnessNotSpent(currentWitness); } } function getAndClearWitness() internal returns (bytes32 witness) { assembly ("memory-safe") { witness := tload(_WITNESS_SLOT) tstore(_WITNESS_SLOT, 0x00) } } function setPayer(address payer) internal { if (payer == address(0)) { revert ConfusedDeputy(); } address oldPayer; assembly ("memory-safe") { oldPayer := tload(_PAYER_SLOT) } if (oldPayer != address(0)) { revert ReentrantPayer(oldPayer); } assembly ("memory-safe") { tstore(_PAYER_SLOT, and(0xffffffffffffffffffffffffffffffffffffffff, payer)) } } function getPayer() internal view returns (address payer) { assembly ("memory-safe") { payer := tload(_PAYER_SLOT) } } function clearPayer(address expectedOldPayer) internal { address oldPayer; assembly ("memory-safe") { oldPayer := tload(_PAYER_SLOT) } if (oldPayer != expectedOldPayer) { revert PayerSpent(); } assembly ("memory-safe") { tstore(_PAYER_SLOT, 0x00) } } } abstract contract Permit2PaymentBase is SettlerAbstract { using Revert for bool; /// @dev Permit2 address ISignatureTransfer internal constant _PERMIT2 = ISignatureTransfer(0x000000000022D473030F116dDEE9F6B43aC78BA3); function _isRestrictedTarget(address target) internal pure virtual override returns (bool) { return target == address(_PERMIT2); } function _msgSender() internal view virtual override returns (address) { return TransientStorage.getPayer(); } /// @dev You must ensure that `target` is derived by hashing trusted initcode or another /// equivalent mechanism that guarantees "reasonable"ness. `target` must not be /// user-supplied or attacker-controlled. This is required for security and is not checked /// here. For example, it must not do something weird like modifying the spender (possibly /// setting it to itself). If the callback is expected to relay a /// `ISignatureTransfer.PermitTransferFrom` struct, then the computation of `target` using /// the trusted initcode (or equivalent) must ensure that that calldata is relayed /// unmodified. The library function `AddressDerivation.deriveDeterministicContract` is /// recommended. function _setOperatorAndCall( address payable target, uint256 value, bytes memory data, uint32 selector, function (bytes calldata) internal returns (bytes memory) callback ) internal returns (bytes memory) { TransientStorage.setOperatorAndCallback(target, selector, callback); (bool success, bytes memory returndata) = target.call{value: value}(data); success.maybeRevert(returndata); TransientStorage.checkSpentOperatorAndCallback(); return returndata; } function _setOperatorAndCall( address target, bytes memory data, uint32 selector, function (bytes calldata) internal returns (bytes memory) callback ) internal override returns (bytes memory) { return _setOperatorAndCall(payable(target), 0, data, selector, callback); } function _invokeCallback(bytes calldata data) internal returns (bytes memory) { // Retrieve callback and perform call with untrusted calldata (bytes4 selector, function (bytes calldata) internal returns (bytes memory) callback, address operator) = TransientStorage.getAndClearOperatorAndCallback(); require(bytes4(data) == selector); require(msg.sender == operator); return callback(data[4:]); } } abstract contract Permit2Payment is Permit2PaymentBase { fallback(bytes calldata data) external virtual returns (bytes memory) { return _invokeCallback(data); } function _permitToTransferDetails(ISignatureTransfer.PermitTransferFrom memory permit, address recipient) internal pure override returns (ISignatureTransfer.SignatureTransferDetails memory transferDetails, address token, uint256 amount) { transferDetails.to = recipient; transferDetails.requestedAmount = amount = permit.permitted.amount; token = permit.permitted.token; } // This function is provided *EXCLUSIVELY* for use here and in RfqOrderSettlement. Any other use // of this function is forbidden. You must use the version that does *NOT* take a `from` or // `witness` argument. function _transferFromIKnowWhatImDoing( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, address from, bytes32 witness, string memory witnessTypeString, bytes memory sig, bool isForwarded ) internal override { if (isForwarded) revert ForwarderNotAllowed(); _PERMIT2.permitWitnessTransferFrom(permit, transferDetails, from, witness, witnessTypeString, sig); } // See comment in above overload; don't use this function function _transferFromIKnowWhatImDoing( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, address from, bytes32 witness, string memory witnessTypeString, bytes memory sig ) internal override { _transferFromIKnowWhatImDoing(permit, transferDetails, from, witness, witnessTypeString, sig, _isForwarded()); } function _transferFrom( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, bytes memory sig ) internal override { _transferFrom(permit, transferDetails, sig, _isForwarded()); } } abstract contract Permit2PaymentTakerSubmitted is AllowanceHolderContext, Permit2Payment { constructor() { assert(!_hasMetaTxn()); } function _isRestrictedTarget(address target) internal pure virtual override returns (bool) { return target == address(_ALLOWANCE_HOLDER) || super._isRestrictedTarget(target); } function _operator() internal view override returns (address) { return AllowanceHolderContext._msgSender(); } function _msgSender() internal view virtual override(Permit2PaymentBase, AllowanceHolderContext) returns (address) { return Permit2PaymentBase._msgSender(); } function _transferFrom( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, bytes memory sig, bool isForwarded ) internal override { if (isForwarded) { if (sig.length != 0) revert InvalidSignatureLen(); if (permit.nonce != 0) Panic.panic(Panic.ARITHMETIC_OVERFLOW); if (block.timestamp > permit.deadline) revert SignatureExpired(permit.deadline); // we don't check `requestedAmount` because it's checked by AllowanceHolder itself _allowanceHolderTransferFrom( permit.permitted.token, _msgSender(), transferDetails.to, transferDetails.requestedAmount ); } else { _PERMIT2.permitTransferFrom(permit, transferDetails, _msgSender(), sig); } } function _allowanceHolderTransferFrom(address token, address owner, address recipient, uint256 amount) internal override { // `owner` is always `_msgSender()` _ALLOWANCE_HOLDER.transferFrom(token, owner, recipient, amount); } modifier takerSubmitted() override { address msgSender = _operator(); TransientStorage.setPayer(msgSender); _; TransientStorage.clearPayer(msgSender); } modifier metaTx(address, bytes32) override { revert(); _; } } abstract contract Permit2PaymentMetaTxn is Context, Permit2Payment { constructor() { assert(_hasMetaTxn()); } function _operator() internal view override returns (address) { return Context._msgSender(); } function _msgSender() internal view virtual override(Permit2PaymentBase, Context) returns (address) { return Permit2PaymentBase._msgSender(); } // `string.concat` isn't recognized by solc as compile-time constant, but `abi.encodePacked` is // This is defined here as `private` and not in `SettlerAbstract` as `internal` because no other // contract/file should reference it. The *ONLY* approved way to make a transfer using this // witness string is by setting the witness with modifier `metaTx` string private constant _SLIPPAGE_AND_ACTIONS_WITNESS = string( abi.encodePacked("SlippageAndActions slippageAndActions)", SLIPPAGE_AND_ACTIONS_TYPE, TOKEN_PERMISSIONS_TYPE) ); function _transferFrom( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails memory transferDetails, bytes memory sig, bool isForwarded // must be false ) internal override { bytes32 witness = TransientStorage.getAndClearWitness(); if (witness == bytes32(0)) { revert ConfusedDeputy(); } _transferFromIKnowWhatImDoing( permit, transferDetails, _msgSender(), witness, _SLIPPAGE_AND_ACTIONS_WITNESS, sig, isForwarded ); } function _allowanceHolderTransferFrom(address, address, address, uint256) internal pure override { revert ConfusedDeputy(); } modifier takerSubmitted() override { revert(); _; } modifier metaTx(address msgSender, bytes32 witness) override { if (_isForwarded()) { revert ForwarderNotAllowed(); } TransientStorage.setWitness(witness); TransientStorage.setPayer(msgSender); _; TransientStorage.clearPayer(msgSender); // It should not be possible for this check to revert because the very first thing that a // metatransaction does is spend the witness. TransientStorage.checkSpentWitness(); } } // src/core/UniswapV3Fork.sol interface IUniswapV3Pool { /// @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); } abstract contract UniswapV3Fork is SettlerAbstract { using UnsafeMath for uint256; using SafeTransferLib for IERC20; /// @dev Minimum size of an encoded swap path: /// sizeof(address(inputToken) | uint8(forkId) | uint24(poolId) | address(outputToken)) uint256 private constant SINGLE_HOP_PATH_SIZE = 0x2c; /// @dev How many bytes to skip ahead in an encoded path to start at the next hop: /// sizeof(address(inputToken) | uint8(forkId) | uint24(poolId)) uint256 private constant PATH_SKIP_HOP_SIZE = 0x18; /// @dev The size of the swap callback prefix data before the Permit2 data. uint256 private constant SWAP_CALLBACK_PREFIX_DATA_SIZE = 0x28; /// @dev The offset from the pointer to the length of the swap callback prefix data to the start of the Permit2 data. uint256 private constant SWAP_CALLBACK_PERMIT2DATA_OFFSET = 0x48; uint256 private constant PERMIT_DATA_SIZE = 0x60; uint256 private constant ISFORWARDED_DATA_SIZE = 0x01; /// @dev Minimum tick price sqrt ratio. uint160 private constant MIN_PRICE_SQRT_RATIO = 4295128739; /// @dev Minimum tick price sqrt ratio. uint160 private constant MAX_PRICE_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @dev Mask of lower 20 bytes. uint256 private constant ADDRESS_MASK = 0x00ffffffffffffffffffffffffffffffffffffffff; /// @dev Mask of lower 3 bytes. uint256 private constant UINT24_MASK = 0xffffff; /// @dev Sell a token for another token directly against uniswap v3. /// @param encodedPath Uniswap-encoded path. /// @param bps proportion of current balance of the first token in the path to sell. /// @param minBuyAmount Minimum amount of the last token in the path to buy. /// @param recipient The recipient of the bought tokens. /// @return buyAmount Amount of the last token in the path bought. function sellToUniswapV3(address recipient, uint256 bps, bytes memory encodedPath, uint256 minBuyAmount) internal returns (uint256 buyAmount) { buyAmount = _uniV3ForkSwap( recipient, encodedPath, // We don't care about phantom overflow here because reserves are // limited to 128 bits. Any token balance that would overflow here // would also break UniV3. (IERC20(address(bytes20(encodedPath))).balanceOf(address(this)) * bps).unsafeDiv(10_000), minBuyAmount, address(this), // payer new bytes(SWAP_CALLBACK_PREFIX_DATA_SIZE) ); } /// @dev Sell a token for another token directly against uniswap v3. Payment is using a Permit2 signature (or AllowanceHolder). /// @param encodedPath Uniswap-encoded path. /// @param minBuyAmount Minimum amount of the last token in the path to buy. /// @param recipient The recipient of the bought tokens. /// @param permit The PermitTransferFrom allowing this contract to spend the taker's tokens /// @param sig The taker's signature for Permit2 /// @return buyAmount Amount of the last token in the path bought. function sellToUniswapV3VIP( address recipient, bytes memory encodedPath, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) internal returns (uint256 buyAmount) { bytes memory swapCallbackData = new bytes(SWAP_CALLBACK_PREFIX_DATA_SIZE + PERMIT_DATA_SIZE + ISFORWARDED_DATA_SIZE + sig.length); _encodePermit2Data(swapCallbackData, permit, sig, _isForwarded()); buyAmount = _uniV3ForkSwap( recipient, encodedPath, permit.permitted.amount, minBuyAmount, address(0), // payer swapCallbackData ); } // Executes successive swaps along an encoded uniswap path. function _uniV3ForkSwap( address recipient, bytes memory encodedPath, uint256 sellAmount, uint256 minBuyAmount, address payer, bytes memory swapCallbackData ) internal returns (uint256 buyAmount) { if (sellAmount > uint256(type(int256).max)) { Panic.panic(Panic.ARITHMETIC_OVERFLOW); } IERC20 outputToken; while (true) { bool isPathMultiHop = _isPathMultiHop(encodedPath); bool zeroForOne; IUniswapV3Pool pool; uint32 callbackSelector; { (IERC20 token0, uint8 forkId, uint24 poolId, IERC20 token1) = _decodeFirstPoolInfoFromPath(encodedPath); IERC20 sellToken = token0; outputToken = token1; if (!(zeroForOne = token0 < token1)) { (token0, token1) = (token1, token0); } address factory; bytes32 initHash; (factory, initHash, callbackSelector) = _uniV3ForkInfo(forkId); pool = _toPool(factory, initHash, token0, token1, poolId); _updateSwapCallbackData(swapCallbackData, sellToken, payer); } int256 amount0; int256 amount1; if (isPathMultiHop) { uint256 freeMemPtr; assembly ("memory-safe") { freeMemPtr := mload(0x40) } (amount0, amount1) = abi.decode( _setOperatorAndCall( address(pool), abi.encodeCall( pool.swap, ( // Intermediate tokens go to this contract. address(this), zeroForOne, int256(sellAmount), zeroForOne ? MIN_PRICE_SQRT_RATIO + 1 : MAX_PRICE_SQRT_RATIO - 1, swapCallbackData ) ), callbackSelector, _uniV3ForkCallback ), (int256, int256) ); assembly ("memory-safe") { mstore(0x40, freeMemPtr) } } else { (amount0, amount1) = abi.decode( _setOperatorAndCall( address(pool), abi.encodeCall( pool.swap, ( recipient, zeroForOne, int256(sellAmount), zeroForOne ? MIN_PRICE_SQRT_RATIO + 1 : MAX_PRICE_SQRT_RATIO - 1, swapCallbackData ) ), callbackSelector, _uniV3ForkCallback ), (int256, int256) ); } { int256 _buyAmount = -(zeroForOne ? amount1 : amount0); if (_buyAmount < 0) { Panic.panic(Panic.ARITHMETIC_OVERFLOW); } buyAmount = uint256(_buyAmount); } if (!isPathMultiHop) { // Done. break; } // Continue with next hop. payer = address(this); // Subsequent hops are paid for by us. sellAmount = buyAmount; // Skip to next hop along path. encodedPath = _shiftHopFromPathInPlace(encodedPath); assembly ("memory-safe") { mstore(swapCallbackData, SWAP_CALLBACK_PREFIX_DATA_SIZE) } } if (buyAmount < minBuyAmount) { revert TooMuchSlippage(outputToken, minBuyAmount, buyAmount); } } // Return whether or not an encoded uniswap path contains more than one hop. function _isPathMultiHop(bytes memory encodedPath) private pure returns (bool) { return encodedPath.length > SINGLE_HOP_PATH_SIZE; } function _decodeFirstPoolInfoFromPath(bytes memory encodedPath) private pure returns (IERC20 inputToken, uint8 forkId, uint24 poolId, IERC20 outputToken) { if (encodedPath.length < SINGLE_HOP_PATH_SIZE) { Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS); } assembly ("memory-safe") { // Solidity cleans dirty bits automatically inputToken := mload(add(encodedPath, 0x14)) forkId := mload(add(encodedPath, 0x15)) poolId := mload(add(encodedPath, 0x18)) outputToken := mload(add(encodedPath, SINGLE_HOP_PATH_SIZE)) } } // Skip past the first hop of an encoded uniswap path in-place. function _shiftHopFromPathInPlace(bytes memory encodedPath) private pure returns (bytes memory) { if (encodedPath.length < PATH_SKIP_HOP_SIZE) { Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS); } assembly ("memory-safe") { let length := sub(mload(encodedPath), PATH_SKIP_HOP_SIZE) encodedPath := add(encodedPath, PATH_SKIP_HOP_SIZE) mstore(encodedPath, length) } return encodedPath; } function _encodePermit2Data( bytes memory swapCallbackData, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, bool isForwarded ) private pure { assembly ("memory-safe") { mstore(add(SWAP_CALLBACK_PERMIT2DATA_OFFSET, swapCallbackData), mload(add(0x20, mload(permit)))) mcopy(add(add(SWAP_CALLBACK_PERMIT2DATA_OFFSET, 0x20), swapCallbackData), add(0x20, permit), 0x40) mstore8(add(add(SWAP_CALLBACK_PERMIT2DATA_OFFSET, PERMIT_DATA_SIZE), swapCallbackData), isForwarded) mcopy( add( add(add(SWAP_CALLBACK_PERMIT2DATA_OFFSET, PERMIT_DATA_SIZE), ISFORWARDED_DATA_SIZE), swapCallbackData ), add(0x20, sig), mload(sig) ) } } // Update `swapCallbackData` in place with new values. function _updateSwapCallbackData(bytes memory swapCallbackData, IERC20 sellToken, address payer) private pure { assembly ("memory-safe") { let length := mload(swapCallbackData) mstore(add(0x28, swapCallbackData), sellToken) mstore(add(0x14, swapCallbackData), payer) mstore(swapCallbackData, length) } } // Compute the pool address given two tokens and a poolId. function _toPool(address factory, bytes32 initHash, IERC20 token0, IERC20 token1, uint24 poolId) private pure returns (IUniswapV3Pool) { // address(keccak256(abi.encodePacked( // hex"ff", // factory, // keccak256(abi.encode(token0, token1, poolId)), // initHash // ))) bytes32 salt; assembly ("memory-safe") { token0 := and(ADDRESS_MASK, token0) token1 := and(ADDRESS_MASK, token1) poolId := and(UINT24_MASK, poolId) let ptr := mload(0x40) mstore(0x00, token0) mstore(0x20, token1) mstore(0x40, poolId) salt := keccak256(0x00, sub(0x60, shl(0x05, iszero(poolId)))) mstore(0x40, ptr) } return IUniswapV3Pool(AddressDerivation.deriveDeterministicContract(factory, salt, initHash)); } function _uniV3ForkInfo(uint8 forkId) internal view virtual returns (address, bytes32, uint32); function _uniV3ForkCallback(bytes calldata data) private returns (bytes memory) { require(data.length >= 0x80); int256 amount0Delta; int256 amount1Delta; assembly ("memory-safe") { amount0Delta := calldataload(data.offset) amount1Delta := calldataload(add(0x20, data.offset)) data.offset := add(data.offset, calldataload(add(0x40, data.offset))) data.length := calldataload(data.offset) data.offset := add(0x20, data.offset) } uniswapV3SwapCallback(amount0Delta, amount1Delta, data); return new bytes(0); } /// @dev The UniswapV3 pool swap callback which pays the funds requested /// by the caller/pool to the pool. Can only be called by a valid /// UniswapV3 pool. /// @param amount0Delta Token0 amount owed. /// @param amount1Delta Token1 amount owed. /// @param data Arbitrary data forwarded from swap() caller. A packed encoding of: payer, sellToken, (optionally: permit[0x20:], isForwarded, sig) function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) private { address payer = address(uint160(bytes20(data))); data = data[0x14:]; uint256 sellAmount = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta); _pay(payer, sellAmount, data); } function _pay(address payer, uint256 amount, bytes calldata permit2Data) private { if (payer == address(this)) { IERC20(address(uint160(bytes20(permit2Data)))).safeTransfer(msg.sender, amount); } else { assert(payer == address(0)); ISignatureTransfer.PermitTransferFrom calldata permit; bool isForwarded; bytes calldata sig; assembly ("memory-safe") { // this is super dirty, but it works because although `permit` is aliasing in the // middle of `payer`, because `payer` is all zeroes, it's treated as padding for the // first word of `permit`, which is the sell token permit := sub(permit2Data.offset, 0x0c) isForwarded := and(0x01, calldataload(add(0x55, permit2Data.offset))) sig.offset := add(0x75, permit2Data.offset) sig.length := sub(permit2Data.length, 0x75) } _transferFrom( permit, ISignatureTransfer.SignatureTransferDetails({to: msg.sender, requestedAmount: amount}), sig, isForwarded ); } } } // src/core/Basic.sol abstract contract Basic is SettlerAbstract { using SafeTransferLib for IERC20; using FullMath for uint256; using Revert for bool; IERC20 internal constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); /// @dev Sell to a pool with a generic approval, transferFrom interaction. /// offset in the calldata is used to update the sellAmount given a proportion of the sellToken balance function basicSellToPool(IERC20 sellToken, uint256 bps, address pool, uint256 offset, bytes memory data) internal { if (_isRestrictedTarget(pool)) { revert ConfusedDeputy(); } bool success; bytes memory returnData; uint256 value; if (sellToken == IERC20(ETH_ADDRESS)) { value = address(this).balance.mulDiv(bps, 10_000); if (data.length == 0) { if (offset != 0) revert InvalidOffset(); (success, returnData) = payable(pool).call{value: value}(""); success.maybeRevert(returnData); return; } else { if ((offset += 32) > data.length) { Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS); } assembly ("memory-safe") { mstore(add(data, offset), value) } } } else if (address(sellToken) == address(0)) { // TODO: check for zero `bps` if (offset != 0) revert InvalidOffset(); } else { uint256 amount = sellToken.balanceOf(address(this)).mulDiv(bps, 10_000); if ((offset += 32) > data.length) { Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS); } assembly ("memory-safe") { mstore(add(data, offset), amount) } if (address(sellToken) != pool) { sellToken.safeApproveIfBelow(pool, amount); } } (success, returnData) = payable(pool).call{value: value}(data); success.maybeRevert(returnData); // forbid sending data to EOAs if (returnData.length == 0 && pool.code.length == 0) revert InvalidTarget(); } } // src/SettlerBase.sol /// @dev This library's ABIDeocding is more lax than the Solidity ABIDecoder. This library omits index bounds/overflow /// checking when accessing calldata arrays for gas efficiency. It also omits checks against `calldatasize()`. This /// means that it is possible that `args` will run off the end of calldata and be implicitly padded with zeroes. That we /// don't check for overflow means that offsets can be negative. This can also result in `args` that alias other parts /// of calldata, or even the `actions` array itself. library CalldataDecoder { function decodeCall(bytes[] calldata data, uint256 i) internal pure returns (bytes4 selector, bytes calldata args) { assembly ("memory-safe") { // initially, we set `args.offset` to the pointer to the length. this is 32 bytes before the actual start of data args.offset := add( data.offset, // We allow the indirection/offset to `calls[i]` to be negative calldataload( add(shl(5, i), data.offset) // can't overflow; we assume `i` is in-bounds ) ) // now we load `args.length` and set `args.offset` to the start of data args.length := calldataload(args.offset) args.offset := add(args.offset, 0x20) // slice off the first 4 bytes of `args` as the selector selector := calldataload(args.offset) // solidity cleans dirty bits automatically args.length := sub(args.length, 0x04) args.offset := add(args.offset, 0x04) } } } abstract contract SettlerBase is Basic, RfqOrderSettlement, UniswapV3Fork, UniswapV2, Velodrome { using SafeTransferLib for IERC20; using SafeTransferLib for address payable; receive() external payable {} event GitCommit(bytes20 indexed); constructor(bytes20 gitCommit, uint256 tokenId) { if (block.chainid != 31337) { emit GitCommit(gitCommit); assert(IERC721Owner(0x00000000000004533Fe15556B1E086BB1A72cEae).ownerOf(tokenId) == address(this)); } else { assert(gitCommit == bytes20(0)); } } struct AllowedSlippage { address recipient; IERC20 buyToken; uint256 minAmountOut; } function _checkSlippageAndTransfer(AllowedSlippage calldata slippage) internal { // This final slippage check effectively prohibits custody optimization on the // final hop of every swap. This is gas-inefficient. This is on purpose. Because // ISettlerActions.BASIC could interact with an intents-based settlement // mechanism, we must ensure that the user's want token increase is coming // directly from us instead of from some other form of exchange of value. (address recipient, IERC20 buyToken, uint256 minAmountOut) = (slippage.recipient, slippage.buyToken, slippage.minAmountOut); if (minAmountOut != 0 || address(buyToken) != address(0)) { if (buyToken == ETH_ADDRESS) { uint256 amountOut = address(this).balance; if (amountOut < minAmountOut) { revert TooMuchSlippage(buyToken, minAmountOut, amountOut); } payable(recipient).safeTransferETH(amountOut); } else { uint256 amountOut = buyToken.balanceOf(address(this)); if (amountOut < minAmountOut) { revert TooMuchSlippage(buyToken, minAmountOut, amountOut); } buyToken.safeTransfer(recipient, amountOut); } } } function _dispatch(uint256, bytes4 action, bytes calldata data) internal virtual override returns (bool) { if (action == ISettlerActions.TRANSFER_FROM.selector) { (address recipient, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig) = abi.decode(data, (address, ISignatureTransfer.PermitTransferFrom, bytes)); (ISignatureTransfer.SignatureTransferDetails memory transferDetails,,) = _permitToTransferDetails(permit, recipient); _transferFrom(permit, transferDetails, sig); } else if (action == ISettlerActions.RFQ.selector) { ( address recipient, ISignatureTransfer.PermitTransferFrom memory permit, address maker, bytes memory makerSig, IERC20 takerToken, uint256 maxTakerAmount ) = abi.decode(data, (address, ISignatureTransfer.PermitTransferFrom, address, bytes, IERC20, uint256)); fillRfqOrderSelfFunded(recipient, permit, maker, makerSig, takerToken, maxTakerAmount); } else if (action == ISettlerActions.UNISWAPV3.selector) { (address recipient, uint256 bps, bytes memory path, uint256 amountOutMin) = abi.decode(data, (address, uint256, bytes, uint256)); sellToUniswapV3(recipient, bps, path, amountOutMin); } else if (action == ISettlerActions.UNISWAPV2.selector) { (address recipient, address sellToken, uint256 bps, address pool, uint24 swapInfo, uint256 amountOutMin) = abi.decode(data, (address, address, uint256, address, uint24, uint256)); sellToUniswapV2(recipient, sellToken, bps, pool, swapInfo, amountOutMin); } else if (action == ISettlerActions.BASIC.selector) { (IERC20 sellToken, uint256 bps, address pool, uint256 offset, bytes memory _data) = abi.decode(data, (IERC20, uint256, address, uint256, bytes)); basicSellToPool(sellToken, bps, pool, offset, _data); } else if (action == ISettlerActions.VELODROME.selector) { (address recipient, uint256 bps, IVelodromePair pool, uint24 swapInfo, uint256 minAmountOut) = abi.decode(data, (address, uint256, IVelodromePair, uint24, uint256)); sellToVelodrome(recipient, bps, pool, swapInfo, minAmountOut); } else if (action == ISettlerActions.POSITIVE_SLIPPAGE.selector) { (address recipient, IERC20 token, uint256 expectedAmount) = abi.decode(data, (address, IERC20, uint256)); if (token == IERC20(ETH_ADDRESS)) { uint256 balance = address(this).balance; if (balance > expectedAmount) { unchecked { payable(recipient).safeTransferETH(balance - expectedAmount); } } } else { uint256 balance = token.balanceOf(address(this)); if (balance > expectedAmount) { unchecked { token.safeTransfer(recipient, balance - expectedAmount); } } } } else { return false; } return true; } } // src/Settler.sol abstract contract Settler is Permit2PaymentTakerSubmitted, SettlerBase { using UnsafeMath for uint256; using CalldataDecoder for bytes[]; // When/if you change this, you must make corresponding changes to // `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set // `constructor_args`. constructor(bytes20 gitCommit) SettlerBase(gitCommit, 2) {} function _hasMetaTxn() internal pure override returns (bool) { return false; } function _msgSender() internal view virtual // Solidity inheritance is so stupid override(Permit2PaymentTakerSubmitted, AbstractContext) returns (address) { return super._msgSender(); } function _isRestrictedTarget(address target) internal pure virtual // Solidity inheritance is so stupid override(Permit2PaymentTakerSubmitted, Permit2PaymentAbstract) returns (bool) { return super._isRestrictedTarget(target); } function _dispatchVIP(bytes4 action, bytes calldata data) internal virtual returns (bool) { if (action == ISettlerActions.RFQ_VIP.selector) { ( address recipient, ISignatureTransfer.PermitTransferFrom memory makerPermit, address maker, bytes memory makerSig, ISignatureTransfer.PermitTransferFrom memory takerPermit, bytes memory takerSig ) = abi.decode( data, ( address, ISignatureTransfer.PermitTransferFrom, address, bytes, ISignatureTransfer.PermitTransferFrom, bytes ) ); fillRfqOrderVIP(recipient, makerPermit, maker, makerSig, takerPermit, takerSig); } else if (action == ISettlerActions.UNISWAPV3_VIP.selector) { ( address recipient, bytes memory path, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 amountOutMin ) = abi.decode(data, (address, bytes, ISignatureTransfer.PermitTransferFrom, bytes, uint256)); sellToUniswapV3VIP(recipient, path, permit, sig, amountOutMin); } else { return false; } return true; } function execute(AllowedSlippage calldata slippage, bytes[] calldata actions, bytes32 /* zid & affiliate */ ) public payable takerSubmitted returns (bool) { for (uint256 i; i < actions.length; i = i.unsafeInc()) { (bytes4 action, bytes calldata data) = actions.decodeCall(i); if (!((i == 0 && _dispatchVIP(action, data)) || _dispatch(i, action, data))) { revert ActionInvalid(i, action, data); } } _checkSlippageAndTransfer(slippage); return true; } } // src/SettlerMetaTxn.sol abstract contract SettlerMetaTxn is Permit2PaymentMetaTxn, SettlerBase { using UnsafeMath for uint256; using CalldataDecoder for bytes[]; // When/if you change this, you must make corresponding changes to // `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set // `constructor_args`. constructor(bytes20 gitCommit) SettlerBase(gitCommit, 3) {} function _hasMetaTxn() internal pure override returns (bool) { return true; } function _msgSender() internal view virtual // Solidity inheritance is so stupid override(Permit2PaymentMetaTxn, AbstractContext) returns (address) { return super._msgSender(); } function _hashArrayOfBytes(bytes[] calldata actions) internal pure returns (bytes32 result) { // This function deliberately does no bounds checking on `actions` for // gas efficiency. We assume that `actions` will get used elsewhere in // this context and any OOB or other malformed calldata will result in a // revert later. assembly ("memory-safe") { let ptr := mload(0x40) let hashesLength := shl(5, actions.length) for { let i := actions.offset let dst := ptr let end := add(i, hashesLength) } lt(i, end) { i := add(i, 0x20) dst := add(dst, 0x20) } { let src := add(actions.offset, calldataload(i)) let length := calldataload(src) calldatacopy(dst, add(src, 0x20), length) mstore(dst, keccak256(dst, length)) } result := keccak256(ptr, hashesLength) } } function _hashActionsAndSlippage(bytes[] calldata actions, AllowedSlippage calldata slippage) internal pure returns (bytes32 result) { // This function does not check for or clean any dirty bits that might // exist in `slippage`. We assume that `slippage` will be used elsewhere // in this context and that if there are dirty bits it will result in a // revert later. bytes32 arrayOfBytesHash = _hashArrayOfBytes(actions); assembly ("memory-safe") { let ptr := mload(0x40) mstore(ptr, SLIPPAGE_AND_ACTIONS_TYPEHASH) calldatacopy(add(ptr, 0x20), slippage, 0x60) mstore(add(ptr, 0x80), arrayOfBytesHash) result := keccak256(ptr, 0xa0) } } function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal virtual returns (bool) { if (action == ISettlerActions.METATXN_RFQ_VIP.selector) { // An optimized path involving a maker/taker in a single trade // The RFQ order is signed by both maker and taker, validation is // performed inside the RfqOrderSettlement so there is no need to // validate `sig` against `actions` here ( address recipient, ISignatureTransfer.PermitTransferFrom memory makerPermit, address maker, bytes memory makerSig, ISignatureTransfer.PermitTransferFrom memory takerPermit ) = abi.decode( data, (address, ISignatureTransfer.PermitTransferFrom, address, bytes, ISignatureTransfer.PermitTransferFrom) ); fillRfqOrderVIP(recipient, makerPermit, maker, makerSig, takerPermit, sig); } else if (action == ISettlerActions.METATXN_TRANSFER_FROM.selector) { (address recipient, ISignatureTransfer.PermitTransferFrom memory permit) = abi.decode(data, (address, ISignatureTransfer.PermitTransferFrom)); (ISignatureTransfer.SignatureTransferDetails memory transferDetails,,) = _permitToTransferDetails(permit, recipient); // We simultaneously transfer-in the taker's tokens and authenticate the // metatransaction. _transferFrom(permit, transferDetails, sig); } else if (action == ISettlerActions.METATXN_UNISWAPV3_VIP.selector) { ( address recipient, bytes memory path, ISignatureTransfer.PermitTransferFrom memory permit, uint256 amountOutMin ) = abi.decode(data, (address, bytes, ISignatureTransfer.PermitTransferFrom, uint256)); sellToUniswapV3VIP(recipient, path, permit, sig, amountOutMin); } else { return false; } return true; } function executeMetaTxn( AllowedSlippage calldata slippage, bytes[] calldata actions, bytes32, /* zid & affiliate */ address msgSender, bytes calldata sig ) public metaTx(msgSender, _hashActionsAndSlippage(actions, slippage)) returns (bool) { require(actions.length != 0); { (bytes4 action, bytes calldata data) = actions.decodeCall(0); // By forcing the first action to be one of the witness-aware // actions, we ensure that the entire sequence of actions is // authorized. `msgSender` is the signer of the metatransaction. if (!_dispatchVIP(action, data, sig)) { revert ActionInvalid(0, action, data); } } for (uint256 i = 1; i < actions.length; i = i.unsafeInc()) { (bytes4 action, bytes calldata data) = actions.decodeCall(i); if (!_dispatch(i, action, data)) { revert ActionInvalid(i, action, data); } } _checkSlippageAndTransfer(slippage); return true; } } // src/chains/Mainnet.sol // Solidity inheritance is stupid abstract contract MainnetMixin is FreeMemory, SettlerBase, MakerPSM, MaverickV2, CurveTricrypto, DodoV1, DodoV2 { constructor() { assert(block.chainid == 1 || block.chainid == 31337); } function _dispatch(uint256 i, bytes4 action, bytes calldata data) internal virtual override(SettlerAbstract, SettlerBase) DANGEROUS_freeMemory returns (bool) { if (super._dispatch(i, action, data)) { return true; } else if (action == ISettlerActions.MAKERPSM.selector) { (address recipient, IERC20 gemToken, uint256 bps, IPSM psm, bool buyGem) = abi.decode(data, (address, IERC20, uint256, IPSM, bool)); sellToMakerPsm(recipient, gemToken, bps, psm, buyGem); } else if (action == ISettlerActions.MAVERICKV2.selector) { ( address recipient, IERC20 sellToken, uint256 bps, IMaverickV2Pool pool, bool tokenAIn, uint256 minBuyAmount ) = abi.decode(data, (address, IERC20, uint256, IMaverickV2Pool, bool, uint256)); sellToMaverickV2(recipient, sellToken, bps, pool, tokenAIn, minBuyAmount); } else if (action == ISettlerActions.DODOV2.selector) { (address recipient, IERC20 sellToken, uint256 bps, IDodoV2 dodo, bool quoteForBase, uint256 minBuyAmount) = abi.decode(data, (address, IERC20, uint256, IDodoV2, bool, uint256)); sellToDodoV2(recipient, sellToken, bps, dodo, quoteForBase, minBuyAmount); } else if (action == ISettlerActions.DODOV1.selector) { (IERC20 sellToken, uint256 bps, IDodoV1 dodo, bool quoteForBase, uint256 minBuyAmount) = abi.decode(data, (IERC20, uint256, IDodoV1, bool, uint256)); sellToDodoV1(sellToken, bps, dodo, quoteForBase, minBuyAmount); } else { return false; } return true; } function _uniV3ForkInfo(uint8 forkId) internal pure override returns (address factory, bytes32 initHash, uint32 callbackSelector) { if (forkId == uniswapV3ForkId) { factory = uniswapV3MainnetFactory; initHash = uniswapV3InitHash; callbackSelector = uint32(IUniswapV3Callback.uniswapV3SwapCallback.selector); } else if (forkId == pancakeSwapV3ForkId) { factory = pancakeSwapV3Factory; initHash = pancakeSwapV3InitHash; callbackSelector = uint32(IPancakeSwapV3Callback.pancakeV3SwapCallback.selector); } else if (forkId == sushiswapV3ForkId) { factory = sushiswapV3MainnetFactory; initHash = uniswapV3InitHash; callbackSelector = uint32(IUniswapV3Callback.uniswapV3SwapCallback.selector); } else if (forkId == solidlyV3ForkId) { factory = solidlyV3Factory; initHash = solidlyV3InitHash; callbackSelector = uint32(ISolidlyV3Callback.solidlyV3SwapCallback.selector); } else { revert UnknownForkId(forkId); } } function _curveFactory() internal pure override returns (address) { return 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963; } } /// @custom:security-contact [email protected] contract MainnetSettler is Settler, MainnetMixin { constructor(bytes20 gitCommit) Settler(gitCommit) {} function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) { if (super._dispatchVIP(action, data)) { return true; } else if (action == ISettlerActions.MAVERICKV2_VIP.selector) { ( address recipient, bytes32 salt, bool tokenAIn, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) = abi.decode(data, (address, bytes32, bool, ISignatureTransfer.PermitTransferFrom, bytes, uint256)); sellToMaverickV2VIP(recipient, salt, tokenAIn, permit, sig, minBuyAmount); } else if (action == ISettlerActions.CURVE_TRICRYPTO_VIP.selector) { ( address recipient, uint80 poolInfo, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, uint256 minBuyAmount ) = abi.decode(data, (address, uint80, ISignatureTransfer.PermitTransferFrom, bytes, uint256)); sellToCurveTricryptoVIP(recipient, poolInfo, permit, sig, minBuyAmount); } else { return false; } return true; } // Solidity inheritance is stupid function _isRestrictedTarget(address target) internal pure override(Settler, Permit2PaymentAbstract) returns (bool) { return super._isRestrictedTarget(target); } function _dispatch(uint256 i, bytes4 action, bytes calldata data) internal override(SettlerAbstract, SettlerBase, MainnetMixin) returns (bool) { return super._dispatch(i, action, data); } function _msgSender() internal view override(Settler, AbstractContext) returns (address) { return super._msgSender(); } } /// @custom:security-contact [email protected] contract MainnetSettlerMetaTxn is SettlerMetaTxn, MainnetMixin { constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {} function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override DANGEROUS_freeMemory returns (bool) { if (super._dispatchVIP(action, data, sig)) { return true; } else if (action == ISettlerActions.METATXN_MAVERICKV2_VIP.selector) { ( address recipient, bytes32 salt, bool tokenAIn, ISignatureTransfer.PermitTransferFrom memory permit, uint256 minBuyAmount ) = abi.decode(data, (address, bytes32, bool, ISignatureTransfer.PermitTransferFrom, uint256)); sellToMaverickV2VIP(recipient, salt, tokenAIn, permit, sig, minBuyAmount); } else if (action == ISettlerActions.METATXN_CURVE_TRICRYPTO_VIP.selector) { ( address recipient, uint80 poolInfo, ISignatureTransfer.PermitTransferFrom memory permit, uint256 minBuyAmount ) = abi.decode(data, (address, uint80, ISignatureTransfer.PermitTransferFrom, uint256)); sellToCurveTricryptoVIP(recipient, poolInfo, permit, sig, minBuyAmount); } else { return false; } return true; } // Solidity inheritance is stupid function _dispatch(uint256 i, bytes4 action, bytes calldata data) internal override(SettlerAbstract, SettlerBase, MainnetMixin) returns (bool) { return super._dispatch(i, action, data); } function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) { return super._msgSender(); } }
{ "remappings": [ "solmate/=lib/solmate/", "permit2/=lib/permit2/", "forge-std/=lib/forge-std/src/", "forge-gas-snapshot/=lib/forge-gas-snapshot/src/", "ds-test/=lib/forge-std/lib/ds-test/src/" ], "optimizer": { "enabled": true, "runs": 10000, "details": { "constantOptimizer": true, "yul": true } }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": false }, "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":[{"internalType":"bytes20","name":"gitCommit","type":"bytes20"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"bytes4","name":"action","type":"bytes4"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"ActionInvalid","type":"error"},{"inputs":[{"internalType":"uint256","name":"callbackInt","type":"uint256"}],"name":"CallbackNotSpent","type":"error"},{"inputs":[],"name":"ConfusedDeputy","type":"error"},{"inputs":[],"name":"ForwarderNotAllowed","type":"error"},{"inputs":[],"name":"InvalidOffset","type":"error"},{"inputs":[],"name":"InvalidTarget","type":"error"},{"inputs":[],"name":"NotConverged","type":"error"},{"inputs":[],"name":"PayerSpent","type":"error"},{"inputs":[{"internalType":"uint256","name":"callbackInt","type":"uint256"}],"name":"ReentrantCallback","type":"error"},{"inputs":[{"internalType":"bytes32","name":"oldWitness","type":"bytes32"}],"name":"ReentrantMetatransaction","type":"error"},{"inputs":[{"internalType":"address","name":"oldPayer","type":"address"}],"name":"ReentrantPayer","type":"error"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"TooMuchSlippage","type":"error"},{"inputs":[{"internalType":"uint8","name":"forkId","type":"uint8"}],"name":"UnknownForkId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"oldWitness","type":"bytes32"}],"name":"WitnessNotSpent","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes20","name":"","type":"bytes20"}],"name":"GitCommit","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"internalType":"struct SettlerBase.AllowedSlippage","name":"slippage","type":"tuple"},{"internalType":"bytes[]","name":"actions","type":"bytes[]"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"executeMetaTxn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6080604090808252346102ff578061585e803803809161001f8285610358565b83396020928391810103126102ff57516001600160601b0319811691908290036102ff576100ef605b845161005381610329565b8181527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060858301927f536c697070616765416e64416374696f6e73286164647265737320726563697084527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d69898201520152207f615e8d716cef7295e75dd3f1f10d679914ad6d7759e8e9459f0109ef752417011461037b565b6101276100fa610396565b8281519101207f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa1461037b565b610200835161013581610329565b604b81528281017f5266714f7264657228436f6e73696465726174696f6e206d616b6572436f6e7381527f696465726174696f6e2c436f6e73696465726174696f6e2074616b6572436f6e868301526a73696465726174696f6e2960a81b60608301526101d6846101a4610396565b9281895194859282840197518091895e8301908282015f8152815193849201905e015f83820152038084520182610358565b5190207f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a75982761461037b565b46617a69149182610314578351907f16fbd3a71aa6d159973eb9ff1e1199f9fe242767e6f30ac662a492f92ac704115f80a26331a9108f60e11b81526003600482015281816024816d04533fe15556b1e086bb1a72ceae5afa91821561030a575f926102c2575b506102a6929161028291506001600160a01b0316301461037b565b600146149081821592836102bb575b61029a9061037b565b916102b3575b5061037b565b51615442908161041c8239f35b90505f6102a0565b5081610291565b90809250813d8311610303575b6102d98183610358565b810103126102ff5751906001600160a01b03821682036102ff57906102826102a6610267565b5f80fd5b503d6102cf565b84513d5f823e3d90fd5b6102a6929150610324901561037b565b610282565b608081019081106001600160401b0382111761034457604052565b634e487b7160e01b5f52604160045260245ffd5b601f909101601f19168101906001600160401b0382119082101761034457604052565b1561038257565b634e487b7160e01b5f52600160045260245ffd5b604051906103a382610329565b605882527f626f6f6c207061727469616c46696c6c416c6c6f7765642900000000000000006060837f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7460208201527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c6040820152015256fe60a060405260043610801561043a575b36156104385734610213577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe9905f825c925d7fffffffff000000000000000000000000000000000000000000000000000000005f3581811692610423575b50808316911603610213576001600160a01b0380821633036102135736600411610213577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36019160a01c61ffff16908160011461035d57816002146102175750600314610101577f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffd5b60801161021357600435604435908160040135610121816024850161534c565b60601c9181601411610213575f81131561020957915b308103610193575061017361017b9360387fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec339401910161534c565b60601c61326f565b60405161018781610bb4565b5f81525b602081519101f35b916101a2610204949315614c85565b604051906101af82610b1f565b33825260208201526101fe6101c736602c8601610bf3565b92608d8501356001169460ad7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff773693019101610c69565b9161490c565b61017b565b5060243591610137565b5f80fd5b9160a091501061021357608435907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f82019160a4359180831680840361021357610265916004351614614c85565b60405161027181610b1f565b33815260243560208201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5c360192608084126102135760408051946102b686610b68565b1261021357604051906102c882610b1f565b815260c4356020820152835260e43560208401526101043560408401526102ee84610c4d565b916102fc6040519384610bd0565b8483523660a4820111610213577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9f5f9161034996610125602087013784010152610105356001169261490c565b60405161035581610bb4565b5f815261018b565b9160a09150036102135760043590604435918060a01c8360a01c176102135781610388911615614c85565b5f5c905f805d60019260015c5f60015d60025c905f60025d6040519360208560200160035c9860208a8901019988528960405260045b8a831061041157505050506103499650604051936103db85610b1f565b1683526064356020840152604051926103f384610b68565b83526020830152604082015261040933826132ec565b50509061490c565b805c83525f815d8101918301916103be565b818093503660040360031b1b1616905f61006c565b005b5f3560e01c63fd3ad6d40361000f5734610213577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160e08112610213576060136102135767ffffffffffffffff60643511610213573660236064350112156102135767ffffffffffffffff6064356004013511610213573660246064356004013560051b606435010111610213576001600160a01b0360a4351660a435036102135767ffffffffffffffff60c435116102135736602360c4350112156102135767ffffffffffffffff60c43560040135116102135736602460c4356004013560c4350101116102135760a06064356024015b60246064356004013560051b60643501018110610ac85760a06064356004013560051b60a020604051907f615e8d716cef7295e75dd3f1f10d679914ad6d7759e8e9459f0109ef7524170182526060600460208401376080820152207f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5c80610a9757507f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5d6001600160a01b0360a4351615610a6d576001600160a01b037f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1680610a3c5760a4356001600160a01b03167f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935d606435600401351561021357602460643501356064350160448101359060487ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc602483013501910191604051926106a860c43560040135602460c43501858486610cac565b84604052156109d55760015b606435600401358110610907576004356001600160a01b03811680820361021357602435906001600160a01b03821692838303610213576044359384158015906108fe575b6107ef575b50505050506001600160a01b0360a435166001600160a01b037f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16036107c5575f7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935d7f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5c8061079457602060405160018152f35b602490604051907fe25527c20000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517f5149e795000000000000000000000000000000000000000000000000000000008152fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103610878575050479183831061082a575061082092506132dd565b80808080806106fe565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526024810193909352506044820152606490fd5b0390fd5b602493919250602090604051948580926370a0823160e01b82523060048301525afa9283156108f3575f936108bf575b5083831061082a576108ba935061326f565b610820565b9092506020813d6020116108eb575b816108db60209383610bd0565b81010312610213575191846108a8565b3d91506108ce565b6040513d5f823e3d90fd5b508015156106f9565b60246064358260051b010135606435019060448201359160487ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc602483013501910160405191610958818387611e15565b836040521561096e5750505060019150016106b4565b7fffffffff00000000000000000000000000000000000000000000000000000000839584957f3c74eed60000000000000000000000000000000000000000000000000000000061087496526004870152166024850152606060448501526064840191610aff565b83927fffffffff00000000000000000000000000000000000000000000000000000000610874937f3c74eed60000000000000000000000000000000000000000000000000000000086525f6004870152166024850152606060448501526064840191610aff565b602490604051907f7407c0f80000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b602490604051907f9936cbab0000000000000000000000000000000000000000000000000000000082526004820152fd5b60448135606435016024810135918291018437822082526020918201910161052e565b35906001600160a01b038216820361021357565b601f8260209493601f1993818652868601375f8582860101520116010190565b6040810190811067ffffffffffffffff821117610b3b57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6060810190811067ffffffffffffffff821117610b3b57604052565b6080810190811067ffffffffffffffff821117610b3b57604052565b67ffffffffffffffff8111610b3b57604052565b6020810190811067ffffffffffffffff821117610b3b57604052565b90601f601f19910116810190811067ffffffffffffffff821117610b3b57604052565b8092910391608083126102135760405190610c0d82610b68565b60408294126102135760606040918251610c2681610b1f565b610c2f82610aeb565b81526020820135602082015284528281013560208501520135910152565b67ffffffffffffffff8111610b3b57601f01601f191660200190565b929192610c7582610c4d565b91610c836040519384610bd0565b829481845281830111610213578281602093845f960137010152565b3590811515820361021357565b919091610cbc8585848685611534565b15610ccb575050505050600190565b7fffffffff00000000000000000000000000000000000000000000000000000000167f8d62436100000000000000000000000000000000000000000000000000000000810361113557508101906101008183031261021357610d2c81610aeb565b92602091604094610d4b610d41878401610c9f565b9560608401610bf3565b9660e083013597610e6a866055610d6d6001600160a01b039889963691610c69565b967fbb7b783eb4b8ca46925c5384a6b9919df57cb83da8f76e37291f58d0dd5c439a60e18d730a7e848aca42d879ef06507fca0e7b33a0a63c1e8151809c838b51838b015e838b8a01836060015e5f8260a00153805180918a018360a1015e806081018252019160a18301809152528560ac82019460ff8653013560c182015201522092510151881561110f57637fffffff5b8a5191610e0c83610b84565b8252891515898301525f8b83015260030b6060820152610e5c8a51968792868b8501987f3eece7db000000000000000000000000000000000000000000000000000000008a521660248501611da1565b03601f198101865285610bd0565b16927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1683146110e6577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe991825c806110b657505f9182917f67ca7c91000000000000000200000000000000000000000000000000000000008617855d519082865af190610ef6614cb9565b91156110ae575c8061107e5750808380610f1593518301019101611deb565b939050858410610f2a57505050505050600190565b6004939291829115611002578551948580927f5f64b55b0000000000000000000000000000000000000000000000000000000082525afa908115610ff8575f91610fc1575b506108749250925b519384937f97a6f3b9000000000000000000000000000000000000000000000000000000008552600485016040919493926001600160a01b03606083019616825260208201520152565b905082813d8311610ff1575b610fd78183610bd0565b8101031261021357610feb61087492611e01565b85610f6f565b503d610fcd565b84513d5f823e3d90fd5b8551948580927f0fc63d100000000000000000000000000000000000000000000000000000000082525afa908115610ff8575f91611047575b50610874925092610f77565b905082813d8311611077575b61105d8183610bd0565b810103126102135761107161087492611e01565b8561103b565b503d611053565b6024908651907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b508281519101fd5b6024908851907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b600486517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000610e00565b7fdaac39fd000000000000000000000000000000000000000000000000000000000361150e5781019260e0828503126102135761117182610aeb565b92602092838101359469ffffffffffffffffffff86168603610213576111af61119e604098898501610bf3565b936001600160a01b03953691610c69565b9067ffffffffffffffff92838860101c16948860081c9580155f14611419575076d6940c0e5f2ff0ff18a3be9b835635039256dc4b4963805f526017600920938793929189915b5f805d8c82808501519160019260015d015160025d818401848351938401019260035d6004905b8381106113f957505050505101518a5199898b01977fdd96994f00000000000000000000000000000000000000000000000000000000895260ff1660248c015260ff1660448b015260648a015260c00135608489015260a488015f905260c488015f90521660e48701526101048087017f6370a85c000000000000000000000000000000000000000000000000000000009052865261014086019186831090831117610b3b578187528316927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1683146113d157507e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe993845c806113a15750915f92918380937f6370a85c000000000000000100000000000000000000000000000000000000008417885d51925af190611355614cb9565b911561139b5750505c908161136b575050600190565b6024925051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b81519101fd5b6024908751907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b807fe758b8d50000000000000000000000000000000000000000000000000000000060049252fd5b9193959697509193508051825d8b01908201918a969594928c949261121d565b608081101561145457730c0e5f2ff0ff18a3be9b835635039256dc4b496360145261d6945f526034536017601e20935b8793929189916111f6565b600863ffffffff8b60301c166114f3575b6001811b66ffffffffffffff8c60181c1610156114eb575b6001811b8210156114e3575b6001811b68ffffffffffffffff00891610156114db575b60031c90815280607f018953730c0e5f2ff0ff18a3be9b835635039256dc4b49635f528060d501600a536094600b53601601600a2093611449565b6008016114a0565b600801611489565b60100161147d565b5060288682036114655760118a634e487b715f52526024601cfd5b505050505f90565b9080601f830112156102135781602061153193359101610c69565b90565b90939291907fffffffff00000000000000000000000000000000000000000000000000000000167f5228831d0000000000000000000000000000000000000000000000000000000081036117355750830190610160848303126102135761159a84610aeb565b936115a88360208301610bf3565b926115b560a08301610aeb565b9060c08301359267ffffffffffffffff841161021357611730976001600160a01b0397611715976116148a61160c6116ac9a6116048960e06115fd6116be9c879f8d01611516565b9a01610bf3565b953691610c69565b9416826132ec565b6080529890936116a4611629898b16866132ec565b919e90917f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c90826040519461165e86610b84565b16845260208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8c9461479e565b6116b461337e565b9287871691614bae565b81604051936116cc85610b84565b16835260805160208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b6fffffffffffffffffffffffffffffffff6080511691614c42565b600190565b919392917f0dfeb4190000000000000000000000000000000000000000000000000000000081036117ad5750820160a083820312610213576117309361179d6001600160a01b036117956117a794602061178e89610aeb565b9801610bf3565b9516856132ec565b5050923691610c69565b9161479e565b92949193927f9ebf8e8d0000000000000000000000000000000000000000000000000000000003611d735784019360e081860312610213576117ee81610aeb565b9260208201359067ffffffffffffffff82116102135761160461181688611820948601611516565b9760408501610bf3565b80516089019485608911611b3a57602091601f1961185661184089610c4d565b9861184e6040519a8b610bd0565b808a52610c4d565b013684890137815183015187604801526040828401886068015e5f8760a8015380519083018760a9015e5101515f937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211611b285795905b815190602c8210611aae57866014840151601585015197601886015190602c87015194838690879c6001600160a01b0389166001600160a01b0388161015611d68575b60ff1680611c2057506001600160a01b039161196f91731f98431c8ad98523631ae4a59f267346ea31f9847fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33985b62ffffff16906040519387165f528616602052806040521560051b6060035f2091604052613578565b1691855190858760280152866014015285528c602c88115f14611b8c5750611a0e6001600160a01b0393878594611a09611a1d956119fb6040519b8c9586938d8c8084169116105f14611b6e578d8c806401000276a4945b7f128acb080000000000000000000000000000000000000000000000000000000060208a0152169116103060248701614768565b03601f198101845283610bd0565b613468565b60208082518301019101611deb565b9590946040525b1691161015611b6757505b7f80000000000000000000000000000000000000000000000000000000000000008114611b3a575f03945f8612611b2857602c86921115611ac05750503093906018815110611aae5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906118af565b634e487b715f5260326020526024601cfd5b939650935050925060c08301358210611adb57505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260c0929092013560248301526044820152606490fd5b634e487b715f5260116020526024601cfd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9050611a2f565b8d8c8073fffd8963efd1fc6a506488495d951d5263988d25946119c7565b926001600160a01b03611bfc93611a09896119fb849b9a8a611a0e98879b888616898416105f14611c0457886401000276a4935b816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c015216911610911660248701614768565b949093611a24565b8873fffd8963efd1fc6a506488495d951d5263988d2593611bc0565b60018103611c7857506001600160a01b039161196f917341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c97f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7598611946565b60028103611cd057506001600160a01b039161196f9173baceb8ec6b9355dfc0269c18bac9d6e2bdc29c4f7fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e3398611946565b9091929394959650600381145f14611d37575061196f8d96959493926001600160a01b03927370fe4a44ea505cfa3a57b95cf2862d4fd5f0f6877fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c98611946565b602490604051907fd3b1276d0000000000000000000000000000000000000000000000000000000082526004820152fd5b8692508891506118f2565b50925050505f90565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b606061153194936001600160a01b0360c094168352805160208401526020810151151560408401526040810151151582840152015160030b60808201528160a08201520190611d7c565b9190826040910312610213576020825192015190565b51906001600160a01b038216820361021357565b919091611e238284836135a7565b15611e3057505050600190565b82907fffffffff00000000000000000000000000000000000000000000000000000000167fe12b0f130000000000000000000000000000000000000000000000000000000081036123a8575060a0918101031261021357611e9081610aeb565b602091611e9e838201610aeb565b90604092838201356060830135916001600160a01b039384841680940361021357611ecc6080869201610c9f565b91169015612253578551966370a0823160e01b885260049230848a0152736b175474e89094c44da98b954eedeac495271d0f9882816024818d5afa9081156121aa575f91612224575b5061271091611f2391614736565b04978751967ffae036d500000000000000000000000000000000000000000000000000000000885282888681895afa9788156121aa575f986121f5575b508290858a51809981937f313ce567000000000000000000000000000000000000000000000000000000008352165afa9586156121eb575f966121b4575b5087517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230858201528560248201528281604481855afa9081156121aa575f9161217d575b5089811061208d575b505050823b15610213575f9461205e670de0b6b3a764000093879360ff978a519b8c998a9889977f8d7ef9bb000000000000000000000000000000000000000000000000000000008952019216600a0a0204918401602090939291936001600160a01b0360408201951681520152565b03925af19081156120845750612075575b50600190565b61207e90610ba0565b5f61206f565b513d5f823e3d90fd5b612121575b905f604481938a519485917f095ea7b300000000000000000000000000000000000000000000000000000000835289898401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561211957503d15601f3d1160015f511416171561210d575f8080611fee565b50633e3f8f735f52601cfd5b3d5f823e3d90fd5b87517f095ea7b300000000000000000000000000000000000000000000000000000000815285858201525f6024820152825f60448382865af11561211957503d15601f3d1160015f511416176120925783633e3f8f735f52601cfd5b90508281813d83116121a3575b6121948183610bd0565b8101031261021357515f611fe5565b503d61218a565b89513d5f823e3d90fd5b9095508181813d83116121e4575b6121cc8183610bd0565b81010312610213576121dd90614728565b945f611f9e565b503d6121c2565b88513d5f823e3d90fd5b9097508281813d831161221d575b61220d8183610bd0565b8101031261021357519682611f60565b503d612203565b90508281813d831161224c575b61223b8183610bd0565b810103126102135751612710611f15565b503d612231565b9392866024918798949851928380926370a0823160e01b825230600483015288165afa90811561236f575f91612379575b506127109161229291614736565b049184517f01664f6600000000000000000000000000000000000000000000000000000000815282816004818a5afa92831561236f57916122de939185935f93612340575b5050614fc2565b833b156102135782517f959912760000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152915f908390604490829084905af190811561208457506120755750600190565b612360929350803d10612368575b6123588183610bd0565b810190614749565b905f806122d7565b503d61234e565b86513d5f823e3d90fd5b90508281813d83116123a1575b6123908183610bd0565b810103126102135751612710612284565b503d612386565b7f67848fe7000000000000000000000000000000000000000000000000000000008103612782575060c09181010312610213576123e481610aeb565b6020906123f2828401610aeb565b9160409283850135946060810135916001600160a01b03908184168094036102135760a061242260808501610c9f565b930135975f908061271b575b50878161270657869150916024849351809481936370a0823160e01b8352896004840152165afa9081156126fc575f916126cf575b5086517f1865c57d0000000000000000000000000000000000000000000000000000000081526101208082600481895afa9182156121aa579089949392915f926125d1575b50506fffffffffffffffffffffffffffffffff809188875f146125c9575051165b169003955b83156125a357637fffffff5b8351976124e689610b84565b8852841515878901525f8489015260030b6060880152612541835161250a81610bb4565b5f8152845198899485947f3eece7db0000000000000000000000000000000000000000000000000000000086521660048501611da1565b03815f865af1938415612599575f94612568575b50858410610f2a57505050505050600190565b612589919450853d8711612592575b6125818183610bd0565b810190611deb565b9050925f612555565b503d612577565b85513d5f823e3d90fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff800000006124da565b0151166124c9565b818096508193503d83116126c8575b6125ea8183610bd0565b8101031261021357885193840184811067ffffffffffffffff821117610b3b578952612615816146f0565b84526126228782016146f0565b8785015261263189820161470d565b898501526126416060820161470d565b6060850152608081015164ffffffffff8116810361021357608085015260a08101518060030b81036102135760a085015261267e60c0820161471b565b60c085015260e081015163ffffffff8116810361021357846fffffffffffffffffffffffffffffffff92839260e08d9801526126be610100809201614728565b90820152916124a8565b503d6125e0565b90508481813d83116126f5575b6126e68183610bd0565b8101031261021357515f612463565b503d6126dc565b87513d5f823e3d90fd5b929181866127169299939961326f565b6124ce565b88516370a0823160e01b8152306004820152915086826024818688165afa80156121aa575f90612753575b612710925002045f61242e565b508682813d831161277b575b6127698183610bd0565b81010312610213576127109151612746565b503d61275f565b7fca9e5d0f000000000000000000000000000000000000000000000000000000008103612ae3575060c09181010312610213576127be81610aeb565b9060206127cc818301610aeb565b9160409283820135916060810135916001600160a01b0393848416809403610213578460a06127fd60808601610c9f565b9401359816948682612a60575b505050505f14612957578351917fdd93f59a000000000000000000000000000000000000000000000000000000008352600483015282826024815f855af1918215610ff8575f92612928575b50848210612868575050505050600190565b826004918551928380927f4a248d2a0000000000000000000000000000000000000000000000000000000082525afa928315610ff8575f936128ef575b505091517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260248101929092526044820152606490fd5b90809350813d8311612921575b6129068183610bd0565b810103126102135761291a61087492611e01565b91856128a5565b503d6128fc565b9091508281813d8311612950575b6129408183610bd0565b810103126102135751905f612856565b503d612936565b8351917fbd6015b4000000000000000000000000000000000000000000000000000000008352600483015282826024815f855af1918215610ff8575f92612a31575b508482106129ab575050505050600190565b826004918551928380927fd4b970460000000000000000000000000000000000000000000000000000000082525afa928315610ff8575f936128ef57505091517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260248101929092526044820152606490fd5b9091508281813d8311612a59575b612a498183610bd0565b810103126102135751905f612999565b503d612a3f565b6024918951928380926370a0823160e01b825230600483015287165afa9081156121eb5790859392915f91612aae575b50612aa59391612a9f91614f3f565b9161326f565b5f80808661280a565b809450888092503d8311612adc575b612ac78183610bd0565b81010312610213579151849290612aa5612a90565b503d612abd565b7fb8df6d4d0000000000000000000000000000000000000000000000000000000014159050613269578160a0918101031261021357612b2181610aeb565b90602091604090818301356001600160a01b039384821680920361021357612b4b60608201610c9f565b9260808201359185516370a0823160e01b8152888160248160049b308d83015287165afa9081156126fc579089915f9161323a575b5081612b8f9293013590614f3f565b94612b9b868685614fc2565b156131ee5750845160e0810181811067ffffffffffffffff8211176131c25786525f81528781015f8152868201905f825260608301905f825260808401915f835260a08501905f825260c086015f81528c8c8b8151928380927fffa642250000000000000000000000000000000000000000000000000000000082525afa80156130c4578f908f928f908e925f915f916131a3575b508852895251928380927f17be952e0000000000000000000000000000000000000000000000000000000082525afa80156130c4578f5f9161316d575b5060ff915016600381101561306a5781528b517f796da7af0000000000000000000000000000000000000000000000000000000081528e818f818e5afa9081156130c4578f908f928f908e925f91613138575b508b5251928380927f7c9b8e890000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f908f928f908e925f91613103575b50865251928380927feab5d20e0000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f908f928f908e925f916130ce575b508a5251928380927fec2fd46d0000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f5f92613096575b505084528051600381101561306a57612f7957505050505050612da59085615317565b8551907fc0ffa17800000000000000000000000000000000000000000000000000000000825288828981885afa9182156126fc575f92612f4a575b508651917fab44a7a300000000000000000000000000000000000000000000000000000000835289838a81895afa9081156121eb575f91612f19575b612e35935001670de0b6b3a76400009081019102614d2f565b91808310612eca575050908592915f855196612e5088610bb4565b818852612e898751988996879586947fe67ce70600000000000000000000000000000000000000000000000000000000865285016146d4565b03925af19081156120845750612ea1575b5050600190565b813d8311612ec3575b612eb48183610bd0565b81010312610213575f80612e9a565b503d612eaa565b61087483889288519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865285016040919493926001600160a01b03606083019616825260208201520152565b90508983813d8311612f43575b612f308183610bd0565b8101031261021357612e35925190612e1c565b503d612f26565b9091508881813d8311612f72575b612f628183610bd0565b810103126102135751905f612de0565b503d612f58565b51600381101561303e57600103612fbc575050612f9a612fb4939451614ce8565b915190670de0b6b3a7640000898651925194020491615390565b905103612da5565b919290935190519003835182519003808a11155f146130275750509161300f93918389612fee95510194859451614ce8565b9251905191519061301583670de0b6b3a76400008099819885839602614d2f565b0261542a565b82020490840301930302040204612da5565b915093915061303892508703615317565b01612da5565b60218d7f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b60218e7f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b90809250813d83116130bd575b6130ad8183610bd0565b8101031261021357515f8f612d82565b503d6130a3565b8d513d5f823e3d90fd5b945050505081813d83116130fc575b6130e78183610bd0565b81010312610213578e8b8f928f90515f612d46565b503d6130dd565b945050505081813d8311613131575b61311c8183610bd0565b81010312610213578e8b8f928f90515f612d03565b503d613112565b945050505081813d8311613166575b6131518183610bd0565b81010312610213578e8b8f928f90515f612cc0565b503d613147565b905081813d831161319c575b6131838183610bd0565b810103126102135761319660ff91614728565b8f612c6d565b503d613179565b90506131bc9150823d8411612592576125818183610bd0565b5f612c30565b6041887f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b9390505f85939293519661320188610bb4565b818852612e898751988996879586947f8dae733300000000000000000000000000000000000000000000000000000000865285016146d4565b82819392503d8311613262575b6132518183610bd0565b810103126102135751889081612b80565b503d613247565b50505f90565b60446020925f80936001600160a01b03966040519788947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af11561211957503d15601f3d1160015f51141617156132d057565b6390b8ec185f526004601cfd5b5f80809381935af1156108f357565b60405192916132fa84610b1f565b60208401915f8352846001600160a01b03809316905260208151015180935251511691565b6040519061332c82610b68565b602e82527f696e7432353620616d6f756e74290000000000000000000000000000000000006040837f546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c7560208201520152565b60405161338a81610b84565b60588152611531603c60208301927f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7484527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c60408201527f626f6f6c207061727469616c46696c6c416c6c6f7765642900000000000000006060820152602061341161331f565b6040519586937f436f6e73696465726174696f6e20636f6e73696465726174696f6e2900000000848601525180918686015e8301908482015f8152815193849201905e015f8382015203601c810184520182610bd0565b6001600160a01b03809116907f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c168114610a6d577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe992835c8061354757509181740300000000000000000000000000000000000000005f9493859460e01b1717855d82602083519301915af1906134fd614cb9565b911561353e575c8061350d575090565b602490604051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b50602081519101fd5b602490604051907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b9160406055938151908152600b81019360ff8553602082015201522090565b359062ffffff8216820361021357565b9091907fffffffff00000000000000000000000000000000000000000000000000000000167fc1fb425e0000000000000000000000000000000000000000000000000000000081036136565750810160c0828203126102135761360982610aeb565b906136178160208501610bf3565b9060a084013567ffffffffffffffff81116102135761364661364e926001600160a01b03926117309701611516565b9316826132ec565b50509061479e565b7fd92aadfb0000000000000000000000000000000000000000000000000000000081036138a657508101610120828203126102135761369482610aeb565b916020926136a483858401610bf3565b6136b060a08401610aeb565b9360c08401359067ffffffffffffffff8211610213576136d1918501611516565b916101006136e160e08601610aeb565b9401356136fb6001600160a01b03808098169316846132ec565b969091926137586040938a85519161371283610b84565b168152898c820152868582015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9760248b6137d78c8616809d7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c89519261379284610b84565b83528785840152168882015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8651928380926370a0823160e01b82523060048301525afa94851561208457505f94613863575b509361384484878c95856117309f9b98996138529b976fffffffffffffffffffffffffffffffff9e9b9511613859575b908461383a92615288565b809b86015261326f565b61384c61337e565b93614bae565b1691614c42565b909350839061382f565b95919a809794508681999692993d831161389f575b6138828183610bd0565b8101031261021357945195999396929590949390926138446137ff565b503d613878565b9192917f8d68a156000000000000000000000000000000000000000000000000000000008103613df657508201608083820312610213576138e683610aeb565b9060408401359067ffffffffffffffff821161021357613907918501611516565b9160246020845181860151907fffffffffffffffffffffffffffffffffffffffff000000000000000000000000918281169160148110613de1575b50509050604051928380926370a0823160e01b825230600483015260601c5afa9081156108f3575f91613dad575b5061398361271091602087013590614736565b04936040519361399285610b68565b6028855260403660208701379430937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211611b285795905b815190602c8210611aae57866014840151601585015197601886015190602c87015194838690879c6001600160a01b0389166001600160a01b0388161015613da2575b60ff1680613c8b57506001600160a01b0391613a8a91731f98431c8ad98523631ae4a59f267346ea31f9847fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e339862ffffff16906040519387165f528616602052806040521560051b6060035f2091604052613578565b1691855190858760280152866014015285528c602c88115f14613c145750611a0e6001600160a01b0393878594611a09613b14956119fb6040519b8c9586938d8c8084169116105f14611b6e577f128acb080000000000000000000000000000000000000000000000000000000060208601526401000276a4918c168c8f16103060248701614768565b9590946040525b1691161015613c0d57505b7f80000000000000000000000000000000000000000000000000000000000000008114611b3a575f03945f8612611b2857602c86921115613ba55750503093906018815110611aae5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906139cb565b939650935050925060608301358210613bc057505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526060929092013560248301526044820152606490fd5b9050613b26565b926001600160a01b03613c8393611a09896119fb849b9a8a611a0e98879b888616898416105f14611c0457886401000276a493816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c015216911610911660248701614768565b949093613b1b565b60018103613ce357506001600160a01b0391613a8a917341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c97f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7598611946565b60028103613d3b57506001600160a01b0391613a8a9173baceb8ec6b9355dfc0269c18bac9d6e2bdc29c4f7fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e3398611946565b9091929394959650600381145f14611d375750613a8a8d96959493926001600160a01b03927370fe4a44ea505cfa3a57b95cf2862d4fd5f0f6877fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c98611946565b869250889150613a0e565b90506020813d602011613dd9575b81613dc860209383610bd0565b810103126102135751613983613970565b3d9150613dbb565b8391925060140360031b1b1616805f80613942565b92837f103b48be00000000000000000000000000000000000000000000000000000000829495145f14614156575060c0918101031261021357613e3881610aeb565b602091613e46838201610aeb565b916040918281013590613e5b60608201610aeb565b9060a0613e6a60808301613597565b910135926001600160a01b03808098169316926001908180851614935f92846140e3575b8394508951936140ad575b630902f1ac5f52895f6004601c8a5afa156140a457893d10610213578b8b928760051b9687519288811851948084811c1614821517614057575b506060955061ffff6127109260081c1682030292028201910204975f601c8d8187019763022c0d9f88526080808901528360a08901528c82828a0101526004011886010152169101525f8060a48382875af1156121195750828410613f3e5750505050505050600190565b600491879115613ff3578551928380927fd21220a70000000000000000000000000000000000000000000000000000000082525afa908115610ff8576108749495965f92613fd6575b5050935b519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865216600485016040919493926001600160a01b03606083019616825260208201520152565b613fec9250803d10612368576123588183610bd0565b8680613f87565b8551928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa908115610ff8576108749495965f9261403a575b505093613f8b565b6140509250803d10612368576123588183610bd0565b8680614032565b9294505091936024601c5f926370a0823184528b85525afa156140a4578b3d10610213575f51838110614093579183916060948d94038e613ed3565b60118d634e487b715f52526024601cfd5b833d5f823e3d90fd5b63a9059cbb8452868c850152848a8501528b5f6044601c870182875af1156140a457805f51148c3d1015163d1517613e99575f80fd5b9250928851906370a0823160e01b82523060048301528b82602481865afa801561414c575f9061411d575b61271092500204918390613e8e565b508b82813d8311614145575b6141338183610bd0565b8101031261021357612710915161410e565b503d614129565b8a513d5f823e3d90fd5b7f38c9c1470000000000000000000000000000000000000000000000000000000081036141df5750019060a0818303126102135761419381610aeb565b906141a060408201610aeb565b90608081013567ffffffffffffffff811161021357611730946141c4918301611516565b9260206001600160a01b036060840135941692013590614d39565b7ff5b991890000000000000000000000000000000000000000000000000000000081036145a9575060a091810103126102135761421b81610aeb565b906040810135916001600160a01b03928381168091036102135761424160608401613597565b6040517f392f37e9000000000000000000000000000000000000000000000000000000008152936001808316149160e086600481875afa9081156108f3575f91885f985f935f945f9b5f935f9661452e575b50878197839781969f6142a590614c85565b8c15614519575b50505050505f91602088013561449f575b8983158d858215938461448e575b50505090614480575b61440f575b61432193508686670de0b6b3a76400008099818099020493020495869461271061ffff838089800204818880020401818a89020402049660081c168202049003020401615149565b9003020494608082013586106143c0575050156143ba575f925b60405161434781610bb4565b5f8152823b15610213575f946143a68692604051988997889687957f022c0d9f00000000000000000000000000000000000000000000000000000000875260048701526024860152166044840152608060648401526084830190611d7c565b03925af180156108f3576120755750600190565b5f61433b565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260809190910135602482015260448101859052606490fd5b915060208b60248b60405196879384926370a0823160e01b84526004840152165afa80156108f35784905f9061444a575b8d945003916142d9565b50506020833d602011614478575b8161446560209383610bd0565b8101031261021357836143219351614440565b3d9150614458565b5060018083811c16146142d4565b6144979261326f565b8d858d6142cb565b915060208b6024604051809681936370a0823160e01b8352306004840152165afa80156108f3578c935f916144e1575b506127109060208901350204916142bd565b9350506020833d602011614511575b816144fd60209383610bd0565b81010312610213576127108c9351906144cf565b3d91506144f0565b9e509198509650945091505f808080806142ac565b9c50505094505050505060e0863d60e0116145a1575b8161455160e09383610bd0565b81010312610213578580519188602083015193604084015192606085015161459360c061458c60a061458560808b0161471b565b9901611e01565b9d01611e01565b92969490959b92945f614293565b3d9150614544565b7fc876d21d0000000000000000000000000000000000000000000000000000000014159050613269578160609181010312610213576145e781610aeb565b60406145f560208401610aeb565b920135906001600160a01b038091169083169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee84145f1461464d57504792509080831161463a575b505050600190565b6146459203906132dd565b5f8080614632565b916020602494604051958680926370a0823160e01b82523060048301525afa9384156108f3575f946146a0575b5080841161468c575b50505050600190565b61469793039161326f565b5f808080614683565b9093506020813d6020116146cc575b816146bc60209383610bd0565b810103126102135751925f61467a565b3d91506146af565b6115319392606092825260208201528160408201520190611d7c565b51906fffffffffffffffffffffffffffffffff8216820361021357565b51908160070b820361021357565b5190811515820361021357565b519060ff8216820361021357565b81810292918115918404141715611b3a57565b9081602091031261021357516001600160a01b03811681036102135790565b919360a09361153196956001600160a01b0380941685521515602085015260408401521660608201528160808201520190611d7c565b9190917f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5f815c915d8015610a6d5761490a937f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c906040519361480185610b84565b605b8552614905604660208701967f536c697070616765416e64416374696f6e73286164647265737320726563697088527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d6960408201527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060820152602061488861331f565b604051998a937f536c697070616765416e64416374696f6e7320736c697070616765416e644163848601527f74696f6e7329000000000000000000000000000000000000000000000000000060408601525180918686015e8301908482015f8152815193849201905e015f83820152036026810188520186610bd0565b614bae565b565b9291907f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa935f855c955d8415610a6d577f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c7f74696f6e73290000000000000000000000000000000000000000000000000000604095614a6c6046886020815161499581610b84565b605b81528181017f536c697070616765416e64416374696f6e73286164647265737320726563697081527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d69848301527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060830152614a1261331f565b9184519889957f536c697070616765416e64416374696f6e7320736c697070616765416e644163868801528601525180918686015e8301908482015f8152815193849201905e015f83820152036026810185520183610bd0565b614b85576e22d473030f116ddee9f6b43ac78ba392833b1561021357614b695f96614b388894614b199b6001600160a01b038c9889519e8f9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c52614aed60048d018251602080916001600160a01b0381511684520151910152565b60208181015160448e015291015160648c015281516001600160a01b031660848c0152015160a48a0152565b1660c487015260e4860152610140610104860152610144850190611d7c565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc84830301610124850152611d7c565b03925af19081156120845750614b7c5750565b61490a90610ba0565b600486517f1c500e5c000000000000000000000000000000000000000000000000000000008152fd5b91909294936e22d473030f116ddee9f6b43ac78ba392833b1561021357614c315f96614b388894614b199a6001600160a01b0360409889519d8e9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c52614aed60048d018251602080916001600160a01b0381511684520151910152565b03925af180156108f357614b7c5750565b9190917f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a75982765f526020526040519160405260605f20916040526010525f5260305fa0565b15614c8c57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b3d15614ce3573d90614cca82610c4d565b91614cd86040519384610bd0565b82523d5f602084013e565b606090565b8015614d02576ec097ce7bc90715b34b9f10000000000490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8115614d02570490565b9291906001600160a01b03808316946e22d473030f116ddee9f6b43ac78ba38614610a6d575f91811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614e6157505050614d8a9047614f3f565b938051155f14614de5575050614dbb575f80809381935af1614daa614cb9565b9015614db35750565b602081519101fd5b60046040517f01da1572000000000000000000000000000000000000000000000000000000008152fd5b90939260208301808411611b3a57825110611aae57835f9460208695850101525b602083519301915af1614e17614cb9565b9015614db35751159081614e57575b50614e2d57565b60046040517f82d5d76a000000000000000000000000000000000000000000000000000000008152fd5b90503b155f614e26565b9091949281979497155f14614e8057505050614dbb575f928392614e06565b604096959496939293516370a0823160e01b81523060048201526020918282602481875afa80156108f3575f90614f10575b614ebc9250614f3f565b92818101808211611b3a57885110614eff57865f9896949293838a9997958c948a01015203614eee575b505050614e06565b614ef792614fc2565b5f8087614ee6565b603282634e487b715f52526024601cfd5b508282813d8311614f38575b614f268183610bd0565b8101031261021357614ebc9151614eb2565b503d614f1c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff828209828202918280831092039180830391612710958691099282861115611b285714614fbc577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919350828211900360fc1b910360041c170290565b50500490565b916001600160a01b039182916040519384927fdd62ed3e0000000000000000000000000000000000000000000000000000000084523060048501521692836024840152826044602096879389165afa9182156108f3575f9261511a575b50811061502d575b50505050565b6150bb575b60445f91826040519586927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561211957503d15601f3d1160015f51141617156150ae575f808080615027565b633e3f8f735f526004601cfd5b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081528160048201525f6024820152825f60448382885af11561211957503d15601f3d1160015f5114161761503257633e3f8f735f526004601cfd5b9091508381813d8311615142575b6151328183610bd0565b810103126102135751905f61501f565b503d615128565b929091670de0b6b3a7640000918285800204948381870204955f935b60ff85106151975760046040517f481b61af000000000000000000000000000000000000000000000000000000008152fd5b85818002048789886003878286890181898402040204958587105f1461521957020204018883830302049182156151d8575b505060019101945b0193615165565b14905061520e57600180820188888083800204860181848902040204116152015750875f6151c9565b9750505050509350505090565b955050509350505090565b02020401888284030204918215615237575b505060019103946151d1565b149050801561524e575b61520e576001875f61522b565b5086867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8301818082800204860191870204020410615241565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff828409818385029384808410930395099080851461530f5782805f0316809304600280826003021880830282030280830282030280830282030280830282030280830282030280920290030294600184805f0304019185841191030302920304170290565b505091500490565b90615346906153268151614ce8565b90670de0b6b3a76400006080820194602086519301519302049080615390565b90510390565b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000903581811693926014811061538157505050565b60140360031b82901b16169150565b90919392670de0b6b3a76400009182818302040294826153b08588614d2f565b92810394850204910190818110155f1461541f570381600191955b8460021b02048580020194600186811c019186925b83811061540957506115319596505f146154015701915b60011b910261542a565b9003916153f7565b9250826154168189614d2f565b0160011c6153e0565b9003815f91956153cb565b6154348282614d2f565b918202146115315760010190563ae13a6a1d3eea900d733ebc1d1ba9d772e6b415000000000000000000000000
Deployed Bytecode
0x60a060405260043610801561043a575b36156104385734610213577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe9905f825c925d7fffffffff000000000000000000000000000000000000000000000000000000005f3581811692610423575b50808316911603610213576001600160a01b0380821633036102135736600411610213577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36019160a01c61ffff16908160011461035d57816002146102175750600314610101577f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffd5b60801161021357600435604435908160040135610121816024850161534c565b60601c9181601411610213575f81131561020957915b308103610193575061017361017b9360387fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec339401910161534c565b60601c61326f565b60405161018781610bb4565b5f81525b602081519101f35b916101a2610204949315614c85565b604051906101af82610b1f565b33825260208201526101fe6101c736602c8601610bf3565b92608d8501356001169460ad7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff773693019101610c69565b9161490c565b61017b565b5060243591610137565b5f80fd5b9160a091501061021357608435907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f82019160a4359180831680840361021357610265916004351614614c85565b60405161027181610b1f565b33815260243560208201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5c360192608084126102135760408051946102b686610b68565b1261021357604051906102c882610b1f565b815260c4356020820152835260e43560208401526101043560408401526102ee84610c4d565b916102fc6040519384610bd0565b8483523660a4820111610213577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9f5f9161034996610125602087013784010152610105356001169261490c565b60405161035581610bb4565b5f815261018b565b9160a09150036102135760043590604435918060a01c8360a01c176102135781610388911615614c85565b5f5c905f805d60019260015c5f60015d60025c905f60025d6040519360208560200160035c9860208a8901019988528960405260045b8a831061041157505050506103499650604051936103db85610b1f565b1683526064356020840152604051926103f384610b68565b83526020830152604082015261040933826132ec565b50509061490c565b805c83525f815d8101918301916103be565b818093503660040360031b1b1616905f61006c565b005b5f3560e01c63fd3ad6d40361000f5734610213577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160e08112610213576060136102135767ffffffffffffffff60643511610213573660236064350112156102135767ffffffffffffffff6064356004013511610213573660246064356004013560051b606435010111610213576001600160a01b0360a4351660a435036102135767ffffffffffffffff60c435116102135736602360c4350112156102135767ffffffffffffffff60c43560040135116102135736602460c4356004013560c4350101116102135760a06064356024015b60246064356004013560051b60643501018110610ac85760a06064356004013560051b60a020604051907f615e8d716cef7295e75dd3f1f10d679914ad6d7759e8e9459f0109ef7524170182526060600460208401376080820152207f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5c80610a9757507f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5d6001600160a01b0360a4351615610a6d576001600160a01b037f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1680610a3c5760a4356001600160a01b03167f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935d606435600401351561021357602460643501356064350160448101359060487ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc602483013501910191604051926106a860c43560040135602460c43501858486610cac565b84604052156109d55760015b606435600401358110610907576004356001600160a01b03811680820361021357602435906001600160a01b03821692838303610213576044359384158015906108fe575b6107ef575b50505050506001600160a01b0360a435166001600160a01b037f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16036107c5575f7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935d7f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5c8061079457602060405160018152f35b602490604051907fe25527c20000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517f5149e795000000000000000000000000000000000000000000000000000000008152fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103610878575050479183831061082a575061082092506132dd565b80808080806106fe565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526024810193909352506044820152606490fd5b0390fd5b602493919250602090604051948580926370a0823160e01b82523060048301525afa9283156108f3575f936108bf575b5083831061082a576108ba935061326f565b610820565b9092506020813d6020116108eb575b816108db60209383610bd0565b81010312610213575191846108a8565b3d91506108ce565b6040513d5f823e3d90fd5b508015156106f9565b60246064358260051b010135606435019060448201359160487ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc602483013501910160405191610958818387611e15565b836040521561096e5750505060019150016106b4565b7fffffffff00000000000000000000000000000000000000000000000000000000839584957f3c74eed60000000000000000000000000000000000000000000000000000000061087496526004870152166024850152606060448501526064840191610aff565b83927fffffffff00000000000000000000000000000000000000000000000000000000610874937f3c74eed60000000000000000000000000000000000000000000000000000000086525f6004870152166024850152606060448501526064840191610aff565b602490604051907f7407c0f80000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b602490604051907f9936cbab0000000000000000000000000000000000000000000000000000000082526004820152fd5b60448135606435016024810135918291018437822082526020918201910161052e565b35906001600160a01b038216820361021357565b601f8260209493601f1993818652868601375f8582860101520116010190565b6040810190811067ffffffffffffffff821117610b3b57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6060810190811067ffffffffffffffff821117610b3b57604052565b6080810190811067ffffffffffffffff821117610b3b57604052565b67ffffffffffffffff8111610b3b57604052565b6020810190811067ffffffffffffffff821117610b3b57604052565b90601f601f19910116810190811067ffffffffffffffff821117610b3b57604052565b8092910391608083126102135760405190610c0d82610b68565b60408294126102135760606040918251610c2681610b1f565b610c2f82610aeb565b81526020820135602082015284528281013560208501520135910152565b67ffffffffffffffff8111610b3b57601f01601f191660200190565b929192610c7582610c4d565b91610c836040519384610bd0565b829481845281830111610213578281602093845f960137010152565b3590811515820361021357565b919091610cbc8585848685611534565b15610ccb575050505050600190565b7fffffffff00000000000000000000000000000000000000000000000000000000167f8d62436100000000000000000000000000000000000000000000000000000000810361113557508101906101008183031261021357610d2c81610aeb565b92602091604094610d4b610d41878401610c9f565b9560608401610bf3565b9660e083013597610e6a866055610d6d6001600160a01b039889963691610c69565b967fbb7b783eb4b8ca46925c5384a6b9919df57cb83da8f76e37291f58d0dd5c439a60e18d730a7e848aca42d879ef06507fca0e7b33a0a63c1e8151809c838b51838b015e838b8a01836060015e5f8260a00153805180918a018360a1015e806081018252019160a18301809152528560ac82019460ff8653013560c182015201522092510151881561110f57637fffffff5b8a5191610e0c83610b84565b8252891515898301525f8b83015260030b6060820152610e5c8a51968792868b8501987f3eece7db000000000000000000000000000000000000000000000000000000008a521660248501611da1565b03601f198101865285610bd0565b16927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1683146110e6577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe991825c806110b657505f9182917f67ca7c91000000000000000200000000000000000000000000000000000000008617855d519082865af190610ef6614cb9565b91156110ae575c8061107e5750808380610f1593518301019101611deb565b939050858410610f2a57505050505050600190565b6004939291829115611002578551948580927f5f64b55b0000000000000000000000000000000000000000000000000000000082525afa908115610ff8575f91610fc1575b506108749250925b519384937f97a6f3b9000000000000000000000000000000000000000000000000000000008552600485016040919493926001600160a01b03606083019616825260208201520152565b905082813d8311610ff1575b610fd78183610bd0565b8101031261021357610feb61087492611e01565b85610f6f565b503d610fcd565b84513d5f823e3d90fd5b8551948580927f0fc63d100000000000000000000000000000000000000000000000000000000082525afa908115610ff8575f91611047575b50610874925092610f77565b905082813d8311611077575b61105d8183610bd0565b810103126102135761107161087492611e01565b8561103b565b503d611053565b6024908651907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b508281519101fd5b6024908851907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b600486517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000610e00565b7fdaac39fd000000000000000000000000000000000000000000000000000000000361150e5781019260e0828503126102135761117182610aeb565b92602092838101359469ffffffffffffffffffff86168603610213576111af61119e604098898501610bf3565b936001600160a01b03953691610c69565b9067ffffffffffffffff92838860101c16948860081c9580155f14611419575076d6940c0e5f2ff0ff18a3be9b835635039256dc4b4963805f526017600920938793929189915b5f805d8c82808501519160019260015d015160025d818401848351938401019260035d6004905b8381106113f957505050505101518a5199898b01977fdd96994f00000000000000000000000000000000000000000000000000000000895260ff1660248c015260ff1660448b015260648a015260c00135608489015260a488015f905260c488015f90521660e48701526101048087017f6370a85c000000000000000000000000000000000000000000000000000000009052865261014086019186831090831117610b3b578187528316927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c1683146113d157507e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe993845c806113a15750915f92918380937f6370a85c000000000000000100000000000000000000000000000000000000008417885d51925af190611355614cb9565b911561139b5750505c908161136b575050600190565b6024925051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b81519101fd5b6024908751907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b807fe758b8d50000000000000000000000000000000000000000000000000000000060049252fd5b9193959697509193508051825d8b01908201918a969594928c949261121d565b608081101561145457730c0e5f2ff0ff18a3be9b835635039256dc4b496360145261d6945f526034536017601e20935b8793929189916111f6565b600863ffffffff8b60301c166114f3575b6001811b66ffffffffffffff8c60181c1610156114eb575b6001811b8210156114e3575b6001811b68ffffffffffffffff00891610156114db575b60031c90815280607f018953730c0e5f2ff0ff18a3be9b835635039256dc4b49635f528060d501600a536094600b53601601600a2093611449565b6008016114a0565b600801611489565b60100161147d565b5060288682036114655760118a634e487b715f52526024601cfd5b505050505f90565b9080601f830112156102135781602061153193359101610c69565b90565b90939291907fffffffff00000000000000000000000000000000000000000000000000000000167f5228831d0000000000000000000000000000000000000000000000000000000081036117355750830190610160848303126102135761159a84610aeb565b936115a88360208301610bf3565b926115b560a08301610aeb565b9060c08301359267ffffffffffffffff841161021357611730976001600160a01b0397611715976116148a61160c6116ac9a6116048960e06115fd6116be9c879f8d01611516565b9a01610bf3565b953691610c69565b9416826132ec565b6080529890936116a4611629898b16866132ec565b919e90917f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c90826040519461165e86610b84565b16845260208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8c9461479e565b6116b461337e565b9287871691614bae565b81604051936116cc85610b84565b16835260805160208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b6fffffffffffffffffffffffffffffffff6080511691614c42565b600190565b919392917f0dfeb4190000000000000000000000000000000000000000000000000000000081036117ad5750820160a083820312610213576117309361179d6001600160a01b036117956117a794602061178e89610aeb565b9801610bf3565b9516856132ec565b5050923691610c69565b9161479e565b92949193927f9ebf8e8d0000000000000000000000000000000000000000000000000000000003611d735784019360e081860312610213576117ee81610aeb565b9260208201359067ffffffffffffffff82116102135761160461181688611820948601611516565b9760408501610bf3565b80516089019485608911611b3a57602091601f1961185661184089610c4d565b9861184e6040519a8b610bd0565b808a52610c4d565b013684890137815183015187604801526040828401886068015e5f8760a8015380519083018760a9015e5101515f937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211611b285795905b815190602c8210611aae57866014840151601585015197601886015190602c87015194838690879c6001600160a01b0389166001600160a01b0388161015611d68575b60ff1680611c2057506001600160a01b039161196f91731f98431c8ad98523631ae4a59f267346ea31f9847fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33985b62ffffff16906040519387165f528616602052806040521560051b6060035f2091604052613578565b1691855190858760280152866014015285528c602c88115f14611b8c5750611a0e6001600160a01b0393878594611a09611a1d956119fb6040519b8c9586938d8c8084169116105f14611b6e578d8c806401000276a4945b7f128acb080000000000000000000000000000000000000000000000000000000060208a0152169116103060248701614768565b03601f198101845283610bd0565b613468565b60208082518301019101611deb565b9590946040525b1691161015611b6757505b7f80000000000000000000000000000000000000000000000000000000000000008114611b3a575f03945f8612611b2857602c86921115611ac05750503093906018815110611aae5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906118af565b634e487b715f5260326020526024601cfd5b939650935050925060c08301358210611adb57505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260c0929092013560248301526044820152606490fd5b634e487b715f5260116020526024601cfd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9050611a2f565b8d8c8073fffd8963efd1fc6a506488495d951d5263988d25946119c7565b926001600160a01b03611bfc93611a09896119fb849b9a8a611a0e98879b888616898416105f14611c0457886401000276a4935b816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c015216911610911660248701614768565b949093611a24565b8873fffd8963efd1fc6a506488495d951d5263988d2593611bc0565b60018103611c7857506001600160a01b039161196f917341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c97f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7598611946565b60028103611cd057506001600160a01b039161196f9173baceb8ec6b9355dfc0269c18bac9d6e2bdc29c4f7fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e3398611946565b9091929394959650600381145f14611d37575061196f8d96959493926001600160a01b03927370fe4a44ea505cfa3a57b95cf2862d4fd5f0f6877fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c98611946565b602490604051907fd3b1276d0000000000000000000000000000000000000000000000000000000082526004820152fd5b8692508891506118f2565b50925050505f90565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b606061153194936001600160a01b0360c094168352805160208401526020810151151560408401526040810151151582840152015160030b60808201528160a08201520190611d7c565b9190826040910312610213576020825192015190565b51906001600160a01b038216820361021357565b919091611e238284836135a7565b15611e3057505050600190565b82907fffffffff00000000000000000000000000000000000000000000000000000000167fe12b0f130000000000000000000000000000000000000000000000000000000081036123a8575060a0918101031261021357611e9081610aeb565b602091611e9e838201610aeb565b90604092838201356060830135916001600160a01b039384841680940361021357611ecc6080869201610c9f565b91169015612253578551966370a0823160e01b885260049230848a0152736b175474e89094c44da98b954eedeac495271d0f9882816024818d5afa9081156121aa575f91612224575b5061271091611f2391614736565b04978751967ffae036d500000000000000000000000000000000000000000000000000000000885282888681895afa9788156121aa575f986121f5575b508290858a51809981937f313ce567000000000000000000000000000000000000000000000000000000008352165afa9586156121eb575f966121b4575b5087517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230858201528560248201528281604481855afa9081156121aa575f9161217d575b5089811061208d575b505050823b15610213575f9461205e670de0b6b3a764000093879360ff978a519b8c998a9889977f8d7ef9bb000000000000000000000000000000000000000000000000000000008952019216600a0a0204918401602090939291936001600160a01b0360408201951681520152565b03925af19081156120845750612075575b50600190565b61207e90610ba0565b5f61206f565b513d5f823e3d90fd5b612121575b905f604481938a519485917f095ea7b300000000000000000000000000000000000000000000000000000000835289898401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561211957503d15601f3d1160015f511416171561210d575f8080611fee565b50633e3f8f735f52601cfd5b3d5f823e3d90fd5b87517f095ea7b300000000000000000000000000000000000000000000000000000000815285858201525f6024820152825f60448382865af11561211957503d15601f3d1160015f511416176120925783633e3f8f735f52601cfd5b90508281813d83116121a3575b6121948183610bd0565b8101031261021357515f611fe5565b503d61218a565b89513d5f823e3d90fd5b9095508181813d83116121e4575b6121cc8183610bd0565b81010312610213576121dd90614728565b945f611f9e565b503d6121c2565b88513d5f823e3d90fd5b9097508281813d831161221d575b61220d8183610bd0565b8101031261021357519682611f60565b503d612203565b90508281813d831161224c575b61223b8183610bd0565b810103126102135751612710611f15565b503d612231565b9392866024918798949851928380926370a0823160e01b825230600483015288165afa90811561236f575f91612379575b506127109161229291614736565b049184517f01664f6600000000000000000000000000000000000000000000000000000000815282816004818a5afa92831561236f57916122de939185935f93612340575b5050614fc2565b833b156102135782517f959912760000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152915f908390604490829084905af190811561208457506120755750600190565b612360929350803d10612368575b6123588183610bd0565b810190614749565b905f806122d7565b503d61234e565b86513d5f823e3d90fd5b90508281813d83116123a1575b6123908183610bd0565b810103126102135751612710612284565b503d612386565b7f67848fe7000000000000000000000000000000000000000000000000000000008103612782575060c09181010312610213576123e481610aeb565b6020906123f2828401610aeb565b9160409283850135946060810135916001600160a01b03908184168094036102135760a061242260808501610c9f565b930135975f908061271b575b50878161270657869150916024849351809481936370a0823160e01b8352896004840152165afa9081156126fc575f916126cf575b5086517f1865c57d0000000000000000000000000000000000000000000000000000000081526101208082600481895afa9182156121aa579089949392915f926125d1575b50506fffffffffffffffffffffffffffffffff809188875f146125c9575051165b169003955b83156125a357637fffffff5b8351976124e689610b84565b8852841515878901525f8489015260030b6060880152612541835161250a81610bb4565b5f8152845198899485947f3eece7db0000000000000000000000000000000000000000000000000000000086521660048501611da1565b03815f865af1938415612599575f94612568575b50858410610f2a57505050505050600190565b612589919450853d8711612592575b6125818183610bd0565b810190611deb565b9050925f612555565b503d612577565b85513d5f823e3d90fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff800000006124da565b0151166124c9565b818096508193503d83116126c8575b6125ea8183610bd0565b8101031261021357885193840184811067ffffffffffffffff821117610b3b578952612615816146f0565b84526126228782016146f0565b8785015261263189820161470d565b898501526126416060820161470d565b6060850152608081015164ffffffffff8116810361021357608085015260a08101518060030b81036102135760a085015261267e60c0820161471b565b60c085015260e081015163ffffffff8116810361021357846fffffffffffffffffffffffffffffffff92839260e08d9801526126be610100809201614728565b90820152916124a8565b503d6125e0565b90508481813d83116126f5575b6126e68183610bd0565b8101031261021357515f612463565b503d6126dc565b87513d5f823e3d90fd5b929181866127169299939961326f565b6124ce565b88516370a0823160e01b8152306004820152915086826024818688165afa80156121aa575f90612753575b612710925002045f61242e565b508682813d831161277b575b6127698183610bd0565b81010312610213576127109151612746565b503d61275f565b7fca9e5d0f000000000000000000000000000000000000000000000000000000008103612ae3575060c09181010312610213576127be81610aeb565b9060206127cc818301610aeb565b9160409283820135916060810135916001600160a01b0393848416809403610213578460a06127fd60808601610c9f565b9401359816948682612a60575b505050505f14612957578351917fdd93f59a000000000000000000000000000000000000000000000000000000008352600483015282826024815f855af1918215610ff8575f92612928575b50848210612868575050505050600190565b826004918551928380927f4a248d2a0000000000000000000000000000000000000000000000000000000082525afa928315610ff8575f936128ef575b505091517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260248101929092526044820152606490fd5b90809350813d8311612921575b6129068183610bd0565b810103126102135761291a61087492611e01565b91856128a5565b503d6128fc565b9091508281813d8311612950575b6129408183610bd0565b810103126102135751905f612856565b503d612936565b8351917fbd6015b4000000000000000000000000000000000000000000000000000000008352600483015282826024815f855af1918215610ff8575f92612a31575b508482106129ab575050505050600190565b826004918551928380927fd4b970460000000000000000000000000000000000000000000000000000000082525afa928315610ff8575f936128ef57505091517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260248101929092526044820152606490fd5b9091508281813d8311612a59575b612a498183610bd0565b810103126102135751905f612999565b503d612a3f565b6024918951928380926370a0823160e01b825230600483015287165afa9081156121eb5790859392915f91612aae575b50612aa59391612a9f91614f3f565b9161326f565b5f80808661280a565b809450888092503d8311612adc575b612ac78183610bd0565b81010312610213579151849290612aa5612a90565b503d612abd565b7fb8df6d4d0000000000000000000000000000000000000000000000000000000014159050613269578160a0918101031261021357612b2181610aeb565b90602091604090818301356001600160a01b039384821680920361021357612b4b60608201610c9f565b9260808201359185516370a0823160e01b8152888160248160049b308d83015287165afa9081156126fc579089915f9161323a575b5081612b8f9293013590614f3f565b94612b9b868685614fc2565b156131ee5750845160e0810181811067ffffffffffffffff8211176131c25786525f81528781015f8152868201905f825260608301905f825260808401915f835260a08501905f825260c086015f81528c8c8b8151928380927fffa642250000000000000000000000000000000000000000000000000000000082525afa80156130c4578f908f928f908e925f915f916131a3575b508852895251928380927f17be952e0000000000000000000000000000000000000000000000000000000082525afa80156130c4578f5f9161316d575b5060ff915016600381101561306a5781528b517f796da7af0000000000000000000000000000000000000000000000000000000081528e818f818e5afa9081156130c4578f908f928f908e925f91613138575b508b5251928380927f7c9b8e890000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f908f928f908e925f91613103575b50865251928380927feab5d20e0000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f908f928f908e925f916130ce575b508a5251928380927fec2fd46d0000000000000000000000000000000000000000000000000000000082525afa9081156130c4578f5f92613096575b505084528051600381101561306a57612f7957505050505050612da59085615317565b8551907fc0ffa17800000000000000000000000000000000000000000000000000000000825288828981885afa9182156126fc575f92612f4a575b508651917fab44a7a300000000000000000000000000000000000000000000000000000000835289838a81895afa9081156121eb575f91612f19575b612e35935001670de0b6b3a76400009081019102614d2f565b91808310612eca575050908592915f855196612e5088610bb4565b818852612e898751988996879586947fe67ce70600000000000000000000000000000000000000000000000000000000865285016146d4565b03925af19081156120845750612ea1575b5050600190565b813d8311612ec3575b612eb48183610bd0565b81010312610213575f80612e9a565b503d612eaa565b61087483889288519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865285016040919493926001600160a01b03606083019616825260208201520152565b90508983813d8311612f43575b612f308183610bd0565b8101031261021357612e35925190612e1c565b503d612f26565b9091508881813d8311612f72575b612f628183610bd0565b810103126102135751905f612de0565b503d612f58565b51600381101561303e57600103612fbc575050612f9a612fb4939451614ce8565b915190670de0b6b3a7640000898651925194020491615390565b905103612da5565b919290935190519003835182519003808a11155f146130275750509161300f93918389612fee95510194859451614ce8565b9251905191519061301583670de0b6b3a76400008099819885839602614d2f565b0261542a565b82020490840301930302040204612da5565b915093915061303892508703615317565b01612da5565b60218d7f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b60218e7f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b90809250813d83116130bd575b6130ad8183610bd0565b8101031261021357515f8f612d82565b503d6130a3565b8d513d5f823e3d90fd5b945050505081813d83116130fc575b6130e78183610bd0565b81010312610213578e8b8f928f90515f612d46565b503d6130dd565b945050505081813d8311613131575b61311c8183610bd0565b81010312610213578e8b8f928f90515f612d03565b503d613112565b945050505081813d8311613166575b6131518183610bd0565b81010312610213578e8b8f928f90515f612cc0565b503d613147565b905081813d831161319c575b6131838183610bd0565b810103126102135761319660ff91614728565b8f612c6d565b503d613179565b90506131bc9150823d8411612592576125818183610bd0565b5f612c30565b6041887f4e487b71000000000000000000000000000000000000000000000000000000005f525260245ffd5b9390505f85939293519661320188610bb4565b818852612e898751988996879586947f8dae733300000000000000000000000000000000000000000000000000000000865285016146d4565b82819392503d8311613262575b6132518183610bd0565b810103126102135751889081612b80565b503d613247565b50505f90565b60446020925f80936001600160a01b03966040519788947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af11561211957503d15601f3d1160015f51141617156132d057565b6390b8ec185f526004601cfd5b5f80809381935af1156108f357565b60405192916132fa84610b1f565b60208401915f8352846001600160a01b03809316905260208151015180935251511691565b6040519061332c82610b68565b602e82527f696e7432353620616d6f756e74290000000000000000000000000000000000006040837f546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c7560208201520152565b60405161338a81610b84565b60588152611531603c60208301927f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7484527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c60408201527f626f6f6c207061727469616c46696c6c416c6c6f7765642900000000000000006060820152602061341161331f565b6040519586937f436f6e73696465726174696f6e20636f6e73696465726174696f6e2900000000848601525180918686015e8301908482015f8152815193849201905e015f8382015203601c810184520182610bd0565b6001600160a01b03809116907f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c168114610a6d577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe992835c8061354757509181740300000000000000000000000000000000000000005f9493859460e01b1717855d82602083519301915af1906134fd614cb9565b911561353e575c8061350d575090565b602490604051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b50602081519101fd5b602490604051907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b9160406055938151908152600b81019360ff8553602082015201522090565b359062ffffff8216820361021357565b9091907fffffffff00000000000000000000000000000000000000000000000000000000167fc1fb425e0000000000000000000000000000000000000000000000000000000081036136565750810160c0828203126102135761360982610aeb565b906136178160208501610bf3565b9060a084013567ffffffffffffffff81116102135761364661364e926001600160a01b03926117309701611516565b9316826132ec565b50509061479e565b7fd92aadfb0000000000000000000000000000000000000000000000000000000081036138a657508101610120828203126102135761369482610aeb565b916020926136a483858401610bf3565b6136b060a08401610aeb565b9360c08401359067ffffffffffffffff8211610213576136d1918501611516565b916101006136e160e08601610aeb565b9401356136fb6001600160a01b03808098169316846132ec565b969091926137586040938a85519161371283610b84565b168152898c820152868582015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9760248b6137d78c8616809d7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c89519261379284610b84565b83528785840152168882015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8651928380926370a0823160e01b82523060048301525afa94851561208457505f94613863575b509361384484878c95856117309f9b98996138529b976fffffffffffffffffffffffffffffffff9e9b9511613859575b908461383a92615288565b809b86015261326f565b61384c61337e565b93614bae565b1691614c42565b909350839061382f565b95919a809794508681999692993d831161389f575b6138828183610bd0565b8101031261021357945195999396929590949390926138446137ff565b503d613878565b9192917f8d68a156000000000000000000000000000000000000000000000000000000008103613df657508201608083820312610213576138e683610aeb565b9060408401359067ffffffffffffffff821161021357613907918501611516565b9160246020845181860151907fffffffffffffffffffffffffffffffffffffffff000000000000000000000000918281169160148110613de1575b50509050604051928380926370a0823160e01b825230600483015260601c5afa9081156108f3575f91613dad575b5061398361271091602087013590614736565b04936040519361399285610b68565b6028855260403660208701379430937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211611b285795905b815190602c8210611aae57866014840151601585015197601886015190602c87015194838690879c6001600160a01b0389166001600160a01b0388161015613da2575b60ff1680613c8b57506001600160a01b0391613a8a91731f98431c8ad98523631ae4a59f267346ea31f9847fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e339862ffffff16906040519387165f528616602052806040521560051b6060035f2091604052613578565b1691855190858760280152866014015285528c602c88115f14613c145750611a0e6001600160a01b0393878594611a09613b14956119fb6040519b8c9586938d8c8084169116105f14611b6e577f128acb080000000000000000000000000000000000000000000000000000000060208601526401000276a4918c168c8f16103060248701614768565b9590946040525b1691161015613c0d57505b7f80000000000000000000000000000000000000000000000000000000000000008114611b3a575f03945f8612611b2857602c86921115613ba55750503093906018815110611aae5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906139cb565b939650935050925060608301358210613bc057505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526060929092013560248301526044820152606490fd5b9050613b26565b926001600160a01b03613c8393611a09896119fb849b9a8a611a0e98879b888616898416105f14611c0457886401000276a493816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c015216911610911660248701614768565b949093613b1b565b60018103613ce357506001600160a01b0391613a8a917341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c97f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7598611946565b60028103613d3b57506001600160a01b0391613a8a9173baceb8ec6b9355dfc0269c18bac9d6e2bdc29c4f7fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e3398611946565b9091929394959650600381145f14611d375750613a8a8d96959493926001600160a01b03927370fe4a44ea505cfa3a57b95cf2862d4fd5f0f6877fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c98611946565b869250889150613a0e565b90506020813d602011613dd9575b81613dc860209383610bd0565b810103126102135751613983613970565b3d9150613dbb565b8391925060140360031b1b1616805f80613942565b92837f103b48be00000000000000000000000000000000000000000000000000000000829495145f14614156575060c0918101031261021357613e3881610aeb565b602091613e46838201610aeb565b916040918281013590613e5b60608201610aeb565b9060a0613e6a60808301613597565b910135926001600160a01b03808098169316926001908180851614935f92846140e3575b8394508951936140ad575b630902f1ac5f52895f6004601c8a5afa156140a457893d10610213578b8b928760051b9687519288811851948084811c1614821517614057575b506060955061ffff6127109260081c1682030292028201910204975f601c8d8187019763022c0d9f88526080808901528360a08901528c82828a0101526004011886010152169101525f8060a48382875af1156121195750828410613f3e5750505050505050600190565b600491879115613ff3578551928380927fd21220a70000000000000000000000000000000000000000000000000000000082525afa908115610ff8576108749495965f92613fd6575b5050935b519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865216600485016040919493926001600160a01b03606083019616825260208201520152565b613fec9250803d10612368576123588183610bd0565b8680613f87565b8551928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa908115610ff8576108749495965f9261403a575b505093613f8b565b6140509250803d10612368576123588183610bd0565b8680614032565b9294505091936024601c5f926370a0823184528b85525afa156140a4578b3d10610213575f51838110614093579183916060948d94038e613ed3565b60118d634e487b715f52526024601cfd5b833d5f823e3d90fd5b63a9059cbb8452868c850152848a8501528b5f6044601c870182875af1156140a457805f51148c3d1015163d1517613e99575f80fd5b9250928851906370a0823160e01b82523060048301528b82602481865afa801561414c575f9061411d575b61271092500204918390613e8e565b508b82813d8311614145575b6141338183610bd0565b8101031261021357612710915161410e565b503d614129565b8a513d5f823e3d90fd5b7f38c9c1470000000000000000000000000000000000000000000000000000000081036141df5750019060a0818303126102135761419381610aeb565b906141a060408201610aeb565b90608081013567ffffffffffffffff811161021357611730946141c4918301611516565b9260206001600160a01b036060840135941692013590614d39565b7ff5b991890000000000000000000000000000000000000000000000000000000081036145a9575060a091810103126102135761421b81610aeb565b906040810135916001600160a01b03928381168091036102135761424160608401613597565b6040517f392f37e9000000000000000000000000000000000000000000000000000000008152936001808316149160e086600481875afa9081156108f3575f91885f985f935f945f9b5f935f9661452e575b50878197839781969f6142a590614c85565b8c15614519575b50505050505f91602088013561449f575b8983158d858215938461448e575b50505090614480575b61440f575b61432193508686670de0b6b3a76400008099818099020493020495869461271061ffff838089800204818880020401818a89020402049660081c168202049003020401615149565b9003020494608082013586106143c0575050156143ba575f925b60405161434781610bb4565b5f8152823b15610213575f946143a68692604051988997889687957f022c0d9f00000000000000000000000000000000000000000000000000000000875260048701526024860152166044840152608060648401526084830190611d7c565b03925af180156108f3576120755750600190565b5f61433b565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260809190910135602482015260448101859052606490fd5b915060208b60248b60405196879384926370a0823160e01b84526004840152165afa80156108f35784905f9061444a575b8d945003916142d9565b50506020833d602011614478575b8161446560209383610bd0565b8101031261021357836143219351614440565b3d9150614458565b5060018083811c16146142d4565b6144979261326f565b8d858d6142cb565b915060208b6024604051809681936370a0823160e01b8352306004840152165afa80156108f3578c935f916144e1575b506127109060208901350204916142bd565b9350506020833d602011614511575b816144fd60209383610bd0565b81010312610213576127108c9351906144cf565b3d91506144f0565b9e509198509650945091505f808080806142ac565b9c50505094505050505060e0863d60e0116145a1575b8161455160e09383610bd0565b81010312610213578580519188602083015193604084015192606085015161459360c061458c60a061458560808b0161471b565b9901611e01565b9d01611e01565b92969490959b92945f614293565b3d9150614544565b7fc876d21d0000000000000000000000000000000000000000000000000000000014159050613269578160609181010312610213576145e781610aeb565b60406145f560208401610aeb565b920135906001600160a01b038091169083169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee84145f1461464d57504792509080831161463a575b505050600190565b6146459203906132dd565b5f8080614632565b916020602494604051958680926370a0823160e01b82523060048301525afa9384156108f3575f946146a0575b5080841161468c575b50505050600190565b61469793039161326f565b5f808080614683565b9093506020813d6020116146cc575b816146bc60209383610bd0565b810103126102135751925f61467a565b3d91506146af565b6115319392606092825260208201528160408201520190611d7c565b51906fffffffffffffffffffffffffffffffff8216820361021357565b51908160070b820361021357565b5190811515820361021357565b519060ff8216820361021357565b81810292918115918404141715611b3a57565b9081602091031261021357516001600160a01b03811681036102135790565b919360a09361153196956001600160a01b0380941685521515602085015260408401521660608201528160808201520190611d7c565b9190917f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa5f815c915d8015610a6d5761490a937f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c906040519361480185610b84565b605b8552614905604660208701967f536c697070616765416e64416374696f6e73286164647265737320726563697088527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d6960408201527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060820152602061488861331f565b604051998a937f536c697070616765416e64416374696f6e7320736c697070616765416e644163848601527f74696f6e7329000000000000000000000000000000000000000000000000000060408601525180918686015e8301908482015f8152815193849201905e015f83820152036026810188520186610bd0565b614bae565b565b9291907f1643bf8e9fdaef48c4abf5a998de359be44a235ac7aebfbc05485e093720deaa935f855c955d8415610a6d577f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c7f74696f6e73290000000000000000000000000000000000000000000000000000604095614a6c6046886020815161499581610b84565b605b81528181017f536c697070616765416e64416374696f6e73286164647265737320726563697081527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d69848301527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060830152614a1261331f565b9184519889957f536c697070616765416e64416374696f6e7320736c697070616765416e644163868801528601525180918686015e8301908482015f8152815193849201905e015f83820152036026810185520183610bd0565b614b85576e22d473030f116ddee9f6b43ac78ba392833b1561021357614b695f96614b388894614b199b6001600160a01b038c9889519e8f9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c52614aed60048d018251602080916001600160a01b0381511684520151910152565b60208181015160448e015291015160648c015281516001600160a01b031660848c0152015160a48a0152565b1660c487015260e4860152610140610104860152610144850190611d7c565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc84830301610124850152611d7c565b03925af19081156120845750614b7c5750565b61490a90610ba0565b600486517f1c500e5c000000000000000000000000000000000000000000000000000000008152fd5b91909294936e22d473030f116ddee9f6b43ac78ba392833b1561021357614c315f96614b388894614b199a6001600160a01b0360409889519d8e9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c52614aed60048d018251602080916001600160a01b0381511684520151910152565b03925af180156108f357614b7c5750565b9190917f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a75982765f526020526040519160405260605f20916040526010525f5260305fa0565b15614c8c57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b3d15614ce3573d90614cca82610c4d565b91614cd86040519384610bd0565b82523d5f602084013e565b606090565b8015614d02576ec097ce7bc90715b34b9f10000000000490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8115614d02570490565b9291906001600160a01b03808316946e22d473030f116ddee9f6b43ac78ba38614610a6d575f91811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614e6157505050614d8a9047614f3f565b938051155f14614de5575050614dbb575f80809381935af1614daa614cb9565b9015614db35750565b602081519101fd5b60046040517f01da1572000000000000000000000000000000000000000000000000000000008152fd5b90939260208301808411611b3a57825110611aae57835f9460208695850101525b602083519301915af1614e17614cb9565b9015614db35751159081614e57575b50614e2d57565b60046040517f82d5d76a000000000000000000000000000000000000000000000000000000008152fd5b90503b155f614e26565b9091949281979497155f14614e8057505050614dbb575f928392614e06565b604096959496939293516370a0823160e01b81523060048201526020918282602481875afa80156108f3575f90614f10575b614ebc9250614f3f565b92818101808211611b3a57885110614eff57865f9896949293838a9997958c948a01015203614eee575b505050614e06565b614ef792614fc2565b5f8087614ee6565b603282634e487b715f52526024601cfd5b508282813d8311614f38575b614f268183610bd0565b8101031261021357614ebc9151614eb2565b503d614f1c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff828209828202918280831092039180830391612710958691099282861115611b285714614fbc577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919350828211900360fc1b910360041c170290565b50500490565b916001600160a01b039182916040519384927fdd62ed3e0000000000000000000000000000000000000000000000000000000084523060048501521692836024840152826044602096879389165afa9182156108f3575f9261511a575b50811061502d575b50505050565b6150bb575b60445f91826040519586927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561211957503d15601f3d1160015f51141617156150ae575f808080615027565b633e3f8f735f526004601cfd5b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081528160048201525f6024820152825f60448382885af11561211957503d15601f3d1160015f5114161761503257633e3f8f735f526004601cfd5b9091508381813d8311615142575b6151328183610bd0565b810103126102135751905f61501f565b503d615128565b929091670de0b6b3a7640000918285800204948381870204955f935b60ff85106151975760046040517f481b61af000000000000000000000000000000000000000000000000000000008152fd5b85818002048789886003878286890181898402040204958587105f1461521957020204018883830302049182156151d8575b505060019101945b0193615165565b14905061520e57600180820188888083800204860181848902040204116152015750875f6151c9565b9750505050509350505090565b955050509350505090565b02020401888284030204918215615237575b505060019103946151d1565b149050801561524e575b61520e576001875f61522b565b5086867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8301818082800204860191870204020410615241565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff828409818385029384808410930395099080851461530f5782805f0316809304600280826003021880830282030280830282030280830282030280830282030280830282030280920290030294600184805f0304019185841191030302920304170290565b505091500490565b90615346906153268151614ce8565b90670de0b6b3a76400006080820194602086519301519302049080615390565b90510390565b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000903581811693926014811061538157505050565b60140360031b82901b16169150565b90919392670de0b6b3a76400009182818302040294826153b08588614d2f565b92810394850204910190818110155f1461541f570381600191955b8460021b02048580020194600186811c019186925b83811061540957506115319596505f146154015701915b60011b910261542a565b9003916153f7565b9250826154168189614d2f565b0160011c6153e0565b9003815f91956153cb565b6154348282614d2f565b91820214611531576001019056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
3ae13a6a1d3eea900d733ebc1d1ba9d772e6b415000000000000000000000000
-----Decoded View---------------
Arg [0] : gitCommit (bytes20): 0x3ae13a6a1d3eea900d733ebc1d1ba9d772e6b415
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 3ae13a6a1d3eea900d733ebc1d1ba9d772e6b415000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Loading...
Loading
[ 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.