@rainbow-me/swaps
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -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,d,l,y,c,m=(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 l?t:l).prototype),i=new g(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===d)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===d)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 d={};function l(){}function y(){}function c(){}var m={};o(m,r,(function(){return this}));var f=Object.getPrototypeOf,b=f&&f(f(E([])));b&&b!==t&&n.call(b,r)&&(m=b);var T=c.prototype=l.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 d=p.arg,l=d.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){a("next",e,s,o)}),(function(e){a("throw",e,s,o)})):t.resolve(l).then((function(e){d.value=e,s(d)}),(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 d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var a=u(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;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,d):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}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 g(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function E(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 y.prototype=c,o(T,"constructor",c),o(c,"constructor",y),y.displayName=o(c,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"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=E,g.prototype={constructor:g,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,d):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),d},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),d}},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:E(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)}}(c={exports:{}}),c.exports),f=[{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",(d=exports.SwapType||(exports.SwapType={})).normal="normal",d.crossChain="cross-chain";var b="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",T="https://swap.p.rainbow.me",h=((l={})[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",l[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",l[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",l[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",l),v=((y={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",y),w="0x77777feddddffc19ff86db637967013e6c6a116c",S="0x0d438f3b5175bebc262bf23753c1e53d03432bde",x="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",g=t.BigNumber.from("2").pow("256").sub("1").toString(),E=function(){var t=s(m.mark((function t(n,a,r,i){var s;return m.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(h[r],JSON.stringify(f),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)}}(),A=function(){var t=s(m.mark((function t(n,a,r,i){var s;return m.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(h[r],JSON.stringify(f),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)}}(),C=[{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"}],_=function(e){var t=e.sellTokenAddress,n=e.buyTokenAddress,a=e.buyAmount,r=e.sellAmount,i=e.fromAddress,s=e.source,p=e.feePercentageBasisPoints,u=e.slippage,d=new URLSearchParams(o({buyToken:n,chainId:String(e.chainId),fromAddress:i,sellToken:t,slippage:String(u),swapType:exports.SwapType.normal},s?{source:s}:{},r?{sellAmount:String(r)}:{buyAmount:String(a)},n===b?{destReceiver:"0x00000000009726632680fb29d3f7a9734e3010e2"}:{},void 0!==p?{feePercentageBasisPoints:String(p)}:{}));return T+"/quote?"+d.toString()},P=function(e){var t=e.toChainId,n=e.sellTokenAddress,a=e.sellAmount,r=e.fromAddress,i=e.slippage,s=e.refuel,o=new URLSearchParams({buyToken:e.buyTokenAddress,chainId:String(e.chainId),fromAddress:r,refuel:String(s),sellAmount:String(a),sellToken:n,slippage:String(i),swapType:exports.SwapType.crossChain,toChainId:String(t)});return T+"/quote?"+o.toString()},M=function(){var e=s(m.mark((function e(n){var a,r,i,s,o;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.chainId,r=n.toChainId,e.next=4,fetch("https://swap.p.rainbow.me/chains");case 4:return i=e.sent,e.next=7,i.json();case 7:if(s=e.sent.result.find((function(e){return e.chainId===a}))){e.next=11;break}return e.abrupt("return",null);case 11:if(o=s.limits.find((function(e){return e.chainId===r}))){e.next=14;break}return e.abrupt("return",null);case 14:return e.abrupt("return",t.BigNumber.from(o.minAmount).mul(2).toString());case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),k=function(){var e=s(m.mark((function e(t){var n,a,r,i,s,o,p,u,d,l,y,c,f,T,v,w,S,x,g,E;return m.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,d=t.buyAmount,l=t.slippage,y=t.feePercentageBasisPoints,c=(o=t.sellTokenAddress).toLowerCase(),f=p.toLowerCase(),T=b.toLowerCase(),v=null==(n=h[i])?void 0:n.toLowerCase(),S=c===v&&f===T,!(w=c===T&&f===v)&&!S){e.next=9;break}return e.abrupt("return",{buyAmount:u||d,buyTokenAddress:p,defaultGasLimit:w?"30000":"40000",fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:u||d,sellAmountMinusFees:u||d,sellTokenAddress:o});case 9:if(!isNaN(Number(u))||!isNaN(Number(d))){e.next=11;break}return e.abrupt("return",null);case 11:return x=_({buyAmount:d,buyTokenAddress:p,chainId:i,feePercentageBasisPoints:y,fromAddress:s,sellAmount:u,sellTokenAddress:o,slippage:l,source:a}),e.next=14,fetch(x);case 14:return g=e.sent,e.next=17,g.json();case 17:if(!(E=e.sent).error){e.next=20;break}return e.abrupt("return",E);case 20:return e.abrupt("return",E);case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),I=function(){var e=s(m.mark((function e(t){var n,a,r,i,s,o,p,u,d,l,y,c,f;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,r=t.toChainId,i=t.fromAddress,s=t.sellTokenAddress,o=t.buyTokenAddress,u=t.slippage,l=void 0!==(d=t.refuel)&&d,(p=t.sellAmount)&&r){e.next=3;break}return e.abrupt("return",null);case 3:return y=P({buyTokenAddress:o,chainId:a,fromAddress:i,refuel:l,sellAmount:p,sellTokenAddress:s,slippage:u,toChainId:r}),e.next=6,fetch(y);case 6:return c=e.sent,e.next=9,c.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)}}(),L=function(){var e=s(m.mark((function e(t){return m.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)}}(),R=function(){var t=s(m.mark((function t(n,a,r,i,s){var p,u,d,l,y,c,f,T,h,v,w,S,x,E,A;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(p=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",C,r),d=n.sellTokenAddress,l=n.buyTokenAddress,y=n.to,c=n.data,f=n.fee,T=n.value,h=n.sellAmount,v=n.feePercentageBasisPoints,w=b.toLowerCase(),(null==d?void 0:d.toLowerCase())!==w){t.next=9;break}return t.next=6,p.fillQuoteEthToToken(l,y,c,f,o({},a,{value:T}));case 6:u=t.sent,t.next=42;break;case 9:if((null==l?void 0:l.toLowerCase())!==w){t.next=27;break}if(!i){t.next=22;break}return t.next=13,L(r);case 13:return S=t.sent,t.next=16,X(r,d,n.from,p.address,g,S,s);case 16:return x=t.sent,t.next=19,p.fillQuoteTokenToEthWithPermit(d,y,c,h,v,x,o({},a,{value:T}));case 19:u=t.sent,t.next=25;break;case 22:return t.next=24,p.fillQuoteTokenToEth(d,y,c,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,L(r);case 30:return E=t.sent,t.next=33,X(r,d,n.from,p.address,g,E,s);case 33:return A=t.sent,t.next=36,p.fillQuoteTokenToTokenWithPermit(d,l,y,c,h,f,A,o({},a,{value:T}));case 36:u=t.sent,t.next=42;break;case 39:return t.next=41,p.fillQuoteTokenToToken(d,l,y,c,h,f,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)}}(),N=function(){var e=s(m.mark((function e(t,n,a){var r,i,s,p;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,i=t.data,s=t.from,p=t.value,e.next=3,a.sendTransaction(o({data:i,from:s,to:r},o({},n,{value:p})));case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),O=[{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"}],D=[{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"}],V=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],U=function(){var e=s(m.mark((function e(t,n,r,i){return m.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:V},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),B=function(){var e=s(m.mark((function e(t,n,a,r){var i,s;return m.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,U(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===[w,S,x].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)}}(),W=function(){var e=s(m.mark((function e(t,n){return m.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)}}(),H=[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],F=[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],Q=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function X(e,t,n,a,r,i,s){return j.apply(this,arguments)}function j(){return(j=s(m.mark((function i(s,o,p,u,d,l,y){var c,f,b,T,h,w,S,x,g,E,A,C,_;return m.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(c=v[y])?void 0:c.toLowerCase()),b=new e.Contract(o,f?O:D,s),i.next=4,b.name();case 4:return T=i.sent,i.next=7,Promise.all([W(b,p),B(b,T,y,b.address)]);case 7:return w=(h=i.sent)[0],S=h[1],x={nonce:Number(w.toString()),spender:u},f?(x.holder=p,x.allowed=!0,x.expiry=Number(l.toString())):(x.value=t.BigNumber.from(d).toHexString(),x.deadline=Number(l.toString()),x.owner=p),g={chainId:y,name:T,verifyingContract:b.address},null!==S&&(g.version=S),E={domain:g,message:x,primaryType:"Permit",types:{EIP712Domain:null!==S?V:H,Permit:f?Q:F}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),C=a.signTypedData({data:E,privateKey:A,version:a.SignTypedDataVersion.V4}),_=n.splitSignature(C),i.abrupt("return",{deadline:l,isDaiStylePermit:f,nonce:w,r:_.r,s:_.s,v:_.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=T,exports.DAI=v,exports.ETH_ADDRESS=b,exports.MAX_INT=g,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.SOCKET_REGISTRY_CONTRACT_ADDRESSESS="0xc30141B657f4216252dc59Af2e7CdB9D8792e1B0",exports.TORN_ADDRESS=w,exports.USDC_ADDRESS="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",exports.VSP_ADDRESS=x,exports.WNXM_ADDRESS=S,exports.WRAPPED_ASSET=h,exports.fillCrosschainQuote=N,exports.fillQuote=R,exports.getCrosschainQuote=I,exports.getCrosschainQuoteExecutionDetails=function(e,t,n){var a=e.value;return{method:n.estimateGas({data:e.data,from:e.from,to:e.to,value:a}),params:o({},t,{value:a})}},exports.getMinRefuelAmount=M,exports.getQuote=k,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",C,a),i=t.sellTokenAddress,s=t.buyTokenAddress,p=t.to,u=t.data,d=t.fee,l=t.value,y=t.sellAmount,c=t.feePercentageBasisPoints,m=b.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:r.estimateGas.fillQuoteEthToToken,methodArgs:[s,p,u,d],methodName:"fillQuoteEthToToken",params:o({},n,{value:l}),router:r}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,p,u,y,c],methodName:"fillQuoteTokenToEth",params:o({},n,{value:l}),router:r}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,p,u,y,d],methodName:"fillQuoteTokenToToken",params:o({},n,{value:l}),router:r}},exports.getWrappedAssetMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(h[a],JSON.stringify(f),n).estimateGas[t]},exports.signPermit=X,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=A,exports.wrapNativeAsset=E; | ||
"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,d,l,y,c,m=(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 l?t:l).prototype),i=new g(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===d)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===d)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 d={};function l(){}function y(){}function c(){}var m={};o(m,r,(function(){return this}));var f=Object.getPrototypeOf,b=f&&f(f(E([])));b&&b!==t&&n.call(b,r)&&(m=b);var T=c.prototype=l.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 d=p.arg,l=d.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){a("next",e,s,o)}),(function(e){a("throw",e,s,o)})):t.resolve(l).then((function(e){d.value=e,s(d)}),(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 d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var a=u(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;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,d):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}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 g(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function E(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 y.prototype=c,o(T,"constructor",c),o(c,"constructor",y),y.displayName=o(c,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"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=E,g.prototype={constructor:g,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,d):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),d},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),d}},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:E(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)}}(c={exports:{}}),c.exports),f=[{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",(d=exports.SwapType||(exports.SwapType={})).normal="normal",d.crossChain="cross-chain";var b="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",T="https://swap.p.rainbow.me",h=((l={})[""+exports.ChainId.arbitrum]="0x82af49447d8a07e3bd95bd0d56f35241523fbab1",l[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",l[""+exports.ChainId.optimism]="0x4200000000000000000000000000000000000006",l[""+exports.ChainId.polygon]="0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",l),v=((y={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",y),w="0x77777feddddffc19ff86db637967013e6c6a116c",S="0x0d438f3b5175bebc262bf23753c1e53d03432bde",x="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",g=t.BigNumber.from("2").pow("256").sub("1").toString(),E=function(){var t=s(m.mark((function t(n,a,r,i){var s;return m.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(h[r],JSON.stringify(f),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)}}(),A=function(){var t=s(m.mark((function t(n,a,r,i){var s;return m.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(h[r],JSON.stringify(f),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)}}(),C=[{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"}],_=function(e){var t=e.sellTokenAddress,n=e.buyTokenAddress,a=e.buyAmount,r=e.sellAmount,i=e.fromAddress,s=e.source,p=e.feePercentageBasisPoints,u=e.slippage,d=new URLSearchParams(o({buyToken:n,chainId:String(e.chainId),fromAddress:i,sellToken:t,slippage:String(u),swapType:exports.SwapType.normal},s?{source:s}:{},r?{sellAmount:String(r)}:{buyAmount:String(a)},n===b?{destReceiver:"0x00000000009726632680fb29d3f7a9734e3010e2"}:{},void 0!==p?{feePercentageBasisPoints:String(p)}:{}));return T+"/v1/quote?"+d.toString()},P=function(e){var t=e.toChainId,n=e.sellTokenAddress,a=e.sellAmount,r=e.fromAddress,i=e.slippage,s=e.refuel,o=new URLSearchParams({buyToken:e.buyTokenAddress,chainId:String(e.chainId),fromAddress:r,refuel:String(s),sellAmount:String(a),sellToken:n,slippage:String(i),swapType:exports.SwapType.crossChain,toChainId:String(t)});return T+"/v1/quote?"+o.toString()},M=function(){var e=s(m.mark((function e(n){var a,r,i,s,o;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.chainId,r=n.toChainId,e.next=4,fetch("https://swap.p.rainbow.me/v1/chains");case 4:return i=e.sent,e.next=7,i.json();case 7:if(s=e.sent.result.find((function(e){return e.chainId===a}))){e.next=11;break}return e.abrupt("return",null);case 11:if(o=s.limits.find((function(e){return e.chainId===r}))){e.next=14;break}return e.abrupt("return",null);case 14:return e.abrupt("return",t.BigNumber.from(o.minAmount).mul(2).toString());case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),k=function(){var e=s(m.mark((function e(t){var n,a,r,i,s,o,p,u,d,l,y,c,f,T,v,w,S,x,g,E;return m.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,d=t.buyAmount,l=t.slippage,y=t.feePercentageBasisPoints,c=(o=t.sellTokenAddress).toLowerCase(),f=p.toLowerCase(),T=b.toLowerCase(),v=null==(n=h[i])?void 0:n.toLowerCase(),S=c===v&&f===T,!(w=c===T&&f===v)&&!S){e.next=9;break}return e.abrupt("return",{buyAmount:u||d,buyTokenAddress:p,defaultGasLimit:w?"30000":"40000",fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:u||d,sellAmountMinusFees:u||d,sellTokenAddress:o});case 9:if(!isNaN(Number(u))||!isNaN(Number(d))){e.next=11;break}return e.abrupt("return",null);case 11:return x=_({buyAmount:d,buyTokenAddress:p,chainId:i,feePercentageBasisPoints:y,fromAddress:s,sellAmount:u,sellTokenAddress:o,slippage:l,source:a}),e.next=14,fetch(x);case 14:return g=e.sent,e.next=17,g.json();case 17:if(!(E=e.sent).error){e.next=20;break}return e.abrupt("return",E);case 20:return e.abrupt("return",E);case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),I=function(){var e=s(m.mark((function e(t){var n,a,r,i,s,o,p,u,d,l,y,c,f;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=void 0===(n=t.chainId)?exports.ChainId.mainnet:n,r=t.toChainId,i=t.fromAddress,s=t.sellTokenAddress,o=t.buyTokenAddress,u=t.slippage,l=void 0!==(d=t.refuel)&&d,(p=t.sellAmount)&&r){e.next=3;break}return e.abrupt("return",null);case 3:return y=P({buyTokenAddress:o,chainId:a,fromAddress:i,refuel:l,sellAmount:p,sellTokenAddress:s,slippage:u,toChainId:r}),e.next=6,fetch(y);case 6:return c=e.sent,e.next=9,c.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)}}(),L=function(){var e=s(m.mark((function e(t){return m.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)}}(),R=function(){var t=s(m.mark((function t(n,a,r,i,s){var p,u,d,l,y,c,f,T,h,v,w,S,x,E,A;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(p=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",C,r),d=n.sellTokenAddress,l=n.buyTokenAddress,y=n.to,c=n.data,f=n.fee,T=n.value,h=n.sellAmount,v=n.feePercentageBasisPoints,w=b.toLowerCase(),(null==d?void 0:d.toLowerCase())!==w){t.next=9;break}return t.next=6,p.fillQuoteEthToToken(l,y,c,f,o({},a,{value:T}));case 6:u=t.sent,t.next=42;break;case 9:if((null==l?void 0:l.toLowerCase())!==w){t.next=27;break}if(!i){t.next=22;break}return t.next=13,L(r);case 13:return S=t.sent,t.next=16,X(r,d,n.from,p.address,g,S,s);case 16:return x=t.sent,t.next=19,p.fillQuoteTokenToEthWithPermit(d,y,c,h,v,x,o({},a,{value:T}));case 19:u=t.sent,t.next=25;break;case 22:return t.next=24,p.fillQuoteTokenToEth(d,y,c,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,L(r);case 30:return E=t.sent,t.next=33,X(r,d,n.from,p.address,g,E,s);case 33:return A=t.sent,t.next=36,p.fillQuoteTokenToTokenWithPermit(d,l,y,c,h,f,A,o({},a,{value:T}));case 36:u=t.sent,t.next=42;break;case 39:return t.next=41,p.fillQuoteTokenToToken(d,l,y,c,h,f,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)}}(),N=function(){var e=s(m.mark((function e(t,n,a){var r,i,s,p;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,i=t.data,s=t.from,p=t.value,e.next=3,a.sendTransaction(o({data:i,from:s,to:r},o({},n,{value:p})));case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),O=[{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"}],D=[{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"}],V=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],U=function(){var e=s(m.mark((function e(t,n,r,i){return m.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:V},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),B=function(){var e=s(m.mark((function e(t,n,a,r){var i,s;return m.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,U(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===[w,S,x].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)}}(),W=function(){var e=s(m.mark((function e(t,n){return m.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)}}(),H=[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],F=[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],Q=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function X(e,t,n,a,r,i,s){return j.apply(this,arguments)}function j(){return(j=s(m.mark((function i(s,o,p,u,d,l,y){var c,f,b,T,h,w,S,x,g,E,A,C,_;return m.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(c=v[y])?void 0:c.toLowerCase()),b=new e.Contract(o,f?O:D,s),i.next=4,b.name();case 4:return T=i.sent,i.next=7,Promise.all([W(b,p),B(b,T,y,b.address)]);case 7:return w=(h=i.sent)[0],S=h[1],x={nonce:Number(w.toString()),spender:u},f?(x.holder=p,x.allowed=!0,x.expiry=Number(l.toString())):(x.value=t.BigNumber.from(d).toHexString(),x.deadline=Number(l.toString()),x.owner=p),g={chainId:y,name:T,verifyingContract:b.address},null!==S&&(g.version=S),E={domain:g,message:x,primaryType:"Permit",types:{EIP712Domain:null!==S?V:H,Permit:f?Q:F}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),C=a.signTypedData({data:E,privateKey:A,version:a.SignTypedDataVersion.V4}),_=n.splitSignature(C),i.abrupt("return",{deadline:l,isDaiStylePermit:f,nonce:w,r:_.r,s:_.s,v:_.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=T,exports.DAI=v,exports.ETH_ADDRESS=b,exports.MAX_INT=g,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.SOCKET_REGISTRY_CONTRACT_ADDRESSESS="0xc30141B657f4216252dc59Af2e7CdB9D8792e1B0",exports.TORN_ADDRESS=w,exports.USDC_ADDRESS="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",exports.VSP_ADDRESS=x,exports.WNXM_ADDRESS=S,exports.WRAPPED_ASSET=h,exports.fillCrosschainQuote=N,exports.fillQuote=R,exports.getCrosschainQuote=I,exports.getCrosschainQuoteExecutionDetails=function(e,t,n){var a=e.value;return{method:n.estimateGas({data:e.data,from:e.from,to:e.to,value:a}),params:o({},t,{value:a})}},exports.getMinRefuelAmount=M,exports.getQuote=k,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",C,a),i=t.sellTokenAddress,s=t.buyTokenAddress,p=t.to,u=t.data,d=t.fee,l=t.value,y=t.sellAmount,c=t.feePercentageBasisPoints,m=b.toLowerCase();return(null==i?void 0:i.toLowerCase())===m?{method:r.estimateGas.fillQuoteEthToToken,methodArgs:[s,p,u,d],methodName:"fillQuoteEthToToken",params:o({},n,{value:l}),router:r}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,p,u,y,c],methodName:"fillQuoteTokenToEth",params:o({},n,{value:l}),router:r}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,p,u,y,d],methodName:"fillQuoteTokenToToken",params:o({},n,{value:l}),router:r}},exports.getWrappedAssetMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(h[a],JSON.stringify(f),n).estimateGas[t]},exports.signPermit=X,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=A,exports.wrapNativeAsset=E; | ||
//# sourceMappingURL=swaps.cjs.production.min.js.map |
{ | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"name": "@rainbow-me/swaps", | ||
@@ -4,0 +4,0 @@ "license": "GPL-3.0", |
@@ -87,3 +87,3 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber'; | ||
}); | ||
return API_BASE_URL + '/quote?' + searchParams.toString(); | ||
return `${API_BASE_URL}/v1/quote?` + searchParams.toString(); | ||
}; | ||
@@ -134,3 +134,3 @@ | ||
}); | ||
return API_BASE_URL + '/quote?' + searchParams.toString(); | ||
return `${API_BASE_URL}/v1/quote?` + searchParams.toString(); | ||
}; | ||
@@ -150,3 +150,3 @@ | ||
const { chainId, toChainId } = params; | ||
const url = `${API_BASE_URL}/chains`; | ||
const url = `${API_BASE_URL}/v1/chains`; | ||
const response = await fetch(url); | ||
@@ -153,0 +153,0 @@ const chainsData = (await response.json()) as SocketChainsData; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
628985