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

@hybridx-exchange/hybridx-sdk

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hybridx-exchange/hybridx-sdk - npm Package Compare versions

Comparing version 0.0.26 to 0.0.27

10

dist/constants.d.ts

@@ -20,7 +20,7 @@ import JSBI from 'jsbi';

}
export declare const CONFIG_ADDRESS = "0x5bd2BC121cF0636f016C6B4C389472fdfB6bBef5";
export declare const FACTORY_ADDRESS = "0xD2B65df7F2478166F593EC61FB31a0643E4675c4";
export declare const INIT_CODE_HASH = "0x47244c9f4c6fa4b21312ac4778654ca45d23d9ae1c6643147a0ed4ff0f658b4b";
export declare const ORDER_BOOK_FACTORY_ADDRESS = "0xA46b25eac2FBF060c8e530cCa204Cd4EADBC9abF";
export declare const ORDER_BOOK_INIT_CODE_HASH = "0x6216832c27b9f40d65b9e27bc27663a478fa8a444913c4b12bb713c0eb30c66d";
export declare const CONFIG_ADDRESS = "0x35bAFF0DC208db7e0701fc16791E5f6871443470";
export declare const FACTORY_ADDRESS = "0x8b466f281C2067a5F40A42daE43350b6A35a0b05";
export declare const INIT_CODE_HASH = "0x581ef0ccd0c15ef0a380cd82bca41249ca81e3c415fdb4fc8f6977e7d4f8c8fa";
export declare const ORDER_BOOK_FACTORY_ADDRESS = "0xA9a06cf12AE3514b101D426797D190b79B335Eb2";
export declare const ORDER_BOOK_INIT_CODE_HASH = "0x1da881d372a03ec2bce6e0bdc6c5d5696b7e7c47e8632d0bdfb6eb52d80abb48";
export declare const ORDER_NFT_INIT_CODE_HASH = "0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40";

@@ -27,0 +27,0 @@ export declare const MINIMUM_LIQUIDITY: JSBI;

@@ -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,a=t(require("jsbi")),s=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),c=t(require("big.js")),d=t(require("toformat")),p=t(require("decimal.js-light")),l=require("@ethersproject/units"),h=require("@ethersproject/solidity"),f=require("@ethersproject/contracts"),m=require("@ethersproject/networks"),v=require("@ethersproject/providers"),y=t(require("@hybridx-exchange/hybridx-protocol/build/IPair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=42262]="MAINNET",n[n.TESTNET=42261]="TESTNET",(r=exports.SwapType||(exports.SwapType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(o=exports.TradeType||(exports.TradeType={}))[o.LIMIT_BUY=1]="LIMIT_BUY",o[o.LIMIT_SELL=2]="LIMIT_SELL",(i=exports.Rounding||(exports.Rounding={}))[i.ROUND_DOWN=0]="ROUND_DOWN",i[i.ROUND_HALF_UP=1]="ROUND_HALF_UP",i[i.ROUND_UP=2]="ROUND_UP";var T,w="0x47244c9f4c6fa4b21312ac4778654ca45d23d9ae1c6643147a0ed4ff0f658b4b",k=a.BigInt(1e3),g=a.BigInt(0),x=a.BigInt(1),I=a.BigInt(2),A=a.BigInt(3),b=a.BigInt(5),O=a.BigInt(10),q=a.BigInt(100),E=a.BigInt(997),S=a.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(T||(T={}));var _=((e={})[T.uint8]=a.BigInt("0xff"),e[T.uint256]=a.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function R(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&&R(t.prototype,e),n&&R(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function C(){return(C=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 D(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,B(t,e)}function U(t){return(U=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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function N(t,e,n){return(N=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 L(t){var e="function"==typeof Map?new Map:void 0;return(L=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return N(t,arguments,U(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 M(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 M(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)?M(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 W="setPrototypeOf"in Object,X=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return D(e,t),e}(L(Error)),Y=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return D(e,t),e}(L(Error));function V(t){return"0x"+t.raw.toString(16)}function Z(t,e){a.greaterThanOrEqual(t,g)||s(!1),a.lessThanOrEqual(t,_[e])||s(!1)}function K(t){try{return u.getAddress(t)}catch(t){s(!1)}}function Q(t){return t instanceof a?t:a.BigInt("bigint"==typeof t?t.toString():t)}function G(t){Z(t,T.uint256);var e,n=g;if(a.greaterThan(t,A))for(n=t,e=a.add(a.divide(t,I),x);a.lessThan(e,n);)n=e,e=a.divide(a.add(a.divide(t,e),e),I);else a.notEqual(t,g)&&(n=x);return n}var J,$=function(t,e,n){Z(a.BigInt(t),T.uint8),this.decimals=t,this.symbol=e,this.name=n},z=$.ETHER=new $(18,"ROSE","ROSE"),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=K(n),a}D(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&&s(!1),this.address===t.address&&s(!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=((J={})[42262]=new tt(42262,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),J[42261]=new tt(42261,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),J),it=d(p),at=d(c),st=((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),ut=((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=x),this.numerator=Q(t),this.denominator=Q(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(Q(e));return a.equal(this.denominator,n.denominator)?new t(a.add(this.numerator,n.numerator),this.denominator):new t(a.add(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Q(e));return a.equal(this.denominator,n.denominator)?new t(a.subtract(this.numerator,n.numerator),this.denominator):new t(a.subtract(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Q(e));return a.lessThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Q(e));return a.equal(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Q(e));return a.greaterThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Q(e));return new t(a.multiply(this.numerator,n.numerator),a.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Q(e));return new t(a.multiply(this.numerator,n.denominator),a.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||s(!1),t>0||s(!1),it.set({precision:t+1,rounding:st[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)||s(!1),t>=0||s(!1),at.DP=t,at.RM=ut[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(t,[{key:"quotient",get:function(){return a.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(a.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),dt=d(c),pt=function(t){function e(e,n){var r,o=Q(n);return Z(o,T.uint256),(r=t.call(this,o,a.exponentiate(O,a.BigInt(e.decimals)))||this).currency=e,r}D(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)||s(!1),new e(this.currency,a.add(this.raw,t.raw))},n.subtract=function(t){return et(this.currency,t.currency)||s(!1),new e(this.currency,a.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||s(!1),t.prototype.toFixed.call(this,e,n,r)},n.toFixedWithoutExtraZero=function(n,r,o){void 0===n&&(n=this.currency.decimals),void 0===o&&(o=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||s(!1);var i=t.prototype.toFixed.call(this,n,r,o);return new e(this.currency,l.parseUnits(i,this.currency.decimals).toString()).toExact(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),lt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}D(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||s(!1),new e(this.token,a.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||s(!1),new e(this.token,a.subtract(this.raw,t.raw))},e}(pt),ht=function(t){function e(e,n,r,o){var i;return(i=t.call(this,o,r)||this).baseCurrency=e,i.quoteCurrency=n,i.scalar=new ct(a.exponentiate(O,a.BigInt(e.decimals)),a.exponentiate(O,a.BigInt(n.decimals))),i}D(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){et(this.quoteCurrency,n.baseCurrency)||s(!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)||s(!1),this.quoteCurrency instanceof tt?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):pt.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),ft={},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,i,a,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=ft)||void 0===n||null===(r=n[s[0].address])||void 0===r?void 0:r[s[1].address])&&(ft=C({},ft,((a={})[s[0].address]=C({},null===(o=ft)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0xD2B65df7F2478166F593EC61FB31a0643E4675c4",h.keccak256(["bytes"],[h.pack(["address","address"],[s[0].address,s[1].address])]),w),i)),a))),ft[s[0].address][s[1].address]};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||s(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=a.multiply(e.raw,E),i=a.multiply(o,r.raw),u=a.add(a.multiply(n.raw,S),o),c=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.divide(i,u));if(a.equal(c.raw,g))throw new Y;return[c,new t(n.add(e),r.subtract(c))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||s(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g)||a.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=a.multiply(a.multiply(r.raw,e.raw),S),i=a.multiply(a.subtract(n.raw,e.raw),E),u=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.add(a.divide(o,i),x));return[u,new t(r.add(u),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||s(!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)||s(!1),a.equal(t.raw,g))r=a.subtract(G(a.multiply(o[0].raw,o[1].raw)),k);else{var i=a.divide(a.multiply(o[0].raw,t.raw),this.reserve0.raw),u=a.divide(a.multiply(o[1].raw,t.raw),this.reserve1.raw);r=a.lessThanOrEqual(i,u)?i:u}if(!a.greaterThan(r,g))throw new Y;return new lt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,o){var i;if(void 0===r&&(r=!1),this.involvesToken(t)||s(!1),e.token.equals(this.liquidityToken)||s(!1),n.token.equals(this.liquidityToken)||s(!1),a.lessThanOrEqual(n.raw,e.raw)||s(!1),r){o||s(!1);var u=Q(o);if(a.equal(u,g))i=e;else{var c=G(a.multiply(this.reserve0.raw,this.reserve1.raw)),d=G(u);if(a.greaterThan(c,d)){var p=a.multiply(e.raw,a.subtract(c,d)),l=a.add(a.multiply(c,b),d),h=a.divide(p,l);i=e.add(new lt(this.liquidityToken,h))}else i=e}}else i=e;return new lt(t,a.divide(a.multiply(n.raw,this.reserveOf(t).raw),i.raw))},P(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={},yt={},Tt=function(){function t(e,n,r,o,i,a,s,u,c,d,p,l){this.exist=e,this.orderBookAddress=t.getAddress(n.token,r.token),this.baseToken=n,this.quoteToken=r,this.baseSignificantDigits=o<n.token.decimals?o:n.token.decimals,this.quoteSignificantDigits=i<r.token.decimals?i:r.token.decimals,this.priceStepFactor=s,this.priceStep=a,this.protocolFeeRate=u,this.subsidyFeeRate=c,this.curPrice=d,this.buyOrders=p,this.sellOrders=l}t.getAddress=function(t,e){var n,r,o,i,a,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=vt)||void 0===n||null===(r=n[s[0].address])||void 0===r?void 0:r[s[1].address])&&(vt=C({},vt,((a={})[s[0].address]=C({},null===(o=vt)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0xA46b25eac2FBF060c8e530cCa204Cd4EADBC9abF",h.keccak256(["bytes"],[h.pack(["address","address"],[s[0].address,s[1].address])]),"0x6216832c27b9f40d65b9e27bc27663a478fa8a444913c4b12bb713c0eb30c66d"),i)),a))),vt[s[0].address][s[1].address]},t.getNFTAddress=function(e,n){var r,o,i,a,s,c=e.sortsBefore(n)?[e,n]:[n,e];return void 0===(null===(r=yt)||void 0===r||null===(o=r[c[0].address])||void 0===o?void 0:o[c[1].address])&&(yt=C({},yt,((s={})[c[0].address]=C({},null===(i=yt)||void 0===i?void 0:i[c[0].address],((a={})[c[1].address]=u.getCreate2Address("0xA46b25eac2FBF060c8e530cCa204Cd4EADBC9abF",h.keccak256(["bytes"],[h.pack(["address","address","address"],[t.getAddress(e,n),c[0].address,c[1].address])]),"0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40"),a)),s))),yt[c[0].address][c[1].address]},t.culPrice=function(t,e){if(t&&e){var n=Q(t.raw),r=Q(e.raw),o=Q(l.parseUnits("1",t.token.decimals).toString()),i=e.token,s=a.divide(a.multiply(r,o),n);return new lt(i,s)}};var e=t.prototype;return e.getPriceStep=function(t){return!this.priceStep||a.EQ(Q(this.priceStep),Q("0"))?a.lessThanOrEqual(Q(t),a.BigInt(1e4))?a.BigInt(1e4):a.multiply(a.divide(Q(t),a.BigInt(1e4)),Q(this.priceStepFactor)):this.priceStep},e.getPriceStepDecimal=function(){return this.quoteSignificantDigits},e.getMinAmountDecimal=function(t){return t===exports.TradeType.LIMIT_BUY?this.quoteSignificantDigits:t===exports.TradeType.LIMIT_SELL?this.baseSignificantDigits:18},e.getMinOutputAmountDecimal=function(t){return t===exports.TradeType.LIMIT_SELL?this.quoteSignificantDigits:t===exports.TradeType.LIMIT_BUY?this.baseSignificantDigits:18},t}(),wt=function(){function t(t,e,n,r,o){t.length>0||s(!1),t.every((function(e){return e.chainId===t[0].chainId}))||s(!1),r instanceof tt&&t[0].involvesToken(r)||r===z&&t[0].involvesToken(ot[t[0].chainId])||s(!1),void 0===o||o instanceof tt&&t[t.length-1].involvesToken(o)||o===z&&t[t.length-1].involvesToken(ot[t[0].chainId])||s(!1);for(var i,a=[r instanceof tt?r:ot[t[0].chainId]],u=H(t.entries());!(i=u()).done;){var c=i.value,d=c[1],p=a[c[0]];p.equals(d.token0)||p.equals(d.token1)||s(!1);var l=p.equals(d.token0)?d.token1:d.token0;a.push(l)}this.pairs=t,this.path=a,this.amounts=e,this.extra=n,this.midPrice=ht.fromRoute(this),this.input=r,this.output=null!=o?o:a[a.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),kt=new ct(q),gt=function(t){function e(){return t.apply(this,arguments)||this}D(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(kt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(kt).toFixed(t,e,n)},e}(ct);function xt(t,e){return et(t.inputAmount.currency,e.inputAmount.currency)||s(!1),et(t.outputAmount.currency,e.outputAmount.currency)||s(!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 It(t,e){return t instanceof lt?t:t.currency===z?new lt(ot[e],t.raw):void s(!1)}function At(t,e){return t instanceof tt?t:t===z?ot[e]:void s(!1)}function bt(t,e){return new lt(t.token,e)}var Ot,qt=function(){function t(t,e,n){var r=new Array(t.path.length),o=new Array(t.pairs.length);if(t.amounts.length!==t.path.length&&s(!1),n===exports.SwapType.EXACT_INPUT){et(e.currency,t.input)||s(!1),r[0]=It(e,t.chainId);for(var i=0;i<t.path.length-1;i++){var a=t.pairs[i],u=r[i].token.equals(a.token0)?a.token1:a.token0,c=new lt(u,t.amounts[i+1]),d=new mt(bt(r[i],t.extra[6*i]),bt(c,t.extra[6*i+1]));r[i+1]=c,o[i]=d}}else{et(e.currency,t.output)||s(!1),r[r.length-1]=It(e,t.chainId);for(var p=t.path.length-1;p>0;p--){var l=t.pairs[p-1],h=r[p].token.equals(l.token0)?l.token1:l.token0,f=new lt(h,t.amounts[p-1]),m=new mt(bt(f,t.extra[6*(p-1)]),bt(r[p],t.extra[6*(p-1)+1]));r[p-1]=f,o[p-1]=m}}this.route=t,this.swapType=n,this.inputAmount=n===exports.SwapType.EXACT_INPUT?e:t.input===z?pt.ether(r[0].raw):r[0],this.outputAmount=n===exports.SwapType.EXACT_OUTPUT?e:t.output===z?pt.ether(r[r.length-1].raw):r[r.length-1],this.executionPrice=new ht(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ht.fromRoute(new wt(o,[],[],t.input)),this.priceImpact=function(t,e,n){var r=t.raw.multiply(e.raw),o=r.subtract(n.raw).divide(r);return new gt(o.numerator,o.denominator)}(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(e,n){return new t(e,n,exports.SwapType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.SwapType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(g)&&s(!1),this.swapType===exports.SwapType.EXACT_OUTPUT)return this.outputAmount;var e=new ct(x).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):pt.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&s(!1),this.swapType===exports.SwapType.EXACT_INPUT)return this.inputAmount;var e=new ct(x).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):pt.ether(e)},t.allPathExactIn=function(e,n,r,o,i,a,u){var c=(void 0===o?{}:o).maxHops,d=void 0===c?3:c;void 0===i&&(i=[]),void 0===a&&(a=n),void 0===u&&(u=[]),e.length>0||s(!1),d>0||s(!1),a===n||i.length>0||s(!1);var p=n instanceof tt?n.chainId:r instanceof tt?r.chainId:void 0;void 0===p&&s(!1);for(var l=At(n,p),h=At(r,p),f=0;f<e.length;f++){var m=e[f];if((m.token0.equals(l)||m.token1.equals(l))&&!m.reserve0.equalTo(g)&&!m.reserve1.equalTo(g)){var v=l.equals(m.token0)?m.token1:m.token0;if(v.equals(h))u.push(new wt([].concat(i,[m]),[],[],a,r));else if(d>1&&e.length>1){var y=e.slice(0,f).concat(e.slice(f+1,e.length));t.allPathExactIn(y,v,r,{maxHops:d-1},[].concat(i,[m]),a,u)}}}return u},t.allPathExactOut=function(e,n,r,o,i,a,u){var c=(void 0===o?{}:o).maxHops,d=void 0===c?3:c;void 0===i&&(i=[]),void 0===a&&(a=r),void 0===u&&(u=[]),e.length>0||s(!1),d>0||s(!1),a===r||i.length>0||s(!1);var p=r instanceof tt?r.chainId:n instanceof tt?n.chainId:void 0;void 0===p&&s(!1);for(var l=At(r,p),h=At(n,p),f=0;f<e.length;f++){var m=e[f];if((m.token0.equals(l)||m.token1.equals(l))&&!m.reserve0.equalTo(g)&&!m.reserve1.equalTo(g)){var v=l.equals(m.token0)?m.token1:m.token0;if(v.equals(h))u.push(new wt([m].concat(i),[],[],n,a));else if(d>1&&e.length>1){var y=e.slice(0,f).concat(e.slice(f+1,e.length));t.allPathExactOut(y,n,v,{maxHops:d-1},[m].concat(i),a,u)}}}return u},t}(),Et=function(){function t(t,e,n,r,o,i,a,s){this.ammAmountIn=t,this.ammAmountOut=e,this.orderAmountIn=n,this.orderAmountOut=r,this.orderFee=o,this.amountLeft=i,this.amountExpect=a,this.priceTo=s}return t.prototype.equalTo=function(t){return!!(this.ammAmountIn||this.ammAmountOut||this.orderAmountIn||this.orderAmountOut||this.amountLeft||this.amountExpect||this.orderFee)&&this.ammAmountIn.equalTo(t.ammAmountIn)&&this.ammAmountOut.equalTo(t.ammAmountOut)&&this.orderAmountIn.equalTo(t.orderAmountIn)&&this.orderAmountOut.equalTo(t.orderAmountOut)&&this.amountLeft.equalTo(t.amountLeft)&&this.amountExpect.equalTo(t.amountExpect)&&this.orderFee.equalTo(t.orderFee)},t}(),St=function(){function t(t,e){this.price=t,this.amount=e}var e=t.prototype;return e.lessThan=function(t){return this.price.lessThan(t.price)},e.equalTo=function(t){return this.price.equalTo(t.price)},e.greaterThan=function(t){return this.price.greaterThan(t.price)},t}(),_t=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===z,r=t.outputAmount.currency===z;n&&r&&s(!1),!("ttl"in e)||e.ttl>0||s(!1);var o,i,a,u=K(e.recipient),c=V(t.maximumAmountIn(e.allowedSlippage)),d=V(t.minimumAmountOut(e.allowedSlippage)),p=t.route.path.map((function(t){return t.address})),l="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),h=Boolean(e.feeOnTransfer);switch(t.swapType){case exports.SwapType.EXACT_INPUT:n?(o=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,u,l],a=c):r?(o=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,u,l],a="0x0"):(o=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,u,l],a="0x0");break;case exports.SwapType.EXACT_OUTPUT:h&&s(!1),n?(o="swapETHForExactTokens",i=[d,p,u,l],a=c):r?(o="swapTokensForExactETH",i=[d,c,p,u,l],a="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,u,l],a="0x0")}return{methodName:o,args:i,value:a}},t}(),Rt=function(){function t(){}return t.tradeCallParameters=function(t,e){var n=t.tradeType,r=t.orderBook.baseToken.token,o=t.orderBook.quoteToken.token,i=n===exports.TradeType.LIMIT_BUY&&t.quoteToken===z||n===exports.TradeType.LIMIT_SELL&&t.baseToken===z;t.baseToken===z&&r===ot[r.chainId]||t.baseToken===r||s(!1),t.quoteToken===z&&o===ot[o.chainId]||t.quoteToken===o||s(!1),(t.quoteToken===z&&t.baseToken===ot[o.chainId]||t.baseToken===z&&t.quoteToken===ot[o.chainId]||t.quoteToken===t.baseToken)&&s(!1),!("ttl"in e)||e.ttl>0||s(!1);var a,u,c,d=K(e.recipient),p=V(t.amount),l=V(t.price),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16);switch(t.tradeType){case exports.TradeType.LIMIT_BUY:i?(a="buyWithEth",u=[l,r.address,d,h],c=p):(a="buyWithToken",u=[p,l,r.address,o.address,d,h],c="0x0");break;case exports.TradeType.LIMIT_SELL:i?(a="sellEth",u=[l,o.address,d,h],c=p):(a="sellToken",u=[p,l,r.address,o.address,d,h],c="0x0")}return{methodName:a,args:u,value:c}},t}(),Pt=[{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"}],Ct=((Ot={})[exports.ChainId.MAINNET]={},Ot),Dt=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,a,s=function(n){return new tt(t,e,n,r,o)};void 0===n&&(n=v.getDefaultProvider(m.getNetwork(t)));var u="number"==typeof(null===(i=Ct)||void 0===i||null===(a=i[t])||void 0===a?void 0:a[e]);return Promise.resolve(u?s(Ct[t][e]):Promise.resolve(new f.Contract(e,Pt,n).decimals().then((function(n){var r,o,i;return Ct=C({},Ct,((i={})[t]=C({},null===(r=Ct)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(s))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=v.getDefaultProvider(m.getNetwork(t.chainId))),t.chainId!==e.chainId&&s(!1);var r=mt.getAddress(t,e);return Promise.resolve(new f.Contract(r,y.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 lt(t,i[0]),new lt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=a,exports.CONFIG_ADDRESS="0x5bd2BC121cF0636f016C6B4C389472fdfB6bBef5",exports.Currency=$,exports.CurrencyAmount=pt,exports.ETHER=z,exports.FACTORY_ADDRESS="0xD2B65df7F2478166F593EC61FB31a0643E4675c4",exports.Fetcher=Dt,exports.Fraction=ct,exports.INIT_CODE_HASH=w,exports.InsufficientInputAmountError=Y,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=k,exports.ORDER_BOOK_FACTORY_ADDRESS="0xA46b25eac2FBF060c8e530cCa204Cd4EADBC9abF",exports.ORDER_BOOK_INIT_CODE_HASH="0x6216832c27b9f40d65b9e27bc27663a478fa8a444913c4b12bb713c0eb30c66d",exports.ORDER_NFT_INIT_CODE_HASH="0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40",exports.Order=St,exports.OrderBook=Tt,exports.Pair=mt,exports.Percent=gt,exports.Price=ht,exports.Route=wt,exports.Router=_t,exports.Swap=qt,exports.Token=tt,exports.TokenAmount=lt,exports.Trade=function(t,e,n,r,o,i,a){this.orderBook=t,this.baseToken=n,this.quoteToken=r,this.tradeType=e,this.amount=o,this.price=i,this.tradeRet=a},exports.TradeRet=Et,exports.Trader=Rt,exports.UserOrder=function(t,e,n,r,o,i,a,s,u,c){this.orderBook=t,this.baseToken=e,this.quoteToken=n,this.owner=r,this.orderId=o,this.price=i,this.amountOffer=a,this.amountLeft=s,this.orderType=u,this.orderIndex=c},exports.WETH=ot,exports.ZERO=g,exports.ZERO_HEX="0x0",exports.currencyEquals=et,exports.inputOutputComparator=xt,exports.parseBigintIsh=Q,exports.sortedInsert=function(t,e,n,r){if(n>0||s(!1),t.length<=n||s(!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,a=t.length;i<a;){var u=i+a>>>1;r(t[u],e)<=0?i=u+1:a=u}return t.splice(i,0,e),o?t.pop():null},exports.sqrt=G,exports.swapComparator=function(t,e){var n=xt(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},exports.toHex=V,exports.validChainId=function(t){return t===exports.ChainId.MAINNET.valueOf()||t===exports.ChainId.TESTNET.valueOf()},exports.validateAndParseAddress=K,exports.validateSolidityTypeInstance=Z;
"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,a=t(require("jsbi")),s=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),c=t(require("big.js")),d=t(require("toformat")),p=t(require("decimal.js-light")),l=require("@ethersproject/units"),h=require("@ethersproject/solidity"),f=require("@ethersproject/contracts"),m=require("@ethersproject/networks"),v=require("@ethersproject/providers"),y=t(require("@hybridx-exchange/hybridx-protocol/build/IPair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=42262]="MAINNET",n[n.TESTNET=42261]="TESTNET",(r=exports.SwapType||(exports.SwapType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(o=exports.TradeType||(exports.TradeType={}))[o.LIMIT_BUY=1]="LIMIT_BUY",o[o.LIMIT_SELL=2]="LIMIT_SELL",(i=exports.Rounding||(exports.Rounding={}))[i.ROUND_DOWN=0]="ROUND_DOWN",i[i.ROUND_HALF_UP=1]="ROUND_HALF_UP",i[i.ROUND_UP=2]="ROUND_UP";var T,w="0x581ef0ccd0c15ef0a380cd82bca41249ca81e3c415fdb4fc8f6977e7d4f8c8fa",k=a.BigInt(1e3),g=a.BigInt(0),x=a.BigInt(1),I=a.BigInt(2),b=a.BigInt(3),A=a.BigInt(5),O=a.BigInt(10),q=a.BigInt(100),E=a.BigInt(997),S=a.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(T||(T={}));var _=((e={})[T.uint8]=a.BigInt("0xff"),e[T.uint256]=a.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function R(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&&R(t.prototype,e),n&&R(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function D(){return(D=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,C(t,e)}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function C(t,e){return(C=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function B(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function F(t,e,n){return(F=B()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&C(o,n.prototype),o}).apply(null,arguments)}function L(t){var e="function"==typeof Map?new Map:void 0;return(L=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return F(t,arguments,N(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),C(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 M(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 M(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)?M(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 W="setPrototypeOf"in Object,X=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return U(e,t),e}(L(Error)),Y=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return U(e,t),e}(L(Error));function V(t){return"0x"+t.raw.toString(16)}function Z(t,e){a.greaterThanOrEqual(t,g)||s(!1),a.lessThanOrEqual(t,_[e])||s(!1)}function K(t){try{return u.getAddress(t)}catch(t){s(!1)}}function Q(t){return t instanceof a?t:a.BigInt("bigint"==typeof t?t.toString():t)}function G(t){Z(t,T.uint256);var e,n=g;if(a.greaterThan(t,b))for(n=t,e=a.add(a.divide(t,I),x);a.lessThan(e,n);)n=e,e=a.divide(a.add(a.divide(t,e),e),I);else a.notEqual(t,g)&&(n=x);return n}var J,$=function(t,e,n){Z(a.BigInt(t),T.uint8),this.decimals=t,this.symbol=e,this.name=n},z=$.ETHER=new $(18,"ROSE","ROSE"),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=K(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&&s(!1),this.address===t.address&&s(!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=((J={})[42262]=new tt(42262,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),J[42261]=new tt(42261,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),J),it=d(p),at=d(c),st=((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),ut=((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=x),this.numerator=Q(t),this.denominator=Q(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(Q(e));return a.equal(this.denominator,n.denominator)?new t(a.add(this.numerator,n.numerator),this.denominator):new t(a.add(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Q(e));return a.equal(this.denominator,n.denominator)?new t(a.subtract(this.numerator,n.numerator),this.denominator):new t(a.subtract(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Q(e));return a.lessThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Q(e));return a.equal(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Q(e));return a.greaterThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Q(e));return new t(a.multiply(this.numerator,n.numerator),a.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Q(e));return new t(a.multiply(this.numerator,n.denominator),a.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||s(!1),t>0||s(!1),it.set({precision:t+1,rounding:st[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)||s(!1),t>=0||s(!1),at.DP=t,at.RM=ut[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(t,[{key:"quotient",get:function(){return a.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(a.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),dt=d(c),pt=function(t){function e(e,n){var r,o=Q(n);return Z(o,T.uint256),(r=t.call(this,o,a.exponentiate(O,a.BigInt(e.decimals)))||this).currency=e,r}U(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)||s(!1),new e(this.currency,a.add(this.raw,t.raw))},n.subtract=function(t){return et(this.currency,t.currency)||s(!1),new e(this.currency,a.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||s(!1),t.prototype.toFixed.call(this,e,n,r)},n.toFixedWithoutExtraZero=function(n,r,o){void 0===n&&(n=this.currency.decimals),void 0===o&&(o=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||s(!1);var i=t.prototype.toFixed.call(this,n,r,o);return new e(this.currency,l.parseUnits(i,this.currency.decimals).toString()).toExact(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),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)||s(!1),new e(this.token,a.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||s(!1),new e(this.token,a.subtract(this.raw,t.raw))},e}(pt),ht=function(t){function e(e,n,r,o){var i;return(i=t.call(this,o,r)||this).baseCurrency=e,i.quoteCurrency=n,i.scalar=new ct(a.exponentiate(O,a.BigInt(e.decimals)),a.exponentiate(O,a.BigInt(n.decimals))),i}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){et(this.quoteCurrency,n.baseCurrency)||s(!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)||s(!1),this.quoteCurrency instanceof tt?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):pt.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),ft={},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,i,a,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=ft)||void 0===n||null===(r=n[s[0].address])||void 0===r?void 0:r[s[1].address])&&(ft=D({},ft,((a={})[s[0].address]=D({},null===(o=ft)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0x8b466f281C2067a5F40A42daE43350b6A35a0b05",h.keccak256(["bytes"],[h.pack(["address","address"],[s[0].address,s[1].address])]),w),i)),a))),ft[s[0].address][s[1].address]};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||s(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=a.multiply(e.raw,E),i=a.multiply(o,r.raw),u=a.add(a.multiply(n.raw,S),o),c=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.divide(i,u));if(a.equal(c.raw,g))throw new Y;return[c,new t(n.add(e),r.subtract(c))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||s(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g)||a.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new X;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=a.multiply(a.multiply(r.raw,e.raw),S),i=a.multiply(a.subtract(n.raw,e.raw),E),u=new lt(e.token.equals(this.token0)?this.token1:this.token0,a.add(a.divide(o,i),x));return[u,new t(r.add(u),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||s(!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)||s(!1),a.equal(t.raw,g))r=a.subtract(G(a.multiply(o[0].raw,o[1].raw)),k);else{var i=a.divide(a.multiply(o[0].raw,t.raw),this.reserve0.raw),u=a.divide(a.multiply(o[1].raw,t.raw),this.reserve1.raw);r=a.lessThanOrEqual(i,u)?i:u}if(!a.greaterThan(r,g))throw new Y;return new lt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,o){var i;if(void 0===r&&(r=!1),this.involvesToken(t)||s(!1),e.token.equals(this.liquidityToken)||s(!1),n.token.equals(this.liquidityToken)||s(!1),a.lessThanOrEqual(n.raw,e.raw)||s(!1),r){o||s(!1);var u=Q(o);if(a.equal(u,g))i=e;else{var c=G(a.multiply(this.reserve0.raw,this.reserve1.raw)),d=G(u);if(a.greaterThan(c,d)){var p=a.multiply(e.raw,a.subtract(c,d)),l=a.add(a.multiply(c,A),d),h=a.divide(p,l);i=e.add(new lt(this.liquidityToken,h))}else i=e}}else i=e;return new lt(t,a.divide(a.multiply(n.raw,this.reserveOf(t).raw),i.raw))},P(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={},yt={},Tt=function(){function t(e,n,r,o,i,a,s,u,c,d,p,l){this.exist=e,this.orderBookAddress=t.getAddress(n.token,r.token),this.baseToken=n,this.quoteToken=r,this.baseSignificantDigits=o<n.token.decimals?o:n.token.decimals,this.quoteSignificantDigits=i<r.token.decimals?i:r.token.decimals,this.priceStepFactor=s,this.priceStep=a,this.protocolFeeRate=u,this.subsidyFeeRate=c,this.curPrice=d,this.buyOrders=p,this.sellOrders=l}t.getAddress=function(t,e){var n,r,o,i,a,s=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=vt)||void 0===n||null===(r=n[s[0].address])||void 0===r?void 0:r[s[1].address])&&(vt=D({},vt,((a={})[s[0].address]=D({},null===(o=vt)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0xA9a06cf12AE3514b101D426797D190b79B335Eb2",h.keccak256(["bytes"],[h.pack(["address","address"],[s[0].address,s[1].address])]),"0x1da881d372a03ec2bce6e0bdc6c5d5696b7e7c47e8632d0bdfb6eb52d80abb48"),i)),a))),vt[s[0].address][s[1].address]},t.getNFTAddress=function(e,n){var r,o,i,a,s,c=e.sortsBefore(n)?[e,n]:[n,e];return void 0===(null===(r=yt)||void 0===r||null===(o=r[c[0].address])||void 0===o?void 0:o[c[1].address])&&(yt=D({},yt,((s={})[c[0].address]=D({},null===(i=yt)||void 0===i?void 0:i[c[0].address],((a={})[c[1].address]=u.getCreate2Address("0xA9a06cf12AE3514b101D426797D190b79B335Eb2",h.keccak256(["bytes"],[h.pack(["address","address","address"],[t.getAddress(e,n),c[0].address,c[1].address])]),"0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40"),a)),s))),yt[c[0].address][c[1].address]},t.culPrice=function(t,e){if(t&&e){var n=Q(t.raw),r=Q(e.raw),o=Q(l.parseUnits("1",t.token.decimals).toString()),i=e.token,s=a.divide(a.multiply(r,o),n);return new lt(i,s)}};var e=t.prototype;return e.getPriceStep=function(t){return!this.priceStep||a.EQ(Q(this.priceStep),Q("0"))?a.lessThanOrEqual(Q(t),a.BigInt(1e4))?a.BigInt(1e4):a.multiply(a.divide(Q(t),a.BigInt(1e4)),Q(this.priceStepFactor)):this.priceStep},e.getPriceStepDecimal=function(){return this.quoteSignificantDigits},e.getMinAmountDecimal=function(t){return t===exports.TradeType.LIMIT_BUY?this.quoteSignificantDigits:t===exports.TradeType.LIMIT_SELL?this.baseSignificantDigits:18},e.getMinOutputAmountDecimal=function(t){return t===exports.TradeType.LIMIT_SELL?this.quoteSignificantDigits:t===exports.TradeType.LIMIT_BUY?this.baseSignificantDigits:18},t}(),wt=function(){function t(t,e,n,r,o){t.length>0||s(!1),t.every((function(e){return e.chainId===t[0].chainId}))||s(!1),r instanceof tt&&t[0].involvesToken(r)||r===z&&t[0].involvesToken(ot[t[0].chainId])||s(!1),void 0===o||o instanceof tt&&t[t.length-1].involvesToken(o)||o===z&&t[t.length-1].involvesToken(ot[t[0].chainId])||s(!1);for(var i,a=[r instanceof tt?r:ot[t[0].chainId]],u=H(t.entries());!(i=u()).done;){var c=i.value,d=c[1],p=a[c[0]];p.equals(d.token0)||p.equals(d.token1)||s(!1);var l=p.equals(d.token0)?d.token1:d.token0;a.push(l)}this.pairs=t,this.path=a,this.amounts=e,this.extra=n,this.midPrice=ht.fromRoute(this),this.input=r,this.output=null!=o?o:a[a.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),kt=new ct(q),gt=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(kt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(kt).toFixed(t,e,n)},e}(ct);function xt(t,e){return et(t.inputAmount.currency,e.inputAmount.currency)||s(!1),et(t.outputAmount.currency,e.outputAmount.currency)||s(!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 It(t,e){return t instanceof lt?t:t.currency===z?new lt(ot[e],t.raw):void s(!1)}function bt(t,e){return t instanceof tt?t:t===z?ot[e]:void s(!1)}function At(t,e){return new lt(t.token,e)}var Ot,qt=function(){function t(t,e,n){var r=new Array(t.path.length),o=new Array(t.pairs.length);if(t.amounts.length!==t.path.length&&s(!1),n===exports.SwapType.EXACT_INPUT){et(e.currency,t.input)||s(!1),r[0]=It(e,t.chainId);for(var i=0;i<t.path.length-1;i++){var a=t.pairs[i],u=r[i].token.equals(a.token0)?a.token1:a.token0,c=new lt(u,t.amounts[i+1]),d=new mt(At(r[i],t.extra[6*i]),At(c,t.extra[6*i+1]));r[i+1]=c,o[i]=d}}else{et(e.currency,t.output)||s(!1),r[r.length-1]=It(e,t.chainId);for(var p=t.path.length-1;p>0;p--){var l=t.pairs[p-1],h=r[p].token.equals(l.token0)?l.token1:l.token0,f=new lt(h,t.amounts[p-1]),m=new mt(At(f,t.extra[6*(p-1)]),At(r[p],t.extra[6*(p-1)+1]));r[p-1]=f,o[p-1]=m}}this.route=t,this.swapType=n,this.inputAmount=n===exports.SwapType.EXACT_INPUT?e:t.input===z?pt.ether(r[0].raw):r[0],this.outputAmount=n===exports.SwapType.EXACT_OUTPUT?e:t.output===z?pt.ether(r[r.length-1].raw):r[r.length-1],this.executionPrice=new ht(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ht.fromRoute(new wt(o,[],[],t.input)),this.priceImpact=function(t,e,n){var r=t.raw.multiply(e.raw),o=r.subtract(n.raw).divide(r);return new gt(o.numerator,o.denominator)}(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(e,n){return new t(e,n,exports.SwapType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.SwapType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(g)&&s(!1),this.swapType===exports.SwapType.EXACT_OUTPUT)return this.outputAmount;var e=new ct(x).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):pt.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&s(!1),this.swapType===exports.SwapType.EXACT_INPUT)return this.inputAmount;var e=new ct(x).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):pt.ether(e)},t.allPathExactIn=function(e,n,r,o,i,a,u){var c=(void 0===o?{}:o).maxHops,d=void 0===c?3:c;void 0===i&&(i=[]),void 0===a&&(a=n),void 0===u&&(u=[]),e.length>0||s(!1),d>0||s(!1),a===n||i.length>0||s(!1);var p=n instanceof tt?n.chainId:r instanceof tt?r.chainId:void 0;void 0===p&&s(!1);for(var l=bt(n,p),h=bt(r,p),f=0;f<e.length;f++){var m=e[f];if((m.token0.equals(l)||m.token1.equals(l))&&!m.reserve0.equalTo(g)&&!m.reserve1.equalTo(g)){var v=l.equals(m.token0)?m.token1:m.token0;if(v.equals(h))u.push(new wt([].concat(i,[m]),[],[],a,r));else if(d>1&&e.length>1){var y=e.slice(0,f).concat(e.slice(f+1,e.length));t.allPathExactIn(y,v,r,{maxHops:d-1},[].concat(i,[m]),a,u)}}}return u},t.allPathExactOut=function(e,n,r,o,i,a,u){var c=(void 0===o?{}:o).maxHops,d=void 0===c?3:c;void 0===i&&(i=[]),void 0===a&&(a=r),void 0===u&&(u=[]),e.length>0||s(!1),d>0||s(!1),a===r||i.length>0||s(!1);var p=r instanceof tt?r.chainId:n instanceof tt?n.chainId:void 0;void 0===p&&s(!1);for(var l=bt(r,p),h=bt(n,p),f=0;f<e.length;f++){var m=e[f];if((m.token0.equals(l)||m.token1.equals(l))&&!m.reserve0.equalTo(g)&&!m.reserve1.equalTo(g)){var v=l.equals(m.token0)?m.token1:m.token0;if(v.equals(h))u.push(new wt([m].concat(i),[],[],n,a));else if(d>1&&e.length>1){var y=e.slice(0,f).concat(e.slice(f+1,e.length));t.allPathExactOut(y,n,v,{maxHops:d-1},[m].concat(i),a,u)}}}return u},t}(),Et=function(){function t(t,e,n,r,o,i,a,s){this.ammAmountIn=t,this.ammAmountOut=e,this.orderAmountIn=n,this.orderAmountOut=r,this.orderFee=o,this.amountLeft=i,this.amountExpect=a,this.priceTo=s}return t.prototype.equalTo=function(t){return!!(this.ammAmountIn||this.ammAmountOut||this.orderAmountIn||this.orderAmountOut||this.amountLeft||this.amountExpect||this.orderFee)&&this.ammAmountIn.equalTo(t.ammAmountIn)&&this.ammAmountOut.equalTo(t.ammAmountOut)&&this.orderAmountIn.equalTo(t.orderAmountIn)&&this.orderAmountOut.equalTo(t.orderAmountOut)&&this.amountLeft.equalTo(t.amountLeft)&&this.amountExpect.equalTo(t.amountExpect)&&this.orderFee.equalTo(t.orderFee)},t}(),St=function(){function t(t,e){this.price=t,this.amount=e}var e=t.prototype;return e.lessThan=function(t){return this.price.lessThan(t.price)},e.equalTo=function(t){return this.price.equalTo(t.price)},e.greaterThan=function(t){return this.price.greaterThan(t.price)},t}(),_t=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===z,r=t.outputAmount.currency===z;n&&r&&s(!1),!("ttl"in e)||e.ttl>0||s(!1);var o,i,a,u=K(e.recipient),c=V(t.maximumAmountIn(e.allowedSlippage)),d=V(t.minimumAmountOut(e.allowedSlippage)),p=t.route.path.map((function(t){return t.address})),l="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),h=Boolean(e.feeOnTransfer);switch(t.swapType){case exports.SwapType.EXACT_INPUT:n?(o=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,u,l],a=c):r?(o=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,u,l],a="0x0"):(o=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,u,l],a="0x0");break;case exports.SwapType.EXACT_OUTPUT:h&&s(!1),n?(o="swapETHForExactTokens",i=[d,p,u,l],a=c):r?(o="swapTokensForExactETH",i=[d,c,p,u,l],a="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,u,l],a="0x0")}return{methodName:o,args:i,value:a}},t}(),Rt=function(){function t(){}return t.tradeCallParameters=function(t,e){var n=t.tradeType,r=t.orderBook.baseToken.token,o=t.orderBook.quoteToken.token,i=n===exports.TradeType.LIMIT_BUY&&t.quoteToken===z||n===exports.TradeType.LIMIT_SELL&&t.baseToken===z;t.baseToken===z&&r===ot[r.chainId]||t.baseToken===r||s(!1),t.quoteToken===z&&o===ot[o.chainId]||t.quoteToken===o||s(!1),(t.quoteToken===z&&t.baseToken===ot[o.chainId]||t.baseToken===z&&t.quoteToken===ot[o.chainId]||t.quoteToken===t.baseToken)&&s(!1),!("ttl"in e)||e.ttl>0||s(!1);var a,u,c,d=K(e.recipient),p=V(t.amount),l=V(t.price),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16);switch(t.tradeType){case exports.TradeType.LIMIT_BUY:i?(a="buyWithEth",u=[l,r.address,d,h],c=p):(a="buyWithToken",u=[p,l,r.address,o.address,d,h],c="0x0");break;case exports.TradeType.LIMIT_SELL:i?(a="sellEth",u=[l,o.address,d,h],c=p):(a="sellToken",u=[p,l,r.address,o.address,d,h],c="0x0")}return{methodName:a,args:u,value:c}},t}(),Pt=[{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"}],Dt=((Ot={})[exports.ChainId.MAINNET]={},Ot),Ut=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,a,s=function(n){return new tt(t,e,n,r,o)};void 0===n&&(n=v.getDefaultProvider(m.getNetwork(t)));var u="number"==typeof(null===(i=Dt)||void 0===i||null===(a=i[t])||void 0===a?void 0:a[e]);return Promise.resolve(u?s(Dt[t][e]):Promise.resolve(new f.Contract(e,Pt,n).decimals().then((function(n){var r,o,i;return Dt=D({},Dt,((i={})[t]=D({},null===(r=Dt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(s))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=v.getDefaultProvider(m.getNetwork(t.chainId))),t.chainId!==e.chainId&&s(!1);var r=mt.getAddress(t,e);return Promise.resolve(new f.Contract(r,y.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 lt(t,i[0]),new lt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=a,exports.CONFIG_ADDRESS="0x35bAFF0DC208db7e0701fc16791E5f6871443470",exports.Currency=$,exports.CurrencyAmount=pt,exports.ETHER=z,exports.FACTORY_ADDRESS="0x8b466f281C2067a5F40A42daE43350b6A35a0b05",exports.Fetcher=Ut,exports.Fraction=ct,exports.INIT_CODE_HASH=w,exports.InsufficientInputAmountError=Y,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=k,exports.ORDER_BOOK_FACTORY_ADDRESS="0xA9a06cf12AE3514b101D426797D190b79B335Eb2",exports.ORDER_BOOK_INIT_CODE_HASH="0x1da881d372a03ec2bce6e0bdc6c5d5696b7e7c47e8632d0bdfb6eb52d80abb48",exports.ORDER_NFT_INIT_CODE_HASH="0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40",exports.Order=St,exports.OrderBook=Tt,exports.Pair=mt,exports.Percent=gt,exports.Price=ht,exports.Route=wt,exports.Router=_t,exports.Swap=qt,exports.Token=tt,exports.TokenAmount=lt,exports.Trade=function(t,e,n,r,o,i,a){this.orderBook=t,this.baseToken=n,this.quoteToken=r,this.tradeType=e,this.amount=o,this.price=i,this.tradeRet=a},exports.TradeRet=Et,exports.Trader=Rt,exports.UserOrder=function(t,e,n,r,o,i,a,s,u,c){this.orderBook=t,this.baseToken=e,this.quoteToken=n,this.owner=r,this.orderId=o,this.price=i,this.amountOffer=a,this.amountLeft=s,this.orderType=u,this.orderIndex=c},exports.WETH=ot,exports.ZERO=g,exports.ZERO_HEX="0x0",exports.currencyEquals=et,exports.inputOutputComparator=xt,exports.parseBigintIsh=Q,exports.sortedInsert=function(t,e,n,r){if(n>0||s(!1),t.length<=n||s(!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,a=t.length;i<a;){var u=i+a>>>1;r(t[u],e)<=0?i=u+1:a=u}return t.splice(i,0,e),o?t.pop():null},exports.sqrt=G,exports.swapComparator=function(t,e){var n=xt(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},exports.toHex=V,exports.validChainId=function(t){return t===exports.ChainId.MAINNET.valueOf()||t===exports.ChainId.TESTNET.valueOf()},exports.validateAndParseAddress=K,exports.validateSolidityTypeInstance=Z;
//# sourceMappingURL=hybridx-sdk.cjs.production.min.js.map
{
"name": "@hybridx-exchange/hybridx-sdk",
"license": "GPL-3.0-or-later",
"version": "0.0.26",
"version": "0.0.27",
"description": "🛠 An SDK for building applications on top of HybridX.",

@@ -32,3 +32,3 @@ "main": "dist/index.js",

"@ethersproject/units": "^5.0.0-beta.131",
"@hybridx-exchange/hybridx-protocol": "0.0.30",
"@hybridx-exchange/hybridx-protocol": "0.0.31",
"big.js": "^5.2.2",

@@ -35,0 +35,0 @@ "decimal.js-light": "^2.5.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc