Overview
ETH Balance
0.000009990843133006 ETH
Eth Value
$0.03 (@ $3,370.02/ETH)Token Holdings
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 34,404 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Swap And Transfe... | 20646317 | 84 days ago | IN | 0.01353948 ETH | 0.00002379 | ||||
Swap And Transfe... | 20453358 | 111 days ago | IN | 0.01294056 ETH | 0.00003964 | ||||
Swap And Transfe... | 20440839 | 113 days ago | IN | 0.11959891 ETH | 0.00085872 | ||||
Swap And Transfe... | 20437733 | 113 days ago | IN | 1.59211431 ETH | 0.00067166 | ||||
Swap And Transfe... | 20435112 | 113 days ago | IN | 0.0649072 ETH | 0.00411237 | ||||
Swap And Transfe... | 20434799 | 113 days ago | IN | 0 ETH | 0.0059868 | ||||
Transfer Token | 20434777 | 113 days ago | IN | 0 ETH | 0.00399745 | ||||
Swap And Transfe... | 20434643 | 113 days ago | IN | 0.00973005 ETH | 0.00440752 | ||||
Swap And Transfe... | 20434631 | 113 days ago | IN | 0.06466495 ETH | 0.00480324 | ||||
Swap And Transfe... | 20434609 | 113 days ago | IN | 0 ETH | 0.00494753 | ||||
Swap And Transfe... | 20434600 | 113 days ago | IN | 0.29683789 ETH | 0.00421722 | ||||
Swap And Transfe... | 20434576 | 113 days ago | IN | 0.0068546 ETH | 0.00431718 | ||||
Swap And Transfe... | 20434549 | 113 days ago | IN | 0 ETH | 0.00392885 | ||||
Swap And Transfe... | 20434506 | 113 days ago | IN | 0.00645127 ETH | 0.00369416 | ||||
Transfer Token | 20434429 | 113 days ago | IN | 0 ETH | 0.00176475 | ||||
Swap And Transfe... | 20434379 | 113 days ago | IN | 0.31942877 ETH | 0.00217902 | ||||
Swap And Transfe... | 20434375 | 113 days ago | IN | 0.06388637 ETH | 0.00215485 | ||||
Swap And Transfe... | 20434374 | 113 days ago | IN | 0.22328193 ETH | 0.0021741 | ||||
Swap And Transfe... | 20434370 | 113 days ago | IN | 0.28088583 ETH | 0.0021774 | ||||
Swap And Transfe... | 20434369 | 113 days ago | IN | 0.00127675 ETH | 0.00210703 | ||||
Swap And Transfe... | 20434367 | 113 days ago | IN | 0.06219932 ETH | 0.00221547 | ||||
Swap And Transfe... | 20434333 | 113 days ago | IN | 0.32009965 ETH | 0.00284589 | ||||
Swap And Transfe... | 20434328 | 113 days ago | IN | 0.01919895 ETH | 0.00262113 | ||||
Swap And Transfe... | 20434290 | 113 days ago | IN | 0.17223447 ETH | 0.00294208 | ||||
Swap And Transfe... | 20434271 | 113 days ago | IN | 0.0688914 ETH | 0.00370711 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
20440839 | 113 days ago | 0.11959891 ETH | ||||
20437733 | 113 days ago | 1.59211431 ETH | ||||
20435112 | 113 days ago | 0.0649072 ETH | ||||
20434643 | 113 days ago | 0.00973005 ETH | ||||
20434631 | 113 days ago | 0.06466495 ETH | ||||
20434600 | 113 days ago | 0.29683789 ETH | ||||
20434576 | 113 days ago | 0.0068546 ETH | ||||
20434506 | 113 days ago | 0.00645127 ETH | ||||
20434379 | 113 days ago | 0.31942877 ETH | ||||
20434375 | 113 days ago | 0.06388637 ETH | ||||
20434374 | 113 days ago | 0.22328193 ETH | ||||
20434370 | 113 days ago | 0.28088583 ETH | ||||
20434369 | 113 days ago | 0.00127675 ETH | ||||
20434367 | 113 days ago | 0.06219932 ETH | ||||
20434333 | 113 days ago | 0.32009965 ETH | ||||
20434328 | 113 days ago | 0.01919895 ETH | ||||
20434290 | 113 days ago | 0.17223447 ETH | ||||
20434271 | 113 days ago | 0.0688914 ETH | ||||
20434260 | 113 days ago | 0.04134296 ETH | ||||
20434217 | 113 days ago | 0.31837352 ETH | ||||
20434210 | 113 days ago | 0.35019403 ETH | ||||
20434157 | 113 days ago | 0.13583155 ETH | ||||
20434152 | 113 days ago | 0.15867687 ETH | ||||
20434118 | 113 days ago | 0.09495294 ETH | ||||
20434094 | 113 days ago | 0.04756335 ETH |
Loading...
Loading
Contract Name:
Transfers
Compiler Version
v0.8.17+commit.8df45f5f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/interfaces/IERC2612.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@uniswap/universal-router/contracts/interfaces/IUniversalRouter.sol"; import {Commands as UniswapCommands} from "@uniswap/universal-router/contracts/libraries/Commands.sol"; import {Constants as UniswapConstants} from "@uniswap/universal-router/contracts/libraries/Constants.sol"; import "../interfaces/IWrappedNativeCurrency.sol"; import "../interfaces/ITransfers.sol"; import "../utils/Sweepable.sol"; import "../permit2/src/Permit2.sol"; // Uniswap error selectors, used to surface information when swaps fail // Pulled from @uniswap/universal-router/out/V3SwapRouter.sol/V3SwapRouter.json after compiling with forge bytes32 constant V3_INVALID_SWAP = keccak256(hex"316cf0eb"); bytes32 constant V3_TOO_LITTLE_RECEIVED = keccak256(hex"39d35496"); bytes32 constant V3_TOO_MUCH_REQUESTED = keccak256(hex"739dbe52"); bytes32 constant V3_INVALID_AMOUNT_OUT = keccak256(hex"d4e0248e"); bytes32 constant V3_INVALID_CALLER = keccak256(hex"32b13d91"); // @inheritdoc ITransfers contract Transfers is Context, Ownable, Pausable, ReentrancyGuard, Sweepable, ITransfers { using SafeERC20 for IERC20; using SafeERC20 for IWrappedNativeCurrency; // @dev Map of operator addresses and fee destinations. mapping(address => address) private feeDestinations; // @dev Map of operator addresses to a map of transfer intent ids that have been processed mapping(address => mapping(bytes16 => bool)) private processedTransferIntents; // @dev Represents native token of a chain (e.g. ETH or MATIC) address private immutable NATIVE_CURRENCY = address(0); // @dev Uniswap on-chain contract IUniversalRouter private immutable uniswap; // @dev permit2 SignatureTransfer contract address. Used for tranferring tokens with a signature instead of a full transaction. // See: https://github.com/Uniswap/permit2 Permit2 public immutable permit2; // @dev Canonical wrapped token for this chain. e.g. (wETH or wMATIC). IWrappedNativeCurrency private immutable wrappedNativeCurrency; // @param _uniswap The address of the Uniswap V3 swap router // @param _wrappedNativeCurrency The address of the wrapped token for this chain constructor( IUniversalRouter _uniswap, Permit2 _permit2, address _initialOperator, address _initialFeeDestination, IWrappedNativeCurrency _wrappedNativeCurrency ) { require( address(_uniswap) != address(0) && address(_permit2) != address(0) && address(_wrappedNativeCurrency) != address(0) && _initialOperator != address(0) && _initialFeeDestination != address(0), "invalid constructor parameters" ); uniswap = _uniswap; permit2 = _permit2; wrappedNativeCurrency = _wrappedNativeCurrency; // Sets an initial operator to enable immediate payment processing feeDestinations[_initialOperator] = _initialFeeDestination; } // @dev Raises errors if the intent is invalid // @param _intent The intent to validate modifier validIntent(TransferIntent calldata _intent, address sender) { bytes32 hash = keccak256( abi.encodePacked( _intent.recipientAmount, _intent.deadline, _intent.recipient, _intent.recipientCurrency, _intent.refundDestination, _intent.feeAmount, _intent.id, _intent.operator, block.chainid, sender, address(this) ) ); bytes32 signedMessageHash; if (_intent.prefix.length == 0) { // Use 'default' message prefix. signedMessageHash = ECDSA.toEthSignedMessageHash(hash); } else { // Use custom message prefix. signedMessageHash = keccak256(abi.encodePacked(_intent.prefix, hash)); } address signer = ECDSA.recover(signedMessageHash, _intent.signature); if (signer != _intent.operator) { revert InvalidSignature(); } if (_intent.deadline < block.timestamp) { revert ExpiredIntent(); } if (_intent.recipient == address(0)) { revert NullRecipient(); } if (processedTransferIntents[_intent.operator][_intent.id]) { revert AlreadyProcessed(); } _; } // @dev Raises an error if the operator in the transfer intent is not registered. // @param _intent The intent to validate modifier operatorIsRegistered(TransferIntent calldata _intent) { if (feeDestinations[_intent.operator] == address(0)) revert OperatorNotRegistered(); _; } modifier exactValueSent(TransferIntent calldata _intent) { // Make sure the correct value was sent uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; if (msg.value > neededAmount) { revert InvalidNativeAmount(int256(msg.value - neededAmount)); } else if (msg.value < neededAmount) { revert InvalidNativeAmount(-int256(neededAmount - msg.value)); } _; } // @inheritdoc ITransfers function transferNative(TransferIntent calldata _intent) external payable override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) exactValueSent(_intent) { // Make sure the recipient wants the native currency if (_intent.recipientCurrency != NATIVE_CURRENCY) revert IncorrectCurrency(NATIVE_CURRENCY); if (msg.value > 0) { // Complete the payment transferFundsToDestinations(_intent); } succeedPayment(_intent, msg.value, NATIVE_CURRENCY, _msgSender()); } // @inheritdoc ITransfers function transferToken( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData ) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { // Make sure the recipient wants a token and the payer is sending it if ( _intent.recipientCurrency == NATIVE_CURRENCY || _signatureTransferData.permit.permitted.token != _intent.recipientCurrency ) { revert IncorrectCurrency(_signatureTransferData.permit.permitted.token); } // Make sure the payer has enough of the payment token IERC20 erc20 = IERC20(_intent.recipientCurrency); uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 payerBalance = erc20.balanceOf(_msgSender()); if (payerBalance < neededAmount) { revert InsufficientBalance(neededAmount - payerBalance); } if (neededAmount > 0) { // Make sure the payer is transferring the right amount to this contract if ( _signatureTransferData.transferDetails.to != address(this) || _signatureTransferData.transferDetails.requestedAmount != neededAmount ) { revert InvalidTransferDetails(); } // Record our balance before (most likely zero) to detect fee-on-transfer tokens uint256 balanceBefore = erc20.balanceOf(address(this)); // Transfer the payment token to this contract permit2.permitTransferFrom( _signatureTransferData.permit, _signatureTransferData.transferDetails, _msgSender(), _signatureTransferData.signature ); // Make sure this is not a fee-on-transfer token revertIfInexactTransfer(neededAmount, balanceBefore, erc20, address(this)); // Complete the payment transferFundsToDestinations(_intent); } succeedPayment(_intent, neededAmount, _intent.recipientCurrency, _msgSender()); } // @inheritdoc ITransfers function transferTokenPreApproved(TransferIntent calldata _intent) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { // Make sure the recipient wants a token if (_intent.recipientCurrency == NATIVE_CURRENCY) { revert IncorrectCurrency(_intent.recipientCurrency); } // Make sure the payer has enough of the payment token IERC20 erc20 = IERC20(_intent.recipientCurrency); uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 payerBalance = erc20.balanceOf(_msgSender()); if (payerBalance < neededAmount) { revert InsufficientBalance(neededAmount - payerBalance); } // Make sure the payer has approved this contract for a sufficient transfer uint256 allowance = erc20.allowance(_msgSender(), address(this)); if (allowance < neededAmount) { revert InsufficientAllowance(neededAmount - allowance); } if (neededAmount > 0) { // Record our balance before (most likely zero) to detect fee-on-transfer tokens uint256 balanceBefore = erc20.balanceOf(address(this)); // Transfer the payment token to this contract erc20.safeTransferFrom(_msgSender(), address(this), neededAmount); // Make sure this is not a fee-on-transfer token revertIfInexactTransfer(neededAmount, balanceBefore, erc20, address(this)); // Complete the payment transferFundsToDestinations(_intent); } succeedPayment(_intent, neededAmount, _intent.recipientCurrency, _msgSender()); } // @inheritdoc ITransfers // @dev Wraps msg.value into wrapped token and transfers to recipient. function wrapAndTransfer(TransferIntent calldata _intent) external payable override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) exactValueSent(_intent) { // Make sure the recipient wants to receive the wrapped native currency if (_intent.recipientCurrency != address(wrappedNativeCurrency)) { revert IncorrectCurrency(NATIVE_CURRENCY); } if (msg.value > 0) { // Wrap the sent native currency wrappedNativeCurrency.deposit{value: msg.value}(); // Complete the payment transferFundsToDestinations(_intent); } succeedPayment(_intent, msg.value, NATIVE_CURRENCY, _msgSender()); } // @inheritdoc ITransfers // @dev Requires _msgSender() to have approved this contract to use the wrapped token. // @dev Unwraps into native token and transfers native token (e.g. ETH) to _intent.recipient. function unwrapAndTransfer( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData ) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { // Make sure the recipient wants the native currency and that the payer is // sending the wrapped native currency if ( _intent.recipientCurrency != NATIVE_CURRENCY || _signatureTransferData.permit.permitted.token != address(wrappedNativeCurrency) ) { revert IncorrectCurrency(_signatureTransferData.permit.permitted.token); } // Make sure the payer has enough of the wrapped native currency uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 payerBalance = wrappedNativeCurrency.balanceOf(_msgSender()); if (payerBalance < neededAmount) { revert InsufficientBalance(neededAmount - payerBalance); } if (neededAmount > 0) { // Make sure the payer is transferring the right amount of the wrapped native currency to the contract if ( _signatureTransferData.transferDetails.to != address(this) || _signatureTransferData.transferDetails.requestedAmount != neededAmount ) { revert InvalidTransferDetails(); } // Transfer the payer's wrapped native currency to the contract permit2.permitTransferFrom( _signatureTransferData.permit, _signatureTransferData.transferDetails, _msgSender(), _signatureTransferData.signature ); // Complete the payment unwrapAndTransferFundsToDestinations(_intent); } succeedPayment(_intent, neededAmount, address(wrappedNativeCurrency), _msgSender()); } // @inheritdoc ITransfers // @dev Requires _msgSender() to have approved this contract to use the wrapped token. // @dev Unwraps into native token and transfers native token (e.g. ETH) to _intent.recipient. function unwrapAndTransferPreApproved(TransferIntent calldata _intent) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { // Make sure the recipient wants the native currency if (_intent.recipientCurrency != NATIVE_CURRENCY) { revert IncorrectCurrency(address(wrappedNativeCurrency)); } // Make sure the payer has enough of the wrapped native currency uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 payerBalance = wrappedNativeCurrency.balanceOf(_msgSender()); if (payerBalance < neededAmount) { revert InsufficientBalance(neededAmount - payerBalance); } // Make sure the payer has approved this contract for a sufficient transfer uint256 allowance = wrappedNativeCurrency.allowance(_msgSender(), address(this)); if (allowance < neededAmount) { revert InsufficientAllowance(neededAmount - allowance); } if (neededAmount > 0) { // Transfer the payer's wrapped native currency to the contract wrappedNativeCurrency.safeTransferFrom(_msgSender(), address(this), neededAmount); // Complete the payment unwrapAndTransferFundsToDestinations(_intent); } succeedPayment(_intent, neededAmount, address(wrappedNativeCurrency), _msgSender()); } /*------------------------------------------------------------------*\ | Swap and Transfer \*------------------------------------------------------------------*/ // @inheritdoc ITransfers function swapAndTransferUniswapV3Native(TransferIntent calldata _intent, uint24 poolFeesTier) external payable override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { // Make sure a swap is actually required, otherwise the payer should use `wrapAndTransfer` or `transferNative` if ( _intent.recipientCurrency == NATIVE_CURRENCY || _intent.recipientCurrency == address(wrappedNativeCurrency) ) { revert IncorrectCurrency(NATIVE_CURRENCY); } uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 amountSwapped = 0; if (neededAmount > 0) { // Perform the swap amountSwapped = swapTokens(_intent, address(wrappedNativeCurrency), msg.value, poolFeesTier); } // Complete the payment succeedPayment(_intent, amountSwapped, NATIVE_CURRENCY, _msgSender()); } // @inheritdoc ITransfers function swapAndTransferUniswapV3Token( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData, uint24 poolFeesTier ) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { IERC20 tokenIn = IERC20(_signatureTransferData.permit.permitted.token); // Make sure a swap is actually required if (address(tokenIn) == _intent.recipientCurrency) { revert IncorrectCurrency(address(tokenIn)); } // Make sure the transfer is to this contract if (_signatureTransferData.transferDetails.to != address(this)) { revert InvalidTransferDetails(); } uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 maxWillingToPay = _signatureTransferData.transferDetails.requestedAmount; uint256 amountSwapped = 0; if (neededAmount > 0) { // Record our balance before (most likely zero) to detect fee-on-transfer tokens uint256 balanceBefore = tokenIn.balanceOf(address(this)); // Transfer the payer's tokens to this contract permit2.permitTransferFrom( _signatureTransferData.permit, _signatureTransferData.transferDetails, _msgSender(), _signatureTransferData.signature ); // Make sure this is not a fee-on-transfer token revertIfInexactTransfer(maxWillingToPay, balanceBefore, tokenIn, address(this)); // Perform the swap amountSwapped = swapTokens(_intent, address(tokenIn), maxWillingToPay, poolFeesTier); } // Complete the payment succeedPayment(_intent, amountSwapped, address(tokenIn), _msgSender()); } // @inheritdoc ITransfers function swapAndTransferUniswapV3TokenPreApproved( TransferIntent calldata _intent, address _tokenIn, uint256 maxWillingToPay, uint24 poolFeesTier ) external override nonReentrant whenNotPaused validIntent(_intent, _msgSender()) operatorIsRegistered(_intent) { IERC20 tokenIn = IERC20(_tokenIn); // Make sure a swap is actually required if (address(tokenIn) == _intent.recipientCurrency) { revert IncorrectCurrency(address(tokenIn)); } // Make sure the payer has enough of the payment token uint256 payerBalance = tokenIn.balanceOf(_msgSender()); if (payerBalance < maxWillingToPay) { revert InsufficientBalance(maxWillingToPay - payerBalance); } // Make sure the payer has approved this contract for a sufficient transfer uint256 allowance = tokenIn.allowance(_msgSender(), address(this)); if (allowance < maxWillingToPay) { revert InsufficientAllowance(maxWillingToPay - allowance); } uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 amountSwapped = 0; if (neededAmount > 0) { // Record our balance before (most likely zero) to detect fee-on-transfer tokens uint256 balanceBefore = tokenIn.balanceOf(address(this)); // Transfer the payment token to this contract tokenIn.safeTransferFrom(_msgSender(), address(this), maxWillingToPay); // Make sure this is not a fee-on-transfer token revertIfInexactTransfer(maxWillingToPay, balanceBefore, tokenIn, address(this)); // Perform the swap amountSwapped = swapTokens(_intent, address(tokenIn), maxWillingToPay, poolFeesTier); } // Complete the payment succeedPayment(_intent, amountSwapped, address(tokenIn), _msgSender()); } // @inheritdoc ITransfers function subsidizedTransferToken( TransferIntent calldata _intent, EIP2612SignatureTransferData calldata _signatureTransferData ) external override nonReentrant whenNotPaused validIntent(_intent, _signatureTransferData.owner) operatorIsRegistered(_intent) { // Make sure the recipient wants a token if (_intent.recipientCurrency == NATIVE_CURRENCY) { revert IncorrectCurrency(_intent.recipientCurrency); } // Check the balance of the payer IERC20 erc20 = IERC20(_intent.recipientCurrency); uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; uint256 payerBalance = erc20.balanceOf(_signatureTransferData.owner); if (payerBalance < neededAmount) { revert InsufficientBalance(neededAmount - payerBalance); } // Permit this contract to spend the payer's tokens IERC2612 erc20Permit = IERC2612(_intent.recipientCurrency); (uint8 v, bytes32 r, bytes32 s) = splitSignature(_signatureTransferData.signature); erc20Permit.permit(_signatureTransferData.owner, address(this), neededAmount, _intent.deadline, v, r, s); // Check the payer has approved this contract for a sufficient transfer uint256 allowance = erc20.allowance(_signatureTransferData.owner, address(this)); if (allowance < neededAmount) { revert InsufficientAllowance(neededAmount - allowance); } if (neededAmount > 0) { // Record our balance before (most likely zero) to detect fee-on-transfer tokens uint256 balanceBefore = erc20.balanceOf(address(this)); // Transfer the payment token to this contract erc20.safeTransferFrom(_signatureTransferData.owner, address(this), neededAmount); // Make sure this is not a fee-on-transfer token revertIfInexactTransfer(neededAmount, balanceBefore, erc20, address(this)); // Complete the payment transferFundsToDestinations(_intent); } succeedPayment(_intent, neededAmount, _intent.recipientCurrency, _signatureTransferData.owner); } function splitSignature(bytes calldata sig) internal pure returns ( uint8 v, bytes32 r, bytes32 s ) { if (sig.length != 65) { revert InvalidEIP2612Signature(); } r = bytes32(sig[0:32]); s = bytes32(sig[32:64]); v = uint8(bytes1(sig[64:65])); } function swapTokens( TransferIntent calldata _intent, address tokenIn, uint256 maxAmountWillingToPay, uint24 poolFeesTier ) internal returns (uint256) { // If the seller is requesting native currency, we need to swap for the wrapped // version of that currency first, then unwrap it and send it to the seller. address tokenOut = _intent.recipientCurrency == NATIVE_CURRENCY ? address(wrappedNativeCurrency) : _intent.recipientCurrency; // Figure out the total output needed from the swap uint256 neededAmount = _intent.recipientAmount + _intent.feeAmount; // Parameters and shared inputs for the universal router bytes memory uniswap_commands; bytes[] memory uniswap_inputs; bytes memory swapPath = abi.encodePacked(tokenOut, poolFeesTier, tokenIn); bytes memory swapParams = abi.encode(address(uniswap), neededAmount, maxAmountWillingToPay, swapPath, false); bytes memory transferToRecipient = abi.encode( _intent.recipientCurrency, _intent.recipient, _intent.recipientAmount ); bytes memory collectFees = abi.encode( _intent.recipientCurrency, feeDestinations[_intent.operator], _intent.feeAmount ); // The payer's and router's balances before this transaction, used to calculate the amount consumed by the swap uint256 payerBalanceBefore; uint256 routerBalanceBefore; // The fee and recipient balances of the output token, to detect fee-on-transfer tokens uint256 feeBalanceBefore; uint256 recipientBalanceBefore; // Populate the commands and inputs for the universal router if (msg.value > 0) { payerBalanceBefore = _msgSender().balance + msg.value; routerBalanceBefore = address(uniswap).balance + IERC20(wrappedNativeCurrency).balanceOf(address(uniswap)); feeBalanceBefore = IERC20(tokenOut).balanceOf(feeDestinations[_intent.operator]); recipientBalanceBefore = IERC20(tokenOut).balanceOf(_intent.recipient); // Paying with ETH, merchant wants tokenOut uniswap_commands = abi.encodePacked( bytes1(uint8(UniswapCommands.WRAP_ETH)), bytes1(uint8(UniswapCommands.V3_SWAP_EXACT_OUT)), bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.UNWRAP_WETH)), // for the payer refund bytes1(uint8(UniswapCommands.SWEEP)) ); uniswap_inputs = new bytes[](6); uniswap_inputs[0] = abi.encode(address(uniswap), msg.value); uniswap_inputs[1] = swapParams; uniswap_inputs[2] = collectFees; uniswap_inputs[3] = transferToRecipient; uniswap_inputs[4] = abi.encode(address(uniswap), 0); uniswap_inputs[5] = abi.encode(UniswapConstants.ETH, _msgSender(), 0); } else { // No need to check fee/recipient balance of the output token before, // since we know WETH and ETH are not fee-on-transfer payerBalanceBefore = IERC20(tokenIn).balanceOf(_msgSender()) + maxAmountWillingToPay; routerBalanceBefore = IERC20(tokenIn).balanceOf(address(uniswap)); if (_intent.recipientCurrency == NATIVE_CURRENCY) { // Paying with token, merchant wants ETH uniswap_commands = abi.encodePacked( bytes1(uint8(UniswapCommands.V3_SWAP_EXACT_OUT)), bytes1(uint8(UniswapCommands.UNWRAP_WETH)), // for the recipient bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.SWEEP)) ); uniswap_inputs = new bytes[](5); uniswap_inputs[0] = swapParams; uniswap_inputs[1] = abi.encode(address(uniswap), neededAmount); uniswap_inputs[2] = collectFees; uniswap_inputs[3] = transferToRecipient; uniswap_inputs[4] = abi.encode(tokenIn, _msgSender(), 0); } else { feeBalanceBefore = IERC20(tokenOut).balanceOf(feeDestinations[_intent.operator]); recipientBalanceBefore = IERC20(tokenOut).balanceOf(_intent.recipient); // Paying with token, merchant wants tokenOut uniswap_commands = abi.encodePacked( bytes1(uint8(UniswapCommands.V3_SWAP_EXACT_OUT)), bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.TRANSFER)), bytes1(uint8(UniswapCommands.SWEEP)) ); uniswap_inputs = new bytes[](4); uniswap_inputs[0] = swapParams; uniswap_inputs[1] = collectFees; uniswap_inputs[2] = transferToRecipient; uniswap_inputs[3] = abi.encode(tokenIn, _msgSender(), 0); } // Send the input tokens to Uniswap for the swap IERC20(tokenIn).safeTransfer(address(uniswap), maxAmountWillingToPay); } // Perform the swap try uniswap.execute{value: msg.value}(uniswap_commands, uniswap_inputs, _intent.deadline) { // Disallow fee-on-transfer tokens as the output token, since we want to guarantee exact settlement if (_intent.recipientCurrency != NATIVE_CURRENCY) { revertIfInexactTransfer( _intent.feeAmount, feeBalanceBefore, IERC20(tokenOut), feeDestinations[_intent.operator] ); revertIfInexactTransfer( _intent.recipientAmount, recipientBalanceBefore, IERC20(tokenOut), _intent.recipient ); } // Calculate and return how much of the input token was consumed by the swap. The router // could have had a balance of the input token prior to this transaction, which would have // been swept to the payer. This amount, if any, must be accounted for so we don't underflow // and assume that negative amount of the input token was consumed by the swap. uint256 payerBalanceAfter; uint256 routerBalanceAfter; if (msg.value > 0) { payerBalanceAfter = _msgSender().balance; routerBalanceAfter = address(uniswap).balance + IERC20(wrappedNativeCurrency).balanceOf(address(uniswap)); } else { payerBalanceAfter = IERC20(tokenIn).balanceOf(_msgSender()); routerBalanceAfter = IERC20(tokenIn).balanceOf(address(uniswap)); } return (payerBalanceBefore + routerBalanceBefore) - (payerBalanceAfter + routerBalanceAfter); } catch Error(string memory reason) { revert SwapFailedString(reason); } catch (bytes memory reason) { bytes32 reasonHash = keccak256(reason); if (reasonHash == V3_INVALID_SWAP) { revert SwapFailedString("V3InvalidSwap"); } else if (reasonHash == V3_TOO_LITTLE_RECEIVED) { revert SwapFailedString("V3TooLittleReceived"); } else if (reasonHash == V3_TOO_MUCH_REQUESTED) { revert SwapFailedString("V3TooMuchRequested"); } else if (reasonHash == V3_INVALID_AMOUNT_OUT) { revert SwapFailedString("V3InvalidAmountOut"); } else if (reasonHash == V3_INVALID_CALLER) { revert SwapFailedString("V3InvalidCaller"); } else { revert SwapFailedBytes(reason); } } } function transferFundsToDestinations(TransferIntent calldata _intent) internal { if (_intent.recipientCurrency == NATIVE_CURRENCY) { if (_intent.recipientAmount > 0) { sendNative(_intent.recipient, _intent.recipientAmount, false); } if (_intent.feeAmount > 0) { sendNative(feeDestinations[_intent.operator], _intent.feeAmount, false); } } else { IERC20 requestedCurrency = IERC20(_intent.recipientCurrency); if (_intent.recipientAmount > 0) { requestedCurrency.safeTransfer(_intent.recipient, _intent.recipientAmount); } if (_intent.feeAmount > 0) { requestedCurrency.safeTransfer(feeDestinations[_intent.operator], _intent.feeAmount); } } } function unwrapAndTransferFundsToDestinations(TransferIntent calldata _intent) internal { uint256 amountToWithdraw = _intent.recipientAmount + _intent.feeAmount; if (_intent.recipientCurrency == NATIVE_CURRENCY && amountToWithdraw > 0) { wrappedNativeCurrency.withdraw(amountToWithdraw); } transferFundsToDestinations(_intent); } function succeedPayment( TransferIntent calldata _intent, uint256 spentAmount, address spentCurrency, address sender ) internal { processedTransferIntents[_intent.operator][_intent.id] = true; emit Transferred(_intent.operator, _intent.id, _intent.recipient, sender, spentAmount, spentCurrency); } function sendNative( address destination, uint256 amount, bool isRefund ) internal { (bool success, bytes memory data) = payable(destination).call{value: amount}(""); if (!success) { revert NativeTransferFailed(destination, amount, isRefund, data); } } function revertIfInexactTransfer( uint256 expectedDiff, uint256 balanceBefore, IERC20 token, address target ) internal view { uint256 balanceAfter = token.balanceOf(target); if (balanceAfter - balanceBefore != expectedDiff) { revert InexactTransfer(); } } // @notice Registers an operator with a custom fee destination. function registerOperatorWithFeeDestination(address _feeDestination) external { feeDestinations[_msgSender()] = _feeDestination; emit OperatorRegistered(_msgSender(), _feeDestination); } // @notice Registers an operator, using the operator's address as the fee destination. function registerOperator() external { feeDestinations[_msgSender()] = _msgSender(); emit OperatorRegistered(_msgSender(), _msgSender()); } function unregisterOperator() external { delete feeDestinations[_msgSender()]; emit OperatorUnregistered(_msgSender()); } // @notice Allows the owner to pause the contract. function pause() external onlyOwner { _pause(); } // @notice Allows the owner to un-pause the contract. function unpause() external onlyOwner { _unpause(); } // @dev Required to be able to unwrap WETH receive() external payable { require(msg.sender == address(wrappedNativeCurrency), "only payable for unwrapping"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2612.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20Permit.sol"; interface IERC2612 is IERC20Permit {}
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, 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 and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // 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) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the 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. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // 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 preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.15; import {ERC20} from 'solmate/src/tokens/ERC20.sol'; /// @title LooksRare Rewards Collector /// @notice Implements a permissionless call to fetch LooksRare rewards earned by Universal Router users /// and transfers them to an external rewards distributor contract interface IRewardsCollector { /// @notice Fetches users' LooksRare rewards and sends them to the distributor contract /// @param looksRareClaim The data required by LooksRare to claim reward tokens function collectRewards(bytes calldata looksRareClaim) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IERC721Receiver} from '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import {IERC1155Receiver} from '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol'; import {IRewardsCollector} from './IRewardsCollector.sol'; interface IUniversalRouter is IRewardsCollector, IERC721Receiver, IERC1155Receiver { /// @notice Thrown when a required command has failed error ExecutionFailed(uint256 commandIndex, bytes message); /// @notice Thrown when attempting to send ETH directly to the contract error ETHNotAccepted(); /// @notice Thrown when executing commands with an expired deadline error TransactionDeadlinePassed(); /// @notice Thrown when attempting to execute commands and an incorrect number of inputs are provided error LengthMismatch(); /// @notice Executes encoded commands along with provided inputs. Reverts if deadline has expired. /// @param commands A set of concatenated commands, each 1 byte in length /// @param inputs An array of byte strings containing abi encoded inputs for each command /// @param deadline The deadline by which the transaction must be executed function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; /// @title Commands /// @notice Command Flags used to decode commands library Commands { // Masks to extract certain bits of commands bytes1 internal constant FLAG_ALLOW_REVERT = 0x80; bytes1 internal constant COMMAND_TYPE_MASK = 0x3f; // Command Types. Maximum supported command at this moment is 0x3f. // Command Types where value<0x08, executed in the first nested-if block uint256 constant V3_SWAP_EXACT_IN = 0x00; uint256 constant V3_SWAP_EXACT_OUT = 0x01; uint256 constant PERMIT2_TRANSFER_FROM = 0x02; uint256 constant PERMIT2_PERMIT_BATCH = 0x03; uint256 constant SWEEP = 0x04; uint256 constant TRANSFER = 0x05; uint256 constant PAY_PORTION = 0x06; // COMMAND_PLACEHOLDER = 0x07; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant FIRST_IF_BOUNDARY = 0x08; // Command Types where 0x08<=value<=0x0f, executed in the second nested-if block uint256 constant V2_SWAP_EXACT_IN = 0x08; uint256 constant V2_SWAP_EXACT_OUT = 0x09; uint256 constant PERMIT2_PERMIT = 0x0a; uint256 constant WRAP_ETH = 0x0b; uint256 constant UNWRAP_WETH = 0x0c; uint256 constant PERMIT2_TRANSFER_FROM_BATCH = 0x0d; uint256 constant BALANCE_CHECK_ERC20 = 0x0e; // COMMAND_PLACEHOLDER = 0x0f; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant SECOND_IF_BOUNDARY = 0x10; // Command Types where 0x10<=value<0x18, executed in the third nested-if block uint256 constant SEAPORT_V1_5 = 0x10; uint256 constant LOOKS_RARE_V2 = 0x11; uint256 constant NFTX = 0x12; uint256 constant CRYPTOPUNKS = 0x13; // 0x14; uint256 constant OWNER_CHECK_721 = 0x15; uint256 constant OWNER_CHECK_1155 = 0x16; uint256 constant SWEEP_ERC721 = 0x17; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant THIRD_IF_BOUNDARY = 0x18; // Command Types where 0x18<=value<=0x1f, executed in the final nested-if block uint256 constant X2Y2_721 = 0x18; uint256 constant SUDOSWAP = 0x19; uint256 constant NFT20 = 0x1a; uint256 constant X2Y2_1155 = 0x1b; uint256 constant FOUNDATION = 0x1c; uint256 constant SWEEP_ERC1155 = 0x1d; uint256 constant ELEMENT_MARKET = 0x1e; // COMMAND_PLACEHOLDER = 0x1f; // The commands are executed in nested if blocks to minimise gas consumption // The following constant defines one of the boundaries where the if blocks split commands uint256 constant FOURTH_IF_BOUNDARY = 0x20; // Command Types where 0x20<=value uint256 constant SEAPORT_V1_4 = 0x20; uint256 constant EXECUTE_SUB_PLAN = 0x21; uint256 constant APPROVE_ERC20 = 0x22; uint256 constant WRAP_STETH = 0x23; uint256 constant UNWRAP_STETH = 0x24; // COMMAND_PLACEHOLDER for 0x25 to 0x3f (all unused) }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import {IWETH9} from '../interfaces/external/IWETH9.sol'; /// @title Constant state /// @notice Constant state used by the Universal Router library Constants { /// @dev Used for identifying cases when this contract's balance of a token is to be used as an input /// This value is equivalent to 1<<255, i.e. a singular 1 in the most significant bit. uint256 internal constant CONTRACT_BALANCE = 0x8000000000000000000000000000000000000000000000000000000000000000; /// @dev Used for identifying cases when a v2 pair has already received input tokens uint256 internal constant ALREADY_PAID = 0; /// @dev Used as a flag for identifying the transfer of ETH instead of a token address internal constant ETH = address(0); /// @dev Used as a flag for identifying that msg.sender should be used, saves gas by sending more 0 bytes address internal constant MSG_SENDER = address(1); /// @dev Used as a flag for identifying address(this) should be used, saves gas by sending more 0 bytes address internal constant ADDRESS_THIS = address(2); /// @dev The length of the bytes encoded address uint256 internal constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 internal constant V3_FEE_SIZE = 3; /// @dev The offset of a single token address (20) and pool fee (3) uint256 internal constant NEXT_V3_POOL_OFFSET = ADDR_SIZE + V3_FEE_SIZE; /// @dev The offset of an encoded pool key /// Token (20) + Fee (3) + Token (20) = 43 uint256 internal constant V3_POP_OFFSET = NEXT_V3_POOL_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 internal constant MULTIPLE_V3_POOLS_MIN_LENGTH = V3_POP_OFFSET + NEXT_V3_POOL_OFFSET; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../permit2/src/interfaces/ISignatureTransfer.sol"; // @notice Description of the transfer // @member recipientAmount Amount of currency to transfer // @member deadline The timestamp by when the transfer must be in a block. // @member chainId The chain which the transfer must occur on. // @member recipient The address which will receive the funds. // @member recipientCurrency The currency address that amount is priced in. // @member refundDestination The address which will receive any refunds. If blank, this will be msg.sender. // @member feeAmount The fee value (in currency) to send to the operator. // @member id An ID which can be used to track payments. // @member operator The address of the operator (who created and signed the intent). // @member signature A hash of all the other struct properties signed by the operator. // @member prefix An alternate signature prefix to use instead of the standard EIP-191 "\x19Ethereum Signed Message:\n" // @dev signature=keccak256(encodePacked(...allPropsInOrderExceptSignatureAndPrefix, chainId, _msgSender(), address(transfersContract)) struct TransferIntent { uint256 recipientAmount; uint256 deadline; address payable recipient; address recipientCurrency; address refundDestination; uint256 feeAmount; bytes16 id; address operator; bytes signature; bytes prefix; } struct Permit2SignatureTransferData { ISignatureTransfer.PermitTransferFrom permit; ISignatureTransfer.SignatureTransferDetails transferDetails; bytes signature; } struct EIP2612SignatureTransferData { address owner; // The owner of the funds bytes signature; // The signature for the permit } // @title Transfers Contract // @notice Functions for making checked transfers between accounts interface ITransfers { // @notice Emitted when a transfer is completed // @param operator The operator for the transfer intent // @param id The ID of the transfer intent // @param recipient Who recieved the funds. // @param sender Who sent the funds. // @param spentAmount How much the payer sent // @param spentCurrency What currency the payer sent event Transferred( address indexed operator, bytes16 id, address recipient, address sender, uint256 spentAmount, address spentCurrency ); // @notice Raised when a native currency transfer fails // @param recipient Who the transfer was intended for // @param amount The amount of the transfer // @param isRefund Whether the transfer was part of a refund // @param data The data returned from the failed call error NativeTransferFailed(address recipient, uint256 amount, bool isRefund, bytes data); // @notice Emitted when an operator is registered // @param operator The operator that was registered // @param feeDestination The new fee destination for the operator event OperatorRegistered(address operator, address feeDestination); // @notice Emitted when an operator is unregistered // @param operator The operator that was registered event OperatorUnregistered(address operator); // @notice Raised when the operator in the intent is not registered error OperatorNotRegistered(); // @notice Raised when the intent signature is invalid error InvalidSignature(); // @notice Raised when the invalid amount of native currency is provided // @param difference The surplus (or deficit) amount sent error InvalidNativeAmount(int256 difference); // @notice Raised when the payer does not have enough of the payment token // @param difference The balance deficit error InsufficientBalance(uint256 difference); // @notice Raised when the payer has not approved enough of the payment token // @param difference The allowance deficit error InsufficientAllowance(uint256 difference); // @notice Raised when providing an intent with the incorrect currency. e.g. a USDC intent to `wrapAndTransfer` // @param attemptedCurrency The currency the payer attempted to pay with error IncorrectCurrency(address attemptedCurrency); // @notice Raised when the permit2 transfer details are incorrect error InvalidTransferDetails(); // @notice Raised when an intent is paid past its deadline error ExpiredIntent(); // @notice Raised when an intent's recipient is the null address error NullRecipient(); // @notice Raised when an intent has already been processed error AlreadyProcessed(); // @notice Raised when a transfer does not result in the correct balance increase, // such as with fee-on-transfer tokens error InexactTransfer(); // @notice Raised when a swap fails and returns a reason string // @param reason The error reason returned from the swap error SwapFailedString(string reason); // @notice Raised when a swap fails and returns another error // @param reason The error reason returned from the swap error SwapFailedBytes(bytes reason); // @notice Raised when the EIP2612 signature is invalid error InvalidEIP2612Signature(); // @notice Send the exact amount of the native currency from the sender to the recipient. // @dev The intent's recipient currency must be the native currency. // @param _intent The intent which describes the transfer function transferNative(TransferIntent calldata _intent) external payable; // @notice Transfer the exact amount of any ERC-20 token from the sender to the recipient. // @dev The intent's recipient currency must be an ERC-20 token matching the one in `_signatureTransferData`. // @dev The user must have approved the Permit2 contract for at least `_intent.recipientAmount + _intent.feeAmount` // with the `_intent.recipientCurrency` ERC-20 contract prior to invoking. // @param _intent The intent which describes the transfer function transferToken( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData ) external; // @notice Transfer the exact amount of any ERC-20 token from the sender to the recipient. // @dev The intent's recipient currency must be an ERC-20 token. // @dev The user must have approved this contract for at least `_intent.recipientAmount + _intent.feeAmount` // with the `_intent.recipientCurrency` ERC-20 contract prior to invoking. // @param _intent The intent which describes the transfer function transferTokenPreApproved(TransferIntent calldata _intent) external; // @notice Takes native currency (e.g. ETH) from the sender and sends wrapped currency (e.g. wETH) to the recipient. // @dev The intent's recipient currency must be the wrapped native currency. // @param _intent The intent which describes the transfer function wrapAndTransfer(TransferIntent calldata _intent) external payable; // @notice Takes wrapped currency (e.g. wETH) from the sender and sends native currency (e.g. ETH) to the recipient. // @dev The intent's recipient currency must be the native currency. // @dev The user must have approved the Permit2 contract for at least `_intent.recipientAmount + _intent.feeAmount` // with the wETH contract prior to invoking. // @param _intent The intent which describes the transfer // @param _signatureTransferData The signed Permit2 transfer data for the payment function unwrapAndTransfer( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData ) external; // @notice Takes wrapped currency (e.g. wETH) from the sender and sends native currency (e.g. ETH) to the recipient. // @dev The intent's recipient currency must be the native currency. // @dev The user must have approved this contract for at least `_intent.recipientAmount + _intent.feeAmount` with the wETH contract prior to invoking. // @param _intent The intent which describes the transfer function unwrapAndTransferPreApproved(TransferIntent calldata _intent) external; // @notice Allows the sender to pay for an intent with a swap from the native currency using Uniswap. // @param _intent The intent which describes the transfer // @param poolFeesTier The Uniswap pool fee the user wishes to pay. See: https://docs.uniswap.org/protocol/concepts/V3-overview/fees#pool-fees-tiers function swapAndTransferUniswapV3Native(TransferIntent calldata _intent, uint24 poolFeesTier) external payable; // @notice Allows the sender to pay for an intent with a swap from any ERC-20 token using Uniswap. // @dev The user must have approved the Permit2 contract for at least `_signatureTransferData.transferDetails.requestedAmount` // with the `_signatureTransferData.permit.permitted.token` ERC-20 contract prior to invoking. // @param _intent The intent which describes the transfer // @param _signatureTransferData The signed Permit2 transfer data for the payment // @param poolFeesTier The Uniswap pool fee the user wishes to pay. See: https://docs.uniswap.org/protocol/concepts/V3-overview/fees#pool-fees-tiers function swapAndTransferUniswapV3Token( TransferIntent calldata _intent, Permit2SignatureTransferData calldata _signatureTransferData, uint24 poolFeesTier ) external; // @notice Allows the sender to pay for an intent with a swap from any ERC-20 token using Uniswap. // @dev The user must have approved this contract for at least `maxWillingToPay` with the `_tokenIn` ERC-20 contract prior to invoking. // @param _intent The intent which describes the transfer // @param _tokenIn The currency address which the sender wishes to pay for the intent. // @param maxWillingToPay The maximum amount of _tokenIn the sender is willing to pay. // @param poolFeesTier The Uniswap pool fee the user wishes to pay. See: https://docs.uniswap.org/protocol/concepts/V3-overview/fees#pool-fees-tiers function swapAndTransferUniswapV3TokenPreApproved( TransferIntent calldata _intent, address _tokenIn, uint256 maxWillingToPay, uint24 poolFeesTier ) external; // @notice Allows the sender to pay for an intent with gasless transaction // @param _intent The intent which describes the transfer // @param _signatureTransferData The signed EIP-2612 permit data for the payment function subsidizedTransferToken( TransferIntent calldata _intent, EIP2612SignatureTransferData calldata _signatureTransferData ) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // @title Represented wrapped (e.g. wETH) currencies interface IWrappedNativeCurrency is IERC20 { function deposit() external payable; function withdraw(uint256) external; }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {ERC20} from "../solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "../solmate/utils/SafeTransferLib.sol"; import {PermitHash} from "./libraries/PermitHash.sol"; import {SignatureVerification} from "./libraries/SignatureVerification.sol"; import {EIP712} from "./EIP712.sol"; import {IAllowanceTransfer} from "../src/interfaces/IAllowanceTransfer.sol"; import {SignatureExpired, InvalidNonce} from "./PermitErrors.sol"; import {Allowance} from "./libraries/Allowance.sol"; contract AllowanceTransfer is IAllowanceTransfer, EIP712 { using SignatureVerification for bytes; using SafeTransferLib for ERC20; using PermitHash for PermitSingle; using PermitHash for PermitBatch; using Allowance for PackedAllowance; /// @notice Maps users to tokens to spender addresses and information about the approval on the token /// @dev Indexed in the order of token owner address, token address, spender address /// @dev The stored word saves the allowed amount, expiration on the allowance, and nonce mapping(address => mapping(address => mapping(address => PackedAllowance))) public allowance; /// @inheritdoc IAllowanceTransfer function approve(address token, address spender, uint160 amount, uint48 expiration) external { PackedAllowance storage allowed = allowance[msg.sender][token][spender]; allowed.updateAmountAndExpiration(amount, expiration); emit Approval(msg.sender, token, spender, amount, expiration); } /// @inheritdoc IAllowanceTransfer function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external { if (block.timestamp > permitSingle.sigDeadline) revert SignatureExpired(permitSingle.sigDeadline); // Verify the signer address from the signature. signature.verify(_hashTypedData(permitSingle.hash()), owner); _updateApproval(permitSingle.details, owner, permitSingle.spender); } /// @inheritdoc IAllowanceTransfer function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external { if (block.timestamp > permitBatch.sigDeadline) revert SignatureExpired(permitBatch.sigDeadline); // Verify the signer address from the signature. signature.verify(_hashTypedData(permitBatch.hash()), owner); address spender = permitBatch.spender; unchecked { uint256 length = permitBatch.details.length; for (uint256 i = 0; i < length; ++i) { _updateApproval(permitBatch.details[i], owner, spender); } } } /// @inheritdoc IAllowanceTransfer function transferFrom(address from, address to, uint160 amount, address token) external { _transfer(from, to, amount, token); } /// @inheritdoc IAllowanceTransfer function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external { unchecked { uint256 length = transferDetails.length; for (uint256 i = 0; i < length; ++i) { AllowanceTransferDetails memory transferDetail = transferDetails[i]; _transfer(transferDetail.from, transferDetail.to, transferDetail.amount, transferDetail.token); } } } /// @notice Internal function for transferring tokens using stored allowances /// @dev Will fail if the allowed timeframe has passed function _transfer(address from, address to, uint160 amount, address token) private { PackedAllowance storage allowed = allowance[from][token][msg.sender]; if (block.timestamp > allowed.expiration) revert AllowanceExpired(allowed.expiration); uint256 maxAmount = allowed.amount; if (maxAmount != type(uint160).max) { if (amount > maxAmount) { revert InsufficientAllowance(maxAmount); } else { unchecked { allowed.amount = uint160(maxAmount) - amount; } } } // Transfer the tokens from the from address to the recipient. ERC20(token).safeTransferFrom(from, to, amount); } /// @inheritdoc IAllowanceTransfer function lockdown(TokenSpenderPair[] calldata approvals) external { address owner = msg.sender; // Revoke allowances for each pair of spenders and tokens. unchecked { uint256 length = approvals.length; for (uint256 i = 0; i < length; ++i) { address token = approvals[i].token; address spender = approvals[i].spender; allowance[owner][token][spender].amount = 0; emit Lockdown(owner, token, spender); } } } /// @inheritdoc IAllowanceTransfer function invalidateNonces(address token, address spender, uint48 newNonce) external { uint48 oldNonce = allowance[msg.sender][token][spender].nonce; if (newNonce <= oldNonce) revert InvalidNonce(); // Limit the amount of nonces that can be invalidated in one transaction. unchecked { uint48 delta = newNonce - oldNonce; if (delta > type(uint16).max) revert ExcessiveInvalidation(); } allowance[msg.sender][token][spender].nonce = newNonce; emit NonceInvalidation(msg.sender, token, spender, newNonce, oldNonce); } /// @notice Sets the new values for amount, expiration, and nonce. /// @dev Will check that the signed nonce is equal to the current nonce and then incrememnt the nonce value by 1. /// @dev Emits a Permit event. function _updateApproval(PermitDetails memory details, address owner, address spender) private { uint48 nonce = details.nonce; address token = details.token; uint160 amount = details.amount; uint48 expiration = details.expiration; PackedAllowance storage allowed = allowance[owner][token][spender]; if (allowed.nonce != nonce) revert InvalidNonce(); allowed.updateAll(amount, expiration, nonce); emit Permit(owner, token, spender, amount, expiration, nonce); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; /// @notice EIP712 helpers for permit2 /// @dev Maintains cross-chain replay protection in the event of a fork /// @dev Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol contract EIP712 { // Cache the domain separator as an immutable value, but also store the chain id that it // corresponds to, in order to invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private constant _HASHED_NAME = keccak256("Permit2"); bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); constructor() { _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME); } /// @notice Returns the domain separator for the current chain. /// @dev Uses cached version if chainid and address are unchanged from construction. function DOMAIN_SEPARATOR() public view returns (bytes32) { return block.chainid == _CACHED_CHAIN_ID ? _CACHED_DOMAIN_SEPARATOR : _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME); } /// @notice Builds a domain separator using the current chainId and contract address. function _buildDomainSeparator(bytes32 typeHash, bytes32 nameHash) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, block.chainid, address(this))); } /// @notice Creates an EIP-712 typed data hash function _hashTypedData(bytes32 dataHash) internal view returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR(), dataHash)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {SignatureTransfer} from "./SignatureTransfer.sol"; import {AllowanceTransfer} from "./AllowanceTransfer.sol"; /// @notice Permit2 handles signature-based transfers in SignatureTransfer and allowance-based transfers in AllowanceTransfer. /// @dev Users must approve Permit2 before calling any of the transfer functions. contract Permit2 is SignatureTransfer, AllowanceTransfer { // Permit2 unifies the two contracts so users have maximal flexibility with their approval. }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; /// @notice Shared errors between signature based transfers and allowance based transfers. /// @notice Thrown when validating an inputted signature that is stale /// @param signatureDeadline The timestamp at which a signature is no longer valid error SignatureExpired(uint256 signatureDeadline); /// @notice Thrown when validating that the inputted nonce has not been used error InvalidNonce();
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {ISignatureTransfer} from "./interfaces/ISignatureTransfer.sol"; import {SignatureExpired, InvalidNonce} from "./PermitErrors.sol"; import {ERC20} from "../solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "../solmate/utils/SafeTransferLib.sol"; import {SignatureVerification} from "./libraries/SignatureVerification.sol"; import {PermitHash} from "./libraries/PermitHash.sol"; import {EIP712} from "./EIP712.sol"; contract SignatureTransfer is ISignatureTransfer, EIP712 { using SignatureVerification for bytes; using SafeTransferLib for ERC20; using PermitHash for PermitTransferFrom; using PermitHash for PermitBatchTransferFrom; /// @inheritdoc ISignatureTransfer mapping(address => mapping(uint256 => uint256)) public nonceBitmap; /// @inheritdoc ISignatureTransfer function permitTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature ) external { _permitTransferFrom(permit, transferDetails, owner, permit.hash(), signature); } /// @inheritdoc ISignatureTransfer function permitWitnessTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external { _permitTransferFrom( permit, transferDetails, owner, permit.hashWithWitness(witness, witnessTypeString), signature ); } /// @notice Transfers a token using a signed permit message. /// @dev If to is the zero address, the tokens are sent to the spender. /// @param permit The permit data signed over by the owner /// @param dataHash The EIP-712 hash of permit data to include when checking signature /// @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, bytes32 dataHash, bytes calldata signature ) private { uint256 requestedAmount = transferDetails.requestedAmount; if (block.timestamp > permit.deadline) revert SignatureExpired(permit.deadline); if (requestedAmount > permit.permitted.amount) revert InvalidAmount(permit.permitted.amount); _useUnorderedNonce(owner, permit.nonce); signature.verify(_hashTypedData(dataHash), owner); ERC20(permit.permitted.token).safeTransferFrom(owner, transferDetails.to, requestedAmount); } /// @inheritdoc ISignatureTransfer function permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes calldata signature ) external { _permitTransferFrom(permit, transferDetails, owner, permit.hash(), signature); } /// @inheritdoc ISignatureTransfer function permitWitnessTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external { _permitTransferFrom( permit, transferDetails, owner, permit.hashWithWitness(witness, witnessTypeString), signature ); } /// @notice Transfers tokens using a signed permit messages /// @dev If to is the zero address, the tokens are sent to the spender /// @param permit The permit data signed over by the owner /// @param dataHash The EIP-712 hash of permit data to include when checking signature /// @param owner The owner of the tokens to transfer /// @param signature The signature to verify function _permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes32 dataHash, bytes calldata signature ) private { uint256 numPermitted = permit.permitted.length; if (block.timestamp > permit.deadline) revert SignatureExpired(permit.deadline); if (numPermitted != transferDetails.length) revert LengthMismatch(); _useUnorderedNonce(owner, permit.nonce); signature.verify(_hashTypedData(dataHash), owner); unchecked { for (uint256 i = 0; i < numPermitted; ++i) { TokenPermissions memory permitted = permit.permitted[i]; uint256 requestedAmount = transferDetails[i].requestedAmount; if (requestedAmount > permitted.amount) revert InvalidAmount(permitted.amount); if (requestedAmount != 0) { // allow spender to specify which of the permitted tokens should be transferred ERC20(permitted.token).safeTransferFrom(owner, transferDetails[i].to, requestedAmount); } } } } /// @inheritdoc ISignatureTransfer function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external { nonceBitmap[msg.sender][wordPos] |= mask; emit UnorderedNonceInvalidation(msg.sender, wordPos, mask); } /// @notice Returns the index of the bitmap and the bit position within the bitmap. Used for unordered nonces /// @param nonce The nonce to get the associated word and bit positions /// @return wordPos The word position or index into the nonceBitmap /// @return bitPos The bit position /// @dev The first 248 bits of the nonce value is the index of the desired bitmap /// @dev The last 8 bits of the nonce value is the position of the bit in the bitmap function bitmapPositions(uint256 nonce) private pure returns (uint256 wordPos, uint256 bitPos) { wordPos = uint248(nonce >> 8); bitPos = uint8(nonce); } /// @notice Checks whether a nonce is taken and sets the bit at the bit position in the bitmap at the word position /// @param from The address to use the nonce at /// @param nonce The nonce to spend function _useUnorderedNonce(address from, uint256 nonce) internal { (uint256 wordPos, uint256 bitPos) = bitmapPositions(nonce); uint256 bit = 1 << bitPos; uint256 flipped = nonceBitmap[from][wordPos] ^= bit; if (flipped & bit == 0) revert InvalidNonce(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; /// @title AllowanceTransfer /// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts /// @dev Requires user's token approval on the Permit2 contract interface IAllowanceTransfer { /// @notice Thrown when an allowance on a token has expired. /// @param deadline The timestamp at which the allowed amount is no longer valid error AllowanceExpired(uint256 deadline); /// @notice Thrown when an allowance on a token has been depleted. /// @param amount The maximum amount allowed error InsufficientAllowance(uint256 amount); /// @notice Thrown when too many nonces are invalidated. error ExcessiveInvalidation(); /// @notice Emits an event when the owner successfully invalidates an ordered nonce. event NonceInvalidation( address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce ); /// @notice Emits an event when the owner successfully sets permissions on a token for the spender. event Approval( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration ); /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender. event Permit( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration, uint48 nonce ); /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function. event Lockdown(address indexed owner, address token, address spender); /// @notice The permit data for a token struct PermitDetails { // ERC20 token address address token; // the maximum amount allowed to spend uint160 amount; // timestamp at which a spender's token allowances become invalid uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice The permit message signed for a single token allownce struct PermitSingle { // the permit data for a single token alownce PermitDetails details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The permit message signed for multiple token allowances struct PermitBatch { // the permit data for multiple token allowances PermitDetails[] details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The saved permissions /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message /// @dev Setting amount to type(uint160).max sets an unlimited approval struct PackedAllowance { // amount allowed uint160 amount; // permission expiry uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice A token spender pair. struct TokenSpenderPair { // the token the spender is approved address token; // the spender address address spender; } /// @notice Details for a token transfer. struct AllowanceTransferDetails { // the owner of the token address from; // the recipient of the token address to; // the amount of the token uint160 amount; // the token to be transferred address token; } /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval. /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress] /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals. function allowance(address, address, address) external view returns (uint160, uint48, uint48); /// @notice Approves the spender to use up to amount of the specified token up until the expiration /// @param token The token to approve /// @param spender The spender address to approve /// @param amount The approved amount of the token /// @param expiration The timestamp at which the approval is no longer valid /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve /// @dev Setting amount to type(uint160).max sets an unlimited approval function approve(address token, address spender, uint160 amount, uint48 expiration) external; /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitSingle Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external; /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitBatch Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external; /// @notice Transfer approved tokens from one address to another /// @param from The address to transfer from /// @param to The address of the recipient /// @param amount The amount of the token to transfer /// @param token The token address to transfer /// @dev Requires the from address to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(address from, address to, uint160 amount, address token) external; /// @notice Transfer approved tokens in a batch /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers /// @dev Requires the from addresses to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external; /// @notice Enables performing a "lockdown" of the sender's Permit2 identity /// by batch revoking approvals /// @param approvals Array of approvals to revoke. function lockdown(TokenSpenderPair[] calldata approvals) external; /// @notice Invalidate nonces for a given (token, spender) pair /// @param token The token to invalidate nonces for /// @param spender The spender to invalidate nonces for /// @param newNonce The new nonce to set. Invalidates all nonces less than it. /// @dev Can't invalidate more than 2**16 nonces per transaction. function invalidateNonces(address token, address spender, uint48 newNonce) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; interface IERC1271 { /// @dev Should return whether the signature provided is valid for the provided data /// @param hash Hash of the data to be signed /// @param signature Signature byte array associated with _data /// @return magicValue The bytes4 magic value 0x1626ba7e function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; /// @title SignatureTransfer /// @notice Handles ERC20 token transfers through signature based actions /// @dev Requires user's token approval on the Permit2 contract interface ISignatureTransfer { /// @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.17; import {IAllowanceTransfer} from "../interfaces/IAllowanceTransfer.sol"; library Allowance { // note if the expiration passed is 0, then it the approval set to the block.timestamp uint256 private constant BLOCK_TIMESTAMP_EXPIRATION = 0; /// @notice Sets the allowed amount, expiry, and nonce of the spender's permissions on owner's token. /// @dev Nonce is incremented. /// @dev If the inputted expiration is 0, the stored expiration is set to block.timestamp function updateAll( IAllowanceTransfer.PackedAllowance storage allowed, uint160 amount, uint48 expiration, uint48 nonce ) internal { uint48 storedNonce; unchecked { storedNonce = nonce + 1; } uint48 storedExpiration = expiration == BLOCK_TIMESTAMP_EXPIRATION ? uint48(block.timestamp) : expiration; uint256 word = pack(amount, storedExpiration, storedNonce); assembly { sstore(allowed.slot, word) } } /// @notice Sets the allowed amount and expiry of the spender's permissions on owner's token. /// @dev Nonce does not need to be incremented. function updateAmountAndExpiration( IAllowanceTransfer.PackedAllowance storage allowed, uint160 amount, uint48 expiration ) internal { // If the inputted expiration is 0, the allowance only lasts the duration of the block. allowed.expiration = expiration == 0 ? uint48(block.timestamp) : expiration; allowed.amount = amount; } /// @notice Computes the packed slot of the amount, expiration, and nonce that make up PackedAllowance function pack(uint160 amount, uint48 expiration, uint48 nonce) internal pure returns (uint256 word) { word = (uint256(nonce) << 208) | uint256(expiration) << 160 | amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {IAllowanceTransfer} from "../interfaces/IAllowanceTransfer.sol"; import {ISignatureTransfer} from "../interfaces/ISignatureTransfer.sol"; library PermitHash { bytes32 public constant _PERMIT_DETAILS_TYPEHASH = keccak256("PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)"); bytes32 public constant _PERMIT_SINGLE_TYPEHASH = keccak256( "PermitSingle(PermitDetails details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)" ); bytes32 public constant _PERMIT_BATCH_TYPEHASH = keccak256( "PermitBatch(PermitDetails[] details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)" ); bytes32 public constant _TOKEN_PERMISSIONS_TYPEHASH = keccak256("TokenPermissions(address token,uint256 amount)"); bytes32 public constant _PERMIT_TRANSFER_FROM_TYPEHASH = keccak256( "PermitTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline)TokenPermissions(address token,uint256 amount)" ); bytes32 public constant _PERMIT_BATCH_TRANSFER_FROM_TYPEHASH = keccak256( "PermitBatchTransferFrom(TokenPermissions[] permitted,address spender,uint256 nonce,uint256 deadline)TokenPermissions(address token,uint256 amount)" ); string public constant _TOKEN_PERMISSIONS_TYPESTRING = "TokenPermissions(address token,uint256 amount)"; string public constant _PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB = "PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,"; string public constant _PERMIT_BATCH_WITNESS_TRANSFER_FROM_TYPEHASH_STUB = "PermitBatchWitnessTransferFrom(TokenPermissions[] permitted,address spender,uint256 nonce,uint256 deadline,"; function hash(IAllowanceTransfer.PermitSingle memory permitSingle) internal pure returns (bytes32) { bytes32 permitHash = _hashPermitDetails(permitSingle.details); return keccak256(abi.encode(_PERMIT_SINGLE_TYPEHASH, permitHash, permitSingle.spender, permitSingle.sigDeadline)); } function hash(IAllowanceTransfer.PermitBatch memory permitBatch) internal pure returns (bytes32) { uint256 numPermits = permitBatch.details.length; bytes32[] memory permitHashes = new bytes32[](numPermits); for (uint256 i = 0; i < numPermits; ++i) { permitHashes[i] = _hashPermitDetails(permitBatch.details[i]); } return keccak256( abi.encode( _PERMIT_BATCH_TYPEHASH, keccak256(abi.encodePacked(permitHashes)), permitBatch.spender, permitBatch.sigDeadline ) ); } function hash(ISignatureTransfer.PermitTransferFrom memory permit) internal view returns (bytes32) { bytes32 tokenPermissionsHash = _hashTokenPermissions(permit.permitted); return keccak256( abi.encode(_PERMIT_TRANSFER_FROM_TYPEHASH, tokenPermissionsHash, msg.sender, permit.nonce, permit.deadline) ); } function hash(ISignatureTransfer.PermitBatchTransferFrom memory permit) internal view returns (bytes32) { uint256 numPermitted = permit.permitted.length; bytes32[] memory tokenPermissionHashes = new bytes32[](numPermitted); for (uint256 i = 0; i < numPermitted; ++i) { tokenPermissionHashes[i] = _hashTokenPermissions(permit.permitted[i]); } return keccak256( abi.encode( _PERMIT_BATCH_TRANSFER_FROM_TYPEHASH, keccak256(abi.encodePacked(tokenPermissionHashes)), msg.sender, permit.nonce, permit.deadline ) ); } function hashWithWitness( ISignatureTransfer.PermitTransferFrom memory permit, bytes32 witness, string calldata witnessTypeString ) internal view returns (bytes32) { bytes32 typeHash = keccak256(abi.encodePacked(_PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB, witnessTypeString)); bytes32 tokenPermissionsHash = _hashTokenPermissions(permit.permitted); return keccak256(abi.encode(typeHash, tokenPermissionsHash, msg.sender, permit.nonce, permit.deadline, witness)); } function hashWithWitness( ISignatureTransfer.PermitBatchTransferFrom memory permit, bytes32 witness, string calldata witnessTypeString ) internal view returns (bytes32) { bytes32 typeHash = keccak256(abi.encodePacked(_PERMIT_BATCH_WITNESS_TRANSFER_FROM_TYPEHASH_STUB, witnessTypeString)); uint256 numPermitted = permit.permitted.length; bytes32[] memory tokenPermissionHashes = new bytes32[](numPermitted); for (uint256 i = 0; i < numPermitted; ++i) { tokenPermissionHashes[i] = _hashTokenPermissions(permit.permitted[i]); } return keccak256( abi.encode( typeHash, keccak256(abi.encodePacked(tokenPermissionHashes)), msg.sender, permit.nonce, permit.deadline, witness ) ); } function _hashPermitDetails(IAllowanceTransfer.PermitDetails memory details) private pure returns (bytes32) { return keccak256(abi.encode(_PERMIT_DETAILS_TYPEHASH, details)); } function _hashTokenPermissions(ISignatureTransfer.TokenPermissions memory permitted) private pure returns (bytes32) { return keccak256(abi.encode(_TOKEN_PERMISSIONS_TYPEHASH, permitted)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {IERC1271} from "../interfaces/IERC1271.sol"; library SignatureVerification { /// @notice Thrown when the passed in signature is not a valid length error InvalidSignatureLength(); /// @notice Thrown when the recovered signer is equal to the zero address error InvalidSignature(); /// @notice Thrown when the recovered signer does not equal the claimedSigner error InvalidSigner(); /// @notice Thrown when the recovered contract signature is incorrect error InvalidContractSignature(); bytes32 constant UPPER_BIT_MASK = (0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); function verify(bytes calldata signature, bytes32 hash, address claimedSigner) internal view { bytes32 r; bytes32 s; uint8 v; if (claimedSigner.code.length == 0) { if (signature.length == 65) { (r, s) = abi.decode(signature, (bytes32, bytes32)); v = uint8(signature[64]); } else if (signature.length == 64) { // EIP-2098 bytes32 vs; (r, vs) = abi.decode(signature, (bytes32, bytes32)); s = vs & UPPER_BIT_MASK; v = uint8(uint256(vs >> 255)) + 27; } else { revert InvalidSignatureLength(); } address signer = ecrecover(hash, v, r, s); if (signer == address(0)) revert InvalidSignature(); if (signer != claimedSigner) revert InvalidSigner(); } else { bytes4 magicValue = IERC1271(claimedSigner).isValidSignature(hash, signature); if (magicValue != IERC1271.isValidSignature.selector) revert InvalidContractSignature(); } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; // @title Sweepable contract // @notice Implements a role that can sweep stuck funds to an address provided // at the time of the call abstract contract Sweepable is Context, Ownable { using SafeERC20 for IERC20; // @dev The address of the current sweeper address private _sweeper; // @dev Restricts the caller to the current sweeper modifier onlySweeper() { require(sweeper() == _msgSender(), "Sweepable: not the sweeper"); _; } modifier notZero(address a) { require(a != address(0), "Sweepable: cannot be zero address"); _; } // @dev Returns the current sweeper function sweeper() public view virtual returns (address) { return _sweeper; } // @dev Sets the sweeper // @notice To remove the sweeper role entirely, set this to the zero address. function setSweeper(address newSweeper) public virtual onlyOwner notZero(newSweeper) { _sweeper = newSweeper; } // @dev Sweeps the entire ETH balance to `destination` function sweepETH(address payable destination) public virtual onlySweeper notZero(destination) { uint256 balance = address(this).balance; require(balance > 0, "Sweepable: zero balance"); (bool success, ) = destination.call{value: balance}(""); require(success, "Sweepable: transfer error"); } // @dev Sweeps a specific ETH `amount` to `destination` function sweepETHAmount(address payable destination, uint256 amount) public virtual onlySweeper notZero(destination) { uint256 balance = address(this).balance; require(balance >= amount, "Sweepable: insufficient balance"); (bool success, ) = destination.call{value: amount}(""); require(success, "Sweepable: transfer error"); } // @dev Sweeps the entire token balance to `destination` function sweepToken(address _token, address destination) public virtual onlySweeper notZero(destination) { IERC20 token = IERC20(_token); uint256 balance = token.balanceOf(address(this)); require(balance > 0, "Sweepable: zero balance"); token.safeTransfer(destination, balance); } // @dev Sweeps a specific token `amount` to `destination` function sweepTokenAmount( address _token, address destination, uint256 amount ) public virtual onlySweeper notZero(destination) { IERC20 token = IERC20(_token); uint256 balance = token.balanceOf(address(this)); require(balance >= amount, "Sweepable: insufficient balance"); token.safeTransfer(destination, amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 1 }, "remappings": [], "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IUniversalRouter","name":"_uniswap","type":"address"},{"internalType":"contract Permit2","name":"_permit2","type":"address"},{"internalType":"address","name":"_initialOperator","type":"address"},{"internalType":"address","name":"_initialFeeDestination","type":"address"},{"internalType":"contract IWrappedNativeCurrency","name":"_wrappedNativeCurrency","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyProcessed","type":"error"},{"inputs":[],"name":"ExpiredIntent","type":"error"},{"inputs":[{"internalType":"address","name":"attemptedCurrency","type":"address"}],"name":"IncorrectCurrency","type":"error"},{"inputs":[],"name":"InexactTransfer","type":"error"},{"inputs":[{"internalType":"uint256","name":"difference","type":"uint256"}],"name":"InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"uint256","name":"difference","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidEIP2612Signature","type":"error"},{"inputs":[{"internalType":"int256","name":"difference","type":"int256"}],"name":"InvalidNativeAmount","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidTransferDetails","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isRefund","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NullRecipient","type":"error"},{"inputs":[],"name":"OperatorNotRegistered","type":"error"},{"inputs":[{"internalType":"bytes","name":"reason","type":"bytes"}],"name":"SwapFailedBytes","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"SwapFailedString","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"feeDestination","type":"address"}],"name":"OperatorRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorUnregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bytes16","name":"id","type":"bytes16"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"spentAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"spentCurrency","type":"address"}],"name":"Transferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permit2","outputs":[{"internalType":"contract Permit2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registerOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeDestination","type":"address"}],"name":"registerOperatorWithFeeDestination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSweeper","type":"address"}],"name":"setSweeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct EIP2612SignatureTransferData","name":"_signatureTransferData","type":"tuple"}],"name":"subsidizedTransferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"internalType":"uint24","name":"poolFeesTier","type":"uint24"}],"name":"swapAndTransferUniswapV3Native","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"transferDetails","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Permit2SignatureTransferData","name":"_signatureTransferData","type":"tuple"},{"internalType":"uint24","name":"poolFeesTier","type":"uint24"}],"name":"swapAndTransferUniswapV3Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"internalType":"address","name":"_tokenIn","type":"address"},{"internalType":"uint256","name":"maxWillingToPay","type":"uint256"},{"internalType":"uint24","name":"poolFeesTier","type":"uint24"}],"name":"swapAndTransferUniswapV3TokenPreApproved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"destination","type":"address"}],"name":"sweepETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"destination","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sweepETHAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"destination","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sweepTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"}],"name":"transferNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"transferDetails","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Permit2SignatureTransferData","name":"_signatureTransferData","type":"tuple"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"}],"name":"transferTokenPreApproved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unregisterOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"transferDetails","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Permit2SignatureTransferData","name":"_signatureTransferData","type":"tuple"}],"name":"unwrapAndTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"}],"name":"unwrapAndTransferPreApproved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"recipientAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"recipientCurrency","type":"address"},{"internalType":"address","name":"refundDestination","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes16","name":"id","type":"bytes16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"prefix","type":"bytes"}],"internalType":"struct TransferIntent","name":"_intent","type":"tuple"}],"name":"wrapAndTransfer","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
61010034620002e557601f62004ee638819003918201601f19168301916001600160401b03831184841017620002ea5780849260a094604052833981010312620002e55780516001600160a01b039081811690818103620002e55760208401519183831692838103620002e5576200007a6040870162000300565b9260806200008b6060890162000300565b9701519286841695868503620002e55760009687549260405193338b82167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08c80a36001600160a81b0319163360ff60a01b191617895560018055608089905215159182620002da575b5081620002cf575b5080620002c3575b80620002b7575b1562000275575060a05260c05260e05282168152600360205260409081902080546001600160a01b0319169390921692909217905551614bd0908162000316823960805181818161038c01528181610b4b015281816113e10152818161171c01528181611b3d01528181611f810152818161200d01528181612432015281816129830152818161350401528181613d330152818161417f01528181614641015261475f015260a0518181816135b9015281816136fb015281816138b201528181613939015281816139c301528181613a5f01528181613d8c01528181613e9d0152818161412d015281816142560152614309015260c051818181610f54015281816117e001528181611c170152612770015260e051818181601b01528181610b8401528181610cc9015281816114530152818161149801528181611758015281816118f901528181611f480152818161352d0152818161373401528181613dc701526147990152f35b62461bcd60e51b815260206004820152601e60248201527f696e76616c696420636f6e7374727563746f7220706172616d657465727300006044820152606490fd5b5086881615156200010c565b50868516151562000105565b9050151538620000fd565b1515915038620000f5565b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620002e55756fe6080604052600436101561008e575b361561001957600080fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361004b57005b60405162461bcd60e51b815260206004820152601b60248201527a6f6e6c792070617961626c6520666f7220756e7772617070696e6760281b6044820152606490fd5b60e060008035821c6304e0fc3681146127f35780631163b2b01461279f57806312261ee71461275a5780631d7f10ac1461223c57806323d4c2ba146121ef578063258836fe146121345780632acde098146120e75780633f4ba83a1461204c57806347a8c96414611d9f5780635c975abb14611d7a5780636614eb71146119a7578063715018a61461195f57806380747a83146115865780638456cb591461152557806386489553146114bf5780638bf122da1461125a5780638da5cb5b146112335780639189a59e1461120a578063a54180af14611145578063a876b89a146110ec578063b8d8e48914611087578063ccba8aac14610d13578063e5368147146109c1578063f2fda4ae14610559578063f2fde38b146104a55763fc8f31e0146101ba57505061000e565b6101c336612b63565b906101cc612eb3565b6101d4612e6c565b8135916020928382013593604083016101ec81612c67565b9160608501976101fb89612c67565b9261020860808801612c67565b60a08801359560c089019361021c85612c7b565b908a019661022988612c67565b928d8b6040519586958d8c8801998a973097339746976102489b612c90565b03601f198101825261025a9082612d84565b5190209861012088019961026e8b8a612da7565b6102bb9c91506104685750600080516020614b5b8339815191528a52601c526102b3603c8a205b6102ad6102a66101008c018c612da7565b3691612df4565b9061301e565b9a909a612f09565b6001600160a01b03998a806102cf88612c67565b16911603610456574211610445576102e78991612c67565b161561043357876102f784612c67565b1687526004825260408720906001600160801b03199061031690612c7b565b168752815260ff6040872054166104215786610333600393612c67565b16865252846040852054161561040f5761034c91612e2b565b938434116000146103785760246103638634612e4e565b6040519063b06a5d5160e01b82526004820152fd5b848034106103fa575061038a90612c67565b7f00000000000000000000000000000000000000000000000000000000000000009084821694859116036103e157906103cc91346103d3575b33913490614809565b6001805580f35b6103dc82614625565b6103c3565b604051636453b66b60e01b815260048101859052602490fd5b61036361040a6024923490612e4e565b612e5b565b6040516325ec6c1f60e01b8152600490fd5b604051632bf773b360e11b8152600490fd5b6040516337e6495760e21b8152600490fd5b60405162202b7560e21b8152600490fd5b604051638baa579f60e01b8152600490fd5b6102b39161049d61047b6040938d612da7565b84919451938185928c84019788378201908b8201520389810184520182612d84565b519020610295565b5034610556576020366003190112610556576104bf612b95565b6104c7612c0f565b6001600160a01b03908116908115610502576000548260018060a01b031982161760005516600080516020614b7b833981519152600080a380f35b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b80fd5b5034610556576003196080368201126109bd576001600160401b03600435116109bd57610140906004353603011261055657610593612bab565b6044359062ffffff6064351660643503610897576106a6906105b3612eb3565b6105bb612e6c565b6105c9604460043501612c67565b6106446105da606460043501612c67565b916106366105ec608460043501612c67565b916105fb60c460043501612c7b565b9261060a60e460043501612c67565b9560405196879530943394469460a4600435013592602460043501356004356004013560208d01612c90565b03601f198101835282612d84565b602081519101206101246004350161066181600435600401612da7565b151590506109785750600080516020614b5b8339815191528552601c5261069e603c85205b6102ad6102a661010460043501600435600401612da7565b929092612f09565b6001600160a01b039182806106bf60043560e401612c67565b169116036104565742602460043501351061044557816106e3604460043501612c67565b161561043357816106f860e460043501612c67565b1684526004602081905260408520906001600160801b03199061071e903560c401612c7b565b16855260205260ff604085205416610421578161073f60e460043501612c67565b1684526003602052816040852054161561040f57811690610764606460043501612c67565b168114610960576040516370a0823160e01b8082523360048301529190602081602481855afa90811561090257859161092e575b5083811061090d5750604051636eb1769f60e11b8152602081806107c0303360048401613166565b0381855afa9081156109025785916108d0575b508381106108af57506107f260a4600435013560043560040135612e2b565b91849261080d575b506103cc92503391600435600401614809565b909150604051908152306004820152602081602481855afa9081156108a457849161086b575b50826108546108649261084b6103cc963033886131a2565b8430918461492b565b60643590836004356004016134e0565b90846107fa565b90506020813d60201161089c575b8161088660209383612d84565b8101031261089757516103cc610833565b600080fd5b3d9150610879565b6040513d86823e3d90fd5b6108bb60249185612e4e565b6040519063f96fb07160e01b82526004820152fd5b90506020813d6020116108fa575b816108eb60209383612d84565b810103126108975751856107d3565b3d91506108de565b6040513d87823e3d90fd5b61091960249185612e4e565b60405190639266535160e01b82526004820152fd5b90506020813d602011610958575b8161094960209383612d84565b81010312610897575185610798565b3d915061093c565b60249060405190636453b66b60e01b82526004820152fd5b61069e916109b5610990604093600435600401612da7565b8491945193818592602084019788378201906020820152036020810184520182612d84565b519020610686565b5080fd5b5090346109bd5790610aa0916109d636612b63565b906109df612eb3565b6109e7612e6c565b6109f360408301612c67565b6109ff60608401612c67565b90610a52610a0f60808601612c67565b92610636610a1f60c08801612c7b565b91610a2b878901612c67565b948860405196879560208701809a30963396469660a0810135946020820135913590612c90565b519020610a63610120840184612da7565b15159050610cf457600080516020614b5b8339815191528452601c52610a98603c84205b6102ad6102a6610100860186612da7565b949094612f09565b6001600160a01b03938480610ab6858501612c67565b1691160361045657426020830135106104455783610ad660408401612c67565b16156104335783610ae8828401612c67565b1683526004602052604083206001600160801b0319610b0960c08501612c7b565b16845260205260ff60408420541661042157610b2784918301612c67565b1682526003602052826040832054161561040f57610b4760608201612c67565b83807f000000000000000000000000000000000000000000000000000000000000000016911603610cba57610b8160a08201358235612e2b565b927f0000000000000000000000000000000000000000000000000000000000000000166040516370a0823160e01b8152336004820152602081602481855afa9081156108a4578491610c88575b50848110610c7c5750604051636eb1769f60e11b815260208180610bf6303360048401613166565b0381855afa9081156108a4578491610c4a575b50848110610c3e5750836103cc9394610c24575b3392614809565b610c30813033856131a2565b610c3983614736565b610c1d565b6108bb60249186612e4e565b90506020813d602011610c74575b81610c6560209383612d84565b81010312610897575138610c09565b3d9150610c58565b61091960249186612e4e565b90506020813d602011610cb2575b81610ca360209383612d84565b81010312610897575138610bce565b3d9150610c96565b604051636453b66b60e01b81527f000000000000000000000000000000000000000000000000000000000000000084166004820152602490fd5b6040610a9891610d0b610990610120870187612da7565b519020610a87565b5090346109bd57600319606036820112611083576001600160401b036004358110611006576101408260043536030112611006576024351161108357602435360301126105565762ffffff604435166044350361089757610d72612eb3565b610d7a612e6c565b610d88604460043501612c67565b610d996105da606460043501612c67565b60208151910120610db561012460043501600435600401612da7565b1515905061106257600080516020614b5b8339815191528252601c52610dfb610df3603c83206102ad6102a661010460043501600435600401612da7565b919091612f09565b6001600160a01b03908180610e1460043560e401612c67565b16911603610456574260246004350135106104455780610e38604460043501612c67565b16156104335780610e4d60e460043501612c67565b1682526004602081905260408320906001600160801b031990610e73903560c401612c7b565b16835260205260ff6040832054166104215780610e9460e460043501612c67565b1682526003602052806040832054161561040f5760243560040181610eb882612c67565b1682610ec8606460043501612c67565b16811461096057608460243501923081610ee186612c67565b16036110505784610efe60a4600435013560043560040135612e2b565b9360a46024350135958295610f1f575b826103cc3387896004803501614809565b6040516370a0823160e01b81523060048201529495509192909190602085602481895afa9485156108a4578495611019575b507f00000000000000000000000000000000000000000000000000000000000000001691610f8460c46024350182612da7565b939091813b1561101557858094610fb36040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57610ff2575b50506103cc92610fd8610fe8928430918461492b565b60443590836004356004016134e0565b9038848180610f0e565b610ffb90612d0a565b611006578338610fc2565b8380fd5b6040513d84823e3d90fd5b8580fd5b935093506020833d602011611048575b8161103660209383612d84565b81010312610897578692519338610f51565b3d9150611029565b60405163ed5c656160e01b8152600490fd5b610df36040610dfb926109b561099061012460043501600435600401612da7565b8280fd5b503461055657602036600319011261055657600080516020614b3b8339815191526110e66110b3612b95565b338085526003602052604080862080546001600160a01b0319166001600160a01b03851617905551928392909183613166565b0390a180f35b50346105565780600319360112610556573380825260036020908152604080842080546001600160a01b0319169055519182527f6f42117a557500c705ddf040a619d86f39101e6b74ac20d7b3e5943ba473fc7f91a180f35b50346105565760603660031901126105565761115f612b95565b611167612bab565b906044359060018060a01b039061118382600254163314614a17565b61119082851615156149c1565b6040516370a0823160e01b8152306004820152939116602084602481845afa9384156109025785946111d5575b506111cd836111d2951015614aee565b6145fe565b80f35b93506020843d8211611202575b816111ef60209383612d84565b81010312610897579251926111cd6111bd565b3d91506111e2565b50346105565780600319360112610556576002546040516001600160a01b039091168152602090f35b5034610556578060031936011261055657546040516001600160a01b039091168152602090f35b506003196040368201126109bd576001600160401b03600435116109bd5761014090600435360301126105565762ffffff602435166024350361089757611323906112a3612eb3565b6112ab612e6c565b6112b9604460043501612c67565b6112ca6105da606460043501612c67565b60208151910120610124600435016112e781600435600401612da7565b151590506109785750600080516020614b5b8339815191528252601c5261069e603c82206102ad6102a661010460043501600435600401612da7565b6001600160a01b0391828061133c60043560e401612c67565b16911603610456574260246004350135106104455781611360604460043501612c67565b1615610433578161137560e460043501612c67565b1681526004602081905260408220906001600160801b03199061139b903560c401612c7b565b16825260205260ff60408220541661042157816113bc60e460043501612c67565b1681526003602052816040822054161561040f57816113df606460043501612c67565b7f00000000000000000000000000000000000000000000000000000000000000009082821694859116148015611485575b6103e157906103cc9161142f60a4600435013560043560040135612e2b565b918492611445575b503391600435600401614809565b61147e9192506024359034907f0000000000000000000000000000000000000000000000000000000000000000166004356004016134e0565b9084611437565b50611494606460043501612c67565b82167f0000000000000000000000000000000000000000000000000000000000000000831614611410565b5034610556576040366003190112610556576111d2818080806114e0612b95565b600254602435916001600160a01b03916114fd9083163314614a17565b166115098115156149c1565b61151582471015614aee565b5af161151f6132d4565b50614aa6565b503461055657806003193601126105565761153e612c0f565b611546612e6c565b805460ff60a01b1916600160a01b1781556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890602090a180f35b5090346109bd5761159636612bc1565b9161159f612eb3565b6115a7612e6c565b818035916020928391828401359060408501906115c382612c67565b9160608701936115d285612c67565b926115df60808a01612c67565b9060a08a013598899260c08c01966115f688612c7b565b938d01988b6116048b612c67565b6040519687968701988996309633968d469761161f9b612c90565b03601f19810182526116319082612d84565b519020896101208a01611644818c612da7565b6116869c915061192157505050600080516020614b5b8339815191528d52601c5261167e603c8d205b6102ad6102a66101008e018e612da7565b989098612f09565b6001600160a01b0397888061169a87612c67565b16911603610456574211610445576116b28791612c67565b161561043357856116c283612c67565b168a526004875260408a20906001600160801b0319906116e190612c7b565b168a52865260ff60408a205416610421576116fc8591612c67565b16885260038552836040892054161561040f5761171890612c67565b83167f00000000000000000000000000000000000000000000000000000000000000008416148015906118eb575b6118c9579061175491612e2b565b93817f000000000000000000000000000000000000000000000000000000000000000016926040516370a0823160e01b81523360048201528181602481885afa9182156118be578892611890575b50508581106118845750846117bf575b50506103cc923392614809565b6080810130836117ce83612c67565b1614801590611876575b6110505786927f0000000000000000000000000000000000000000000000000000000000000000169161180e60c0820182612da7565b939091813b156110155785809461183d6040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57611862575b50506103cc9261185b83614736565b92386117b2565b61186b90612d0a565b61100657833861184c565b508560a083013514156117d8565b61091960249187612e4e565b90809250813d83116118b7575b6118a78183612d84565b81010312610897575138806117a2565b503d61189d565b6040513d8a823e3d90fd5b6024836118d588612c67565b604051636453b66b60e01b815291166004820152fd5b506118f586612c67565b83167f000000000000000000000000000000000000000000000000000000000000000084161415611746565b604061193461167e959361195793612da7565b829591955194818692848401988937820190838201520390810184520182612d84565b51902061166d565b5034610556578060031936011261055657611978612c0f565b600080546001600160a01b0319811682556001600160a01b0316600080516020614b7b8339815191528280a380f35b5090346109bd576119b736612bc1565b91906119c1612eb3565b6119c9612e6c565b8035926020938285808201359560408301906119e482612c67565b9160608501986119f38a612c67565b92611a0060808801612c67565b9060a088013596879260c08a0196611a1788612c7b565b938b01988c611a258b612c67565b6040519687968701988996309633968d4697611a409b612c90565b03601f1981018252611a529082612d84565b5190208b6101208801611a65818a612da7565b611aa79a9150611d5f57505050600080516020614b5b8339815191528d52601c52611a9f603c8d205b6102ad6102a66101008d018d612da7565b969096612f09565b6001600160a01b03958680611abb87612c67565b1691160361045657421161044557611ad38591612c67565b16156104335783611ae383612c67565b168a526004895260408a20906001600160801b031990611b0290612c7b565b168a52885260ff60408a20541661042157611b1d8391612c67565b16885260038752816040892054161561040f57611b3986612c67565b82167f00000000000000000000000000000000000000000000000000000000000000008316148015611d40575b611d3457611b7f9082611b7888612c67565b1693612e2b565b92604051916370a0823160e01b928381523360048201528881602481885afa908115611d29578a91611cfc575b50858110611884575084611bd1575b886103cc338888611bcb8c612c67565b91614809565b60808201903081611be184612c67565b1614801590611cee575b6110505789936040519081523060048201528981602481895afa998a1561090257859a611cbb575b50507f00000000000000000000000000000000000000000000000000000000000000001691611c4560c0820182612da7565b939091813b1561101557858094611c746040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57611ca7575b50506103cc94611c959130918461492b565b611c9e82614625565b38808080611bbb565b611cb090612d0a565b611015578538611c83565b80929a508195503d8311611ce7575b611cd48183612d84565b8101031261089757889251973880611c13565b503d611cca565b508560a08401351415611beb565b90508881813d8311611d22575b611d138183612d84565b81010312610897575138611bac565b503d611d09565b6040513d8c823e3d90fd5b6024826118d586612c67565b50611d4a84612c67565b8280611d5589612c67565b1691161415611b66565b6040611934611a9f9593611d7293612da7565b519020611a8e565b503461055657806003193601126105565760ff6020915460a01c166040519015158152f35b50611da936612b63565b611db1612eb3565b611db9612e6c565b808035602094858301356040840196611dd188612c67565b926060860198611de08a612c67565b93611ded60808901612c67565b60a08901359660c08a01948892611e0387612c7b565b918c0198611e108a612c67565b938c6040519586958c8701988996309633968d4697611e2e9b612c90565b03601f1981018252611e409082612d84565b5190206101208901611e52818b612da7565b611e8a9b9150612039575050600080516020614b5b8339815191528b52601c5261167e603c8b206102ad6102a66101008d018d612da7565b6001600160a01b03978880611e9e88612c67565b1691160361045657421161044557611eb68791612c67565b16156104335785611ec684612c67565b1688526004825260408820906001600160801b031990611ee590612c7b565b168852815260ff6040882054166104215784611f02600393612c67565b16875252826040862054161561040f57611f1b91612e2b565b93843411600014611f325760246103638634612e4e565b848034106103fa5750611f458291612c67565b817f0000000000000000000000000000000000000000000000000000000000000000169283911603611ffe5750829034611fa7575b506103cc337f00000000000000000000000000000000000000000000000000000000000000003485614809565b803b156109bd578160049160405192838092630d0e30db60e41b825234905af1801561100a57611fea575b505080611fe16103cc92614625565b90508183611f7a565b611ff390612d0a565b6109bd578183611fd2565b604051636453b66b60e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152602490fd5b91611d7261047b60409361167e95612da7565b5034610556578060031936011261055657612065612c0f565b805460ff8160a01c16156120ab5760ff60a01b191681556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa90602090a180f35b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b5034610556578060031936011261055657338082526003602052604080832080546001600160a01b0319168317905551600080516020614b3b8339815191529181906110e6908083613166565b50346105565760403660031901126105565761214e612b95565b612156612bab565b60025490916001600160a01b03916121719083163314614a17565b61217e82841615156149c1565b16604051916370a0823160e01b8352306004840152602083602481855afa9182156108a45784926121ba575b6111d293506111cd831515614a60565b91506020833d82116121e7575b816121d460209383612d84565b81010312610897576111d29251916121aa565b3d91506121c7565b503461055657602036600319011261055657612209612b95565b612211612c0f565b6001600160a01b03166122258115156149c1565b600280546001600160a01b03191691909117905580f35b5034610556576003196040368201126109bd576001600160401b03600435811061108357610140826004353603011261108357602435116109bd57604090602435360301126105565761228d612eb3565b612295612e6c565b6123786122a6602435600401612c67565b6122b4604460043501612c67565b90612321606460043501926106366122cb85612c67565b936122da608460043501612c67565b906122e960c460043501612c7b565b956122f860e460043501612c67565b6040519788963095469460a4600435013592602460043501356004356004013560208d01612c90565b6020815191012061233d61012460043501600435600401612da7565b1515905061273c57600080516020614b5b8339815191528452601c5261069e603c84206102ad6102a661010460043501600435600401612da7565b6001600160a01b0391828061239160043560e401612c67565b169116036104565742602460043501351061044557816123b5604460043501612c67565b161561043357816123ca60e460043501612c67565b1683526004602081905260408420906001600160801b0319906123f0903560c401612c7b565b16845260205260ff604084205416610421578161241160e460043501612c67565b1683526003602052816040842054161561040f5761242e81612c67565b82167f0000000000000000000000000000000000000000000000000000000000000000831614612730578161246282612c67565b169061247a60a4600435013560043560040135612e2b565b91612489602435600401612c67565b93604051816370a0823160e01b96878352166004820152602081602481865afa9081156127255787916126ef575b50848110610c7c5750806124ca84612c67565b16906124df6024803501602435600401612da7565b919092604183036126dd5782899360201161100657806040116110065760411161108357612511602435600401612c67565b813b15611006578360e4926020604051978896879563d505accf60e01b87521660048601523060248601528b6044860152602460043501356064860152604081013560f81c6084860152803560a4860152013560c48401525af180156126bf576126ca575b506125a6602061258a602435600401612c67565b60405180938192636eb1769f60e11b8352309060048401613166565b0381855afa9081156126bf57869161268d575b508381106108af5750826125f0575b846103cc846125d685612c67565b6125e4602435600401612c67565b91600435600401614809565b604051938452306004850152602084602481845afa938415610902578594612655575b50906126416103cc946125d6936126398630612633602435600401612c67565b846131a2565b30918661492b565b61264f600435600401614625565b906125c8565b9350906020843d602011612685575b8161267160209383612d84565b810103126108975792519290612641612613565b3d9150612664565b90506020813d6020116126b7575b816126a860209383612d84565b810103126108975751866125b9565b3d915061269b565b6040513d88823e3d90fd5b6126d690959195612d0a565b9385612576565b6040516325ba634760e11b8152600490fd5b90506020813d60201161271d575b8161270a60209383612d84565b810103126127195751876124b7565b8680fd5b3d91506126fd565b6040513d89823e3d90fd5b906118d5602492612c67565b604061069e916109b561099061012460043501600435600401612da7565b50346105565780600319360112610556576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5034610556576020366003190112610556576111d2818080806127c0612b95565b6002546001600160a01b0391906127da9083163314614a17565b166127e68115156149c1565b4790611515821515614a60565b5090346109bd5761280336612b63565b9061280c612eb3565b612814612e6c565b8135916020808201358083604081019561282d87612c67565b966060830197898761283e8b612c67565b61284a60808801612c67565b9360a0880135998a9460c08a01986128618a612c7b565b9a019961286d8b612c67565b906040519788978801998a973097339746976128889b612c90565b03601f198101825261289a9082612d84565b519020936101208801946128ae868a612da7565b6128ed979150612b2e5750600080516020614b5b8339815191528c52601c526128e5603c8c206102ad6102a66101008c018c612da7565b959095612f09565b6001600160a01b0394858061290187612c67565b16911603610456574211610445576129198491612c67565b1615610433578261292983612c67565b1689526004855260408920906001600160801b03199061294890612c7b565b168952845260ff604089205416610421576129638291612c67565b16875260038352806040882054161561040f5761297f85612c67565b81167f0000000000000000000000000000000000000000000000000000000000000000821614612b2257906129be916129b786612c67565b1695612e2b565b906040516370a0823160e01b9081815233600482015282816024818a5afa9081156118be578891612af5575b5083811061090d5750604051636eb1769f60e11b8152828180612a11303360048401613166565b03818a5afa9081156118be578891612ac4575b508381106108af575082612a44575b50506103cc9350611bcb3393612c67565b6040519081523060048201528181602481895afa918215612725578792612a94575b5050612a84906103cc95612a7c843033846131a2565b30918461492b565b612a8d82614625565b3880612a33565b90809250813d8311612abd575b612aab8183612d84565b81010312611015575184612a84612a66565b503d612aa1565b90508281813d8311612aee575b612adb8183612d84565b81010312612aea575138612a24565b8780fd5b503d612ad1565b90508281813d8311612b1b575b612b0c8183612d84565b81010312612aea5751386129ea565b503d612b02565b6024906118d586612c67565b6128e59161049d612b416040938d612da7565b8c8592955194828693838501988937830191820152038c810184520182612d84565b6003199060208183011261089757600435916001600160401b0383116108975782610140920301126108975760040190565b600435906001600160a01b038216820361089757565b602435906001600160a01b038216820361089757565b6003199190604083820112610897576001600160401b0390600435828111610897576101408582840301126108975760040193602435928311610897578260e0920301126108975760040190565b6000546001600160a01b03163303612c2357565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b356001600160a01b03811681036108975790565b356001600160801b0319811681036108975790565b9081526020810191909152606091821b6001600160601b0319908116604083015292821b8316605482015292811b82166068840152607c8301939093526001600160801b0319909316609c82015292811b821660ac84015260c083019390935292821b831660e082015292901b1660f48201526101080190565b6001600160401b038111612d1d57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117612d1d57604052565b606081019081106001600160401b03821117612d1d57604052565b608081019081106001600160401b03821117612d1d57604052565b601f909101601f19168101906001600160401b03821190821017612d1d57604052565b903590601e198136030182121561089757018035906001600160401b0382116108975760200191813603831361089757565b6001600160401b038111612d1d57601f01601f191660200190565b929192612e0082612dd9565b91612e0e6040519384612d84565b829481845281830111610897578281602093846000960137010152565b91908201809211612e3857565b634e487b7160e01b600052601160045260246000fd5b91908203918211612e3857565b600160ff1b8114612e385760000390565b60ff60005460a01c16612e7b57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b600260015414612ec4576002600155565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b60058110156130085780612f1a5750565b60018103612f625760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b60028103612faf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314612fb857565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b90604181511460001461304c57613048916020820151906060604084015193015160001a90613056565b9091565b5050600090600290565b9291906fa2a8918ca85bafe22016d0b997e4df60600160ff1b0383116130cf5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156130c25781516001600160a01b038116156130bc579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b80356001600160a01b03811690819003610897578252602090810135910152565b93949291606061312b9261311087826130db565b604081013560408801520135606086015260808501906130db565b6001600160a01b031660c083015261010060e083018190528201819052610120928190848401376000828201840152601f01601f1916010190565b6001600160a01b0391821681529116602082015260400190565b6001600160a01b03918216815291166020820152604081019190915260600190565b906131d8906131ca6131dd956040519586936323b872dd60e01b602086015260248501613180565b03601f198101845283612d84565b6131df565b565b60018060a01b03169061323e6040516131f781612d33565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16132386132d4565b91613304565b8051918215918483156132b0575b5050509050156132595750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126109bd5782015190811515820361055657508038808461324c565b3d156132ff573d906132e582612dd9565b916132f36040519384612d84565b82523d6000602084013e565b606090565b919290156133665750815115613318575090565b3b156133215790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156133795750805190602001fd5b60405162461bcd60e51b81526020600482015290819061339d9060248301906133a1565b0390fd5b919082519283825260005b8481106133cd575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016133ac565b8051156133ee5760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156133ee5760400190565b8051600210156133ee5760600190565b8051600310156133ee5760800190565b8051600410156133ee5760a00190565b8051600510156133ee5760c00190565b6001600160a01b039091168152602081019190915260400190565b600060443d106134cc57604051600319913d83016004833e81516001600160401b03918282113d6024840111176134cf578184019485519384116134d7573d850101602084870101116134cf57506134cc92910160200190612d84565b90565b949350505050565b50949350505050565b91939290936000946000936134f760608201612c67565b6001600160a01b039081167f0000000000000000000000000000000000000000000000000000000000000000909116036145ec577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316905b61360761361e61356c60a08401358435612e2b565b604051606086811b6001600160601b0319908116602084015260e89a909a1b6001600160e81b031916603483015287901b9098166037890152602b8852966135b381612d4e565b604080517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660208201529081018990526060810188905260a0608082015292839160c08301906133a1565b600060a0830152601f198282030182520382612d84565b61362a60608301612c67565b9561363760408401612c67565b6040519760018060a01b0316602089015260018060a01b03166040880152823560608801526060875261366987612d69565b61367560608401612c67565b956001600160a01b0361368a60e08601612c67565b1660005260036020526136ca60018060a01b03604060002054166136bc604051998a9260a08901359160208501613180565b03601f198101895288612d84565b600090819034156140d157505050506136e4343331612e2b565b6040516370a0823160e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483018190529297923190602090839060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa90811561405d5760009161409b575b61376f9250612e2b565b966001600160a01b0361378460e08601612c67565b166000908152600360209081526040918290205491516370a0823160e01b81526001600160a01b03928316600482015291829060249082908a165afa90811561405d57600091614069575b50926137dd60408601612c67565b6040516370a0823160e01b81526001600160a01b03918216600482015290602090829060249082908b165afa90811561405d5760009161402b575b50604051600b60f81b6020820152600160f81b6021820152600560f81b602282018190526023820152600360fa1b6024820152600160fa1b60258201526006815290939061386581612d33565b604051909390916001600160401b0360e0840190811190841117612d1d5760e083016040526006835260005b60c0811061401a575060405192936139bf9385939291906138e381610636347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660208401613454565b6138ec856133e1565b526138f6846133e1565b5061390084613404565b5261390a83613404565b5061391483613414565b5261391e82613414565b5061392882613424565b5261393281613424565b50604080517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602082015260008183015290815261397881612d4e565b61398182613434565b5261398b81613434565b506040516000602082015233604082015260006060820152606081526139b081612d69565b6139b982613444565b52613444565b505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163b1561089757604051630d64d59360e21b81526060600482015291829190613a179060648401906133a1565b600319838203016024840152815180825260208201916020808360051b8301019401926000915b838310613fe9575050505050602086013560448301526000919081900381347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19081613fd5575b50613d1c57505050505050506001908060033d11613d0c575b6308c379a014613cd1575b50613abb57565b613ac36132d4565b805160208201207f865c3ff234d3d0edd202666a7ee80e1df8991d5f3d0735c47363eaf02da248f68103613b27576040516345313e0b60e11b815260206004820152600d60248201526c05633496e76616c69645377617609c1b6044820152606490fd5b7f7949afa5f7d1aca4443eae437acb1046b7439815697e5489cca05d226a192b138103613b8a576040516345313e0b60e11b8152602060048201526013602482015272158cd51bdbd31a5d1d1b19549958d95a5d9959606a1b6044820152606490fd5b7f6c00b934adb0b7404a228838c719adfbb4e9deac0b09dc9249e888189cb51f6a8103613bec576040516345313e0b60e11b8152602060048201526012602482015271158cd51bdbd35d58da14995c5d595cdd195960721b6044820152606490fd5b7f483c13bc9b4251bad271f371298893f2995abed398de6edf3108289714194b898103613c4e576040516345313e0b60e11b8152602060048201526012602482015271158cd25b9d985b1a59105b5bdd5b9d13dd5d60721b6044820152606490fd5b7ff14c0a0eab0cabeb85cee7eed6c1c3d990aa7959546121092a1062bf3a5d784103613cac576040516345313e0b60e11b815260206004820152600f60248201526e2b19a4b73b30b634b221b0b63632b960891b6044820152606490fd5b60405163917827e160e01b81526020600482015290819061339d9060248301906133a1565b613cd961346f565b9081613ce55750613ab4565b506040516345313e0b60e11b8152602060048201529150819061339d9060248301906133a1565b50600481803e805160e01c613aa9565b979850949693949293919290916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690613d6160608601612c67565b1603613f6c575b505034159150613e5c905057506040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830181905233319492903191602090829060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa928315613e505792613e18575b506134cc94613e0c613e129493613e0c93612e2b565b92612e2b565b90612e4e565b9291506020833d602011613e48575b81613e3460209383612d84565b8101031261089757915190916134cc613df6565b3d9150613e27565b604051903d90823e3d90fd5b6040516370a0823160e01b80825233600483015292949293916001600160a01b031690602081602481855afa8015613f61578390613f2e575b6040519586527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166004870152949160209150829060249082905afa918215613e505791613ef8575b506134cc93613e1292613e0c91612e2b565b9390506020843d602011613f26575b81613f1460209383612d84565b81010312610897579251613e0c613ee6565b3d9150613f07565b506020813d602011613f59575b81613f4860209383612d84565b810103126108975760209051613e95565b3d9150613f3b565b6040513d85823e3d90fd5b613fcc93613fb0906001600160a01b03613f8860e08701612c67565b168952600360205260408920546001600160a01b0391821694911690849060a087013561492b565b6001600160a01b03613fc460408501612c67565b16923561492b565b38808080613d68565b613fe0919950612d0a565b60009738613a90565b919395509193602080614008600193601f1986820301875289516133a1565b97019301930190928695949293613a3e565b806060602080938701015201613891565b90506020813d602011614055575b8161404660209383612d84565b81010312610897575138613818565b3d9150614039565b6040513d6000823e3d90fd5b90506020813d602011614093575b8161408460209383612d84565b810103126108975751386137cf565b3d9150614077565b90506020823d6020116140c9575b816140b660209383612d84565b810103126108975761376f915190613765565b3d91506140a9565b6040516370a0823160e01b81523360048201529398929491936020816024816001600160a01b038d165afa801561405d5782906000906145b6575b6141169250612e2b565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152919a91602090829060249082908e165afa90811561405d57600091614584575b509a6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116906141ad60608b01612c67565b160361434857604051600160f81b6020820152600360fa1b6021820152600560f81b602282018190526023820152600160fa1b6024820152600581526141f281612d33565b604051909590926001600160401b0360c0850190811190851117612d1d5760c084016040526005845260005b60a0811061433757509183916106366142876142fd95614332989799614243876133e1565b5261424d866133e1565b506040519283917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660208401613454565b61429084613404565b5261429a83613404565b506142a483613414565b526142ae82613414565b506142b882613424565b526142c281613424565b5060405160018060a01b038c16602082015233604082015260006060820152606081526142ee81612d69565b6142f782613434565b52613434565b505b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116908a166145fe565b6139c1565b80606060208093880101520161421e565b9195509093506001600160a01b03905061436460e08701612c67565b166000908152600360209081526040918290205491516370a0823160e01b81526001600160a01b03928316600482015291829060249082908b165afa90811561405d57600091614552575b50936143bd60408701612c67565b6040516370a0823160e01b81526001600160a01b03918216600482015290602090829060249082908c165afa90811561405d57600091614520575b5060408051600160f81b6020820152600560f81b602182018190526022820152600160fa1b60238201526004815291959082018083116001600160401b0390911117612d1d5781946040830160e084011060018060401b0360e085011117612d1d5760e083016040526004604084015260005b6080811061451057508261450a92604092836143329796019761448f8585016133e1565b5261449b8484016133e1565b506144a7848401613404565b526144b3838301613404565b506144bf838301613414565b526144cb828201613414565b5081516001600160a01b038d1660208201523381840152600060608083019190915281526144f881612d69565b614503838301613424565b5201613424565b506142ff565b606084820181015260200161446b565b90506020813d60201161454a575b8161453b60209383612d84565b810103126108975751386143f8565b3d915061452e565b90506020813d60201161457c575b8161456d60209383612d84565b810103126108975751386143af565b3d9150614560565b90506020813d6020116145ae575b8161459f60209383612d84565b81010312610897575138614173565b3d9150614592565b50506020813d6020116145e4575b816145d160209383612d84565b810103126108975781614116915161410c565b3d91506145c4565b6145f860608201612c67565b90613557565b6131d86131dd93926131ca60405194859263a9059cbb60e01b602085015260248401613454565b6060810161463281612c67565b6001600160a01b0391829182167f00000000000000000000000000000000000000000000000000000000000000008316036146c45750508135806146a7575b5060a0820135908161468257505050565b8061469260e06131dd9501612c67565b166000526003602052604060002054166148d0565b6146be90826146b860408601612c67565b166148d0565b38614671565b6146cd90612c67565b16823580614718575b5060a083013591826146e9575b50505050565b806146f960e061470f9601612c67565b16600052600360205260406000205416906145fe565b388080806146e3565b614730908361472960408701612c67565b16836145fe565b386146d6565b61474560a08201358235612e2b565b9061475260608201612c67565b6001600160a01b039081167f000000000000000000000000000000000000000000000000000000000000000082161480614800575b614797575b506131dd9150614625565b7f00000000000000000000000000000000000000000000000000000000000000001691823b1561089757600092602484926040519586938492632e1a7d4d60e01b845260048401525af191821561405d576131dd921561478c576147fa90612d0a565b3861478c565b50821515614787565b927fb7ee4fafa10d16ee883a136a3dcc9179d8e6041ba71cc29c2b0bce4f7bdd6e869260a0926001600160a01b03928692849290918390816148846148ac60406148a561489f60e08c018661485d82612c67565b166000908152600460205284902060c09d909d019c6001600160801b03199687908f612c7b565b1660005260205283600020600160ff19825416179055612c67565b9a612c7b565b9d01612c67565b906040519c168c521660208b015216604089015260608801521660808601521692a2565b6001600160a01b0316600080808085855af16148ea6132d4565b90156148f557505050565b61339d906040519384936328688b5560e01b855260048501526024840152600060448401526080606484015260848301906133a1565b6040516370a0823160e01b81526001600160a01b03948516600482015290939192909160209183916024918391165afa90811561405d5760009161498e575b509061497591612e4e565b0361497c57565b604051631dc418c360e31b8152600490fd5b906020823d82116149b9575b816149a760209383612d84565b8101031261055657505161497561496a565b3d915061499a565b156149c857565b60405162461bcd60e51b815260206004820152602160248201527f537765657061626c653a2063616e6e6f74206265207a65726f206164647265736044820152607360f81b6064820152608490fd5b15614a1e57565b60405162461bcd60e51b815260206004820152601a60248201527929bbb2b2b830b136329d103737ba103a34329039bbb2b2b832b960311b6044820152606490fd5b15614a6757565b60405162461bcd60e51b8152602060048201526017602482015276537765657061626c653a207a65726f2062616c616e636560481b6044820152606490fd5b15614aad57565b60405162461bcd60e51b815260206004820152601960248201527829bbb2b2b830b136329d103a3930b739b332b91032b93937b960391b6044820152606490fd5b15614af557565b60405162461bcd60e51b815260206004820152601f60248201527f537765657061626c653a20696e73756666696369656e742062616c616e6365006044820152606490fdfea453db612af59e5521d6ab9284dc3e2d06af286eb1b1b7b771fce4716c19f2c119457468657265756d205369676e6564204d6573736167653a0a3332000000008be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0a2646970667358221220157560c88e23f3e233fc467282dc5bbbfb9ccd5cbbe8aeeeb548a89421b22d1664736f6c634300081100330000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000008fccc78dae0a8f93b0fe6799de888d4c57e273db0000000000000000000000006d8675a52438849d90241cb639fba41bdc3329c8000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x6080604052600436101561008e575b361561001957600080fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316330361004b57005b60405162461bcd60e51b815260206004820152601b60248201527a6f6e6c792070617961626c6520666f7220756e7772617070696e6760281b6044820152606490fd5b60e060008035821c6304e0fc3681146127f35780631163b2b01461279f57806312261ee71461275a5780631d7f10ac1461223c57806323d4c2ba146121ef578063258836fe146121345780632acde098146120e75780633f4ba83a1461204c57806347a8c96414611d9f5780635c975abb14611d7a5780636614eb71146119a7578063715018a61461195f57806380747a83146115865780638456cb591461152557806386489553146114bf5780638bf122da1461125a5780638da5cb5b146112335780639189a59e1461120a578063a54180af14611145578063a876b89a146110ec578063b8d8e48914611087578063ccba8aac14610d13578063e5368147146109c1578063f2fda4ae14610559578063f2fde38b146104a55763fc8f31e0146101ba57505061000e565b6101c336612b63565b906101cc612eb3565b6101d4612e6c565b8135916020928382013593604083016101ec81612c67565b9160608501976101fb89612c67565b9261020860808801612c67565b60a08801359560c089019361021c85612c7b565b908a019661022988612c67565b928d8b6040519586958d8c8801998a973097339746976102489b612c90565b03601f198101825261025a9082612d84565b5190209861012088019961026e8b8a612da7565b6102bb9c91506104685750600080516020614b5b8339815191528a52601c526102b3603c8a205b6102ad6102a66101008c018c612da7565b3691612df4565b9061301e565b9a909a612f09565b6001600160a01b03998a806102cf88612c67565b16911603610456574211610445576102e78991612c67565b161561043357876102f784612c67565b1687526004825260408720906001600160801b03199061031690612c7b565b168752815260ff6040872054166104215786610333600393612c67565b16865252846040852054161561040f5761034c91612e2b565b938434116000146103785760246103638634612e4e565b6040519063b06a5d5160e01b82526004820152fd5b848034106103fa575061038a90612c67565b7f00000000000000000000000000000000000000000000000000000000000000009084821694859116036103e157906103cc91346103d3575b33913490614809565b6001805580f35b6103dc82614625565b6103c3565b604051636453b66b60e01b815260048101859052602490fd5b61036361040a6024923490612e4e565b612e5b565b6040516325ec6c1f60e01b8152600490fd5b604051632bf773b360e11b8152600490fd5b6040516337e6495760e21b8152600490fd5b60405162202b7560e21b8152600490fd5b604051638baa579f60e01b8152600490fd5b6102b39161049d61047b6040938d612da7565b84919451938185928c84019788378201908b8201520389810184520182612d84565b519020610295565b5034610556576020366003190112610556576104bf612b95565b6104c7612c0f565b6001600160a01b03908116908115610502576000548260018060a01b031982161760005516600080516020614b7b833981519152600080a380f35b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b80fd5b5034610556576003196080368201126109bd576001600160401b03600435116109bd57610140906004353603011261055657610593612bab565b6044359062ffffff6064351660643503610897576106a6906105b3612eb3565b6105bb612e6c565b6105c9604460043501612c67565b6106446105da606460043501612c67565b916106366105ec608460043501612c67565b916105fb60c460043501612c7b565b9261060a60e460043501612c67565b9560405196879530943394469460a4600435013592602460043501356004356004013560208d01612c90565b03601f198101835282612d84565b602081519101206101246004350161066181600435600401612da7565b151590506109785750600080516020614b5b8339815191528552601c5261069e603c85205b6102ad6102a661010460043501600435600401612da7565b929092612f09565b6001600160a01b039182806106bf60043560e401612c67565b169116036104565742602460043501351061044557816106e3604460043501612c67565b161561043357816106f860e460043501612c67565b1684526004602081905260408520906001600160801b03199061071e903560c401612c7b565b16855260205260ff604085205416610421578161073f60e460043501612c67565b1684526003602052816040852054161561040f57811690610764606460043501612c67565b168114610960576040516370a0823160e01b8082523360048301529190602081602481855afa90811561090257859161092e575b5083811061090d5750604051636eb1769f60e11b8152602081806107c0303360048401613166565b0381855afa9081156109025785916108d0575b508381106108af57506107f260a4600435013560043560040135612e2b565b91849261080d575b506103cc92503391600435600401614809565b909150604051908152306004820152602081602481855afa9081156108a457849161086b575b50826108546108649261084b6103cc963033886131a2565b8430918461492b565b60643590836004356004016134e0565b90846107fa565b90506020813d60201161089c575b8161088660209383612d84565b8101031261089757516103cc610833565b600080fd5b3d9150610879565b6040513d86823e3d90fd5b6108bb60249185612e4e565b6040519063f96fb07160e01b82526004820152fd5b90506020813d6020116108fa575b816108eb60209383612d84565b810103126108975751856107d3565b3d91506108de565b6040513d87823e3d90fd5b61091960249185612e4e565b60405190639266535160e01b82526004820152fd5b90506020813d602011610958575b8161094960209383612d84565b81010312610897575185610798565b3d915061093c565b60249060405190636453b66b60e01b82526004820152fd5b61069e916109b5610990604093600435600401612da7565b8491945193818592602084019788378201906020820152036020810184520182612d84565b519020610686565b5080fd5b5090346109bd5790610aa0916109d636612b63565b906109df612eb3565b6109e7612e6c565b6109f360408301612c67565b6109ff60608401612c67565b90610a52610a0f60808601612c67565b92610636610a1f60c08801612c7b565b91610a2b878901612c67565b948860405196879560208701809a30963396469660a0810135946020820135913590612c90565b519020610a63610120840184612da7565b15159050610cf457600080516020614b5b8339815191528452601c52610a98603c84205b6102ad6102a6610100860186612da7565b949094612f09565b6001600160a01b03938480610ab6858501612c67565b1691160361045657426020830135106104455783610ad660408401612c67565b16156104335783610ae8828401612c67565b1683526004602052604083206001600160801b0319610b0960c08501612c7b565b16845260205260ff60408420541661042157610b2784918301612c67565b1682526003602052826040832054161561040f57610b4760608201612c67565b83807f000000000000000000000000000000000000000000000000000000000000000016911603610cba57610b8160a08201358235612e2b565b927f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2166040516370a0823160e01b8152336004820152602081602481855afa9081156108a4578491610c88575b50848110610c7c5750604051636eb1769f60e11b815260208180610bf6303360048401613166565b0381855afa9081156108a4578491610c4a575b50848110610c3e5750836103cc9394610c24575b3392614809565b610c30813033856131a2565b610c3983614736565b610c1d565b6108bb60249186612e4e565b90506020813d602011610c74575b81610c6560209383612d84565b81010312610897575138610c09565b3d9150610c58565b61091960249186612e4e565b90506020813d602011610cb2575b81610ca360209383612d84565b81010312610897575138610bce565b3d9150610c96565b604051636453b66b60e01b81527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc284166004820152602490fd5b6040610a9891610d0b610990610120870187612da7565b519020610a87565b5090346109bd57600319606036820112611083576001600160401b036004358110611006576101408260043536030112611006576024351161108357602435360301126105565762ffffff604435166044350361089757610d72612eb3565b610d7a612e6c565b610d88604460043501612c67565b610d996105da606460043501612c67565b60208151910120610db561012460043501600435600401612da7565b1515905061106257600080516020614b5b8339815191528252601c52610dfb610df3603c83206102ad6102a661010460043501600435600401612da7565b919091612f09565b6001600160a01b03908180610e1460043560e401612c67565b16911603610456574260246004350135106104455780610e38604460043501612c67565b16156104335780610e4d60e460043501612c67565b1682526004602081905260408320906001600160801b031990610e73903560c401612c7b565b16835260205260ff6040832054166104215780610e9460e460043501612c67565b1682526003602052806040832054161561040f5760243560040181610eb882612c67565b1682610ec8606460043501612c67565b16811461096057608460243501923081610ee186612c67565b16036110505784610efe60a4600435013560043560040135612e2b565b9360a46024350135958295610f1f575b826103cc3387896004803501614809565b6040516370a0823160e01b81523060048201529495509192909190602085602481895afa9485156108a4578495611019575b507f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba31691610f8460c46024350182612da7565b939091813b1561101557858094610fb36040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57610ff2575b50506103cc92610fd8610fe8928430918461492b565b60443590836004356004016134e0565b9038848180610f0e565b610ffb90612d0a565b611006578338610fc2565b8380fd5b6040513d84823e3d90fd5b8580fd5b935093506020833d602011611048575b8161103660209383612d84565b81010312610897578692519338610f51565b3d9150611029565b60405163ed5c656160e01b8152600490fd5b610df36040610dfb926109b561099061012460043501600435600401612da7565b8280fd5b503461055657602036600319011261055657600080516020614b3b8339815191526110e66110b3612b95565b338085526003602052604080862080546001600160a01b0319166001600160a01b03851617905551928392909183613166565b0390a180f35b50346105565780600319360112610556573380825260036020908152604080842080546001600160a01b0319169055519182527f6f42117a557500c705ddf040a619d86f39101e6b74ac20d7b3e5943ba473fc7f91a180f35b50346105565760603660031901126105565761115f612b95565b611167612bab565b906044359060018060a01b039061118382600254163314614a17565b61119082851615156149c1565b6040516370a0823160e01b8152306004820152939116602084602481845afa9384156109025785946111d5575b506111cd836111d2951015614aee565b6145fe565b80f35b93506020843d8211611202575b816111ef60209383612d84565b81010312610897579251926111cd6111bd565b3d91506111e2565b50346105565780600319360112610556576002546040516001600160a01b039091168152602090f35b5034610556578060031936011261055657546040516001600160a01b039091168152602090f35b506003196040368201126109bd576001600160401b03600435116109bd5761014090600435360301126105565762ffffff602435166024350361089757611323906112a3612eb3565b6112ab612e6c565b6112b9604460043501612c67565b6112ca6105da606460043501612c67565b60208151910120610124600435016112e781600435600401612da7565b151590506109785750600080516020614b5b8339815191528252601c5261069e603c82206102ad6102a661010460043501600435600401612da7565b6001600160a01b0391828061133c60043560e401612c67565b16911603610456574260246004350135106104455781611360604460043501612c67565b1615610433578161137560e460043501612c67565b1681526004602081905260408220906001600160801b03199061139b903560c401612c7b565b16825260205260ff60408220541661042157816113bc60e460043501612c67565b1681526003602052816040822054161561040f57816113df606460043501612c67565b7f00000000000000000000000000000000000000000000000000000000000000009082821694859116148015611485575b6103e157906103cc9161142f60a4600435013560043560040135612e2b565b918492611445575b503391600435600401614809565b61147e9192506024359034907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2166004356004016134e0565b9084611437565b50611494606460043501612c67565b82167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2831614611410565b5034610556576040366003190112610556576111d2818080806114e0612b95565b600254602435916001600160a01b03916114fd9083163314614a17565b166115098115156149c1565b61151582471015614aee565b5af161151f6132d4565b50614aa6565b503461055657806003193601126105565761153e612c0f565b611546612e6c565b805460ff60a01b1916600160a01b1781556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890602090a180f35b5090346109bd5761159636612bc1565b9161159f612eb3565b6115a7612e6c565b818035916020928391828401359060408501906115c382612c67565b9160608701936115d285612c67565b926115df60808a01612c67565b9060a08a013598899260c08c01966115f688612c7b565b938d01988b6116048b612c67565b6040519687968701988996309633968d469761161f9b612c90565b03601f19810182526116319082612d84565b519020896101208a01611644818c612da7565b6116869c915061192157505050600080516020614b5b8339815191528d52601c5261167e603c8d205b6102ad6102a66101008e018e612da7565b989098612f09565b6001600160a01b0397888061169a87612c67565b16911603610456574211610445576116b28791612c67565b161561043357856116c283612c67565b168a526004875260408a20906001600160801b0319906116e190612c7b565b168a52865260ff60408a205416610421576116fc8591612c67565b16885260038552836040892054161561040f5761171890612c67565b83167f00000000000000000000000000000000000000000000000000000000000000008416148015906118eb575b6118c9579061175491612e2b565b93817f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216926040516370a0823160e01b81523360048201528181602481885afa9182156118be578892611890575b50508581106118845750846117bf575b50506103cc923392614809565b6080810130836117ce83612c67565b1614801590611876575b6110505786927f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3169161180e60c0820182612da7565b939091813b156110155785809461183d6040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57611862575b50506103cc9261185b83614736565b92386117b2565b61186b90612d0a565b61100657833861184c565b508560a083013514156117d8565b61091960249187612e4e565b90809250813d83116118b7575b6118a78183612d84565b81010312610897575138806117a2565b503d61189d565b6040513d8a823e3d90fd5b6024836118d588612c67565b604051636453b66b60e01b815291166004820152fd5b506118f586612c67565b83167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc284161415611746565b604061193461167e959361195793612da7565b829591955194818692848401988937820190838201520390810184520182612d84565b51902061166d565b5034610556578060031936011261055657611978612c0f565b600080546001600160a01b0319811682556001600160a01b0316600080516020614b7b8339815191528280a380f35b5090346109bd576119b736612bc1565b91906119c1612eb3565b6119c9612e6c565b8035926020938285808201359560408301906119e482612c67565b9160608501986119f38a612c67565b92611a0060808801612c67565b9060a088013596879260c08a0196611a1788612c7b565b938b01988c611a258b612c67565b6040519687968701988996309633968d4697611a409b612c90565b03601f1981018252611a529082612d84565b5190208b6101208801611a65818a612da7565b611aa79a9150611d5f57505050600080516020614b5b8339815191528d52601c52611a9f603c8d205b6102ad6102a66101008d018d612da7565b969096612f09565b6001600160a01b03958680611abb87612c67565b1691160361045657421161044557611ad38591612c67565b16156104335783611ae383612c67565b168a526004895260408a20906001600160801b031990611b0290612c7b565b168a52885260ff60408a20541661042157611b1d8391612c67565b16885260038752816040892054161561040f57611b3986612c67565b82167f00000000000000000000000000000000000000000000000000000000000000008316148015611d40575b611d3457611b7f9082611b7888612c67565b1693612e2b565b92604051916370a0823160e01b928381523360048201528881602481885afa908115611d29578a91611cfc575b50858110611884575084611bd1575b886103cc338888611bcb8c612c67565b91614809565b60808201903081611be184612c67565b1614801590611cee575b6110505789936040519081523060048201528981602481895afa998a1561090257859a611cbb575b50507f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba31691611c4560c0820182612da7565b939091813b1561101557858094611c746040519788968795869463187945bd60e11b86523391600487016130fc565b03925af1801561100a57611ca7575b50506103cc94611c959130918461492b565b611c9e82614625565b38808080611bbb565b611cb090612d0a565b611015578538611c83565b80929a508195503d8311611ce7575b611cd48183612d84565b8101031261089757889251973880611c13565b503d611cca565b508560a08401351415611beb565b90508881813d8311611d22575b611d138183612d84565b81010312610897575138611bac565b503d611d09565b6040513d8c823e3d90fd5b6024826118d586612c67565b50611d4a84612c67565b8280611d5589612c67565b1691161415611b66565b6040611934611a9f9593611d7293612da7565b519020611a8e565b503461055657806003193601126105565760ff6020915460a01c166040519015158152f35b50611da936612b63565b611db1612eb3565b611db9612e6c565b808035602094858301356040840196611dd188612c67565b926060860198611de08a612c67565b93611ded60808901612c67565b60a08901359660c08a01948892611e0387612c7b565b918c0198611e108a612c67565b938c6040519586958c8701988996309633968d4697611e2e9b612c90565b03601f1981018252611e409082612d84565b5190206101208901611e52818b612da7565b611e8a9b9150612039575050600080516020614b5b8339815191528b52601c5261167e603c8b206102ad6102a66101008d018d612da7565b6001600160a01b03978880611e9e88612c67565b1691160361045657421161044557611eb68791612c67565b16156104335785611ec684612c67565b1688526004825260408820906001600160801b031990611ee590612c7b565b168852815260ff6040882054166104215784611f02600393612c67565b16875252826040862054161561040f57611f1b91612e2b565b93843411600014611f325760246103638634612e4e565b848034106103fa5750611f458291612c67565b817f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169283911603611ffe5750829034611fa7575b506103cc337f00000000000000000000000000000000000000000000000000000000000000003485614809565b803b156109bd578160049160405192838092630d0e30db60e41b825234905af1801561100a57611fea575b505080611fe16103cc92614625565b90508183611f7a565b611ff390612d0a565b6109bd578183611fd2565b604051636453b66b60e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152602490fd5b91611d7261047b60409361167e95612da7565b5034610556578060031936011261055657612065612c0f565b805460ff8160a01c16156120ab5760ff60a01b191681556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa90602090a180f35b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b5034610556578060031936011261055657338082526003602052604080832080546001600160a01b0319168317905551600080516020614b3b8339815191529181906110e6908083613166565b50346105565760403660031901126105565761214e612b95565b612156612bab565b60025490916001600160a01b03916121719083163314614a17565b61217e82841615156149c1565b16604051916370a0823160e01b8352306004840152602083602481855afa9182156108a45784926121ba575b6111d293506111cd831515614a60565b91506020833d82116121e7575b816121d460209383612d84565b81010312610897576111d29251916121aa565b3d91506121c7565b503461055657602036600319011261055657612209612b95565b612211612c0f565b6001600160a01b03166122258115156149c1565b600280546001600160a01b03191691909117905580f35b5034610556576003196040368201126109bd576001600160401b03600435811061108357610140826004353603011261108357602435116109bd57604090602435360301126105565761228d612eb3565b612295612e6c565b6123786122a6602435600401612c67565b6122b4604460043501612c67565b90612321606460043501926106366122cb85612c67565b936122da608460043501612c67565b906122e960c460043501612c7b565b956122f860e460043501612c67565b6040519788963095469460a4600435013592602460043501356004356004013560208d01612c90565b6020815191012061233d61012460043501600435600401612da7565b1515905061273c57600080516020614b5b8339815191528452601c5261069e603c84206102ad6102a661010460043501600435600401612da7565b6001600160a01b0391828061239160043560e401612c67565b169116036104565742602460043501351061044557816123b5604460043501612c67565b161561043357816123ca60e460043501612c67565b1683526004602081905260408420906001600160801b0319906123f0903560c401612c7b565b16845260205260ff604084205416610421578161241160e460043501612c67565b1683526003602052816040842054161561040f5761242e81612c67565b82167f0000000000000000000000000000000000000000000000000000000000000000831614612730578161246282612c67565b169061247a60a4600435013560043560040135612e2b565b91612489602435600401612c67565b93604051816370a0823160e01b96878352166004820152602081602481865afa9081156127255787916126ef575b50848110610c7c5750806124ca84612c67565b16906124df6024803501602435600401612da7565b919092604183036126dd5782899360201161100657806040116110065760411161108357612511602435600401612c67565b813b15611006578360e4926020604051978896879563d505accf60e01b87521660048601523060248601528b6044860152602460043501356064860152604081013560f81c6084860152803560a4860152013560c48401525af180156126bf576126ca575b506125a6602061258a602435600401612c67565b60405180938192636eb1769f60e11b8352309060048401613166565b0381855afa9081156126bf57869161268d575b508381106108af5750826125f0575b846103cc846125d685612c67565b6125e4602435600401612c67565b91600435600401614809565b604051938452306004850152602084602481845afa938415610902578594612655575b50906126416103cc946125d6936126398630612633602435600401612c67565b846131a2565b30918661492b565b61264f600435600401614625565b906125c8565b9350906020843d602011612685575b8161267160209383612d84565b810103126108975792519290612641612613565b3d9150612664565b90506020813d6020116126b7575b816126a860209383612d84565b810103126108975751866125b9565b3d915061269b565b6040513d88823e3d90fd5b6126d690959195612d0a565b9385612576565b6040516325ba634760e11b8152600490fd5b90506020813d60201161271d575b8161270a60209383612d84565b810103126127195751876124b7565b8680fd5b3d91506126fd565b6040513d89823e3d90fd5b906118d5602492612c67565b604061069e916109b561099061012460043501600435600401612da7565b50346105565780600319360112610556576040517f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03168152602090f35b5034610556576020366003190112610556576111d2818080806127c0612b95565b6002546001600160a01b0391906127da9083163314614a17565b166127e68115156149c1565b4790611515821515614a60565b5090346109bd5761280336612b63565b9061280c612eb3565b612814612e6c565b8135916020808201358083604081019561282d87612c67565b966060830197898761283e8b612c67565b61284a60808801612c67565b9360a0880135998a9460c08a01986128618a612c7b565b9a019961286d8b612c67565b906040519788978801998a973097339746976128889b612c90565b03601f198101825261289a9082612d84565b519020936101208801946128ae868a612da7565b6128ed979150612b2e5750600080516020614b5b8339815191528c52601c526128e5603c8c206102ad6102a66101008c018c612da7565b959095612f09565b6001600160a01b0394858061290187612c67565b16911603610456574211610445576129198491612c67565b1615610433578261292983612c67565b1689526004855260408920906001600160801b03199061294890612c7b565b168952845260ff604089205416610421576129638291612c67565b16875260038352806040882054161561040f5761297f85612c67565b81167f0000000000000000000000000000000000000000000000000000000000000000821614612b2257906129be916129b786612c67565b1695612e2b565b906040516370a0823160e01b9081815233600482015282816024818a5afa9081156118be578891612af5575b5083811061090d5750604051636eb1769f60e11b8152828180612a11303360048401613166565b03818a5afa9081156118be578891612ac4575b508381106108af575082612a44575b50506103cc9350611bcb3393612c67565b6040519081523060048201528181602481895afa918215612725578792612a94575b5050612a84906103cc95612a7c843033846131a2565b30918461492b565b612a8d82614625565b3880612a33565b90809250813d8311612abd575b612aab8183612d84565b81010312611015575184612a84612a66565b503d612aa1565b90508281813d8311612aee575b612adb8183612d84565b81010312612aea575138612a24565b8780fd5b503d612ad1565b90508281813d8311612b1b575b612b0c8183612d84565b81010312612aea5751386129ea565b503d612b02565b6024906118d586612c67565b6128e59161049d612b416040938d612da7565b8c8592955194828693838501988937830191820152038c810184520182612d84565b6003199060208183011261089757600435916001600160401b0383116108975782610140920301126108975760040190565b600435906001600160a01b038216820361089757565b602435906001600160a01b038216820361089757565b6003199190604083820112610897576001600160401b0390600435828111610897576101408582840301126108975760040193602435928311610897578260e0920301126108975760040190565b6000546001600160a01b03163303612c2357565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b356001600160a01b03811681036108975790565b356001600160801b0319811681036108975790565b9081526020810191909152606091821b6001600160601b0319908116604083015292821b8316605482015292811b82166068840152607c8301939093526001600160801b0319909316609c82015292811b821660ac84015260c083019390935292821b831660e082015292901b1660f48201526101080190565b6001600160401b038111612d1d57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117612d1d57604052565b606081019081106001600160401b03821117612d1d57604052565b608081019081106001600160401b03821117612d1d57604052565b601f909101601f19168101906001600160401b03821190821017612d1d57604052565b903590601e198136030182121561089757018035906001600160401b0382116108975760200191813603831361089757565b6001600160401b038111612d1d57601f01601f191660200190565b929192612e0082612dd9565b91612e0e6040519384612d84565b829481845281830111610897578281602093846000960137010152565b91908201809211612e3857565b634e487b7160e01b600052601160045260246000fd5b91908203918211612e3857565b600160ff1b8114612e385760000390565b60ff60005460a01c16612e7b57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b600260015414612ec4576002600155565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b60058110156130085780612f1a5750565b60018103612f625760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b60028103612faf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314612fb857565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b90604181511460001461304c57613048916020820151906060604084015193015160001a90613056565b9091565b5050600090600290565b9291906fa2a8918ca85bafe22016d0b997e4df60600160ff1b0383116130cf5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156130c25781516001600160a01b038116156130bc579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b80356001600160a01b03811690819003610897578252602090810135910152565b93949291606061312b9261311087826130db565b604081013560408801520135606086015260808501906130db565b6001600160a01b031660c083015261010060e083018190528201819052610120928190848401376000828201840152601f01601f1916010190565b6001600160a01b0391821681529116602082015260400190565b6001600160a01b03918216815291166020820152604081019190915260600190565b906131d8906131ca6131dd956040519586936323b872dd60e01b602086015260248501613180565b03601f198101845283612d84565b6131df565b565b60018060a01b03169061323e6040516131f781612d33565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16132386132d4565b91613304565b8051918215918483156132b0575b5050509050156132595750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126109bd5782015190811515820361055657508038808461324c565b3d156132ff573d906132e582612dd9565b916132f36040519384612d84565b82523d6000602084013e565b606090565b919290156133665750815115613318575090565b3b156133215790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156133795750805190602001fd5b60405162461bcd60e51b81526020600482015290819061339d9060248301906133a1565b0390fd5b919082519283825260005b8481106133cd575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016133ac565b8051156133ee5760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156133ee5760400190565b8051600210156133ee5760600190565b8051600310156133ee5760800190565b8051600410156133ee5760a00190565b8051600510156133ee5760c00190565b6001600160a01b039091168152602081019190915260400190565b600060443d106134cc57604051600319913d83016004833e81516001600160401b03918282113d6024840111176134cf578184019485519384116134d7573d850101602084870101116134cf57506134cc92910160200190612d84565b90565b949350505050565b50949350505050565b91939290936000946000936134f760608201612c67565b6001600160a01b039081167f0000000000000000000000000000000000000000000000000000000000000000909116036145ec577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316905b61360761361e61356c60a08401358435612e2b565b604051606086811b6001600160601b0319908116602084015260e89a909a1b6001600160e81b031916603483015287901b9098166037890152602b8852966135b381612d4e565b604080517f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b031660208201529081018990526060810188905260a0608082015292839160c08301906133a1565b600060a0830152601f198282030182520382612d84565b61362a60608301612c67565b9561363760408401612c67565b6040519760018060a01b0316602089015260018060a01b03166040880152823560608801526060875261366987612d69565b61367560608401612c67565b956001600160a01b0361368a60e08601612c67565b1660005260036020526136ca60018060a01b03604060002054166136bc604051998a9260a08901359160208501613180565b03601f198101895288612d84565b600090819034156140d157505050506136e4343331612e2b565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad8116600483018190529297923190602090839060249082907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2165afa90811561405d5760009161409b575b61376f9250612e2b565b966001600160a01b0361378460e08601612c67565b166000908152600360209081526040918290205491516370a0823160e01b81526001600160a01b03928316600482015291829060249082908a165afa90811561405d57600091614069575b50926137dd60408601612c67565b6040516370a0823160e01b81526001600160a01b03918216600482015290602090829060249082908b165afa90811561405d5760009161402b575b50604051600b60f81b6020820152600160f81b6021820152600560f81b602282018190526023820152600360fa1b6024820152600160fa1b60258201526006815290939061386581612d33565b604051909390916001600160401b0360e0840190811190841117612d1d5760e083016040526006835260005b60c0811061401a575060405192936139bf9385939291906138e381610636347f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b031660208401613454565b6138ec856133e1565b526138f6846133e1565b5061390084613404565b5261390a83613404565b5061391483613414565b5261391e82613414565b5061392882613424565b5261393281613424565b50604080517f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b0316602082015260008183015290815261397881612d4e565b61398182613434565b5261398b81613434565b506040516000602082015233604082015260006060820152606081526139b081612d69565b6139b982613444565b52613444565b505b7f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b03163b1561089757604051630d64d59360e21b81526060600482015291829190613a179060648401906133a1565b600319838203016024840152815180825260208201916020808360051b8301019401926000915b838310613fe9575050505050602086013560448301526000919081900381347f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b03165af19081613fd5575b50613d1c57505050505050506001908060033d11613d0c575b6308c379a014613cd1575b50613abb57565b613ac36132d4565b805160208201207f865c3ff234d3d0edd202666a7ee80e1df8991d5f3d0735c47363eaf02da248f68103613b27576040516345313e0b60e11b815260206004820152600d60248201526c05633496e76616c69645377617609c1b6044820152606490fd5b7f7949afa5f7d1aca4443eae437acb1046b7439815697e5489cca05d226a192b138103613b8a576040516345313e0b60e11b8152602060048201526013602482015272158cd51bdbd31a5d1d1b19549958d95a5d9959606a1b6044820152606490fd5b7f6c00b934adb0b7404a228838c719adfbb4e9deac0b09dc9249e888189cb51f6a8103613bec576040516345313e0b60e11b8152602060048201526012602482015271158cd51bdbd35d58da14995c5d595cdd195960721b6044820152606490fd5b7f483c13bc9b4251bad271f371298893f2995abed398de6edf3108289714194b898103613c4e576040516345313e0b60e11b8152602060048201526012602482015271158cd25b9d985b1a59105b5bdd5b9d13dd5d60721b6044820152606490fd5b7ff14c0a0eab0cabeb85cee7eed6c1c3d990aa7959546121092a1062bf3a5d784103613cac576040516345313e0b60e11b815260206004820152600f60248201526e2b19a4b73b30b634b221b0b63632b960891b6044820152606490fd5b60405163917827e160e01b81526020600482015290819061339d9060248301906133a1565b613cd961346f565b9081613ce55750613ab4565b506040516345313e0b60e11b8152602060048201529150819061339d9060248301906133a1565b50600481803e805160e01c613aa9565b979850949693949293919290916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690613d6160608601612c67565b1603613f6c575b505034159150613e5c905057506040516370a0823160e01b81526001600160a01b037f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad81166004830181905233319492903191602090829060249082907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2165afa928315613e505792613e18575b506134cc94613e0c613e129493613e0c93612e2b565b92612e2b565b90612e4e565b9291506020833d602011613e48575b81613e3460209383612d84565b8101031261089757915190916134cc613df6565b3d9150613e27565b604051903d90823e3d90fd5b6040516370a0823160e01b80825233600483015292949293916001600160a01b031690602081602481855afa8015613f61578390613f2e575b6040519586527f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b03166004870152949160209150829060249082905afa918215613e505791613ef8575b506134cc93613e1292613e0c91612e2b565b9390506020843d602011613f26575b81613f1460209383612d84565b81010312610897579251613e0c613ee6565b3d9150613f07565b506020813d602011613f59575b81613f4860209383612d84565b810103126108975760209051613e95565b3d9150613f3b565b6040513d85823e3d90fd5b613fcc93613fb0906001600160a01b03613f8860e08701612c67565b168952600360205260408920546001600160a01b0391821694911690849060a087013561492b565b6001600160a01b03613fc460408501612c67565b16923561492b565b38808080613d68565b613fe0919950612d0a565b60009738613a90565b919395509193602080614008600193601f1986820301875289516133a1565b97019301930190928695949293613a3e565b806060602080938701015201613891565b90506020813d602011614055575b8161404660209383612d84565b81010312610897575138613818565b3d9150614039565b6040513d6000823e3d90fd5b90506020813d602011614093575b8161408460209383612d84565b810103126108975751386137cf565b3d9150614077565b90506020823d6020116140c9575b816140b660209383612d84565b810103126108975761376f915190613765565b3d91506140a9565b6040516370a0823160e01b81523360048201529398929491936020816024816001600160a01b038d165afa801561405d5782906000906145b6575b6141169250612e2b565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad81166004830152919a91602090829060249082908e165afa90811561405d57600091614584575b509a6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116906141ad60608b01612c67565b160361434857604051600160f81b6020820152600360fa1b6021820152600560f81b602282018190526023820152600160fa1b6024820152600581526141f281612d33565b604051909590926001600160401b0360c0850190811190851117612d1d5760c084016040526005845260005b60a0811061433757509183916106366142876142fd95614332989799614243876133e1565b5261424d866133e1565b506040519283917f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad6001600160a01b031660208401613454565b61429084613404565b5261429a83613404565b506142a483613414565b526142ae82613414565b506142b882613424565b526142c281613424565b5060405160018060a01b038c16602082015233604082015260006060820152606081526142ee81612d69565b6142f782613434565b52613434565b505b6001600160a01b037f0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad8116908a166145fe565b6139c1565b80606060208093880101520161421e565b9195509093506001600160a01b03905061436460e08701612c67565b166000908152600360209081526040918290205491516370a0823160e01b81526001600160a01b03928316600482015291829060249082908b165afa90811561405d57600091614552575b50936143bd60408701612c67565b6040516370a0823160e01b81526001600160a01b03918216600482015290602090829060249082908c165afa90811561405d57600091614520575b5060408051600160f81b6020820152600560f81b602182018190526022820152600160fa1b60238201526004815291959082018083116001600160401b0390911117612d1d5781946040830160e084011060018060401b0360e085011117612d1d5760e083016040526004604084015260005b6080811061451057508261450a92604092836143329796019761448f8585016133e1565b5261449b8484016133e1565b506144a7848401613404565b526144b3838301613404565b506144bf838301613414565b526144cb828201613414565b5081516001600160a01b038d1660208201523381840152600060608083019190915281526144f881612d69565b614503838301613424565b5201613424565b506142ff565b606084820181015260200161446b565b90506020813d60201161454a575b8161453b60209383612d84565b810103126108975751386143f8565b3d915061452e565b90506020813d60201161457c575b8161456d60209383612d84565b810103126108975751386143af565b3d9150614560565b90506020813d6020116145ae575b8161459f60209383612d84565b81010312610897575138614173565b3d9150614592565b50506020813d6020116145e4575b816145d160209383612d84565b810103126108975781614116915161410c565b3d91506145c4565b6145f860608201612c67565b90613557565b6131d86131dd93926131ca60405194859263a9059cbb60e01b602085015260248401613454565b6060810161463281612c67565b6001600160a01b0391829182167f00000000000000000000000000000000000000000000000000000000000000008316036146c45750508135806146a7575b5060a0820135908161468257505050565b8061469260e06131dd9501612c67565b166000526003602052604060002054166148d0565b6146be90826146b860408601612c67565b166148d0565b38614671565b6146cd90612c67565b16823580614718575b5060a083013591826146e9575b50505050565b806146f960e061470f9601612c67565b16600052600360205260406000205416906145fe565b388080806146e3565b614730908361472960408701612c67565b16836145fe565b386146d6565b61474560a08201358235612e2b565b9061475260608201612c67565b6001600160a01b039081167f000000000000000000000000000000000000000000000000000000000000000082161480614800575b614797575b506131dd9150614625565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21691823b1561089757600092602484926040519586938492632e1a7d4d60e01b845260048401525af191821561405d576131dd921561478c576147fa90612d0a565b3861478c565b50821515614787565b927fb7ee4fafa10d16ee883a136a3dcc9179d8e6041ba71cc29c2b0bce4f7bdd6e869260a0926001600160a01b03928692849290918390816148846148ac60406148a561489f60e08c018661485d82612c67565b166000908152600460205284902060c09d909d019c6001600160801b03199687908f612c7b565b1660005260205283600020600160ff19825416179055612c67565b9a612c7b565b9d01612c67565b906040519c168c521660208b015216604089015260608801521660808601521692a2565b6001600160a01b0316600080808085855af16148ea6132d4565b90156148f557505050565b61339d906040519384936328688b5560e01b855260048501526024840152600060448401526080606484015260848301906133a1565b6040516370a0823160e01b81526001600160a01b03948516600482015290939192909160209183916024918391165afa90811561405d5760009161498e575b509061497591612e4e565b0361497c57565b604051631dc418c360e31b8152600490fd5b906020823d82116149b9575b816149a760209383612d84565b8101031261055657505161497561496a565b3d915061499a565b156149c857565b60405162461bcd60e51b815260206004820152602160248201527f537765657061626c653a2063616e6e6f74206265207a65726f206164647265736044820152607360f81b6064820152608490fd5b15614a1e57565b60405162461bcd60e51b815260206004820152601a60248201527929bbb2b2b830b136329d103737ba103a34329039bbb2b2b832b960311b6044820152606490fd5b15614a6757565b60405162461bcd60e51b8152602060048201526017602482015276537765657061626c653a207a65726f2062616c616e636560481b6044820152606490fd5b15614aad57565b60405162461bcd60e51b815260206004820152601960248201527829bbb2b2b830b136329d103a3930b739b332b91032b93937b960391b6044820152606490fd5b15614af557565b60405162461bcd60e51b815260206004820152601f60248201527f537765657061626c653a20696e73756666696369656e742062616c616e6365006044820152606490fdfea453db612af59e5521d6ab9284dc3e2d06af286eb1b1b7b771fce4716c19f2c119457468657265756d205369676e6564204d6573736167653a0a3332000000008be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0a2646970667358221220157560c88e23f3e233fc467282dc5bbbfb9ccd5cbbe8aeeeb548a89421b22d1664736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000008fccc78dae0a8f93b0fe6799de888d4c57e273db0000000000000000000000006d8675a52438849d90241cb639fba41bdc3329c8000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : _uniswap (address): 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD
Arg [1] : _permit2 (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
Arg [2] : _initialOperator (address): 0x8fcCC78Dae0a8f93B0fE6799de888d4C57e273db
Arg [3] : _initialFeeDestination (address): 0x6D8675A52438849d90241cB639fba41bDC3329c8
Arg [4] : _wrappedNativeCurrency (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad
Arg [1] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [2] : 0000000000000000000000008fccc78dae0a8f93b0fe6799de888d4c57e273db
Arg [3] : 0000000000000000000000006d8675a52438849d90241cb639fba41bdc3329c8
Arg [4] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Loading...
Loading
Loading...
Loading
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.