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

@rainbow-me/swaps

Package Overview
Dependencies
Maintainers
9
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.1 to 0.1.2

4

dist/quotes.d.ts
import { StaticJsonRpcProvider } from '@ethersproject/providers';
import { Transaction } from '@ethersproject/transactions';
import { Wallet } from '@ethersproject/wallet';
import { ChainId, Quote, QuoteExecutionDetails, QuoteParams, TransactionOptions } from './types';
import { ChainId, Quote, QuoteError, QuoteExecutionDetails, QuoteParams, TransactionOptions } from './types';
/**

@@ -19,3 +19,3 @@ * Function to get a quote from rainbow's swap aggregator backend

*/
export declare const getQuote: ({ source, chainId, fromAddress, sellTokenAddress, buyTokenAddress, sellAmount, buyAmount, slippage, }: QuoteParams) => Promise<Quote | null>;
export declare const getQuote: ({ source, chainId, fromAddress, sellTokenAddress, buyTokenAddress, sellAmount, buyAmount, slippage, }: 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),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).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,u,"next",e)}function u(e){i(s,a,r,o,u,"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 u,p,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 u(e,t,n,a){var r=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new k(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=x(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 u=p(e,t,n);if("normal"===u.type){if(a=n.done?"completed":"suspendedYield",u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a="completed",n.method="throw",n.arg=u.arg)}}}(e,n,i),r}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var y={};function d(){}function l(){}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=d.prototype=Object.create(m);function v(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function h(e,t){var a;this._invoke=function(r,i){function s(){return new t((function(a,s){!function a(r,i,s,o){var u=p(e[r],e,i);if("throw"!==u.type){var y=u.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(u.arg)}(r,i,a,s)}))}return a=a?a.then(s,s):s()}}function x(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,x(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=p(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 w(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 g(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,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 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}},v(h.prototype),o(h.prototype,i,(function(){return this})),e.AsyncIterator=h,e.async=function(t,n,a,r,i){void 0===i&&(i=Promise);var s=new h(u(t,n,a,r),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},v(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,k.prototype={constructor:k,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(g),!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"),u=n.call(i,"finallyLoc");if(o&&u){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(!u)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),g(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;g(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),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"}];(u=exports.ChainId||(exports.ChainId={}))[u.mainnet=1]="mainnet",u[u.ropsten=3]="ropsten",u[u.kovan=42]="kovan",u[u.goerli=5]="goerli",u[u.rinkeby=4]="rinkeby",u[u.optimism=10]="optimism",u[u.polygon=137]="polygon",u[u.arbitrum=42161]="arbitrum",(p=exports.Source||(exports.Source={})).Aggregator0x="0x",p.Aggregotor1inch="1inch";var f="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",b="https://swap-aggregator.api.p.rainbow.me",T=((y={})[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",y),v=((d={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",d),h="0x77777feddddffc19ff86db637967013e6c6a116c",x="0x0d438f3b5175bebc262bf23753c1e53d03432bde",w="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",g=t.BigNumber.from("2").pow("256").sub("1").toString(),k=function(){var t=s(c.mark((function t(n,a,r){var i;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),i=new e.Contract(T[r],JSON.stringify(m),a),t.abrupt("return",i.deposit({value:n}));case 3:case"end":return t.stop()}}),t)})));return function(e,n,a){return t.apply(this,arguments)}}(),E=function(){var t=s(c.mark((function t(n,a,r){var i;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),i=new e.Contract(T[r],JSON.stringify(m),a),t.abrupt("return",i.withdraw(n));case 3:case"end":return t.stop()}}),t)})));return function(e,n,a){return t.apply(this,arguments)}}(),A=[{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"}],M=function(){var e=s(c.mark((function e(t){var n,a,r,i,s,o,u,p,y,d,l,m,v,h,x,w;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,u=t.buyTokenAddress,p=t.sellAmount,y=t.buyAmount,d=t.slippage,l=(o=t.sellTokenAddress).toLowerCase(),m=u.toLowerCase(),v=f.toLowerCase(),h=null==(n=T[i])?void 0:n.toLowerCase(),!(l===v&&m===h||l===h&&m===v)){e.next=7;break}return e.abrupt("return",{buyAmount:p||y,buyTokenAddress:u,fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:p||y,sellAmountMinusFees:p||y,sellTokenAddress:o});case 7:if(x=b+"/quote?chainId="+i+"&fromAddress="+s+"&buyToken="+u+"&sellToken="+o+"&slippage="+d,a&&(x+="&source="+a),p?x+="&sellAmount="+p:y&&(x+="&buyAmount="+y),!isNaN(Number(p))||!isNaN(Number(y))){e.next=12;break}return e.abrupt("return",null);case 12:return u===f&&(x+="&destReceiver=0x00000000009726632680fb29d3f7a9734e3010e2"),e.next=15,fetch(x);case 15:return w=e.sent,e.next=18,w.json();case 18:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),S=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)}}(),P=function(){var t=s(c.mark((function t(n,a,r,i,s){var u,p,y,d,l,m,b,T,v,h,x,w,k,E,M;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",A,r),y=n.sellTokenAddress,d=n.buyTokenAddress,l=n.to,m=n.data,b=n.fee,T=n.value,v=n.sellAmount,h=n.feePercentageBasisPoints,x=f.toLowerCase(),(null==y?void 0:y.toLowerCase())!==x){t.next=9;break}return t.next=6,u.fillQuoteEthToToken(d,l,m,b,o({},a,{value:T}));case 6:p=t.sent,t.next=42;break;case 9:if((null==d?void 0:d.toLowerCase())!==x){t.next=27;break}if(!i){t.next=22;break}return t.next=13,S(r);case 13:return w=t.sent,t.next=16,Q(r,y,n.from,u.address,g,w,s);case 16:return k=t.sent,t.next=19,u.fillQuoteTokenToEthWithPermit(y,l,m,v,h,k,o({},a,{value:T}));case 19:p=t.sent,t.next=25;break;case 22:return t.next=24,u.fillQuoteTokenToEth(y,l,m,v,h,o({},a,{value:T}));case 24:p=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,S(r);case 30:return E=t.sent,t.next=33,Q(r,y,n.from,u.address,g,E,s);case 33:return M=t.sent,t.next=36,u.fillQuoteTokenToTokenWithPermit(y,d,l,m,v,b,M,o({},a,{value:T}));case 36:p=t.sent,t.next=42;break;case 39:return t.next=41,u.fillQuoteTokenToToken(y,d,l,m,v,b,o({},a,{value:T}));case 41:p=t.sent;case 42:return t.abrupt("return",p);case 43:case"end":return t.stop()}}),t)})));return function(e,n,a,r,i){return t.apply(this,arguments)}}(),L=[{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"}],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:[{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"}],O=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],D=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:O},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),_=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,D(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,x,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)}}(),I=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)}}(),N=[{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"}],j=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function Q(e,t,n,a,r,i,s){return B.apply(this,arguments)}function B(){return(B=s(c.mark((function i(s,o,u,p,y,d,l){var m,f,b,T,h,x,w,g,k,E,A,M,S;return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(m=v[l])?void 0:m.toLowerCase()),b=new e.Contract(o,f?L:C,s),i.next=4,b.name();case 4:return T=i.sent,i.next=7,Promise.all([I(b,u),_(b,T,l,b.address)]);case 7:return x=(h=i.sent)[0],w=h[1],g={nonce:Number(x.toString()),spender:p},f?(g.holder=u,g.allowed=!0,g.expiry=Number(d.toString())):(g.value=t.BigNumber.from(y).toHexString(),g.deadline=Number(d.toString()),g.owner=u),k={chainId:l,name:T,verifyingContract:b.address},null!==w&&(k.version=w),E={domain:k,message:g,primaryType:"Permit",types:{EIP712Domain:null!==w?O:N,Permit:f?j:R}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),M=a.signTypedData({data:E,privateKey:A,version:a.SignTypedDataVersion.V4}),S=n.splitSignature(M),i.abrupt("return",{deadline:d,isDaiStylePermit:f,nonce:x,r:S.r,s:S.s,v:S.v,value:g.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,"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9":!0,"0x888888435fde8e7d4c54cab67f206e4199454c60":!0,"0x888888888889c00c67689029d7856aac1065ec11":!0,"0x88acdd2a6425c3faae4bc9650fd7e27e0bebb7ab":!0,"0x956f47f50a910163d8bf957cf5846d573e7f87ca":!0,"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":!0,"0xba100000625a3754423978a60c9317c58a424e3d":!0,"0xc7283b66eb1eb5fb86327f08e1b5816b0720212b":!0},exports.API_BASE_URL=b,exports.DAI=v,exports.ETH_ADDRESS=f,exports.MAX_INT=g,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.TORN_ADDRESS=h,exports.USDC_ADDRESS="0x111111111117dc0aa78b770fa6a738034120c302",exports.VSP_ADDRESS=w,exports.WETH=T,exports.WNXM_ADDRESS=x,exports.fillQuote=P,exports.geWethMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(T[a],JSON.stringify(m),n).estimateGas[t]},exports.getQuote=M,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",A,a),i=t.sellTokenAddress,s=t.buyTokenAddress,u=t.to,p=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,u,p,y],params:o({},n,{value:d})}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,u,p,l,c],params:o({},n,{value:d})}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,u,p,l,y],params:o({},n,{value:d})}},exports.signPermit=Q,exports.unwrapWeth=E,exports.wrapEth=k;
"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),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).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,u,"next",e)}function u(e){i(s,a,r,o,u,"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 u,p,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 u(e,t,n,a){var r=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new k(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=x(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 u=p(e,t,n);if("normal"===u.type){if(a=n.done?"completed":"suspendedYield",u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a="completed",n.method="throw",n.arg=u.arg)}}}(e,n,i),r}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var y={};function d(){}function l(){}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=d.prototype=Object.create(m);function v(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function h(e,t){var a;this._invoke=function(r,i){function s(){return new t((function(a,s){!function a(r,i,s,o){var u=p(e[r],e,i);if("throw"!==u.type){var y=u.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(u.arg)}(r,i,a,s)}))}return a=a?a.then(s,s):s()}}function x(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,x(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=p(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 w(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 g(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,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 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}},v(h.prototype),o(h.prototype,i,(function(){return this})),e.AsyncIterator=h,e.async=function(t,n,a,r,i){void 0===i&&(i=Promise);var s=new h(u(t,n,a,r),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},v(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,k.prototype={constructor:k,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(g),!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"),u=n.call(i,"finallyLoc");if(o&&u){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(!u)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),g(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;g(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),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"}];(u=exports.ChainId||(exports.ChainId={}))[u.mainnet=1]="mainnet",u[u.ropsten=3]="ropsten",u[u.kovan=42]="kovan",u[u.goerli=5]="goerli",u[u.rinkeby=4]="rinkeby",u[u.optimism=10]="optimism",u[u.polygon=137]="polygon",u[u.arbitrum=42161]="arbitrum",(p=exports.Source||(exports.Source={})).Aggregator0x="0x",p.Aggregotor1inch="1inch";var f="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",b="https://swap-aggregator.api.p.rainbow.me",T=((y={})[""+exports.ChainId.mainnet]="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",y),v=((d={})[""+exports.ChainId.mainnet]="0x6b175474e89094c44da98b954eedeac495271d0f",d),h="0x77777feddddffc19ff86db637967013e6c6a116c",x="0x0d438f3b5175bebc262bf23753c1e53d03432bde",w="0x1b40183efb4dd766f11bda7a7c3ad8982e998421",g=t.BigNumber.from("2").pow("256").sub("1").toString(),k=function(){var t=s(c.mark((function t(n,a,r){var i;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),i=new e.Contract(T[r],JSON.stringify(m),a),t.abrupt("return",i.deposit({value:n}));case 3:case"end":return t.stop()}}),t)})));return function(e,n,a){return t.apply(this,arguments)}}(),E=function(){var t=s(c.mark((function t(n,a,r){var i;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=exports.ChainId.mainnet),i=new e.Contract(T[r],JSON.stringify(m),a),t.abrupt("return",i.withdraw(n));case 3:case"end":return t.stop()}}),t)})));return function(e,n,a){return t.apply(this,arguments)}}(),A=[{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"}],M=function(){var e=s(c.mark((function e(t){var n,a,r,i,s,o,u,p,y,d,l,m,v,h,x,w,g;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,u=t.buyTokenAddress,p=t.sellAmount,y=t.buyAmount,d=t.slippage,l=(o=t.sellTokenAddress).toLowerCase(),m=u.toLowerCase(),v=f.toLowerCase(),h=null==(n=T[i])?void 0:n.toLowerCase(),!(l===v&&m===h||l===h&&m===v)){e.next=7;break}return e.abrupt("return",{buyAmount:p||y,buyTokenAddress:u,fee:0,feePercentageBasisPoints:0,from:s,inputTokenDecimals:18,outputTokenDecimals:18,sellAmount:p||y,sellAmountMinusFees:p||y,sellTokenAddress:o});case 7:if(x=b+"/quote?chainId="+i+"&fromAddress="+s+"&buyToken="+u+"&sellToken="+o+"&slippage="+d,a&&(x+="&source="+a),p?x+="&sellAmount="+p:y&&(x+="&buyAmount="+y),!isNaN(Number(p))||!isNaN(Number(y))){e.next=12;break}return e.abrupt("return",null);case 12:return u===f&&(x+="&destReceiver=0x00000000009726632680fb29d3f7a9734e3010e2"),e.next=15,fetch(x);case 15:return w=e.sent,e.next=18,w.json();case 18:if(!(g=e.sent).error){e.next=21;break}return e.abrupt("return",g);case 21:return e.abrupt("return",g);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),S=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)}}(),P=function(){var t=s(c.mark((function t(n,a,r,i,s){var u,p,y,d,l,m,b,T,v,h,x,w,k,E,M;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",A,r),y=n.sellTokenAddress,d=n.buyTokenAddress,l=n.to,m=n.data,b=n.fee,T=n.value,v=n.sellAmount,h=n.feePercentageBasisPoints,x=f.toLowerCase(),(null==y?void 0:y.toLowerCase())!==x){t.next=9;break}return t.next=6,u.fillQuoteEthToToken(d,l,m,b,o({},a,{value:T}));case 6:p=t.sent,t.next=42;break;case 9:if((null==d?void 0:d.toLowerCase())!==x){t.next=27;break}if(!i){t.next=22;break}return t.next=13,S(r);case 13:return w=t.sent,t.next=16,Q(r,y,n.from,u.address,g,w,s);case 16:return k=t.sent,t.next=19,u.fillQuoteTokenToEthWithPermit(y,l,m,v,h,k,o({},a,{value:T}));case 19:p=t.sent,t.next=25;break;case 22:return t.next=24,u.fillQuoteTokenToEth(y,l,m,v,h,o({},a,{value:T}));case 24:p=t.sent;case 25:t.next=42;break;case 27:if(!i){t.next=39;break}return t.next=30,S(r);case 30:return E=t.sent,t.next=33,Q(r,y,n.from,u.address,g,E,s);case 33:return M=t.sent,t.next=36,u.fillQuoteTokenToTokenWithPermit(y,d,l,m,v,b,M,o({},a,{value:T}));case 36:p=t.sent,t.next=42;break;case 39:return t.next=41,u.fillQuoteTokenToToken(y,d,l,m,v,b,o({},a,{value:T}));case 41:p=t.sent;case 42:return t.abrupt("return",p);case 43:case"end":return t.stop()}}),t)})));return function(e,n,a,r,i){return t.apply(this,arguments)}}(),L=[{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"}],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:[{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"}],O=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],D=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:O},a.SignTypedDataVersion.V4).toString("hex"));case 1:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),_=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,D(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,x,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)}}(),I=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)}}(),N=[{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"}],j=[{name:"holder",type:"address"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"expiry",type:"uint256"},{name:"allowed",type:"bool"}];function Q(e,t,n,a,r,i,s){return B.apply(this,arguments)}function B(){return(B=s(c.mark((function i(s,o,u,p,y,d,l){var m,f,b,T,h,x,w,g,k,E,A,M,S;return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return f=o.toLowerCase()===(null==(m=v[l])?void 0:m.toLowerCase()),b=new e.Contract(o,f?L:C,s),i.next=4,b.name();case 4:return T=i.sent,i.next=7,Promise.all([I(b,u),_(b,T,l,b.address)]);case 7:return x=(h=i.sent)[0],w=h[1],g={nonce:Number(x.toString()),spender:p},f?(g.holder=u,g.allowed=!0,g.expiry=Number(d.toString())):(g.value=t.BigNumber.from(y).toHexString(),g.deadline=Number(d.toString()),g.owner=u),k={chainId:l,name:T,verifyingContract:b.address},null!==w&&(k.version=w),E={domain:k,message:g,primaryType:"Permit",types:{EIP712Domain:null!==w?O:N,Permit:f?j:R}},A=r.toBuffer(r.addHexPrefix(s.privateKey)),M=a.signTypedData({data:E,privateKey:A,version:a.SignTypedDataVersion.V4}),S=n.splitSignature(M),i.abrupt("return",{deadline:d,isDaiStylePermit:f,nonce:x,r:S.r,s:S.s,v:S.v,value:g.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,"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9":!0,"0x888888435fde8e7d4c54cab67f206e4199454c60":!0,"0x888888888889c00c67689029d7856aac1065ec11":!0,"0x88acdd2a6425c3faae4bc9650fd7e27e0bebb7ab":!0,"0x956f47f50a910163d8bf957cf5846d573e7f87ca":!0,"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":!0,"0xba100000625a3754423978a60c9317c58a424e3d":!0,"0xc7283b66eb1eb5fb86327f08e1b5816b0720212b":!0},exports.API_BASE_URL=b,exports.DAI=v,exports.ETH_ADDRESS=f,exports.MAX_INT=g,exports.PERMIT_EXPIRATION_TS=3600,exports.RAINBOW_ROUTER_CONTRACT_ADDRESS="0x00000000009726632680fb29d3f7a9734e3010e2",exports.TORN_ADDRESS=h,exports.USDC_ADDRESS="0x111111111117dc0aa78b770fa6a738034120c302",exports.VSP_ADDRESS=w,exports.WETH=T,exports.WNXM_ADDRESS=x,exports.fillQuote=P,exports.geWethMethod=function(t,n,a){return void 0===a&&(a=exports.ChainId.mainnet),new e.Contract(T[a],JSON.stringify(m),n).estimateGas[t]},exports.getQuote=M,exports.getQuoteExecutionDetails=function(t,n,a){var r=new e.Contract("0x00000000009726632680fb29d3f7a9734e3010e2",A,a),i=t.sellTokenAddress,s=t.buyTokenAddress,u=t.to,p=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,u,p,y],params:o({},n,{value:d})}:(null==s?void 0:s.toLowerCase())===m?{method:r.estimateGas.fillQuoteTokenToEth,methodArgs:[i,u,p,l,c],params:o({},n,{value:d})}:{method:r.estimateGas.fillQuoteTokenToToken,methodArgs:[i,s,u,p,l,y],params:o({},n,{value:d})}},exports.signPermit=Q,exports.unwrapWeth=E,exports.wrapEth=k;
//# sourceMappingURL=swaps.cjs.production.min.js.map

@@ -32,2 +32,7 @@ import { BigNumberish } from '@ethersproject/bignumber';

}
export interface QuoteError {
error: boolean;
error_code?: number;
message: string;
}
export interface Quote {

@@ -34,0 +39,0 @@ source?: Source;

{
"version": "0.1.1",
"version": "0.1.2",
"name": "@rainbow-me/swaps",

@@ -4,0 +4,0 @@ "license": "GPL-3.0",

@@ -27,10 +27,10 @@ ## 🌈 Rainbow Swap Aggregator JS SDK

{
source, // optional, "oneinch" or "zerox"
chainId, // numeric chain id
fromAddress, // address of the wallet to execute the swap from
source, // optional, "oneinch" or "zerox"
chainId, // numeric chain id
fromAddress, // address of the wallet to execute the swap from
sellTokenAddress, // address of the input token
buyTokenAddress, // address of the output token
sellAmount, // amount of the input token (optional)
buyAmount, // amount of the output token (optional)
slippage // max slippage percentage allowed (optional)
sellAmount, // amount of the input token (required if not passing buyAmount)
buyAmount, // amount of the output token (required if not passing sellAmount)
slippage // max slippage percentage allowed
}

@@ -60,3 +60,3 @@ );

quote, // quote returned from getQuote
transactionOptions, // gasLimit, maxFeePerGas, maxPriorityFeePerGas, nonce, value, from
transactionOptions, // gasLimit, maxFeePerGas, maxPriorityFeePerGas, nonce, value, from
permit, // true if you want to use the permit

@@ -66,2 +66,2 @@ chainId, // numeric chain id

```
```

@@ -9,2 +9,3 @@ import { Contract } from '@ethersproject/contracts';

Quote,
QuoteError,
QuoteExecutionDetails,

@@ -47,3 +48,3 @@ QuoteParams,

slippage,
}: QuoteParams): Promise<Quote | null> => {
}: QuoteParams): Promise<Quote | QuoteError | null> => {
// When wrapping or unwrapping ETH, the quote is always 1:1

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

const quote = await response.json();
if (quote.error) {
return quote as QuoteError;
}
return quote as Quote;

@@ -99,0 +103,0 @@ };

@@ -38,2 +38,8 @@ import { BigNumberish } from '@ethersproject/bignumber';

export interface QuoteError {
error: boolean;
error_code?: number;
message: string;
}
export interface Quote {

@@ -40,0 +46,0 @@ source?: Source;

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