Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 6,973 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Execute | 20413924 | 35 days ago | IN | 0 ETH | 0.00270334 | ||||
Execute | 20413917 | 35 days ago | IN | 0 ETH | 0.00068287 | ||||
Execute | 20413913 | 35 days ago | IN | 0 ETH | 0.00218206 | ||||
Execute | 20413912 | 35 days ago | IN | 0 ETH | 0.00084307 | ||||
Execute | 20413902 | 35 days ago | IN | 0 ETH | 0.00068263 | ||||
Execute | 20413892 | 35 days ago | IN | 0.003 ETH | 0.00046961 | ||||
Execute | 20413883 | 35 days ago | IN | 0 ETH | 0.0008758 | ||||
Execute | 20413878 | 35 days ago | IN | 0 ETH | 0.00077567 | ||||
Execute | 20413860 | 35 days ago | IN | 0 ETH | 0.00063579 | ||||
Execute | 20413859 | 35 days ago | IN | 1 ETH | 0.00047806 | ||||
Execute | 20413838 | 35 days ago | IN | 0.035 ETH | 0.00044565 | ||||
Execute | 20413833 | 35 days ago | IN | 0 ETH | 0.00262942 | ||||
Execute | 20413827 | 35 days ago | IN | 0.2 ETH | 0.00109029 | ||||
Execute | 20413823 | 35 days ago | IN | 0.11 ETH | 0.00071096 | ||||
Execute | 20413805 | 35 days ago | IN | 6.2626625 ETH | 0.00052454 | ||||
Execute | 20413804 | 35 days ago | IN | 0 ETH | 0.00137613 | ||||
Execute | 20413794 | 35 days ago | IN | 0 ETH | 0.00073442 | ||||
Execute | 20413790 | 35 days ago | IN | 0 ETH | 0.00061301 | ||||
Execute | 20413788 | 35 days ago | IN | 8 ETH | 0.00071534 | ||||
Execute | 20413786 | 35 days ago | IN | 6.26500458 ETH | 0.00108503 | ||||
Execute | 20413783 | 35 days ago | IN | 1 ETH | 0.00046146 | ||||
Execute | 20413768 | 35 days ago | IN | 1 ETH | 0.00030724 | ||||
Execute | 20413734 | 35 days ago | IN | 0.00846104 ETH | 0.00072122 | ||||
Execute | 20413731 | 35 days ago | IN | 0.00846104 ETH | 0.00090012 | ||||
Execute | 20413720 | 35 days ago | IN | 0.1 ETH | 0.00059259 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
20459146 | 29 days ago | 0.00462031 ETH | ||||
20459146 | 29 days ago | 0.00462031 ETH | ||||
20459146 | 29 days ago | 0.00057337 ETH | ||||
20459146 | 29 days ago | 0.00057337 ETH | ||||
20413917 | 35 days ago | 0.18057658 ETH | ||||
20413917 | 35 days ago | 0.18057658 ETH | ||||
20413912 | 35 days ago | 0.09780849 ETH | ||||
20413912 | 35 days ago | 0.09780849 ETH | ||||
20413902 | 35 days ago | 0.17477661 ETH | ||||
20413902 | 35 days ago | 0.17477661 ETH | ||||
20413892 | 35 days ago | 0.003 ETH | ||||
20413883 | 35 days ago | 0.44306533 ETH | ||||
20413883 | 35 days ago | 0.44306533 ETH | ||||
20413878 | 35 days ago | 0.12727998 ETH | ||||
20413878 | 35 days ago | 0.12727998 ETH | ||||
20413860 | 35 days ago | 0.20831821 ETH | ||||
20413860 | 35 days ago | 0.20831821 ETH | ||||
20413859 | 35 days ago | 1 ETH | ||||
20413838 | 35 days ago | 0.035 ETH | ||||
20413827 | 35 days ago | 0.2 ETH | ||||
20413823 | 35 days ago | 0.11 ETH | ||||
20413805 | 35 days ago | 6.2626625 ETH | ||||
20413804 | 35 days ago | 1.56760408 ETH | ||||
20413804 | 35 days ago | 1.56760408 ETH | ||||
20413794 | 35 days ago | 0.11542865 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
MainnetSettler
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.8.25; import {SettlerBase} from "../SettlerBase.sol"; import {Settler} from "../Settler.sol"; import {SettlerMetaTxn} from "../SettlerMetaTxn.sol"; import {IERC20, IERC20Meta} from "../IERC20.sol"; import {IPSM, MakerPSM} from "../core/MakerPSM.sol"; import {CurveTricrypto} from "../core/CurveTricrypto.sol"; import {DodoV1} from "../core/DodoV1.sol"; import {FreeMemory} from "../utils/FreeMemory.sol"; import {ISettlerActions} from "../ISettlerActions.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {UnknownForkId} from "../core/SettlerErrors.sol"; import { uniswapV3MainnetFactory, uniswapV3InitHash, uniswapV3ForkId, IUniswapV3Callback } from "../core/univ3forks/UniswapV3.sol"; import { pancakeSwapV3Factory, pancakeSwapV3InitHash, pancakeSwapV3ForkId, IPancakeSwapV3Callback } from "../core/univ3forks/PancakeSwapV3.sol"; import { solidlyV3Factory, solidlyV3InitHash, solidlyV3ForkId, ISolidlyV3Callback } from "../core/univ3forks/SolidlyV3.sol"; // Solidity inheritance is stupid import {SettlerAbstract} from "../SettlerAbstract.sol"; import {AbstractContext} from "../Context.sol"; import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol"; abstract contract MainnetMixin is FreeMemory, SettlerBase, MakerPSM, CurveTricrypto, DodoV1 { 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, IERC20Meta gemToken, uint256 bps, IPSM psm, bool buyGem) = abi.decode(data, (address, IERC20Meta, uint256, IPSM, bool)); sellToMakerPsm(recipient, gemToken, bps, psm, buyGem); } else if (action == ISettlerActions.DODOV1.selector) { (IERC20 sellToken, uint256 bps, address dodo, bool quoteForBase, uint256 minBuyAmount) = abi.decode(data, (IERC20, uint256, address, 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 == 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) SettlerBase(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.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) SettlerBase(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_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(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20, IERC20Meta} from "./IERC20.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {Basic} from "./core/Basic.sol"; import {RfqOrderSettlement} from "./core/RfqOrderSettlement.sol"; import {UniswapV3Fork} from "./core/UniswapV3Fork.sol"; import {UniswapV2} from "./core/UniswapV2.sol"; import {SafeTransferLib} from "./vendor/SafeTransferLib.sol"; import {ISettlerActions} from "./ISettlerActions.sol"; import {TooMuchSlippage} from "./core/SettlerErrors.sol"; /// @dev This library omits index bounds/overflow checking when accessing calldata arrays for gas efficiency 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, 4) args.offset := add(args.offset, 4) } } } abstract contract SettlerBase is Basic, RfqOrderSettlement, UniswapV3Fork, UniswapV2 { using SafeTransferLib for IERC20; using SafeTransferLib for address payable; receive() external payable {} event GitCommit(bytes20 indexed); // When 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) { assert((gitCommit == bytes20(0)) == (block.chainid == 31337)); emit GitCommit(gitCommit); } 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.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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20, IERC20Meta} from "./IERC20.sol"; import {IERC721Owner} from "./IERC721Owner.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {Permit2PaymentTakerSubmitted} from "./core/Permit2Payment.sol"; import {Permit2PaymentAbstract} from "./core/Permit2PaymentAbstract.sol"; import {AbstractContext} from "./Context.sol"; import {AllowanceHolderContext} from "./allowanceholder/AllowanceHolderContext.sol"; import {CalldataDecoder, SettlerBase} from "./SettlerBase.sol"; import {UnsafeMath} from "./utils/UnsafeMath.sol"; import {ISettlerActions} from "./ISettlerActions.sol"; import {ActionInvalid} from "./core/SettlerErrors.sol"; abstract contract Settler is Permit2PaymentTakerSubmitted, SettlerBase { using UnsafeMath for uint256; using CalldataDecoder for bytes[]; constructor() { assert( block.chainid == 31337 || IERC721Owner(0x00000000000004533Fe15556B1E086BB1A72cEae).ownerOf(2) == address(this) ); } 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20, IERC20Meta} from "./IERC20.sol"; import {IERC721Owner} from "./IERC721Owner.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {Permit2PaymentMetaTxn} from "./core/Permit2Payment.sol"; import {Context, AbstractContext} from "./Context.sol"; import {CalldataDecoder, SettlerBase} from "./SettlerBase.sol"; import {UnsafeMath} from "./utils/UnsafeMath.sol"; import {ISettlerActions} from "./ISettlerActions.sol"; import {ConfusedDeputy, ActionInvalid} from "./core/SettlerErrors.sol"; abstract contract SettlerMetaTxn is Permit2PaymentMetaTxn, SettlerBase { using UnsafeMath for uint256; using CalldataDecoder for bytes[]; constructor() { assert( block.chainid == 31337 || IERC721Owner(0x00000000000004533Fe15556B1E086BB1A72cEae).ownerOf(3) == address(this) ); } 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address) external view returns (uint256); function transfer(address, uint256) external returns (bool); function transferFrom(address, address, uint256) external returns (bool); function approve(address, uint256) external returns (bool); function allowance(address, address) external view returns (uint256); event Transfer(address indexed, address indexed, uint256); event Approval(address indexed, address indexed, uint256); } interface IERC20Meta is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20, IERC20Meta} from "../IERC20.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; import {UnsafeMath} from "../utils/UnsafeMath.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; using SafeTransferLib for IERC20Meta; // 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, IERC20Meta 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); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20} from "../IERC20.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {UnsafeMath} from "../utils/UnsafeMath.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; import {Panic} from "../utils/Panic.sol"; import {AddressDerivation} from "../utils/AddressDerivation.sol"; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {ConfusedDeputy} from "./SettlerErrors.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); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.25; import {IERC20} from "../IERC20.sol"; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {TooMuchSlippage} from "./SettlerErrors.sol"; import {FullMath} from "../vendor/FullMath.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; // see below for explanation /* import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {AddressDerivation} from "../utils/AddressDerivation.sol"; import {ConfusedDeputy} from from "./SettlerErrors.sol"; */ interface IDodo { function init( address owner, address supervisor, address maintainer, address baseToken, address quoteToken, address oracle, uint256 lpFeeRate, uint256 mtFeeRate, uint256 k, uint256 gasPriceLimit ) external; function transferOwnership(address newOwner) external; function claimOwnership() external; 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 querySellBaseToken(uint256 amount) external view returns (uint256 receiveQuote); function queryBuyBaseToken(uint256 amount) external view returns (uint256 payQuote); function depositBaseTo(address to, uint256 amount) external returns (uint256); function withdrawBase(uint256 amount) external returns (uint256); function withdrawAllBase() external returns (uint256); function depositQuoteTo(address to, uint256 amount) external returns (uint256); function withdrawQuote(uint256 amount) external returns (uint256); function withdrawAllQuote() external returns (uint256); function _BASE_CAPITAL_TOKEN_() external returns (address); function _QUOTE_CAPITAL_TOKEN_() external returns (address); function _BASE_TOKEN_() external returns (address); function _QUOTE_TOKEN_() external returns (address); 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) { return target * d / ONE; } function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) { return (target * d).divCeil(ONE); } function divFloor(uint256 target, uint256 d) internal pure returns (uint256) { return target * ONE / d; } function divCeil(uint256 target, uint256 d) internal pure returns (uint256) { 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) { 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) { // 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) { // 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(IDodo 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_(); 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) { 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) { 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) { uint256 Q1 = state.Q + amount; uint256 i = DecimalMath.divFloor(DecimalMath.ONE, state.oraclePrice); return DodoMath._GeneralIntegrate(state.quoteTarget, Q1, state.Q, i, state.K); } } // see below for explanation /* interface IDodoCallee { function dodoCall(bool isBuyBaseToken, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external; } */ abstract contract DodoV1 is SettlerAbstract, DodoSellHelper { using FullMath for uint256; using SafeTransferLib for IERC20; function sellToDodoV1(IERC20 sellToken, uint256 bps, address dodo, bool quoteForBase, uint256 minBuyAmount) internal { uint256 sellAmount = sellToken.balanceOf(address(this)).mulDiv(bps, 10_000); sellToken.safeApproveIfBelow(dodo, sellAmount); if (quoteForBase) { uint256 buyAmount = dodoQuerySellQuoteToken(IDodo(dodo), sellAmount); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(sellToken, minBuyAmount, buyAmount); } IDodo(dodo).buyBaseToken(buyAmount, sellAmount, new bytes(0)); } else { IDodo(dodo).sellBaseToken(sellAmount, minBuyAmount, new bytes(0)); } } // In spite of the fact that DodoV1 pools have a callback function as // specified in `IDodoCallee` above, they don't actually support flash // swaps. The approve/transferFrom flow is completely mandatory. Therefore, // it is not possible to custody optimize using a VIP that spends the // taker's coupon as part of the callback. This code is maintained here as // an example of a way to obtain a trusted callback. /* using AddressDerivation for address; address private constant dodoDeployer = 0x5E5a7b76462E4BdF83Aa98795644281BdbA80B88; address private constant dodoPrototype = 0xF6A8E47daEEdDcCe297e7541523e27DF2f167BF3; // this is the ERC1167 runtime code bytes32 private constant dodoCodehash = keccak256(abi.encodePacked(hex"363d3d373d3d3d363d73", dodoPrototype, hex"5af43d82803e903d91602b57fd5bf3")); constructor() { assert(block.chainid == 1 || block.chainid == 31337); } function _dodoV1Callback(bytes calldata data) private returns (bytes memory) { require(data.length >= 0xa0); bool isBuyBaseToken; uint256 baseAmount; uint256 quoteAmount; assembly ("memory-safe") { isBuyBaseToken := calldataload(data.offset) if shr(0x01, isBuyBaseToken) { revert(0x00, 0x00) } baseAmount := calldataload(add(0x20, data.offset)) quoteAmount := calldataload(add(0x40, data.offset)) data.offset := add(data.offset, calldataload(add(0x60, data.offset))) data.length := calldataload(data.offset) data.offset := add(0x20, data.offset) } dodoCall(isBuyBaseToken, baseAmount, quoteAmount, data); return new bytes(0); } function dodoCall(bool quoteForBase, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) private { (ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, bool isForwarded) = abi.decode(data, (ISignatureTransfer.PermitTransferFrom, bytes, bool)); _transferFrom( permit, ISignatureTransfer.SignatureTransferDetails({ to: msg.sender, requestedAmount: quoteForBase ? quoteAmount : baseAmount }), sig, isForwarded ); } function sellToDodoV1VIP( uint64 deployerNonce, ISignatureTransfer.PermitTransferFrom memory permit, bytes memory sig, bool quoteForBase, uint256 minBuyAmount ) internal { // deriving the contract address from the factory nonce verifies the initcode conforms to ERC1167 address dodo = dodoDeployer.deriveContract(deployerNonce); // checking the codehash against the one computed from the prototype verifies the implementation if (dodo.codehash != dodoCodehash) { revert ConfusedDeputy(); } // now we know that we can trust `dodo` uint256 sellAmount = permit.permitted.amount; bytes memory callbackData = abi.encode(permit, sig, _isForwarded()); if (quoteForBase) { uint256 buyAmount = dodoQuerySellQuoteToken(IDodo(dodo), sellAmount); if (buyAmount < minBuyAmount) { revert TooMuchSlippage(permit.permitted.token, minBuyAmount, buyAmount); } callbackData = abi.encodeCall(IDodo.buyBaseToken, (buyAmount, sellAmount, callbackData)); } else { callbackData = abi.encodeCall(IDodo.sellBaseToken, (sellAmount, minBuyAmount, callbackData)); } _setOperatorAndCall(dodo, callbackData, uint32(IDodoCallee.dodoCall.selector), _dodoV1Callback); } */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; abstract contract FreeMemory { modifier DANGEROUS_freeMemory() { uint256 freeMemPtr; assembly ("memory-safe") { freeMemPtr := mload(0x40) } _; assembly ("memory-safe") { mstore(0x40, freeMemPtr) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.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 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 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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {IEIP712} from "./IEIP712.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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20} from "../IERC20.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();
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; address constant uniswapV3MainnetFactory = 0x1F98431c8aD98523631AE4a59f267346ea31F984; address constant uniswapV3SepoliaFactory = 0x0227628f3F023bb0B980b67D528571c95c6DaC1c; address constant uniswapV3BaseFactory = 0x33128a8fC17869897dcE68Ed026d694621f6FDfD; address constant uniswapV3BnbFactory = 0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7; address constant uniswapV3AvalancheFactory = 0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD; bytes32 constant uniswapV3InitHash = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; uint8 constant uniswapV3ForkId = 0; interface IUniswapV3Callback { function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; address constant pancakeSwapV3Factory = 0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9; bytes32 constant pancakeSwapV3InitHash = 0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2; uint8 constant pancakeSwapV3ForkId = 1; interface IPancakeSwapV3Callback { function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; address constant solidlyV3Factory = 0x70Fe4a44EA505cFa3A57b95cF2862D4fd5F0f687; bytes32 constant solidlyV3InitHash = 0xe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf; uint8 constant solidlyV3ForkId = 3; interface ISolidlyV3Callback { function solidlyV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {Permit2PaymentAbstract} from "./core/Permit2PaymentAbstract.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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {AbstractContext} from "../Context.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {InvalidOffset, ConfusedDeputy, InvalidTarget} from "./SettlerErrors.sol"; import {IERC20} from "../IERC20.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; import {FullMath} from "../vendor/FullMath.sol"; import {Panic} from "../utils/Panic.sol"; import {Revert} from "../utils/Revert.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(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20} from "../IERC20.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; import {FullMath} from "../vendor/FullMath.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)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20} from "../IERC20.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {UnsafeMath} from "../utils/UnsafeMath.sol"; import {Panic} from "../utils/Panic.sol"; import {SafeTransferLib} from "../vendor/SafeTransferLib.sol"; import {AddressDerivation} from "../utils/AddressDerivation.sol"; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {TooMuchSlippage} from "./SettlerErrors.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, poolId, token1); _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 inputToken, uint24 poolId, IERC20 outputToken) private pure returns (IUniswapV3Pool) { // address(keccak256(abi.encodePacked( // hex"ff", // factory, // keccak256(abi.encode(inputToken, outputToken, poolId)), // initHash // ))) (IERC20 token0, IERC20 token1) = inputToken < outputToken ? (inputToken, outputToken) : (outputToken, inputToken); 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 ); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {IERC20} from "../IERC20.sol"; import {UnsafeMath} from "../utils/UnsafeMath.sol"; import {Panic} from "../utils/Panic.sol"; import {TooMuchSlippage} from "./SettlerErrors.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, sellAmount ); } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.25; import {IERC20} from "../IERC20.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); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; interface IERC721Owner { function ownerOf(uint256) external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import { CallbackNotSpent, ConfusedDeputy, ForwarderNotAllowed, InvalidSignatureLen, PayerSpent, ReentrantCallback, ReentrantMetatransaction, ReentrantPayer, SignatureExpired, WitnessNotSpent } from "./SettlerErrors.sol"; import {SettlerAbstract} from "../SettlerAbstract.sol"; import {Permit2PaymentAbstract} from "./Permit2PaymentAbstract.sol"; import {Panic} from "../utils/Panic.sol"; import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol"; import {Revert} from "../utils/Revert.sol"; import {Context} from "../Context.sol"; import {AllowanceHolderContext} from "../allowanceholder/AllowanceHolderContext.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(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {Context} from "../Context.sol"; import {IAllowanceHolder} from "./IAllowanceHolder.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) revert(0x00, 0x01) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; 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) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; 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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {Panic} from "./Panic.sol"; import {UnsafeMath} from "./UnsafeMath.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) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {UnsafeMath} from "../utils/UnsafeMath.sol"; import {Panic} from "../utils/Panic.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); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; interface IEIP712 { function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; 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); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; 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); }
{ "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":"InvalidSignatureLen","type":"error"},{"inputs":[],"name":"InvalidTarget","type":"error"},{"inputs":[],"name":"PayerSpent","type":"error"},{"inputs":[{"internalType":"uint256","name":"callbackInt","type":"uint256"}],"name":"ReentrantCallback","type":"error"},{"inputs":[{"internalType":"address","name":"oldPayer","type":"address"}],"name":"ReentrantPayer","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"SignatureExpired","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes20","name":"","type":"bytes20"}],"name":"GitCommit","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[],"stateMutability":"pure","type":"function"},{"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"}],"name":"execute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040908082523461031d57806143ed803803809161001f8285610361565b833960209283918101031261031d57516001600160601b031981169081900361031d576100ee605b845161005281610332565b8181527f6e416d6f756e744f75742c62797465735b5d20616374696f6e732900000000006060868301927f536c697070616765416e64416374696f6e73286164647265737320726563697084527f69656e742c6164647265737320627579546f6b656e2c75696e74323536206d69898201520152207f615e8d716cef7295e75dd3f1f10d679914ad6d7759e8e9459f0109ef7524170114610384565b6101266100f961039f565b8381519101207f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa14610384565b6101ff835161013481610332565b604b81528381017f5266714f7264657228436f6e73696465726174696f6e206d616b6572436f6e7381527f696465726174696f6e2c436f6e73696465726174696f6e2074616b6572436f6e868301526a73696465726174696f6e2960a81b60608301526101d5856101a361039f565b9281895194859282840197518091895e8301908282015f8152815193849201905e015f83820152038084520182610361565b5190207f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a759827614610384565b617a6946149161021183831514610384565b8351917f16fbd3a71aa6d159973eb9ff1e1199f9fe242767e6f30ac662a492f92ac704115f80a282918315610290575b50509061025061027492610384565b60014614908182159283610289575b61026890610384565b91610281575b50610384565b51613fc890816104258239f35b90505f61026e565b508161025f565b6331a9108f60e11b81526002600482015290915081816024816d04533fe15556b1e086bb1a72ceae5afa918215610328575f926102e0575b50506001600160a01b03163014610250610274610241565b90809250813d8311610321575b6102f78183610361565b8101031261031d5751906001600160a01b038216820361031d57906102506102746102c8565b5f80fd5b503d6102ed565b84513d5f823e3d90fd5b608081019081106001600160401b0382111761034d57604052565b634e487b7160e01b5f52604160045260245ffd5b601f909101601f19168101906001600160401b0382119082101761034d57604052565b1561038b57565b634e487b7160e01b5f52600160045260245ffd5b604051906103ac82610332565b605882527f626f6f6c207061727469616c46696c6c416c6c6f7765642900000000000000006060837f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7460208201527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c6040820152015256fe608080604052600436109081156102e5575b5036156102e357346101f0577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe9905f825c925d7fffffffff000000000000000000000000000000000000000000000000000000005f35818116926102ce575b508083169116036101f0576001600160a01b0380821633036101f057366004116101f05760031936019160a01c61ffff1690816001146101f457506002146100de577f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffd5b6080116101f0576004356044359081600401356100fe8160248501613e51565b60601c91816014116101f0575f8113156101e657915b30810361017057506101506101589360387fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec3394019101613e51565b60601c612343565b6040516101648161086e565b5f81525b602081519101f35b9161017f6101e1949315613666565b6040519061018c826107d9565b33825260208201526101db6101a436602c86016108ad565b92608d8501356001169460ad7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff773693019101610923565b91613b1d565b610158565b5060243591610114565b5f80fd5b9160a09150036101f05760043590604435918060a01c8360a01c176101f0578161021f911615613666565b5f5c905f805d60019260015c5f60015d60025c905f60025d6040519360208560200160035c9860208a8901019988528960405260045b8a83106102bc57505050506102a8965060405193610272856107d9565b16835260643560208401526040519261028a84610822565b8352602083015260408201526102a033826134e6565b505090613b1d565b6040516102b48161086e565b5f8152610168565b805c83525f815d810191830191610255565b818093503660040360031b1b1616905f61006f565b005b5f3560e01c9081631fff991f1461033257506370a0823114610307575f610011565b346101f05760206003193601126101f0576004356001600160a01b038116036101f0575f805360015ffd5b600319360160a081126101f0576060136101f05767ffffffffffffffff80606435116101f0573660236064350112156101f05760643560040135116101f0576005903660246064356004013560051b6064350101116101f05733906d1ff3684f28c67538d4d072c227343314610797575b6001600160a01b0382161561076f57507f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde893916001600160a01b03835c168061073e5750816001600160a01b0316835d5f5b6064356004013581106106265750506004356001600160a01b0381168082036101f057602435916001600160a01b038316908184036101f05760443591821580159061061d575b610496575b50505050506001600160a01b03166001600160a01b03825c160361046c575f905d602060405160018152f35b60046040517f5149e795000000000000000000000000000000000000000000000000000000008152fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361052a57505047928184106104db5750506001600160a01b0392916104d1916123b1565b9083808080610440565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b0390fd5b60249492919350602090604051958680927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa938415610612575f946105de575b50808410610596575091610591916001600160a01b039493612343565b6104d1565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015260448101839052606490fd5b9093506020813d60201161060a575b816105fa6020938361088a565b810103126101f057519286610574565b3d91506105ed565b6040513d5f823e3d90fd5b5080151561043b565b602460643582841b01013560643501811580610717575b80156106f0575b1561065257506001016103f4565b604051917f3c74eed600000000000000000000000000000000000000000000000000000000835260048301527fffffffff00000000000000000000000000000000000000000000000000000000604482013516602483015260606044830152600319602482013501606483015281601f19601b6024608494600319828201350160488201878701375f60808383013587010152013501168101030190fd5b5060405161070e60031960248401350160488401604485013561157a565b90604052610644565b50604051610735600319602484013501604884016044850135610977565b9060405261063d565b602490604051907f7407c0f80000000000000000000000000000000000000000000000000000000082526004820152fd5b807fe758b8d50000000000000000000000000000000000000000000000000000000060049252fd5b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec013560601c91506103a3565b35906001600160a01b03821682036101f057565b6040810190811067ffffffffffffffff8211176107f557604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6060810190811067ffffffffffffffff8211176107f557604052565b6080810190811067ffffffffffffffff8211176107f557604052565b67ffffffffffffffff81116107f557604052565b6020810190811067ffffffffffffffff8211176107f557604052565b90601f601f19910116810190811067ffffffffffffffff8211176107f557604052565b8092910391608083126101f057604051906108c782610822565b60408294126101f057606060409182516108e0816107d9565b6108e9826107c5565b81526020820135602082015284528281013560208501520135910152565b67ffffffffffffffff81116107f557601f01601f191660200190565b92919261092f82610907565b9161093d604051938461088a565b8294818452818301116101f0578281602093845f960137010152565b9080601f830112156101f05781602061097493359101610923565b90565b919091610985828483610d8a565b1561099257505050600190565b7fffffffff00000000000000000000000000000000000000000000000000000000167f52efd15d0000000000000000000000000000000000000000000000000000000003610d8457810190610100818303126101f0576109f1816107c5565b90602090818101359269ffffffffffffffffffff841684036101f057604094610a1c818785016108ad565b9160c084013567ffffffffffffffff928382116101f057610a3e918601610959565b906001600160a01b0394838860101c16948860081c9580155f14610c8f575076d6940c0e5f2ff0ff18a3be9b835635039256dc4b4963805f526017600920938793929189915b6d1ff3684f28c67538d4d072c2273433145f5d8c82808501519160019260015d015160025d818401848351938401019260035d6004905b838110610c6f57505050505101518a5199898b01977fdd96994f00000000000000000000000000000000000000000000000000000000895260ff1660248c015260ff1660448b015260648a015260e00135608489015260a488015f905260c488015f90521660e48701526101048087017f6370a85c0000000000000000000000000000000000000000000000000000000090528652610140860191868310908311176107f5578187528316927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16831461076f57507e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe993845c80610c3f5750915f92918380937f6370a85c000000000000000100000000000000000000000000000000000000008417885d51925af190610bf361369a565b9115610c395750505c9081610c09575050600190565b6024925051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b81519101fd5b6024908751907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b9193959697509193508051825d8b01908201918a969594928c9492610abb565b6080811015610cca57730c0e5f2ff0ff18a3be9b835635039256dc4b496360145261d6945f526034536017601e20935b879392918991610a84565b600863ffffffff8b60301c16610d69575b6001811b66ffffffffffffff8c60181c161015610d61575b6001811b821015610d59575b6001811b68ffffffffffffffff0089161015610d51575b60031c90815280607f018953730c0e5f2ff0ff18a3be9b835635039256dc4b49635f528060d501600a536094600b53601601600a2093610cbf565b600801610d16565b600801610cff565b601001610cf3565b506028868203610cdb5760118a634e487b715f52526024601cfd5b50505f90565b9091907fffffffff00000000000000000000000000000000000000000000000000000000167f6d42ea47000000000000000000000000000000000000000000000000000000008103610fa25750810190610180818303126101f057610dee816107c5565b610dfb83602084016108ad565b610e0760a084016107c5565b9260c08101359467ffffffffffffffff958681116101f05781610e2b918401610959565b93610e398260e085016108ad565b916101608401359788116101f057610f42610f34966fffffffffffffffffffffffffffffffff96610e75610e8f94610f9d9c610f959901610959565b996001600160a01b039586958680931697889216846134e6565b9c9099610f1a610e9f85836134e6565b7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde893989192985c908260405194610ed48661083e565b16845260208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9e8f956d1ff3684f28c67538d4d072c22734331492613b1d565b610f3c6123cd565b9361354c565b60405192610f4f8461083e565b16825284602083015260408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b911691613623565b600190565b9192917f22ce6ede000000000000000000000000000000000000000000000000000000000361156757820190610100838303126101f057610fe2836107c5565b9060208401359367ffffffffffffffff948581116101f05784611006918301610959565b9461101485604084016108ad565b9460c08301359182116101f05761102c918301610959565b8051608901948560891161137857602091601f1961106261104c89610907565b9861105a6040519a8b61088a565b808a52610907565b013684890137815183015187604801526040828401886068015e6d1ff3684f28c67538d4d072c2273433148760a8015380519083018760a9015e5101515f937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116113665795905b815190602c82106112ec57866014840151601585015197601886015190602c8701519483928690879c6001600160a01b0389166001600160a01b038816101561155c575b60ff168061146857506001600160a01b03916055916040731f98431c8ad98523631ae4a59f267346ea31f984927fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33995b8088168389168082101561145e57505091905b62ffffff169083519288165f5287166020528083521560051b6060035f20938183528152600b81019360ff855360208201520152201691855190858760280152866014015285528c602c88115f146113ca575061124c6001600160a01b039387859461124761125b956112396040519b8c9586938d8c8084169116105f146113ac578d8c806401000276a4945b7f128acb080000000000000000000000000000000000000000000000000000000060208a015216911610306024870161349a565b03601f19810184528361088a565b61250a565b602080825183010191016134d0565b9590946040525b16911610156113a557505b7f80000000000000000000000000000000000000000000000000000000000000008114611378575f03945f861261136657602c869211156112fe57505030939060188151106112ec5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906110cb565b634e487b715f5260326020526024601cfd5b939650935050925060e0830135821061131957505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260e0929092013560248301526044820152606490fd5b634e487b715f5260116020526024601cfd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b905061126d565b8d8c8073fffd8963efd1fc6a506488495d951d5263988d2594611205565b926001600160a01b0361143a9361124789611239849b9a8a61124c98879b888616898416105f1461144257886401000276a4935b816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c01521691161091166024870161349a565b949093611262565b8873fffd8963efd1fc6a506488495d951d5263988d25936113fe565b9350919050611178565b600181036114c257506001600160a01b039160559160407341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c9927f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7599611165565b9091929394959650600381145f1461152b575060558d96959493926001600160a01b039260407370fe4a44ea505cfa3a57b95cf2862d4fd5f0f687927fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c99611165565b602490604051907fd3b1276d0000000000000000000000000000000000000000000000000000000082526004820152fd5b88955086925061110f565b505f9150565b359081151582036101f057565b919091611588828483612644565b1561159557505050600190565b82907fffffffff00000000000000000000000000000000000000000000000000000000167fe12b0f13000000000000000000000000000000000000000000000000000000008103611b3d575060a091810103126101f0576115f5816107c5565b9060209182820135906001600160a01b038083168093036101f05760409384810135916060820135918183168093036101f0576080611634910161156d565b931692156119d3578451927f70a082310000000000000000000000000000000000000000000000000000000084526004923084860152736b175474e89094c44da98b954eedeac495271d0f948881602481895afa908115611967575f916119a4575b50612710916116a49161344f565b04968651947ffae036d500000000000000000000000000000000000000000000000000000000865281868681875afa958615611967575f96611971575b50818596978996959651978880927f313ce5670000000000000000000000000000000000000000000000000000000082525afa958615611967575f96611938575b5087517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230858201528560248201528281604481855afa90811561192e575f91611901575b50898110611811575b505050823b156101f0575f946117e2670de0b6b3a764000093879360ff978a519b8c998a9889977f8d7ef9bb000000000000000000000000000000000000000000000000000000008952019216600a0a0204918401602090939291936001600160a01b0360408201951681520152565b03925af190811561180857506117f9575b50600190565b6118029061085a565b5f6117f3565b513d5f823e3d90fd5b6118a5575b905f604481938a519485917f095ea7b300000000000000000000000000000000000000000000000000000000835289898401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561189d57503d15601f3d1160015f5114161715611891575f8080611772565b50633e3f8f735f52601cfd5b3d5f823e3d90fd5b87517f095ea7b300000000000000000000000000000000000000000000000000000000815285858201525f6024820152825f60448382865af11561189d57503d15601f3d1160015f511416176118165783633e3f8f735f52601cfd5b90508281813d8311611927575b611918818361088a565b810103126101f057515f611769565b503d61190e565b89513d5f823e3d90fd5b611959919650823d8411611960575b611951818361088a565b810190613481565b945f611722565b503d611947565b88513d5f823e3d90fd5b939495508184813d831161199d575b61198a818361088a565b810103126101f0579251949392816116e1565b503d611980565b90508881813d83116119cc575b6119bb818361088a565b810103126101f05751612710611696565b503d6119b1565b949084939293517f70a082310000000000000000000000000000000000000000000000000000000081523060048201528281602481875afa908115611b04575f91611b0e575b5061271091611a279161344f565b049184517f01664f6600000000000000000000000000000000000000000000000000000000815282816004818a5afa928315611b045791611a73939185935f93611ad5575b5050613989565b833b156101f05782517f959912760000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152915f908390604490829084905af190811561180857506117f95750600190565b611af5929350803d10611afd575b611aed818361088a565b810190613462565b905f80611a6c565b503d611ae3565b86513d5f823e3d90fd5b90508281813d8311611b36575b611b25818361088a565b810103126101f05751612710611a19565b503d611b1b565b7fb8df6d4d0000000000000000000000000000000000000000000000000000000014159050610d84578160a091810103126101f057611b7b816107c5565b90611b88604082016107c5565b90611b956060820161156d565b906001600160a01b03906040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481868a165afa8015610612575f9061230f575b611bf39150602083013590613906565b92611c018484871688613989565b156122ba5760405160e0810181811067ffffffffffffffff8211176107f5576040525f81525f60208201525f60408201525f60608201525f60808201525f60a08201525f60c08201526040517fffa64225000000000000000000000000000000000000000000000000000000008152604081600481878a165afa8015610612575f915f91612281575b5060a083015260808201526040517f17be952e000000000000000000000000000000000000000000000000000000008152602081600481878a165afa80156106125760ff915f91612262575b5016600381101561216d5760c08201526040517f796da7af000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f91612230575b5081526040517f7c9b8e89000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f916121fe575b5060608201526040517feab5d20e000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f916121cc575b5060408201526040517fec2fd46d000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f9161219a575b50602082015260c0810151600381101561216d5761202257611e139084613dc1565b604051907fc0ffa178000000000000000000000000000000000000000000000000000000008252602082600481878a165afa918215610612575f92611fee575b50670de0b6b3a764000091820180831161137857604051907fab44a7a3000000000000000000000000000000000000000000000000000000008252602082600481898c165afa908115610612575f91611fb8575b611eb192506123c0565b9082810292818404149015171561137857611ecb91613e00565b9460808201358610611f6957505091611f2993915f60209460405194611ef08661086e565b828652604051978896879586937fe67ce70600000000000000000000000000000000000000000000000000000000855260048501613433565b0393165af1801561061257611f3e5750600190565b602090813d8311611f62575b611f54818361088a565b810103126101f0575f6117f3565b503d611f4a565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260809190910135602482015260448101859052606490fd5b90506020823d602011611fe6575b81611fd36020938361088a565b810103126101f057611eb1915190611ea7565b3d9150611fc6565b9091506020813d60201161201a575b8161200a6020938361088a565b810103126101f05751905f611e53565b3d9150611ffd565b60c0810151600381101561216d576001036120815780604061207461204a61207c9451613e37565b608084015190670de0b6b3a76400006120678a868801519361344f565b0490602086015192613e95565b910151613b10565b611e13565b6120946040820151608083015190613b10565b6120a760a0830151606084015190613b10565b808611612151575050806120c28560606121009401516123c0565b6120cc8251613e37565b9161210d60a0820151926121086020606085015194015195670de0b6b3a76400009788916120fa8786613b10565b9061344f565b04948061344f565b613e00565b90848202918083048614901517156113785761212d612133918693613fb0565b8461344f565b049183038381116113785761214b926120fa916123c0565b04611e13565b61207c926121626121679288613b10565b613dc1565b906123c0565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b90506020813d6020116121c4575b816121b56020938361088a565b810103126101f057515f611df1565b3d91506121a8565b90506020813d6020116121f6575b816121e76020938361088a565b810103126101f057515f611dac565b3d91506121da565b90506020813d602011612228575b816122196020938361088a565b810103126101f057515f611d67565b3d915061220c565b90506020813d60201161225a575b8161224b6020938361088a565b810103126101f057515f611d25565b3d915061223e565b61227b915060203d60201161196057611951818361088a565b5f611cd6565b9150506040813d6040116122b2575b8161229d6040938361088a565b810103126101f057602081519101515f611c8a565b3d9150612290565b93509160805f602094604051966122d08861086e565b828852611f29604051988997889687947f8dae733300000000000000000000000000000000000000000000000000000000865201359060048501613433565b506020813d60201161233b575b816123296020938361088a565b810103126101f057611bf39051611be3565b3d915061231c565b60446020925f80936001600160a01b03966040519788947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af11561189d57503d15601f3d1160015f51141617156123a457565b6390b8ec185f526004601cfd5b5f80809381935af11561061257565b9190820180921161137857565b6040516123d98161083e565b60588152610974603c60208301927f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7484527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c60408201527f626f6f6c207061727469616c46696c6c416c6c6f776564290000000000000000606082015260405161246281610822565b602e815260208101907f546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c7582527f696e7432353620616d6f756e742900000000000000000000000000000000000060408201526040519586937f436f6e73696465726174696f6e20636f6e73696465726174696f6e290000000060208601525180918686015e830190848201905f8252519283915e015f8382015203601c81018452018261088a565b6001600160a01b03809116907f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16811461261a577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe992835c806125e957509181740200000000000000000000000000000000000000005f9493859460e01b1717855d82602083519301915af19061259f61369a565b91156125e0575c806125af575090565b602490604051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b50602081519101fd5b602490604051907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b9091907fffffffff00000000000000000000000000000000000000000000000000000000167fc1fb425e0000000000000000000000000000000000000000000000000000000081036127035750810160c0828203126101f0576126a6826107c5565b6126b382602085016108ad565b9160a084013567ffffffffffffffff81116101f0576126e26126ea926001600160a01b0392610f9d9701610959565b9216836134e6565b50506d1ff3684f28c67538d4d072c22734331492613b1d565b7fd92aadfb00000000000000000000000000000000000000000000000000000000810361295e57508101610120828203126101f057612741826107c5565b91602092612751838584016108ad565b61275d60a084016107c5565b9360c08401359067ffffffffffffffff82116101f05761277e918501610959565b9161010061278e60e086016107c5565b9401356127a86001600160a01b03808098169316846134e6565b969091926128056040938a8551916127bf8361083e565b168152898c820152868582015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9760248b6128848c8616809d7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c89519261283f8461083e565b83528785840152168882015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8651928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa94851561180857505f9461291b575b5093610f3484878c9585610f9d9f9b989961290a9b976fffffffffffffffffffffffffffffffff9e9b9511612911575b908461290092613d32565b809b860152612343565b1691613623565b90935083906128f5565b95919a809794508681999692993d8311612957575b61293a818361088a565b810103126101f05794519599939692959094939092610f346128c5565b503d612930565b9192917f8d68a156000000000000000000000000000000000000000000000000000000008103612ea0575082016080838203126101f05761299e836107c5565b9060408401359067ffffffffffffffff82116101f0576129bf918501610959565b9160246020845181860151907fffffffffffffffffffffffffffffffffffffffff000000000000000000000000918281169160148110612e8b575b50509050604051928380927f70a0823100000000000000000000000000000000000000000000000000000000825230600483015260601c5afa908115610612575f91612e57575b50612a546127109160208701359061344f565b049360405193612a6385610822565b6028855260403660208701379430937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116113665795905b815190602c82106112ec57866014840151601585015197601886015190602c8701519483928690879c6001600160a01b0389166001600160a01b0388161015612e4c575b60ff1680612d8957506001600160a01b03916055916040731f98431c8ad98523631ae4a59f267346ea31f984927fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33995b80881683891680821015612d7f57505091905b62ffffff169083519288165f5287166020528083521560051b6060035f20938183528152600b81019360ff855360208201520152201691855190858760280152866014015285528c602c88115f14612d08575061124c6001600160a01b0393878594611247612c08956112396040519b8c9586938d8c8084169116105f146113ac577f128acb080000000000000000000000000000000000000000000000000000000060208601526401000276a4918c168c8f1610306024870161349a565b9590946040525b1691161015612d0157505b7f80000000000000000000000000000000000000000000000000000000000000008114611378575f03945f861261136657602c86921115612c9957505030939060188151106112ec5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe80160189091019081526028865290612a9c565b939650935050925060608301358210612cb457505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526060929092013560248301526044820152606490fd5b9050612c1a565b926001600160a01b03612d779361124789611239849b9a8a61124c98879b888616898416105f1461144257886401000276a493816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c01521691161091166024870161349a565b949093612c0f565b9350919050612b49565b60018103612de357506001600160a01b039160559160407341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c9927f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7599612b36565b9091929394959650600381145f1461152b575060558d96959493926001600160a01b039260407370fe4a44ea505cfa3a57b95cf2862d4fd5f0f687927fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c99612b36565b889550869250612ae0565b90506020813d602011612e83575b81612e726020938361088a565b810103126101f05751612a54612a41565b3d9150612e65565b8391925060140360031b1b1616805f806129fa565b92837f103b48be00000000000000000000000000000000000000000000000000000000829495145f14613241575060c091810103126101f057612ee2816107c5565b90602091612ef18383016107c5565b916040918282013591612f06606082016107c5565b9160808201359162ffffff831683036101f05760a00135926001600160a01b03808098169116926001918280831614935f97806131b4575b50885191908861317e575b630902f1ac5f52895f6004601c8a5afa1561317557893d106101f0578b948b928760051b9586519187891851938083811c16148d1517613114575b5060609493925f92601c928e61ffff6127109260081c1682030292028201910204978187019763022c0d9f88526080808901528360a08901528982828a0101526004011886010152169101525f8060a48382885af11561189d57508311612ff15750505050505050600190565b6004918791156130b0578551928380927fd21220a70000000000000000000000000000000000000000000000000000000082525afa9081156130a6576105269495965f92613089575b5050935b519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865216600485016040919493926001600160a01b03606083019616825260208201520152565b61309f9250803d10611afd57611aed818361088a565b868061303a565b84513d5f823e3d90fd5b8551928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa9081156130a6576105269495965f926130f7575b50509361303e565b61310d9250803d10611afd57611aed818361088a565b86806130ef565b6024919c505f9294969798939550601c906370a0823184528b85525afa1561316c578b3d106101f0575f5182811061315b57829003988c9594938c93909290916060612f84565b60118d634e487b715f52526024601cfd5b833d5f823e3d90fd5b823d5f823e3d90fd5b63a9059cbb8352868c840152888a8401528b5f6044601c860182865af11561317557845f51148c3d1015163d1517612f49575f80fd5b909197508851907f70a082310000000000000000000000000000000000000000000000000000000082523060048301528b826024818c5afa8015613237575f90613208575b6127109250020496905f612f3e565b508b82813d8311613230575b61321e818361088a565b810103126101f05761271091516131f9565b503d613214565b8a513d5f823e3d90fd5b90507f38c9c1470000000000000000000000000000000000000000000000000000000081036132cd575081019060a0818303126101f057613281816107c5565b9061328e604082016107c5565b90608081013567ffffffffffffffff81116101f057610f9d946132b2918301610959565b9260206001600160a01b0360608401359416920135906136c9565b7fc876d21d0000000000000000000000000000000000000000000000000000000003610d845781606091810103126101f057613308816107c5565b6040613316602084016107c5565b920135906001600160a01b038091169083169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee84145f1461336e57504792509080831161335b575b505050600190565b6133669203906123b1565b5f8080613353565b916020602494604051958680927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa938415610612575f946133da575b508084116133c6575b50505050600190565b6133d1930391612343565b5f8080806133bd565b9093506020813d602011613406575b816133f66020938361088a565b810103126101f05751925f6133b4565b3d91506133e9565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b610974939260609282526020820152816040820152019061340e565b8181029291811591840414171561137857565b908160209103126101f057516001600160a01b03811681036101f05790565b908160209103126101f0575160ff811681036101f05790565b919360a09361097496956001600160a01b038094168552151560208501526040840152166060820152816080820152019061340e565b91908260409103126101f0576020825192015190565b60405192916134f4846107d9565b60208401915f8352846001600160a01b03809316905260208151015180935251511691565b604060609161353c848251602080916001600160a01b0381511684520151910152565b6020810151828501520151910152565b91909294936e22d473030f116ddee9f6b43ac78ba392833b156101f0576136075f966135f488946135d59a6001600160a01b036135ba986040519d8e9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c5260048c0190613519565b80516001600160a01b031660848b01526020015160a48a0152565b1660c487015260e486015261014061010486015261014485019061340e565b906003198483030161012485015261340e565b03925af18015610612576136185750565b6136219061085a565b565b9190917f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a75982765f526020526040519160405260605f20916040526010525f5260305fa0565b1561366d57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b3d156136c4573d906136ab82610907565b916136b9604051938461088a565b82523d5f602084013e565b606090565b9291906001600160a01b03808316946d1ff3684f28c67538d4d072c22734861480156138ee575b61261a575f91811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036137f7575050506137209047613906565b938051155f1461377b575050613751575f80809381935af161374061369a565b90156137495750565b602081519101fd5b60046040517f01da1572000000000000000000000000000000000000000000000000000000008152fd5b90939260208301808411611378578251106112ec57835f9460208695850101525b602083519301915af16137ad61369a565b901561374957511590816137ed575b506137c357565b60046040517f82d5d76a000000000000000000000000000000000000000000000000000000008152fd5b90503b155f6137bc565b9091949281979497155f1461381657505050613751575f92839261379c565b604096959496939293517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526020918282602481875afa8015610612575f906138bf575b61386b9250613906565b92818101808211611378578851106138ae57865f9896949293838a9997958c948a0101520361389d575b50505061379c565b6138a692613989565b5f8087613895565b603282634e487b715f52526024601cfd5b508282813d83116138e7575b6138d5818361088a565b810103126101f05761386b9151613861565b503d6138cb565b506e22d473030f116ddee9f6b43ac78ba386146136f0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8282098282029182808310920391808303916127109586910992828611156113665714613983577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919350828211900360fc1b910360041c170290565b50500490565b916001600160a01b039182916040519384927fdd62ed3e0000000000000000000000000000000000000000000000000000000084523060048501521692836024840152826044602096879389165afa918215610612575f92613ae1575b5081106139f4575b50505050565b613a82575b60445f91826040519586927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561189d57503d15601f3d1160015f5114161715613a75575f8080806139ee565b633e3f8f735f526004601cfd5b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081528160048201525f6024820152825f60448382885af11561189d57503d15601f3d1160015f511416176139f957633e3f8f735f526004601cfd5b9091508381813d8311613b09575b613af9818361088a565b810103126101f05751905f6139e6565b503d613aef565b9190820391821161137857565b9190925f14613c775751613c4d5760209081810151613c3c576040810151804211613c0b575051518251928201516040517f15dacbea0000000000000000000000000000000000000000000000000000000081526001600160a01b0392831660048201527f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c83166024820152939091166044840152606483015280826084815f6d1ff3684f28c67538d4d072c227345af1801561061257613bdd575050565b81813d8311613c04575b613bf1818361088a565b810103126101f05751801515036101f057565b503d613be7565b602490604051907fcd21db4f0000000000000000000000000000000000000000000000000000000082526004820152fd5b601182634e487b715f52526024601cfd5b60046040517fc321526c000000000000000000000000000000000000000000000000000000008152fd5b916e22d473030f116ddee9f6b43ac78ba37f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c813b156101f0575f8094613607613d19976001600160a01b03613cfe956040519a8b998a9889977f30f28b7a0000000000000000000000000000000000000000000000000000000089526004890190613519565b80516001600160a01b031660848801526020015160a4870152565b1660c484015261010060e484015261010483019061340e565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8284098183850293848084109303950990808514613db95782805f0316809304600280826003021880830282030280830282030280830282030280830282030280830282030280920290030294600184805f0304019185841191030302920304170290565b505091500490565b613df961097492613dd28151613e37565b906020670de0b6b3a7640000613dee608084019687519561344f565b049101519180613e95565b9051613b10565b8115613e0a570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8015613e0a576ec097ce7bc90715b34b9f10000000000490565b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000009035818116939260148110613e8657505050565b60140360031b82901b16169150565b9092670de0b6b3a764000093613eba816121088588613eb4828861344f565b0461344f565b90828603948686116113785786613ed4613edb938861344f565b04926123c0565b90818110613f9f5790613eed91613b10565b906001905b8460021b908087149486830460041486171561137857613f2f926120fa828a613eb4613f1f95829761344f565b04613f2a848061344f565b6123c0565b92600184811c01845b858210613f875750508460011b94850460021417156113785715613f795790613f60916123c0565b8281029281840414901517156113785761097491613fb0565b613f8291613b10565b613f60565b90945084613f958183613e00565b0160011c90613f38565b613fa891613b10565b905f90613ef2565b613fba8282613e00565b91820214610974576001019056336fda7ac33e46626cba703a82a53ad517aa8336000000000000000000000000
Deployed Bytecode
0x608080604052600436109081156102e5575b5036156102e357346101f0577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe9905f825c925d7fffffffff000000000000000000000000000000000000000000000000000000005f35818116926102ce575b508083169116036101f0576001600160a01b0380821633036101f057366004116101f05760031936019160a01c61ffff1690816001146101f457506002146100de577f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffd5b6080116101f0576004356044359081600401356100fe8160248501613e51565b60601c91816014116101f0575f8113156101e657915b30810361017057506101506101589360387fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec3394019101613e51565b60601c612343565b6040516101648161086e565b5f81525b602081519101f35b9161017f6101e1949315613666565b6040519061018c826107d9565b33825260208201526101db6101a436602c86016108ad565b92608d8501356001169460ad7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff773693019101610923565b91613b1d565b610158565b5060243591610114565b5f80fd5b9160a09150036101f05760043590604435918060a01c8360a01c176101f0578161021f911615613666565b5f5c905f805d60019260015c5f60015d60025c905f60025d6040519360208560200160035c9860208a8901019988528960405260045b8a83106102bc57505050506102a8965060405193610272856107d9565b16835260643560208401526040519261028a84610822565b8352602083015260408201526102a033826134e6565b505090613b1d565b6040516102b48161086e565b5f8152610168565b805c83525f815d810191830191610255565b818093503660040360031b1b1616905f61006f565b005b5f3560e01c9081631fff991f1461033257506370a0823114610307575f610011565b346101f05760206003193601126101f0576004356001600160a01b038116036101f0575f805360015ffd5b600319360160a081126101f0576060136101f05767ffffffffffffffff80606435116101f0573660236064350112156101f05760643560040135116101f0576005903660246064356004013560051b6064350101116101f05733906d1ff3684f28c67538d4d072c227343314610797575b6001600160a01b0382161561076f57507f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde893916001600160a01b03835c168061073e5750816001600160a01b0316835d5f5b6064356004013581106106265750506004356001600160a01b0381168082036101f057602435916001600160a01b038316908184036101f05760443591821580159061061d575b610496575b50505050506001600160a01b03166001600160a01b03825c160361046c575f905d602060405160018152f35b60046040517f5149e795000000000000000000000000000000000000000000000000000000008152fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361052a57505047928184106104db5750506001600160a01b0392916104d1916123b1565b9083808080610440565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b0390fd5b60249492919350602090604051958680927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa938415610612575f946105de575b50808410610596575091610591916001600160a01b039493612343565b6104d1565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015260448101839052606490fd5b9093506020813d60201161060a575b816105fa6020938361088a565b810103126101f057519286610574565b3d91506105ed565b6040513d5f823e3d90fd5b5080151561043b565b602460643582841b01013560643501811580610717575b80156106f0575b1561065257506001016103f4565b604051917f3c74eed600000000000000000000000000000000000000000000000000000000835260048301527fffffffff00000000000000000000000000000000000000000000000000000000604482013516602483015260606044830152600319602482013501606483015281601f19601b6024608494600319828201350160488201878701375f60808383013587010152013501168101030190fd5b5060405161070e60031960248401350160488401604485013561157a565b90604052610644565b50604051610735600319602484013501604884016044850135610977565b9060405261063d565b602490604051907f7407c0f80000000000000000000000000000000000000000000000000000000082526004820152fd5b807fe758b8d50000000000000000000000000000000000000000000000000000000060049252fd5b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec013560601c91506103a3565b35906001600160a01b03821682036101f057565b6040810190811067ffffffffffffffff8211176107f557604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6060810190811067ffffffffffffffff8211176107f557604052565b6080810190811067ffffffffffffffff8211176107f557604052565b67ffffffffffffffff81116107f557604052565b6020810190811067ffffffffffffffff8211176107f557604052565b90601f601f19910116810190811067ffffffffffffffff8211176107f557604052565b8092910391608083126101f057604051906108c782610822565b60408294126101f057606060409182516108e0816107d9565b6108e9826107c5565b81526020820135602082015284528281013560208501520135910152565b67ffffffffffffffff81116107f557601f01601f191660200190565b92919261092f82610907565b9161093d604051938461088a565b8294818452818301116101f0578281602093845f960137010152565b9080601f830112156101f05781602061097493359101610923565b90565b919091610985828483610d8a565b1561099257505050600190565b7fffffffff00000000000000000000000000000000000000000000000000000000167f52efd15d0000000000000000000000000000000000000000000000000000000003610d8457810190610100818303126101f0576109f1816107c5565b90602090818101359269ffffffffffffffffffff841684036101f057604094610a1c818785016108ad565b9160c084013567ffffffffffffffff928382116101f057610a3e918601610959565b906001600160a01b0394838860101c16948860081c9580155f14610c8f575076d6940c0e5f2ff0ff18a3be9b835635039256dc4b4963805f526017600920938793929189915b6d1ff3684f28c67538d4d072c2273433145f5d8c82808501519160019260015d015160025d818401848351938401019260035d6004905b838110610c6f57505050505101518a5199898b01977fdd96994f00000000000000000000000000000000000000000000000000000000895260ff1660248c015260ff1660448b015260648a015260e00135608489015260a488015f905260c488015f90521660e48701526101048087017f6370a85c0000000000000000000000000000000000000000000000000000000090528652610140860191868310908311176107f5578187528316927f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16831461076f57507e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe993845c80610c3f5750915f92918380937f6370a85c000000000000000100000000000000000000000000000000000000008417885d51925af190610bf361369a565b9115610c395750505c9081610c09575050600190565b6024925051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b81519101fd5b6024908751907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b9193959697509193508051825d8b01908201918a969594928c9492610abb565b6080811015610cca57730c0e5f2ff0ff18a3be9b835635039256dc4b496360145261d6945f526034536017601e20935b879392918991610a84565b600863ffffffff8b60301c16610d69575b6001811b66ffffffffffffff8c60181c161015610d61575b6001811b821015610d59575b6001811b68ffffffffffffffff0089161015610d51575b60031c90815280607f018953730c0e5f2ff0ff18a3be9b835635039256dc4b49635f528060d501600a536094600b53601601600a2093610cbf565b600801610d16565b600801610cff565b601001610cf3565b506028868203610cdb5760118a634e487b715f52526024601cfd5b50505f90565b9091907fffffffff00000000000000000000000000000000000000000000000000000000167f6d42ea47000000000000000000000000000000000000000000000000000000008103610fa25750810190610180818303126101f057610dee816107c5565b610dfb83602084016108ad565b610e0760a084016107c5565b9260c08101359467ffffffffffffffff958681116101f05781610e2b918401610959565b93610e398260e085016108ad565b916101608401359788116101f057610f42610f34966fffffffffffffffffffffffffffffffff96610e75610e8f94610f9d9c610f959901610959565b996001600160a01b039586958680931697889216846134e6565b9c9099610f1a610e9f85836134e6565b7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde893989192985c908260405194610ed48661083e565b16845260208401521660408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9e8f956d1ff3684f28c67538d4d072c22734331492613b1d565b610f3c6123cd565b9361354c565b60405192610f4f8461083e565b16825284602083015260408201525f6060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b911691613623565b600190565b9192917f22ce6ede000000000000000000000000000000000000000000000000000000000361156757820190610100838303126101f057610fe2836107c5565b9060208401359367ffffffffffffffff948581116101f05784611006918301610959565b9461101485604084016108ad565b9460c08301359182116101f05761102c918301610959565b8051608901948560891161137857602091601f1961106261104c89610907565b9861105a6040519a8b61088a565b808a52610907565b013684890137815183015187604801526040828401886068015e6d1ff3684f28c67538d4d072c2273433148760a8015380519083018760a9015e5101515f937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116113665795905b815190602c82106112ec57866014840151601585015197601886015190602c8701519483928690879c6001600160a01b0389166001600160a01b038816101561155c575b60ff168061146857506001600160a01b03916055916040731f98431c8ad98523631ae4a59f267346ea31f984927fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33995b8088168389168082101561145e57505091905b62ffffff169083519288165f5287166020528083521560051b6060035f20938183528152600b81019360ff855360208201520152201691855190858760280152866014015285528c602c88115f146113ca575061124c6001600160a01b039387859461124761125b956112396040519b8c9586938d8c8084169116105f146113ac578d8c806401000276a4945b7f128acb080000000000000000000000000000000000000000000000000000000060208a015216911610306024870161349a565b03601f19810184528361088a565b61250a565b602080825183010191016134d0565b9590946040525b16911610156113a557505b7f80000000000000000000000000000000000000000000000000000000000000008114611378575f03945f861261136657602c869211156112fe57505030939060188151106112ec5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe801601890910190815260288652906110cb565b634e487b715f5260326020526024601cfd5b939650935050925060e0830135821061131957505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260e0929092013560248301526044820152606490fd5b634e487b715f5260116020526024601cfd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b905061126d565b8d8c8073fffd8963efd1fc6a506488495d951d5263988d2594611205565b926001600160a01b0361143a9361124789611239849b9a8a61124c98879b888616898416105f1461144257886401000276a4935b816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c01521691161091166024870161349a565b949093611262565b8873fffd8963efd1fc6a506488495d951d5263988d25936113fe565b9350919050611178565b600181036114c257506001600160a01b039160559160407341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c9927f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7599611165565b9091929394959650600381145f1461152b575060558d96959493926001600160a01b039260407370fe4a44ea505cfa3a57b95cf2862d4fd5f0f687927fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c99611165565b602490604051907fd3b1276d0000000000000000000000000000000000000000000000000000000082526004820152fd5b88955086925061110f565b505f9150565b359081151582036101f057565b919091611588828483612644565b1561159557505050600190565b82907fffffffff00000000000000000000000000000000000000000000000000000000167fe12b0f13000000000000000000000000000000000000000000000000000000008103611b3d575060a091810103126101f0576115f5816107c5565b9060209182820135906001600160a01b038083168093036101f05760409384810135916060820135918183168093036101f0576080611634910161156d565b931692156119d3578451927f70a082310000000000000000000000000000000000000000000000000000000084526004923084860152736b175474e89094c44da98b954eedeac495271d0f948881602481895afa908115611967575f916119a4575b50612710916116a49161344f565b04968651947ffae036d500000000000000000000000000000000000000000000000000000000865281868681875afa958615611967575f96611971575b50818596978996959651978880927f313ce5670000000000000000000000000000000000000000000000000000000082525afa958615611967575f96611938575b5087517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230858201528560248201528281604481855afa90811561192e575f91611901575b50898110611811575b505050823b156101f0575f946117e2670de0b6b3a764000093879360ff978a519b8c998a9889977f8d7ef9bb000000000000000000000000000000000000000000000000000000008952019216600a0a0204918401602090939291936001600160a01b0360408201951681520152565b03925af190811561180857506117f9575b50600190565b6118029061085a565b5f6117f3565b513d5f823e3d90fd5b6118a5575b905f604481938a519485917f095ea7b300000000000000000000000000000000000000000000000000000000835289898401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561189d57503d15601f3d1160015f5114161715611891575f8080611772565b50633e3f8f735f52601cfd5b3d5f823e3d90fd5b87517f095ea7b300000000000000000000000000000000000000000000000000000000815285858201525f6024820152825f60448382865af11561189d57503d15601f3d1160015f511416176118165783633e3f8f735f52601cfd5b90508281813d8311611927575b611918818361088a565b810103126101f057515f611769565b503d61190e565b89513d5f823e3d90fd5b611959919650823d8411611960575b611951818361088a565b810190613481565b945f611722565b503d611947565b88513d5f823e3d90fd5b939495508184813d831161199d575b61198a818361088a565b810103126101f0579251949392816116e1565b503d611980565b90508881813d83116119cc575b6119bb818361088a565b810103126101f05751612710611696565b503d6119b1565b949084939293517f70a082310000000000000000000000000000000000000000000000000000000081523060048201528281602481875afa908115611b04575f91611b0e575b5061271091611a279161344f565b049184517f01664f6600000000000000000000000000000000000000000000000000000000815282816004818a5afa928315611b045791611a73939185935f93611ad5575b5050613989565b833b156101f05782517f959912760000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526024820152915f908390604490829084905af190811561180857506117f95750600190565b611af5929350803d10611afd575b611aed818361088a565b810190613462565b905f80611a6c565b503d611ae3565b86513d5f823e3d90fd5b90508281813d8311611b36575b611b25818361088a565b810103126101f05751612710611a19565b503d611b1b565b7fb8df6d4d0000000000000000000000000000000000000000000000000000000014159050610d84578160a091810103126101f057611b7b816107c5565b90611b88604082016107c5565b90611b956060820161156d565b906001600160a01b03906040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481868a165afa8015610612575f9061230f575b611bf39150602083013590613906565b92611c018484871688613989565b156122ba5760405160e0810181811067ffffffffffffffff8211176107f5576040525f81525f60208201525f60408201525f60608201525f60808201525f60a08201525f60c08201526040517fffa64225000000000000000000000000000000000000000000000000000000008152604081600481878a165afa8015610612575f915f91612281575b5060a083015260808201526040517f17be952e000000000000000000000000000000000000000000000000000000008152602081600481878a165afa80156106125760ff915f91612262575b5016600381101561216d5760c08201526040517f796da7af000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f91612230575b5081526040517f7c9b8e89000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f916121fe575b5060608201526040517feab5d20e000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f916121cc575b5060408201526040517fec2fd46d000000000000000000000000000000000000000000000000000000008152602081600481878a165afa908115610612575f9161219a575b50602082015260c0810151600381101561216d5761202257611e139084613dc1565b604051907fc0ffa178000000000000000000000000000000000000000000000000000000008252602082600481878a165afa918215610612575f92611fee575b50670de0b6b3a764000091820180831161137857604051907fab44a7a3000000000000000000000000000000000000000000000000000000008252602082600481898c165afa908115610612575f91611fb8575b611eb192506123c0565b9082810292818404149015171561137857611ecb91613e00565b9460808201358610611f6957505091611f2993915f60209460405194611ef08661086e565b828652604051978896879586937fe67ce70600000000000000000000000000000000000000000000000000000000855260048501613433565b0393165af1801561061257611f3e5750600190565b602090813d8311611f62575b611f54818361088a565b810103126101f0575f6117f3565b503d611f4a565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015260809190910135602482015260448101859052606490fd5b90506020823d602011611fe6575b81611fd36020938361088a565b810103126101f057611eb1915190611ea7565b3d9150611fc6565b9091506020813d60201161201a575b8161200a6020938361088a565b810103126101f05751905f611e53565b3d9150611ffd565b60c0810151600381101561216d576001036120815780604061207461204a61207c9451613e37565b608084015190670de0b6b3a76400006120678a868801519361344f565b0490602086015192613e95565b910151613b10565b611e13565b6120946040820151608083015190613b10565b6120a760a0830151606084015190613b10565b808611612151575050806120c28560606121009401516123c0565b6120cc8251613e37565b9161210d60a0820151926121086020606085015194015195670de0b6b3a76400009788916120fa8786613b10565b9061344f565b04948061344f565b613e00565b90848202918083048614901517156113785761212d612133918693613fb0565b8461344f565b049183038381116113785761214b926120fa916123c0565b04611e13565b61207c926121626121679288613b10565b613dc1565b906123c0565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b90506020813d6020116121c4575b816121b56020938361088a565b810103126101f057515f611df1565b3d91506121a8565b90506020813d6020116121f6575b816121e76020938361088a565b810103126101f057515f611dac565b3d91506121da565b90506020813d602011612228575b816122196020938361088a565b810103126101f057515f611d67565b3d915061220c565b90506020813d60201161225a575b8161224b6020938361088a565b810103126101f057515f611d25565b3d915061223e565b61227b915060203d60201161196057611951818361088a565b5f611cd6565b9150506040813d6040116122b2575b8161229d6040938361088a565b810103126101f057602081519101515f611c8a565b3d9150612290565b93509160805f602094604051966122d08861086e565b828852611f29604051988997889687947f8dae733300000000000000000000000000000000000000000000000000000000865201359060048501613433565b506020813d60201161233b575b816123296020938361088a565b810103126101f057611bf39051611be3565b3d915061231c565b60446020925f80936001600160a01b03966040519788947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af11561189d57503d15601f3d1160015f51141617156123a457565b6390b8ec185f526004601cfd5b5f80809381935af11561061257565b9190820180921161137857565b6040516123d98161083e565b60588152610974603c60208301927f436f6e73696465726174696f6e286164647265737320746f6b656e2c75696e7484527f32353620616d6f756e742c6164647265737320636f756e74657270617274792c60408201527f626f6f6c207061727469616c46696c6c416c6c6f776564290000000000000000606082015260405161246281610822565b602e815260208101907f546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c7582527f696e7432353620616d6f756e742900000000000000000000000000000000000060408201526040519586937f436f6e73696465726174696f6e20636f6e73696465726174696f6e290000000060208601525180918686015e830190848201905f8252519283915e015f8382015203601c81018452018261088a565b6001600160a01b03809116907f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c16811461261a577e9355806b743562f351db2e3726091207f49fa1cdccd5c65a7d4860ce3abbe992835c806125e957509181740200000000000000000000000000000000000000005f9493859460e01b1717855d82602083519301915af19061259f61369a565b91156125e0575c806125af575090565b602490604051907fd66fcc380000000000000000000000000000000000000000000000000000000082526004820152fd5b50602081519101fd5b602490604051907fab7646c40000000000000000000000000000000000000000000000000000000082526004820152fd5b60046040517fe758b8d5000000000000000000000000000000000000000000000000000000008152fd5b9091907fffffffff00000000000000000000000000000000000000000000000000000000167fc1fb425e0000000000000000000000000000000000000000000000000000000081036127035750810160c0828203126101f0576126a6826107c5565b6126b382602085016108ad565b9160a084013567ffffffffffffffff81116101f0576126e26126ea926001600160a01b0392610f9d9701610959565b9216836134e6565b50506d1ff3684f28c67538d4d072c22734331492613b1d565b7fd92aadfb00000000000000000000000000000000000000000000000000000000810361295e57508101610120828203126101f057612741826107c5565b91602092612751838584016108ad565b61275d60a084016107c5565b9360c08401359067ffffffffffffffff82116101f05761277e918501610959565b9161010061278e60e086016107c5565b9401356127a86001600160a01b03808098169316846134e6565b969091926128056040938a8551916127bf8361083e565b168152898c820152868582015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9760248b6128848c8616809d7f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c89519261283f8461083e565b83528785840152168882015260016060820152601f19019081517f7d806873084f389a66fd0315dead7adaad8ae6e8b6cf9fb0d3db61e5a91c3ffa835260a083209252565b9b8651928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa94851561180857505f9461291b575b5093610f3484878c9585610f9d9f9b989961290a9b976fffffffffffffffffffffffffffffffff9e9b9511612911575b908461290092613d32565b809b860152612343565b1691613623565b90935083906128f5565b95919a809794508681999692993d8311612957575b61293a818361088a565b810103126101f05794519599939692959094939092610f346128c5565b503d612930565b9192917f8d68a156000000000000000000000000000000000000000000000000000000008103612ea0575082016080838203126101f05761299e836107c5565b9060408401359067ffffffffffffffff82116101f0576129bf918501610959565b9160246020845181860151907fffffffffffffffffffffffffffffffffffffffff000000000000000000000000918281169160148110612e8b575b50509050604051928380927f70a0823100000000000000000000000000000000000000000000000000000000825230600483015260601c5afa908115610612575f91612e57575b50612a546127109160208701359061344f565b049360405193612a6385610822565b6028855260403660208701379430937f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116113665795905b815190602c82106112ec57866014840151601585015197601886015190602c8701519483928690879c6001600160a01b0389166001600160a01b0388161015612e4c575b60ff1680612d8957506001600160a01b03916055916040731f98431c8ad98523631ae4a59f267346ea31f984927fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b549263fa461e33995b80881683891680821015612d7f57505091905b62ffffff169083519288165f5287166020528083521560051b6060035f20938183528152600b81019360ff855360208201520152201691855190858760280152866014015285528c602c88115f14612d08575061124c6001600160a01b0393878594611247612c08956112396040519b8c9586938d8c8084169116105f146113ac577f128acb080000000000000000000000000000000000000000000000000000000060208601526401000276a4918c168c8f1610306024870161349a565b9590946040525b1691161015612d0157505b7f80000000000000000000000000000000000000000000000000000000000000008114611378575f03945f861261136657602c86921115612c9957505030939060188151106112ec5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe80160189091019081526028865290612a9c565b939650935050925060608301358210612cb457505050600190565b6040517f97a6f3b90000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526060929092013560248301526044820152606490fd5b9050612c1a565b926001600160a01b03612d779361124789611239849b9a8a61124c98879b888616898416105f1461144257886401000276a493816040519b8c997f128acb080000000000000000000000000000000000000000000000000000000060208c01521691161091166024870161349a565b949093612c0f565b9350919050612b49565b60018103612de357506001600160a01b039160559160407341ff9aa7e16b8b1a8a8dc4f0efacd93d02d071c9927f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2926323a69e7599612b36565b9091929394959650600381145f1461152b575060558d96959493926001600160a01b039260407370fe4a44ea505cfa3a57b95cf2862d4fd5f0f687927fe9b68c5f77858eecac2e651646e208175e9b1359d68d0e14fc69f8c54e5010bf92633a1c453c99612b36565b889550869250612ae0565b90506020813d602011612e83575b81612e726020938361088a565b810103126101f05751612a54612a41565b3d9150612e65565b8391925060140360031b1b1616805f806129fa565b92837f103b48be00000000000000000000000000000000000000000000000000000000829495145f14613241575060c091810103126101f057612ee2816107c5565b90602091612ef18383016107c5565b916040918282013591612f06606082016107c5565b9160808201359162ffffff831683036101f05760a00135926001600160a01b03808098169116926001918280831614935f97806131b4575b50885191908861317e575b630902f1ac5f52895f6004601c8a5afa1561317557893d106101f0578b948b928760051b9586519187891851938083811c16148d1517613114575b5060609493925f92601c928e61ffff6127109260081c1682030292028201910204978187019763022c0d9f88526080808901528360a08901528982828a0101526004011886010152169101525f8060a48382885af11561189d57508311612ff15750505050505050600190565b6004918791156130b0578551928380927fd21220a70000000000000000000000000000000000000000000000000000000082525afa9081156130a6576105269495965f92613089575b5050935b519485947f97a6f3b900000000000000000000000000000000000000000000000000000000865216600485016040919493926001600160a01b03606083019616825260208201520152565b61309f9250803d10611afd57611aed818361088a565b868061303a565b84513d5f823e3d90fd5b8551928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa9081156130a6576105269495965f926130f7575b50509361303e565b61310d9250803d10611afd57611aed818361088a565b86806130ef565b6024919c505f9294969798939550601c906370a0823184528b85525afa1561316c578b3d106101f0575f5182811061315b57829003988c9594938c93909290916060612f84565b60118d634e487b715f52526024601cfd5b833d5f823e3d90fd5b823d5f823e3d90fd5b63a9059cbb8352868c840152888a8401528b5f6044601c860182865af11561317557845f51148c3d1015163d1517612f49575f80fd5b909197508851907f70a082310000000000000000000000000000000000000000000000000000000082523060048301528b826024818c5afa8015613237575f90613208575b6127109250020496905f612f3e565b508b82813d8311613230575b61321e818361088a565b810103126101f05761271091516131f9565b503d613214565b8a513d5f823e3d90fd5b90507f38c9c1470000000000000000000000000000000000000000000000000000000081036132cd575081019060a0818303126101f057613281816107c5565b9061328e604082016107c5565b90608081013567ffffffffffffffff81116101f057610f9d946132b2918301610959565b9260206001600160a01b0360608401359416920135906136c9565b7fc876d21d0000000000000000000000000000000000000000000000000000000003610d845781606091810103126101f057613308816107c5565b6040613316602084016107c5565b920135906001600160a01b038091169083169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee84145f1461336e57504792509080831161335b575b505050600190565b6133669203906123b1565b5f8080613353565b916020602494604051958680927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa938415610612575f946133da575b508084116133c6575b50505050600190565b6133d1930391612343565b5f8080806133bd565b9093506020813d602011613406575b816133f66020938361088a565b810103126101f05751925f6133b4565b3d91506133e9565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b610974939260609282526020820152816040820152019061340e565b8181029291811591840414171561137857565b908160209103126101f057516001600160a01b03811681036101f05790565b908160209103126101f0575160ff811681036101f05790565b919360a09361097496956001600160a01b038094168552151560208501526040840152166060820152816080820152019061340e565b91908260409103126101f0576020825192015190565b60405192916134f4846107d9565b60208401915f8352846001600160a01b03809316905260208151015180935251511691565b604060609161353c848251602080916001600160a01b0381511684520151910152565b6020810151828501520151910152565b91909294936e22d473030f116ddee9f6b43ac78ba392833b156101f0576136075f966135f488946135d59a6001600160a01b036135ba986040519d8e9c8d9b8c9a7f137c29fe000000000000000000000000000000000000000000000000000000008c5260048c0190613519565b80516001600160a01b031660848b01526020015160a48a0152565b1660c487015260e486015261014061010486015261014485019061340e565b906003198483030161012485015261340e565b03925af18015610612576136185750565b6136219061085a565b565b9190917f49fa719b76f0f6b7e76be94b56c26671a548e1c712d5b13dc2874f70a75982765f526020526040519160405260605f20916040526010525f5260305fa0565b1561366d57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b3d156136c4573d906136ab82610907565b916136b9604051938461088a565b82523d5f602084013e565b606090565b9291906001600160a01b03808316946d1ff3684f28c67538d4d072c22734861480156138ee575b61261a575f91811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036137f7575050506137209047613906565b938051155f1461377b575050613751575f80809381935af161374061369a565b90156137495750565b602081519101fd5b60046040517f01da1572000000000000000000000000000000000000000000000000000000008152fd5b90939260208301808411611378578251106112ec57835f9460208695850101525b602083519301915af16137ad61369a565b901561374957511590816137ed575b506137c357565b60046040517f82d5d76a000000000000000000000000000000000000000000000000000000008152fd5b90503b155f6137bc565b9091949281979497155f1461381657505050613751575f92839261379c565b604096959496939293517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526020918282602481875afa8015610612575f906138bf575b61386b9250613906565b92818101808211611378578851106138ae57865f9896949293838a9997958c948a0101520361389d575b50505061379c565b6138a692613989565b5f8087613895565b603282634e487b715f52526024601cfd5b508282813d83116138e7575b6138d5818361088a565b810103126101f05761386b9151613861565b503d6138cb565b506e22d473030f116ddee9f6b43ac78ba386146136f0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8282098282029182808310920391808303916127109586910992828611156113665714613983577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919350828211900360fc1b910360041c170290565b50500490565b916001600160a01b039182916040519384927fdd62ed3e0000000000000000000000000000000000000000000000000000000084523060048501521692836024840152826044602096879389165afa918215610612575f92613ae1575b5081106139f4575b50505050565b613a82575b60445f91826040519586927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af11561189d57503d15601f3d1160015f5114161715613a75575f8080806139ee565b633e3f8f735f526004601cfd5b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081528160048201525f6024820152825f60448382885af11561189d57503d15601f3d1160015f511416176139f957633e3f8f735f526004601cfd5b9091508381813d8311613b09575b613af9818361088a565b810103126101f05751905f6139e6565b503d613aef565b9190820391821161137857565b9190925f14613c775751613c4d5760209081810151613c3c576040810151804211613c0b575051518251928201516040517f15dacbea0000000000000000000000000000000000000000000000000000000081526001600160a01b0392831660048201527f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c83166024820152939091166044840152606483015280826084815f6d1ff3684f28c67538d4d072c227345af1801561061257613bdd575050565b81813d8311613c04575b613bf1818361088a565b810103126101f05751801515036101f057565b503d613be7565b602490604051907fcd21db4f0000000000000000000000000000000000000000000000000000000082526004820152fd5b601182634e487b715f52526024601cfd5b60046040517fc321526c000000000000000000000000000000000000000000000000000000008152fd5b916e22d473030f116ddee9f6b43ac78ba37f46bacb9b87ba1d2910347e4a3e052d06c824a45acd1e9517bb0cb8d0d5cde8935c813b156101f0575f8094613607613d19976001600160a01b03613cfe956040519a8b998a9889977f30f28b7a0000000000000000000000000000000000000000000000000000000089526004890190613519565b80516001600160a01b031660848801526020015160a4870152565b1660c484015261010060e484015261010483019061340e565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8284098183850293848084109303950990808514613db95782805f0316809304600280826003021880830282030280830282030280830282030280830282030280830282030280920290030294600184805f0304019185841191030302920304170290565b505091500490565b613df961097492613dd28151613e37565b906020670de0b6b3a7640000613dee608084019687519561344f565b049101519180613e95565b9051613b10565b8115613e0a570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8015613e0a576ec097ce7bc90715b34b9f10000000000490565b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000009035818116939260148110613e8657505050565b60140360031b82901b16169150565b9092670de0b6b3a764000093613eba816121088588613eb4828861344f565b0461344f565b90828603948686116113785786613ed4613edb938861344f565b04926123c0565b90818110613f9f5790613eed91613b10565b906001905b8460021b908087149486830460041486171561137857613f2f926120fa828a613eb4613f1f95829761344f565b04613f2a848061344f565b6123c0565b92600184811c01845b858210613f875750508460011b94850460021417156113785715613f795790613f60916123c0565b8281029281840414901517156113785761097491613fb0565b613f8291613b10565b613f60565b90945084613f958183613e00565b0160011c90613f38565b613fa891613b10565b905f90613ef2565b613fba8282613e00565b91820214610974576001019056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
336fda7ac33e46626cba703a82a53ad517aa8336000000000000000000000000
-----Decoded View---------------
Arg [0] : gitCommit (bytes20): 0x336fda7ac33e46626cba703a82a53ad517aa8336
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 336fda7ac33e46626cba703a82a53ad517aa8336000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.