@photonswap/sdk
Version:
🛠An example SDK for building applications on top of Photonswap.
3 lines (2 loc) • 30.1 kB
JavaScript
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,n,r,o,i,a,s=e(require("jsbi")),u=e(require("tiny-invariant")),c=(e(require("tiny-warning")),require("@ethersproject/address")),d=e(require("big.js")),p=e(require("toformat")),f=e(require("decimal.js-light")),h=require("@ethersproject/solidity"),T=require("@ethersproject/contracts"),E=require("@ethersproject/networks"),l=require("@ethersproject/providers"),I=e(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(o=exports.ChainId||(exports.ChainId={}))[o.CRONOSMAINNET=25]="CRONOSMAINNET",o[o.CRONOSTEST=338]="CRONOSTEST",o[o.BSC_TEST_NET=97]="BSC_TEST_NET",o[o.CASSINI=339]="CASSINI",o[o.MUMBAI_TESTNET=80001]="MUMBAI_TESTNET",o[o.EVMOS_TESTNET=9e3]="EVMOS_TESTNET",o[o.EVMOS_MAINNET=9001]="EVMOS_MAINNET",o[o.KAVA_TESTNET=2221]="KAVA_TESTNET",o[o.KAVA_MAINNET=2222]="KAVA_MAINNET",o[o.SHARDEUM_LIBERTY_TESTNET=8080]="SHARDEUM_LIBERTY_TESTNET",o[o.HAQQ_TESTNET=53211]="HAQQ_TESTNET",o[o.REBUS_TESTNET=3333]="REBUS_TESTNET",o[o.MINTME_MAINNET=24734]="MINTME_MAINNET",o[o.POLYGON_ZK_TESTNET=1402]="POLYGON_ZK_TESTNET",o[o.MANTLE_TESTNET=5001]="MANTLE_TESTNET",o[o.PEPE_CHAIN=906090]="PEPE_CHAIN",o[o.SEPOLIA=11155111]="SEPOLIA",(i=exports.TradeType||(exports.TradeType={}))[i.EXACT_INPUT=0]="EXACT_INPUT",i[i.EXACT_OUTPUT=1]="EXACT_OUTPUT",(a=exports.Rounding||(exports.Rounding={}))[a.ROUND_DOWN=0]="ROUND_DOWN",a[a.ROUND_HALF_UP=1]="ROUND_HALF_UP",a[a.ROUND_UP=2]="ROUND_UP";var A,b=((t={})[exports.ChainId.CRONOSMAINNET]="0x462C98Cae5AffEED576c98A55dAA922604e2D875",t[exports.ChainId.CRONOSTEST]="0xF9db97007782ae35051a97790766531684C4943c",t[exports.ChainId.BSC_TEST_NET]="0x4117FfdD251fD54fe0dfa3Ff89b9f3a2a3d370a1",t[exports.ChainId.CASSINI]="0xD4bbbA8812263f82f97866d1fe7961eB02D695c3",t[exports.ChainId.MUMBAI_TESTNET]="0xD4bbbA8812263f82f97866d1fe7961eB02D695c3",t[exports.ChainId.EVMOS_TESTNET]="0xa95D850cad9f5c9c43f63755c3F8f5f0a7913a1f",t[exports.ChainId.EVMOS_MAINNET]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t[exports.ChainId.KAVA_TESTNET]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t[exports.ChainId.KAVA_MAINNET]="0x4FD2c40c25Dd40e9Bf0CE8479bA384178b8671b5",t[exports.ChainId.SHARDEUM_LIBERTY_TESTNET]="0x4FD2c40c25Dd40e9Bf0CE8479bA384178b8671b5",t[exports.ChainId.HAQQ_TESTNET]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t[exports.ChainId.REBUS_TESTNET]="0x361Fcc661938cD5a99C4AdacE77f2Bf0a5fe1314",t[exports.ChainId.MINTME_MAINNET]="0x9E91c2bff4a5504898a33186c19901d786B394cD",t[exports.ChainId.POLYGON_ZK_TESTNET]="0x6c6A6F2a8113f11d3F5C860ac5fD80a7398e8d2e",t[exports.ChainId.MANTLE_TESTNET]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t[exports.ChainId.PEPE_CHAIN]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t[exports.ChainId.SEPOLIA]="0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",t),m=((n={})[exports.ChainId.CRONOSTEST]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.CRONOSMAINNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.BSC_TEST_NET]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n[exports.ChainId.CASSINI]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.MUMBAI_TESTNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.EVMOS_TESTNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.EVMOS_MAINNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.KAVA_TESTNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.KAVA_MAINNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.SHARDEUM_LIBERTY_TESTNET]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n[exports.ChainId.HAQQ_TESTNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.REBUS_TESTNET]="0x1cd980072399273f55deb8c618cb6873f43e3fe305ee432ee3b9b5ff9116555d",n[exports.ChainId.MINTME_MAINNET]="0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c",n[exports.ChainId.POLYGON_ZK_TESTNET]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n[exports.ChainId.MANTLE_TESTNET]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n[exports.ChainId.PEPE_CHAIN]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n[exports.ChainId.SEPOLIA]="0xcbd5bfb195b0b40a24ed317b4dda6b82614ee29ab16622fe28aa0d62c15da783",n),v=s.BigInt(100),x=s.BigInt(0),C=s.BigInt(1),N=s.BigInt(2),y=s.BigInt(3),S=s.BigInt(5),w=s.BigInt(10),O=s.BigInt(100),_=s.BigInt(997),g=s.BigInt(1e3);!function(e){e.uint8="uint8",e.uint256="uint256"}(A||(A={}));var k=((r={})[A.uint8]=s.BigInt("0xff"),r[A.uint256]=s.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),r);function M(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function R(e,t,n){return t&&M(e.prototype,t),n&&M(e,n),e}function B(){return(B=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function F(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,U(e,t)}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function q(){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(e){return!1}}function D(e,t,n){return(D=q()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&U(o,n.prototype),o}).apply(null,arguments)}function H(e){var t="function"==typeof Map?new Map:void 0;return(H=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,P(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,e)})(e)}function V(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function W(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return L(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?L(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[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 j="setPrototypeOf"in Object,K=function(e){function t(){var n;return(n=e.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,j&&Object.setPrototypeOf(V(n),(this instanceof t?this.constructor:void 0).prototype),n}return F(t,e),t}(H(Error)),Y=function(e){function t(){var n;return(n=e.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,j&&Object.setPrototypeOf(V(n),(this instanceof t?this.constructor:void 0).prototype),n}return F(t,e),t}(H(Error));function Q(e,t){s.greaterThanOrEqual(e,x)||u(!1),s.lessThanOrEqual(e,k[t])||u(!1)}function X(e){try{return c.getAddress(e)}catch(e){u(!1)}}function G(e){return e instanceof s?e:s.BigInt("bigint"==typeof e?e.toString():e)}function Z(e){Q(e,A.uint256);var t,n=x;if(s.greaterThan(e,y))for(n=e,t=s.add(s.divide(e,N),C);s.lessThan(t,n);)n=t,t=s.divide(s.add(s.divide(e,t),t),N);else s.notEqual(e,x)&&(n=C);return n}function J(e,t,n,r){if(n>0||u(!1),e.length<=n||u(!1),0===e.length)return e.push(t),null;var o=e.length===n;if(o&&r(e[e.length-1],t)<=0)return t;for(var i=0,a=e.length;i<a;){var s=i+a>>>1;r(e[s],t)<=0?i=s+1:a=s}return e.splice(i,0,t),o?e.pop():null}var $=function(){function e(e,t,n){Q(s.BigInt(e),A.uint8),this.decimals=e,this.symbol=t,this.name=n}return e.prototype.getDisplaySymbol=function(e){if("ETHER"==this.symbol)switch(e){case exports.ChainId.BSC_TEST_NET:return"BNB";case exports.ChainId.CRONOSTEST:case exports.ChainId.CRONOSMAINNET:case exports.ChainId.CASSINI:return"CRO";case exports.ChainId.MUMBAI_TESTNET:return"MATIC";case exports.ChainId.EVMOS_TESTNET:case exports.ChainId.EVMOS_MAINNET:return"EVMOS";case exports.ChainId.KAVA_TESTNET:case exports.ChainId.KAVA_MAINNET:return"KAVA";case exports.ChainId.SHARDEUM_LIBERTY_TESTNET:return"SHM";case exports.ChainId.HAQQ_TESTNET:return"ISLM";case exports.ChainId.REBUS_TESTNET:return"REBUS";case exports.ChainId.MINTME_MAINNET:return"MINTME";case exports.ChainId.POLYGON_ZK_TESTNET:return"ETHER";case exports.ChainId.MANTLE_TESTNET:return"BIT";case exports.ChainId.PEPE_CHAIN:case exports.ChainId.SEPOLIA:return"ETH"}return this.symbol},e}();$.ETHER=new $(18,"ETHER","Eth"),$.BNB=new $(18,"BNB","BNB"),$.CRO=new $(18,"CRO","CRO"),$.MATIC=new $(18,"MATIC","Matic"),$.EVMOS=new $(18,"EVMOS","EVMOS"),$.KAVA=new $(18,"KAVA","KAVA"),$.SHARDEUM=new $(18,"SHM","SHARDEUM"),$.ISLM=new $(18,"ISLM","ISLAMCOIN"),$.REBUS=new $(18,"REBUS","REBUS"),$.MINTME=new $(18,"MINTME","MINTME");var z,ee=$.ETHER,te=function(e){function t(t,n,r,o,i){var a;return(a=e.call(this,r,o,i)||this).chainId=t,a.address=X(n),a}F(t,e);var n=t.prototype;return n.equals=function(e){return this===e||this.chainId===e.chainId&&this.address===e.address},n.sortsBefore=function(e){return this.chainId!==e.chainId&&u(!1),this.address===e.address&&u(!1),this.address.toLowerCase()<e.address.toLowerCase()},t}($);function ne(e,t){return e instanceof te&&t instanceof te?e.equals(t):!(e instanceof te||t instanceof te||e!==t)}var re,oe,ie=((z={})[exports.ChainId.CRONOSMAINNET]=new te(exports.ChainId.CRONOSMAINNET,"0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23",18,"WCRO","Wrapped Cronos"),z[exports.ChainId.CRONOSTEST]=new te(exports.ChainId.CRONOSTEST,"0xa85d35eb8E439078a1810Ec3738997E61d157f0d",18,"WCRO","Wrapped Cronos"),z[exports.ChainId.BSC_TEST_NET]=new te(exports.ChainId.BSC_TEST_NET,"0x6820305F97141dAe62bBacf73a3b09a01edfCBD9",18,"WBNB","Wrapped BNB"),z[exports.ChainId.CASSINI]=new te(exports.ChainId.CASSINI,"0x77e66C840e7198C95500f7f547543E1466C5CB2c",18,"WCRO","Wrapped Cronos"),z[exports.ChainId.MUMBAI_TESTNET]=new te(exports.ChainId.MUMBAI_TESTNET,"0x77e66C840e7198C95500f7f547543E1466C5CB2c",18,"WMATIC","Wrapped Matic"),z[exports.ChainId.EVMOS_TESTNET]=new te(exports.ChainId.EVMOS_TESTNET,"0xc8A2413D8ac65eC936F7350d6FF62ec603004565",18,"WEVMOS","Wrapped EVMOS"),z[exports.ChainId.KAVA_TESTNET]=new te(exports.ChainId.KAVA_TESTNET,"0xbAAFeC4B6eF4F5E0bAFA850CBC48364B953EFCf9",18,"WKAVA","Wrapped KAVA"),z[exports.ChainId.KAVA_MAINNET]=new te(exports.ChainId.KAVA_MAINNET,"0xc86c7C0eFbd6A49B35E8714C5f59D99De09A225b",18,"WKAVA","Wrapped KAVA"),z[exports.ChainId.MANTLE_TESTNET]=new te(exports.ChainId.MANTLE_TESTNET,"0xbAAFeC4B6eF4F5E0bAFA850CBC48364B953EFCf9",18,"WBIT","Wrapped BIT"),z[exports.ChainId.SHARDEUM_LIBERTY_TESTNET]=new te(exports.ChainId.SHARDEUM_LIBERTY_TESTNET,"0x1c671d6fEC45Ec0de88C82e6D8536bFe33F00c8a",18,"WSHM","Wrapped SHM"),z[exports.ChainId.EVMOS_MAINNET]=new te(exports.ChainId.EVMOS_MAINNET,"0xD4949664cD82660AaE99bEdc034a0deA8A0bd517",18,"WEVMOS","Wrapped EVMOS"),z[exports.ChainId.HAQQ_TESTNET]=new te(exports.ChainId.HAQQ_TESTNET,"0xbAAFeC4B6eF4F5E0bAFA850CBC48364B953EFCf9",18,"WISLM","Wrapped ISLM"),z[exports.ChainId.REBUS_TESTNET]=new te(exports.ChainId.REBUS_TESTNET,"0x1A3d70c6Ba491680393F6a05140B09358A78CFd2",18,"WREBUS","Wrapped Rebus"),z[exports.ChainId.MINTME_MAINNET]=new te(exports.ChainId.MINTME_MAINNET,"0xa297432E5c707435cd2249f78978206626dcA17C",18,"WMINTME","Wrapped MINTME"),z[exports.ChainId.POLYGON_ZK_TESTNET]=new te(exports.ChainId.POLYGON_ZK_TESTNET,"0x65A0fC432f88aF171656E707709863E82F3e0775",18,"WETH","Wrapped Ether"),z[exports.ChainId.PEPE_CHAIN]=new te(exports.ChainId.PEPE_CHAIN,"0xbAAFeC4B6eF4F5E0bAFA850CBC48364B953EFCf9",18,"WETH","Wrapped Ether"),z[exports.ChainId.SEPOLIA]=new te(exports.ChainId.SEPOLIA,"0xbAAFeC4B6eF4F5E0bAFA850CBC48364B953EFCf9",18,"WETH","Wrapped Ether"),z),ae=p(f),se=p(d),ue=((re={})[exports.Rounding.ROUND_DOWN]=ae.ROUND_DOWN,re[exports.Rounding.ROUND_HALF_UP]=ae.ROUND_HALF_UP,re[exports.Rounding.ROUND_UP]=ae.ROUND_UP,re),ce=((oe={})[exports.Rounding.ROUND_DOWN]=0,oe[exports.Rounding.ROUND_HALF_UP]=1,oe[exports.Rounding.ROUND_UP]=3,oe),de=function(){function e(e,t){void 0===t&&(t=C),this.numerator=G(e),this.denominator=G(t)}var t=e.prototype;return t.invert=function(){return new e(this.denominator,this.numerator)},t.add=function(t){var n=t instanceof e?t:new e(G(t));return s.equal(this.denominator,n.denominator)?new e(s.add(this.numerator,n.numerator),this.denominator):new e(s.add(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},t.subtract=function(t){var n=t instanceof e?t:new e(G(t));return s.equal(this.denominator,n.denominator)?new e(s.subtract(this.numerator,n.numerator),this.denominator):new e(s.subtract(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},t.lessThan=function(t){var n=t instanceof e?t:new e(G(t));return s.lessThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},t.equalTo=function(t){var n=t instanceof e?t:new e(G(t));return s.equal(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},t.greaterThan=function(t){var n=t instanceof e?t:new e(G(t));return s.greaterThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},t.multiply=function(t){var n=t instanceof e?t:new e(G(t));return new e(s.multiply(this.numerator,n.numerator),s.multiply(this.denominator,n.denominator))},t.divide=function(t){var n=t instanceof e?t:new e(G(t));return new e(s.multiply(this.numerator,n.denominator),s.multiply(this.denominator,n.numerator))},t.toSignificant=function(e,t,n){void 0===t&&(t={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(e)||u(!1),e>0||u(!1),ae.set({precision:e+1,rounding:ue[n]});var r=new ae(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),t)},t.toFixed=function(e,t,n){return void 0===t&&(t={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(e)||u(!1),e>=0||u(!1),se.DP=e,se.RM=ce[n],new se(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)},R(e,[{key:"quotient",get:function(){return s.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new e(s.remainder(this.numerator,this.denominator),this.denominator)}}]),e}(),pe=p(d),fe=function(e){function t(t,n){var r,o=G(n);return Q(o,A.uint256),(r=e.call(this,o,s.exponentiate(w,s.BigInt(t.decimals)))||this).currency=t,r}F(t,e),t.ether=function(e){return new t(ee,e)};var n=t.prototype;return n.add=function(e){return ne(this.currency,e.currency)||u(!1),new t(this.currency,s.add(this.raw,e.raw))},n.subtract=function(e){return ne(this.currency,e.currency)||u(!1),new t(this.currency,s.subtract(this.raw,e.raw))},n.toSignificant=function(t,n,r){return void 0===t&&(t=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e.prototype.toSignificant.call(this,t,n,r)},n.toFixed=function(t,n,r){return void 0===t&&(t=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t<=this.currency.decimals||u(!1),e.prototype.toFixed.call(this,t,n,r)},n.toExact=function(e){return void 0===e&&(e={groupSeparator:""}),pe.DP=this.currency.decimals,new pe(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)},R(t,[{key:"raw",get:function(){return this.numerator}}]),t}(de),he=function(e){function t(t,n){var r;return(r=e.call(this,t,n)||this).token=t,r}F(t,e);var n=t.prototype;return n.add=function(e){return this.token.equals(e.token)||u(!1),new t(this.token,s.add(this.raw,e.raw))},n.subtract=function(e){return this.token.equals(e.token)||u(!1),new t(this.token,s.subtract(this.raw,e.raw))},t}(fe),Te=function(e){function t(t,n,r,o){var i;return(i=e.call(this,o,r)||this).baseCurrency=t,i.quoteCurrency=n,i.scalar=new de(s.exponentiate(w,s.BigInt(t.decimals)),s.exponentiate(w,s.BigInt(n.decimals))),i}F(t,e),t.fromRoute=function(e){for(var n,r=[],o=W(e.pairs.entries());!(n=o()).done;){var i=n.value,a=i[1];r.push(e.path[i[0]].equals(a.token0)?new t(a.reserve0.currency,a.reserve1.currency,a.reserve0.raw,a.reserve1.raw):new t(a.reserve1.currency,a.reserve0.currency,a.reserve1.raw,a.reserve0.raw))}return r.slice(1).reduce((function(e,t){return e.multiply(t)}),r[0])};var n=t.prototype;return n.invert=function(){return new t(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},n.multiply=function(n){ne(this.quoteCurrency,n.baseCurrency)||u(!1);var r=e.prototype.multiply.call(this,n);return new t(this.baseCurrency,n.quoteCurrency,r.denominator,r.numerator)},n.quote=function(t){return ne(t.currency,this.baseCurrency)||u(!1),this.quoteCurrency instanceof te?new he(this.quoteCurrency,e.prototype.multiply.call(this,t.raw).quotient):fe.ether(e.prototype.multiply.call(this,t.raw).quotient)},n.toSignificant=function(e,t,n){return void 0===e&&(e=6),this.adjusted.toSignificant(e,t,n)},n.toFixed=function(e,t,n){return void 0===e&&(e=4),this.adjusted.toFixed(e,t,n)},R(t,[{key:"raw",get:function(){return new de(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return e.prototype.multiply.call(this,this.scalar)}}]),t}(de),Ee={},le=function(){function e(t,n){var r=t.token.sortsBefore(n.token)?[t,n]:[n,t];this.liquidityToken=new te(r[0].token.chainId,e.getAddress(r[0].token,r[1].token),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=r}e.getAddress=function(e,t){var n,r,o,i,a,s=e.sortsBefore(t)?[e,t]:[t,e];return void 0===(null===(n=Ee)||void 0===n||null===(r=n[s[0].address])||void 0===r?void 0:r[s[1].address])&&(Ee=B({},Ee,((a={})[s[0].address]=B({},null===(o=Ee)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=c.getCreate2Address(b[s[0].chainId],h.keccak256(["bytes"],[h.pack(["address","address"],[s[0].address,s[1].address])]),m[s[0].chainId]),i)),a))),Ee[s[0].address][s[1].address]};var t=e.prototype;return t.involvesToken=function(e){return e.equals(this.token0)||e.equals(this.token1)},t.priceOf=function(e){return this.involvesToken(e)||u(!1),e.equals(this.token0)?this.token0Price:this.token1Price},t.reserveOf=function(e){return this.involvesToken(e)||u(!1),e.equals(this.token0)?this.reserve0:this.reserve1},t.getOutputAmount=function(t){if(this.involvesToken(t.token)||u(!1),s.equal(this.reserve0.raw,x)||s.equal(this.reserve1.raw,x))throw new K;var n=this.reserveOf(t.token),r=this.reserveOf(t.token.equals(this.token0)?this.token1:this.token0),o=s.multiply(t.raw,_),i=s.multiply(o,r.raw),a=s.add(s.multiply(n.raw,g),o),c=new he(t.token.equals(this.token0)?this.token1:this.token0,s.divide(i,a));if(s.equal(c.raw,x))throw new Y;return[c,new e(n.add(t),r.subtract(c))]},t.getInputAmount=function(t){if(this.involvesToken(t.token)||u(!1),s.equal(this.reserve0.raw,x)||s.equal(this.reserve1.raw,x)||s.greaterThanOrEqual(t.raw,this.reserveOf(t.token).raw))throw new K;var n=this.reserveOf(t.token),r=this.reserveOf(t.token.equals(this.token0)?this.token1:this.token0),o=s.multiply(s.multiply(r.raw,t.raw),g),i=s.multiply(s.subtract(n.raw,t.raw),_),a=new he(t.token.equals(this.token0)?this.token1:this.token0,s.add(s.divide(o,i),C));return[a,new e(r.add(a),n.subtract(t))]},t.getLiquidityMinted=function(e,t,n){e.token.equals(this.liquidityToken)||u(!1);var r,o=t.token.sortsBefore(n.token)?[t,n]:[n,t];if(o[0].token.equals(this.token0)&&o[1].token.equals(this.token1)||u(!1),s.equal(e.raw,x))r=s.subtract(Z(s.multiply(o[0].raw,o[1].raw)),v);else{var i=s.divide(s.multiply(o[0].raw,e.raw),this.reserve0.raw),a=s.divide(s.multiply(o[1].raw,e.raw),this.reserve1.raw);r=s.lessThanOrEqual(i,a)?i:a}if(!s.greaterThan(r,x))throw new Y;return new he(this.liquidityToken,r)},t.getLiquidityValue=function(e,t,n,r,o){var i;if(void 0===r&&(r=!1),this.involvesToken(e)||u(!1),t.token.equals(this.liquidityToken)||u(!1),n.token.equals(this.liquidityToken)||u(!1),s.lessThanOrEqual(n.raw,t.raw)||u(!1),r){o||u(!1);var a=G(o);if(s.equal(a,x))i=t;else{var c=Z(s.multiply(this.reserve0.raw,this.reserve1.raw)),d=Z(a);if(s.greaterThan(c,d)){var p=s.multiply(t.raw,s.subtract(c,d)),f=s.add(s.multiply(c,S),d),h=s.divide(p,f);i=t.add(new he(this.liquidityToken,h))}else i=t}}else i=t;return new he(e,s.divide(s.multiply(n.raw,this.reserveOf(e).raw),i.raw))},R(e,[{key:"token0Price",get:function(){return new Te(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new Te(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]}}]),e}(),Ie=function(){function e(e,t,n){e.length>0||u(!1),e.every((function(t){return t.chainId===e[0].chainId}))||u(!1),t instanceof te&&e[0].involvesToken(t)||t===ee&&e[0].involvesToken(ie[e[0].chainId])||u(!1),void 0===n||n instanceof te&&e[e.length-1].involvesToken(n)||n===ee&&e[e.length-1].involvesToken(ie[e[0].chainId])||u(!1);for(var r,o=[t instanceof te?t:ie[e[0].chainId]],i=W(e.entries());!(r=i()).done;){var a=r.value,s=a[1],c=o[a[0]];c.equals(s.token0)||c.equals(s.token1)||u(!1);var d=c.equals(s.token0)?s.token1:s.token0;o.push(d)}this.pairs=e,this.path=o,this.midPrice=Te.fromRoute(this),this.input=t,this.output=null!=n?n:o[o.length-1]}return R(e,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),e}(),Ae=new de(O),be=function(e){function t(){return e.apply(this,arguments)||this}F(t,e);var n=t.prototype;return n.toSignificant=function(e,t,n){return void 0===e&&(e=5),this.multiply(Ae).toSignificant(e,t,n)},n.toFixed=function(e,t,n){return void 0===e&&(e=2),this.multiply(Ae).toFixed(e,t,n)},t}(de);function me(e,t){return ne(e.inputAmount.currency,t.inputAmount.currency)||u(!1),ne(e.outputAmount.currency,t.outputAmount.currency)||u(!1),e.outputAmount.equalTo(t.outputAmount)?e.inputAmount.equalTo(t.inputAmount)?0:e.inputAmount.lessThan(t.inputAmount)?-1:1:e.outputAmount.lessThan(t.outputAmount)?1:-1}function ve(e,t){var n=me(e,t);return 0!==n?n:e.priceImpact.lessThan(t.priceImpact)?-1:e.priceImpact.greaterThan(t.priceImpact)?1:e.route.path.length-t.route.path.length}function xe(e,t){return e instanceof he?e:e.currency===ee?new he(ie[t],e.raw):void u(!1)}function Ce(e,t){return e instanceof te?e:e===ee?ie[t]:void u(!1)}var Ne=function(){function e(e,t,n){var r,o,i,a=new Array(e.path.length),s=new Array(e.pairs.length);if(n===exports.TradeType.EXACT_INPUT){ne(t.currency,e.input)||u(!1),a[0]=xe(t,e.chainId);for(var c=0;c<e.path.length-1;c++){var d=e.pairs[c].getOutputAmount(a[c]),p=d[1];a[c+1]=d[0],s[c]=p}}else{ne(t.currency,e.output)||u(!1),a[a.length-1]=xe(t,e.chainId);for(var f=e.path.length-1;f>0;f--){var h=e.pairs[f-1].getInputAmount(a[f]),T=h[1];a[f-1]=h[0],s[f-1]=T}}this.route=e,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?t:e.input===ee?fe.ether(a[0].raw):a[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?t:e.output===ee?fe.ether(a[a.length-1].raw):a[a.length-1],this.executionPrice=new Te(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=Te.fromRoute(new Ie(s,e.input)),this.priceImpact=(r=this.outputAmount,i=(o=e.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new be(i.numerator,i.denominator))}e.exactIn=function(t,n){return new e(t,n,exports.TradeType.EXACT_INPUT)},e.exactOut=function(t,n){return new e(t,n,exports.TradeType.EXACT_OUTPUT)};var t=e.prototype;return t.minimumAmountOut=function(e){if(e.lessThan(x)&&u(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var t=new de(C).add(e).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof he?new he(this.outputAmount.token,t):fe.ether(t)},t.maximumAmountIn=function(e){if(e.lessThan(x)&&u(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var t=new de(C).add(e).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof he?new he(this.inputAmount.token,t):fe.ether(t)},e.bestTradeExactIn=function(t,n,r,o,i,a,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,h=void 0===f?3:f;void 0===i&&(i=[]),void 0===a&&(a=n),void 0===s&&(s=[]),t.length>0||u(!1),h>0||u(!1),a===n||i.length>0||u(!1);var T=n instanceof he?n.token.chainId:r instanceof te?r.chainId:void 0;void 0===T&&u(!1);for(var E=xe(n,T),l=Ce(r,T),I=0;I<t.length;I++){var A=t[I];if((A.token0.equals(E.token)||A.token1.equals(E.token))&&!A.reserve0.equalTo(x)&&!A.reserve1.equalTo(x)){var b=void 0;try{b=A.getOutputAmount(E)[0]}catch(e){if(e.isInsufficientInputAmountError)continue;throw e}if(b.token.equals(l))J(s,new e(new Ie([].concat(i,[A]),a.currency,r),a,exports.TradeType.EXACT_INPUT),p,ve);else if(h>1&&t.length>1){var m=t.slice(0,I).concat(t.slice(I+1,t.length));e.bestTradeExactIn(m,b,r,{maxNumResults:p,maxHops:h-1},[].concat(i,[A]),a,s)}}}return s},e.bestTradeExactOut=function(t,n,r,o,i,a,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,h=void 0===f?3:f;void 0===i&&(i=[]),void 0===a&&(a=r),void 0===s&&(s=[]),t.length>0||u(!1),h>0||u(!1),a===r||i.length>0||u(!1);var T=r instanceof he?r.token.chainId:n instanceof te?n.chainId:void 0;void 0===T&&u(!1);for(var E=xe(r,T),l=Ce(n,T),I=0;I<t.length;I++){var A=t[I];if((A.token0.equals(E.token)||A.token1.equals(E.token))&&!A.reserve0.equalTo(x)&&!A.reserve1.equalTo(x)){var b=void 0;try{b=A.getInputAmount(E)[0]}catch(e){if(e.isInsufficientReservesError)continue;throw e}if(b.token.equals(l))J(s,new e(new Ie([A].concat(i),n,a.currency),a,exports.TradeType.EXACT_OUTPUT),p,ve);else if(h>1&&t.length>1){var m=t.slice(0,I).concat(t.slice(I+1,t.length));e.bestTradeExactOut(m,n,b,{maxNumResults:p,maxHops:h-1},[A].concat(i),a,s)}}}return s},e}();function ye(e){return"0x"+e.raw.toString(16)}var Se,we=function(){function e(){}return e.swapCallParameters=function(e,t){var n=e.inputAmount.currency===ee,r=e.outputAmount.currency===ee;n&&r&&u(!1),t.ttl>0||u(!1);var o,i,a,s=X(t.recipient),c=ye(e.maximumAmountIn(t.allowedSlippage)),d=ye(e.minimumAmountOut(t.allowedSlippage)),p=e.route.path.map((function(e){return e.address})),f="0x"+(Math.floor((new Date).getTime()/1e3)+t.ttl).toString(16),h=Boolean(t.feeOnTransfer);switch(e.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,s,f],a=c):r?(o=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,s,f],a="0x0"):(o=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,s,f],a="0x0");break;case exports.TradeType.EXACT_OUTPUT:h&&u(!1),n?(o="swapETHForExactTokens",i=[d,p,s,f],a=c):r?(o="swapTokensForExactETH",i=[d,c,p,s,f],a="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,s,f],a="0x0")}return{methodName:o,args:i,value:a}},e}(),Oe=[{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"}],_e=((Se={})[exports.ChainId.CRONOSTEST]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},Se),ge=function(){function e(){}return e.fetchTokenData=function(e,t,n,r,o){try{var i,a,s=function(n){return new te(e,t,n,r,o)};void 0===n&&(n=l.getDefaultProvider(E.getNetwork(e)));var u="number"==typeof(null===(i=_e)||void 0===i||null===(a=i[e])||void 0===a?void 0:a[t]);return Promise.resolve(u?s(_e[e][t]):Promise.resolve(new T.Contract(t,Oe,n).decimals().then((function(n){var r,o,i;return _e=B({},_e,((i={})[e]=B({},null===(r=_e)||void 0===r?void 0:r[e],((o={})[t]=n,o)),i)),n}))).then(s))}catch(e){return Promise.reject(e)}},e.fetchPairData=function(e,t,n){try{void 0===n&&(n=l.getDefaultProvider(E.getNetwork(e.chainId))),e.chainId!==t.chainId&&u(!1);var r=le.getAddress(e,t);return Promise.resolve(new T.Contract(r,I.abi,n).getReserves()).then((function(n){var r=n[0],o=n[1],i=e.sortsBefore(t)?[r,o]:[o,r];return new le(new he(e,i[0]),new he(t,i[1]))}))}catch(e){return Promise.reject(e)}},e}();exports.JSBI=s,exports.Currency=$,exports.CurrencyAmount=fe,exports.ETHER=ee,exports.FACTORY_ADDRESSES=b,exports.Fetcher=ge,exports.Fraction=de,exports.INIT_CODE_HASH=m,exports.InsufficientInputAmountError=Y,exports.InsufficientReservesError=K,exports.MINIMUM_LIQUIDITY=v,exports.Pair=le,exports.Percent=be,exports.Price=Te,exports.Route=Ie,exports.Router=we,exports.Token=te,exports.TokenAmount=he,exports.Trade=Ne,exports.WETH=ie,exports.currencyEquals=ne,exports.inputOutputComparator=me,exports.tradeComparator=ve;
//# sourceMappingURL=sdk.cjs.production.min.js.map