Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rainbow-me/swaps

Package Overview
Dependencies
Maintainers
10
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainbow-me/swaps - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

2

dist/quotes.d.ts

@@ -19,3 +19,3 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers';

*/
export declare const getQuote: ({ source, chainId, fromAddress, sellTokenAddress, buyTokenAddress, sellAmount, buyAmount, slippage, }: QuoteParams) => Promise<Quote | QuoteError | null>;
export declare const getQuote: (params: QuoteParams) => Promise<Quote | QuoteError | null>;
/**

@@ -22,0 +22,0 @@ * Function that fills a quote onchain via rainbow's swap aggregator smart contract

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ethersproject/contracts"),t=require("@ethersproject/bignumber"),n=require("@ethersproject/bytes"),a=require("@metamask/eth-sig-util"),r=require("ethereumjs-util");function i(e,t,n,a,r,i,s){try{var o=e[i](s),p=o.value}catch(e){return void n(e)}o.done?t(p):Promise.resolve(p).then(a,r)}function s(e){return function(){var t=this,n=arguments;return new Promise((function(a,r){var s=e.apply(t,n);function o(e){i(s,a,r,o,p,"next",e)}function p(e){i(s,a,r,o,p,"throw",e)}o(void 0)}))}}function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var p,u,y,d,l,c=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},r=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(e){o=function(e,t,n){return e[t]=n}}function p(e,t,n,a){var r=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(a||[]);return r._invoke=function(e,t,n){var a="suspendedStart";return function(r,i){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===r)throw i;return{value:void 0,done:!0}}for(n.method=r,n.arg=i;;){var s=n.delegate;if(s){var o=w(s,n);if(o){if(o===y)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var p=u(e,t,n);if("normal"===p.type){if(a=n.done?"completed":"suspendedYield",p.arg===y)continue;return{value:p.arg,done:n.done}}"throw"===p.type&&(a="completed",n.method="throw",n.arg=p.arg)}}}(e,n,i),r}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=p;var y={};function d(){}function l(){}function c(){}var m={};o(m,r,(function(){return this}));var f=Object.getPrototypeOf,b=f&&f(f(g([])));b&&b!==t&&n.call(b,r)&&(m=b);var T=c.prototype=d.prototype=Object.create(m);function h(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var a;this._invoke=function(r,i){function s(){return new t((function(a,s){!function a(r,i,s,o){var p=u(e[r],e,i);if("throw"!==p.type){var y=p.arg,d=y.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){a("next",e,s,o)}),(function(e){a("throw",e,s,o)})):t.resolve(d).then((function(e){y.value=e,s(y)}),(function(e){return a("throw",e,s,o)}))}o(p.arg)}(r,i,a,s)}))}return a=a?a.then(s,s):s()}}function w(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return y;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var a=u(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var r=a.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,y):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function g(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function t(){for(;++a<e.length;)if(n.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return l.prototype=c,o(T,"constructor",c),o(c,"constructor",l),l.displayName=o(c,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,o(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},h(v.prototype),o(v.prototype,i,(function(){return this})),e.AsyncIterator=v,e.async=function(t,n,a,r,i){void 0===i&&(i=Promise);var s=new v(p(t,n,a,r),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},h(T),o(T,s,"Generator"),o(T,r,(function(){return this})),o(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var a=t.pop();if(a in e)return n.value=a,n.done=!1,n}return n.done=!0,n}},e.values=g,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function a(n,a){return s.type="throw",s.arg=e,t.next=n,a&&(t.method="next",t.arg=void 0),!!a}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),p=n.call(i,"finallyLoc");if(o&&p){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!p)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var a=this.tryEntries.length-1;a>=0;--a){var r=this.tryEntries[a];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var r=a.arg;x(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:g(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),y}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(l={exports:{}}),l.exports),m=[{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"}];(p=exports.ChainId||(exports.ChainId={}))[p.mainnet=1]="mainnet",p[p.ropsten=3]="ropsten",p[p.kovan=42]="kovan",p[p.goerli=5]="goerli",p[p.rinkeby=4]="rinkeby",p[p.optimism=10]="optimism",p[p.polygon=137]="polygon",p[p.arbitrum=42161]="arbitrum",(u=exports.Source||(exports.Source={})).Aggregator0x="0x",u.Aggregotor1inch="1inch";var f="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",b=((y={})[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",y[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",y[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",y[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",y),T=((d={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",d),h="0x77777feddddffc19ff86db637967013e6c6a116c",v="0x0d438f3b5175bebc262bf23753c1e53d03432bde",w="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",S=t.BigNumber.from("2").pow("256").sub("1").toString(),x=function(){var t=s(c.mark((function t(n,a,r,i){var s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(b[r],JSON.stringify(m),a),t.abrupt("return",s.deposit(o({},i,{value:n})));case 4:case"end":return t.stop()}}),t)})));return function(e,n,a,r){return t.apply(this,arguments)}}(),E=function(){var t=s(c.mark((function t(n,a,r,i){var s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(b[r],JSON.stringify(m),a),t.abrupt("return",s.withdraw(n,i));case 4:case"end":return t.stop()}}),t)})));return function(e,n,a,r){return t.apply(this,arguments)}}(),g=[{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"}],A=function(){var e=s(c.mark((function e(t){var n,a,r,i,s,o,p,u,y,d,l,m,T,h,v,w,S,x,E;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.source,i=void 0===(r=t.chainId)?exports.ChainId.mainnet:r,s=t.fromAddress,p=t.buyTokenAddress,u=t.sellAmount,y=t.buyAmount,d=t.slippage,l=(o=t.sellTokenAddress).toLowerCase(),m=p.toLowerCase(),T=f.toLowerCase(),h=null==(n=b[i])?void 0:n.toLowerCase(),w=l===h&&m===T,!(v=l===T&&m===h)&&!w){e.next=9;break}return e.abrupt("return",{buyAmount:u||y,buyTokenAddress:p,defaultGasLimit:v?"30000":"40000",fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:u||y,sellAmountMinusFees:u||y,sellTokenAddress:o});case 9:if(S="https://swap.p.rainbow.me/quote?chainId="+i+"&fromAddress="+s+"&buyToken="+p+"&sellToken="+o+"&slippage="+d,a&&(S+="&source="+a),u?S+="&sellAmount="+u:y&&(S+="&buyAmount="+y),!isNaN(Number(u))||!isNaN(Number(y))){e.next=14;break}return e.abrupt("return",null);case 14:return p===f&&(S+="&destReceiver=0x00000000009726632680fb29d3f7a9734e3010e2"),e.next=17,fetch(S);case 17:return x=e.sent,e.next=20,x.json();case 20:if(!(E=e.sent).error){e.next=23;break}return e.abrupt("return",E);case 23:return e.abrupt("return",E);case 24:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_=function(){var e=s(c.mark((function e(t){return c.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)}}(),M=function(){var t=s(c.mark((function t(n,a,r,i,s){var p,u,y,d,l,m,b,T,h,v,w,x,E,A,M;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(p=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",g,r),y=n.sellTokenAddress,d=n.buyTokenAddress,l=n.to,m=n.data,b=n.fee,T=n.value,h=n.sellAmount,v=n.feePercentageBasisPoints,w=f.toLowerCase(),(null==y?void 0:y.toLowerCase())!==w){t.next=9;break}return t.next=6,p.fillQuoteEthToToken(d,l,m,b,o({},a,{value:T}));case 6:u=t.sent,t.next=42;break;case 9:if((null==d?void 0:d.toLowerCase())!==w){t.next=27;break}if(!i){t.next=22;break}return t.next=13,_(r);case 13:return x=t.sent,t.next=16,V(r,y,n.from,p.address,S,x,s);case 16:return E=t.sent,t.next=19,p.fillQuoteTokenToEthWithPermit(y,l,m,h,v,E,o({},a,{value:T}));case 19:u=t.sent,t.next=25;break;case 22:return t.next=24,p.fillQuoteTokenToEth(y,l,m,h,v,o({},a,{value:T}));case 24:u=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,_(r);case 30:return A=t.sent,t.next=33,V(r,y,n.from,p.address,S,A,s);case 33:return M=t.sent,t.next=36,p.fillQuoteTokenToTokenWithPermit(y,d,l,m,h,b,M,o({},a,{value:T}));case 36:u=t.sent,t.next=42;break;case 39:return t.next=41,p.fillQuoteTokenToToken(y,d,l,m,h,b,o({},a,{value:T}));case 41:u=t.sent;case 42:return t.abrupt("return",u);case 43:case"end":return t.stop()}}),t)})));return function(e,n,a,r,i){return t.apply(this,arguments)}}(),C=[{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"}],k=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],I=function(){var e=s(c.mark((function e(t,n,r,i){return c.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:k},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),L=function(){var e=s(c.mark((function e(t,n,a,r){var i,s;return c.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,I(n,i,a,r);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!==a||-1===[h,v,w].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,a,r){return e.apply(this,arguments)}}(),N=function(){var e=s(c.mark((function e(t,n){return c.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"}],R=[{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,a,r,i,s){return U.apply(this,arguments)}function U(){return(U=s(c.mark((function i(s,o,p,u,y,d,l){var m,f,b,h,v,w,S,x,E,g,A,_,M;return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(m=T[l])?void 0:m.toLowerCase()),b=new e.Contract(o,f?C:P,s),i.next=4,b.name();case 4:return h=i.sent,i.next=7,Promise.all([N(b,p),L(b,h,l,b.address)]);case 7:return w=(v=i.sent)[0],S=v[1],x={nonce:Number(w.toString()),spender:u},f?(x.holder=p,x.allowed=!0,x.expiry=Number(d.toString())):(x.value=t.BigNumber.from(y).toHexString(),x.deadline=Number(d.toString()),x.owner=p),E={chainId:l,name:h,verifyingContract:b.address},null!==S&&(E.version=S),g={domain:E,message:x,primaryType:"Permit",types:{EIP712Domain:null!==S?k:O,Permit:f?D:R}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),_=a.signTypedData({data:g,privateKey:A,version:a.SignTypedDataVersion.V4}),M=n.splitSignature(_),i.abrupt("return",{deadline:d,isDaiStylePermit:f,nonce:w,r:M.r,s:M.s,v:M.v,value:x.value||t.BigNumber.from("0").toHexString()});case 20:case"end":return i.stop()}}),i)})))).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=T,exports.ETH_ADDRESS=f,exports.MAX_INT=S,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.TORN_ADDRESS=h,exports.USDC_ADDRESS="0x111111111117dc0aa78b770fa6a738034120c302",exports.VSP_ADDRESS=w,exports.WNXM_ADDRESS=v,exports.WRAPPED_ASSET=b,exports.fillQuote=M,exports.getQuote=A,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",g,a),i=t.sellTokenAddress,s=t.buyTokenAddress,p=t.to,u=t.data,y=t.fee,d=t.value,l=t.sellAmount,c=t.feePercentageBasisPoints,m=f.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:r.estimateGas.fillQuoteEthToToken,methodArgs:[s,p,u,y],methodName:"fillQuoteEthToToken",params:o({},n,{value:d}),router:r}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,p,u,l,c],methodName:"fillQuoteTokenToEth",params:o({},n,{value:d}),router:r}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,p,u,l,y],methodName:"fillQuoteTokenToToken",params:o({},n,{value:d}),router:r}},exports.getWrappedAssetMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(b[a],JSON.stringify(m),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=E,exports.wrapNativeAsset=x;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ethersproject/contracts"),t=require("@ethersproject/bignumber"),n=require("@ethersproject/bytes"),a=require("@metamask/eth-sig-util"),r=require("ethereumjs-util");function i(e,t,n,a,r,i,s){try{var o=e[i](s),p=o.value}catch(e){return void n(e)}o.done?t(p):Promise.resolve(p).then(a,r)}function s(e){return function(){var t=this,n=arguments;return new Promise((function(a,r){var s=e.apply(t,n);function o(e){i(s,a,r,o,p,"next",e)}function p(e){i(s,a,r,o,p,"throw",e)}o(void 0)}))}}function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var p,u,y,d,l,c=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},r=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(e){o=function(e,t,n){return e[t]=n}}function p(e,t,n,a){var r=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(a||[]);return r._invoke=function(e,t,n){var a="suspendedStart";return function(r,i){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===r)throw i;return{value:void 0,done:!0}}for(n.method=r,n.arg=i;;){var s=n.delegate;if(s){var o=w(s,n);if(o){if(o===y)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var p=u(e,t,n);if("normal"===p.type){if(a=n.done?"completed":"suspendedYield",p.arg===y)continue;return{value:p.arg,done:n.done}}"throw"===p.type&&(a="completed",n.method="throw",n.arg=p.arg)}}}(e,n,i),r}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=p;var y={};function d(){}function l(){}function c(){}var m={};o(m,r,(function(){return this}));var f=Object.getPrototypeOf,b=f&&f(f(g([])));b&&b!==t&&n.call(b,r)&&(m=b);var T=c.prototype=d.prototype=Object.create(m);function h(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var a;this._invoke=function(r,i){function s(){return new t((function(a,s){!function a(r,i,s,o){var p=u(e[r],e,i);if("throw"!==p.type){var y=p.arg,d=y.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){a("next",e,s,o)}),(function(e){a("throw",e,s,o)})):t.resolve(d).then((function(e){y.value=e,s(y)}),(function(e){return a("throw",e,s,o)}))}o(p.arg)}(r,i,a,s)}))}return a=a?a.then(s,s):s()}}function w(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return y;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var a=u(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var r=a.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,y):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function g(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function t(){for(;++a<e.length;)if(n.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return l.prototype=c,o(T,"constructor",c),o(c,"constructor",l),l.displayName=o(c,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,o(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},h(v.prototype),o(v.prototype,i,(function(){return this})),e.AsyncIterator=v,e.async=function(t,n,a,r,i){void 0===i&&(i=Promise);var s=new v(p(t,n,a,r),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},h(T),o(T,s,"Generator"),o(T,r,(function(){return this})),o(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var a=t.pop();if(a in e)return n.value=a,n.done=!1,n}return n.done=!0,n}},e.values=g,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function a(n,a){return s.type="throw",s.arg=e,t.next=n,a&&(t.method="next",t.arg=void 0),!!a}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),p=n.call(i,"finallyLoc");if(o&&p){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!p)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var a=this.tryEntries.length-1;a>=0;--a){var r=this.tryEntries[a];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var r=a.arg;x(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:g(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),y}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(l={exports:{}}),l.exports),m=[{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"}];(p=exports.ChainId||(exports.ChainId={}))[p.mainnet=1]="mainnet",p[p.ropsten=3]="ropsten",p[p.kovan=42]="kovan",p[p.goerli=5]="goerli",p[p.rinkeby=4]="rinkeby",p[p.optimism=10]="optimism",p[p.polygon=137]="polygon",p[p.arbitrum=42161]="arbitrum",(u=exports.Source||(exports.Source={})).Aggregator0x="0x",u.Aggregotor1inch="1inch";var f="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",b=((y={})[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",y[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",y[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",y[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",y),T=((d={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",d),h="0x77777feddddffc19ff86db637967013e6c6a116c",v="0x0d438f3b5175bebc262bf23753c1e53d03432bde",w="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",S=t.BigNumber.from("2").pow("256").sub("1").toString(),x=function(){var t=s(c.mark((function t(n,a,r,i){var s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(b[r],JSON.stringify(m),a),t.abrupt("return",s.deposit(o({},i,{value:n})));case 4:case"end":return t.stop()}}),t)})));return function(e,n,a,r){return t.apply(this,arguments)}}(),E=function(){var t=s(c.mark((function t(n,a,r,i){var s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),void 0===i&&(i={}),s=new e.Contract(b[r],JSON.stringify(m),a),t.abrupt("return",s.withdraw(n,i));case 4:case"end":return t.stop()}}),t)})));return function(e,n,a,r){return t.apply(this,arguments)}}(),g=[{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"}],A=function(){var e=s(c.mark((function e(t){var n,a,r,i,s,o,p,u,y,d,l,m,T,h,v,w,S,x,E;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.source,i=void 0===(r=t.chainId)?exports.ChainId.mainnet:r,s=t.fromAddress,p=t.buyTokenAddress,u=t.sellAmount,y=t.buyAmount,d=t.slippage,l=(o=t.sellTokenAddress).toLowerCase(),m=p.toLowerCase(),T=f.toLowerCase(),h=null==(n=b[i])?void 0:n.toLowerCase(),w=l===h&&m===T,!(v=l===T&&m===h)&&!w){e.next=9;break}return e.abrupt("return",{buyAmount:u||y,buyTokenAddress:p,defaultGasLimit:v?"30000":"40000",fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:u||y,sellAmountMinusFees:u||y,sellTokenAddress:o});case 9:if(S="https://swap.p.rainbow.me/quote?chainId="+i+"&fromAddress="+s+"&buyToken="+p+"&sellToken="+o+"&slippage="+d,a&&(S+="&source="+a),u?S+="&sellAmount="+u:y&&(S+="&buyAmount="+y),!isNaN(Number(u))||!isNaN(Number(y))){e.next=14;break}return e.abrupt("return",null);case 14:return p===f&&(S+="&destReceiver=0x00000000009726632680fb29d3f7a9734e3010e2"),void 0!==t.feePercentageBasisPoints&&(S+="&feePercentageBasisPoints="+t.feePercentageBasisPoints),e.next=18,fetch(S);case 18:return x=e.sent,e.next=21,x.json();case 21:if(!(E=e.sent).error){e.next=24;break}return e.abrupt("return",E);case 24:return e.abrupt("return",E);case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_=function(){var e=s(c.mark((function e(t){return c.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)}}(),M=function(){var t=s(c.mark((function t(n,a,r,i,s){var p,u,y,d,l,m,b,T,h,v,w,x,E,A,M;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(p=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",g,r),y=n.sellTokenAddress,d=n.buyTokenAddress,l=n.to,m=n.data,b=n.fee,T=n.value,h=n.sellAmount,v=n.feePercentageBasisPoints,w=f.toLowerCase(),(null==y?void 0:y.toLowerCase())!==w){t.next=9;break}return t.next=6,p.fillQuoteEthToToken(d,l,m,b,o({},a,{value:T}));case 6:u=t.sent,t.next=42;break;case 9:if((null==d?void 0:d.toLowerCase())!==w){t.next=27;break}if(!i){t.next=22;break}return t.next=13,_(r);case 13:return x=t.sent,t.next=16,V(r,y,n.from,p.address,S,x,s);case 16:return E=t.sent,t.next=19,p.fillQuoteTokenToEthWithPermit(y,l,m,h,v,E,o({},a,{value:T}));case 19:u=t.sent,t.next=25;break;case 22:return t.next=24,p.fillQuoteTokenToEth(y,l,m,h,v,o({},a,{value:T}));case 24:u=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,_(r);case 30:return A=t.sent,t.next=33,V(r,y,n.from,p.address,S,A,s);case 33:return M=t.sent,t.next=36,p.fillQuoteTokenToTokenWithPermit(y,d,l,m,h,b,M,o({},a,{value:T}));case 36:u=t.sent,t.next=42;break;case 39:return t.next=41,p.fillQuoteTokenToToken(y,d,l,m,h,b,o({},a,{value:T}));case 41:u=t.sent;case 42:return t.abrupt("return",u);case 43:case"end":return t.stop()}}),t)})));return function(e,n,a,r,i){return t.apply(this,arguments)}}(),C=[{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"}],k=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],I=function(){var e=s(c.mark((function e(t,n,r,i){return c.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:k},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),L=function(){var e=s(c.mark((function e(t,n,a,r){var i,s;return c.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,I(n,i,a,r);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!==a||-1===[h,v,w].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,a,r){return e.apply(this,arguments)}}(),N=function(){var e=s(c.mark((function e(t,n){return c.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"}],R=[{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,a,r,i,s){return U.apply(this,arguments)}function U(){return(U=s(c.mark((function i(s,o,p,u,y,d,l){var m,f,b,h,v,w,S,x,E,g,A,_,M;return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(m=T[l])?void 0:m.toLowerCase()),b=new e.Contract(o,f?C:P,s),i.next=4,b.name();case 4:return h=i.sent,i.next=7,Promise.all([N(b,p),L(b,h,l,b.address)]);case 7:return w=(v=i.sent)[0],S=v[1],x={nonce:Number(w.toString()),spender:u},f?(x.holder=p,x.allowed=!0,x.expiry=Number(d.toString())):(x.value=t.BigNumber.from(y).toHexString(),x.deadline=Number(d.toString()),x.owner=p),E={chainId:l,name:h,verifyingContract:b.address},null!==S&&(E.version=S),g={domain:E,message:x,primaryType:"Permit",types:{EIP712Domain:null!==S?k:O,Permit:f?D:R}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),_=a.signTypedData({data:g,privateKey:A,version:a.SignTypedDataVersion.V4}),M=n.splitSignature(_),i.abrupt("return",{deadline:d,isDaiStylePermit:f,nonce:w,r:M.r,s:M.s,v:M.v,value:x.value||t.BigNumber.from("0").toHexString()});case 20:case"end":return i.stop()}}),i)})))).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=T,exports.ETH_ADDRESS=f,exports.MAX_INT=S,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.TORN_ADDRESS=h,exports.USDC_ADDRESS="0x111111111117dc0aa78b770fa6a738034120c302",exports.VSP_ADDRESS=w,exports.WNXM_ADDRESS=v,exports.WRAPPED_ASSET=b,exports.fillQuote=M,exports.getQuote=A,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",g,a),i=t.sellTokenAddress,s=t.buyTokenAddress,p=t.to,u=t.data,y=t.fee,d=t.value,l=t.sellAmount,c=t.feePercentageBasisPoints,m=f.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:r.estimateGas.fillQuoteEthToToken,methodArgs:[s,p,u,y],methodName:"fillQuoteEthToToken",params:o({},n,{value:d}),router:r}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,p,u,l,c],methodName:"fillQuoteTokenToEth",params:o({},n,{value:d}),router:r}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,p,u,l,y],methodName:"fillQuoteTokenToToken",params:o({},n,{value:d}),router:r}},exports.getWrappedAssetMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(b[a],JSON.stringify(m),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=E,exports.wrapNativeAsset=x;
//# sourceMappingURL=swaps.cjs.production.min.js.map
{
"version": "0.1.13",
"version": "0.1.14",
"name": "@rainbow-me/swaps",

@@ -76,2 +76,5 @@ "license": "GPL-3.0",

"**/node-notifier": "8.0.1",
"**/minimist": "1.2.6",
"**/terser": "4.8.1",
"**/jsdom": "16.5.0",
"**/nanoid": "3.1.31",

@@ -78,0 +81,0 @@ "**/shelljs": "0.8.5",

@@ -38,12 +38,15 @@ import { Contract } from '@ethersproject/contracts';

*/
export const getQuote = async ({
source,
chainId = ChainId.mainnet,
fromAddress,
sellTokenAddress,
buyTokenAddress,
sellAmount,
buyAmount,
slippage,
}: QuoteParams): Promise<Quote | QuoteError | null> => {
export const getQuote = async (
params: QuoteParams
): Promise<Quote | QuoteError | null> => {
const {
source,
chainId = ChainId.mainnet,
fromAddress,
sellTokenAddress,
buyTokenAddress,
sellAmount,
buyAmount,
slippage,
} = params;
// When wrapping or unwrapping ETH, the quote is always 1:1

@@ -97,2 +100,8 @@ // so we don't need to call our backend.

// @ts-ignore
if (params.feePercentageBasisPoints !== undefined) {
// @ts-ignore
url += `&feePercentageBasisPoints=${params.feePercentageBasisPoints}`;
}
const response = await fetch(url);

@@ -99,0 +108,0 @@ const quote = await response.json();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc