Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 20 from a total of 20 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Pay With Any Tok... | 20034448 | 48 days ago | IN | 0 ETH | 0.00473965 | ||||
Execute | 19948530 | 60 days ago | IN | 0.22922288 ETH | 0.00167424 | ||||
Execute | 19948419 | 60 days ago | IN | 0.19362264 ETH | 0.00176135 | ||||
Execute | 19948393 | 60 days ago | IN | 0.89329567 ETH | 0.00207583 | ||||
Execute | 19948155 | 60 days ago | IN | 0.44531587 ETH | 0.00234216 | ||||
Pay With Any Tok... | 19911154 | 65 days ago | IN | 0 ETH | 0.00157867 | ||||
Execute | 19883996 | 69 days ago | IN | 0.00033932 ETH | 0.00142739 | ||||
Pay With Any Tok... | 19869836 | 71 days ago | IN | 0 ETH | 0.00351961 | ||||
Pay With Any Tok... | 19832067 | 76 days ago | IN | 0 ETH | 0.00133639 | ||||
Pay With Any Tok... | 19303913 | 150 days ago | IN | 0 ETH | 0.00205436 | ||||
Pay With Any Tok... | 19284034 | 153 days ago | IN | 0 ETH | 0.00749398 | ||||
Pay With Any Tok... | 19248456 | 158 days ago | IN | 0 ETH | 0.00529321 | ||||
Pay With Any Tok... | 19232953 | 160 days ago | IN | 0 ETH | 0.00543809 | ||||
Pay With Any Tok... | 18983250 | 195 days ago | IN | 0.3379271 ETH | 0.00429429 | ||||
Pay With Any Tok... | 18982985 | 195 days ago | IN | 0.07596905 ETH | 0.00447852 | ||||
Pay With Any Tok... | 18855435 | 213 days ago | IN | 0 ETH | 0.0093817 | ||||
Pay With Any Tok... | 18304624 | 290 days ago | IN | 0 ETH | 0.00085967 | ||||
Pay With Any Tok... | 18190960 | 306 days ago | IN | 0 ETH | 0.00093805 | ||||
Pay With Any Tok... | 18113049 | 317 days ago | IN | 0 ETH | 0.00214536 | ||||
Pay With Any Tok... | 18095902 | 319 days ago | IN | 0.01707431 ETH | 0.0017548 |
Latest 13 internal transactions
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
20248295 | 18 days ago | 0.00740387 ETH | ||||
20248295 | 18 days ago | 0.00740387 ETH | ||||
19948530 | 60 days ago | 0.22922288 ETH | ||||
19948419 | 60 days ago | 0.19362264 ETH | ||||
19948393 | 60 days ago | 0.89329567 ETH | ||||
19948155 | 60 days ago | 0.44531587 ETH | ||||
19883996 | 69 days ago | 0.00033932 ETH | ||||
18983250 | 195 days ago | 0.3379271 ETH | ||||
18982985 | 195 days ago | 0.07596905 ETH | ||||
18263251 | 296 days ago | 0.20671765 ETH | ||||
18263251 | 296 days ago | 0.20671765 ETH | ||||
18095902 | 319 days ago | 0.01707431 ETH | ||||
18009552 | 331 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
Gateway
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0 /* Used only by [swappin.gifts](https://swappin.gifts]) to accept payments in any token or native coin. We've designed this contract to be non-upgradable. Once the contract has been deployed to the blockchain, it will never change. This guarantee, as provided by the blockchain, together with the complete source code of the contract, will allow any party to verify the security properties and guarantees. By putting security and transparency first, we hope to pave the way for a more trustless and trustable ecosystem. Clara pacta, boni amici. =; ;@f `z. ?@@o *QR T@@@*`^hQ@@~ `!vSjv*. ~D@@@@%@@@@@B;;~~~:,,'`` `,. `^yg@@@} :i ``...';iD@@@@@@@@@@@@@@@@@@@@@@@@@QY;~'` :zg@@@@@@@Wi*jQ@875q8Q@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@bod@@@@@@QNKa7<;,. ` z@@@@@@@@@@@@@@@@@@@@@@@DXUd&@@@@@@@@@@@@@@@@@@@@@@@@@RjjQ@@@@@@@@@@@@@@@@@@@Qm<` +@@@Q@@@@@@@@@@@@@@@@Qf;,`,7N@@@@@@@@@@@@@@@@@@@@@@NoqQ@@@@@@@@@@@@@@@@@@NESE%@@@Q86}|~` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@goZhQ@DqbbD%BQ@@@@QB8E7hXAN@@@@@@@@@@@@@@QE=. 5@@b;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&hz?!^hgQ@@@@@@@@Q&#%655XqRQyj8@@@@@@@@@@@@@@@@@@@q*. 'Q@@`x@z8@@@@@@@@@@@@@@@@@@@@@@@@@Qbj\r,``;fDQQQWE|;,~~~~,!czzzfEqQ@@@@WE6DQ@@@@@@@@@@@@@@@@@@Bj+` 'Q@y |~`qf .~wbDDgWD%Q@@@@@@@@@@@@@@@@@@@@QWEL,7yjz+, ,?7yXqUSc;.~?}URQ@QNQQQQBb57|=*s}yZShXqDDy?^' `6@* ~ ,Q@@@@@@Kj@@@@@@@@@@@@@@@@@@@@@@@@Ez@@@@@QQ@Q@@@@@@@Qw^Z6yc; ,\i>~'z8QQbUK@@@@@@@@@@W%D%j! ^Q| ;Q@@@@@QDk<@@@@@@@@@@@@@@@RkXN@@@@@@RL@@@@@@@Q*}@@@@@@@z`Q@@@@E,'|{XQQa=*K@@@qyQ@@@@@@@@@@bAQQ^ `\i` ~D@@@@@DDQQ^b@@@@@@auQ@@@kT=vi^>~Q@@@@@{@@@@@@Y``d@@@@@@j ,@@@@@@@^:QgJ~~^^`'7W@@yS@@@@@@@@@@@NQ@U` `;D@@@@#XD@U; +@@@@@@@@P,Bi`~.7@@{DTX@@@@X@@@@%i` =Q@@@@87'`z@@@@@@@@j K@@@6,`: `^jDKg8Q@@@@@@@@@@@Q; ,D@@@@KY8@I` ;@@@@@@@@@Qi ~@h+%czNu@@@QyQ@#J_~<SQ@Q%qX*=76@@@@@@@@Qi'}@@@@@Q ;Nx. '`'r^':^|zjm6DNQ@@d; `?6J@@@@o^J@Zqy: *@@@@@gSoLvEy ?f\JgKB@@RLi5*''<aR8BNkjz^!yD%8BQ8D6mwZjg@@@@@@@7 'g@@E``;ERaK@BE>~DNQQQNDdaLu\` ~U@@LN@@hsBhQI`7@@@@@@@jjN@Q@~ ~yNb8@gRu, !R67^, .\aEZs|!, 'iUg#%Ayz|;`_j@@@@@8 ;%}6@od@@QP@@@@@@@@@U|EK*` ,D@@@@;@#iW@!.@@@%@@@@@j7QQf_ { ;Dg6E%%Wq< .r` `,` ~XE7^_,nNQQQ@@@@@@@@@, y@K;j*L@@Q@@@@@@@@@@@%K@Q; ~*.@@@@@@~^=@g' j@@@@@@d}n8m~ `6D~:IQQs' ' .^nKQ@@@@Q%c }@@Q. `iQQ@@@@@@@@@@@@@@@; !@Q'@@@@@Q^=@f `~;;^=7T~ D\ DD! ;xi?<*7b@@@@k j: ~ugQQ#@@@@@@@@@@Q` .JJ@@d*@@@QRxQ? .= ^! `?6Q@@@@@@@^ i@m`XE+.\wc;;*zSdQ@@@Q, i} s@@@w^gk8%m; ` .;?vz|. `D@@d`A@Q+A@@Qz}@@Q%DKDQE, .K7 'Q@@@@'.QQ;L !s7c7fq@@@@@,a^yB~7@@@aQ@@@@@@@@K' ~Q7 .Q@@@@@L5#'' .ibQ@@@@@@@'f@~ , ,D@@y@@@@@@@@@QI. =@#z;Q@@@@QDI~ '~^in{\' y@@; !D@q@@@@@@@@@@@o` <Q!b@q@@@@UA@: =qDSIzjB@@@# ~U%DQ@@@@@@@@@j ?@~`@@NW@gYQ@! .s. _yQ@@@@@@@`b. dj' >f|!7g@@@@@@@` <@i z@@@u^t@@^ ,Q~ _\mDBq* 8#`b@@z{@@NS,IZ8@@@@^ =@k ;@@@@@`K@~ ^`!@o ^7;` !@@y_R@@_Q@@@5@@QN@@@B. QQ``Q@@@@@o@~ 'E:z@@. ~W@@QQ@@@@Q,'<Qy,@@@6@@@@@@hQ6+` *\`@< 6@@@@@@h8 ~d'k@@a= ;q@@@@@@h!Q`.K.,#@h@@@@@@@@@j ~@Q@ ;@@@@@@AQa ~B'N@@@^% ! '`!7jY^ j@\ , `Dd@@@@@@@@@@} !@@@;}@@@@@RP@!'Q;kQ=@g7W`{, _%n^,,+E@@D ' `oE@@@@@@@@@U b%W@@jQ@@@mb@j`Bj>qy{EjUQB| ,Q@@@@@@@B ! Wy .;;g@@@@@@@E <@;N@@@Az%*Q@N`EQ`=7@z;=K@; +8@@@@@n D~%@j+@s.,E@@@@@a :@Q,@@@@@Q;`Q@'z@z ~@@| ;` `\_'*ti~ ~@L|@Q~@@@L6zuQ@@R #@a<@@@@@@@\!,,@@, Q@@^ , ;@Q{^;!}@@* L@`@@Qk@@@y|D@? `@@vI@@@@@@@@@'q@@`^@@@!=jD L@@@@@@@@' y.6@mQ@@@@#`y@~ Q@|J@@@@@@@@@7U@Q d@@@;K~@ .;Q@@@@@?`+ ~@n@@@@@@;'Q<` 'sz@}~@@@@@@@d@{`A,`@@@@;a7q' SL`=5P}, of P{Q@@@@@7 @+ 'Q@@|i@@@@Q|@@_ ,@KQ@r|@;~ _@W+'``_m@| ~y `hk@@@@@U @Q v@h@QAD@@;N@B ~@',Q\,@>` w@@@@@@@Q` 8@: 'm@@@@@Q @@+ *@.D@@@k*.N@L :g?+'< Q7 .`U@@@@@%, .@@^,y,a@@@@@;@@~ j@:?@@@@@U+z` <=`yx@! zi c; ;fP};_7 Qh Q@@,=@@@@Q@| %@^'@@@@@@@Qf` @@7 n@@i .^ 7@! ^@, |`?@@@<6hg@@@u %@5 X@@@@@@@8Q`y@@`v@@@* ` ;@@Q6XQ@j R@%X@@@#|Q@~ L@Q ~@@@@@@@DQX`X@ ^@@@@; ``w@@@@@y Q@Q@@@@@=`@n T@| j@@@@@@N%@,`= `@@@@@: {f ;Jjz,~` ;X Q@@@@@@@f,@S `iU@! j@@@@@RN@z q@@@@@: `Q@j' `;Uf U@@~ hQ@@@@@@hy@R `d@@gnjd@@@6Q@U ,@@i;U@: '@@@@@@@5 ^@#^`o_n@@@@@@Q@@+ W@SQ@@#DK*~RD L@L '~d~ h f@@@@g^ Kj `B@i`7@@@@@@@! ,QQ:Q@@@@@S;> `' ?j NX;; ^@, :\i;, `? `d@@Q.`b@@@@Q~ ,@D'@@@@@@@%Kn` QS:. c@@Q> Q@Qj!;}a 6@Qaq@Q;@@@Q` ,Qx*@@@@@@@@6@^7@@D,`Q@@@B; '@@@@@@i .T; +@XZ@@@@X^@@i .8~h@@@@@@@E@@i;6@y ,@@@@@k` ~D `@@@@j. u@@+ QuN@@@@@g K@~ `U.!R@@@@@Qm@@* ,s _Q@@@@Q| ;@Q |7~`` ?@@@~.~D@@@@@@@{'ES` ^WUtJoPURQ'K@@^ 'N@D*oWf ,@@@K*^Tf^ Q&|;AE'@@@@@@@B'W+ `qQ@@@@QDy?rc; `5Q !i?; `T R@@@@@Q* ;;`k@@j B@@@@@@!gQ `S;g@@@@@@@#Ay; *Nz,;.;@@@@dL' `{@f X@@@U! ,Q@@djq7@@@@@zQ@7 ;g`|@@@@@@@@qN%_ E@@Q' =@@@@@@b; ,Q@@D. ',;*' ~ 'Q@kk@@@^@@@@d@@R` mQ,'Z@@@@@@@qB@j'^h@g !@@@@QQ@D, 's:'@@@@@@QQE!!h@\ `QDA@@@@@iZ@@@@q; `Q@^ ;g@@@@@@y8@Q+ `*; ,D@@; `;^. `f@D Z@@@@Qw=` v@@Q ,^zBQ@@@@@@;;@@y, `A@b'`~zkd%RD!+zi'`` ``^#|'@@@@@#EL: . ^Q@@8.,rvz= i@U*^D@*d@@@@@@@f !R' :7%@bQ@@@@@@@@@QWdKy{;i#XE,z@@@@@@@@@q*` `^ZN; ^@@@@@@@@d^` : ;D@@?`5@@@@@@z`Sq` '{'`~y@@@@@@@@@@@68QhKQ@7,q@@@@N^:,;+'` +X@@@~ g@@@@Qh*. ';` ;d@QKyU^@@@@@Q;+QN` `A\` `}@@@@@@@@@@%6@@k~^: 'v#@Q',Q@@@@@@@Qdy*_ `!zSX_+Q@@@@Q*^;zjs+ YQ@@D, `EWgWQ@@@P@@@@z;D@Q. `BQ= 'jQ@@@@@@@@DJgQD' ~Yqr|Q@@@@@@w\>;,.~!=||*^;:. `,!**~*d@@@B' @@@@@@@@@@@87.`a@@@y `''y%@@@@@@@q@@B>k@@Q~ 'W@Qyi<^v5UKKbKKquiJdN%Kyz;!mZY~ ;oQ@@@; !qQ@@@@@@@@w?~.'*aW@@@E;>Q@@@@@K;'^EgQQgK5i;` ,wm7*TSQ@,<@@@@@@@@id@gq@8o! !wQ@U|\ag@@@@@@@@@@@@@#k@@E{SR| '=aBX~?b@@@@@@D` `{&@@@@@@L R@@@@@@@@@@gj<,'jXK%j` ~S@@@W:.@@@@@@@K,,@Qy;` `;iv, _\8@@@@@@@@@@@m@@@%^ '\yuS! `!{bQ@@Bi~{R@@@@@@@@NUKKEI=!;,` `!q@@@Wr .uQ@@QgDQRY@@@@@D~`LNc \K>` ,fQ@@@@@@@QU,,~?nSPaUDXfYyjSL `,^xJ!``'~;;!^^;;|uzL*+; 'i7\L?^,``zQ@@@@@@@@*Q@@@P~~a@D. ,WQZ; ;\o5Ti\zkN@@@@@@@N%%RQ@QqY' ~d@@@@A?` <KQ@@@Qj^` ';i}UgQ@T~Q@@@@@@@@@S=@@K+7%@@y` ^6@QZ+;|o%@@@@@@@@@@@@@@@@Q+`,+\nSqDQQ%XYcI\*!~' `'''_^*?'`+}R@@QQQQQK,7@@@@@@@@@@u`W@dD&KaL' `,;|h@6fUB@@@@@@@@@QmnzjDQ@@@@@@@WDq6byi|izykb8Q@@@Qy+cXKD%NQQQQQQ!L@@@@@@@@8\,+fn~` .aQUi;,!|zJcr*w@@@@@@@@@@@@@@@Q*`^PAgQ@@@QWwv. 'fQ@@@@@@@@@@@_@@@@@@bucyBQ< ,h@@@8a7TwQ@@@@@@@@@@@@@@@Di*A@@@@@@@@@@@@L;A@@@@@@@@@@@@8_D@@@@@8Q@@WL` .^<<+!!\6NDwYzfEK8Q@@Qy|yQ@@@@@@@@@@@@Q!S@@@@@@@@@@&U7!~y@QdE}T*!_. ;yQ@QKo7<^~iN@@Q%K6U66qqqUm*i@@@@@@N6a}JYEwt<=z' `!czv|z7<<sERBgDqUUkkXomQ@QRdDDDDbqXy>' .^z5aY?~`~T;` */ pragma solidity ^0.8.20; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import './Whitelist.sol'; import './ApproveUtils.sol'; import './IPermit2.sol'; // import 'hardhat/console.sol'; /// /// @title Used only by [swappin.gifts](https://swappin.gifts]) to accept payments in any token or native coin. /// @author swappin.gifts /// @notice We've designed this contract to be non-upgradable. Once the contract has been deployed to the blockchain, it will never change. /// @notice This guarantee, as provided by the blockchain, together with the complete source code of the contract, will allow any party to verify the security properties and guarantees. /// @notice By putting security and transparency first, we hope to pave the way for a more trustless and trustable ecosystem. /// @notice Clara pacta, boni amici. /// @dev Supports payment with several different ERC20 tokens and ETH in one transaction, NFT mint & burn, Permit2. /// @dev See README.md for more information. /// contract Gateway is ReentrancyGuard, Whitelist { using Address for address; using SafeERC20 for IERC20; using ApproveUtils for IERC20; IPermit2 public immutable PERMIT2; /// @notice emitted on succesfull payment event Payment(bytes32 indexed orderId, uint64 indexed refId, address indexed dest, address tokenTo, uint256 amount); /// @notice emitted on succesfull execution of execute() event ExecuteEvent(int8 indexed eventType, bytes32 eventData); constructor(address _permit2Address) { PERMIT2 = IPermit2(_permit2Address); } /// /// @notice The create2 constructor alternative. Initializes the whitelist and sets the owner. /// @dev Setting the owner this way is secure because the DeterministicDeployFactory.deploy() is onlyOwner. /// @dev `_dests` and `_tokens` are pairs so arrays must have same length. Same applies to `_providers` and `_providerSpenders`. /// /// @param _dests array of allowed destination wallets /// @param _tokens array of allowed destination tokens /// @param _providers array of allowed swap providers /// @param _providerSpenders array of allowed swap provider spender contracts (sometimes not the same as the provider main contract) /// @param _signers array of allowed signers /// @param _ownerAddress the constructor will transfer ownership to this account /// function init( address[] memory _dests, address[] memory _tokens, address[] memory _providers, address[] memory _providerSpenders, address[] memory _signers, address _ownerAddress ) external onlyOwner { // make sure pair lists lengths match require(_providers.length == _providerSpenders.length, 'providers and providerSpenders length differs'); require(_dests.length == _tokens.length, 'destinations and tokens length differs'); // fill white list of providers setProviders(_providers, _providerSpenders, TRUE); // fill white list of destinations setDestinations(_dests, _tokens, TRUE); // fill white list of signers (for execute() method) setSigners(_signers, TRUE); // transfer ownership to final owner transferOwnership(_ownerAddress); } //// //// @notice Pay with any token or ETH, converting on the fly into toToken. //// @dev //// @dev This entry point supports //// @dev 1. ERC20 allowance flow. //// @dev 2. Permit2 SignatureTransfer allowance flow. //// @dev 3. AllowanceTransfer allowance flow - permit & transfer. //// @dev 4. AllowanceTransfer allowance flow - transfer (allowance exists). //// //// @notice This external method is for the simple use case of payment alone. /// @notice For complex txs that include additional operations such as mint and redeem, execute() is used. //// //// @param orderInfo order info //// @param swapInfo swap info //// @param paymentMethod data specific to the selected payment flow type //// function payWithAnyToken(OrderInfo memory orderInfo, TokenSwapInfo[] memory swapInfo, PaymentMethodInfo memory paymentMethod) external payable nonReentrant { _payWithAnyToken(orderInfo, swapInfo, paymentMethod); } /// /// @notice Composes several tx in one meta tx. /// @dev Executes a signed list of tx. /// @dev Signature verification protects against tampering. /// @dev Contained tx are unsigned, which prevents their extraction (i.e. mint without payment). /// @dev /// function execute(Tx[] calldata txs, int8 eventType, bytes32 eventData, bytes calldata signature) external payable nonReentrant { _requireValidSigned(ECDSA.toEthSignedMessageHash(keccak256(abi.encode(address(this), block.chainid, txs, eventType, eventData))), signature); uint len = txs.length; for (uint i = 0; i < len; ) { Tx calldata t = txs[i]; address to = t.to; bytes calldata data = t.data; if (to == address(this)) { // call the payment function directly and internaly (OrderInfo memory orderInfo, TokenSwapInfo[] memory swapInfo, PaymentMethodInfo memory paymentMethod) = abi.decode( data, (OrderInfo, TokenSwapInfo[], PaymentMethodInfo) ); _payWithAnyToken(orderInfo, swapInfo, paymentMethod); } else if (t.value > 0) { // optionaly appends msg.sender to.functionCallWithValue(t.msgSender ? abi.encodePacked(data, msg.sender) : data, t.value); } else { // optionaly appends msg.sender to.functionCall(t.msgSender ? abi.encodePacked(data, msg.sender) : data); } unchecked { ++i; } } emit ExecuteEvent(eventType, eventData); } function _payWithAnyToken(OrderInfo memory orderInfo, TokenSwapInfo[] memory swapInfo, PaymentMethodInfo memory paymentMethod) private { IERC20 tokenTo = orderInfo.tokenTo; address dest = orderInfo.dest; // validation. save start balance uint256 destStartBalance = paymentStart(tokenTo, dest); // transfer to this contract or dest from user wallet transferFromSender(orderInfo, swapInfo, paymentMethod); // swap tokens and ETH to toToken and transfer to 'dest' executeSwaps(swapInfo, tokenTo, dest); // verify that 'minAmountTo' of 'tokenTo' added to 'dest' uint256 totalAmountReceived = verifyFinalAmounts(destStartBalance, tokenTo, dest, orderInfo.minAmountTo); emit Payment(orderInfo.orderId, orderInfo.refId, dest, address(tokenTo), totalAmountReceived); } function transferFromSender(OrderInfo memory orderInfo, TokenSwapInfo[] memory swapInfo, PaymentMethodInfo memory paymentMethod) private { if (paymentMethod.methodType == PAY_ALLOWANCE_ERC20) { transferByErc20Allowance(orderInfo, swapInfo); } else if (paymentMethod.methodType == PAY_PERMIT2_PERMIT_AND_TRANSFER) { permit2PermitAndTransfer(paymentMethod.methodSpecificData); } else if (paymentMethod.methodType == PAY_PERMIT2_TRANSFER) { permit2ValidateAndTransfer(abi.decode(paymentMethod.methodSpecificData, (IPermit2.AllowanceTransferDetails[]))); } else if (paymentMethod.methodType == PAY_PERMIT2_SIG_TRANSFER) { permit2SigTransfer(paymentMethod.methodSpecificData); } else { revert('unknown paymentMethod'); } } /// @notice Permit2 SignatureTransfer single-use permit & transfer /// @dev Transfer tokens from msg.sender to this contract /// @dev Transfer toTokens directly to 'dest' /// @dev Permit2 provides batch transfer, which can be used only once for all the tokens in one call function permit2SigTransfer(bytes memory methodSpecificData) private { Permit2SignatureBatch memory permit2 = abi.decode(methodSpecificData, (Permit2SignatureBatch)); PERMIT2.permitTransferFrom(permit2.permit, permit2.transferDetails, msg.sender, permit2.permit2Signature); } /// @notice Permit2 AllowanceTransfer permit & transfer /// @dev Transfer tokens from msg.sender to this contract /// @dev Transfer toTokens directly to 'dest' /// @dev Permit2 provides batch transfer, which can be used only once for all the tokens in one call function permit2PermitAndTransfer(bytes memory methodSpecificData) private { Permit2AllowanceBatch memory permit2 = abi.decode(methodSpecificData, (Permit2AllowanceBatch)); // first permit the allowance PERMIT2.permit(msg.sender, permit2.permit, permit2.permit2Signature); // next perform the transfer permit2ValidateAndTransfer(permit2.transferDetails); } /// @notice Permit2 AllowanceTransfer just transfer /// @dev Validates the batch and then /// @dev Transfer tokens from msg.sender to this contract /// @dev Transfer toTokens directly to 'dest' /// @dev Permit2 provides batch transfer, which can be used only once for all the tokens in one call function permit2ValidateAndTransfer(IPermit2.AllowanceTransferDetails[] memory batchDetails) private { // make sure it's only msg.sender operating on his own tokens validatePermit2Batch(batchDetails); // perform transfers PERMIT2.transferFrom(batchDetails); } /// @notice ERC20 allowance flow - batch ERC20.safeTransferFrom() /// @dev Transfer tokens from msg.sender to this contract /// @dev Transfer toTokens directly to 'dest' function transferByErc20Allowance(OrderInfo memory orderInfo, TokenSwapInfo[] memory swapInfo) private { uint256 batchLen = swapInfo.length; // transfer tokens from sender to this contract. or to dest (if tokenFrom=tokenTo) for (uint i = 0; i < batchLen; ) { TokenSwapInfo memory s = swapInfo[i]; IERC20 tokenFrom = s.tokenFrom; // Skip ETH swap entries if (address(tokenFrom) != address(0)) { // Send to 'dest' (if tokenTo) or to this contract (if requires conversion to tokenTo first) tokenFrom.safeTransferFrom(msg.sender, tokenFrom == orderInfo.tokenTo ? orderInfo.dest : address(this), s.amountFrom); } unchecked { ++i; } } } function paymentStart(IERC20 tokenTo, address dest) private view returns (uint256) { // destination address and token are white listed require(_isValidDestination(dest, address(tokenTo)), 'unknown destination'); // return start balance of dest return tokenTo.balanceOf(dest); } function executeSwaps(TokenSwapInfo[] memory swapInfo, IERC20 tokenTo, address dest) private returns (uint256) { uint256 totalAmountReceived = 0; uint256 batchLen = swapInfo.length; for (uint i = 0; i < batchLen; ) { TokenSwapInfo memory s = swapInfo[i]; // don't swap the tokenTo token if (s.tokenFrom == tokenTo) { // basic input checks require(s.minAmountTo > 1, 'invalid minAmountTo'); require(s.amountFrom > 0, 'invalid amountFrom'); } else { if (address(s.tokenFrom) == address(0)) { // call provider to convert ETH to tokenTo totalAmountReceived += swapEth(s, tokenTo); } else { // call provider to convert tokenFrom to tokenTo totalAmountReceived += swapToken(s, tokenTo); } } unchecked { ++i; } } // transfer received tokenTo from all swaps to dest address if (totalAmountReceived > 0) { tokenTo.safeTransfer(dest, totalAmountReceived); } return totalAmountReceived; } /// /// @notice Call DEX provider to convert ETH to `token` /// function swapEth(TokenSwapInfo memory swapInfo, IERC20 tokenTo) private returns (uint256) { uint256 minAmountTo = swapInfo.minAmountTo; uint256 amountFrom = swapInfo.amountFrom; address swapProvider = swapInfo.swapProvider; // provider address is white listed require(_isValidProvider(swapProvider), 'unknown provider'); require(minAmountTo > 1, 'invalid minAmountTo'); require(amountFrom > 0, 'invalid amountFrom'); // save this contract's ETH balance uint256 ethStartBalance = address(this).balance; // save this contract's token balance uint256 startBalance = tokenTo.balanceOf(address(this)); // call provider to convert ETH to token swapProvider.functionCallWithValue(swapInfo.swapCalldata, amountFrom); // verify received tokens amount from provider uint256 receivedAmount = tokenTo.balanceOf(address(this)) - startBalance; require(receivedAmount >= minAmountTo, 'invalid amount of token from swap provider'); // verify transfered exactly the received ETH to provider require(ethStartBalance - address(this).balance == amountFrom, 'invalid amount transferred to swap provider'); // return the actual amount calculated from balances (not what the provider might have returned) return receivedAmount; } /// /// @notice Call DEX provider to convert `tokenFrom` to `tokenTo` /// function swapToken(TokenSwapInfo memory swapInfo, IERC20 tokenTo) private returns (uint256) { uint256 minAmountTo = swapInfo.minAmountTo; uint256 amountFrom = swapInfo.amountFrom; address swapProvider = swapInfo.swapProvider; address providerSpender = swapInfo.providerSpender; IERC20 tokenFrom = swapInfo.tokenFrom; // provider address and provider spender address are white listed require(_isValidProviderSpender(swapProvider, providerSpender), 'unknown provider'); require(minAmountTo > 1, 'invalid minAmountTo'); require(amountFrom > 0, 'invalid amountFrom'); // allow providerSpender to spend amountFrom of tokenFrom tokens held by this contract tokenFrom.safeApproveImproved(providerSpender, amountFrom); // save start tokenTo balance uint256 startBalance = tokenTo.balanceOf(address(this)); // call swap provider swapProvider.functionCall(swapInfo.swapCalldata); // verify tokenTo amount received from provider corresponds to what was quoted uint256 receivedAmount = tokenTo.balanceOf(address(this)) - startBalance; require(receivedAmount >= minAmountTo, 'received invalid destToken amount from swap provider'); // reset providerSpender allowance to 0 tokenFrom.zeroAllowance(providerSpender); // return the actual amount calculated from balances return receivedAmount; } /// /// @notice Verify final payment amount /// function verifyFinalAmounts(uint256 destStartBalance, IERC20 tokenTo, address _dest, uint256 minAmountTo) private view returns (uint256) { // total amount of tokenTo added to 'dest' since getting 'destStartBalance' uint256 totalAmountReceived = tokenTo.balanceOf(_dest) - destStartBalance; require(totalAmountReceived >= minAmountTo, 'invalid amount transfered to dest'); return totalAmountReceived; } /// /// @notice Verifies signature and signer /// function _requireValidSigned(bytes32 hash, bytes calldata signature) private view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); require(error == ECDSA.RecoverError.NoError && _isValidSigner(recovered), 'execute: invalid signature or signer'); return true; } function validatePermit2Batch(IPermit2.AllowanceTransferDetails[] memory batchDetails) private view { uint256 batchLength = batchDetails.length; for (uint256 i = 0; i < batchLength; ) { require(batchDetails[i].from == msg.sender, 'from address is not owner'); unchecked { ++i; } } } struct Tx { address to; uint256 value; bool msgSender; bytes data; } struct OrderInfo { bytes32 orderId; uint64 refId; address dest; IERC20 tokenTo; uint256 minAmountTo; } struct TokenSwapInfo { address swapProvider; address providerSpender; IERC20 tokenFrom; uint256 amountFrom; uint256 minAmountTo; bytes swapCalldata; } struct PaymentMethodInfo { uint8 methodType; bytes methodSpecificData; } struct Permit2AllowanceBatch { IPermit2.PermitBatch permit; IPermit2.AllowanceTransferDetails[] transferDetails; bytes permit2Signature; } struct Permit2SignatureBatch { IPermit2.PermitBatchTransferFrom permit; IPermit2.SignatureTransferDetails[] transferDetails; bytes permit2Signature; } }
// 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) (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.9.0) (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. */ 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]. */ 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.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.0) (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. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ 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.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 v4.4.1 (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; } }
// 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 (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: 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: AGPL-3.0 pragma solidity ^0.8.20; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title ergonomic and robust utility functions to set and reset allowances in a safe way /// @notice this library is embedded in the contract since it has only internal functions library ApproveUtils { using Address for address; using SafeERC20 for IERC20; /// @notice ERC20 safeApprove /// @dev Gives `spender` allowance to transfer `requiredAmount` of `token` held by this contract function safeApproveImproved(IERC20 token, address spender, uint256 requiredAmount) internal { uint256 allowance = token.allowance(address(this), spender); // only change allowance if we don't have enough of it already if (allowance >= requiredAmount) return; if (allowance == 0) { // safeApprove works only if trying to set to 0 or current allowance is 0 token.safeApprove(spender, requiredAmount); return; } // current allowance != 0 and less than the required amount // first try to set it to the required amount try token.approve(spender, requiredAmount) returns (bool result) { // check return status safeApprove() does this for us, but not approve() require(result, 'failed to approve spender'); } catch { // Probably a non standard ERC20, like USDT // set allowance to 0 token.safeApprove(spender, 0); // set allowance to required amount token.safeApprove(spender, requiredAmount); } } /// @dev Reset ERC20 allowance to 0 function zeroAllowance(IERC20 token, address spender) internal { // if already 0 don't do anything (can't be less than 0 because uint) if (token.allowance(address(this), spender) == 0) return; token.safeApprove(spender, 0); require(token.allowance(address(this), spender) == 0, 'failed to zero allowance'); } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.20; contract Constants { /// @dev deletes an entry from a whitelist - isn't currently used from the contract. kept for documentation purposes bytes32 internal constant ZERO = bytes32(uint256(0)); /// @dev allow flag in a whitelist - isn't currently used from the contract. reserved for future use bytes32 internal constant TRUE = bytes32(uint256(1)); /// @dev destination role bytes32 internal constant ROLE_DESTINATION = bytes32(uint256(2)); /// @dev provider role bytes32 internal constant ROLE_PROVIDER = bytes32(uint256(3)); /// @dev signer role bytes32 internal constant ROLE_SIGNER = bytes32(uint256(4)); uint8 internal constant PAY_ALLOWANCE_ERC20 = 1; uint8 internal constant PAY_PERMIT2_PERMIT_AND_TRANSFER = 2; uint8 internal constant PAY_PERMIT2_TRANSFER = 3; uint8 internal constant PAY_PERMIT2_SIG_TRANSFER = 4; }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.20; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Just what is used from the Permit2 interface interface IPermit2 { /// @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 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 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 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 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; // Token and amount in a permit message. struct TokenPermissions { // Token to transfer. IERC20 token; // Amount to transfer. uint256 amount; } // Transfer details for permitTransferFrom(). struct SignatureTransferDetails { // Recipient of tokens. address to; // Amount to transfer. uint256 requestedAmount; } 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; } function permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes calldata signature ) external; }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.20; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import './Constants.sol'; /// @title A whitelist for provider addresses and destination addresses /// @notice Use by inheriting contract Whitelist is Ownable, Constants { /// @dev roles mapping(bytes32 => bytes32) public _roles; /// @notice on added/removed destination event UpdatedDestination(address indexed dest, address indexed token, bytes32 status); /// @notice on added/removed provider event UpdatedProvider(address indexed provider, address indexed providerSpender, bytes32 status); /// @notice on added/removed signer event UpdatedSigner(address indexed frowarder, bytes32 status); constructor() {} /// @dev Returns current status flag for destination function _isValidDestination(address dest, address token) internal view returns (bool) { return _roles[keccak256(abi.encode(dest, token, ROLE_DESTINATION))] == TRUE; } /// @dev Returns current status flag for provider and spender address combination function _isValidProviderSpender(address providerAddress, address spenderAddress) internal view returns (bool) { return _roles[keccak256(abi.encode(providerAddress, spenderAddress, ROLE_PROVIDER))] == TRUE; } /// @dev Returns current status flag for provider address function _isValidProvider(address providerAddress) internal view returns (bool) { return _roles[keccak256(abi.encode(providerAddress, ROLE_PROVIDER))] == TRUE; } /// @dev Returns if signer is valid function _isValidSigner(address signerAddress) internal view returns (bool) { return _roles[keccak256(abi.encode(signerAddress, ROLE_SIGNER))] == TRUE; } /// @dev Adds/deletes the given destinations from the white list function setDestinations(address[] memory dests, address[] memory tokens, bytes32 flag) public onlyOwner { uint256 len = dests.length; for (uint256 i = 0; i < len; i++) { emit UpdatedDestination(dests[i], tokens[i], flag); _roles[keccak256(abi.encode(dests[i], tokens[i], ROLE_DESTINATION))] = flag; } } /// @dev Adds/deletes the given signer from the white list function setSigners(address[] memory signers, bytes32 flag) public onlyOwner { uint256 len = signers.length; for (uint256 i = 0; i < len; i++) { emit UpdatedSigner(signers[i], flag); _roles[keccak256(abi.encode(signers[i], ROLE_SIGNER))] = flag; } } /// @dev Adds/deletes the given providers from the white list function setProviders(address[] memory _providers, address[] memory _providerSpenders, bytes32 flag) public onlyOwner { uint256 len = _providers.length; for (uint256 i = 0; i < len; i++) { emit UpdatedProvider(_providers[i], _providerSpenders[i], flag); _roles[keccak256(abi.encode(_providers[i], ROLE_PROVIDER))] = flag; _roles[keccak256(abi.encode(_providers[i], _providerSpenders[i], ROLE_PROVIDER))] = flag; } } }
{ "evmVersion": "paris", "viaIR": true, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_permit2Address","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int8","name":"eventType","type":"int8"},{"indexed":false,"internalType":"bytes32","name":"eventData","type":"bytes32"}],"name":"ExecuteEvent","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":true,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":true,"internalType":"uint64","name":"refId","type":"uint64"},{"indexed":true,"internalType":"address","name":"dest","type":"address"},{"indexed":false,"internalType":"address","name":"tokenTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Payment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"dest","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bytes32","name":"status","type":"bytes32"}],"name":"UpdatedDestination","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"address","name":"providerSpender","type":"address"},{"indexed":false,"internalType":"bytes32","name":"status","type":"bytes32"}],"name":"UpdatedProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"frowarder","type":"address"},{"indexed":false,"internalType":"bytes32","name":"status","type":"bytes32"}],"name":"UpdatedSigner","type":"event"},{"inputs":[],"name":"PERMIT2","outputs":[{"internalType":"contract IPermit2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"_roles","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"msgSender","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Gateway.Tx[]","name":"txs","type":"tuple[]"},{"internalType":"int8","name":"eventType","type":"int8"},{"internalType":"bytes32","name":"eventData","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_dests","type":"address[]"},{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address[]","name":"_providers","type":"address[]"},{"internalType":"address[]","name":"_providerSpenders","type":"address[]"},{"internalType":"address[]","name":"_signers","type":"address[]"},{"internalType":"address","name":"_ownerAddress","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"orderId","type":"bytes32"},{"internalType":"uint64","name":"refId","type":"uint64"},{"internalType":"address","name":"dest","type":"address"},{"internalType":"contract IERC20","name":"tokenTo","type":"address"},{"internalType":"uint256","name":"minAmountTo","type":"uint256"}],"internalType":"struct Gateway.OrderInfo","name":"orderInfo","type":"tuple"},{"components":[{"internalType":"address","name":"swapProvider","type":"address"},{"internalType":"address","name":"providerSpender","type":"address"},{"internalType":"contract IERC20","name":"tokenFrom","type":"address"},{"internalType":"uint256","name":"amountFrom","type":"uint256"},{"internalType":"uint256","name":"minAmountTo","type":"uint256"},{"internalType":"bytes","name":"swapCalldata","type":"bytes"}],"internalType":"struct Gateway.TokenSwapInfo[]","name":"swapInfo","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"methodType","type":"uint8"},{"internalType":"bytes","name":"methodSpecificData","type":"bytes"}],"internalType":"struct Gateway.PaymentMethodInfo","name":"paymentMethod","type":"tuple"}],"name":"payWithAnyToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"dests","type":"address[]"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes32","name":"flag","type":"bytes32"}],"name":"setDestinations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_providers","type":"address[]"},{"internalType":"address[]","name":"_providerSpenders","type":"address[]"},{"internalType":"bytes32","name":"flag","type":"bytes32"}],"name":"setProviders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"signers","type":"address[]"},{"internalType":"bytes32","name":"flag","type":"bytes32"}],"name":"setSigners","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a0346100d457601f6200337338819003918201601f19168301916001600160401b038311848410176100d9578084926020946040528339810103126100d457516001600160a01b0390818116908190036100d457600160008181558154336001600160a01b0319821681179093556040519416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a36080526132839081620000f08239608051818181610ff3015281816121cd0152818161227d01528181612601015281816126ce0152612a0c0152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c80632c0aa4441461111f57806363c48dc9146110225780636afdd85014610fdd5780636b9ae9e01461072d578063715018a6146106d05780638da5cb5b146106a7578063bd99d7e11461067b578063ea4ab55d146105ac578063f1469009146104d8578063f2fde38b146104ab5763fc4421761461009557600080fd5b346104a65760c03660031901126104a6576001600160401b036004358181116104a6576100c69036906004016114ac565b906024358181116104a6576100df9036906004016114ac565b916044358281116104a6576100f89036906004016114ac565b6064358381116104a6576101109036906004016114ac565b926084359081116104a6576101299036906004016114ac565b9160a4359460018060a01b0392838716958688036104a65761014961155c565b815181510361044b5783518351036103f75761016361155c565b81519160005b838110610326575050505061017c61155c565b81519160005b838110610293575050505061019561155c565b81519160005b8381106102105785856101ac61155c565b156101bc576101ba906115b4565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b808361021f61028e9385612b4a565b511660026040516001928382527f8f274dd93892c16bd176917df3ac9c96c46485a816e07abb0a330c8a694e85a760208093a28661025d8588612b4a565b5116604051828101918252600460408201526040815261027c816113a7565b5190206000525260406000205561323e565b61019b565b80856102a26103219385612b4a565b5116866102af8387612b4a565b5116604051906001928383527fe551056d99411952ee83a3fb5b4d6633f179839bf8dc9a07e7b1892708e9892360208094a3876102ec8487612b4a565b511690886102fa8589612b4a565b51169160405192828401918252604084015260029260608481830152815261027c816113d5565b610182565b80876103356103f29385612b4a565b5116886103428387612b4a565b5116604051906001928383527fe74f3f5287db251a626ba2d45792295a1dc0d4118437040cf716b5533f56099e60208094a38961037f8487612b4a565b51169060405191818301908152600392836040820152604081526103a2816113a7565b519020600052600291828252836040600020558b6103c08689612b4a565b5116908c6103ce878b612b4a565b51169060405191848301938452604083015260609081830152815261027c816113d5565b610169565b60405162461bcd60e51b815260206004820152602660248201527f64657374696e6174696f6e7320616e6420746f6b656e73206c656e677468206460448201526569666665727360d01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602d60248201527f70726f76696465727320616e642070726f76696465725370656e64657273206c60448201526c656e677468206469666665727360981b6064820152608490fd5b600080fd5b346104a65760203660031901126104a6576004356001600160a01b0381168082036104a6576101ac61155c565b346104a65760403660031901126104a6576004356001600160401b0381116104a6576105089036906004016114ac565b60243561051361155c565b81519060005b82811061052257005b6105a79060026001600160a01b038061053b8489612b4a565b511690604051918683527f8f274dd93892c16bd176917df3ac9c96c46485a816e07abb0a330c8a694e85a760208094a26105758489612b4a565b51166040518281019182526004604082015260408152610594816113a7565b519020600052528260406000205561323e565b610519565b346104a6576105ba36611512565b6105c261155c565b82519160005b8381106105d157005b610676906001600160a01b03806105e88389612b4a565b5116816105f58487612b4a565b5116604051918783527fe551056d99411952ee83a3fb5b4d6633f179839bf8dc9a07e7b1892708e9892360208094a38161062f848a612b4a565b51169161063c8487612b4a565b511691604051928284019182526040840152600292606084818301528152610663816113d5565b519020600052528360406000205561323e565b6105c8565b346104a65760203660031901126104a65760043560005260026020526020604060002054604051908152f35b346104a65760003660031901126104a6576001546040516001600160a01b039091168152602090f35b346104a65760003660031901126104a6576106e961155c565b600180546001600160a01b031981169091556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b60803660031901126104a6576001600160401b03600435116104a6573660236004350112156104a6576001600160401b0360043560040135116104a6573660246004356004013560051b6004350101116104a6576024358060000b81036104a6576001600160401b03606435116104a6573660236064350112156104a6576001600160401b0360643560040135116104a657366024606435600401356064350101116104a6576107db6115fd565b60405130602082015246604082015260a0606082015260c0810160043560040135905260e081018160e06004356004013560051b8201016024600435019260005b600435600401358110610ee757505061084f92508460000b608083015260443560a083015203601f1981018352826113f0565b602081519101207f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c526108a1603c60002061089b3660643560040135602460643501611457565b90613177565b6005811015610ed157159081610e8d575b5015610e3c5760005b60043560040135811061090157507feca3caccccb5df40a89f1a6b525e97e804596a1b95e2e832afa53361823a5f5e602060405192604435845260000b92a26001600055005b60248160051b6004350101359060a2196004353603018212156104a6576004358201602401356001600160a01b03811690036104a6576004358201368190036042190160849091013512156104a6576001600160401b03600435830160848101350160240135116104a6576004358201608481013501602481013536036044909101136104a6576004358201602401356001600160a01b03163003610d2d576004358201608481013501602481013581010360e081126104a65760a0136104a657604051916109cf83611340565b600435810160848101350160448101358452606401356001600160401b03811690036104a6576064608460043583018181013501918201356020860152610a169101611411565b6040840152610a31600435820160848101350160a401611411565b6060840152600435810160848101350160c481013560808501526001600160401b0360e490910135116104a65760043581016084810135016024810135810160440160e482013590910160630112156104a657600435810160848101350160e48101350160440135610aa281611425565b90610ab060405192836113f0565b808252602082019060043584016084810135016024810135810160440160e4820135909101600583901b01606401116104a657600435840160848101350160e481013501606401915b600435850160848101350160e481013501600583901b016064018310610bfb5750506001600160401b03600435840160848101350161010401351190506104a657604060043583016084810135016101048101358101602482013590910103126104a65760405190610b6a8261138c565b6004358301608481013501610104810135016044013560ff811690036104a657600435830160848101350161010481013501604481013583526001600160401b03606490910135116104a657600194610bf593610beb906004350160848101350160248101358101604490810191610104810135016064810135010161148e565b60208401526118bb565b016108bb565b6001600160401b038335116104a65760c0600435860160848101350160e48101358101853501602482013590910103601f1901126104a657604051610c3f81611371565b610c5e600435870160848101350160e481013501853501606401611411565b8152610c80600435870160848181013590910160e48101350186350101611411565b6020820152610ca4600435870160848101350160e48101350185350160a401611411565b6040820152600435860160848101350160e48181013590910185350160c481013560608401529081013560808301526001600160401b0361010490910135116104a6576020918291610d1d6004358901608481013501602481013581016044019060e4810135018835016101048101350160640161148e565b60a0820152815201920191610af9565b6001916004358101604401358015610dc75781610d536064610d9d946004350101611653565b15610da357604051602490610d9081610d82336004358701608481013501808701359060440160208501611660565b03601f1981018352826113f0565b915b6004350101356116c3565b50610bf5565b6024610dc13660043584016084810135018084013590604401611457565b91610d92565b5080610ddc6064610d9d936004350101611653565b15610e1857604051602490610e0b81610d82336004358701608481013501808701359060440160208501611660565b915b600435010135611683565b6024610e363660043584016084810135018084013590604401611457565b91610e0d565b60405162461bcd60e51b8152602060048201526024808201527f657865637574653a20696e76616c6964207369676e6174757265206f7220736960448201526333b732b960e11b6064820152608490fd5b604080516001600160a01b03909216602083019081526004838301529082529150610eb7816113a7565b5190206000526002602052600160406000205414826108b2565b634e487b7160e01b600052602160045260246000fd5b85830360df1901825290925090600435360360a21901843512156104a6576001600160a01b03610f1e853560043501602401611411565b168152833560043501604481013560208301526064013580151581036104a65715156040820152833560043501368190036042190160849091013512156104a6576004358435016084810135016001600160401b036024820135116104a6576024810135360360448201136104a657602060a08382936080606060019701526024810135608083015260248101356044820184840137600083602483013584010152601f6024811992013501160101950193019101908492939161081c565b346104a65760003660031901126104a6576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346104a65761103036611512565b61103b92919261155c565b81519160005b83811061104a57005b61111a906001600160a01b03806110618386612b4a565b51168161106e848a612b4a565b5116604051918783527fe74f3f5287db251a626ba2d45792295a1dc0d4118437040cf716b5533f56099e60208094a3816110a88487612b4a565b51169160405192828401908152600393846040820152604081526110cb816113a7565b51902060005260029283835287604060002055816110e98689612b4a565b5116916110f6868c612b4a565b511690604051918483019384526040830152606090818301528152610663816113d5565b611041565b366003190160e081126104a65760a0136104a65761113d6080611340565b6004356080526024356001600160401b03811681036104a65760a0526001600160a01b0360443581811681036104a65760c05260643590811681036104a65760e052608435610100526001600160401b0360a435116104a65736602360a4350112156104a6576111b260a43560040135611425565b6111bf60405191826113f0565b60a4356004013581526020810136602460a4356004013560051b60a4350101116104a657602460a43501905b602460a4356004013560051b60a435010182106112815760c435836001600160401b0382116104a657604060031983360301126104a6576040519061122f8261138c565b826004013560ff811681036104a657825260248301356001600160401b0381116104a65761127a936004611266923692010161148e565b60208301526112736115fd565b60806118bb565b6001600055005b81356001600160401b0381116104a65760c060a4358201360360231901126104a657604051916112b083611371565b6112c060248360a4350101611411565b83526112d260448360a4350101611411565b60208401526112e760648360a4350101611411565b604084015260a4803583016084810135606086015290810135608085015260c40135926001600160401b0384116104a6576113306020949360248695369260a43501010161148e565b60a08201528152019101906111eb565b60a081019081106001600160401b0382111761135b57604052565b634e487b7160e01b600052604160045260246000fd5b60c081019081106001600160401b0382111761135b57604052565b604081019081106001600160401b0382111761135b57604052565b606081019081106001600160401b0382111761135b57604052565b6001600160401b03811161135b57604052565b608081019081106001600160401b0382111761135b57604052565b90601f801991011681019081106001600160401b0382111761135b57604052565b35906001600160a01b03821682036104a657565b6001600160401b03811161135b5760051b60200190565b6001600160401b03811161135b57601f01601f191660200190565b9291926114638261143c565b9161147160405193846113f0565b8294818452818301116104a6578281602093846000960137010152565b9080601f830112156104a6578160206114a993359101611457565b90565b81601f820112156104a6578035916114c383611425565b926114d160405194856113f0565b808452602092838086019260051b8201019283116104a6578301905b8282106114fb575050505090565b83809161150784611411565b8152019101906114ed565b9060606003198301126104a6576001600160401b036004358181116104a6578361153e916004016114ac565b926024359182116104a657611555916004016114ac565b9060443590565b6001546001600160a01b0316330361157057565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600180546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60026000541461160e576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b3580151581036104a65790565b826014949392823701906bffffffffffffffffffffffff199060601b1681520190565b6114a991604051916116948361138c565b601e83527f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000060208401526117af565b604051916116d0836113a7565b602983527f416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c6020840152681d594819985a5b195960ba1b604084015283471061175b576000816114a9956020839451920190855af13d15611753573d916117368361143c565b9261174460405194856113f0565b83523d6000602085013e6117d6565b6060916117d6565b60405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608490fd5b6000806114a9949360208151910182855af13d156117d2573d916117368361143c565b6060915b9192901561183857508151156117ea575090565b3b156117f35790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561184b5750805190602001fd5b60405162461bcd60e51b81526020600482015290819061186f906024830190611896565b0390fd5b60005b8381106118865750506000910152565b8181015183820152602001611876565b906020916118af81518092818552858086019101611873565b601f01601f1916010190565b919091606081015191600060018060a01b0360408401511694604051602081019087825260018060a01b03871660408201526002606082015260608152611901816113d5565b51902082526002602052600160408320540361289c576040516370a0823160e01b815260048101879052926020846024816001600160a01b038a165afa93841561289157839461285d575b50805160ff16600181036120345750508051825b818110611f965750505b80518291825b828110611afe5750505080611ab1575b5060808301516040516370a0823160e01b815260048101879052909290916020836024816001600160a01b038a165afa908115611aa55790611a71575b6119c79250612d42565b908110611a22578151602092830151604080516001600160a01b03969096168652938501929092526001600160401b039091169290917f492a436a3bf1e520560253818ad2141475da45f6984e5a5f791fcb29c186782391a4565b60405162461bcd60e51b815260206004820152602160248201527f696e76616c696420616d6f756e74207472616e73666572656420746f206465736044820152601d60fa1b6064820152608490fd5b506020823d602011611a9d575b81611a8b602093836113f0565b810103126104a6576119c791516119bd565b3d9150611a7e565b604051903d90823e3d90fd5b60405163a9059cbb60e01b60208201526001600160a01b03871660248201526044810191909152611af890611ae98160648101610d82565b6001600160a01b038616612b8c565b38611980565b611b088183612b4a565b5160408101516001600160a01b03908116908a168103611b4a575090611b44606083611b3b600160808197015111612c80565b01511515612cc2565b01611970565b919490918681611dab57505060808201519189602460608301519260018060a01b038151169060405160208101908382526003604082015260408152611b8f816113a7565b5190208b526002602052611ba9600160408d205414612d03565b611bb560018811612c80565b611bc0851515612cc2565b6040516370a0823160e01b81523060048201524794909360209185919082906001600160a01b03165afa928315611da05790859392918c93611d65575b5092611c109160a06024950151906116c3565b5060208d604051938480926370a0823160e01b825230600483015260018060a01b03165afa8015611d5a578a90611d26575b611c4c9250612d42565b938410611cce57611c5e904790612d42565b03611c7557600191611c6f91612c5d565b93611b44565b60405162461bcd60e51b815260206004820152602b60248201527f696e76616c696420616d6f756e74207472616e7366657272656420746f20737760448201526a30b810383937bb34b232b960a91b6064820152608490fd5b60405162461bcd60e51b815260206004820152602a60248201527f696e76616c696420616d6f756e74206f6620746f6b656e2066726f6d207377616044820152693810383937bb34b232b960b11b6064820152608490fd5b506020823d602011611d52575b81611d40602093836113f0565b810103126104a657611c4c9151611c42565b3d9150611d33565b6040513d8c823e3d90fd5b935091506020833d602011611d98575b81611d82602093836113f0565b810103126104a657915184929091611c10611bfd565b3d9150611d75565b6040513d8d823e3d90fd5b918a602460808694960151936020606082015193611e3160018060a01b0384511695611e1360016040818060a01b0387890151169c8d8251898101918d8352848201526003606082015260608152611e02816113d5565b519020815260028852205414612d03565b611e1f60018a11612c80565b611e2a811515612cc2565b898b612d4f565b6040516370a0823160e01b815230600482015293849182906001600160a01b03165afa918215611da0578b92611f61575b5060249260a0611e7492015190611683565b5060208d604051938480926370a0823160e01b825230600483015260018060a01b03165afa8015611d5a578a90611f2d575b611eb09250612d42565b918210611ecb57611ec6611c6f93600195613031565b612c5d565b60405162461bcd60e51b815260206004820152603460248201527f726563656976656420696e76616c69642064657374546f6b656e20616d6f756e6044820152733a10333937b69039bbb0b810383937bb34b232b960611b6064820152608490fd5b506020823d602011611f59575b81611f47602093836113f0565b810103126104a657611eb09151611ea6565b3d9150611f3a565b9091506020813d602011611f8e575b81611f7d602093836113f0565b810103126104a65751906024611e62565b3d9150611f70565b80611fa360019285612b4a565b51828060a01b036040820151169081611fbf575b505001611960565b61202491848060a01b0360608b015116811460001461202b576060858060a01b0360408c015116925b0151604051926323b872dd60e01b6020850152336024850152868060a01b0316604484015260649081840152825261201f82611340565b612b8c565b3880611fb7565b60603092611fe8565b600281036123c757506020015180518101906020818303126123c3576020810151916001600160401b038311612347576060838301820312612347576040519261207d846113a7565b602081840101516001600160401b03811161234b576060818386010184031261234b57604051906120ad826113a7565b6020818487010101516001600160401b0381116123bf5760208501603f8284878a0101010112156123bf576020818386890101010151906120ed82611425565b916120fb60405193846113f0565b80835260208301916020880160408a83888b8760071b930101010101116123bb5760408186898c01010101925b60408a83888b8760071b930101010101841061234f575050505090606091835261215860408286890101016128d7565b602084015283860101015160408201528452604081840101516001600160401b03811161234b576121939060208085019184870101016128eb565b602085015260608184010151916001600160401b03831161234b5791602091826121c29594019301010161299d565b6040820181905281517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163b1561234757846040518093632a2d80d160e01b82523360048301526060602483015260c4820193805194606060648501528551809152602060e48501960190855b8181106122ec5750505060208101516001600160a01b031660848401526040015160a483015281840360031901604483015291929091829161227891611896565b0381837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af180156122e1579084916122c9575b505060206122c49101516129f2565b61196a565b6122d2906113c2565b6122dd5782386122b5565b8280fd5b6040513d86823e3d90fd5b825180516001600160a01b039081168a52602082810151909116818b015260408083015165ffffffffffff908116918c019190915260609283015116918a01919091526080909801978c975089965090920191600101612237565b8480fd5b8680fd5b60806020858b0301126123b7579060806020604093845161236f816113d5565b612378886128d7565b81526123858389016128d7565b838201526123948689016129df565b868201526123a4606089016129df565b6060820152815201940193909150612128565b8c80fd5b8b80fd5b8880fd5b8380fd5b60038103612410575060200151805181016020828203126123c3576020820151906001600160401b0382116123475791602061240b92816122c495019201016128eb565b6129f2565b919291600403612820576020015180518101906020818303126122dd576020810151916001600160401b0383116123c35760608383018203126123c3576040519261245a846113a7565b602081840101516001600160401b0381116127865760608183860101840312612786576040519061248a826113a7565b6020818487010101516001600160401b03811161281c5760208501603f8284878a01010101121561281c576020818386890101010151906124ca82611425565b916124d860405193846113f0565b80835260208301916020880160408a83888b8760061b930101010101116128185760408186898c01010101925b60408a83888b8760061b93010101010184106127ce57505050908352506040838601918201818101516020850152606001518184015291865201516001600160401b0381116127865760208301603f8284870101011215612786576020818386010101519061257382611425565b9161258160405193846113f0565b80835260208301916020860160408360061b83888b01010101116123bf576040818689010101925b60408360061b83888b01010101841061278a5750505050602085015260608184010151916001600160401b0383116127865791602091826125ef9594019301010161299d565b604082018190528151602090920151907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163b156123c35791839160405193849263edd9444b60e01b84526080600485015260e484019080519160606084870152825180915260206101048701930190875b81811061275557505050806020604092015160a4870152015160c485015260031984820301602485015260208084519283815201930190855b8181106127245750503360448501525082820360031901606484015282916126c991611896565b0381837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af180156127195761270a575b509061196a565b612713906113c2565b38612703565b6040513d84823e3d90fd5b825180516001600160a01b0316865260209081015181870152899750889650604090950194909201916001016126a2565b825180516001600160a01b03168652602090810151818701528b99508a985060409095019490920191600101612669565b8580fd5b6040602085890301126127ca579060406020819382516127a98161138c565b6127b2886128d7565b815282880151838201528152019401939091506125a9565b8980fd5b60406020858b0301126123bb576040516127e78161138c565b84516001600160a01b03811681036128145781526020858101518183015290825260409094019301612505565b8d80fd5b8a80fd5b8780fd5b60405162461bcd60e51b81526020600482015260156024820152741d5b9adb9bdddb881c185e5b595b9d13595d1a1bd9605a1b6044820152606490fd5b9093506020813d602011612889575b81612879602093836113f0565b810103126122dd5751923861194c565b3d915061286c565b6040513d85823e3d90fd5b60405162461bcd60e51b81526020600482015260136024820152723ab735b737bbb7103232b9ba34b730ba34b7b760691b6044820152606490fd5b51906001600160a01b03821682036104a657565b81601f820112156104a65780519061290282611425565b92604092612912845195866113f0565b808552602091828087019260071b850101938185116104a6578301915b84831061293f5750505050505090565b6080838303126104a657836080918751612958816113d5565b612961866128d7565b815261296e8387016128d7565b8382015261297d8987016128d7565b89820152606061298e8188016128d7565b9082015281520192019161292f565b81601f820112156104a65780516129b38161143c565b926129c160405194856113f0565b818452602082840101116104a6576114a99160208085019101611873565b519065ffffffffffff821682036104a657565b805160005b818110612ae257506001600160a01b039190507f00000000000000000000000000000000000000000000000000000000000000008216803b156104a6576040929192918251938491630d58b1db60e01b8352602483016020806004860152835180925280604486019401926000905b838210612aa15750505050509181600081819503925af1908115612a975750612a8c5750565b612a95906113c2565b565b513d6000823e3d90fd5b8451805182168752838101518216848801528981015182168a8801526060908101518216908701528996506080909501949382019360019190910190612a66565b336001600160a01b03612af58386612b4a565b51511603612b05576001016129f7565b60405162461bcd60e51b815260206004820152601960248201527f66726f6d2061646472657373206973206e6f74206f776e6572000000000000006044820152606490fd5b8051821015612b5e5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b908160209103126104a6575180151581036104a65790565b612bd59160405191612b9d8361138c565b60208084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526001600160a01b03166117af565b8051908115918215612c43575b505015612beb57565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b612c569250602080918301019101612b74565b3880612be2565b91908201809211612c6a57565b634e487b7160e01b600052601160045260246000fd5b15612c8757565b60405162461bcd60e51b8152602060048201526013602482015272696e76616c6964206d696e416d6f756e74546f60681b6044820152606490fd5b15612cc957565b60405162461bcd60e51b8152602060048201526012602482015271696e76616c696420616d6f756e7446726f6d60701b6044820152606490fd5b15612d0a57565b60405162461bcd60e51b815260206004820152601060248201526f3ab735b737bbb710383937bb34b232b960811b6044820152606490fd5b91908203918211612c6a57565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152602094939291908216908581604481855afa908115612eb857600091612e88575b5084811015612e805715612e755760405163095ea7b360e01b81526001600160a01b038416600482015260248101859052908590829060449082906000905af160009181612e46575b50612df65750612a959350612df18282612ec4565b612eff565b9250505015612e025750565b6064906040519062461bcd60e51b82526004820152601960248201527f6661696c656420746f20617070726f7665207370656e646572000000000000006044820152fd5b612e67919250863d8811612e6e575b612e5f81836113f0565b810190612b74565b9038612ddc565b503d612e55565b50612a959350612eff565b505050505050565b908682813d8311612eb1575b612e9e81836113f0565b81010312612eae57505138612d93565b80fd5b503d612e94565b6040513d6000823e3d90fd5b60405163095ea7b360e01b60208201526001600160a01b03909216602483015260006044808401919091528252612a95919061201f826113d5565b91909181158015612fb1575b15612f4d5760405163095ea7b360e01b60208201526001600160a01b03939093166024840152604480840192909252908252612a95919061201f6064836113f0565b60405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b50604051636eb1769f60e11b81523060048201526001600160a01b0384166024820152602081806044810103816001600160a01b0386165afa908115612eb857600091613000575b5015612f0b565b906020823d8211613029575b81613019602093836113f0565b81010312612eae57505138612ff9565b3d915061300c565b604051636eb1769f60e11b8082523060048301526001600160a01b038481166024840152602094919392908316908581604481855afa908115612eb85760009161314a575b5015613143576130b79361308b838795612ec4565b6040519081523060048201526001600160a01b0390921660248301529092839190829081906044820190565b03915afa908115612eb857600091613116575b506130d25750565b6064906040519062461bcd60e51b82526004820152601860248201527f6661696c656420746f207a65726f20616c6c6f77616e636500000000000000006044820152fd5b908282813d831161313c575b61312c81836113f0565b81010312612eae575051386130ca565b503d613122565b5050505050565b908682813d8311613170575b61316081836113f0565b81010312612eae57505138613076565b503d613156565b9060418151146000146131a5576131a1916020820151906060604084015193015160001a906131af565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116132325791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156132255781516001600160a01b0381161561321f579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b6000198114612c6a576001019056fea2646970667358221220f83f04365a7f1b1cf09135eaca365e9c3d210e9d121f5f66947bc2765bb6d65164736f6c63430008140033000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c80632c0aa4441461111f57806363c48dc9146110225780636afdd85014610fdd5780636b9ae9e01461072d578063715018a6146106d05780638da5cb5b146106a7578063bd99d7e11461067b578063ea4ab55d146105ac578063f1469009146104d8578063f2fde38b146104ab5763fc4421761461009557600080fd5b346104a65760c03660031901126104a6576001600160401b036004358181116104a6576100c69036906004016114ac565b906024358181116104a6576100df9036906004016114ac565b916044358281116104a6576100f89036906004016114ac565b6064358381116104a6576101109036906004016114ac565b926084359081116104a6576101299036906004016114ac565b9160a4359460018060a01b0392838716958688036104a65761014961155c565b815181510361044b5783518351036103f75761016361155c565b81519160005b838110610326575050505061017c61155c565b81519160005b838110610293575050505061019561155c565b81519160005b8381106102105785856101ac61155c565b156101bc576101ba906115b4565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b808361021f61028e9385612b4a565b511660026040516001928382527f8f274dd93892c16bd176917df3ac9c96c46485a816e07abb0a330c8a694e85a760208093a28661025d8588612b4a565b5116604051828101918252600460408201526040815261027c816113a7565b5190206000525260406000205561323e565b61019b565b80856102a26103219385612b4a565b5116866102af8387612b4a565b5116604051906001928383527fe551056d99411952ee83a3fb5b4d6633f179839bf8dc9a07e7b1892708e9892360208094a3876102ec8487612b4a565b511690886102fa8589612b4a565b51169160405192828401918252604084015260029260608481830152815261027c816113d5565b610182565b80876103356103f29385612b4a565b5116886103428387612b4a565b5116604051906001928383527fe74f3f5287db251a626ba2d45792295a1dc0d4118437040cf716b5533f56099e60208094a38961037f8487612b4a565b51169060405191818301908152600392836040820152604081526103a2816113a7565b519020600052600291828252836040600020558b6103c08689612b4a565b5116908c6103ce878b612b4a565b51169060405191848301938452604083015260609081830152815261027c816113d5565b610169565b60405162461bcd60e51b815260206004820152602660248201527f64657374696e6174696f6e7320616e6420746f6b656e73206c656e677468206460448201526569666665727360d01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602d60248201527f70726f76696465727320616e642070726f76696465725370656e64657273206c60448201526c656e677468206469666665727360981b6064820152608490fd5b600080fd5b346104a65760203660031901126104a6576004356001600160a01b0381168082036104a6576101ac61155c565b346104a65760403660031901126104a6576004356001600160401b0381116104a6576105089036906004016114ac565b60243561051361155c565b81519060005b82811061052257005b6105a79060026001600160a01b038061053b8489612b4a565b511690604051918683527f8f274dd93892c16bd176917df3ac9c96c46485a816e07abb0a330c8a694e85a760208094a26105758489612b4a565b51166040518281019182526004604082015260408152610594816113a7565b519020600052528260406000205561323e565b610519565b346104a6576105ba36611512565b6105c261155c565b82519160005b8381106105d157005b610676906001600160a01b03806105e88389612b4a565b5116816105f58487612b4a565b5116604051918783527fe551056d99411952ee83a3fb5b4d6633f179839bf8dc9a07e7b1892708e9892360208094a38161062f848a612b4a565b51169161063c8487612b4a565b511691604051928284019182526040840152600292606084818301528152610663816113d5565b519020600052528360406000205561323e565b6105c8565b346104a65760203660031901126104a65760043560005260026020526020604060002054604051908152f35b346104a65760003660031901126104a6576001546040516001600160a01b039091168152602090f35b346104a65760003660031901126104a6576106e961155c565b600180546001600160a01b031981169091556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b60803660031901126104a6576001600160401b03600435116104a6573660236004350112156104a6576001600160401b0360043560040135116104a6573660246004356004013560051b6004350101116104a6576024358060000b81036104a6576001600160401b03606435116104a6573660236064350112156104a6576001600160401b0360643560040135116104a657366024606435600401356064350101116104a6576107db6115fd565b60405130602082015246604082015260a0606082015260c0810160043560040135905260e081018160e06004356004013560051b8201016024600435019260005b600435600401358110610ee757505061084f92508460000b608083015260443560a083015203601f1981018352826113f0565b602081519101207f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c526108a1603c60002061089b3660643560040135602460643501611457565b90613177565b6005811015610ed157159081610e8d575b5015610e3c5760005b60043560040135811061090157507feca3caccccb5df40a89f1a6b525e97e804596a1b95e2e832afa53361823a5f5e602060405192604435845260000b92a26001600055005b60248160051b6004350101359060a2196004353603018212156104a6576004358201602401356001600160a01b03811690036104a6576004358201368190036042190160849091013512156104a6576001600160401b03600435830160848101350160240135116104a6576004358201608481013501602481013536036044909101136104a6576004358201602401356001600160a01b03163003610d2d576004358201608481013501602481013581010360e081126104a65760a0136104a657604051916109cf83611340565b600435810160848101350160448101358452606401356001600160401b03811690036104a6576064608460043583018181013501918201356020860152610a169101611411565b6040840152610a31600435820160848101350160a401611411565b6060840152600435810160848101350160c481013560808501526001600160401b0360e490910135116104a65760043581016084810135016024810135810160440160e482013590910160630112156104a657600435810160848101350160e48101350160440135610aa281611425565b90610ab060405192836113f0565b808252602082019060043584016084810135016024810135810160440160e4820135909101600583901b01606401116104a657600435840160848101350160e481013501606401915b600435850160848101350160e481013501600583901b016064018310610bfb5750506001600160401b03600435840160848101350161010401351190506104a657604060043583016084810135016101048101358101602482013590910103126104a65760405190610b6a8261138c565b6004358301608481013501610104810135016044013560ff811690036104a657600435830160848101350161010481013501604481013583526001600160401b03606490910135116104a657600194610bf593610beb906004350160848101350160248101358101604490810191610104810135016064810135010161148e565b60208401526118bb565b016108bb565b6001600160401b038335116104a65760c0600435860160848101350160e48101358101853501602482013590910103601f1901126104a657604051610c3f81611371565b610c5e600435870160848101350160e481013501853501606401611411565b8152610c80600435870160848181013590910160e48101350186350101611411565b6020820152610ca4600435870160848101350160e48101350185350160a401611411565b6040820152600435860160848101350160e48181013590910185350160c481013560608401529081013560808301526001600160401b0361010490910135116104a6576020918291610d1d6004358901608481013501602481013581016044019060e4810135018835016101048101350160640161148e565b60a0820152815201920191610af9565b6001916004358101604401358015610dc75781610d536064610d9d946004350101611653565b15610da357604051602490610d9081610d82336004358701608481013501808701359060440160208501611660565b03601f1981018352826113f0565b915b6004350101356116c3565b50610bf5565b6024610dc13660043584016084810135018084013590604401611457565b91610d92565b5080610ddc6064610d9d936004350101611653565b15610e1857604051602490610e0b81610d82336004358701608481013501808701359060440160208501611660565b915b600435010135611683565b6024610e363660043584016084810135018084013590604401611457565b91610e0d565b60405162461bcd60e51b8152602060048201526024808201527f657865637574653a20696e76616c6964207369676e6174757265206f7220736960448201526333b732b960e11b6064820152608490fd5b604080516001600160a01b03909216602083019081526004838301529082529150610eb7816113a7565b5190206000526002602052600160406000205414826108b2565b634e487b7160e01b600052602160045260246000fd5b85830360df1901825290925090600435360360a21901843512156104a6576001600160a01b03610f1e853560043501602401611411565b168152833560043501604481013560208301526064013580151581036104a65715156040820152833560043501368190036042190160849091013512156104a6576004358435016084810135016001600160401b036024820135116104a6576024810135360360448201136104a657602060a08382936080606060019701526024810135608083015260248101356044820184840137600083602483013584010152601f6024811992013501160101950193019101908492939161081c565b346104a65760003660031901126104a6576040517f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03168152602090f35b346104a65761103036611512565b61103b92919261155c565b81519160005b83811061104a57005b61111a906001600160a01b03806110618386612b4a565b51168161106e848a612b4a565b5116604051918783527fe74f3f5287db251a626ba2d45792295a1dc0d4118437040cf716b5533f56099e60208094a3816110a88487612b4a565b51169160405192828401908152600393846040820152604081526110cb816113a7565b51902060005260029283835287604060002055816110e98689612b4a565b5116916110f6868c612b4a565b511690604051918483019384526040830152606090818301528152610663816113d5565b611041565b366003190160e081126104a65760a0136104a65761113d6080611340565b6004356080526024356001600160401b03811681036104a65760a0526001600160a01b0360443581811681036104a65760c05260643590811681036104a65760e052608435610100526001600160401b0360a435116104a65736602360a4350112156104a6576111b260a43560040135611425565b6111bf60405191826113f0565b60a4356004013581526020810136602460a4356004013560051b60a4350101116104a657602460a43501905b602460a4356004013560051b60a435010182106112815760c435836001600160401b0382116104a657604060031983360301126104a6576040519061122f8261138c565b826004013560ff811681036104a657825260248301356001600160401b0381116104a65761127a936004611266923692010161148e565b60208301526112736115fd565b60806118bb565b6001600055005b81356001600160401b0381116104a65760c060a4358201360360231901126104a657604051916112b083611371565b6112c060248360a4350101611411565b83526112d260448360a4350101611411565b60208401526112e760648360a4350101611411565b604084015260a4803583016084810135606086015290810135608085015260c40135926001600160401b0384116104a6576113306020949360248695369260a43501010161148e565b60a08201528152019101906111eb565b60a081019081106001600160401b0382111761135b57604052565b634e487b7160e01b600052604160045260246000fd5b60c081019081106001600160401b0382111761135b57604052565b604081019081106001600160401b0382111761135b57604052565b606081019081106001600160401b0382111761135b57604052565b6001600160401b03811161135b57604052565b608081019081106001600160401b0382111761135b57604052565b90601f801991011681019081106001600160401b0382111761135b57604052565b35906001600160a01b03821682036104a657565b6001600160401b03811161135b5760051b60200190565b6001600160401b03811161135b57601f01601f191660200190565b9291926114638261143c565b9161147160405193846113f0565b8294818452818301116104a6578281602093846000960137010152565b9080601f830112156104a6578160206114a993359101611457565b90565b81601f820112156104a6578035916114c383611425565b926114d160405194856113f0565b808452602092838086019260051b8201019283116104a6578301905b8282106114fb575050505090565b83809161150784611411565b8152019101906114ed565b9060606003198301126104a6576001600160401b036004358181116104a6578361153e916004016114ac565b926024359182116104a657611555916004016114ac565b9060443590565b6001546001600160a01b0316330361157057565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600180546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60026000541461160e576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b3580151581036104a65790565b826014949392823701906bffffffffffffffffffffffff199060601b1681520190565b6114a991604051916116948361138c565b601e83527f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000060208401526117af565b604051916116d0836113a7565b602983527f416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c6020840152681d594819985a5b195960ba1b604084015283471061175b576000816114a9956020839451920190855af13d15611753573d916117368361143c565b9261174460405194856113f0565b83523d6000602085013e6117d6565b6060916117d6565b60405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608490fd5b6000806114a9949360208151910182855af13d156117d2573d916117368361143c565b6060915b9192901561183857508151156117ea575090565b3b156117f35790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561184b5750805190602001fd5b60405162461bcd60e51b81526020600482015290819061186f906024830190611896565b0390fd5b60005b8381106118865750506000910152565b8181015183820152602001611876565b906020916118af81518092818552858086019101611873565b601f01601f1916010190565b919091606081015191600060018060a01b0360408401511694604051602081019087825260018060a01b03871660408201526002606082015260608152611901816113d5565b51902082526002602052600160408320540361289c576040516370a0823160e01b815260048101879052926020846024816001600160a01b038a165afa93841561289157839461285d575b50805160ff16600181036120345750508051825b818110611f965750505b80518291825b828110611afe5750505080611ab1575b5060808301516040516370a0823160e01b815260048101879052909290916020836024816001600160a01b038a165afa908115611aa55790611a71575b6119c79250612d42565b908110611a22578151602092830151604080516001600160a01b03969096168652938501929092526001600160401b039091169290917f492a436a3bf1e520560253818ad2141475da45f6984e5a5f791fcb29c186782391a4565b60405162461bcd60e51b815260206004820152602160248201527f696e76616c696420616d6f756e74207472616e73666572656420746f206465736044820152601d60fa1b6064820152608490fd5b506020823d602011611a9d575b81611a8b602093836113f0565b810103126104a6576119c791516119bd565b3d9150611a7e565b604051903d90823e3d90fd5b60405163a9059cbb60e01b60208201526001600160a01b03871660248201526044810191909152611af890611ae98160648101610d82565b6001600160a01b038616612b8c565b38611980565b611b088183612b4a565b5160408101516001600160a01b03908116908a168103611b4a575090611b44606083611b3b600160808197015111612c80565b01511515612cc2565b01611970565b919490918681611dab57505060808201519189602460608301519260018060a01b038151169060405160208101908382526003604082015260408152611b8f816113a7565b5190208b526002602052611ba9600160408d205414612d03565b611bb560018811612c80565b611bc0851515612cc2565b6040516370a0823160e01b81523060048201524794909360209185919082906001600160a01b03165afa928315611da05790859392918c93611d65575b5092611c109160a06024950151906116c3565b5060208d604051938480926370a0823160e01b825230600483015260018060a01b03165afa8015611d5a578a90611d26575b611c4c9250612d42565b938410611cce57611c5e904790612d42565b03611c7557600191611c6f91612c5d565b93611b44565b60405162461bcd60e51b815260206004820152602b60248201527f696e76616c696420616d6f756e74207472616e7366657272656420746f20737760448201526a30b810383937bb34b232b960a91b6064820152608490fd5b60405162461bcd60e51b815260206004820152602a60248201527f696e76616c696420616d6f756e74206f6620746f6b656e2066726f6d207377616044820152693810383937bb34b232b960b11b6064820152608490fd5b506020823d602011611d52575b81611d40602093836113f0565b810103126104a657611c4c9151611c42565b3d9150611d33565b6040513d8c823e3d90fd5b935091506020833d602011611d98575b81611d82602093836113f0565b810103126104a657915184929091611c10611bfd565b3d9150611d75565b6040513d8d823e3d90fd5b918a602460808694960151936020606082015193611e3160018060a01b0384511695611e1360016040818060a01b0387890151169c8d8251898101918d8352848201526003606082015260608152611e02816113d5565b519020815260028852205414612d03565b611e1f60018a11612c80565b611e2a811515612cc2565b898b612d4f565b6040516370a0823160e01b815230600482015293849182906001600160a01b03165afa918215611da0578b92611f61575b5060249260a0611e7492015190611683565b5060208d604051938480926370a0823160e01b825230600483015260018060a01b03165afa8015611d5a578a90611f2d575b611eb09250612d42565b918210611ecb57611ec6611c6f93600195613031565b612c5d565b60405162461bcd60e51b815260206004820152603460248201527f726563656976656420696e76616c69642064657374546f6b656e20616d6f756e6044820152733a10333937b69039bbb0b810383937bb34b232b960611b6064820152608490fd5b506020823d602011611f59575b81611f47602093836113f0565b810103126104a657611eb09151611ea6565b3d9150611f3a565b9091506020813d602011611f8e575b81611f7d602093836113f0565b810103126104a65751906024611e62565b3d9150611f70565b80611fa360019285612b4a565b51828060a01b036040820151169081611fbf575b505001611960565b61202491848060a01b0360608b015116811460001461202b576060858060a01b0360408c015116925b0151604051926323b872dd60e01b6020850152336024850152868060a01b0316604484015260649081840152825261201f82611340565b612b8c565b3880611fb7565b60603092611fe8565b600281036123c757506020015180518101906020818303126123c3576020810151916001600160401b038311612347576060838301820312612347576040519261207d846113a7565b602081840101516001600160401b03811161234b576060818386010184031261234b57604051906120ad826113a7565b6020818487010101516001600160401b0381116123bf5760208501603f8284878a0101010112156123bf576020818386890101010151906120ed82611425565b916120fb60405193846113f0565b80835260208301916020880160408a83888b8760071b930101010101116123bb5760408186898c01010101925b60408a83888b8760071b930101010101841061234f575050505090606091835261215860408286890101016128d7565b602084015283860101015160408201528452604081840101516001600160401b03811161234b576121939060208085019184870101016128eb565b602085015260608184010151916001600160401b03831161234b5791602091826121c29594019301010161299d565b6040820181905281517f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03163b1561234757846040518093632a2d80d160e01b82523360048301526060602483015260c4820193805194606060648501528551809152602060e48501960190855b8181106122ec5750505060208101516001600160a01b031660848401526040015160a483015281840360031901604483015291929091829161227891611896565b0381837f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03165af180156122e1579084916122c9575b505060206122c49101516129f2565b61196a565b6122d2906113c2565b6122dd5782386122b5565b8280fd5b6040513d86823e3d90fd5b825180516001600160a01b039081168a52602082810151909116818b015260408083015165ffffffffffff908116918c019190915260609283015116918a01919091526080909801978c975089965090920191600101612237565b8480fd5b8680fd5b60806020858b0301126123b7579060806020604093845161236f816113d5565b612378886128d7565b81526123858389016128d7565b838201526123948689016129df565b868201526123a4606089016129df565b6060820152815201940193909150612128565b8c80fd5b8b80fd5b8880fd5b8380fd5b60038103612410575060200151805181016020828203126123c3576020820151906001600160401b0382116123475791602061240b92816122c495019201016128eb565b6129f2565b919291600403612820576020015180518101906020818303126122dd576020810151916001600160401b0383116123c35760608383018203126123c3576040519261245a846113a7565b602081840101516001600160401b0381116127865760608183860101840312612786576040519061248a826113a7565b6020818487010101516001600160401b03811161281c5760208501603f8284878a01010101121561281c576020818386890101010151906124ca82611425565b916124d860405193846113f0565b80835260208301916020880160408a83888b8760061b930101010101116128185760408186898c01010101925b60408a83888b8760061b93010101010184106127ce57505050908352506040838601918201818101516020850152606001518184015291865201516001600160401b0381116127865760208301603f8284870101011215612786576020818386010101519061257382611425565b9161258160405193846113f0565b80835260208301916020860160408360061b83888b01010101116123bf576040818689010101925b60408360061b83888b01010101841061278a5750505050602085015260608184010151916001600160401b0383116127865791602091826125ef9594019301010161299d565b604082018190528151602090920151907f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03163b156123c35791839160405193849263edd9444b60e01b84526080600485015260e484019080519160606084870152825180915260206101048701930190875b81811061275557505050806020604092015160a4870152015160c485015260031984820301602485015260208084519283815201930190855b8181106127245750503360448501525082820360031901606484015282916126c991611896565b0381837f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03165af180156127195761270a575b509061196a565b612713906113c2565b38612703565b6040513d84823e3d90fd5b825180516001600160a01b0316865260209081015181870152899750889650604090950194909201916001016126a2565b825180516001600160a01b03168652602090810151818701528b99508a985060409095019490920191600101612669565b8580fd5b6040602085890301126127ca579060406020819382516127a98161138c565b6127b2886128d7565b815282880151838201528152019401939091506125a9565b8980fd5b60406020858b0301126123bb576040516127e78161138c565b84516001600160a01b03811681036128145781526020858101518183015290825260409094019301612505565b8d80fd5b8a80fd5b8780fd5b60405162461bcd60e51b81526020600482015260156024820152741d5b9adb9bdddb881c185e5b595b9d13595d1a1bd9605a1b6044820152606490fd5b9093506020813d602011612889575b81612879602093836113f0565b810103126122dd5751923861194c565b3d915061286c565b6040513d85823e3d90fd5b60405162461bcd60e51b81526020600482015260136024820152723ab735b737bbb7103232b9ba34b730ba34b7b760691b6044820152606490fd5b51906001600160a01b03821682036104a657565b81601f820112156104a65780519061290282611425565b92604092612912845195866113f0565b808552602091828087019260071b850101938185116104a6578301915b84831061293f5750505050505090565b6080838303126104a657836080918751612958816113d5565b612961866128d7565b815261296e8387016128d7565b8382015261297d8987016128d7565b89820152606061298e8188016128d7565b9082015281520192019161292f565b81601f820112156104a65780516129b38161143c565b926129c160405194856113f0565b818452602082840101116104a6576114a99160208085019101611873565b519065ffffffffffff821682036104a657565b805160005b818110612ae257506001600160a01b039190507f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba38216803b156104a6576040929192918251938491630d58b1db60e01b8352602483016020806004860152835180925280604486019401926000905b838210612aa15750505050509181600081819503925af1908115612a975750612a8c5750565b612a95906113c2565b565b513d6000823e3d90fd5b8451805182168752838101518216848801528981015182168a8801526060908101518216908701528996506080909501949382019360019190910190612a66565b336001600160a01b03612af58386612b4a565b51511603612b05576001016129f7565b60405162461bcd60e51b815260206004820152601960248201527f66726f6d2061646472657373206973206e6f74206f776e6572000000000000006044820152606490fd5b8051821015612b5e5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b908160209103126104a6575180151581036104a65790565b612bd59160405191612b9d8361138c565b60208084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526001600160a01b03166117af565b8051908115918215612c43575b505015612beb57565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b612c569250602080918301019101612b74565b3880612be2565b91908201809211612c6a57565b634e487b7160e01b600052601160045260246000fd5b15612c8757565b60405162461bcd60e51b8152602060048201526013602482015272696e76616c6964206d696e416d6f756e74546f60681b6044820152606490fd5b15612cc957565b60405162461bcd60e51b8152602060048201526012602482015271696e76616c696420616d6f756e7446726f6d60701b6044820152606490fd5b15612d0a57565b60405162461bcd60e51b815260206004820152601060248201526f3ab735b737bbb710383937bb34b232b960811b6044820152606490fd5b91908203918211612c6a57565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152602094939291908216908581604481855afa908115612eb857600091612e88575b5084811015612e805715612e755760405163095ea7b360e01b81526001600160a01b038416600482015260248101859052908590829060449082906000905af160009181612e46575b50612df65750612a959350612df18282612ec4565b612eff565b9250505015612e025750565b6064906040519062461bcd60e51b82526004820152601960248201527f6661696c656420746f20617070726f7665207370656e646572000000000000006044820152fd5b612e67919250863d8811612e6e575b612e5f81836113f0565b810190612b74565b9038612ddc565b503d612e55565b50612a959350612eff565b505050505050565b908682813d8311612eb1575b612e9e81836113f0565b81010312612eae57505138612d93565b80fd5b503d612e94565b6040513d6000823e3d90fd5b60405163095ea7b360e01b60208201526001600160a01b03909216602483015260006044808401919091528252612a95919061201f826113d5565b91909181158015612fb1575b15612f4d5760405163095ea7b360e01b60208201526001600160a01b03939093166024840152604480840192909252908252612a95919061201f6064836113f0565b60405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b50604051636eb1769f60e11b81523060048201526001600160a01b0384166024820152602081806044810103816001600160a01b0386165afa908115612eb857600091613000575b5015612f0b565b906020823d8211613029575b81613019602093836113f0565b81010312612eae57505138612ff9565b3d915061300c565b604051636eb1769f60e11b8082523060048301526001600160a01b038481166024840152602094919392908316908581604481855afa908115612eb85760009161314a575b5015613143576130b79361308b838795612ec4565b6040519081523060048201526001600160a01b0390921660248301529092839190829081906044820190565b03915afa908115612eb857600091613116575b506130d25750565b6064906040519062461bcd60e51b82526004820152601860248201527f6661696c656420746f207a65726f20616c6c6f77616e636500000000000000006044820152fd5b908282813d831161313c575b61312c81836113f0565b81010312612eae575051386130ca565b503d613122565b5050505050565b908682813d8311613170575b61316081836113f0565b81010312612eae57505138613076565b503d613156565b9060418151146000146131a5576131a1916020820151906060604084015193015160001a906131af565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116132325791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156132255781516001600160a01b0381161561321f579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b6000198114612c6a576001019056fea2646970667358221220f83f04365a7f1b1cf09135eaca365e9c3d210e9d121f5f66947bc2765bb6d65164736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
-----Decoded View---------------
Arg [0] : _permit2Address (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.