text: "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,o,i=t(require("jsbi")),a=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),s=t(require("big.js")),c=t(require("toformat")),f=t(require("decimal.js-light")),l=require("@ethersproject/solidity"),h=require("@ethersproject/contracts"),p=require("@ethersproject/providers"),d=t(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=43114]="MAINNET",n[n.TESTNET=16667e5]="TESTNET",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(o=exports.Rounding||(exports.Rounding={}))[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP";var v,m="0x2174e1476dd66b37d90fcffe8b2b037b4358dd4e8619790c3dc8d63ffa1f045a",y=i.BigInt(1e3),w=i.BigInt(0),g=i.BigInt(1),T=i.BigInt(2),k=i.BigInt(3),x=i.BigInt(5),b=i.BigInt(10),A=i.BigInt(100),E=i.BigInt(997),O=i.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(v||(v={}));var I=((e={})[v.uint8]=i.BigInt("0xff"),e[v.uint256]=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function q(t,e,n,r,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).then(r,o)}function _(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){q(i,r,o,a,u,"next",t)}function u(t){q(i,r,o,a,u,"throw",t)}a(void 0)}))}}function P(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 N(t,e,n){return e&&P(t.prototype,e),n&&P(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 U(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,F(t,e)}function C(t){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function F(t,e){return(F=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 D(t,e,n){return(D=S()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&F(o,n.prototype),o}).apply(null,arguments)}function j(t){var e="function"==typeof Map?new Map:void 0;return(j=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 D(t,arguments,C(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(n,t)})(t)}function L(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function B(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 H(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 B(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)?B(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 M="setPrototypeOf"in Object,X=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,M&&Object.setPrototypeOf(L(n),(this instanceof e?this.constructor:void 0).prototype),n}return U(e,t),e}(j(Error)),W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,M&&Object.setPrototypeOf(L(n),(this instanceof e?this.constructor:void 0).prototype),n}return U(e,t),e}(j(Error));function G(t,e){i.greaterThanOrEqual(t,w)||a(!1),i.lessThanOrEqual(t,I[e])||a(!1)}function V(t){try{return u.getAddress(t)}catch(t){a(!1)}}function Y(t){return t instanceof i?t:i.BigInt("bigint"==typeof t?t.toString():t)}function J(t){G(t,v.uint256);var e,n=w;if(i.greaterThan(t,k))for(n=t,e=i.add(i.divide(t,T),g);i.lessThan(e,n);)n=e,e=i.divide(i.add(i.divide(t,e),e),T);else i.notEqual(t,w)&&(n=g);return n}function Q(t,e,n,r){if(n>0||a(!1),t.length<=n||a(!1),0===t.length)return t.push(e),null;var o=t.length===n;if(o&&r(t[t.length-1],e)<=0)return e;for(var i=0,u=t.length;i<u;){var s=i+u>>>1;r(t[s],e)<=0?i=s+1:u=s}return t.splice(i,0,e),o?t.pop():null}var $,z=function(t,e,n){G(i.BigInt(t),v.uint8),this.decimals=t,this.symbol=e,this.name=n},K=z.ETHER=new z(18,"ETH","Ether"),Z=function(t){function e(e,n,r,o,i){var a;return(a=t.call(this,r,o,i)||this).chainId=e,a.address=V(n),a}U(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&&a(!1),this.address===t.address&&a(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(z);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=(($={})[exports.ChainId.MAINNET]=new Z(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),$[exports.ChainId.TESTNET]=new Z(exports.ChainId.TESTNET,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),$),ot=c(f),it=c(s),at=((et={})[exports.Rounding.ROUND_DOWN]=ot.ROUND_DOWN,et[exports.Rounding.ROUND_HALF_UP]=ot.ROUND_HALF_UP,et[exports.Rounding.ROUND_UP]=ot.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=g),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 i.equal(this.denominator,n.denominator)?new t(i.add(this.numerator,n.numerator),this.denominator):new t(i.add(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Y(e));return i.equal(this.denominator,n.denominator)?new t(i.subtract(this.numerator,n.numerator),this.denominator):new t(i.subtract(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Y(e));return i.lessThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Y(e));return i.equal(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Y(e));return i.greaterThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Y(e));return new t(i.multiply(this.numerator,n.numerator),i.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Y(e));return new t(i.multiply(this.numerator,n.denominator),i.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)||a(!1),t>0||a(!1),ot.set({precision:t+1,rounding:at[n]});var r=new ot(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)||a(!1),t>=0||a(!1),it.DP=t,it.RM=ut[n],new it(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},N(t,[{key:"quotient",get:function(){return i.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(i.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),ct=c(s),ft=function(t){function e(e,n){var r,o=Y(n);return G(o,v.uint256),(r=t.call(this,o,i.exponentiate(b,i.BigInt(e.decimals)))||this).currency=e,r}U(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)||a(!1),new e(this.currency,i.add(this.raw,t.raw))},n.subtract=function(t){return tt(this.currency,t.currency)||a(!1),new e(this.currency,i.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||a(!1),t.prototype.toFixed.call(this,e,n,r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),ct.DP=this.currency.decimals,new ct(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},N(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}U(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,i.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,i.subtract(this.raw,t.raw))},e}(ft),ht=function(t){function e(e,n,r,o){var a;return(a=t.call(this,o,r)||this).baseCurrency=e,a.quoteCurrency=n,a.scalar=new st(i.exponentiate(b,i.BigInt(e.decimals)),i.exponentiate(b,i.BigInt(n.decimals))),a}U(e,t),e.fromRoute=function(t){for(var n,r=[],o=H(t.pairs.entries());!(n=o()).done;){var i=n.value,a=i[1];r.push(t.path[i[0]].equals(a.token0)?new e(a.reserve0.currency,a.reserve1.currency,a.reserve0.raw,a.reserve1.raw):new e(a.reserve1.currency,a.reserve0.currency,a.reserve1.raw,a.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)||a(!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)||a(!1),this.quoteCurrency instanceof Z?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ft.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)},N(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),pt={},dt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new Z(r[0].token.chainId,t.getAddress(r[0].token,r[1].token),18,"OAVAX","Open AVAX"),this.tokenAmounts=r}t.getAddress=function(t,e){var n,r,o,i,a,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null==(n=pt)||null==(r=n[s[0].address])?void 0:r[s[1].address])&&(pt=R({},pt,((a={})[s[0].address]=R({},null==(o=pt)?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0x161FdbA801F1cC81DcB9f4e90c9f06E5317d3D7d",l.keccak256(["bytes"],[l.pack(["address","address"],[s[0].address,s[1].address])]),m),i)),a))),pt[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)||a(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||a(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||a(!1),i.equal(this.reserve0.raw,w)||i.equal(this.reserve1.raw,w))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(e.raw,E),u=i.multiply(o,r.raw),s=i.add(i.multiply(n.raw,O),o),c=new lt(e.token.equals(this.token0)?this.token1:this.token0,i.divide(u,s));if(i.equal(c.raw,w))throw new W;return[c,new t(n.add(e),r.subtract(c))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||a(!1),i.equal(this.reserve0.raw,w)||i.equal(this.reserve1.raw,w)||i.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),o=i.multiply(i.multiply(r.raw,e.raw),O),u=i.multiply(i.subtract(n.raw,e.raw),E),s=new lt(e.token.equals(this.token0)?this.token1:this.token0,i.add(i.divide(o,u),g));return[s,new t(r.add(s),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||a(!1);var r,o=e.token.sortsBefore(n.token)?[e,n]:[n,e];if(o[0].token.equals(this.token0)&&o[1].token.equals(this.token1)||a(!1),i.equal(t.raw,w))r=i.subtract(J(i.multiply(o[0].raw,o[1].raw)),y);else{var u=i.divide(i.multiply(o[0].raw,t.raw),this.reserve0.raw),s=i.divide(i.multiply(o[1].raw,t.raw),this.reserve1.raw);r=i.lessThanOrEqual(u,s)?u:s}if(!i.greaterThan(r,w))throw new W;return new lt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,o){var u;if(void 0===r&&(r=!1),this.involvesToken(t)||a(!1),e.token.equals(this.liquidityToken)||a(!1),n.token.equals(this.liquidityToken)||a(!1),i.lessThanOrEqual(n.raw,e.raw)||a(!1),r){o||a(!1);var s=Y(o);if(i.equal(s,w))u=e;else{var c=J(i.multiply(this.reserve0.raw,this.reserve1.raw)),f=J(s);if(i.greaterThan(c,f)){var l=i.multiply(e.raw,i.subtract(c,f)),h=i.add(i.multiply(c,x),f),p=i.divide(l,h);u=e.add(new lt(this.liquidityToken,p))}else u=e}}else u=e;return new lt(t,i.divide(i.multiply(n.raw,this.reserveOf(t).raw),u.raw))},N(t,[{key:"token0Price",get:function(){return new ht(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new ht(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}(),vt=function(){function t(t,e,n){t.length>0||a(!1),t.every((function(e){return e.chainId===t[0].chainId}))||a(!1),e instanceof Z&&t[0].involvesToken(e)||e===K&&t[0].involvesToken(rt[t[0].chainId])||a(!1),void 0===n||n instanceof Z&&t[t.length-1].involvesToken(n)||n===K&&t[t.length-1].involvesToken(rt[t[0].chainId])||a(!1);for(var r,o=[e instanceof Z?e:rt[t[0].chainId]],i=H(t.entries());!(r=i()).done;){var u=r.value,s=u[1],c=o[u[0]];c.equals(s.token0)||c.equals(s.token1)||a(!1);var f=c.equals(s.token0)?s.token1:s.token0;o.push(f)}this.pairs=t,this.path=o,this.midPrice=ht.fromRoute(this),this.input=e,this.output=null!=n?n:o[o.length-1]}return N(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),mt=new st(A),yt=function(t){function e(){return t.apply(this,arguments)||this}U(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(mt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(mt).toFixed(t,e,n)},e}(st);function wt(t,e){return tt(t.inputAmount.currency,e.inputAmount.currency)||a(!1),tt(t.outputAmount.currency,e.outputAmount.currency)||a(!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 Tt(t,e){return t instanceof lt?t:t.currency===K?new lt(rt[e],t.raw):void a(!1)}function kt(t,e){return t instanceof Z?t:t===K?rt[e]:void a(!1)}var xt=function(){function t(t,e,n){var r,o,i,u=new Array(t.path.length),s=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){tt(e.currency,t.input)||a(!1),u[0]=Tt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var f=t.pairs[c].getOutputAmount(u[c]),l=f[1];u[c+1]=f[0],s[c]=l}}else{tt(e.currency,t.output)||a(!1),u[u.length-1]=Tt(e,t.chainId);for(var h=t.path.length-1;h>0;h--){var p=t.pairs[h-1].getInputAmount(u[h]),d=p[1];u[h-1]=p[0],s[h-1]=d}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===K?ft.ether(u[0].raw):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===K?ft.ether(u[u.length-1].raw):u[u.length-1],this.executionPrice=new ht(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ht.fromRoute(new vt(s,t.input)),this.priceImpact=(r=this.outputAmount,i=(o=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new yt(i.numerator,i.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(w)&&a(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new st(g).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):ft.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(w)&&a(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new st(g).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):ft.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,f=c.maxNumResults,l=void 0===f?3:f,h=c.maxHops,p=void 0===h?3:h;void 0===i&&(i=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||a(!1),p>0||a(!1),u===n||i.length>0||a(!1);var d=n instanceof lt?n.token.chainId:r instanceof Z?r.chainId:void 0;void 0===d&&a(!1);for(var v=Tt(n,d),m=kt(r,d),y=0;y<e.length;y++){var g=e[y];if((g.token0.equals(v.token)||g.token1.equals(v.token))&&!g.reserve0.equalTo(w)&&!g.reserve1.equalTo(w)){var T=void 0;try{T=g.getOutputAmount(v)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(T.token.equals(m))Q(s,new t(new vt([].concat(i,[g]),u.currency,r),u,exports.TradeType.EXACT_INPUT),l,gt);else if(p>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(k,T,r,{maxNumResults:l,maxHops:p-1},[].concat(i,[g]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,f=c.maxNumResults,l=void 0===f?3:f,h=c.maxHops,p=void 0===h?3:h;void 0===i&&(i=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||a(!1),p>0||a(!1),u===r||i.length>0||a(!1);var d=r instanceof lt?r.token.chainId:n instanceof Z?n.chainId:void 0;void 0===d&&a(!1);for(var v=Tt(r,d),m=kt(n,d),y=0;y<e.length;y++){var g=e[y];if((g.token0.equals(v.token)||g.token1.equals(v.token))&&!g.reserve0.equalTo(w)&&!g.reserve1.equalTo(w)){var T=void 0;try{T=g.getInputAmount(v)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(T.token.equals(m))Q(s,new t(new vt([g].concat(i),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),l,gt);else if(p>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(k,n,T,{maxNumResults:l,maxHops:p-1},[g].concat(i),u,s)}}}return s},t}();function bt(t){return"0x"+t.raw.toString(16)}var At,Et,Ot=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===K,r=t.outputAmount.currency===K;n&&r&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var o,i,u,s=V(e.recipient),c=bt(t.maximumAmountIn(e.allowedSlippage)),f=bt(t.minimumAmountOut(e.allowedSlippage)),l=t.route.path.map((function(t){return t.address})),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),p=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=p?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[f,l,s,h],u=c):r?(o=p?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,f,l,s,h],u="0x0"):(o=p?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,f,l,s,h],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:p&&a(!1),n?(o="swapETHForExactTokens",i=[f,l,s,h],u=c):r?(o="swapTokensForExactETH",i=[f,c,l,s,h],u="0x0"):(o="swapTokensForExactTokens",i=[f,c,l,s,h],u="0x0")}return{methodName:o,args:i,value:u}},t}(),It=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=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 o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new b(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=T(a,n);if(u){if(u===f)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=c(t,e,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(t,n,i),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function l(){}function h(){}function p(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(A([])));m&&m!==e&&n.call(m,o)&&(d=m);var y=p.prototype=l.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var r;this._invoke=function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,u){var s=c(t[o],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function T(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,T(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=c(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,f;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function k(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=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 i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return h.prototype=p,u(y,"constructor",p),u(p,"constructor",h),h.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},w(g.prototype),u(g.prototype,i,(function(){return this})),t.AsyncIterator=g,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new g(s(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(y),u(y,a,"Generator"),u(y,o,(function(){return this})),u(y,"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,b.prototype={constructor:b,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(x),!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 a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},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),f},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),x(n),f}},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 o=r.arg;x(n)}return o}}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),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(Et={exports:{}}),Et.exports),qt=[{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"}],_t=((At={})[exports.ChainId.MAINNET]={"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7":18},At),Pt=function(){function t(){}return t.fetchTokenData=function(){var t=_(It.mark((function t(e,n,r,o,i){var a,u;return It.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=new p.JsonRpcProvider("https://api.avax.network/ext/bc/C/rpc",{chainId:43114,name:"Avalanche"})),"number"!=typeof(null==(a=_t)||null==(u=a[e])?void 0:u[n])){t.next=5;break}t.t0=_t[e][n],t.next=8;break;case 5:return t.next=7,new h.Contract(n,qt,r).decimals().then((function(t){var r,o,i;return _t=R({},_t,((i={})[e]=R({},null==(r=_t)?void 0:r[e],((o={})[n]=t,o)),i)),t}));case 7:t.t0=t.sent;case 8:return t.abrupt("return",new Z(e,n,t.t0,o,i));case 10:case"end":return t.stop()}}),t)})));return function(e,n,r,o,i){return t.apply(this,arguments)}}(),t.fetchPairData=function(){var t=_(It.mark((function t(e,n,r){var o,i,u,s,c;return It.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=new p.JsonRpcProvider("https://api.avax.network/ext/bc/C/rpc",{chainId:43114,name:"Avalanche"})),e.chainId!==n.chainId&&a(!1),o=dt.getAddress(e,n),t.next=5,new h.Contract(o,d.abi,r).getReserves();case 5:return u=(i=t.sent)[0],s=i[1],c=e.sortsBefore(n)?[u,s]:[s,u],t.abrupt("return",new dt(new lt(e,c[0]),new lt(n,c[1])));case 10:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}();exports.JSBI=i,exports.Currency=z,exports.CurrencyAmount=ft,exports.ETHER=K,exports.FACTORY_ADDRESS="0x161FdbA801F1cC81DcB9f4e90c9f06E5317d3D7d",exports.Fetcher=Pt,exports.Fraction=st,exports.INIT_CODE_HASH=m,exports.InsufficientInputAmountError=W,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=y,exports.Pair=dt,exports.Percent=yt,exports.Price=ht,exports.Route=vt,exports.Router=Ot,exports.Token=Z,exports.TokenAmount=lt,exports.Trade=xt,exports.WETH=rt,exports.currencyEquals=tt,exports.inputOutputComparator=wt,exports.tradeComparator=gt;
  //# sourceMappingURL=oavax-sdk.cjs.production.min.js.map
  