"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n,r,i,a=t(require("jsbi")),o=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),s=t(require("big.js")),p=t(require("toformat")),c=t(require("decimal.js-light")),l=require("@ethersproject/solidity"),d=require("@ethersproject/contracts"),y=require("@ethersproject/networks"),f=require("@ethersproject/providers");(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=137]="MAINNET",n[n.TESTNET=80001]="TESTNET",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(i=exports.Rounding||(exports.Rounding={}))[i.ROUND_DOWN=0]="ROUND_DOWN",i[i.ROUND_HALF_UP=1]="ROUND_HALF_UP",i[i.ROUND_UP=2]="ROUND_UP";var h,m="0x0f316c4111d246eee4e7ca6ffd02ca779ad3cd7a0da1f59a95878ac6b6348ea2",v=a.BigInt(1e3),T=a.BigInt(0),w=a.BigInt(1),g=a.BigInt(2),b=a.BigInt(3),k=a.BigInt(5),x=a.BigInt(10),A=a.BigInt(100),I=a.BigInt(9970),O=a.BigInt(1e4);!function(t){t.uint8="uint8",t.uint256="uint256"}(h||(h={}));var E=((e={})[h.uint8]=a.BigInt("0xff"),e[h.uint256]=a.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function q(t,e,n,r,i,a,o){try{var u=t[a](o),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).then(r,i)}function _(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(t){q(a,r,i,o,u,"next",t)}function u(t){q(a,r,i,o,u,"throw",t)}o(void 0)}))}}function N(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function P(t,e,n){return e&&N(t.prototype,e),n&&N(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function R(){return(R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function C(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,M(t,e)}function U(t){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function M(t,e){return(M=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function F(t,e,n){return(F=S()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&M(i,n.prototype),i}).apply(null,arguments)}function L(t){var e="function"==typeof Map?new Map:void 0;return(L=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return F(t,arguments,U(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),M(n,t)})(t)}function j(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function D(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function B(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return D(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var H="setPrototypeOf"in Object,X=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,H&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return C(e,t),e}(L(Error)),W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,H&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return C(e,t),e}(L(Error));function G(t,e){a.greaterThanOrEqual(t,T)||o(!1),a.lessThanOrEqual(t,E[e])||o(!1)}function Q(t){try{return u.getAddress(t)}catch(t){o(!1)}}function Y(t){return t instanceof a?t:a.BigInt("bigint"==typeof t?t.toString():t)}function z(t){G(t,h.uint256);var e,n=T;if(a.greaterThan(t,b))for(n=t,e=a.add(a.divide(t,g),w);a.lessThan(e,n);)n=e,e=a.divide(a.add(a.divide(t,e),e),g);else a.notEqual(t,T)&&(n=w);return n}function J(t,e,n,r){if(n>0||o(!1),t.length<=n||o(!1),0===t.length)return t.push(e),null;var i=t.length===n;if(i&&r(t[t.length-1],e)<=0)return e;for(var a=0,u=t.length;a<u;){var s=a+u>>>1;r(t[s],e)<=0?a=s+1:u=s}return t.splice(a,0,e),i?t.pop():null}var V,$=function(t,e,n){G(a.BigInt(t),h.uint8),this.decimals=t,this.symbol=e,this.name=n},K=$.ETHER=new $(18,"MATIC","MATIC"),Z=function(t){function e(e,n,r,i,a,o){var u;return(u=t.call(this,r,i,a)||this).chainId=e,u.address=Q(n),u.projectLink=o,u}C(e,t);var n=e.prototype;return n.equals=function(t){return this===t||this.chainId===t.chainId&&this.address===t.address},n.sortsBefore=function(t){return this.chainId!==t.chainId&&o(!1),this.address===t.address&&o(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}($);function tt(t,e){return t instanceof Z&&e instanceof Z?t.equals(e):!(t instanceof Z||e instanceof Z||t!==e)}var et,nt,rt=((V={})[exports.ChainId.MAINNET]=new Z(exports.ChainId.MAINNET,"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",18,"WMATIC","Wrapped MATIC","https://polygon.technology/"),V[exports.ChainId.TESTNET]=new Z(exports.ChainId.TESTNET,"0xaE8E19eFB41e7b96815649A6a60785e1fbA84C1e",18,"WBNB","Wrapped BNB","https://www.binance.org"),V),it=p(c),at=p(s),ot=((et={})[exports.Rounding.ROUND_DOWN]=it.ROUND_DOWN,et[exports.Rounding.ROUND_HALF_UP]=it.ROUND_HALF_UP,et[exports.Rounding.ROUND_UP]=it.ROUND_UP,et),ut=((nt={})[exports.Rounding.ROUND_DOWN]=0,nt[exports.Rounding.ROUND_HALF_UP]=1,nt[exports.Rounding.ROUND_UP]=3,nt),st=function(){function t(t,e){void 0===e&&(e=w),this.numerator=Y(t),this.denominator=Y(e)}var e=t.prototype;return e.invert=function(){return new t(this.denominator,this.numerator)},e.add=function(e){var n=e instanceof t?e:new t(Y(e));return a.equal(this.denominator,n.denominator)?new t(a.add(this.numerator,n.numerator),this.denominator):new t(a.add(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Y(e));return a.equal(this.denominator,n.denominator)?new t(a.subtract(this.numerator,n.numerator),this.denominator):new t(a.subtract(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Y(e));return a.lessThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Y(e));return a.equal(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Y(e));return a.greaterThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Y(e));return new t(a.multiply(this.numerator,n.numerator),a.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Y(e));return new t(a.multiply(this.numerator,n.denominator),a.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>0||o(!1),it.set({precision:t+1,rounding:ot[n]});var r=new it(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return r.toFormat(r.decimalPlaces(),e)},e.toFixed=function(t,e,n){return void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>=0||o(!1),at.DP=t,at.RM=ut[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(t,[{key:"quotient",get:function(){return a.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(a.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),pt=p(s),ct=function(t){function e(e,n){var r,i=Y(n);return G(i,h.uint256),(r=t.call(this,i,a.exponentiate(x,a.BigInt(e.decimals)))||this).currency=e,r}C(e,t),e.ether=function(t){return new e(K,t)};var n=e.prototype;return n.add=function(t){return tt(this.currency,t.currency)||o(!1),new e(this.currency,a.add(this.raw,t.raw))},n.subtract=function(t){return tt(this.currency,t.currency)||o(!1),new e(this.currency,a.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||o(!1),t.prototype.toFixed.call(this,e,n,r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),pt.DP=this.currency.decimals,new pt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},P(e,[{key:"raw",get:function(){return this.numerator}}]),e}(st),lt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}C(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||o(!1),new e(this.token,a.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||o(!1),new e(this.token,a.subtract(this.raw,t.raw))},e}(ct),dt=function(t){function e(e,n,r,i){var o;return(o=t.call(this,i,r)||this).baseCurrency=e,o.quoteCurrency=n,o.scalar=new st(a.exponentiate(x,a.BigInt(e.decimals)),a.exponentiate(x,a.BigInt(n.decimals))),o}C(e,t),e.fromRoute=function(t){for(var n,r=[],i=B(t.pairs.entries());!(n=i()).done;){var a=n.value,o=a[1];r.push(t.path[a[0]].equals(o.token0)?new e(o.reserve0.currency,o.reserve1.currency,o.reserve0.raw,o.reserve1.raw):new e(o.reserve1.currency,o.reserve0.currency,o.reserve1.raw,o.reserve0.raw))}return r.slice(1).reduce((function(t,e){return t.multiply(e)}),r[0])};var n=e.prototype;return n.invert=function(){return new e(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},n.multiply=function(n){tt(this.quoteCurrency,n.baseCurrency)||o(!1);var r=t.prototype.multiply.call(this,n);return new e(this.baseCurrency,n.quoteCurrency,r.denominator,r.numerator)},n.quote=function(e){return tt(e.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof Z?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ct.ether(t.prototype.multiply.call(this,e.raw).quotient)},n.toSignificant=function(t,e,n){return void 0===t&&(t=6),this.adjusted.toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=4),this.adjusted.toFixed(t,e,n)},P(e,[{key:"raw",get:function(){return new st(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(st),yt={},ft={},ht=function(){function t(e,n,r){void 0===r&&(r=!1),this.isQuickswap=!1,this.isQuickswap=r;var i=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new Z(i[0].token.chainId,r?t.getQuickswapAddress(i[0].token,i[1].token):t.getAddress(i[0].token,i[1].token),18,"Nacho-LP","Nacho LPs"),this.tokenAmounts=i}t.getAddress=function(t,e){var n,r,i,a,o,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null==(n=yt)||null==(r=n[s[0].address])?void 0:r[s[1].address])&&(yt=R({},yt,((o={})[s[0].address]=R({},null==(i=yt)?void 0:i[s[0].address],((a={})[s[1].address]=u.getCreate2Address("0x1B44bf43111A26206F9735319A0c438dd1c030b2",l.keccak256(["bytes"],[l.pack(["address","address"],[s[0].address,s[1].address])]),m),a)),o))),yt[s[0].address][s[1].address]},t.getQuickswapAddress=function(t,e){var n,r,i,a,o,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null==(n=ft)||null==(r=n[s[0].address])?void 0:r[s[1].address])&&(ft=R({},ft,((o={})[s[0].address]=R({},null==(i=ft)?void 0:i[s[0].address],((a={})[s[1].address]=u.getCreate2Address("0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",l.keccak256(["bytes"],[l.pack(["address","address"],[s[0].address,s[1].address])]),"0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"),a)),o))),ft[s[0].address][s[1].address]};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||o(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||o(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,T)||a.equal(this.reserve1.raw,T))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),i=a.multiply(e.raw,I),u=a.multiply(i,r.raw),s=a.add(a.multiply(n.raw,O),i),p=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.divide(u,s));if(a.equal(p.raw,T))throw new W;return[p,new t(n.add(e),r.subtract(p))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,T)||a.equal(this.reserve1.raw,T)||a.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),i=a.multiply(a.multiply(r.raw,e.raw),O),u=a.multiply(a.subtract(n.raw,e.raw),I),s=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.add(a.divide(i,u),w));return[s,new t(r.add(s),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||o(!1);var r,i=e.token.sortsBefore(n.token)?[e,n]:[n,e];if(i[0].token.equals(this.token0)&&i[1].token.equals(this.token1)||o(!1),a.equal(t.raw,T))r=a.subtract(z(a.multiply(i[0].raw,i[1].raw)),v);else{var u=a.divide(a.multiply(i[0].raw,t.raw),this.reserve0.raw),s=a.divide(a.multiply(i[1].raw,t.raw),this.reserve1.raw);r=a.lessThanOrEqual(u,s)?u:s}if(!a.greaterThan(r,T))throw new W;return new lt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,i){var u;if(void 0===r&&(r=!1),this.involvesToken(t)||o(!1),e.token.equals(this.liquidityToken)||o(!1),n.token.equals(this.liquidityToken)||o(!1),a.lessThanOrEqual(n.raw,e.raw)||o(!1),r){i||o(!1);var s=Y(i);if(a.equal(s,T))u=e;else{var p=z(a.multiply(this.reserve0.raw,this.reserve1.raw)),c=z(s);if(a.greaterThan(p,c)){var l=a.multiply(e.raw,a.subtract(p,c)),d=a.add(a.multiply(p,k),c),y=a.divide(l,d);u=e.add(new lt(this.liquidityToken,y))}else u=e}}else u=e;return new lt(t,a.divide(a.multiply(n.raw,this.reserveOf(t).raw),u.raw))},P(t,[{key:"token0Price",get:function(){return new dt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new dt(this.token1,this.token0,this.tokenAmounts[1].raw,this.tokenAmounts[0].raw)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].token}},{key:"token1",get:function(){return this.tokenAmounts[1].token}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),mt=function(){function t(t,e,n){t.length>0||o(!1),t.every((function(e){return e.chainId===t[0].chainId}))||o(!1),e instanceof Z&&t[0].involvesToken(e)||e===K&&t[0].involvesToken(rt[t[0].chainId])||o(!1),void 0===n||n instanceof Z&&t[t.length-1].involvesToken(n)||n===K&&t[t.length-1].involvesToken(rt[t[0].chainId])||o(!1);for(var r,i=[e instanceof Z?e:rt[t[0].chainId]],a=B(t.entries());!(r=a()).done;){var u=r.value,s=u[1],p=i[u[0]];p.equals(s.token0)||p.equals(s.token1)||o(!1);var c=p.equals(s.token0)?s.token1:s.token0;i.push(c)}this.pairs=t,this.path=i,this.midPrice=dt.fromRoute(this),this.input=e,this.output=null!=n?n:i[i.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),vt=new st(A),Tt=function(t){function e(){return t.apply(this,arguments)||this}C(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(vt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(vt).toFixed(t,e,n)},e}(st);function wt(t,e){return tt(t.inputAmount.currency,e.inputAmount.currency)||o(!1),tt(t.outputAmount.currency,e.outputAmount.currency)||o(!1),t.outputAmount.equalTo(e.outputAmount)?t.inputAmount.equalTo(e.inputAmount)?0:t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}function gt(t,e){var n=wt(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}function bt(t,e){return t instanceof lt?t:t.currency===K?new lt(rt[e],t.raw):void o(!1)}function kt(t,e){return t instanceof Z?t:t===K?rt[e]:void o(!1)}var xt=function(){function t(t,e,n){var r,i,a,u=new Array(t.path.length),s=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){tt(e.currency,t.input)||o(!1),u[0]=bt(e,t.chainId);for(var p=0;p<t.path.length-1;p++){var c=t.pairs[p].getOutputAmount(u[p]),l=c[1];u[p+1]=c[0],s[p]=l}}else{tt(e.currency,t.output)||o(!1),u[u.length-1]=bt(e,t.chainId);for(var d=t.path.length-1;d>0;d--){var y=t.pairs[d-1].getInputAmount(u[d]),f=y[1];u[d-1]=y[0],s[d-1]=f}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===K?ct.ether(u[0].raw):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===K?ct.ether(u[u.length-1].raw):u[u.length-1],this.executionPrice=new dt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=dt.fromRoute(new mt(s,t.input)),this.priceImpact=(r=this.outputAmount,a=(i=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(i),new Tt(a.numerator,a.denominator))}t.exactIn=function(e,n){return new t(e,n,exports.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(T)&&o(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new st(w).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):ct.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(T)&&o(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new st(w).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):ct.ether(e)},t.bestTradeExactIn=function(e,n,r,i,a,u,s){var p=void 0===i?{}:i,c=p.maxNumResults,l=void 0===c?3:c,d=p.maxHops,y=void 0===d?3:d;void 0===a&&(a=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||o(!1),y>0||o(!1),u===n||a.length>0||o(!1);var f=n instanceof lt?n.token.chainId:r instanceof Z?r.chainId:void 0;void 0===f&&o(!1);for(var h=bt(n,f),m=kt(r,f),v=0;v<e.length;v++){var w=e[v];if((w.token0.equals(h.token)||w.token1.equals(h.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getOutputAmount(h)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(g.token.equals(m))J(s,new t(new mt([].concat(a,[w]),u.currency,r),u,exports.TradeType.EXACT_INPUT),l,gt);else if(y>1&&e.length>1){var b=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactIn(b,g,r,{maxNumResults:l,maxHops:y-1},[].concat(a,[w]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,i,a,u,s){var p=void 0===i?{}:i,c=p.maxNumResults,l=void 0===c?3:c,d=p.maxHops,y=void 0===d?3:d;void 0===a&&(a=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||o(!1),y>0||o(!1),u===r||a.length>0||o(!1);var f=r instanceof lt?r.token.chainId:n instanceof Z?n.chainId:void 0;void 0===f&&o(!1);for(var h=bt(r,f),m=kt(n,f),v=0;v<e.length;v++){var w=e[v];if((w.token0.equals(h.token)||w.token1.equals(h.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getInputAmount(h)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(g.token.equals(m))J(s,new t(new mt([w].concat(a),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),l,gt);else if(y>1&&e.length>1){var b=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactOut(b,n,g,{maxNumResults:l,maxHops:y-1},[w].concat(a),u,s)}}}return s},t}();function At(t){return"0x"+t.raw.toString(16)}var It,Ot,Et=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===K,r=t.outputAmount.currency===K;n&&r&&o(!1),!("ttl"in e)||e.ttl>0||o(!1);var i,a,u,s=Q(e.recipient),p=At(t.maximumAmountIn(e.allowedSlippage)),c=At(t.minimumAmountOut(e.allowedSlippage)),l=t.route.path.map((function(t){return t.address})),d="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),y=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:n?(i=y?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",a=[c,l,s,d],u=p):r?(i=y?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",a=[p,c,l,s,d],u="0x0"):(i=y?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",a=[p,c,l,s,d],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:y&&o(!1),n?(i="swapETHForExactTokens",a=[c,l,s,d],u=p):r?(i="swapTokensForExactETH",a=[c,p,l,s,d],u="0x0"):(i="swapTokensForExactTokens",a=[c,p,l,s,d],u="0x0")}return{methodName:i,args:a,value:u}},t}(),qt=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var i=Object.create((e&&e.prototype instanceof l?e:l).prototype),a=new x(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return{value:void 0,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var u=g(o,n);if(u){if(u===c)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=p(t,e,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===c)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(t,n,a),i}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var c={};function l(){}function d(){}function y(){}var f={};u(f,i,(function(){return this}));var h=Object.getPrototypeOf,m=h&&h(h(A([])));m&&m!==e&&n.call(m,i)&&(f=m);var v=y.prototype=l.prototype=Object.create(f);function T(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var r;this._invoke=function(i,a){function o(){return new e((function(r,o){!function r(i,a,o,u){var s=p(t[i],t,a);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,o,u)}),(function(t){r("throw",t,o,u)})):e.resolve(l).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,u)}))}u(s.arg)}(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function g(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,g(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=p(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,c;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function A(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:I}}function I(){return{value:void 0,done:!0}}return d.prototype=y,u(v,"constructor",y),u(y,"constructor",d),d.displayName=u(y,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,o,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},T(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var o=new w(s(e,n,r,i),a);return t.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},T(v),u(v,o,"Generator"),u(v,i,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=A,x.prototype={constructor:x,reset:function(t){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(k),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return o.type="throw",o.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(Ot={exports:{}}),Ot.exports),_t=[{inputs:[],payable:!1,stateMutability:"nonpayable",type:"constructor"},{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:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"Burn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Mint",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0In",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1In",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount0Out",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1Out",type:"uint256"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"Swap",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint112",name:"reserve0",type:"uint112"},{indexed:!1,internalType:"uint112",name:"reserve1",type:"uint112"}],name:"Sync",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"},{constant:!0,inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"MINIMUM_LIQUIDITY",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"burn",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getReserves",outputs:[{internalType:"uint112",name:"_reserve0",type:"uint112"},{internalType:"uint112",name:"_reserve1",type:"uint112"},{internalType:"uint32",name:"_blockTimestampLast",type:"uint32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"_token0",type:"address"},{internalType:"address",name:"_token1",type:"address"}],name:"initialize",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"kLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[{internalType:"uint256",name:"liquidity",type:"uint256"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,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:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"price0CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"price1CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"skim",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{internalType:"uint256",name:"amount0Out",type:"uint256"},{internalType:"uint256",name:"amount1Out",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"swap",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"sync",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"token0",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"token1",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Nt=[{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],Pt=((It={})[exports.ChainId.MAINNET]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},It),Rt=function(){function t(){}return t.fetchTokenData=function(){var t=_(qt.mark((function t(e,n,r,i,a){var o,u;return qt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=f.getDefaultProvider(y.getNetwork(e))),"number"!=typeof(null==(o=Pt)||null==(u=o[e])?void 0:u[n])){t.next=5;break}t.t0=Pt[e][n],t.next=8;break;case 5:return t.next=7,new d.Contract(n,Nt,r).decimals().then((function(t){var r,i,a;return Pt=R({},Pt,((a={})[e]=R({},null==(r=Pt)?void 0:r[e],((i={})[n]=t,i)),a)),t}));case 7:t.t0=t.sent;case 8:return t.abrupt("return",new Z(e,n,t.t0,i,a));case 10:case"end":return t.stop()}}),t)})));return function(e,n,r,i,a){return t.apply(this,arguments)}}(),t.fetchPairData=function(){var t=_(qt.mark((function t(e,n,r){var i,a,u,s,p;return qt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=f.getDefaultProvider(y.getNetwork(e.chainId))),e.chainId!==n.chainId&&o(!1),i=ht.getAddress(e,n),t.next=5,new d.Contract(i,_t,r).getReserves();case 5:return u=(a=t.sent)[0],s=a[1],p=e.sortsBefore(n)?[u,s]:[s,u],t.abrupt("return",new ht(new lt(e,p[0]),new lt(n,p[1])));case 10:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}();exports.JSBI=a,exports.Currency=$,exports.CurrencyAmount=ct,exports.ETHER=K,exports.FACTORY_ADDRESS="0x1B44bf43111A26206F9735319A0c438dd1c030b2",exports.Fetcher=Rt,exports.Fraction=st,exports.INIT_CODE_HASH=m,exports.InsufficientInputAmountError=W,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=v,exports.Pair=ht,exports.Percent=Tt,exports.Price=dt,exports.Route=mt,exports.Router=Et,exports.Token=Z,exports.TokenAmount=lt,exports.Trade=xt,exports.WETH=rt,exports.currencyEquals=tt,exports.inputOutputComparator=wt,exports.tradeComparator=gt;
//# sourceMappingURL=sdk.cjs.production.min.js.map
