New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@openocean.finance/liquidity-sdk

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openocean.finance/liquidity-sdk - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

3

dist/constants.d.ts

@@ -9,2 +9,3 @@ import JSBI from 'jsbi';

POLYGON = 137,
KAVA = 2222,
AVAX = 43114

@@ -27,2 +28,3 @@ }

137: string;
2222: string;
43114: string;

@@ -36,2 +38,3 @@ };

137: string;
2222: string;
43114: string;

@@ -38,0 +41,0 @@ };

@@ -28,2 +28,3 @@ 'use strict';

ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
ChainId[ChainId["KAVA"] = 2222] = "KAVA";
ChainId[ChainId["AVAX"] = 43114] = "AVAX";

@@ -51,2 +52,3 @@ })(exports.ChainId || (exports.ChainId = {}));

137: '0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf',
2222: '0x6dd434082EAB5Cd134B33719ec1FF05fE985B97b',
43114: '0x042AF448582d0a3cE3CFa5b65c2675e88610B18d'

@@ -60,2 +62,3 @@ };

137: '0x0415568b317738f62f1608a814ac51b81c10e7300e23f4b1395231fc8251e7e4',
2222: '0xc26b7c10cfd3e76ca96f0c5d9191b4c2e08295897ffd6e452ae36b1f11f6fec3',
43114: '0x0761dc23a5b0e399fc92b9c3ea676b0314153899f2e30483c7217dcc02046630'

@@ -62,0 +65,0 @@ };

2

dist/liquidity-sdk.cjs.production.min.js

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

"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")),d=t(require("decimal.js-light")),f=require("@ethersproject/solidity"),p=require("@ethersproject/contracts"),l=require("@ethersproject/networks"),h=require("@ethersproject/providers"),m=t(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.ETH=1]="ETH",n[n.MAINNET=56]="MAINNET",n[n.ONTEVM=56]="ONTEVM",n[n.BSCTESTNET=97]="BSCTESTNET",n[n.POLYGON=137]="POLYGON",n[n.AVAX=43114]="AVAX",(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,y={1:"0x1F8c25f8DA3990Ecd3632eE4F02C2eA37755C3c6",56:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",58:"0x1AA8c24ac757758e27E66E619429cA87d3Fc28BB",97:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",137:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",43114:"0x042AF448582d0a3cE3CFa5b65c2675e88610B18d"},T={1:"0x338b9651a8c140547a88432caaff04a13e79d54b23e3cfec1e37fb3051125fab",56:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",58:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",97:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",137:"0x0415568b317738f62f1608a814ac51b81c10e7300e23f4b1395231fc8251e7e4",43114:"0x0761dc23a5b0e399fc92b9c3ea676b0314153899f2e30483c7217dcc02046630"},w=i.BigInt(1e3),g=i.BigInt(0),k=i.BigInt(1),A=i.BigInt(2),x=i.BigInt(3),b=i.BigInt(5),I=i.BigInt(10),O=i.BigInt(100),E=i.BigInt(998),q=i.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(v||(v={}));var C=((e={})[v.uint8]=i.BigInt("0xff"),e[v.uint256]=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);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),t}function U(){return(U=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 _(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function R(t){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function B(t,e){return(B=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function S(t,e,n){return(S=F()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&B(o,n.prototype),o}).apply(null,arguments)}function D(t){var e="function"==typeof Map?new Map:void 0;return(D=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 S(t,arguments,R(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),B(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 H(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 M(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return H(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)?H(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.")}return(n=t[Symbol.iterator]()).next.bind(n)}var X="setPrototypeOf"in Object,W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,X&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return _(e,t),e}(D(Error)),L=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,X&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return _(e,t),e}(D(Error));function V(t,e){i.greaterThanOrEqual(t,g)||a(!1),i.lessThanOrEqual(t,C[e])||a(!1)}function Y(t){try{return u.getAddress(t)}catch(t){a(!1)}}function G(t){return t instanceof i?t:i.BigInt("bigint"==typeof t?t.toString():t)}function J(t){V(t,v.uint256);var e,n=g;if(i.greaterThan(t,x))for(n=t,e=i.add(i.divide(t,A),k);i.lessThan(e,n);)n=e,e=i.divide(i.add(i.divide(t,e),e),A);else i.notEqual(t,g)&&(n=k);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){V(i.BigInt(t),v.uint8),this.decimals=t,this.symbol=e,this.name=n},K=z.ETHER=new z(18,"BNB","Binance"),Z=z.MATIC=new z(18,"MATIC","Polygon"),tt=function(t){function e(e,n,r,o,i){var a;return(a=t.call(this,r,o,i)||this).chainId=e,a.address=Y(n),a}_(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 et(t,e){return t instanceof tt&&e instanceof tt?t.equals(e):!(t instanceof tt||e instanceof tt||t!==e)}var nt,rt,ot=(($={})[exports.ChainId.ETH]=new tt(exports.ChainId.ETH,"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",18,"WETH","Wrapped ETH"),$[exports.ChainId.MAINNET]=new tt(exports.ChainId.MAINNET,"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",18,"WBNB","Wrapped BNB"),$[exports.ChainId.BSCTESTNET]=new tt(exports.ChainId.BSCTESTNET,"0xaE8E19eFB41e7b96815649A6a60785e1fbA84C1e",18,"WBNB","Wrapped BNB"),$[exports.ChainId.POLYGON]=new tt(exports.ChainId.POLYGON,"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",18,"WMATIC","Wrapped MATIC"),$[exports.ChainId.AVAX]=new tt(exports.ChainId.AVAX,"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",18,"WAVAX","Avalanche Token"),$),it=c(d),at=c(s),ut=((nt={})[exports.Rounding.ROUND_DOWN]=it.ROUND_DOWN,nt[exports.Rounding.ROUND_HALF_UP]=it.ROUND_HALF_UP,nt[exports.Rounding.ROUND_UP]=it.ROUND_UP,nt),st=((rt={})[exports.Rounding.ROUND_DOWN]=0,rt[exports.Rounding.ROUND_HALF_UP]=1,rt[exports.Rounding.ROUND_UP]=3,rt),ct=function(){function t(t,e){void 0===e&&(e=k),this.numerator=G(t),this.denominator=G(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(G(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(G(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(G(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(G(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(G(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(G(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(G(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),it.set({precision:t+1,rounding:ut[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)||a(!1),t>=0||a(!1),at.DP=t,at.RM=st[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(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}(),dt=c(s),ft=function(t){function e(e,n){var r,o=G(n);return V(o,v.uint256),(r=t.call(this,o,i.exponentiate(I,i.BigInt(e.decimals)))||this).currency=e,r}_(e,t),e.ether=function(t){return new e(K,t)};var n=e.prototype;return n.add=function(t){return et(this.currency,t.currency)||a(!1),new e(this.currency,i.add(this.raw,t.raw))},n.subtract=function(t){return et(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:""}),dt.DP=this.currency.decimals,new dt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},P(e,[{key:"raw",get:function(){return this.numerator}}]),e}(ct),pt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}_(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),lt=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 ct(i.exponentiate(I,i.BigInt(e.decimals)),i.exponentiate(I,i.BigInt(n.decimals))),a}_(e,t),e.fromRoute=function(t){for(var n,r=[],o=M(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){et(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 et(e.currency,this.baseCurrency)||a(!1),this.quoteCurrency instanceof tt?new pt(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)},P(e,[{key:"raw",get:function(){return new ct(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(ct),ht={},mt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new tt(r[0].token.chainId,t.getAddress(r[0].token,r[1].token),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=r}t.getAddress=function(t,e){var n,r,o=t.sortsBefore(e)?[t,e]:[e,t];if(void 0===(null===(n=ht)||void 0===n||null===(r=n[o[0].address])||void 0===r?void 0:r[o[1].address])){var i,a,s,c=t.chainId,d=T[c];ht=U({},ht,((s={})[o[0].address]=U({},null===(i=ht)||void 0===i?void 0:i[o[0].address],((a={})[o[1].address]=u.getCreate2Address(y[c],f.keccak256(["bytes"],[f.pack(["address","address"],[o[0].address,o[1].address])]),d),a)),s))}return ht[o[0].address][o[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,g)||i.equal(this.reserve1.raw,g))throw new W;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,q),o),c=new pt(e.token.equals(this.token0)?this.token1:this.token0,i.divide(u,s));if(i.equal(c.raw,g))throw new L;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,g)||i.equal(this.reserve1.raw,g)||i.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new W;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),q),u=i.multiply(i.subtract(n.raw,e.raw),E),s=new pt(e.token.equals(this.token0)?this.token1:this.token0,i.add(i.divide(o,u),k));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,g))r=i.subtract(J(i.multiply(o[0].raw,o[1].raw)),w);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,g))throw new L;return new pt(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=G(o);if(i.equal(s,g))u=e;else{var c=J(i.multiply(this.reserve0.raw,this.reserve1.raw)),d=J(s);if(i.greaterThan(c,d)){var f=i.multiply(e.raw,i.subtract(c,d)),p=i.add(i.multiply(c,b),d),l=i.divide(f,p);u=e.add(new pt(this.liquidityToken,l))}else u=e}}else u=e;return new pt(t,i.divide(i.multiply(n.raw,this.reserveOf(t).raw),u.raw))},P(t,[{key:"token0Price",get:function(){return new lt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new lt(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 tt&&t[0].involvesToken(e)||e===K&&t[0].involvesToken(ot[t[0].chainId])||a(!1),void 0===n||n instanceof tt&&t[t.length-1].involvesToken(n)||n===K&&t[t.length-1].involvesToken(ot[t[0].chainId])||a(!1);for(var r,o=[e instanceof tt?e:ot[t[0].chainId]],i=M(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 d=c.equals(s.token0)?s.token1:s.token0;o.push(d)}this.pairs=t,this.path=o,this.midPrice=lt.fromRoute(this),this.input=e,this.output=null!=n?n:o[o.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),yt=new ct(O),Tt=function(t){function e(){return t.apply(this,arguments)||this}_(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(yt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(yt).toFixed(t,e,n)},e}(ct);function wt(t,e){return et(t.inputAmount.currency,e.inputAmount.currency)||a(!1),et(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 kt(t,e){return t instanceof pt?t:t.currency===K?new pt(ot[e],t.raw):void a(!1)}function At(t,e){return t instanceof tt?t:t===K?ot[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){et(e.currency,t.input)||a(!1),u[0]=kt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var d=t.pairs[c].getOutputAmount(u[c]),f=d[1];u[c+1]=d[0],s[c]=f}}else{et(e.currency,t.output)||a(!1),u[u.length-1]=kt(e,t.chainId);for(var p=t.path.length-1;p>0;p--){var l=t.pairs[p-1].getInputAmount(u[p]),h=l[1];u[p-1]=l[0],s[p-1]=h}}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 lt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=lt.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 Tt(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(g)&&a(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new ct(k).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof pt?new pt(this.outputAmount.token,e):ft.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&a(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new ct(k).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof pt?new pt(this.inputAmount.token,e):ft.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,f=void 0===d?3:d,p=c.maxHops,l=void 0===p?3:p;void 0===i&&(i=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===n||i.length>0||a(!1);var h=n instanceof pt?n.token.chainId:r instanceof tt?r.chainId:void 0;void 0===h&&a(!1);for(var m=kt(n,h),v=At(r,h),y=0;y<e.length;y++){var T=e[y];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(w.token.equals(v))Q(s,new t(new vt([].concat(i,[T]),u.currency,r),u,exports.TradeType.EXACT_INPUT),f,gt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(k,w,r,{maxNumResults:f,maxHops:l-1},[].concat(i,[T]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,f=void 0===d?3:d,p=c.maxHops,l=void 0===p?3:p;void 0===i&&(i=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===r||i.length>0||a(!1);var h=r instanceof pt?r.token.chainId:n instanceof tt?n.chainId:void 0;void 0===h&&a(!1);for(var m=kt(r,h),v=At(n,h),y=0;y<e.length;y++){var T=e[y];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(w.token.equals(v))Q(s,new t(new vt([T].concat(i),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),f,gt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(k,n,w,{maxNumResults:f,maxHops:l-1},[T].concat(i),u,s)}}}return s},t}();function bt(t){return"0x"+t.raw.toString(16)}var It,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),e.ttl>0||a(!1);var o,i,u,s=Y(e.recipient),c=bt(t.maximumAmountIn(e.allowedSlippage)),d=bt(t.minimumAmountOut(e.allowedSlippage)),f=t.route.path.map((function(t){return t.address})),p="0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16),l=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,f,s,p],u=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,f,s,p],u="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,f,s,p],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:l&&a(!1),n?(o="swapETHForExactTokens",i=[d,f,s,p],u=c):r?(o="swapTokensForExactETH",i=[d,c,f,s,p],u="0x0"):(o="swapTokensForExactTokens",i=[d,c,f,s,p],u="0x0")}return{methodName:o,args:i,value:u}},t}(),Et=[{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"}],qt=((It={})[exports.ChainId.MAINNET]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},It),Ct=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,a,u=function(n){return new tt(t,e,n,r,o)};void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t)));var s="number"==typeof(null===(i=qt)||void 0===i||null===(a=i[t])||void 0===a?void 0:a[e]);return Promise.resolve(s?u(qt[t][e]):Promise.resolve(new p.Contract(e,Et,n).decimals().then((function(n){var r,o,i;return qt=U({},qt,((i={})[t]=U({},null===(r=qt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(u))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t.chainId))),t.chainId!==e.chainId&&a(!1);var r=mt.getAddress(t,e);return Promise.resolve(new p.Contract(r,m.abi,n).getReserves()).then((function(n){var r=n[0],o=n[1],i=t.sortsBefore(e)?[r,o]:[o,r];return new mt(new pt(t,i[0]),new pt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=i,exports.Currency=z,exports.CurrencyAmount=ft,exports.ETHER=K,exports.FACTORY_ADDRESS=y,exports.Fetcher=Ct,exports.Fraction=ct,exports.INIT_CODE_HASH=T,exports.InsufficientInputAmountError=L,exports.InsufficientReservesError=W,exports.MATIC=Z,exports.MINIMUM_LIQUIDITY=w,exports.Pair=mt,exports.Percent=Tt,exports.Price=lt,exports.Route=vt,exports.Router=Ot,exports.Token=tt,exports.TokenAmount=pt,exports.Trade=xt,exports.WETH=ot,exports.currencyEquals=et,exports.inputOutputComparator=wt,exports.tradeComparator=gt;
"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")),d=t(require("decimal.js-light")),f=require("@ethersproject/solidity"),p=require("@ethersproject/contracts"),l=require("@ethersproject/networks"),h=require("@ethersproject/providers"),m=t(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.ETH=1]="ETH",n[n.MAINNET=56]="MAINNET",n[n.ONTEVM=56]="ONTEVM",n[n.BSCTESTNET=97]="BSCTESTNET",n[n.POLYGON=137]="POLYGON",n[n.KAVA=2222]="KAVA",n[n.AVAX=43114]="AVAX",(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,y={1:"0x1F8c25f8DA3990Ecd3632eE4F02C2eA37755C3c6",56:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",58:"0x1AA8c24ac757758e27E66E619429cA87d3Fc28BB",97:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",137:"0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf",2222:"0x6dd434082EAB5Cd134B33719ec1FF05fE985B97b",43114:"0x042AF448582d0a3cE3CFa5b65c2675e88610B18d"},T={1:"0x338b9651a8c140547a88432caaff04a13e79d54b23e3cfec1e37fb3051125fab",56:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",58:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",97:"0xe7da666f616ba3bdb18c6908b22d556a41659bdd652762c246b8d1fa4f7506b4",137:"0x0415568b317738f62f1608a814ac51b81c10e7300e23f4b1395231fc8251e7e4",2222:"0xc26b7c10cfd3e76ca96f0c5d9191b4c2e08295897ffd6e452ae36b1f11f6fec3",43114:"0x0761dc23a5b0e399fc92b9c3ea676b0314153899f2e30483c7217dcc02046630"},w=i.BigInt(1e3),g=i.BigInt(0),k=i.BigInt(1),A=i.BigInt(2),x=i.BigInt(3),b=i.BigInt(5),I=i.BigInt(10),E=i.BigInt(100),O=i.BigInt(998),q=i.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(v||(v={}));var C=((e={})[v.uint8]=i.BigInt("0xff"),e[v.uint256]=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);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),t}function U(){return(U=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 _(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function R(t,e){return(R=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function S(t,e,n){return(S=F()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&R(o,n.prototype),o}).apply(null,arguments)}function D(t){var e="function"==typeof Map?new Map:void 0;return(D=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 S(t,arguments,B(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),R(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 H(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 M(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return H(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)?H(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.")}return(n=t[Symbol.iterator]()).next.bind(n)}var X="setPrototypeOf"in Object,W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,X&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return _(e,t),e}(D(Error)),L=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,X&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return _(e,t),e}(D(Error));function V(t,e){i.greaterThanOrEqual(t,g)||a(!1),i.lessThanOrEqual(t,C[e])||a(!1)}function Y(t){try{return u.getAddress(t)}catch(t){a(!1)}}function G(t){return t instanceof i?t:i.BigInt("bigint"==typeof t?t.toString():t)}function K(t){V(t,v.uint256);var e,n=g;if(i.greaterThan(t,x))for(n=t,e=i.add(i.divide(t,A),k);i.lessThan(e,n);)n=e,e=i.divide(i.add(i.divide(t,e),e),A);else i.notEqual(t,g)&&(n=k);return n}function J(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 Q,$=function(t,e,n){V(i.BigInt(t),v.uint8),this.decimals=t,this.symbol=e,this.name=n},z=$.ETHER=new $(18,"BNB","Binance"),Z=$.MATIC=new $(18,"MATIC","Polygon"),tt=function(t){function e(e,n,r,o,i){var a;return(a=t.call(this,r,o,i)||this).chainId=e,a.address=Y(n),a}_(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}($);function et(t,e){return t instanceof tt&&e instanceof tt?t.equals(e):!(t instanceof tt||e instanceof tt||t!==e)}var nt,rt,ot=((Q={})[exports.ChainId.ETH]=new tt(exports.ChainId.ETH,"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",18,"WETH","Wrapped ETH"),Q[exports.ChainId.MAINNET]=new tt(exports.ChainId.MAINNET,"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",18,"WBNB","Wrapped BNB"),Q[exports.ChainId.BSCTESTNET]=new tt(exports.ChainId.BSCTESTNET,"0xaE8E19eFB41e7b96815649A6a60785e1fbA84C1e",18,"WBNB","Wrapped BNB"),Q[exports.ChainId.POLYGON]=new tt(exports.ChainId.POLYGON,"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",18,"WMATIC","Wrapped MATIC"),Q[exports.ChainId.AVAX]=new tt(exports.ChainId.AVAX,"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",18,"WAVAX","Avalanche Token"),Q),it=c(d),at=c(s),ut=((nt={})[exports.Rounding.ROUND_DOWN]=it.ROUND_DOWN,nt[exports.Rounding.ROUND_HALF_UP]=it.ROUND_HALF_UP,nt[exports.Rounding.ROUND_UP]=it.ROUND_UP,nt),st=((rt={})[exports.Rounding.ROUND_DOWN]=0,rt[exports.Rounding.ROUND_HALF_UP]=1,rt[exports.Rounding.ROUND_UP]=3,rt),ct=function(){function t(t,e){void 0===e&&(e=k),this.numerator=G(t),this.denominator=G(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(G(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(G(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(G(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(G(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(G(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(G(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(G(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),it.set({precision:t+1,rounding:ut[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)||a(!1),t>=0||a(!1),at.DP=t,at.RM=st[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(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}(),dt=c(s),ft=function(t){function e(e,n){var r,o=G(n);return V(o,v.uint256),(r=t.call(this,o,i.exponentiate(I,i.BigInt(e.decimals)))||this).currency=e,r}_(e,t),e.ether=function(t){return new e(z,t)};var n=e.prototype;return n.add=function(t){return et(this.currency,t.currency)||a(!1),new e(this.currency,i.add(this.raw,t.raw))},n.subtract=function(t){return et(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:""}),dt.DP=this.currency.decimals,new dt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},P(e,[{key:"raw",get:function(){return this.numerator}}]),e}(ct),pt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}_(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),lt=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 ct(i.exponentiate(I,i.BigInt(e.decimals)),i.exponentiate(I,i.BigInt(n.decimals))),a}_(e,t),e.fromRoute=function(t){for(var n,r=[],o=M(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){et(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 et(e.currency,this.baseCurrency)||a(!1),this.quoteCurrency instanceof tt?new pt(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)},P(e,[{key:"raw",get:function(){return new ct(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(ct),ht={},mt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new tt(r[0].token.chainId,t.getAddress(r[0].token,r[1].token),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=r}t.getAddress=function(t,e){var n,r,o=t.sortsBefore(e)?[t,e]:[e,t];if(void 0===(null===(n=ht)||void 0===n||null===(r=n[o[0].address])||void 0===r?void 0:r[o[1].address])){var i,a,s,c=t.chainId,d=T[c];ht=U({},ht,((s={})[o[0].address]=U({},null===(i=ht)||void 0===i?void 0:i[o[0].address],((a={})[o[1].address]=u.getCreate2Address(y[c],f.keccak256(["bytes"],[f.pack(["address","address"],[o[0].address,o[1].address])]),d),a)),s))}return ht[o[0].address][o[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,g)||i.equal(this.reserve1.raw,g))throw new W;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(e.raw,O),u=i.multiply(o,r.raw),s=i.add(i.multiply(n.raw,q),o),c=new pt(e.token.equals(this.token0)?this.token1:this.token0,i.divide(u,s));if(i.equal(c.raw,g))throw new L;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,g)||i.equal(this.reserve1.raw,g)||i.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new W;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),q),u=i.multiply(i.subtract(n.raw,e.raw),O),s=new pt(e.token.equals(this.token0)?this.token1:this.token0,i.add(i.divide(o,u),k));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,g))r=i.subtract(K(i.multiply(o[0].raw,o[1].raw)),w);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,g))throw new L;return new pt(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=G(o);if(i.equal(s,g))u=e;else{var c=K(i.multiply(this.reserve0.raw,this.reserve1.raw)),d=K(s);if(i.greaterThan(c,d)){var f=i.multiply(e.raw,i.subtract(c,d)),p=i.add(i.multiply(c,b),d),l=i.divide(f,p);u=e.add(new pt(this.liquidityToken,l))}else u=e}}else u=e;return new pt(t,i.divide(i.multiply(n.raw,this.reserveOf(t).raw),u.raw))},P(t,[{key:"token0Price",get:function(){return new lt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new lt(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 tt&&t[0].involvesToken(e)||e===z&&t[0].involvesToken(ot[t[0].chainId])||a(!1),void 0===n||n instanceof tt&&t[t.length-1].involvesToken(n)||n===z&&t[t.length-1].involvesToken(ot[t[0].chainId])||a(!1);for(var r,o=[e instanceof tt?e:ot[t[0].chainId]],i=M(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 d=c.equals(s.token0)?s.token1:s.token0;o.push(d)}this.pairs=t,this.path=o,this.midPrice=lt.fromRoute(this),this.input=e,this.output=null!=n?n:o[o.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),yt=new ct(E),Tt=function(t){function e(){return t.apply(this,arguments)||this}_(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(yt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(yt).toFixed(t,e,n)},e}(ct);function wt(t,e){return et(t.inputAmount.currency,e.inputAmount.currency)||a(!1),et(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 kt(t,e){return t instanceof pt?t:t.currency===z?new pt(ot[e],t.raw):void a(!1)}function At(t,e){return t instanceof tt?t:t===z?ot[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){et(e.currency,t.input)||a(!1),u[0]=kt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var d=t.pairs[c].getOutputAmount(u[c]),f=d[1];u[c+1]=d[0],s[c]=f}}else{et(e.currency,t.output)||a(!1),u[u.length-1]=kt(e,t.chainId);for(var p=t.path.length-1;p>0;p--){var l=t.pairs[p-1].getInputAmount(u[p]),h=l[1];u[p-1]=l[0],s[p-1]=h}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===z?ft.ether(u[0].raw):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===z?ft.ether(u[u.length-1].raw):u[u.length-1],this.executionPrice=new lt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=lt.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 Tt(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(g)&&a(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new ct(k).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof pt?new pt(this.outputAmount.token,e):ft.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&a(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new ct(k).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof pt?new pt(this.inputAmount.token,e):ft.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,f=void 0===d?3:d,p=c.maxHops,l=void 0===p?3:p;void 0===i&&(i=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===n||i.length>0||a(!1);var h=n instanceof pt?n.token.chainId:r instanceof tt?r.chainId:void 0;void 0===h&&a(!1);for(var m=kt(n,h),v=At(r,h),y=0;y<e.length;y++){var T=e[y];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(w.token.equals(v))J(s,new t(new vt([].concat(i,[T]),u.currency,r),u,exports.TradeType.EXACT_INPUT),f,gt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(k,w,r,{maxNumResults:f,maxHops:l-1},[].concat(i,[T]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,f=void 0===d?3:d,p=c.maxHops,l=void 0===p?3:p;void 0===i&&(i=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===r||i.length>0||a(!1);var h=r instanceof pt?r.token.chainId:n instanceof tt?n.chainId:void 0;void 0===h&&a(!1);for(var m=kt(r,h),v=At(n,h),y=0;y<e.length;y++){var T=e[y];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(w.token.equals(v))J(s,new t(new vt([T].concat(i),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),f,gt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(k,n,w,{maxNumResults:f,maxHops:l-1},[T].concat(i),u,s)}}}return s},t}();function bt(t){return"0x"+t.raw.toString(16)}var It,Et=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===z,r=t.outputAmount.currency===z;n&&r&&a(!1),e.ttl>0||a(!1);var o,i,u,s=Y(e.recipient),c=bt(t.maximumAmountIn(e.allowedSlippage)),d=bt(t.minimumAmountOut(e.allowedSlippage)),f=t.route.path.map((function(t){return t.address})),p="0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16),l=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,f,s,p],u=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,f,s,p],u="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,f,s,p],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:l&&a(!1),n?(o="swapETHForExactTokens",i=[d,f,s,p],u=c):r?(o="swapTokensForExactETH",i=[d,c,f,s,p],u="0x0"):(o="swapTokensForExactTokens",i=[d,c,f,s,p],u="0x0")}return{methodName:o,args:i,value:u}},t}(),Ot=[{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"}],qt=((It={})[exports.ChainId.MAINNET]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},It),Ct=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,a,u=function(n){return new tt(t,e,n,r,o)};void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t)));var s="number"==typeof(null===(i=qt)||void 0===i||null===(a=i[t])||void 0===a?void 0:a[e]);return Promise.resolve(s?u(qt[t][e]):Promise.resolve(new p.Contract(e,Ot,n).decimals().then((function(n){var r,o,i;return qt=U({},qt,((i={})[t]=U({},null===(r=qt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(u))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t.chainId))),t.chainId!==e.chainId&&a(!1);var r=mt.getAddress(t,e);return Promise.resolve(new p.Contract(r,m.abi,n).getReserves()).then((function(n){var r=n[0],o=n[1],i=t.sortsBefore(e)?[r,o]:[o,r];return new mt(new pt(t,i[0]),new pt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=i,exports.Currency=$,exports.CurrencyAmount=ft,exports.ETHER=z,exports.FACTORY_ADDRESS=y,exports.Fetcher=Ct,exports.Fraction=ct,exports.INIT_CODE_HASH=T,exports.InsufficientInputAmountError=L,exports.InsufficientReservesError=W,exports.MATIC=Z,exports.MINIMUM_LIQUIDITY=w,exports.Pair=mt,exports.Percent=Tt,exports.Price=lt,exports.Route=vt,exports.Router=Et,exports.Token=tt,exports.TokenAmount=pt,exports.Trade=xt,exports.WETH=ot,exports.currencyEquals=et,exports.inputOutputComparator=wt,exports.tradeComparator=gt;
//# sourceMappingURL=liquidity-sdk.cjs.production.min.js.map

@@ -24,2 +24,3 @@ import JSBI from 'jsbi';

ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
ChainId[ChainId["KAVA"] = 2222] = "KAVA";
ChainId[ChainId["AVAX"] = 43114] = "AVAX";

@@ -51,2 +52,3 @@ })(ChainId || (ChainId = {}));

137: '0xd76d8C2A7CA0a1609Aea0b9b5017B3F7782891bf',
2222: '0x6dd434082EAB5Cd134B33719ec1FF05fE985B97b',
43114: '0x042AF448582d0a3cE3CFa5b65c2675e88610B18d'

@@ -60,2 +62,3 @@ };

137: '0x0415568b317738f62f1608a814ac51b81c10e7300e23f4b1395231fc8251e7e4',
2222: '0xc26b7c10cfd3e76ca96f0c5d9191b4c2e08295897ffd6e452ae36b1f11f6fec3',
43114: '0x0761dc23a5b0e399fc92b9c3ea676b0314153899f2e30483c7217dcc02046630'

@@ -62,0 +65,0 @@ };

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.1.1",
"version": "0.1.2",
"description": "🛠 An SDK for building applications on top of openocean.",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

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 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