From f59a4cf545e492cae9085fc8ec871656b55c99a3 Mon Sep 17 00:00:00 2001 From: Wayne Cheng <677680+welps@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:07:34 -0500 Subject: [PATCH] chore: update swaps sdk & rip out WRAPPED_ASSET dependency --- package.json | 6 +-- patches/@rainbow-me+swaps+0.29.0.patch | 34 -------------- src/core/raps/actions/swap.ts | 20 +++----- src/core/utils/swaps.ts | 47 +------------------ src/entries/popup/hooks/swap/useSwapQuote.ts | 17 +------ .../swap/SwapReviewSheet/SwapReviewSheet.tsx | 21 ++++----- yarn.lock | 8 ++-- 7 files changed, 24 insertions(+), 129 deletions(-) delete mode 100644 patches/@rainbow-me+swaps+0.29.0.patch diff --git a/package.json b/package.json index 29ff861891..62117e8b3e 100644 --- a/package.json +++ b/package.json @@ -92,12 +92,12 @@ "@ethersproject/hdnode": "5.7.0", "@ethersproject/keccak256": "5.7.0", "@ethersproject/providers": "5.7.2", + "@ethersproject/sha2": "5.7.0", "@ethersproject/strings": "5.7.0", "@ethersproject/transactions": "5.7.0", "@ethersproject/units": "5.7.0", "@ethersproject/wallet": "5.7.0", "@ledgerhq/hw-app-eth": "6.38.1", - "@ethersproject/sha2": "5.7.0", "@ledgerhq/hw-transport-webhid": "6.29.3", "@metamask/browser-passworder": "4.1.0", "@metamask/eth-sig-util": "7.0.1", @@ -109,7 +109,7 @@ "@radix-ui/react-tabs": "1.0.4", "@radix-ui/react-tooltip": "1.0.3", "@rainbow-me/provider": "0.1.1", - "@rainbow-me/swaps": "0.29.0", + "@rainbow-me/swaps": "0.30.1", "@rudderstack/analytics-js-service-worker": "3.0.6", "@scure/bip39": "1.2.1", "@sentry/browser": "8.33.0", @@ -348,4 +348,4 @@ "@trezor/connect-web>@trezor/connect>@trezor/utxo-lib>blake-hash": false } } -} \ No newline at end of file +} diff --git a/patches/@rainbow-me+swaps+0.29.0.patch b/patches/@rainbow-me+swaps+0.29.0.patch deleted file mode 100644 index 5496b12604..0000000000 --- a/patches/@rainbow-me+swaps+0.29.0.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/node_modules/@rainbow-me/swaps/dist/swaps.cjs.development.js b/node_modules/@rainbow-me/swaps/dist/swaps.cjs.development.js -index 8bdfe68..31e79f9 100644 ---- a/node_modules/@rainbow-me/swaps/dist/swaps.cjs.development.js -+++ b/node_modules/@rainbow-me/swaps/dist/swaps.cjs.development.js -@@ -1121,7 +1121,7 @@ var RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA = '0xa61550e9ddd2797e16489db09343162be9 - * @deprecated: Should not use this anymore to reduce friction for new network support - */ - --var WRAPPED_ASSET = (_WRAPPED_ASSET = {}, _WRAPPED_ASSET["" + exports.ChainId.mainnet] = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', _WRAPPED_ASSET["" + exports.ChainId.optimism] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.polygon] = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', _WRAPPED_ASSET["" + exports.ChainId.arbitrum] = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', _WRAPPED_ASSET["" + exports.ChainId.bsc] = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', _WRAPPED_ASSET["" + exports.ChainId.zora] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.base] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.avalanche] = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', _WRAPPED_ASSET["" + exports.ChainId.blast] = '0x4300000000000000000000000000000000000004', _WRAPPED_ASSET["" + exports.ChainId.degen] = '0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387', _WRAPPED_ASSET["" + exports.ChainId.apechain] = '0x8643a49363e80c7a15790703b915d1b0b6b71d56', _WRAPPED_ASSET); -+var WRAPPED_ASSET = (_WRAPPED_ASSET = {}, _WRAPPED_ASSET["" + exports.ChainId.mainnet] = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', _WRAPPED_ASSET["" + exports.ChainId.optimism] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.polygon] = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', _WRAPPED_ASSET["" + exports.ChainId.arbitrum] = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', _WRAPPED_ASSET["" + exports.ChainId.bsc] = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', _WRAPPED_ASSET["" + exports.ChainId.zora] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.base] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + exports.ChainId.avalanche] = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', _WRAPPED_ASSET["" + exports.ChainId.blast] = '0x4300000000000000000000000000000000000004', _WRAPPED_ASSET["" + exports.ChainId.degen] = '0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387', _WRAPPED_ASSET["" + exports.ChainId.apechain] = '0x48b62137edfa95a428d35c09e44256a739f6b557', _WRAPPED_ASSET); - var DAI = (_DAI = {}, _DAI["" + exports.ChainId.mainnet] = '0x6b175474e89094c44da98b954eedeac495271d0f', _DAI); - var USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; - var TORN_ADDRESS = '0x77777feddddffc19ff86db637967013e6c6a116c'; -diff --git a/node_modules/@rainbow-me/swaps/dist/swaps.cjs.production.min.js b/node_modules/@rainbow-me/swaps/dist/swaps.cjs.production.min.js -index 5b3a12f..ea1181d 100644 ---- a/node_modules/@rainbow-me/swaps/dist/swaps.cjs.production.min.js -+++ b/node_modules/@rainbow-me/swaps/dist/swaps.cjs.production.min.js -@@ -1,2 +1,2 @@ --"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ethersproject/contracts"),t=require("@ethersproject/bignumber"),n=require("@ethereumjs/util"),r=require("@ethersproject/bytes"),a=require("@metamask/eth-sig-util"),i=require("@ethersproject/keccak256"),s=require("@ethersproject/strings");function o(e,t,n,r,a,i,s){try{var o=e[i](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,a)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function s(e){o(i,r,a,s,u,"next",e)}function u(e){o(i,r,a,s,u,"throw",e)}s(void 0)}))}}function p(){return(p=Object.assign||function(e){for(var t=1;t=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports),h=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}];(d=exports.ChainId||(exports.ChainId={}))[d.mainnet=1]="mainnet",d[d.ropsten=3]="ropsten",d[d.kovan=42]="kovan",d[d.goerli=5]="goerli",d[d.rinkeby=4]="rinkeby",d[d.optimism=10]="optimism",d[d.bsc=56]="bsc",d[d.polygon=137]="polygon",d[d.arbitrum=42161]="arbitrum",d[d.zora=7777777]="zora",d[d.base=8453]="base",d[d.avalanche=43114]="avalanche",d[d.blast=81457]="blast",d[d.degen=666666666]="degen",d[d.apechain=33139]="apechain",(l=exports.Source||(exports.Source={})).Aggregator0x="0x",l.Aggregator1inch="1inch",l.AggregatorRainbow="rainbow",l.Aggregotor1inch="1inch",l.CrosschainAggregatorSocket="socket",l.CrosschainAggregatorRelay="relay",(y=exports.SwapType||(exports.SwapType={})).normal="normal",y.crossChain="cross-chain",y.wrap="wrap",y.unwrap="unwrap";var T="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",v=((c={})[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",c[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",c[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",c[""+exports.ChainId.bsc]="0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",c[""+exports.ChainId.zora]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.base]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.avalanche]="0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",c[""+exports.ChainId.blast]="0x4300000000000000000000000000000000000004",c[""+exports.ChainId.degen]="0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387",c[""+exports.ChainId.apechain]="0x8643a49363e80c7a15790703b915d1b0b6b71d56",c),w=((m={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",m),g="0x77777feddddffc19ff86db637967013e6c6a116c",x="0x0d438f3b5175bebc262bf23753c1e53d03432bde",S="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",A=t.BigNumber.from("2").pow("256").sub("1").toString(),E=function(){var t=u(b.mark((function t(n,r,a,i){var s;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(v[a],JSON.stringify(h),r),t.abrupt("return",s.deposit(p({},i,{value:n})));case 4:case"end":return t.stop()}}),t)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),C=function(){var t=u(b.mark((function t(n,r,a,i){var s;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(v[a],JSON.stringify(h),r),t.abrupt("return",s.withdraw(n,i));case 4:case"end":return t.stop()}}),t)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),k=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"EthWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOwner",type:"address"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"}],name:"OwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"}],name:"SwapTargetAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"}],name:"SwapTargetRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!0,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"TokenWithdrawn",type:"event"},{inputs:[{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"feeAmount",type:"uint256"}],name:"fillQuoteEthToToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feePercentageBasisPoints",type:"uint256"}],name:"fillQuoteTokenToEth",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feePercentageBasisPoints",type:"uint256"},{components:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"bool",name:"isDaiStylePermit",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],internalType:"struct PermitHelper.Permit",name:"permitData",type:"tuple"}],name:"fillQuoteTokenToEthWithPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feeAmount",type:"uint256"}],name:"fillQuoteTokenToToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{components:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"bool",name:"isDaiStylePermit",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],internalType:"struct PermitHelper.Permit",name:"permitData",type:"tuple"}],name:"fillQuoteTokenToTokenWithPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapTargets",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"target",type:"address"},{internalType:"bool",name:"add",type:"bool"}],name:"updateSwapTargets",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"withdrawEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],I=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],P=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"_nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],_=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],M=function(){var e=u(b.mark((function e(t,n,r,i){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","0x"+a.TypedDataUtils.hashStruct("EIP712Domain",{chainId:r,name:t,verifyingContract:i,version:n},{EIP712Domain:_},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),R=function(){var e=u(b.mark((function e(t,n,r,a){var i,s;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.version();case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),i="1",e.prev=10,e.next=13,t.DOMAIN_SEPARATOR();case 13:return s=e.sent,e.next=16,M(n,i,r,a);case 16:if(s!==e.sent){e.next=19;break}return e.abrupt("return",i);case 19:e.next=26;break;case 21:if(e.prev=21,e.t1=e.catch(10),1!==r||-1===[g,x,S].map((function(e){return e.toLowerCase()})).indexOf(t.address.toLowerCase())){e.next=25;break}return e.abrupt("return","1");case 25:case 26:return e.abrupt("return",null);case 27:case"end":return e.stop()}}),e,null,[[0,7],[10,21]])})));return function(t,n,r,a){return e.apply(this,arguments)}}(),N=function(){var e=u(b.mark((function e(t,n){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.nonces(n);case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),e.prev=9,e.next=12,t._nonces(n);case 12:return e.abrupt("return",e.sent);case 16:return e.prev=16,e.t1=e.catch(9),e.abrupt("return",0);case 19:case"end":return e.stop()}}),e,null,[[0,7],[9,16]])})));return function(t,n){return e.apply(this,arguments)}}(),O=[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],L=[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],D=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function V(e,t,n,r,a,i,s){return U.apply(this,arguments)}function U(){return(U=u(b.mark((function i(s,o,u,p,d,l,y){var c,m,f,h,T,v,g,x,S,A,E,C,k;return b.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return m=o.toLowerCase()===(null==(c=w[y])?void 0:c.toLowerCase()),f=new e.Contract(o,m?I:P,s),i.next=4,f.name();case 4:return h=i.sent,i.next=7,Promise.all([N(f,u),R(f,h,y,f.address)]);case 7:return v=(T=i.sent)[0],g=T[1],x={nonce:Number(v.toString()),spender:p},m?(x.holder=u,x.allowed=!0,x.expiry=Number(l.toString())):(x.value=t.BigNumber.from(d).toHexString(),x.deadline=Number(l.toString()),x.owner=u),S={chainId:y,name:h,verifyingContract:f.address},null!==g&&(S.version=g),A={domain:S,message:x,primaryType:"Permit",types:{EIP712Domain:null!==g?_:O,Permit:m?D:L}},E=Buffer.from(n.addHexPrefix(s.privateKey).substring(2),"hex"),C=a.signTypedData({data:A,privateKey:E,version:a.SignTypedDataVersion.V4}),k=r.splitSignature(C),i.abrupt("return",{deadline:l,isDaiStylePermit:m,nonce:v,r:k.r,s:k.s,v:k.v,value:x.value||t.BigNumber.from("0").toHexString()});case 20:case"end":return i.stop()}}),i)})))).apply(this,arguments)}function B(e){return i.keccak256(s.toUtf8Bytes(e)).substring(2,10)}function W(e){if(void 0===e||""===e||"0x0000000000000000000000000000000000000000"===e)throw new Error("provided address is not defined (API issue)")}exports.sdkConfig={apiBaseUrl:"https://swap.p.rainbow.me"};var H=function(e){return e===exports.ChainId.zora?"0xa61550e9ddd2797e16489db09343162be98d9483":"0x00000000009726632680fb29d3f7a9734e3010e2"},F=function(e){var t=e.sellTokenAddress,n=e.buyAmount,r=e.sellAmount,a=e.fromAddress,i=e.source,s=e.feePercentageBasisPoints,o=e.slippage,u=e.currency,d=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),currency:u,enableZoraSwaps:String(!0),fromAddress:a,sellToken:t,slippage:String(o)},i?{source:i}:{},r?{sellAmount:String(r)}:{buyAmount:String(n)},void 0!==s?{feePercentageBasisPoints:String(s)}:{}));return exports.sdkConfig.apiBaseUrl+"/v1/quote?"+d.toString()},Q=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.sellAmount,a=e.fromAddress,i=e.slippage,s=e.refuel,o=e.feePercentageBasisPoints,u=e.currency,d=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),currency:u,fromAddress:a,refuel:String(s),sellAmount:String(r),sellToken:n,slippage:String(i),toChainId:String(t)},void 0!==o?{feePercentageBasisPoints:String(o)}:{}));return exports.sdkConfig.apiBaseUrl+"/v1/quote?bridgeVersion=4&"+d.toString()},j=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.sellAmount,a=e.fromAddress,i=e.slippage,s=e.refuel,o=e.currency,u=new URLSearchParams({buyToken:e.buyTokenAddress,chainId:String(e.chainId),claim:String(!0),currency:o,feePercentageBasisPoints:"0",fromAddress:a,refuel:String(s),sellAmount:String(r),sellToken:n,slippage:String(i),source:exports.Source.CrosschainAggregatorRelay.toString(),toChainId:String(t)});return exports.sdkConfig.apiBaseUrl+"/v1/quote?bridgeVersion=4&"+u.toString()},X=function(){var e=u(b.mark((function e(n){var r,a,i,s,o,u;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.chainId,a=n.toChainId,i=exports.sdkConfig.apiBaseUrl+"/v1/chains",e.next=4,fetch(i);case 4:return s=e.sent,e.next=7,s.json();case 7:if(o=e.sent.result.find((function(e){return e.chainId===r}))){e.next=11;break}return e.abrupt("return",null);case 11:if(u=o.limits.find((function(e){return e.chainId===a}))){e.next=14;break}return e.abrupt("return",null);case 14:return e.abrupt("return",t.BigNumber.from(u.minAmount).mul(2).toString());case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),G=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c,m,f;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.source,a=void 0===(r=t.chainId)?exports.ChainId.mainnet:r,i=t.fromAddress,s=t.sellTokenAddress,o=t.buyTokenAddress,u=t.sellAmount,p=t.buyAmount,d=t.slippage,l=t.feePercentageBasisPoints,y=t.currency,!isNaN(Number(u))||!isNaN(Number(p))){e.next=3;break}return e.abrupt("return",null);case 3:return c=F({buyAmount:p,buyTokenAddress:o,chainId:a,currency:y,feePercentageBasisPoints:l,fromAddress:i,sellAmount:u,sellTokenAddress:s,slippage:d,source:n}),e.next=6,fetch(c);case 6:return m=e.sent,e.next=9,m.json();case 9:if(!(f=e.sent).error){e.next=12;break}return e.abrupt("return",f);case 12:return e.abrupt("return",f);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c,m;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,a=t.toChainId,i=t.currency,s=t.fromAddress,o=t.sellTokenAddress,u=t.buyTokenAddress,d=t.slippage,y=void 0!==(l=t.refuel)&&l,c=t.feePercentageBasisPoints,(p=t.sellAmount)&&a){e.next=3;break}return e.abrupt("return",null);case 3:return m=Q({buyTokenAddress:u,chainId:r,currency:i,feePercentageBasisPoints:c,fromAddress:s,refuel:y,sellAmount:p,sellTokenAddress:o,slippage:d,toChainId:a}),e.abrupt("return",Y(m));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.optimism:n,a=t.toChainId,i=t.currency,s=t.fromAddress,o=t.sellTokenAddress,u=t.buyTokenAddress,d=t.slippage,y=void 0!==(l=t.refuel)&&l,(p=t.sellAmount)&&a){e.next=3;break}return e.abrupt("return",null);case 3:return c=j({buyTokenAddress:u,chainId:r,currency:i,fromAddress:s,refuel:y,sellAmount:p,sellTokenAddress:o,slippage:d,toChainId:a}),e.abrupt("return",Y(c));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Y=function(){var e=u(b.mark((function e(t){var n,r;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:return n=e.sent,e.next=5,n.json();case 5:if(!(r=e.sent).error){e.next=8;break}return e.abrupt("return",r);case 8:e.prev=8,W(null==r?void 0:r.to),e.next=15;break;case 12:return e.prev=12,e.t0=e.catch(8),e.abrupt("return",{error:!0,message:e.t0 instanceof Error?e.t0.message:"unexpected error happened while checking crosschain quote's address: "+(null==r?void 0:r.to)});case 15:return e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,null,[[8,12]])})));return function(t){return e.apply(this,arguments)}}(),J=function(){var e=u(b.mark((function e(t){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.provider.getBlock("latest");case 2:return e.abrupt("return",e.sent.timestamp+3600);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),z=function(){var t=u(b.mark((function t(n,r,a,i,s,o){var u,d,l,y,c,m,f,h,v,w,g,x,S,E,C;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=new e.Contract(H(s),k,a),l=n.sellTokenAddress,y=n.buyTokenAddress,c=n.to,m=n.data,f=n.fee,h=n.value,v=n.sellAmount,w=n.feePercentageBasisPoints,g=T.toLowerCase(),(null==l?void 0:l.toLowerCase())!==g){t.next=9;break}return t.next=6,u.populateTransaction.fillQuoteEthToToken(y,c,m,f,p({},r,{value:h}));case 6:d=t.sent,t.next=42;break;case 9:if((null==y?void 0:y.toLowerCase())!==g){t.next=27;break}if(!i){t.next=22;break}return t.next=13,J(a);case 13:return x=t.sent,t.next=16,V(a,l,n.from,u.address,A,x,s);case 16:return S=t.sent,t.next=19,u.populateTransaction.fillQuoteTokenToEthWithPermit(l,c,m,v,w,S,p({},r,{value:h}));case 19:d=t.sent,t.next=25;break;case 22:return t.next=24,u.populateTransaction.fillQuoteTokenToEth(l,c,m,v,w,p({},r,{value:h}));case 24:d=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,J(a);case 30:return E=t.sent,t.next=33,V(a,l,n.from,u.address,A,E,s);case 33:return C=t.sent,t.next=36,u.populateTransaction.fillQuoteTokenToTokenWithPermit(l,y,c,m,v,f,C,p({},r,{value:h}));case 36:d=t.sent,t.next=42;break;case 39:return t.next=41,u.populateTransaction.fillQuoteTokenToToken(l,y,c,m,v,f,p({},r,{value:h}));case 41:d=t.sent;case 42:return o&&(d.data=""+d.data+B(o)),t.next=45,a.sendTransaction(p({data:d.data,from:d.from,to:d.to},p({},r,{value:h})));case 45:return t.abrupt("return",t.sent);case 47:case"end":return t.stop()}}),t)})));return function(e,n,r,a,i,s){return t.apply(this,arguments)}}(),Z=function(){var e=u(b.mark((function e(t,n,r,a){var i,s,o,u;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.data,s=t.from,o=t.value,W(null==t?void 0:t.to),u=i,a&&(u=""+u+B(a)),e.next=6,r.sendTransaction(p({data:u,from:s,to:t.to},p({},n,{value:o})));case 6:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),$=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.buyAmount,a=e.sellAmount,i=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),sellToken:n,toChainId:String(t)},a?{sellAmount:String(a)}:{buyAmount:String(r)}));return exports.sdkConfig.apiBaseUrl+"/v1/slippage?"+i.toString()},ee=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,a=t.toChainId,i=t.sellTokenAddress,s=t.buyTokenAddress,o=t.sellAmount,u=t.buyAmount,!isNaN(Number(o))||!isNaN(Number(u))){e.next=3;break}return e.abrupt("return",null);case 3:return p=$({buyAmount:u,buyTokenAddress:s,chainId:r,sellAmount:o,sellTokenAddress:i,toChainId:a}),e.next=6,fetch(p);case 6:return d=e.sent,e.next=9,d.json();case 9:if(!(l=e.sent).error){e.next=12;break}return e.abrupt("return",l);case 12:return e.abrupt("return",null==l?void 0:l.data);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.ALLOWS_PERMIT={"0x0d438f3b5175bebc262bf23753c1e53d03432bde":!0,"0x111111111117dc0aa78b770fa6a738034120c302":!0,"0x1b40183efb4dd766f11bda7a7c3ad8982e998421":!0,"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984":!0,"0x31c8eacbffdd875c74b94b077895bd78cf1e64a3":!0,"0x6b175474e89094c44da98b954eedeac495271d0f":!0,"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d":!0,"0x77777feddddffc19ff86db637967013e6c6a116c":!0,"0x888888435fde8e7d4c54cab67f206e4199454c60":!0,"0x888888888889c00c67689029d7856aac1065ec11":!0,"0x88acdd2a6425c3faae4bc9650fd7e27e0bebb7ab":!0,"0x956f47f50a910163d8bf957cf5846d573e7f87ca":!0,"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":!0,"0xba100000625a3754423978a60c9317c58a424e3d":!0,"0xc7283b66eb1eb5fb86327f08e1b5816b0720212b":!0},exports.API_BASE_URL="https://swap.p.rainbow.me",exports.DAI=w,exports.ETH_ADDRESS=T,exports.MAX_INT=A,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA="0xa61550e9ddd2797e16489db09343162be98d9483",exports.TORN_ADDRESS=g,exports.USDC_ADDRESS="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",exports.VSP_ADDRESS=S,exports.WNXM_ADDRESS=x,exports.WRAPPED_ASSET=v,exports.buildRainbowClaimBridgeQuoteUrl=j,exports.buildRainbowCrosschainQuoteUrl=Q,exports.configureSDK=function(e){exports.sdkConfig=p({},exports.sdkConfig,e)},exports.fillCrosschainQuote=Z,exports.fillQuote=z,exports.getClaimBridgeQuote=K,exports.getCrosschainQuote=q,exports.getCrosschainQuoteExecutionDetails=function(e,t,n){var r=e.from,a=e.data,i=e.value;return W(null==e?void 0:e.to),{method:n.estimateGas({data:a,from:r,to:e.to,value:i}),params:p({},t,{value:i})}},exports.getMinRefuelAmount=X,exports.getQuote=G,exports.getQuoteExecutionDetails=function(t,n,r){var a=new e.Contract(H(t.chainId),k,r),i=t.sellTokenAddress,s=t.buyTokenAddress,o=t.to,u=t.data,d=t.fee,l=t.value,y=t.sellAmount,c=t.feePercentageBasisPoints,m=T.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:a.estimateGas.fillQuoteEthToToken,methodArgs:[s,o,u,d],methodName:"fillQuoteEthToToken",params:p({},n,{value:l}),router:a}:(null==s?void 0:s.toLowerCase())===m?{method:a.estimateGas.fillQuoteTokenToEth,methodArgs:[i,o,u,y,c],methodName:"fillQuoteTokenToEth",params:p({},n,{value:l}),router:a}:{method:a.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,o,u,y,d],methodName:"fillQuoteTokenToToken",params:p({},n,{value:l}),router:a}},exports.getRainbowRouterContractAddress=H,exports.getSlippage=ee,exports.getWrappedAssetMethod=function(t,n,r){return void 0===r&&(r=exports.ChainId.mainnet),new e.Contract(v[r],JSON.stringify(h),n).estimateGas[t]},exports.signPermit=V,exports.sources={AAVE:"Aave",AAVE_LIQUIDATOR:"Aave Liquidator",AAVE_V2:"Aave V2",BALANCER:"Balancer",BALANCER_V2:"Balancer V2",BANCOR:"Bancor",BLACKHOLESWAP:"Blackholeswap",CHAI:"Chai",CLIPPER:"Clipper",COFIX:"CoFix",COMPOUND:"Compound",CONVERGENCE_X:"Convergence X",CREAM_LENDING:"Creamswap Lending",CREAMSWAP:"Creamswap",CURVE:"Curve",CURVE_V2:"Curve V2",CURVE_V2_ETH_CRV:"CURVE V2 ETH CRV",CURVE_V2_ETH_CVX:"CURVE V2 ETH CVX",CURVE_V2_EURS_2_ASSET:"Curve V2 EURS",CURVE_V2_EURT_2_ASSET:"CURVE V2 EURT",CURVE_V2_SPELL_2_ASSET:"Curve Spell",CURVE_V2_THRESHOLDNETWORK_2_ASSET:"Curve Threshold",CURVE_V2_XAUT_2_ASSET:"CURVE V2 XAUt",CURVE_V2_YFI_2_ASSET:"Curve Yfi",DEFI_PLAZA:"DeFi Plaza",DEFISWAP:"DeFi Swap",DFX_FINANCE:"Dfx Finance",DODO:"DODO",DODO_V2:"DODO v2",DXSWAP:"Swapr",FIXED_FEE_SWAP:"Fixed Fee Swap",FIXED_FEE_SWAP_V3:"Fixed Rate Swap",IEARN:"yEarn",INDEXED_FINANCE:"Indexed Finance",KYBER:"Kyber",KYBER_DMM:"Kyber DMM",LINKSWAP:"Link Swap",LUASWAP:"Lua Swap",MINISWAP:"Mini Swap",MOONISWAP:"Mooniswap",MSTABLE:"mStable",OASIS:"Oasis",ONE_INCH_LIMIT_ORDER:"1inch Limit Order Protocol",ONE_INCH_LIMIT_ORDER_V2:"1inch Limit Order Protocol V2",ONE_INCH_LP:"1inch LP v1.0",ONE_INCH_LP_1_1:"1inch LP v1.1",ONE_INCH_LP_MIGRATOR:"Mooniswap Migrator",ONE_INCH_LP_MIGRATOR_V1_1:"1inch LP v1.0 Migrator",PMM1:"PMM1",PMM2:"PMM2",PMM3:"PMM3",PMM4:"PMM4",PMMX:"LiqPool X",POWERINDEX:"POWERINDEX",PSM:"PSM",S_FINANCE:"sFinance",SADDLE:"Saddle Finance",SAKESWAP:"Sake Swap",SETH_WRAPPER:"sETH Wrapper",SHELL:"Shell",SHIBASWAP:"Shiba Swap",SMOOTHY_FINANCE:"Smoothy Finance",ST_ETH:"stETH",SUSHI:"Sushiswap",SUSHISWAP_MIGRATOR:"SushiSwap Migrator",SWERVE:"Swerve",SYNAPSE:"Synapse",SYNTHETIX:"Synthetix",SYNTHETIX_WRAPPER:"Synthetix Wrapper",UNIFI:"Unifi",UNISWAP_V1:"Uniswap V1",UNISWAP_V2:"Uniswap V2",UNISWAP_V2_MIGRATOR:"Uniswap Migrator",UNISWAP_V3:"UNISWAP V3",VALUELIQUID:"Value Liquid",WETH:"WETH",WSTETH:"wstETH",XSIGMA:"xSigma",ZRX:"0x",Native:"Native",Uniswap:"Uniswap",UniswapV2:"Uniswap_V2",Eth2Dai:"Eth2Dai",Kyber:"Kyber",Curve:"Curve",LiquidityProvider:"LiquidityProvider",MultiBridge:"MultiBridge",Balancer:"Balancer",BalancerV2:"Balancer_V2",Cream:"CREAM",Bancor:"Bancor",MakerPsm:"MakerPsm",MStable:"mStable",Mooniswap:"Mooniswap",MultiHop:"MultiHop",Shell:"Shell",Swerve:"Swerve",SnowSwap:"SnowSwap",SushiSwap:"SushiSwap",Dodo:"DODO",DodoV2:"DODO_V2",CryptoCom:"CryptoCom",Linkswap:"Linkswap",KyberDmm:"KyberDMM",Smoothy:"Smoothy",Component:"Component",Saddle:"Saddle",XSigma:"xSigma",UniswapV3:"Uniswap_V3",CurveV2:"Curve_V2",Lido:"Lido",ShibaSwap:"ShibaSwap",Clipper:"Clipper",PancakeSwap:"PancakeSwap",PancakeSwapV2:"PancakeSwap_V2",BakerySwap:"BakerySwap",Nerve:"Nerve",Belt:"Belt",Ellipsis:"Ellipsis",ApeSwap:"ApeSwap",CafeSwap:"CafeSwap",CheeseSwap:"CheeseSwap",JulSwap:"JulSwap",ACryptos:"ACryptoS",QuickSwap:"QuickSwap",ComethSwap:"ComethSwap",Dfyn:"Dfyn",WaultSwap:"WaultSwap",Polydex:"Polydex",FirebirdOneSwap:"FirebirdOneSwap",JetSwap:"JetSwap",IronSwap:"IronSwap"},exports.unwrapNativeAsset=C,exports.wrapNativeAsset=E; -+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ethersproject/contracts"),t=require("@ethersproject/bignumber"),n=require("@ethereumjs/util"),r=require("@ethersproject/bytes"),a=require("@metamask/eth-sig-util"),i=require("@ethersproject/keccak256"),s=require("@ethersproject/strings");function o(e,t,n,r,a,i,s){try{var o=e[i](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,a)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function s(e){o(i,r,a,s,u,"next",e)}function u(e){o(i,r,a,s,u,"throw",e)}s(void 0)}))}}function p(){return(p=Object.assign||function(e){for(var t=1;t=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports),h=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}];(d=exports.ChainId||(exports.ChainId={}))[d.mainnet=1]="mainnet",d[d.ropsten=3]="ropsten",d[d.kovan=42]="kovan",d[d.goerli=5]="goerli",d[d.rinkeby=4]="rinkeby",d[d.optimism=10]="optimism",d[d.bsc=56]="bsc",d[d.polygon=137]="polygon",d[d.arbitrum=42161]="arbitrum",d[d.zora=7777777]="zora",d[d.base=8453]="base",d[d.avalanche=43114]="avalanche",d[d.blast=81457]="blast",d[d.degen=666666666]="degen",d[d.apechain=33139]="apechain",(l=exports.Source||(exports.Source={})).Aggregator0x="0x",l.Aggregator1inch="1inch",l.AggregatorRainbow="rainbow",l.Aggregotor1inch="1inch",l.CrosschainAggregatorSocket="socket",l.CrosschainAggregatorRelay="relay",(y=exports.SwapType||(exports.SwapType={})).normal="normal",y.crossChain="cross-chain",y.wrap="wrap",y.unwrap="unwrap";var T="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",v=((c={})[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",c[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",c[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",c[""+exports.ChainId.bsc]="0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",c[""+exports.ChainId.zora]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.base]="0x4200000000000000000000000000000000000006",c[""+exports.ChainId.avalanche]="0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",c[""+exports.ChainId.blast]="0x4300000000000000000000000000000000000004",c[""+exports.ChainId.degen]="0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387",c[""+exports.ChainId.apechain]="0x48b62137edfa95a428d35c09e44256a739f6b557",c),w=((m={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",m),g="0x77777feddddffc19ff86db637967013e6c6a116c",x="0x0d438f3b5175bebc262bf23753c1e53d03432bde",S="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",A=t.BigNumber.from("2").pow("256").sub("1").toString(),E=function(){var t=u(b.mark((function t(n,r,a,i){var s;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(v[a],JSON.stringify(h),r),t.abrupt("return",s.deposit(p({},i,{value:n})));case 4:case"end":return t.stop()}}),t)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),C=function(){var t=u(b.mark((function t(n,r,a,i){var s;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(v[a],JSON.stringify(h),r),t.abrupt("return",s.withdraw(n,i));case 4:case"end":return t.stop()}}),t)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),k=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"EthWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOwner",type:"address"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"}],name:"OwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"}],name:"SwapTargetAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"target",type:"address"}],name:"SwapTargetRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!0,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"TokenWithdrawn",type:"event"},{inputs:[{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"feeAmount",type:"uint256"}],name:"fillQuoteEthToToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feePercentageBasisPoints",type:"uint256"}],name:"fillQuoteTokenToEth",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feePercentageBasisPoints",type:"uint256"},{components:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"bool",name:"isDaiStylePermit",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],internalType:"struct PermitHelper.Permit",name:"permitData",type:"tuple"}],name:"fillQuoteTokenToEthWithPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feeAmount",type:"uint256"}],name:"fillQuoteTokenToToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"sellTokenAddress",type:"address"},{internalType:"address",name:"buyTokenAddress",type:"address"},{internalType:"address payable",name:"target",type:"address"},{internalType:"bytes",name:"swapCallData",type:"bytes"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{components:[{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"bool",name:"isDaiStylePermit",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],internalType:"struct PermitHelper.Permit",name:"permitData",type:"tuple"}],name:"fillQuoteTokenToTokenWithPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapTargets",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"target",type:"address"},{internalType:"bool",name:"add",type:"bool"}],name:"updateSwapTargets",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"withdrawEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],I=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],P=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"_nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],_=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],M=function(){var e=u(b.mark((function e(t,n,r,i){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","0x"+a.TypedDataUtils.hashStruct("EIP712Domain",{chainId:r,name:t,verifyingContract:i,version:n},{EIP712Domain:_},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),R=function(){var e=u(b.mark((function e(t,n,r,a){var i,s;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.version();case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),i="1",e.prev=10,e.next=13,t.DOMAIN_SEPARATOR();case 13:return s=e.sent,e.next=16,M(n,i,r,a);case 16:if(s!==e.sent){e.next=19;break}return e.abrupt("return",i);case 19:e.next=26;break;case 21:if(e.prev=21,e.t1=e.catch(10),1!==r||-1===[g,x,S].map((function(e){return e.toLowerCase()})).indexOf(t.address.toLowerCase())){e.next=25;break}return e.abrupt("return","1");case 25:case 26:return e.abrupt("return",null);case 27:case"end":return e.stop()}}),e,null,[[0,7],[10,21]])})));return function(t,n,r,a){return e.apply(this,arguments)}}(),N=function(){var e=u(b.mark((function e(t,n){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.nonces(n);case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),e.prev=9,e.next=12,t._nonces(n);case 12:return e.abrupt("return",e.sent);case 16:return e.prev=16,e.t1=e.catch(9),e.abrupt("return",0);case 19:case"end":return e.stop()}}),e,null,[[0,7],[9,16]])})));return function(t,n){return e.apply(this,arguments)}}(),O=[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],L=[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],D=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function V(e,t,n,r,a,i,s){return U.apply(this,arguments)}function U(){return(U=u(b.mark((function i(s,o,u,p,d,l,y){var c,m,f,h,T,v,g,x,S,A,E,C,k;return b.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return m=o.toLowerCase()===(null==(c=w[y])?void 0:c.toLowerCase()),f=new e.Contract(o,m?I:P,s),i.next=4,f.name();case 4:return h=i.sent,i.next=7,Promise.all([N(f,u),R(f,h,y,f.address)]);case 7:return v=(T=i.sent)[0],g=T[1],x={nonce:Number(v.toString()),spender:p},m?(x.holder=u,x.allowed=!0,x.expiry=Number(l.toString())):(x.value=t.BigNumber.from(d).toHexString(),x.deadline=Number(l.toString()),x.owner=u),S={chainId:y,name:h,verifyingContract:f.address},null!==g&&(S.version=g),A={domain:S,message:x,primaryType:"Permit",types:{EIP712Domain:null!==g?_:O,Permit:m?D:L}},E=Buffer.from(n.addHexPrefix(s.privateKey).substring(2),"hex"),C=a.signTypedData({data:A,privateKey:E,version:a.SignTypedDataVersion.V4}),k=r.splitSignature(C),i.abrupt("return",{deadline:l,isDaiStylePermit:m,nonce:v,r:k.r,s:k.s,v:k.v,value:x.value||t.BigNumber.from("0").toHexString()});case 20:case"end":return i.stop()}}),i)})))).apply(this,arguments)}function B(e){return i.keccak256(s.toUtf8Bytes(e)).substring(2,10)}function W(e){if(void 0===e||""===e||"0x0000000000000000000000000000000000000000"===e)throw new Error("provided address is not defined (API issue)")}exports.sdkConfig={apiBaseUrl:"https://swap.p.rainbow.me"};var H=function(e){return e===exports.ChainId.zora?"0xa61550e9ddd2797e16489db09343162be98d9483":"0x00000000009726632680fb29d3f7a9734e3010e2"},F=function(e){var t=e.sellTokenAddress,n=e.buyAmount,r=e.sellAmount,a=e.fromAddress,i=e.source,s=e.feePercentageBasisPoints,o=e.slippage,u=e.currency,d=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),currency:u,enableZoraSwaps:String(!0),fromAddress:a,sellToken:t,slippage:String(o)},i?{source:i}:{},r?{sellAmount:String(r)}:{buyAmount:String(n)},void 0!==s?{feePercentageBasisPoints:String(s)}:{}));return exports.sdkConfig.apiBaseUrl+"/v1/quote?"+d.toString()},Q=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.sellAmount,a=e.fromAddress,i=e.slippage,s=e.refuel,o=e.feePercentageBasisPoints,u=e.currency,d=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),currency:u,fromAddress:a,refuel:String(s),sellAmount:String(r),sellToken:n,slippage:String(i),toChainId:String(t)},void 0!==o?{feePercentageBasisPoints:String(o)}:{}));return exports.sdkConfig.apiBaseUrl+"/v1/quote?bridgeVersion=4&"+d.toString()},j=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.sellAmount,a=e.fromAddress,i=e.slippage,s=e.refuel,o=e.currency,u=new URLSearchParams({buyToken:e.buyTokenAddress,chainId:String(e.chainId),claim:String(!0),currency:o,feePercentageBasisPoints:"0",fromAddress:a,refuel:String(s),sellAmount:String(r),sellToken:n,slippage:String(i),source:exports.Source.CrosschainAggregatorRelay.toString(),toChainId:String(t)});return exports.sdkConfig.apiBaseUrl+"/v1/quote?bridgeVersion=4&"+u.toString()},X=function(){var e=u(b.mark((function e(n){var r,a,i,s,o,u;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.chainId,a=n.toChainId,i=exports.sdkConfig.apiBaseUrl+"/v1/chains",e.next=4,fetch(i);case 4:return s=e.sent,e.next=7,s.json();case 7:if(o=e.sent.result.find((function(e){return e.chainId===r}))){e.next=11;break}return e.abrupt("return",null);case 11:if(u=o.limits.find((function(e){return e.chainId===a}))){e.next=14;break}return e.abrupt("return",null);case 14:return e.abrupt("return",t.BigNumber.from(u.minAmount).mul(2).toString());case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),G=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c,m,f;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.source,a=void 0===(r=t.chainId)?exports.ChainId.mainnet:r,i=t.fromAddress,s=t.sellTokenAddress,o=t.buyTokenAddress,u=t.sellAmount,p=t.buyAmount,d=t.slippage,l=t.feePercentageBasisPoints,y=t.currency,!isNaN(Number(u))||!isNaN(Number(p))){e.next=3;break}return e.abrupt("return",null);case 3:return c=F({buyAmount:p,buyTokenAddress:o,chainId:a,currency:y,feePercentageBasisPoints:l,fromAddress:i,sellAmount:u,sellTokenAddress:s,slippage:d,source:n}),e.next=6,fetch(c);case 6:return m=e.sent,e.next=9,m.json();case 9:if(!(f=e.sent).error){e.next=12;break}return e.abrupt("return",f);case 12:return e.abrupt("return",f);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c,m;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,a=t.toChainId,i=t.currency,s=t.fromAddress,o=t.sellTokenAddress,u=t.buyTokenAddress,d=t.slippage,y=void 0!==(l=t.refuel)&&l,c=t.feePercentageBasisPoints,(p=t.sellAmount)&&a){e.next=3;break}return e.abrupt("return",null);case 3:return m=Q({buyTokenAddress:u,chainId:r,currency:i,feePercentageBasisPoints:c,fromAddress:s,refuel:y,sellAmount:p,sellTokenAddress:o,slippage:d,toChainId:a}),e.abrupt("return",Y(m));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l,y,c;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.optimism:n,a=t.toChainId,i=t.currency,s=t.fromAddress,o=t.sellTokenAddress,u=t.buyTokenAddress,d=t.slippage,y=void 0!==(l=t.refuel)&&l,(p=t.sellAmount)&&a){e.next=3;break}return e.abrupt("return",null);case 3:return c=j({buyTokenAddress:u,chainId:r,currency:i,fromAddress:s,refuel:y,sellAmount:p,sellTokenAddress:o,slippage:d,toChainId:a}),e.abrupt("return",Y(c));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Y=function(){var e=u(b.mark((function e(t){var n,r;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:return n=e.sent,e.next=5,n.json();case 5:if(!(r=e.sent).error){e.next=8;break}return e.abrupt("return",r);case 8:e.prev=8,W(null==r?void 0:r.to),e.next=15;break;case 12:return e.prev=12,e.t0=e.catch(8),e.abrupt("return",{error:!0,message:e.t0 instanceof Error?e.t0.message:"unexpected error happened while checking crosschain quote's address: "+(null==r?void 0:r.to)});case 15:return e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,null,[[8,12]])})));return function(t){return e.apply(this,arguments)}}(),J=function(){var e=u(b.mark((function e(t){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.provider.getBlock("latest");case 2:return e.abrupt("return",e.sent.timestamp+3600);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),z=function(){var t=u(b.mark((function t(n,r,a,i,s,o){var u,d,l,y,c,m,f,h,v,w,g,x,S,E,C;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=new e.Contract(H(s),k,a),l=n.sellTokenAddress,y=n.buyTokenAddress,c=n.to,m=n.data,f=n.fee,h=n.value,v=n.sellAmount,w=n.feePercentageBasisPoints,g=T.toLowerCase(),(null==l?void 0:l.toLowerCase())!==g){t.next=9;break}return t.next=6,u.populateTransaction.fillQuoteEthToToken(y,c,m,f,p({},r,{value:h}));case 6:d=t.sent,t.next=42;break;case 9:if((null==y?void 0:y.toLowerCase())!==g){t.next=27;break}if(!i){t.next=22;break}return t.next=13,J(a);case 13:return x=t.sent,t.next=16,V(a,l,n.from,u.address,A,x,s);case 16:return S=t.sent,t.next=19,u.populateTransaction.fillQuoteTokenToEthWithPermit(l,c,m,v,w,S,p({},r,{value:h}));case 19:d=t.sent,t.next=25;break;case 22:return t.next=24,u.populateTransaction.fillQuoteTokenToEth(l,c,m,v,w,p({},r,{value:h}));case 24:d=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,J(a);case 30:return E=t.sent,t.next=33,V(a,l,n.from,u.address,A,E,s);case 33:return C=t.sent,t.next=36,u.populateTransaction.fillQuoteTokenToTokenWithPermit(l,y,c,m,v,f,C,p({},r,{value:h}));case 36:d=t.sent,t.next=42;break;case 39:return t.next=41,u.populateTransaction.fillQuoteTokenToToken(l,y,c,m,v,f,p({},r,{value:h}));case 41:d=t.sent;case 42:return o&&(d.data=""+d.data+B(o)),t.next=45,a.sendTransaction(p({data:d.data,from:d.from,to:d.to},p({},r,{value:h})));case 45:return t.abrupt("return",t.sent);case 47:case"end":return t.stop()}}),t)})));return function(e,n,r,a,i,s){return t.apply(this,arguments)}}(),Z=function(){var e=u(b.mark((function e(t,n,r,a){var i,s,o,u;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.data,s=t.from,o=t.value,W(null==t?void 0:t.to),u=i,a&&(u=""+u+B(a)),e.next=6,r.sendTransaction(p({data:u,from:s,to:t.to},p({},n,{value:o})));case 6:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),$=function(e){var t=e.toChainId,n=e.sellTokenAddress,r=e.buyAmount,a=e.sellAmount,i=new URLSearchParams(p({buyToken:e.buyTokenAddress,chainId:String(e.chainId),sellToken:n,toChainId:String(t)},a?{sellAmount:String(a)}:{buyAmount:String(r)}));return exports.sdkConfig.apiBaseUrl+"/v1/slippage?"+i.toString()},ee=function(){var e=u(b.mark((function e(t){var n,r,a,i,s,o,u,p,d,l;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,a=t.toChainId,i=t.sellTokenAddress,s=t.buyTokenAddress,o=t.sellAmount,u=t.buyAmount,!isNaN(Number(o))||!isNaN(Number(u))){e.next=3;break}return e.abrupt("return",null);case 3:return p=$({buyAmount:u,buyTokenAddress:s,chainId:r,sellAmount:o,sellTokenAddress:i,toChainId:a}),e.next=6,fetch(p);case 6:return d=e.sent,e.next=9,d.json();case 9:if(!(l=e.sent).error){e.next=12;break}return e.abrupt("return",l);case 12:return e.abrupt("return",null==l?void 0:l.data);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.ALLOWS_PERMIT={"0x0d438f3b5175bebc262bf23753c1e53d03432bde":!0,"0x111111111117dc0aa78b770fa6a738034120c302":!0,"0x1b40183efb4dd766f11bda7a7c3ad8982e998421":!0,"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984":!0,"0x31c8eacbffdd875c74b94b077895bd78cf1e64a3":!0,"0x6b175474e89094c44da98b954eedeac495271d0f":!0,"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d":!0,"0x77777feddddffc19ff86db637967013e6c6a116c":!0,"0x888888435fde8e7d4c54cab67f206e4199454c60":!0,"0x888888888889c00c67689029d7856aac1065ec11":!0,"0x88acdd2a6425c3faae4bc9650fd7e27e0bebb7ab":!0,"0x956f47f50a910163d8bf957cf5846d573e7f87ca":!0,"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":!0,"0xba100000625a3754423978a60c9317c58a424e3d":!0,"0xc7283b66eb1eb5fb86327f08e1b5816b0720212b":!0},exports.API_BASE_URL="https://swap.p.rainbow.me",exports.DAI=w,exports.ETH_ADDRESS=T,exports.MAX_INT=A,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA="0xa61550e9ddd2797e16489db09343162be98d9483",exports.TORN_ADDRESS=g,exports.USDC_ADDRESS="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",exports.VSP_ADDRESS=S,exports.WNXM_ADDRESS=x,exports.WRAPPED_ASSET=v,exports.buildRainbowClaimBridgeQuoteUrl=j,exports.buildRainbowCrosschainQuoteUrl=Q,exports.configureSDK=function(e){exports.sdkConfig=p({},exports.sdkConfig,e)},exports.fillCrosschainQuote=Z,exports.fillQuote=z,exports.getClaimBridgeQuote=K,exports.getCrosschainQuote=q,exports.getCrosschainQuoteExecutionDetails=function(e,t,n){var r=e.from,a=e.data,i=e.value;return W(null==e?void 0:e.to),{method:n.estimateGas({data:a,from:r,to:e.to,value:i}),params:p({},t,{value:i})}},exports.getMinRefuelAmount=X,exports.getQuote=G,exports.getQuoteExecutionDetails=function(t,n,r){var a=new e.Contract(H(t.chainId),k,r),i=t.sellTokenAddress,s=t.buyTokenAddress,o=t.to,u=t.data,d=t.fee,l=t.value,y=t.sellAmount,c=t.feePercentageBasisPoints,m=T.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:a.estimateGas.fillQuoteEthToToken,methodArgs:[s,o,u,d],methodName:"fillQuoteEthToToken",params:p({},n,{value:l}),router:a}:(null==s?void 0:s.toLowerCase())===m?{method:a.estimateGas.fillQuoteTokenToEth,methodArgs:[i,o,u,y,c],methodName:"fillQuoteTokenToEth",params:p({},n,{value:l}),router:a}:{method:a.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,o,u,y,d],methodName:"fillQuoteTokenToToken",params:p({},n,{value:l}),router:a}},exports.getRainbowRouterContractAddress=H,exports.getSlippage=ee,exports.getWrappedAssetMethod=function(t,n,r){return void 0===r&&(r=exports.ChainId.mainnet),new e.Contract(v[r],JSON.stringify(h),n).estimateGas[t]},exports.signPermit=V,exports.sources={AAVE:"Aave",AAVE_LIQUIDATOR:"Aave Liquidator",AAVE_V2:"Aave V2",BALANCER:"Balancer",BALANCER_V2:"Balancer V2",BANCOR:"Bancor",BLACKHOLESWAP:"Blackholeswap",CHAI:"Chai",CLIPPER:"Clipper",COFIX:"CoFix",COMPOUND:"Compound",CONVERGENCE_X:"Convergence X",CREAM_LENDING:"Creamswap Lending",CREAMSWAP:"Creamswap",CURVE:"Curve",CURVE_V2:"Curve V2",CURVE_V2_ETH_CRV:"CURVE V2 ETH CRV",CURVE_V2_ETH_CVX:"CURVE V2 ETH CVX",CURVE_V2_EURS_2_ASSET:"Curve V2 EURS",CURVE_V2_EURT_2_ASSET:"CURVE V2 EURT",CURVE_V2_SPELL_2_ASSET:"Curve Spell",CURVE_V2_THRESHOLDNETWORK_2_ASSET:"Curve Threshold",CURVE_V2_XAUT_2_ASSET:"CURVE V2 XAUt",CURVE_V2_YFI_2_ASSET:"Curve Yfi",DEFI_PLAZA:"DeFi Plaza",DEFISWAP:"DeFi Swap",DFX_FINANCE:"Dfx Finance",DODO:"DODO",DODO_V2:"DODO v2",DXSWAP:"Swapr",FIXED_FEE_SWAP:"Fixed Fee Swap",FIXED_FEE_SWAP_V3:"Fixed Rate Swap",IEARN:"yEarn",INDEXED_FINANCE:"Indexed Finance",KYBER:"Kyber",KYBER_DMM:"Kyber DMM",LINKSWAP:"Link Swap",LUASWAP:"Lua Swap",MINISWAP:"Mini Swap",MOONISWAP:"Mooniswap",MSTABLE:"mStable",OASIS:"Oasis",ONE_INCH_LIMIT_ORDER:"1inch Limit Order Protocol",ONE_INCH_LIMIT_ORDER_V2:"1inch Limit Order Protocol V2",ONE_INCH_LP:"1inch LP v1.0",ONE_INCH_LP_1_1:"1inch LP v1.1",ONE_INCH_LP_MIGRATOR:"Mooniswap Migrator",ONE_INCH_LP_MIGRATOR_V1_1:"1inch LP v1.0 Migrator",PMM1:"PMM1",PMM2:"PMM2",PMM3:"PMM3",PMM4:"PMM4",PMMX:"LiqPool X",POWERINDEX:"POWERINDEX",PSM:"PSM",S_FINANCE:"sFinance",SADDLE:"Saddle Finance",SAKESWAP:"Sake Swap",SETH_WRAPPER:"sETH Wrapper",SHELL:"Shell",SHIBASWAP:"Shiba Swap",SMOOTHY_FINANCE:"Smoothy Finance",ST_ETH:"stETH",SUSHI:"Sushiswap",SUSHISWAP_MIGRATOR:"SushiSwap Migrator",SWERVE:"Swerve",SYNAPSE:"Synapse",SYNTHETIX:"Synthetix",SYNTHETIX_WRAPPER:"Synthetix Wrapper",UNIFI:"Unifi",UNISWAP_V1:"Uniswap V1",UNISWAP_V2:"Uniswap V2",UNISWAP_V2_MIGRATOR:"Uniswap Migrator",UNISWAP_V3:"UNISWAP V3",VALUELIQUID:"Value Liquid",WETH:"WETH",WSTETH:"wstETH",XSIGMA:"xSigma",ZRX:"0x",Native:"Native",Uniswap:"Uniswap",UniswapV2:"Uniswap_V2",Eth2Dai:"Eth2Dai",Kyber:"Kyber",Curve:"Curve",LiquidityProvider:"LiquidityProvider",MultiBridge:"MultiBridge",Balancer:"Balancer",BalancerV2:"Balancer_V2",Cream:"CREAM",Bancor:"Bancor",MakerPsm:"MakerPsm",MStable:"mStable",Mooniswap:"Mooniswap",MultiHop:"MultiHop",Shell:"Shell",Swerve:"Swerve",SnowSwap:"SnowSwap",SushiSwap:"SushiSwap",Dodo:"DODO",DodoV2:"DODO_V2",CryptoCom:"CryptoCom",Linkswap:"Linkswap",KyberDmm:"KyberDMM",Smoothy:"Smoothy",Component:"Component",Saddle:"Saddle",XSigma:"xSigma",UniswapV3:"Uniswap_V3",CurveV2:"Curve_V2",Lido:"Lido",ShibaSwap:"ShibaSwap",Clipper:"Clipper",PancakeSwap:"PancakeSwap",PancakeSwapV2:"PancakeSwap_V2",BakerySwap:"BakerySwap",Nerve:"Nerve",Belt:"Belt",Ellipsis:"Ellipsis",ApeSwap:"ApeSwap",CafeSwap:"CafeSwap",CheeseSwap:"CheeseSwap",JulSwap:"JulSwap",ACryptos:"ACryptoS",QuickSwap:"QuickSwap",ComethSwap:"ComethSwap",Dfyn:"Dfyn",WaultSwap:"WaultSwap",Polydex:"Polydex",FirebirdOneSwap:"FirebirdOneSwap",JetSwap:"JetSwap",IronSwap:"IronSwap"},exports.unwrapNativeAsset=C,exports.wrapNativeAsset=E; - //# sourceMappingURL=swaps.cjs.production.min.js.map -diff --git a/node_modules/@rainbow-me/swaps/dist/swaps.esm.js b/node_modules/@rainbow-me/swaps/dist/swaps.esm.js -index 44b6d2e..bb5eaba 100644 ---- a/node_modules/@rainbow-me/swaps/dist/swaps.esm.js -+++ b/node_modules/@rainbow-me/swaps/dist/swaps.esm.js -@@ -1123,7 +1123,7 @@ var RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA = '0xa61550e9ddd2797e16489db09343162be9 - * @deprecated: Should not use this anymore to reduce friction for new network support - */ - --var WRAPPED_ASSET = (_WRAPPED_ASSET = {}, _WRAPPED_ASSET["" + ChainId.mainnet] = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', _WRAPPED_ASSET["" + ChainId.optimism] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.polygon] = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', _WRAPPED_ASSET["" + ChainId.arbitrum] = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', _WRAPPED_ASSET["" + ChainId.bsc] = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', _WRAPPED_ASSET["" + ChainId.zora] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.base] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.avalanche] = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', _WRAPPED_ASSET["" + ChainId.blast] = '0x4300000000000000000000000000000000000004', _WRAPPED_ASSET["" + ChainId.degen] = '0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387', _WRAPPED_ASSET["" + ChainId.apechain] = '0x8643a49363e80c7a15790703b915d1b0b6b71d56', _WRAPPED_ASSET); -+var WRAPPED_ASSET = (_WRAPPED_ASSET = {}, _WRAPPED_ASSET["" + ChainId.mainnet] = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', _WRAPPED_ASSET["" + ChainId.optimism] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.polygon] = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', _WRAPPED_ASSET["" + ChainId.arbitrum] = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', _WRAPPED_ASSET["" + ChainId.bsc] = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', _WRAPPED_ASSET["" + ChainId.zora] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.base] = '0x4200000000000000000000000000000000000006', _WRAPPED_ASSET["" + ChainId.avalanche] = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', _WRAPPED_ASSET["" + ChainId.blast] = '0x4300000000000000000000000000000000000004', _WRAPPED_ASSET["" + ChainId.degen] = '0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387', _WRAPPED_ASSET["" + ChainId.apechain] = '0x48b62137edfa95a428d35c09e44256a739f6b557', _WRAPPED_ASSET); - var DAI = (_DAI = {}, _DAI["" + ChainId.mainnet] = '0x6b175474e89094c44da98b954eedeac495271d0f', _DAI); - var USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; - var TORN_ADDRESS = '0x77777feddddffc19ff86db637967013e6c6a116c'; diff --git a/src/core/raps/actions/swap.ts b/src/core/raps/actions/swap.ts index 8423a81f06..a51f2890a2 100644 --- a/src/core/raps/actions/swap.ts +++ b/src/core/raps/actions/swap.ts @@ -3,14 +3,13 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers'; import { Transaction } from '@ethersproject/transactions'; import { CrosschainQuote, - ETH_ADDRESS as ETH_ADDRESS_AGGREGATORS, Quote, ChainId as SwapChainId, SwapType, - WRAPPED_ASSET, fillQuote, getQuoteExecutionDetails, getRainbowRouterContractAddress, + getWrappedAssetAddress, getWrappedAssetMethod, unwrapNativeAsset, wrapNativeAsset, @@ -22,7 +21,6 @@ import { getChainGasUnits } from '~/core/references/chains'; import { ChainId } from '~/core/types/chains'; import { NewTransaction, TxHash } from '~/core/types/transactions'; import { add } from '~/core/utils/numbers'; -import { isLowerCaseMatch } from '~/core/utils/strings'; import { addNewTransaction } from '~/core/utils/transactions'; import { getProvider } from '~/core/wagmi/clientToProvider'; import { TransactionSimulationResponse } from '~/entries/popup/pages/messages/useSimulateTransaction'; @@ -64,14 +62,8 @@ export const estimateSwapGasLimit = async ({ return getChainGasUnits(chainId).basic.swap; } - const { sellTokenAddress, buyTokenAddress } = quote; - const isWrapNativeAsset = - isLowerCaseMatch(sellTokenAddress, ETH_ADDRESS_AGGREGATORS) && - isLowerCaseMatch(buyTokenAddress, WRAPPED_ASSET[chainId]); - - const isUnwrapNativeAsset = - isLowerCaseMatch(sellTokenAddress, WRAPPED_ASSET[chainId]) && - isLowerCaseMatch(buyTokenAddress, ETH_ADDRESS_AGGREGATORS); + const isWrapNativeAsset = quote.swapType === SwapType.wrap; + const isUnwrapNativeAsset = quote.swapType === SwapType.unwrap; // Wrap / Unwrap Eth if (isWrapNativeAsset || isUnwrapNativeAsset) { @@ -87,7 +79,7 @@ export const estimateSwapGasLimit = async ({ contractCallEstimateGas: getWrappedAssetMethod( isWrapNativeAsset ? 'deposit' : 'withdraw', provider as StaticJsonRpcProvider, - chainId as unknown as SwapChainId, + getWrappedAssetAddress(quote), ), callArguments: isWrapNativeAsset ? [] : [quote.buyAmount.toString()], provider, @@ -241,7 +233,7 @@ export const executeSwap = async ({ return wrapNativeAsset( quote.buyAmount, wallet, - chainId as unknown as SwapChainId, + getWrappedAssetAddress(quote), transactionParams, ); // Unwrap native @@ -249,7 +241,7 @@ export const executeSwap = async ({ return unwrapNativeAsset( quote.sellAmount, wallet, - chainId as unknown as SwapChainId, + getWrappedAssetAddress(quote), transactionParams, ); // Swap diff --git a/src/core/utils/swaps.ts b/src/core/utils/swaps.ts index ee3a209826..088a1f17b3 100644 --- a/src/core/utils/swaps.ts +++ b/src/core/utils/swaps.ts @@ -1,16 +1,7 @@ -import { - CrosschainQuote, - ETH_ADDRESS, - Quote, - WRAPPED_ASSET, -} from '@rainbow-me/swaps'; +import { CrosschainQuote, Quote } from '@rainbow-me/swaps'; import { i18n } from '../languages'; -import { useConnectedToHardhatStore } from '../state/currentSettings/connectedToHardhat'; import { ParsedSearchAsset } from '../types/assets'; -import { ChainId } from '../types/chains'; - -import { isLowerCaseMatch } from './strings'; export const getQuoteServiceTime = ({ quote, @@ -55,42 +46,6 @@ export const getCrossChainTimeEstimate = ({ timeEstimateDisplay, }; }; -export const isUnwrapEth = ({ - buyTokenAddress, - chainId, - sellTokenAddress, -}: { - chainId: ChainId; - sellTokenAddress: string; - buyTokenAddress: string; -}) => { - const { connectedToHardhat } = useConnectedToHardhatStore.getState(); - return ( - isLowerCaseMatch( - sellTokenAddress, - WRAPPED_ASSET[connectedToHardhat ? ChainId.mainnet : chainId], - ) && isLowerCaseMatch(buyTokenAddress, ETH_ADDRESS) - ); -}; - -export const isWrapEth = ({ - buyTokenAddress, - chainId, - sellTokenAddress, -}: { - chainId: ChainId; - sellTokenAddress: string; - buyTokenAddress: string; -}) => { - const { connectedToHardhat } = useConnectedToHardhatStore.getState(); - return ( - isLowerCaseMatch(sellTokenAddress, ETH_ADDRESS) && - isLowerCaseMatch( - buyTokenAddress, - WRAPPED_ASSET[connectedToHardhat ? ChainId.mainnet : chainId], - ) - ); -}; export const isWrapOrUnwrapEth = ({ assetToBuy, diff --git a/src/entries/popup/hooks/swap/useSwapQuote.ts b/src/entries/popup/hooks/swap/useSwapQuote.ts index 23aa853c69..0f198071a6 100644 --- a/src/entries/popup/hooks/swap/useSwapQuote.ts +++ b/src/entries/popup/hooks/swap/useSwapQuote.ts @@ -14,9 +14,7 @@ import { useMemo } from 'react'; import { useCurrentAddressStore, useCurrentCurrencyStore } from '~/core/state'; import { ParsedAsset, ParsedSearchAsset } from '~/core/types/assets'; -import { ChainId } from '~/core/types/chains'; import { convertAmountToRawAmount } from '~/core/utils/numbers'; -import { isUnwrapEth, isWrapEth } from '~/core/utils/swaps'; import { IndependentField } from './useSwapInputs'; @@ -128,19 +126,8 @@ export const useSwapQuote = ({ const isWrapOrUnwrapEth = useMemo(() => { if (!data || (data as QuoteError).error) return false; const quote = data as Quote | CrosschainQuote; - return ( - isWrapEth({ - buyTokenAddress: quote?.buyTokenAddress, - sellTokenAddress: quote?.sellTokenAddress, - chainId: assetToSell?.chainId || ChainId.mainnet, - }) || - isUnwrapEth({ - buyTokenAddress: quote?.buyTokenAddress, - sellTokenAddress: quote?.sellTokenAddress, - chainId: assetToSell?.chainId || ChainId.mainnet, - }) - ); - }, [assetToSell?.chainId, data]); + return quote.swapType == SwapType.wrap || quote.swapType == SwapType.unwrap; + }, [data]); const quote = useMemo(() => { if (!data || (data as QuoteError)?.error) return data; diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx index 175518e01d..467d24ed8f 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx @@ -1,4 +1,9 @@ -import { CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps'; +import { + CrosschainQuote, + Quote, + QuoteError, + SwapType, +} from '@rainbow-me/swaps'; import { motion } from 'framer-motion'; import React, { useCallback, @@ -16,7 +21,6 @@ import { ChainId } from '~/core/types/chains'; import { KeychainType } from '~/core/types/keychainTypes'; import { truncateAddress } from '~/core/utils/address'; import { processExchangeRateArray } from '~/core/utils/numbers'; -import { isUnwrapEth, isWrapEth } from '~/core/utils/swaps'; import { Bleed, Box, @@ -243,18 +247,9 @@ const SwapReviewSheetWithQuote = ({ const isWrapOrUnwrapEth = useMemo(() => { return ( - isWrapEth({ - buyTokenAddress: quote.buyTokenAddress, - sellTokenAddress: quote.sellTokenAddress, - chainId: assetToSell.chainId, - }) || - isUnwrapEth({ - buyTokenAddress: quote.buyTokenAddress, - sellTokenAddress: quote.sellTokenAddress, - chainId: assetToSell.chainId, - }) + quote.swapType === SwapType.wrap || quote.swapType === SwapType.unwrap ); - }, [assetToSell.chainId, quote.buyTokenAddress, quote.sellTokenAddress]); + }, [quote]); const openMoreDetails = useCallback(() => setShowDetails(true), []); const closeMoreDetails = useCallback(() => setShowDetails(false), []); diff --git a/yarn.lock b/yarn.lock index df13c22c40..8927f13e66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4187,10 +4187,10 @@ eventemitter3 "5.0.1" viem "1.21.4" -"@rainbow-me/swaps@0.29.0": - version "0.29.0" - resolved "https://registry.yarnpkg.com/@rainbow-me/swaps/-/swaps-0.29.0.tgz#24a6b15017c05211c871ff9c365b643fc4a7802f" - integrity sha512-NTe4uogcHvwBUr3ePmIKJlE45AP+nyhMrCR4ZO1psVKwsLGIbchL6p0s5c6pl+ZaYUARKbT39Q+AVB9308MhNA== +"@rainbow-me/swaps@0.30.1": + version "0.30.1" + resolved "https://registry.yarnpkg.com/@rainbow-me/swaps/-/swaps-0.30.1.tgz#e598c01933cbba5c1360380511a54668ce4d6921" + integrity sha512-ppigkIdaP08VvoCWLRsbHZubAsUMJ3mGmufm8CIfH62YGunV+LFQY+lsiOsmYMfRXDsrw9h50EW+ILByb1EltQ== dependencies: "@ethereumjs/util" "9.0.0" "@ethersproject/abi" "5.7.0"