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.4 to 0.0.5

3

dist/entities/orderBook.d.ts

@@ -6,2 +6,3 @@ import { TokenAmount } from './fractions/tokenAmount';

export declare class OrderBook {
readonly exist: boolean;
readonly baseToken: TokenAmount;

@@ -18,3 +19,3 @@ readonly quoteToken: TokenAmount;

readonly sellOrders: Order[];
constructor(baseToken: TokenAmount, quoteToken: TokenAmount, priceStep: BigintIsh, priceStepFactor: BigintIsh, protocolFeeRate: BigintIsh, subsidyFeeRate: BigintIsh, curPrice: TokenAmount, buyOrders: Order[], sellOrders: Order[]);
constructor(exist: boolean, baseToken: TokenAmount, quoteToken: TokenAmount, priceStep: BigintIsh, priceStepFactor: BigintIsh, protocolFeeRate: BigintIsh, subsidyFeeRate: BigintIsh, curPrice: TokenAmount, buyOrders: Order[], sellOrders: Order[]);
static getAddress(tokenA: Token, tokenB: Token): string;

@@ -21,0 +22,0 @@ getMinQuoteAmount(parsedPrice: BigintIsh): BigintIsh;

@@ -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,s=t(require("jsbi")),a=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")),h=require("@ethersproject/units"),l=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="0x8d3e9891ee86bca65d9eb79bdd5d6584e20c128dacac7df8e858c4c98c55ee90",k=s.BigInt(1e3),g=s.BigInt(0),x=s.BigInt(1),I=s.BigInt(2),A=s.BigInt(3),b=s.BigInt(5),O=s.BigInt(10),q=s.BigInt(100),E=s.BigInt(997),S=s.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(T||(T={}));var R=((e={})[T.uint8]=s.BigInt("0xff"),e[T.uint256]=s.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function _(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 U(t,e,n){return e&&_(t.prototype,e),n&&_(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(){return(P=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,F(t,e)}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function F(t,e){return(F=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function 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 C(t,e,n){return(C=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&&F(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 C(t,arguments,N(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(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){s.greaterThanOrEqual(t,g)||a(!1),s.lessThanOrEqual(t,R[e])||a(!1)}function K(t){try{return u.getAddress(t)}catch(t){a(!1)}}function Q(t){return t instanceof s?t:s.BigInt("bigint"==typeof t?t.toString():t)}function G(t){Z(t,T.uint256);var e,n=g;if(s.greaterThan(t,A))for(n=t,e=s.add(s.divide(t,I),x);s.lessThan(e,n);)n=e,e=s.divide(s.add(s.divide(t,e),e),I);else s.notEqual(t,g)&&(n=x);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,s=t.length;i<s;){var u=i+s>>>1;r(t[u],e)<=0?i=u+1:s=u}return t.splice(i,0,e),o?t.pop():null}var $,z=function(t,e,n){Z(s.BigInt(t),T.uint8),this.decimals=t,this.symbol=e,this.name=n},tt=z.ETHER=new z(18,"ROSE","ROSE"),et=function(t){function e(e,n,r,o,i){var s;return(s=t.call(this,r,o,i)||this).chainId=e,s.address=K(n),s}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&&a(!1),this.address===t.address&&a(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(z);function nt(t,e){return t instanceof et&&e instanceof et?t.equals(e):!(t instanceof et||e instanceof et||t!==e)}var rt,ot,it=(($={})[42262]=new et(42262,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),$[42261]=new et(42261,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),$),st=d(p),at=d(c),ut=((rt={})[exports.Rounding.ROUND_DOWN]=st.ROUND_DOWN,rt[exports.Rounding.ROUND_HALF_UP]=st.ROUND_HALF_UP,rt[exports.Rounding.ROUND_UP]=st.ROUND_UP,rt),ct=((ot={})[exports.Rounding.ROUND_DOWN]=0,ot[exports.Rounding.ROUND_HALF_UP]=1,ot[exports.Rounding.ROUND_UP]=3,ot),dt=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 s.equal(this.denominator,n.denominator)?new t(s.add(this.numerator,n.numerator),this.denominator):new t(s.add(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Q(e));return s.equal(this.denominator,n.denominator)?new t(s.subtract(this.numerator,n.numerator),this.denominator):new t(s.subtract(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Q(e));return s.lessThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Q(e));return s.equal(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Q(e));return s.greaterThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Q(e));return new t(s.multiply(this.numerator,n.numerator),s.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Q(e));return new t(s.multiply(this.numerator,n.denominator),s.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),st.set({precision:t+1,rounding:ut[n]});var r=new st(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=ct[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},U(t,[{key:"quotient",get:function(){return s.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(s.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),pt=d(c),ht=function(t){function e(e,n){var r,o=Q(n);return Z(o,T.uint256),(r=t.call(this,o,s.exponentiate(O,s.BigInt(e.decimals)))||this).currency=e,r}D(e,t),e.ether=function(t){return new e(tt,t)};var n=e.prototype;return n.add=function(t){return nt(this.currency,t.currency)||a(!1),new e(this.currency,s.add(this.raw,t.raw))},n.subtract=function(t){return nt(this.currency,t.currency)||a(!1),new e(this.currency,s.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.toFixedWithoutExtraZero=function(n,r,o){void 0===n&&(n=this.currency.decimals),void 0===o&&(o=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||a(!1);var i=t.prototype.toFixed.call(this,n,r,o);return new e(this.currency,h.parseUnits(i,this.currency.decimals).toString()).toExact(r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),pt.DP=this.currency.decimals,new pt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},U(e,[{key:"raw",get:function(){return this.numerator}}]),e}(dt),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)||a(!1),new e(this.token,s.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,s.subtract(this.raw,t.raw))},e}(ht),ft=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 dt(s.exponentiate(O,s.BigInt(e.decimals)),s.exponentiate(O,s.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,s=i[1];r.push(t.path[i[0]].equals(s.token0)?new e(s.reserve0.currency,s.reserve1.currency,s.reserve0.raw,s.reserve1.raw):new e(s.reserve1.currency,s.reserve0.currency,s.reserve1.raw,s.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){nt(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 nt(e.currency,this.baseCurrency)||a(!1),this.quoteCurrency instanceof et?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ht.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)},U(e,[{key:"raw",get:function(){return new dt(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(dt),mt={},vt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new et(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,s,a=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=mt)||void 0===n||null===(r=n[a[0].address])||void 0===r?void 0:r[a[1].address])&&(mt=P({},mt,((s={})[a[0].address]=P({},null===(o=mt)||void 0===o?void 0:o[a[0].address],((i={})[a[1].address]=u.getCreate2Address("0xb8FD793908Fd45941F6c4D0317aDDaa69a6eD778",l.keccak256(["bytes"],[l.pack(["address","address"],[a[0].address,a[1].address])]),w),i)),s))),mt[a[0].address][a[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),s.equal(this.reserve0.raw,g)||s.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=s.multiply(e.raw,E),i=s.multiply(o,r.raw),u=s.add(s.multiply(n.raw,S),o),c=new lt(e.token.equals(this.token0)?this.token1:this.token0,s.divide(i,u));if(s.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)||a(!1),s.equal(this.reserve0.raw,g)||s.equal(this.reserve1.raw,g)||s.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=s.multiply(s.multiply(r.raw,e.raw),S),i=s.multiply(s.subtract(n.raw,e.raw),E),u=new lt(e.token.equals(this.token0)?this.token1:this.token0,s.add(s.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)||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),s.equal(t.raw,g))r=s.subtract(G(s.multiply(o[0].raw,o[1].raw)),k);else{var i=s.divide(s.multiply(o[0].raw,t.raw),this.reserve0.raw),u=s.divide(s.multiply(o[1].raw,t.raw),this.reserve1.raw);r=s.lessThanOrEqual(i,u)?i:u}if(!s.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)||a(!1),e.token.equals(this.liquidityToken)||a(!1),n.token.equals(this.liquidityToken)||a(!1),s.lessThanOrEqual(n.raw,e.raw)||a(!1),r){o||a(!1);var u=Q(o);if(s.equal(u,g))i=e;else{var c=G(s.multiply(this.reserve0.raw,this.reserve1.raw)),d=G(u);if(s.greaterThan(c,d)){var p=s.multiply(e.raw,s.subtract(c,d)),h=s.add(s.multiply(c,b),d),l=s.divide(p,h);i=e.add(new lt(this.liquidityToken,l))}else i=e}}else i=e;return new lt(t,s.divide(s.multiply(n.raw,this.reserveOf(t).raw),i.raw))},U(t,[{key:"token0Price",get:function(){return new ft(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new ft(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}(),yt={},Tt=function(){function t(e,n,r,o,i,s,a,u,c){this.orderBookAddress=t.getAddress(e.token,n.token),this.baseToken=e,this.quoteToken=n,this.minAmount=Q("10000"),this.priceStepFactor=o,this.priceStep=r,this.protocolFeeRate=i,this.subsidyFeeRate=s,this.curPrice=a,this.buyOrders=u,this.sellOrders=c}t.getAddress=function(t,e){var n,r,o,i,s,a=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=yt)||void 0===n||null===(r=n[a[0].address])||void 0===r?void 0:r[a[1].address])&&(yt=P({},yt,((s={})[a[0].address]=P({},null===(o=yt)||void 0===o?void 0:o[a[0].address],((i={})[a[1].address]=u.getCreate2Address("0x649f13A0DB654966e9abA2213629b33ebF1D4658",l.keccak256(["bytes"],[l.pack(["address","address"],[a[0].address,a[1].address])]),"0xa6e439b6721897ec0f440462b1b09316d7ca46ba3a46bdfe0520752e20b009a9"),i)),s))),yt[a[0].address][a[1].address]};var e=t.prototype;return e.getMinQuoteAmount=function(t){return s.divide(s.multiply(Q(t),Q(this.minAmount)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString()))},e.getPriceStep=function(t){return this.priceStep?this.priceStep:s.lessThanOrEqual(Q(t),s.BigInt(1e4))?s.BigInt(1e4):s.multiply(s.divide(Q(t),s.BigInt(1e4)),Q(this.priceStepFactor))},e.getPriceStepDecimal=function(){var t=h.formatUnits(this.getPriceStep(Q(this.curPrice.toExact())).toString(),this.quoteToken.token.decimals);return t.substring(t.indexOf(".")).length},e.getMinAmountDecimal=function(t){if(t===exports.TradeType.LIMIT_BUY){var e=s.divide(s.multiply(Q(this.minAmount),Q(this.priceStep)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString())),n=h.formatUnits(e.toString(),this.quoteToken.token.decimals);return n.substring(n.indexOf(".")).length}if(t===exports.TradeType.LIMIT_SELL){var r=h.formatUnits(this.minAmount.toString(),this.baseToken.token.decimals);return r.substring(r.indexOf(".")).length}return 18},e.getMinOutputAmountDecimal=function(t){if(t===exports.TradeType.LIMIT_SELL){var e=s.divide(s.multiply(Q(this.minAmount),Q(this.priceStep)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString())),n=h.formatUnits(e.toString(),this.quoteToken.token.decimals);return n.substring(n.indexOf(".")).length}if(t===exports.TradeType.LIMIT_BUY){var r=h.formatUnits(this.minAmount.toString(),this.baseToken.token.decimals);return r.substring(r.indexOf(".")).length}return 18},t}(),wt=function(){function t(t,e,n,r,o){t.length>0||a(!1),t.every((function(e){return e.chainId===t[0].chainId}))||a(!1),r instanceof et&&t[0].involvesToken(r)||r===tt&&t[0].involvesToken(it[t[0].chainId])||a(!1),void 0===o||o instanceof et&&t[t.length-1].involvesToken(o)||o===tt&&t[t.length-1].involvesToken(it[t[0].chainId])||a(!1);for(var i,s=[r instanceof et?r:it[t[0].chainId]],u=H(t.entries());!(i=u()).done;){var c=i.value,d=c[1],p=s[c[0]];p.equals(d.token0)||p.equals(d.token1)||a(!1);var h=p.equals(d.token0)?d.token1:d.token0;s.push(h)}this.pairs=t,this.path=s,this.amounts=e,this.nextReserves=n,this.midPrice=ft.fromRoute(this),this.input=r,this.output=null!=o?o:s[s.length-1]}return U(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),kt=new dt(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}(dt);function xt(t,e){return nt(t.inputAmount.currency,e.inputAmount.currency)||a(!1),nt(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 It(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}function At(t,e){return t instanceof lt?t:t.currency===tt?new lt(it[e],t.raw):void a(!1)}function bt(t,e){return t instanceof et?t:t===tt?it[e]:void a(!1)}function Ot(t,e){return new lt(t.token,e)}var qt,Et=function(){function t(t,e,n){var r=new Array(t.path.length),o=new Array(t.pairs.length);if(n===exports.SwapType.EXACT_INPUT){nt(e.currency,t.input)||a(!1),r[0]=At(e,t.chainId);for(var i=0;i<t.path.length-1;i++){var s=t.pairs[i].getOutputAmount(r[i]),u=s[0],c=s[1];t.amounts.length==t.path.length&&(u=Ot(u,t.amounts[i+1]),c=new vt(Ot(r[i],t.nextReserves[2*i]),Ot(u,t.nextReserves[2*i+1]))),r[i+1]=u,o[i]=c}}else{nt(e.currency,t.output)||a(!1),r[r.length-1]=At(e,t.chainId);for(var d=t.path.length-1;d>0;d--){var p=t.pairs[d-1].getInputAmount(r[d]),h=p[0],l=p[1];t.amounts.length==t.path.length&&(h=Ot(h,t.amounts[d-1]),l=new vt(Ot(h,t.nextReserves[2*(d-1)]),Ot(r[d],t.nextReserves[2*(d-1)+1]))),r[d-1]=h,o[d-1]=l}}this.route=t,this.swapType=n,this.inputAmount=n===exports.SwapType.EXACT_INPUT?e:t.input===tt?ht.ether(r[0].raw):r[0],this.outputAmount=n===exports.SwapType.EXACT_OUTPUT?e:t.output===tt?ht.ether(r[r.length-1].raw):r[r.length-1],this.executionPrice=new ft(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ft.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)&&a(!1),this.swapType===exports.SwapType.EXACT_OUTPUT)return this.outputAmount;var e=new dt(x).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):ht.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&a(!1),this.swapType===exports.SwapType.EXACT_INPUT)return this.inputAmount;var e=new dt(x).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):ht.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,s,u){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,h=c.maxHops,l=void 0===h?3:h;void 0===i&&(i=[]),void 0===s&&(s=n),void 0===u&&(u=[]),e.length>0||a(!1),l>0||a(!1),s===n||i.length>0||a(!1);var f=n instanceof lt?n.token.chainId:r instanceof et?r.chainId:void 0;void 0===f&&a(!1);for(var m=At(n,f),v=bt(r,f),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(u,new t(new wt([].concat(i,[T]),[],[],s.currency,r),s,exports.SwapType.EXACT_INPUT),p,It);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:p,maxHops:l-1},[].concat(i,[T]),s,u)}}}return u},t.bestTradeExactOut=function(e,n,r,o,i,s,u){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,h=c.maxHops,l=void 0===h?3:h;void 0===i&&(i=[]),void 0===s&&(s=r),void 0===u&&(u=[]),e.length>0||a(!1),l>0||a(!1),s===r||i.length>0||a(!1);var f=r instanceof lt?r.token.chainId:n instanceof et?n.chainId:void 0;void 0===f&&a(!1);for(var m=At(r,f),v=bt(n,f),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(u,new t(new wt([T].concat(i),[],[],n,s.currency),s,exports.SwapType.EXACT_OUTPUT),p,It);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:p,maxHops:l-1},[T].concat(i),s,u)}}}return u},t}(),St=function(){function t(t,e,n,r,o,i,s,a,u){this.orderBook=t,this.ammAmountIn=e,this.ammAmountOut=n,this.orderAmountIn=r,this.orderAmountOut=o,this.orderFee=i,this.amountLeft=s,this.amountExpect=a,this.priceTo=u}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}(),Rt=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===tt,r=t.outputAmount.currency===tt;n&&r&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var o,i,s,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})),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),l=Boolean(e.feeOnTransfer);switch(t.swapType){case exports.SwapType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,u,h],s=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,u,h],s="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,u,h],s="0x0");break;case exports.SwapType.EXACT_OUTPUT:l&&a(!1),n?(o="swapETHForExactTokens",i=[d,p,u,h],s=c):r?(o="swapTokensForExactETH",i=[d,c,p,u,h],s="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,u,h],s="0x0")}return{methodName:o,args:i,value:s}},t}(),Ut=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===tt||n===exports.TradeType.LIMIT_SELL&&t.baseToken===tt;t.baseToken===tt&&r===it[r.chainId]||t.baseToken===r||a(!1),t.quoteToken===tt&&o===it[o.chainId]||t.quoteToken===o||a(!1),(t.quoteToken===tt&&t.baseToken===it[o.chainId]||t.baseToken===tt&&t.quoteToken===it[o.chainId]||t.quoteToken===t.baseToken)&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var s,u,c,d=K(e.recipient),p=V(t.amount),h=V(t.price),l="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?(s="buyWithEth",u=[h,r.address,d,l],c=p):(s="buyWithToken",u=[p,h,r.address,o.address,d,l],c="0x0");break;case exports.TradeType.LIMIT_SELL:i?(s="sellEth",u=[h,o.address,d,l],c=p):(s="sellToken",u=[p,h,r.address,o.address,d,l],c="0x0")}return{methodName:s,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=((qt={})[exports.ChainId.MAINNET]={},qt),Nt=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,s,a=function(n){return new et(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===(s=i[t])||void 0===s?void 0:s[e]);return Promise.resolve(u?a(Dt[t][e]):Promise.resolve(new f.Contract(e,Pt,n).decimals().then((function(n){var r,o,i;return Dt=P({},Dt,((i={})[t]=P({},null===(r=Dt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(a))}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&&a(!1);var r=vt.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 vt(new lt(t,i[0]),new lt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=s,exports.CONFIG_ADDRESS="0xC40A5af4fBc94e268aaa598d1B2d6D6E082a0826",exports.Currency=z,exports.CurrencyAmount=ht,exports.ETHER=tt,exports.FACTORY_ADDRESS="0xb8FD793908Fd45941F6c4D0317aDDaa69a6eD778",exports.Fetcher=Nt,exports.Fraction=dt,exports.INIT_CODE_HASH=w,exports.InsufficientInputAmountError=Y,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=k,exports.ORDER_BOOK_FACTORY_ADDRESS="0x649f13A0DB654966e9abA2213629b33ebF1D4658",exports.ORDER_BOOK_INIT_CODE_HASH="0xa6e439b6721897ec0f440462b1b09316d7ca46ba3a46bdfe0520752e20b009a9",exports.ORDER_NFT_INIT_CODE_HASH="0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40",exports.Order=Rt,exports.OrderBook=Tt,exports.Pair=vt,exports.Percent=gt,exports.Price=ft,exports.Route=wt,exports.Router=_t,exports.Swap=Et,exports.Token=et,exports.TokenAmount=lt,exports.Trade=function(t,e,n,r,o,i,s){this.orderBook=t,this.baseToken=n,this.quoteToken=r,this.tradeType=e,this.amount=o,this.price=i,this.tradeRet=s},exports.TradeRet=St,exports.Trader=Ut,exports.UserOrder=function(t,e,n,r,o,i,s,a,u,c){this.orderBook=t,this.baseToken=e,this.quoteToken=n,this.owner=r,this.orderId=o,this.price=i,this.amountOffer=s,this.amountLeft=a,this.orderType=u,this.orderIndex=c},exports.WETH=it,exports.ZERO=g,exports.ZERO_HEX="0x0",exports.currencyEquals=nt,exports.inputOutputComparator=xt,exports.parseBigintIsh=Q,exports.sortedInsert=J,exports.sqrt=G,exports.swapComparator=It,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,s=t(require("jsbi")),a=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")),h=require("@ethersproject/units"),l=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="0x8d3e9891ee86bca65d9eb79bdd5d6584e20c128dacac7df8e858c4c98c55ee90",k=s.BigInt(1e3),g=s.BigInt(0),x=s.BigInt(1),I=s.BigInt(2),A=s.BigInt(3),b=s.BigInt(5),O=s.BigInt(10),q=s.BigInt(100),E=s.BigInt(997),S=s.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(T||(T={}));var R=((e={})[T.uint8]=s.BigInt("0xff"),e[T.uint256]=s.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function _(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 U(t,e,n){return e&&_(t.prototype,e),n&&_(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(){return(P=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,F(t,e)}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function F(t,e){return(F=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function 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 C(t,e,n){return(C=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&&F(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 C(t,arguments,N(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(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){s.greaterThanOrEqual(t,g)||a(!1),s.lessThanOrEqual(t,R[e])||a(!1)}function K(t){try{return u.getAddress(t)}catch(t){a(!1)}}function Q(t){return t instanceof s?t:s.BigInt("bigint"==typeof t?t.toString():t)}function G(t){Z(t,T.uint256);var e,n=g;if(s.greaterThan(t,A))for(n=t,e=s.add(s.divide(t,I),x);s.lessThan(e,n);)n=e,e=s.divide(s.add(s.divide(t,e),e),I);else s.notEqual(t,g)&&(n=x);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,s=t.length;i<s;){var u=i+s>>>1;r(t[u],e)<=0?i=u+1:s=u}return t.splice(i,0,e),o?t.pop():null}var $,z=function(t,e,n){Z(s.BigInt(t),T.uint8),this.decimals=t,this.symbol=e,this.name=n},tt=z.ETHER=new z(18,"ROSE","ROSE"),et=function(t){function e(e,n,r,o,i){var s;return(s=t.call(this,r,o,i)||this).chainId=e,s.address=K(n),s}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&&a(!1),this.address===t.address&&a(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(z);function nt(t,e){return t instanceof et&&e instanceof et?t.equals(e):!(t instanceof et||e instanceof et||t!==e)}var rt,ot,it=(($={})[42262]=new et(42262,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),$[42261]=new et(42261,"0xb9ab821f7323dB4357Bf71eA66670C01761c3d73",18,"WROSE","Wrapped ROSE"),$),st=d(p),at=d(c),ut=((rt={})[exports.Rounding.ROUND_DOWN]=st.ROUND_DOWN,rt[exports.Rounding.ROUND_HALF_UP]=st.ROUND_HALF_UP,rt[exports.Rounding.ROUND_UP]=st.ROUND_UP,rt),ct=((ot={})[exports.Rounding.ROUND_DOWN]=0,ot[exports.Rounding.ROUND_HALF_UP]=1,ot[exports.Rounding.ROUND_UP]=3,ot),dt=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 s.equal(this.denominator,n.denominator)?new t(s.add(this.numerator,n.numerator),this.denominator):new t(s.add(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Q(e));return s.equal(this.denominator,n.denominator)?new t(s.subtract(this.numerator,n.numerator),this.denominator):new t(s.subtract(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator)),s.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Q(e));return s.lessThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Q(e));return s.equal(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Q(e));return s.greaterThan(s.multiply(this.numerator,n.denominator),s.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Q(e));return new t(s.multiply(this.numerator,n.numerator),s.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Q(e));return new t(s.multiply(this.numerator,n.denominator),s.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),st.set({precision:t+1,rounding:ut[n]});var r=new st(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=ct[n],new at(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},U(t,[{key:"quotient",get:function(){return s.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(s.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),pt=d(c),ht=function(t){function e(e,n){var r,o=Q(n);return Z(o,T.uint256),(r=t.call(this,o,s.exponentiate(O,s.BigInt(e.decimals)))||this).currency=e,r}D(e,t),e.ether=function(t){return new e(tt,t)};var n=e.prototype;return n.add=function(t){return nt(this.currency,t.currency)||a(!1),new e(this.currency,s.add(this.raw,t.raw))},n.subtract=function(t){return nt(this.currency,t.currency)||a(!1),new e(this.currency,s.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.toFixedWithoutExtraZero=function(n,r,o){void 0===n&&(n=this.currency.decimals),void 0===o&&(o=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||a(!1);var i=t.prototype.toFixed.call(this,n,r,o);return new e(this.currency,h.parseUnits(i,this.currency.decimals).toString()).toExact(r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),pt.DP=this.currency.decimals,new pt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},U(e,[{key:"raw",get:function(){return this.numerator}}]),e}(dt),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)||a(!1),new e(this.token,s.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,s.subtract(this.raw,t.raw))},e}(ht),ft=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 dt(s.exponentiate(O,s.BigInt(e.decimals)),s.exponentiate(O,s.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,s=i[1];r.push(t.path[i[0]].equals(s.token0)?new e(s.reserve0.currency,s.reserve1.currency,s.reserve0.raw,s.reserve1.raw):new e(s.reserve1.currency,s.reserve0.currency,s.reserve1.raw,s.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){nt(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 nt(e.currency,this.baseCurrency)||a(!1),this.quoteCurrency instanceof et?new lt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ht.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)},U(e,[{key:"raw",get:function(){return new dt(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(dt),mt={},vt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new et(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,s,a=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=mt)||void 0===n||null===(r=n[a[0].address])||void 0===r?void 0:r[a[1].address])&&(mt=P({},mt,((s={})[a[0].address]=P({},null===(o=mt)||void 0===o?void 0:o[a[0].address],((i={})[a[1].address]=u.getCreate2Address("0xb8FD793908Fd45941F6c4D0317aDDaa69a6eD778",l.keccak256(["bytes"],[l.pack(["address","address"],[a[0].address,a[1].address])]),w),i)),s))),mt[a[0].address][a[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),s.equal(this.reserve0.raw,g)||s.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=s.multiply(e.raw,E),i=s.multiply(o,r.raw),u=s.add(s.multiply(n.raw,S),o),c=new lt(e.token.equals(this.token0)?this.token1:this.token0,s.divide(i,u));if(s.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)||a(!1),s.equal(this.reserve0.raw,g)||s.equal(this.reserve1.raw,g)||s.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=s.multiply(s.multiply(r.raw,e.raw),S),i=s.multiply(s.subtract(n.raw,e.raw),E),u=new lt(e.token.equals(this.token0)?this.token1:this.token0,s.add(s.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)||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),s.equal(t.raw,g))r=s.subtract(G(s.multiply(o[0].raw,o[1].raw)),k);else{var i=s.divide(s.multiply(o[0].raw,t.raw),this.reserve0.raw),u=s.divide(s.multiply(o[1].raw,t.raw),this.reserve1.raw);r=s.lessThanOrEqual(i,u)?i:u}if(!s.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)||a(!1),e.token.equals(this.liquidityToken)||a(!1),n.token.equals(this.liquidityToken)||a(!1),s.lessThanOrEqual(n.raw,e.raw)||a(!1),r){o||a(!1);var u=Q(o);if(s.equal(u,g))i=e;else{var c=G(s.multiply(this.reserve0.raw,this.reserve1.raw)),d=G(u);if(s.greaterThan(c,d)){var p=s.multiply(e.raw,s.subtract(c,d)),h=s.add(s.multiply(c,b),d),l=s.divide(p,h);i=e.add(new lt(this.liquidityToken,l))}else i=e}}else i=e;return new lt(t,s.divide(s.multiply(n.raw,this.reserveOf(t).raw),i.raw))},U(t,[{key:"token0Price",get:function(){return new ft(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new ft(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}(),yt={},Tt=function(){function t(e,n,r,o,i,s,a,u,c,d){this.exist=e,this.orderBookAddress=t.getAddress(n.token,r.token),this.baseToken=n,this.quoteToken=r,this.minAmount=Q("10000"),this.priceStepFactor=i,this.priceStep=o,this.protocolFeeRate=s,this.subsidyFeeRate=a,this.curPrice=u,this.buyOrders=c,this.sellOrders=d}t.getAddress=function(t,e){var n,r,o,i,s,a=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(n=yt)||void 0===n||null===(r=n[a[0].address])||void 0===r?void 0:r[a[1].address])&&(yt=P({},yt,((s={})[a[0].address]=P({},null===(o=yt)||void 0===o?void 0:o[a[0].address],((i={})[a[1].address]=u.getCreate2Address("0x649f13A0DB654966e9abA2213629b33ebF1D4658",l.keccak256(["bytes"],[l.pack(["address","address"],[a[0].address,a[1].address])]),"0xa6e439b6721897ec0f440462b1b09316d7ca46ba3a46bdfe0520752e20b009a9"),i)),s))),yt[a[0].address][a[1].address]};var e=t.prototype;return e.getMinQuoteAmount=function(t){return s.divide(s.multiply(Q(t),Q(this.minAmount)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString()))},e.getPriceStep=function(t){return this.priceStep?this.priceStep:s.lessThanOrEqual(Q(t),s.BigInt(1e4))?s.BigInt(1e4):s.multiply(s.divide(Q(t),s.BigInt(1e4)),Q(this.priceStepFactor))},e.getPriceStepDecimal=function(){var t=h.formatUnits(this.getPriceStep(Q(this.curPrice.toExact())).toString(),this.quoteToken.token.decimals);return t.substring(t.indexOf(".")).length},e.getMinAmountDecimal=function(t){if(t===exports.TradeType.LIMIT_BUY){var e=s.divide(s.multiply(Q(this.minAmount),Q(this.priceStep)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString())),n=h.formatUnits(e.toString(),this.quoteToken.token.decimals);return n.substring(n.indexOf(".")).length}if(t===exports.TradeType.LIMIT_SELL){var r=h.formatUnits(this.minAmount.toString(),this.baseToken.token.decimals);return r.substring(r.indexOf(".")).length}return 18},e.getMinOutputAmountDecimal=function(t){if(t===exports.TradeType.LIMIT_SELL){var e=s.divide(s.multiply(Q(this.minAmount),Q(this.priceStep)),Q(h.parseUnits("1",this.baseToken.token.decimals).toString())),n=h.formatUnits(e.toString(),this.quoteToken.token.decimals);return n.substring(n.indexOf(".")).length}if(t===exports.TradeType.LIMIT_BUY){var r=h.formatUnits(this.minAmount.toString(),this.baseToken.token.decimals);return r.substring(r.indexOf(".")).length}return 18},t}(),wt=function(){function t(t,e,n,r,o){t.length>0||a(!1),t.every((function(e){return e.chainId===t[0].chainId}))||a(!1),r instanceof et&&t[0].involvesToken(r)||r===tt&&t[0].involvesToken(it[t[0].chainId])||a(!1),void 0===o||o instanceof et&&t[t.length-1].involvesToken(o)||o===tt&&t[t.length-1].involvesToken(it[t[0].chainId])||a(!1);for(var i,s=[r instanceof et?r:it[t[0].chainId]],u=H(t.entries());!(i=u()).done;){var c=i.value,d=c[1],p=s[c[0]];p.equals(d.token0)||p.equals(d.token1)||a(!1);var h=p.equals(d.token0)?d.token1:d.token0;s.push(h)}this.pairs=t,this.path=s,this.amounts=e,this.nextReserves=n,this.midPrice=ft.fromRoute(this),this.input=r,this.output=null!=o?o:s[s.length-1]}return U(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),kt=new dt(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}(dt);function xt(t,e){return nt(t.inputAmount.currency,e.inputAmount.currency)||a(!1),nt(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 It(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}function At(t,e){return t instanceof lt?t:t.currency===tt?new lt(it[e],t.raw):void a(!1)}function bt(t,e){return t instanceof et?t:t===tt?it[e]:void a(!1)}function Ot(t,e){return new lt(t.token,e)}var qt,Et=function(){function t(t,e,n){var r=new Array(t.path.length),o=new Array(t.pairs.length);if(n===exports.SwapType.EXACT_INPUT){nt(e.currency,t.input)||a(!1),r[0]=At(e,t.chainId);for(var i=0;i<t.path.length-1;i++){var s=t.pairs[i].getOutputAmount(r[i]),u=s[0],c=s[1];t.amounts.length==t.path.length&&(u=Ot(u,t.amounts[i+1]),c=new vt(Ot(r[i],t.nextReserves[2*i]),Ot(u,t.nextReserves[2*i+1]))),r[i+1]=u,o[i]=c}}else{nt(e.currency,t.output)||a(!1),r[r.length-1]=At(e,t.chainId);for(var d=t.path.length-1;d>0;d--){var p=t.pairs[d-1].getInputAmount(r[d]),h=p[0],l=p[1];t.amounts.length==t.path.length&&(h=Ot(h,t.amounts[d-1]),l=new vt(Ot(h,t.nextReserves[2*(d-1)]),Ot(r[d],t.nextReserves[2*(d-1)+1]))),r[d-1]=h,o[d-1]=l}}this.route=t,this.swapType=n,this.inputAmount=n===exports.SwapType.EXACT_INPUT?e:t.input===tt?ht.ether(r[0].raw):r[0],this.outputAmount=n===exports.SwapType.EXACT_OUTPUT?e:t.output===tt?ht.ether(r[r.length-1].raw):r[r.length-1],this.executionPrice=new ft(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ft.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)&&a(!1),this.swapType===exports.SwapType.EXACT_OUTPUT)return this.outputAmount;var e=new dt(x).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof lt?new lt(this.outputAmount.token,e):ht.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&a(!1),this.swapType===exports.SwapType.EXACT_INPUT)return this.inputAmount;var e=new dt(x).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof lt?new lt(this.inputAmount.token,e):ht.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,s,u){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,h=c.maxHops,l=void 0===h?3:h;void 0===i&&(i=[]),void 0===s&&(s=n),void 0===u&&(u=[]),e.length>0||a(!1),l>0||a(!1),s===n||i.length>0||a(!1);var f=n instanceof lt?n.token.chainId:r instanceof et?r.chainId:void 0;void 0===f&&a(!1);for(var m=At(n,f),v=bt(r,f),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(u,new t(new wt([].concat(i,[T]),[],[],s.currency,r),s,exports.SwapType.EXACT_INPUT),p,It);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:p,maxHops:l-1},[].concat(i,[T]),s,u)}}}return u},t.bestTradeExactOut=function(e,n,r,o,i,s,u){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,h=c.maxHops,l=void 0===h?3:h;void 0===i&&(i=[]),void 0===s&&(s=r),void 0===u&&(u=[]),e.length>0||a(!1),l>0||a(!1),s===r||i.length>0||a(!1);var f=r instanceof lt?r.token.chainId:n instanceof et?n.chainId:void 0;void 0===f&&a(!1);for(var m=At(r,f),v=bt(n,f),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(u,new t(new wt([T].concat(i),[],[],n,s.currency),s,exports.SwapType.EXACT_OUTPUT),p,It);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:p,maxHops:l-1},[T].concat(i),s,u)}}}return u},t}(),St=function(){function t(t,e,n,r,o,i,s,a,u){this.orderBook=t,this.ammAmountIn=e,this.ammAmountOut=n,this.orderAmountIn=r,this.orderAmountOut=o,this.orderFee=i,this.amountLeft=s,this.amountExpect=a,this.priceTo=u}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}(),Rt=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===tt,r=t.outputAmount.currency===tt;n&&r&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var o,i,s,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})),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),l=Boolean(e.feeOnTransfer);switch(t.swapType){case exports.SwapType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,u,h],s=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,u,h],s="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,u,h],s="0x0");break;case exports.SwapType.EXACT_OUTPUT:l&&a(!1),n?(o="swapETHForExactTokens",i=[d,p,u,h],s=c):r?(o="swapTokensForExactETH",i=[d,c,p,u,h],s="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,u,h],s="0x0")}return{methodName:o,args:i,value:s}},t}(),Ut=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===tt||n===exports.TradeType.LIMIT_SELL&&t.baseToken===tt;t.baseToken===tt&&r===it[r.chainId]||t.baseToken===r||a(!1),t.quoteToken===tt&&o===it[o.chainId]||t.quoteToken===o||a(!1),(t.quoteToken===tt&&t.baseToken===it[o.chainId]||t.baseToken===tt&&t.quoteToken===it[o.chainId]||t.quoteToken===t.baseToken)&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var s,u,c,d=K(e.recipient),p=V(t.amount),h=V(t.price),l="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?(s="buyWithEth",u=[h,r.address,d,l],c=p):(s="buyWithToken",u=[p,h,r.address,o.address,d,l],c="0x0");break;case exports.TradeType.LIMIT_SELL:i?(s="sellEth",u=[h,o.address,d,l],c=p):(s="sellToken",u=[p,h,r.address,o.address,d,l],c="0x0")}return{methodName:s,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=((qt={})[exports.ChainId.MAINNET]={},qt),Nt=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,s,a=function(n){return new et(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===(s=i[t])||void 0===s?void 0:s[e]);return Promise.resolve(u?a(Dt[t][e]):Promise.resolve(new f.Contract(e,Pt,n).decimals().then((function(n){var r,o,i;return Dt=P({},Dt,((i={})[t]=P({},null===(r=Dt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(a))}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&&a(!1);var r=vt.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 vt(new lt(t,i[0]),new lt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=s,exports.CONFIG_ADDRESS="0xC40A5af4fBc94e268aaa598d1B2d6D6E082a0826",exports.Currency=z,exports.CurrencyAmount=ht,exports.ETHER=tt,exports.FACTORY_ADDRESS="0xb8FD793908Fd45941F6c4D0317aDDaa69a6eD778",exports.Fetcher=Nt,exports.Fraction=dt,exports.INIT_CODE_HASH=w,exports.InsufficientInputAmountError=Y,exports.InsufficientReservesError=X,exports.MINIMUM_LIQUIDITY=k,exports.ORDER_BOOK_FACTORY_ADDRESS="0x649f13A0DB654966e9abA2213629b33ebF1D4658",exports.ORDER_BOOK_INIT_CODE_HASH="0xa6e439b6721897ec0f440462b1b09316d7ca46ba3a46bdfe0520752e20b009a9",exports.ORDER_NFT_INIT_CODE_HASH="0x374d19331443638013ff34b50550a36e2622d2839fe244467678500262d11f40",exports.Order=Rt,exports.OrderBook=Tt,exports.Pair=vt,exports.Percent=gt,exports.Price=ft,exports.Route=wt,exports.Router=_t,exports.Swap=Et,exports.Token=et,exports.TokenAmount=lt,exports.Trade=function(t,e,n,r,o,i,s){this.orderBook=t,this.baseToken=n,this.quoteToken=r,this.tradeType=e,this.amount=o,this.price=i,this.tradeRet=s},exports.TradeRet=St,exports.Trader=Ut,exports.UserOrder=function(t,e,n,r,o,i,s,a,u,c){this.orderBook=t,this.baseToken=e,this.quoteToken=n,this.owner=r,this.orderId=o,this.price=i,this.amountOffer=s,this.amountLeft=a,this.orderType=u,this.orderIndex=c},exports.WETH=it,exports.ZERO=g,exports.ZERO_HEX="0x0",exports.currencyEquals=nt,exports.inputOutputComparator=xt,exports.parseBigintIsh=Q,exports.sortedInsert=J,exports.sqrt=G,exports.swapComparator=It,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.4",
"version": "0.0.5",
"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.15",
"@hybridx-exchange/hybridx-protocol": "0.0.18",
"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