@sashimiswap/sdk
Advanced tools
Comparing version 1.0.3 to 1.0.4-bsc
@@ -8,3 +8,7 @@ import JSBI from 'jsbi'; | ||
GÖRLI = 5, | ||
KOVAN = 42 | ||
KOVAN = 42, | ||
HECO = 128, | ||
THECO = 256, | ||
BSC = 56, | ||
TBSC = 97 | ||
} | ||
@@ -20,4 +24,4 @@ export declare enum TradeType { | ||
} | ||
export declare const FACTORY_ADDRESS = "0xf028f723ed1d0fe01cc59973c49298aa95c57472"; | ||
export declare const INIT_CODE_HASH = "0xb465bbe4edb8c9b0da8ff0b2b36ce0065de9fcd5a33f32c6856ea821779c8b72"; | ||
export declare const FACTORY_ADDRESS = "0x1daed74ed1dd7c9dabbe51361ac90a69d851234d"; | ||
export declare const INIT_CODE_HASH = "0xb7b88947a6a423e784cb5512eccdfee6426797f5f681f521bc1687e844ef15be"; | ||
export declare const MINIMUM_LIQUIDITY: JSBI; | ||
@@ -24,0 +28,0 @@ export declare const ZERO: JSBI; |
@@ -13,5 +13,5 @@ /** | ||
*/ | ||
static readonly ETHER: Currency; | ||
static readonly HT: Currency; | ||
/** | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`. | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.HT`. | ||
* @param decimals decimals of the currency | ||
@@ -23,3 +23,3 @@ * @param symbol symbol of the currency | ||
} | ||
declare const ETHER: Currency; | ||
export { ETHER }; | ||
declare const HT: Currency; | ||
export { HT }; |
@@ -8,6 +8,6 @@ import { Currency } from '../currency'; | ||
/** | ||
* Helper that calls the constructor with the ETHER currency | ||
* @param amount ether amount in wei | ||
* Helper that calls the constructor with the HT currency | ||
* @param amount HT amount in wei | ||
*/ | ||
static ether(amount: BigintIsh): CurrencyAmount; | ||
static ht(amount: BigintIsh): CurrencyAmount; | ||
protected constructor(currency: Currency, amount: BigintIsh); | ||
@@ -14,0 +14,0 @@ get raw(): JSBI; |
@@ -27,3 +27,3 @@ import { ChainId } from '../constants'; | ||
export declare function currencyEquals(currencyA: Currency, currencyB: Currency): boolean; | ||
export declare const WETH: { | ||
export declare const WHT: { | ||
1: Token; | ||
@@ -34,2 +34,6 @@ 3: Token; | ||
42: Token; | ||
128: Token; | ||
256: Token; | ||
56: Token; | ||
97: Token; | ||
}; |
@@ -28,2 +28,6 @@ 'use strict'; | ||
ChainId[ChainId["KOVAN"] = 42] = "KOVAN"; | ||
ChainId[ChainId["HECO"] = 128] = "HECO"; | ||
ChainId[ChainId["THECO"] = 256] = "THECO"; | ||
ChainId[ChainId["BSC"] = 56] = "BSC"; | ||
ChainId[ChainId["TBSC"] = 97] = "TBSC"; | ||
})(exports.ChainId || (exports.ChainId = {})); | ||
@@ -43,5 +47,5 @@ | ||
var FACTORY_ADDRESS = '0xf028f723ed1d0fe01cc59973c49298aa95c57472'; // todo: change code hash | ||
var FACTORY_ADDRESS = '0x1daed74ed1dd7c9dabbe51361ac90a69d851234d'; // todo: change code hash | ||
var INIT_CODE_HASH = '0xb465bbe4edb8c9b0da8ff0b2b36ce0065de9fcd5a33f32c6856ea821779c8b72'; | ||
var INIT_CODE_HASH = '0xb7b88947a6a423e784cb5512eccdfee6426797f5f681f521bc1687e844ef15be'; | ||
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption | ||
@@ -364,3 +368,3 @@ | ||
/** | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`. | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.HT`. | ||
* @param decimals decimals of the currency | ||
@@ -380,6 +384,6 @@ * @param symbol symbol of the currency | ||
Currency.ETHER = /*#__PURE__*/new Currency(18, 'ETH', 'Ether'); | ||
var ETHER = Currency.ETHER; | ||
Currency.HT = /*#__PURE__*/new Currency(18, 'BNB', 'BNB'); | ||
var HT = Currency.HT; | ||
var _WETH; | ||
var _WHT; | ||
/** | ||
@@ -447,3 +451,3 @@ * Represents an ERC20 token with a unique address and some metadata. | ||
} | ||
var WETH = (_WETH = {}, _WETH[exports.ChainId.MAINNET] = /*#__PURE__*/new Token(exports.ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.ROPSTEN] = /*#__PURE__*/new Token(exports.ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.RINKEBY] = /*#__PURE__*/new Token(exports.ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.GÖRLI] = /*#__PURE__*/new Token(exports.ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.KOVAN] = /*#__PURE__*/new Token(exports.ChainId.KOVAN, '0xA050886815CFc52a24B9C4aD044ca199990B6690', 18, 'WETH', 'Wrapped Ether'), _WETH); | ||
var WHT = (_WHT = {}, _WHT[exports.ChainId.MAINNET] = /*#__PURE__*/new Token(exports.ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WHT[exports.ChainId.ROPSTEN] = /*#__PURE__*/new Token(exports.ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WHT[exports.ChainId.RINKEBY] = /*#__PURE__*/new Token(exports.ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WHT[exports.ChainId.GÖRLI] = /*#__PURE__*/new Token(exports.ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WHT[exports.ChainId.KOVAN] = /*#__PURE__*/new Token(exports.ChainId.KOVAN, '0xA050886815CFc52a24B9C4aD044ca199990B6690', 18, 'WETH', 'Wrapped Ether'), _WHT[exports.ChainId.HECO] = /*#__PURE__*/new Token(exports.ChainId.HECO, '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', 18, 'WHT', 'Wrapped HT'), _WHT[exports.ChainId.THECO] = /*#__PURE__*/new Token(exports.ChainId.THECO, '0x5b2da6f42ca09c77d577a12bead0446148830687', 18, 'WHT', 'Wrapped HT'), _WHT[exports.ChainId.BSC] = /*#__PURE__*/new Token(exports.ChainId.BSC, '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', 18, 'WBNB', 'Wrapped BNB'), _WHT[exports.ChainId.TBSC] = /*#__PURE__*/new Token(exports.ChainId.TBSC, '0xae13d989dac2f0debff460ac112a837c89baa7cd', 18, 'WBNB', 'Wrapped BNB'), _WHT); | ||
@@ -587,9 +591,9 @@ var _toSignificantRoundin, _toFixedRounding; | ||
/** | ||
* Helper that calls the constructor with the ETHER currency | ||
* @param amount ether amount in wei | ||
* Helper that calls the constructor with the HT currency | ||
* @param amount HT amount in wei | ||
*/ | ||
CurrencyAmount.ether = function ether(amount) { | ||
return new CurrencyAmount(ETHER, amount); | ||
CurrencyAmount.ht = function ht(amount) { | ||
return new CurrencyAmount(HT, amount); | ||
}; | ||
@@ -968,5 +972,5 @@ | ||
}) ? invariant(false, 'CHAIN_IDS') : void 0; | ||
!(input instanceof Token && pairs[0].involvesToken(input) || input === ETHER && pairs[0].involvesToken(WETH[pairs[0].chainId])) ? invariant(false, 'INPUT') : void 0; | ||
!(typeof output === 'undefined' || output instanceof Token && pairs[pairs.length - 1].involvesToken(output) || output === ETHER && pairs[pairs.length - 1].involvesToken(WETH[pairs[0].chainId])) ? invariant(false, 'OUTPUT') : void 0; | ||
var path = [input instanceof Token ? input : WETH[pairs[0].chainId]]; | ||
!(input instanceof Token && pairs[0].involvesToken(input) || input === HT && pairs[0].involvesToken(WHT[pairs[0].chainId])) ? invariant(false, 'INPUT') : void 0; | ||
!(typeof output === 'undefined' || output instanceof Token && pairs[pairs.length - 1].involvesToken(output) || output === HT && pairs[pairs.length - 1].involvesToken(WHT[pairs[0].chainId])) ? invariant(false, 'OUTPUT') : void 0; | ||
var path = [input instanceof Token ? input : WHT[pairs[0].chainId]]; | ||
@@ -1093,3 +1097,3 @@ for (var _iterator = _createForOfIteratorHelperLoose(pairs.entries()), _step; !(_step = _iterator()).done;) { | ||
* Given a currency amount and a chain ID, returns the equivalent representation as the token amount. | ||
* In other words, if the currency is ETHER, returns the WETH token amount for the given chain. Otherwise, returns | ||
* In other words, if the currency is HT, returns the WHT token amount for the given chain. Otherwise, returns | ||
* the input currency amount. | ||
@@ -1100,3 +1104,3 @@ */ | ||
if (currencyAmount instanceof TokenAmount) return currencyAmount; | ||
if (currencyAmount.currency === ETHER) return new TokenAmount(WETH[chainId], currencyAmount.raw); | ||
if (currencyAmount.currency === HT) return new TokenAmount(WHT[chainId], currencyAmount.raw); | ||
invariant(false, 'CURRENCY') ; | ||
@@ -1107,3 +1111,3 @@ } | ||
if (currency instanceof Token) return currency; | ||
if (currency === ETHER) return WETH[chainId]; | ||
if (currency === HT) return WHT[chainId]; | ||
invariant(false, 'CURRENCY') ; | ||
@@ -1154,4 +1158,4 @@ } | ||
this.tradeType = tradeType; | ||
this.inputAmount = tradeType === exports.TradeType.EXACT_INPUT ? amount : route.input === ETHER ? CurrencyAmount.ether(amounts[0].raw) : amounts[0]; | ||
this.outputAmount = tradeType === exports.TradeType.EXACT_OUTPUT ? amount : route.output === ETHER ? CurrencyAmount.ether(amounts[amounts.length - 1].raw) : amounts[amounts.length - 1]; | ||
this.inputAmount = tradeType === exports.TradeType.EXACT_INPUT ? amount : route.input === HT ? CurrencyAmount.ht(amounts[0].raw) : amounts[0]; | ||
this.outputAmount = tradeType === exports.TradeType.EXACT_OUTPUT ? amount : route.output === HT ? CurrencyAmount.ht(amounts[amounts.length - 1].raw) : amounts[amounts.length - 1]; | ||
this.executionPrice = new Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.raw, this.outputAmount.raw); | ||
@@ -1196,3 +1200,3 @@ this.nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input)); | ||
var slippageAdjustedAmountOut = new Fraction(ONE).add(slippageTolerance).invert().multiply(this.outputAmount.raw).quotient; | ||
return this.outputAmount instanceof TokenAmount ? new TokenAmount(this.outputAmount.token, slippageAdjustedAmountOut) : CurrencyAmount.ether(slippageAdjustedAmountOut); | ||
return this.outputAmount instanceof TokenAmount ? new TokenAmount(this.outputAmount.token, slippageAdjustedAmountOut) : CurrencyAmount.ht(slippageAdjustedAmountOut); | ||
} | ||
@@ -1213,3 +1217,3 @@ } | ||
var slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.raw).quotient; | ||
return this.inputAmount instanceof TokenAmount ? new TokenAmount(this.inputAmount.token, slippageAdjustedAmountIn) : CurrencyAmount.ether(slippageAdjustedAmountIn); | ||
return this.inputAmount instanceof TokenAmount ? new TokenAmount(this.inputAmount.token, slippageAdjustedAmountIn) : CurrencyAmount.ht(slippageAdjustedAmountIn); | ||
} | ||
@@ -1406,6 +1410,6 @@ } | ||
Router.swapCallParameters = function swapCallParameters(trade, options) { | ||
var etherIn = trade.inputAmount.currency === ETHER; | ||
var etherOut = trade.outputAmount.currency === ETHER; // the router does not support both ether in and out | ||
var etherIn = trade.inputAmount.currency === HT; | ||
var etherOut = trade.outputAmount.currency === HT; // the router does not support both ether in and out | ||
!!(etherIn && etherOut) ? invariant(false, 'ETHER_IN_OUT') : void 0; | ||
!!(etherIn && etherOut) ? invariant(false, 'BNB_IN_OUT') : void 0; | ||
!(!('ttl' in options) || options.ttl > 0) ? invariant(false, 'TTL') : void 0; | ||
@@ -1591,6 +1595,6 @@ var to = validateAndParseAddress(options.recipient); | ||
exports.CurrencyAmount = CurrencyAmount; | ||
exports.ETHER = ETHER; | ||
exports.FACTORY_ADDRESS = FACTORY_ADDRESS; | ||
exports.Fetcher = Fetcher; | ||
exports.Fraction = Fraction; | ||
exports.HT = HT; | ||
exports.INIT_CODE_HASH = INIT_CODE_HASH; | ||
@@ -1608,3 +1612,3 @@ exports.InsufficientInputAmountError = InsufficientInputAmountError; | ||
exports.Trade = Trade; | ||
exports.WETH = WETH; | ||
exports.WHT = WHT; | ||
exports.currencyEquals = currencyEquals; | ||
@@ -1611,0 +1615,0 @@ exports.inputOutputComparator = inputOutputComparator; |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n,r,o,i=t(require("jsbi")),u=t(require("tiny-invariant")),a=(t(require("tiny-warning")),require("@ethersproject/address")),s=t(require("big.js")),c=t(require("toformat")),d=t(require("decimal.js-light")),p=require("@ethersproject/solidity"),f=require("@ethersproject/contracts"),l=require("@ethersproject/networks"),h=require("@ethersproject/providers"),m=t(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=1]="MAINNET",n[n.ROPSTEN=3]="ROPSTEN",n[n.RINKEBY=4]="RINKEBY",n[n["GÖRLI"]=5]="GÖRLI",n[n.KOVAN=42]="KOVAN",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(o=exports.Rounding||(exports.Rounding={}))[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP";var v,y="0xb465bbe4edb8c9b0da8ff0b2b36ce0065de9fcd5a33f32c6856ea821779c8b72",w=i.BigInt(1e3),T=i.BigInt(0),g=i.BigInt(1),k=i.BigInt(2),x=i.BigInt(3),A=i.BigInt(5),I=i.BigInt(10),O=i.BigInt(100),E=i.BigInt(997),b=i.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(v||(v={}));var q=((e={})[v.uint8]=i.BigInt("0xff"),e[v.uint256]=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function N(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function P(t,e,n){return e&&N(t.prototype,e),n&&N(t,n),t}function R(){return(R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function C(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function U(t,e){return(U=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function D(t,e,n){return(D=S()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&U(o,n.prototype),o}).apply(null,arguments)}function F(t){var e="function"==typeof Map?new Map:void 0;return(F=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return D(t,arguments,_(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,t)})(t)}function B(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function j(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;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return j(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)?j(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var M="setPrototypeOf"in Object,W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,M&&Object.setPrototypeOf(B(n),(this instanceof e?this.constructor:void 0).prototype),n}return C(e,t),e}(F(Error)),L=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,M&&Object.setPrototypeOf(B(n),(this instanceof e?this.constructor:void 0).prototype),n}return C(e,t),e}(F(Error));function X(t,e){i.greaterThanOrEqual(t,T)||u(!1),i.lessThanOrEqual(t,q[e])||u(!1)}function K(t){try{return a.getAddress(t)}catch(t){u(!1)}}function V(t){return t instanceof i?t:i.BigInt("bigint"==typeof t?t.toString():t)}function Y(t){X(t,v.uint256);var e,n=T;if(i.greaterThan(t,x))for(n=t,e=i.add(i.divide(t,k),g);i.lessThan(e,n);)n=e,e=i.divide(i.add(i.divide(t,e),e),k);else i.notEqual(t,T)&&(n=g);return n}function G(t,e,n,r){if(n>0||u(!1),t.length<=n||u(!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 s=i+a>>>1;r(t[s],e)<=0?i=s+1:a=s}return t.splice(i,0,e),o?t.pop():null}var J,Q=function(t,e,n){X(i.BigInt(t),v.uint8),this.decimals=t,this.symbol=e,this.name=n},$=Q.ETHER=new Q(18,"ETH","Ether"),z=function(t){function e(e,n,r,o,i){var u;return(u=t.call(this,r,o,i)||this).chainId=e,u.address=K(n),u}C(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&&u(!1),this.address===t.address&&u(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(Q);function Z(t,e){return t instanceof z&&e instanceof z?t.equals(e):!(t instanceof z||e instanceof z||t!==e)}var tt,et,nt=((J={})[exports.ChainId.MAINNET]=new z(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),J[exports.ChainId.ROPSTEN]=new z(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),J[exports.ChainId.RINKEBY]=new z(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),J[exports.ChainId.GÖRLI]=new z(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH","Wrapped Ether"),J[exports.ChainId.KOVAN]=new z(exports.ChainId.KOVAN,"0xA050886815CFc52a24B9C4aD044ca199990B6690",18,"WETH","Wrapped Ether"),J),rt=c(d),ot=c(s),it=((tt={})[exports.Rounding.ROUND_DOWN]=rt.ROUND_DOWN,tt[exports.Rounding.ROUND_HALF_UP]=rt.ROUND_HALF_UP,tt[exports.Rounding.ROUND_UP]=rt.ROUND_UP,tt),ut=((et={})[exports.Rounding.ROUND_DOWN]=0,et[exports.Rounding.ROUND_HALF_UP]=1,et[exports.Rounding.ROUND_UP]=3,et),at=function(){function t(t,e){void 0===e&&(e=g),this.numerator=V(t),this.denominator=V(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(V(e));return i.equal(this.denominator,n.denominator)?new t(i.add(this.numerator,n.numerator),this.denominator):new t(i.add(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(V(e));return i.equal(this.denominator,n.denominator)?new t(i.subtract(this.numerator,n.numerator),this.denominator):new t(i.subtract(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(V(e));return i.lessThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(V(e));return i.equal(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(V(e));return i.greaterThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(V(e));return new t(i.multiply(this.numerator,n.numerator),i.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(V(e));return new t(i.multiply(this.numerator,n.denominator),i.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||u(!1),t>0||u(!1),rt.set({precision:t+1,rounding:it[n]});var r=new rt(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)||u(!1),t>=0||u(!1),ot.DP=t,ot.RM=ut[n],new ot(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},P(t,[{key:"quotient",get:function(){return i.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(i.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),st=c(s),ct=function(t){function e(e,n){var r,o=V(n);return X(o,v.uint256),(r=t.call(this,o,i.exponentiate(I,i.BigInt(e.decimals)))||this).currency=e,r}C(e,t),e.ether=function(t){return new e($,t)};var n=e.prototype;return n.add=function(t){return Z(this.currency,t.currency)||u(!1),new e(this.currency,i.add(this.raw,t.raw))},n.subtract=function(t){return Z(this.currency,t.currency)||u(!1),new e(this.currency,i.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||u(!1),t.prototype.toFixed.call(this,e,n,r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),st.DP=this.currency.decimals,new st(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},P(e,[{key:"raw",get:function(){return this.numerator}}]),e}(at),dt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}C(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||u(!1),new e(this.token,i.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||u(!1),new e(this.token,i.subtract(this.raw,t.raw))},e}(ct),pt=function(t){function e(e,n,r,o){var u;return(u=t.call(this,o,r)||this).baseCurrency=e,u.quoteCurrency=n,u.scalar=new at(i.exponentiate(I,i.BigInt(e.decimals)),i.exponentiate(I,i.BigInt(n.decimals))),u}C(e,t),e.fromRoute=function(t){for(var n,r=[],o=H(t.pairs.entries());!(n=o()).done;){var i=n.value,u=i[1];r.push(t.path[i[0]].equals(u.token0)?new e(u.reserve0.currency,u.reserve1.currency,u.reserve0.raw,u.reserve1.raw):new e(u.reserve1.currency,u.reserve0.currency,u.reserve1.raw,u.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){Z(this.quoteCurrency,n.baseCurrency)||u(!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 Z(e.currency,this.baseCurrency)||u(!1),this.quoteCurrency instanceof z?new dt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ct.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 at(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(at),ft={},lt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new z(r[0].token.chainId,t.getAddress(r[0].token,r[1].token),18,"SALP","SashimiSwap"),this.tokenAmounts=r}t.getAddress=function(t,e){var n,r,o,i,u,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=R({},ft,((u={})[s[0].address]=R({},null===(o=ft)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=a.getCreate2Address("0xf028f723ed1d0fe01cc59973c49298aa95c57472",p.keccak256(["bytes"],[p.pack(["address","address"],[s[0].address,s[1].address])]),y),i)),u))),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)||u(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||u(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||u(!1),i.equal(this.reserve0.raw,T)||i.equal(this.reserve1.raw,T))throw new W;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(e.raw,E),a=i.multiply(o,r.raw),s=i.add(i.multiply(n.raw,b),o),c=new dt(e.token.equals(this.token0)?this.token1:this.token0,i.divide(a,s));if(i.equal(c.raw,T))throw new L;return[c,new t(n.add(e),r.subtract(c))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||u(!1),i.equal(this.reserve0.raw,T)||i.equal(this.reserve1.raw,T)||i.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new W;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(i.multiply(r.raw,e.raw),b),a=i.multiply(i.subtract(n.raw,e.raw),E),s=new dt(e.token.equals(this.token0)?this.token1:this.token0,i.add(i.divide(o,a),g));return[s,new t(r.add(s),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||u(!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)||u(!1),i.equal(t.raw,T))r=i.subtract(Y(i.multiply(o[0].raw,o[1].raw)),w);else{var a=i.divide(i.multiply(o[0].raw,t.raw),this.reserve0.raw),s=i.divide(i.multiply(o[1].raw,t.raw),this.reserve1.raw);r=i.lessThanOrEqual(a,s)?a:s}if(!i.greaterThan(r,T))throw new L;return new dt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,o){var a;if(void 0===r&&(r=!1),this.involvesToken(t)||u(!1),e.token.equals(this.liquidityToken)||u(!1),n.token.equals(this.liquidityToken)||u(!1),i.lessThanOrEqual(n.raw,e.raw)||u(!1),r){o||u(!1);var s=V(o);if(i.equal(s,T))a=e;else{var c=Y(i.multiply(this.reserve0.raw,this.reserve1.raw)),d=Y(s);if(i.greaterThan(c,d)){var p=i.multiply(e.raw,i.subtract(c,d)),f=i.add(i.multiply(c,A),d),l=i.divide(p,f);a=e.add(new dt(this.liquidityToken,l))}else a=e}}else a=e;return new dt(t,i.divide(i.multiply(n.raw,this.reserveOf(t).raw),a.raw))},P(t,[{key:"token0Price",get:function(){return new pt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new pt(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}(),ht=function(){function t(t,e,n){t.length>0||u(!1),t.every((function(e){return e.chainId===t[0].chainId}))||u(!1),e instanceof z&&t[0].involvesToken(e)||e===$&&t[0].involvesToken(nt[t[0].chainId])||u(!1),void 0===n||n instanceof z&&t[t.length-1].involvesToken(n)||n===$&&t[t.length-1].involvesToken(nt[t[0].chainId])||u(!1);for(var r,o=[e instanceof z?e:nt[t[0].chainId]],i=H(t.entries());!(r=i()).done;){var a=r.value,s=a[1],c=o[a[0]];c.equals(s.token0)||c.equals(s.token1)||u(!1);var d=c.equals(s.token0)?s.token1:s.token0;o.push(d)}this.pairs=t,this.path=o,this.midPrice=pt.fromRoute(this),this.input=e,this.output=null!=n?n:o[o.length-1]}return P(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),mt=new at(O),vt=function(t){function e(){return t.apply(this,arguments)||this}C(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(mt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(mt).toFixed(t,e,n)},e}(at);function yt(t,e){return Z(t.inputAmount.currency,e.inputAmount.currency)||u(!1),Z(t.outputAmount.currency,e.outputAmount.currency)||u(!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 wt(t,e){var n=yt(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}function Tt(t,e){return t instanceof dt?t:t.currency===$?new dt(nt[e],t.raw):void u(!1)}function gt(t,e){return t instanceof z?t:t===$?nt[e]:void u(!1)}var kt=function(){function t(t,e,n){var r,o,i,a=new Array(t.path.length),s=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){Z(e.currency,t.input)||u(!1),a[0]=Tt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var d=t.pairs[c].getOutputAmount(a[c]),p=d[1];a[c+1]=d[0],s[c]=p}}else{Z(e.currency,t.output)||u(!1),a[a.length-1]=Tt(e,t.chainId);for(var f=t.path.length-1;f>0;f--){var l=t.pairs[f-1].getInputAmount(a[f]),h=l[1];a[f-1]=l[0],s[f-1]=h}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===$?ct.ether(a[0].raw):a[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===$?ct.ether(a[a.length-1].raw):a[a.length-1],this.executionPrice=new pt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=pt.fromRoute(new ht(s,t.input)),this.priceImpact=(r=this.outputAmount,i=(o=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new vt(i.numerator,i.denominator))}t.exactIn=function(e,n){return new t(e,n,exports.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(T)&&u(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new at(g).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof dt?new dt(this.outputAmount.token,e):ct.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(T)&&u(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new at(g).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof dt?new dt(this.inputAmount.token,e):ct.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,a,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,l=void 0===f?3:f;void 0===i&&(i=[]),void 0===a&&(a=n),void 0===s&&(s=[]),e.length>0||u(!1),l>0||u(!1),a===n||i.length>0||u(!1);var h=n instanceof dt?n.token.chainId:r instanceof z?r.chainId:void 0;void 0===h&&u(!1);for(var m=Tt(n,h),v=gt(r,h),y=0;y<e.length;y++){var w=e[y];if((w.token0.equals(m.token)||w.token1.equals(m.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(g.token.equals(v))G(s,new t(new ht([].concat(i,[w]),a.currency,r),a,exports.TradeType.EXACT_INPUT),p,wt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(k,g,r,{maxNumResults:p,maxHops:l-1},[].concat(i,[w]),a,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,a,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,l=void 0===f?3:f;void 0===i&&(i=[]),void 0===a&&(a=r),void 0===s&&(s=[]),e.length>0||u(!1),l>0||u(!1),a===r||i.length>0||u(!1);var h=r instanceof dt?r.token.chainId:n instanceof z?n.chainId:void 0;void 0===h&&u(!1);for(var m=Tt(r,h),v=gt(n,h),y=0;y<e.length;y++){var w=e[y];if((w.token0.equals(m.token)||w.token1.equals(m.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(g.token.equals(v))G(s,new t(new ht([w].concat(i),n,a.currency),a,exports.TradeType.EXACT_OUTPUT),p,wt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(k,n,g,{maxNumResults:p,maxHops:l-1},[w].concat(i),a,s)}}}return s},t}();function xt(t){return"0x"+t.raw.toString(16)}var At,It=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===$,r=t.outputAmount.currency===$;n&&r&&u(!1),!("ttl"in e)||e.ttl>0||u(!1);var o,i,a,s=K(e.recipient),c=xt(t.maximumAmountIn(e.allowedSlippage)),d=xt(t.minimumAmountOut(e.allowedSlippage)),p=t.route.path.map((function(t){return t.address})),f="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.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,s,f],a=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,s,f],a="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,s,f],a="0x0");break;case exports.TradeType.EXACT_OUTPUT:l&&u(!1),n?(o="swapETHForExactTokens",i=[d,p,s,f],a=c):r?(o="swapTokensForExactETH",i=[d,c,p,s,f],a="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,s,f],a="0x0")}return{methodName:o,args:i,value:a}},t}(),Ot=[{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],Et=((At={})[exports.ChainId.MAINNET]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},At),bt=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,u,a=function(n){return new z(t,e,n,r,o)};void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t)));var s="number"==typeof(null===(i=Et)||void 0===i||null===(u=i[t])||void 0===u?void 0:u[e]);return Promise.resolve(s?a(Et[t][e]):Promise.resolve(new f.Contract(e,Ot,n).decimals().then((function(n){var r,o,i;return Et=R({},Et,((i={})[t]=R({},null===(r=Et)||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=h.getDefaultProvider(l.getNetwork(t.chainId))),t.chainId!==e.chainId&&u(!1);var r=lt.getAddress(t,e);return Promise.resolve(new f.Contract(r,m.abi,n).getReserves()).then((function(n){var r=n[0],o=n[1],i=t.sortsBefore(e)?[r,o]:[o,r];return new lt(new dt(t,i[0]),new dt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=i,exports.Currency=Q,exports.CurrencyAmount=ct,exports.ETHER=$,exports.FACTORY_ADDRESS="0xf028f723ed1d0fe01cc59973c49298aa95c57472",exports.Fetcher=bt,exports.Fraction=at,exports.INIT_CODE_HASH=y,exports.InsufficientInputAmountError=L,exports.InsufficientReservesError=W,exports.MINIMUM_LIQUIDITY=w,exports.Pair=lt,exports.Percent=vt,exports.Price=pt,exports.Route=ht,exports.Router=It,exports.Token=z,exports.TokenAmount=dt,exports.Trade=kt,exports.WETH=nt,exports.currencyEquals=Z,exports.inputOutputComparator=yt,exports.tradeComparator=wt; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n,r,o,i=t(require("jsbi")),a=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),s=t(require("big.js")),c=t(require("toformat")),d=t(require("decimal.js-light")),p=require("@ethersproject/solidity"),f=require("@ethersproject/contracts"),l=require("@ethersproject/networks"),h=require("@ethersproject/providers"),m=t(require("@uniswap/v2-core/build/IUniswapV2Pair.json"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=1]="MAINNET",n[n.ROPSTEN=3]="ROPSTEN",n[n.RINKEBY=4]="RINKEBY",n[n["GÖRLI"]=5]="GÖRLI",n[n.KOVAN=42]="KOVAN",n[n.HECO=128]="HECO",n[n.THECO=256]="THECO",n[n.BSC=56]="BSC",n[n.TBSC=97]="TBSC",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(o=exports.Rounding||(exports.Rounding={}))[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP";var v,y="0xb7b88947a6a423e784cb5512eccdfee6426797f5f681f521bc1687e844ef15be",w=i.BigInt(1e3),T=i.BigInt(0),g=i.BigInt(1),k=i.BigInt(2),x=i.BigInt(3),I=i.BigInt(5),A=i.BigInt(10),O=i.BigInt(100),b=i.BigInt(997),E=i.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(v||(v={}));var q=((e={})[v.uint8]=i.BigInt("0xff"),e[v.uint256]=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function C(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function N(t,e,n){return e&&C(t.prototype,e),n&&C(t,n),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 R(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function U(t,e){return(U=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 Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function S(t,e,n){return(S=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&&U(o,n.prototype),o}).apply(null,arguments)}function D(t){var e="function"==typeof Map?new Map:void 0;return(D=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return S(t,arguments,_(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,t)})(t)}function F(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function H(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function j(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return H(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?H(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var W="setPrototypeOf"in Object,M=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(F(n),(this instanceof e?this.constructor:void 0).prototype),n}return R(e,t),e}(D(Error)),L=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,W&&Object.setPrototypeOf(F(n),(this instanceof e?this.constructor:void 0).prototype),n}return R(e,t),e}(D(Error));function X(t,e){i.greaterThanOrEqual(t,T)||a(!1),i.lessThanOrEqual(t,q[e])||a(!1)}function K(t){try{return u.getAddress(t)}catch(t){a(!1)}}function V(t){return t instanceof i?t:i.BigInt("bigint"==typeof t?t.toString():t)}function Y(t){X(t,v.uint256);var e,n=T;if(i.greaterThan(t,x))for(n=t,e=i.add(i.divide(t,k),g);i.lessThan(e,n);)n=e,e=i.divide(i.add(i.divide(t,e),e),k);else i.notEqual(t,T)&&(n=g);return n}function G(t,e,n,r){if(n>0||a(!1),t.length<=n||a(!1),0===t.length)return t.push(e),null;var o=t.length===n;if(o&&r(t[t.length-1],e)<=0)return e;for(var i=0,u=t.length;i<u;){var s=i+u>>>1;r(t[s],e)<=0?i=s+1:u=s}return t.splice(i,0,e),o?t.pop():null}var J,Q=function(t,e,n){X(i.BigInt(t),v.uint8),this.decimals=t,this.symbol=e,this.name=n},$=Q.HT=new Q(18,"BNB","BNB"),z=function(t){function e(e,n,r,o,i){var a;return(a=t.call(this,r,o,i)||this).chainId=e,a.address=K(n),a}R(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}(Q);function Z(t,e){return t instanceof z&&e instanceof z?t.equals(e):!(t instanceof z||e instanceof z||t!==e)}var tt,et,nt=((J={})[exports.ChainId.MAINNET]=new z(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),J[exports.ChainId.ROPSTEN]=new z(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),J[exports.ChainId.RINKEBY]=new z(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),J[exports.ChainId.GÖRLI]=new z(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH","Wrapped Ether"),J[exports.ChainId.KOVAN]=new z(exports.ChainId.KOVAN,"0xA050886815CFc52a24B9C4aD044ca199990B6690",18,"WETH","Wrapped Ether"),J[exports.ChainId.HECO]=new z(exports.ChainId.HECO,"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f",18,"WHT","Wrapped HT"),J[exports.ChainId.THECO]=new z(exports.ChainId.THECO,"0x5b2da6f42ca09c77d577a12bead0446148830687",18,"WHT","Wrapped HT"),J[exports.ChainId.BSC]=new z(exports.ChainId.BSC,"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f",18,"WBNB","Wrapped BNB"),J[exports.ChainId.TBSC]=new z(exports.ChainId.TBSC,"0xae13d989dac2f0debff460ac112a837c89baa7cd",18,"WBNB","Wrapped BNB"),J),rt=c(d),ot=c(s),it=((tt={})[exports.Rounding.ROUND_DOWN]=rt.ROUND_DOWN,tt[exports.Rounding.ROUND_HALF_UP]=rt.ROUND_HALF_UP,tt[exports.Rounding.ROUND_UP]=rt.ROUND_UP,tt),at=((et={})[exports.Rounding.ROUND_DOWN]=0,et[exports.Rounding.ROUND_HALF_UP]=1,et[exports.Rounding.ROUND_UP]=3,et),ut=function(){function t(t,e){void 0===e&&(e=g),this.numerator=V(t),this.denominator=V(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(V(e));return i.equal(this.denominator,n.denominator)?new t(i.add(this.numerator,n.numerator),this.denominator):new t(i.add(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(V(e));return i.equal(this.denominator,n.denominator)?new t(i.subtract(this.numerator,n.numerator),this.denominator):new t(i.subtract(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator)),i.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(V(e));return i.lessThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(V(e));return i.equal(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(V(e));return i.greaterThan(i.multiply(this.numerator,n.denominator),i.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(V(e));return new t(i.multiply(this.numerator,n.numerator),i.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(V(e));return new t(i.multiply(this.numerator,n.denominator),i.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||a(!1),t>0||a(!1),rt.set({precision:t+1,rounding:it[n]});var r=new rt(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),ot.DP=t,ot.RM=at[n],new ot(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},N(t,[{key:"quotient",get:function(){return i.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(i.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),st=c(s),ct=function(t){function e(e,n){var r,o=V(n);return X(o,v.uint256),(r=t.call(this,o,i.exponentiate(A,i.BigInt(e.decimals)))||this).currency=e,r}R(e,t),e.ht=function(t){return new e($,t)};var n=e.prototype;return n.add=function(t){return Z(this.currency,t.currency)||a(!1),new e(this.currency,i.add(this.raw,t.raw))},n.subtract=function(t){return Z(this.currency,t.currency)||a(!1),new e(this.currency,i.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||a(!1),t.prototype.toFixed.call(this,e,n,r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),st.DP=this.currency.decimals,new st(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},N(e,[{key:"raw",get:function(){return this.numerator}}]),e}(ut),dt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}R(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,i.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||a(!1),new e(this.token,i.subtract(this.raw,t.raw))},e}(ct),pt=function(t){function e(e,n,r,o){var a;return(a=t.call(this,o,r)||this).baseCurrency=e,a.quoteCurrency=n,a.scalar=new ut(i.exponentiate(A,i.BigInt(e.decimals)),i.exponentiate(A,i.BigInt(n.decimals))),a}R(e,t),e.fromRoute=function(t){for(var n,r=[],o=j(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){Z(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 Z(e.currency,this.baseCurrency)||a(!1),this.quoteCurrency instanceof z?new dt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ct.ether(t.prototype.multiply.call(this,e.raw).quotient)},n.toSignificant=function(t,e,n){return void 0===t&&(t=6),this.adjusted.toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=4),this.adjusted.toFixed(t,e,n)},N(e,[{key:"raw",get:function(){return new ut(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(ut),ft={},lt=function(){function t(e,n){var r=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new z(r[0].token.chainId,t.getAddress(r[0].token,r[1].token),18,"SALP","SashimiSwap"),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=P({},ft,((a={})[s[0].address]=P({},null===(o=ft)||void 0===o?void 0:o[s[0].address],((i={})[s[1].address]=u.getCreate2Address("0x1daed74ed1dd7c9dabbe51361ac90a69d851234d",p.keccak256(["bytes"],[p.pack(["address","address"],[s[0].address,s[1].address])]),y),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)||a(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||a(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||a(!1),i.equal(this.reserve0.raw,T)||i.equal(this.reserve1.raw,T))throw new M;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(e.raw,b),u=i.multiply(o,r.raw),s=i.add(i.multiply(n.raw,E),o),c=new dt(e.token.equals(this.token0)?this.token1:this.token0,i.divide(u,s));if(i.equal(c.raw,T))throw new L;return[c,new t(n.add(e),r.subtract(c))]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||a(!1),i.equal(this.reserve0.raw,T)||i.equal(this.reserve1.raw,T)||i.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new M;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),o=i.multiply(i.multiply(r.raw,e.raw),E),u=i.multiply(i.subtract(n.raw,e.raw),b),s=new dt(e.token.equals(this.token0)?this.token1:this.token0,i.add(i.divide(o,u),g));return[s,new t(r.add(s),n.subtract(e))]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||a(!1);var r,o=e.token.sortsBefore(n.token)?[e,n]:[n,e];if(o[0].token.equals(this.token0)&&o[1].token.equals(this.token1)||a(!1),i.equal(t.raw,T))r=i.subtract(Y(i.multiply(o[0].raw,o[1].raw)),w);else{var u=i.divide(i.multiply(o[0].raw,t.raw),this.reserve0.raw),s=i.divide(i.multiply(o[1].raw,t.raw),this.reserve1.raw);r=i.lessThanOrEqual(u,s)?u:s}if(!i.greaterThan(r,T))throw new L;return new dt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,o){var u;if(void 0===r&&(r=!1),this.involvesToken(t)||a(!1),e.token.equals(this.liquidityToken)||a(!1),n.token.equals(this.liquidityToken)||a(!1),i.lessThanOrEqual(n.raw,e.raw)||a(!1),r){o||a(!1);var s=V(o);if(i.equal(s,T))u=e;else{var c=Y(i.multiply(this.reserve0.raw,this.reserve1.raw)),d=Y(s);if(i.greaterThan(c,d)){var p=i.multiply(e.raw,i.subtract(c,d)),f=i.add(i.multiply(c,I),d),l=i.divide(p,f);u=e.add(new dt(this.liquidityToken,l))}else u=e}}else u=e;return new dt(t,i.divide(i.multiply(n.raw,this.reserveOf(t).raw),u.raw))},N(t,[{key:"token0Price",get:function(){return new pt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new pt(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}(),ht=function(){function t(t,e,n){t.length>0||a(!1),t.every((function(e){return e.chainId===t[0].chainId}))||a(!1),e instanceof z&&t[0].involvesToken(e)||e===$&&t[0].involvesToken(nt[t[0].chainId])||a(!1),void 0===n||n instanceof z&&t[t.length-1].involvesToken(n)||n===$&&t[t.length-1].involvesToken(nt[t[0].chainId])||a(!1);for(var r,o=[e instanceof z?e:nt[t[0].chainId]],i=j(t.entries());!(r=i()).done;){var u=r.value,s=u[1],c=o[u[0]];c.equals(s.token0)||c.equals(s.token1)||a(!1);var d=c.equals(s.token0)?s.token1:s.token0;o.push(d)}this.pairs=t,this.path=o,this.midPrice=pt.fromRoute(this),this.input=e,this.output=null!=n?n:o[o.length-1]}return N(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),mt=new ut(O),vt=function(t){function e(){return t.apply(this,arguments)||this}R(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(mt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(mt).toFixed(t,e,n)},e}(ut);function yt(t,e){return Z(t.inputAmount.currency,e.inputAmount.currency)||a(!1),Z(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 wt(t,e){var n=yt(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}function Tt(t,e){return t instanceof dt?t:t.currency===$?new dt(nt[e],t.raw):void a(!1)}function gt(t,e){return t instanceof z?t:t===$?nt[e]:void a(!1)}var kt=function(){function t(t,e,n){var r,o,i,u=new Array(t.path.length),s=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){Z(e.currency,t.input)||a(!1),u[0]=Tt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var d=t.pairs[c].getOutputAmount(u[c]),p=d[1];u[c+1]=d[0],s[c]=p}}else{Z(e.currency,t.output)||a(!1),u[u.length-1]=Tt(e,t.chainId);for(var f=t.path.length-1;f>0;f--){var l=t.pairs[f-1].getInputAmount(u[f]),h=l[1];u[f-1]=l[0],s[f-1]=h}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===$?ct.ht(u[0].raw):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===$?ct.ht(u[u.length-1].raw):u[u.length-1],this.executionPrice=new pt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=pt.fromRoute(new ht(s,t.input)),this.priceImpact=(r=this.outputAmount,i=(o=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new vt(i.numerator,i.denominator))}t.exactIn=function(e,n){return new t(e,n,exports.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(T)&&a(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new ut(g).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof dt?new dt(this.outputAmount.token,e):ct.ht(e)},e.maximumAmountIn=function(t){if(t.lessThan(T)&&a(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new ut(g).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof dt?new dt(this.inputAmount.token,e):ct.ht(e)},t.bestTradeExactIn=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,l=void 0===f?3:f;void 0===i&&(i=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===n||i.length>0||a(!1);var h=n instanceof dt?n.token.chainId:r instanceof z?r.chainId:void 0;void 0===h&&a(!1);for(var m=Tt(n,h),v=gt(r,h),y=0;y<e.length;y++){var w=e[y];if((w.token0.equals(m.token)||w.token1.equals(m.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(g.token.equals(v))G(s,new t(new ht([].concat(i,[w]),u.currency,r),u,exports.TradeType.EXACT_INPUT),p,wt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(k,g,r,{maxNumResults:p,maxHops:l-1},[].concat(i,[w]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,u,s){var c=void 0===o?{}:o,d=c.maxNumResults,p=void 0===d?3:d,f=c.maxHops,l=void 0===f?3:f;void 0===i&&(i=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||a(!1),l>0||a(!1),u===r||i.length>0||a(!1);var h=r instanceof dt?r.token.chainId:n instanceof z?n.chainId:void 0;void 0===h&&a(!1);for(var m=Tt(r,h),v=gt(n,h),y=0;y<e.length;y++){var w=e[y];if((w.token0.equals(m.token)||w.token1.equals(m.token))&&!w.reserve0.equalTo(T)&&!w.reserve1.equalTo(T)){var g=void 0;try{g=w.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(g.token.equals(v))G(s,new t(new ht([w].concat(i),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),p,wt);else if(l>1&&e.length>1){var k=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(k,n,g,{maxNumResults:p,maxHops:l-1},[w].concat(i),u,s)}}}return s},t}();function xt(t){return"0x"+t.raw.toString(16)}var It,At=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===$,r=t.outputAmount.currency===$;n&&r&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var o,i,u,s=K(e.recipient),c=xt(t.maximumAmountIn(e.allowedSlippage)),d=xt(t.minimumAmountOut(e.allowedSlippage)),p=t.route.path.map((function(t){return t.address})),f="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.tradeType){case exports.TradeType.EXACT_INPUT:n?(o=l?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[d,p,s,f],u=c):r?(o=l?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[c,d,p,s,f],u="0x0"):(o=l?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[c,d,p,s,f],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:l&&a(!1),n?(o="swapETHForExactTokens",i=[d,p,s,f],u=c):r?(o="swapTokensForExactETH",i=[d,c,p,s,f],u="0x0"):(o="swapTokensForExactTokens",i=[d,c,p,s,f],u="0x0")}return{methodName:o,args:i,value:u}},t}(),Ot=[{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],bt=((It={})[exports.ChainId.MAINNET]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},It),Et=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,o){try{var i,a,u=function(n){return new z(t,e,n,r,o)};void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t)));var s="number"==typeof(null===(i=bt)||void 0===i||null===(a=i[t])||void 0===a?void 0:a[e]);return Promise.resolve(s?u(bt[t][e]):Promise.resolve(new f.Contract(e,Ot,n).decimals().then((function(n){var r,o,i;return bt=P({},bt,((i={})[t]=P({},null===(r=bt)||void 0===r?void 0:r[t],((o={})[e]=n,o)),i)),n}))).then(u))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=h.getDefaultProvider(l.getNetwork(t.chainId))),t.chainId!==e.chainId&&a(!1);var r=lt.getAddress(t,e);return Promise.resolve(new f.Contract(r,m.abi,n).getReserves()).then((function(n){var r=n[0],o=n[1],i=t.sortsBefore(e)?[r,o]:[o,r];return new lt(new dt(t,i[0]),new dt(e,i[1]))}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=i,exports.Currency=Q,exports.CurrencyAmount=ct,exports.FACTORY_ADDRESS="0x1daed74ed1dd7c9dabbe51361ac90a69d851234d",exports.Fetcher=Et,exports.Fraction=ut,exports.HT=$,exports.INIT_CODE_HASH=y,exports.InsufficientInputAmountError=L,exports.InsufficientReservesError=M,exports.MINIMUM_LIQUIDITY=w,exports.Pair=lt,exports.Percent=vt,exports.Price=pt,exports.Route=ht,exports.Router=At,exports.Token=z,exports.TokenAmount=dt,exports.Trade=kt,exports.WHT=nt,exports.currencyEquals=Z,exports.inputOutputComparator=yt,exports.tradeComparator=wt; | ||
//# sourceMappingURL=sdk.cjs.production.min.js.map |
@@ -24,2 +24,6 @@ import JSBI from 'jsbi'; | ||
ChainId[ChainId["KOVAN"] = 42] = "KOVAN"; | ||
ChainId[ChainId["HECO"] = 128] = "HECO"; | ||
ChainId[ChainId["THECO"] = 256] = "THECO"; | ||
ChainId[ChainId["BSC"] = 56] = "BSC"; | ||
ChainId[ChainId["TBSC"] = 97] = "TBSC"; | ||
})(ChainId || (ChainId = {})); | ||
@@ -43,5 +47,5 @@ | ||
var FACTORY_ADDRESS = '0xf028f723ed1d0fe01cc59973c49298aa95c57472'; // todo: change code hash | ||
var FACTORY_ADDRESS = '0x1daed74ed1dd7c9dabbe51361ac90a69d851234d'; // todo: change code hash | ||
var INIT_CODE_HASH = '0xb465bbe4edb8c9b0da8ff0b2b36ce0065de9fcd5a33f32c6856ea821779c8b72'; | ||
var INIT_CODE_HASH = '0xb7b88947a6a423e784cb5512eccdfee6426797f5f681f521bc1687e844ef15be'; | ||
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption | ||
@@ -364,3 +368,3 @@ | ||
/** | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`. | ||
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.HT`. | ||
* @param decimals decimals of the currency | ||
@@ -380,6 +384,6 @@ * @param symbol symbol of the currency | ||
Currency.ETHER = /*#__PURE__*/new Currency(18, 'ETH', 'Ether'); | ||
var ETHER = Currency.ETHER; | ||
Currency.HT = /*#__PURE__*/new Currency(18, 'BNB', 'BNB'); | ||
var HT = Currency.HT; | ||
var _WETH; | ||
var _WHT; | ||
/** | ||
@@ -447,3 +451,3 @@ * Represents an ERC20 token with a unique address and some metadata. | ||
} | ||
var WETH = (_WETH = {}, _WETH[ChainId.MAINNET] = /*#__PURE__*/new Token(ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WETH[ChainId.ROPSTEN] = /*#__PURE__*/new Token(ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[ChainId.RINKEBY] = /*#__PURE__*/new Token(ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[ChainId.GÖRLI] = /*#__PURE__*/new Token(ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WETH[ChainId.KOVAN] = /*#__PURE__*/new Token(ChainId.KOVAN, '0xA050886815CFc52a24B9C4aD044ca199990B6690', 18, 'WETH', 'Wrapped Ether'), _WETH); | ||
var WHT = (_WHT = {}, _WHT[ChainId.MAINNET] = /*#__PURE__*/new Token(ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WHT[ChainId.ROPSTEN] = /*#__PURE__*/new Token(ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WHT[ChainId.RINKEBY] = /*#__PURE__*/new Token(ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WHT[ChainId.GÖRLI] = /*#__PURE__*/new Token(ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WHT[ChainId.KOVAN] = /*#__PURE__*/new Token(ChainId.KOVAN, '0xA050886815CFc52a24B9C4aD044ca199990B6690', 18, 'WETH', 'Wrapped Ether'), _WHT[ChainId.HECO] = /*#__PURE__*/new Token(ChainId.HECO, '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', 18, 'WHT', 'Wrapped HT'), _WHT[ChainId.THECO] = /*#__PURE__*/new Token(ChainId.THECO, '0x5b2da6f42ca09c77d577a12bead0446148830687', 18, 'WHT', 'Wrapped HT'), _WHT[ChainId.BSC] = /*#__PURE__*/new Token(ChainId.BSC, '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', 18, 'WBNB', 'Wrapped BNB'), _WHT[ChainId.TBSC] = /*#__PURE__*/new Token(ChainId.TBSC, '0xae13d989dac2f0debff460ac112a837c89baa7cd', 18, 'WBNB', 'Wrapped BNB'), _WHT); | ||
@@ -587,9 +591,9 @@ var _toSignificantRoundin, _toFixedRounding; | ||
/** | ||
* Helper that calls the constructor with the ETHER currency | ||
* @param amount ether amount in wei | ||
* Helper that calls the constructor with the HT currency | ||
* @param amount HT amount in wei | ||
*/ | ||
CurrencyAmount.ether = function ether(amount) { | ||
return new CurrencyAmount(ETHER, amount); | ||
CurrencyAmount.ht = function ht(amount) { | ||
return new CurrencyAmount(HT, amount); | ||
}; | ||
@@ -968,5 +972,5 @@ | ||
}) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_IDS') : invariant(false) : void 0; | ||
!(input instanceof Token && pairs[0].involvesToken(input) || input === ETHER && pairs[0].involvesToken(WETH[pairs[0].chainId])) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0; | ||
!(typeof output === 'undefined' || output instanceof Token && pairs[pairs.length - 1].involvesToken(output) || output === ETHER && pairs[pairs.length - 1].involvesToken(WETH[pairs[0].chainId])) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0; | ||
var path = [input instanceof Token ? input : WETH[pairs[0].chainId]]; | ||
!(input instanceof Token && pairs[0].involvesToken(input) || input === HT && pairs[0].involvesToken(WHT[pairs[0].chainId])) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0; | ||
!(typeof output === 'undefined' || output instanceof Token && pairs[pairs.length - 1].involvesToken(output) || output === HT && pairs[pairs.length - 1].involvesToken(WHT[pairs[0].chainId])) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0; | ||
var path = [input instanceof Token ? input : WHT[pairs[0].chainId]]; | ||
@@ -1093,3 +1097,3 @@ for (var _iterator = _createForOfIteratorHelperLoose(pairs.entries()), _step; !(_step = _iterator()).done;) { | ||
* Given a currency amount and a chain ID, returns the equivalent representation as the token amount. | ||
* In other words, if the currency is ETHER, returns the WETH token amount for the given chain. Otherwise, returns | ||
* In other words, if the currency is HT, returns the WHT token amount for the given chain. Otherwise, returns | ||
* the input currency amount. | ||
@@ -1100,3 +1104,3 @@ */ | ||
if (currencyAmount instanceof TokenAmount) return currencyAmount; | ||
if (currencyAmount.currency === ETHER) return new TokenAmount(WETH[chainId], currencyAmount.raw); | ||
if (currencyAmount.currency === HT) return new TokenAmount(WHT[chainId], currencyAmount.raw); | ||
process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) ; | ||
@@ -1107,3 +1111,3 @@ } | ||
if (currency instanceof Token) return currency; | ||
if (currency === ETHER) return WETH[chainId]; | ||
if (currency === HT) return WHT[chainId]; | ||
process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) ; | ||
@@ -1154,4 +1158,4 @@ } | ||
this.tradeType = tradeType; | ||
this.inputAmount = tradeType === TradeType.EXACT_INPUT ? amount : route.input === ETHER ? CurrencyAmount.ether(amounts[0].raw) : amounts[0]; | ||
this.outputAmount = tradeType === TradeType.EXACT_OUTPUT ? amount : route.output === ETHER ? CurrencyAmount.ether(amounts[amounts.length - 1].raw) : amounts[amounts.length - 1]; | ||
this.inputAmount = tradeType === TradeType.EXACT_INPUT ? amount : route.input === HT ? CurrencyAmount.ht(amounts[0].raw) : amounts[0]; | ||
this.outputAmount = tradeType === TradeType.EXACT_OUTPUT ? amount : route.output === HT ? CurrencyAmount.ht(amounts[amounts.length - 1].raw) : amounts[amounts.length - 1]; | ||
this.executionPrice = new Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.raw, this.outputAmount.raw); | ||
@@ -1196,3 +1200,3 @@ this.nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input)); | ||
var slippageAdjustedAmountOut = new Fraction(ONE).add(slippageTolerance).invert().multiply(this.outputAmount.raw).quotient; | ||
return this.outputAmount instanceof TokenAmount ? new TokenAmount(this.outputAmount.token, slippageAdjustedAmountOut) : CurrencyAmount.ether(slippageAdjustedAmountOut); | ||
return this.outputAmount instanceof TokenAmount ? new TokenAmount(this.outputAmount.token, slippageAdjustedAmountOut) : CurrencyAmount.ht(slippageAdjustedAmountOut); | ||
} | ||
@@ -1213,3 +1217,3 @@ } | ||
var slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.raw).quotient; | ||
return this.inputAmount instanceof TokenAmount ? new TokenAmount(this.inputAmount.token, slippageAdjustedAmountIn) : CurrencyAmount.ether(slippageAdjustedAmountIn); | ||
return this.inputAmount instanceof TokenAmount ? new TokenAmount(this.inputAmount.token, slippageAdjustedAmountIn) : CurrencyAmount.ht(slippageAdjustedAmountIn); | ||
} | ||
@@ -1406,6 +1410,6 @@ } | ||
Router.swapCallParameters = function swapCallParameters(trade, options) { | ||
var etherIn = trade.inputAmount.currency === ETHER; | ||
var etherOut = trade.outputAmount.currency === ETHER; // the router does not support both ether in and out | ||
var etherIn = trade.inputAmount.currency === HT; | ||
var etherOut = trade.outputAmount.currency === HT; // the router does not support both ether in and out | ||
!!(etherIn && etherOut) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ETHER_IN_OUT') : invariant(false) : void 0; | ||
!!(etherIn && etherOut) ? process.env.NODE_ENV !== "production" ? invariant(false, 'BNB_IN_OUT') : invariant(false) : void 0; | ||
!(!('ttl' in options) || options.ttl > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TTL') : invariant(false) : void 0; | ||
@@ -1588,3 +1592,3 @@ var to = validateAndParseAddress(options.recipient); | ||
export { ChainId, Currency, CurrencyAmount, ETHER, FACTORY_ADDRESS, Fetcher, Fraction, INIT_CODE_HASH, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, Pair, Percent, Price, Rounding, Route, Router, Token, TokenAmount, Trade, TradeType, WETH, currencyEquals, inputOutputComparator, tradeComparator }; | ||
export { ChainId, Currency, CurrencyAmount, FACTORY_ADDRESS, Fetcher, Fraction, HT, INIT_CODE_HASH, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, Pair, Percent, Price, Rounding, Route, Router, Token, TokenAmount, Trade, TradeType, WHT, currencyEquals, inputOutputComparator, tradeComparator }; | ||
//# sourceMappingURL=sdk.esm.js.map |
{ | ||
"name": "@sashimiswap/sdk", | ||
"license": "MIT", | ||
"version": "1.0.3", | ||
"version": "1.0.4-bsc", | ||
"description": "🛠 An SDK for building applications on top of Sashimiswap, forked with @uniswap/sdk.", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
458519
3180
3