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

@uniswap/v2-sdk

Package Overview
Dependencies
Maintainers
16
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/v2-sdk - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1-beta.1

2

dist/entities/pair.d.ts
import { BigintIsh, CurrencyAmount, Price, Token } from '@uniswap/sdk-core';
export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB }: {
export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB, }: {
factoryAddress: string;

@@ -4,0 +4,0 @@ tokenA: Token;

@@ -17,8 +17,7 @@ 'use strict';

*/
var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
var FACTORY_ADDRESS_MAP = sdkCore.V2_FACTORY_ADDRESSES;
var INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f';
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000);
// exports for internal consumption
var ZERO = /*#__PURE__*/JSBI.BigInt(0);

@@ -33,2 +32,31 @@ var ONE = /*#__PURE__*/JSBI.BigInt(1);

function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : String(i);
}
function _defineProperties(target, props) {

@@ -40,20 +68,20 @@ for (var i = 0; i < props.length; i++) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
_setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);

@@ -63,66 +91,30 @@ };

}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
function _isNativeFunction(fn) {
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
return Function.toString.call(fn).indexOf("[native code]") !== -1;
} catch (e) {
return false;
return typeof fn === "function";
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {

@@ -138,6 +130,4 @@ constructor: {

};
return _wrapNativeSuper(Class);
}
function _assertThisInitialized(self) {

@@ -147,6 +137,4 @@ if (self === void 0) {

}
return self;
}
function _unsupportedIterableToArray(o, minLen) {

@@ -160,34 +148,24 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
}
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 {
done: false,
value: o[i++]
};
};
}
it = o[Symbol.iterator]();
return it.next.bind(it);
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

@@ -201,9 +179,6 @@

*/
var InsufficientReservesError = /*#__PURE__*/function (_Error) {
_inheritsLoose(InsufficientReservesError, _Error);
function InsufficientReservesError() {
var _this;
_this = _Error.call(this) || this;

@@ -215,3 +190,2 @@ _this.isInsufficientReservesError = true;

}
return InsufficientReservesError;

@@ -223,9 +197,6 @@ }( /*#__PURE__*/_wrapNativeSuper(Error));

*/
var InsufficientInputAmountError = /*#__PURE__*/function (_Error2) {
_inheritsLoose(InsufficientInputAmountError, _Error2);
function InsufficientInputAmountError() {
var _this2;
_this2 = _Error2.call(this) || this;

@@ -237,3 +208,2 @@ _this2.isInsufficientInputAmountError = true;

}
return InsufficientInputAmountError;

@@ -244,10 +214,7 @@ }( /*#__PURE__*/_wrapNativeSuper(Error));

var factoryAddress = _ref.factoryAddress,
tokenA = _ref.tokenA,
tokenB = _ref.tokenB;
tokenA = _ref.tokenA,
tokenB = _ref.tokenB;
var _ref2 = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA],
token0 = _ref2[0],
token1 = _ref2[1]; // does safety checks
token0 = _ref2[0],
token1 = _ref2[1]; // does safety checks
return address.getCreate2Address(factoryAddress, solidity.keccak256(['bytes'], [solidity.pack(['address', 'address'], [token0.address, token1.address])]), INIT_CODE_HASH);

@@ -262,6 +229,4 @@ };

}
Pair.getAddress = function getAddress(tokenA, tokenB) {
var _FACTORY_ADDRESS_MAP$;
var factoryAddress = (_FACTORY_ADDRESS_MAP$ = FACTORY_ADDRESS_MAP[tokenA.chainId]) != null ? _FACTORY_ADDRESS_MAP$ : FACTORY_ADDRESS;

@@ -277,7 +242,4 @@ return computePairAddress({

* @param token to check
*/
;
*/;
var _proto = Pair.prototype;
_proto.involvesToken = function involvesToken(token) {

@@ -288,5 +250,3 @@ return token.equals(this.token0) || token.equals(this.token1);

* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
*/
;
*/;
/**

@@ -302,5 +262,3 @@ * Return the price of the given token in terms of the other token in the pair.

* Returns the chain ID of the tokens in the pair.
*/
;
*/;
_proto.reserveOf = function reserveOf(token) {

@@ -369,5 +327,3 @@ !this.involvesToken(token) ? invariant(false, 'TOKEN') : void 0;

* @param calculateFotFees
*/
;
*/;
_proto.getOutputAmount = function getOutputAmount(inputAmount, calculateFotFees) {

@@ -377,9 +333,6 @@ if (calculateFotFees === void 0) {

}
!this.involvesToken(inputAmount.currency) ? invariant(false, 'TOKEN') : void 0;
if (JSBI.equal(this.reserve0.quotient, ZERO) || JSBI.equal(this.reserve1.quotient, ZERO)) {
throw new InsufficientReservesError();
}
var inputReserve = this.reserveOf(inputAmount.currency);

@@ -395,15 +348,11 @@ var outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);

);
if (JSBI.equal(outputAmount.quotient, ZERO)) {
throw new InsufficientInputAmountError();
}
var percentAfterBuyFees = calculateFotFees ? this.derivePercentAfterBuyFees(outputAmount) : ZERO_PERCENT;
var outputAmountAfterTax = percentAfterBuyFees.greaterThan(ZERO_PERCENT) ? sdkCore.CurrencyAmount.fromRawAmount(outputAmount.currency, outputAmount.multiply(percentAfterBuyFees).quotient // fraction.quotient will round down by itself, which is desired
) : outputAmount;
if (JSBI.equal(outputAmountAfterTax.quotient, ZERO)) {
throw new InsufficientInputAmountError();
}
return [outputAmountAfterTax, new Pair(inputReserve.add(inputAmountAfterTax), outputReserve.subtract(outputAmountAfterTax))];

@@ -452,5 +401,3 @@ }

* @param outputAmount
*/
;
*/;
_proto.getInputAmount = function getInputAmount(outputAmount, calculateFotFees) {

@@ -460,3 +407,2 @@ if (calculateFotFees === void 0) {

}
!this.involvesToken(outputAmount.currency) ? invariant(false, 'TOKEN') : void 0;

@@ -466,7 +412,5 @@ var percentAfterBuyFees = calculateFotFees ? this.derivePercentAfterBuyFees(outputAmount) : ZERO_PERCENT;

) : outputAmount;
if (JSBI.equal(this.reserve0.quotient, ZERO) || JSBI.equal(this.reserve1.quotient, ZERO) || JSBI.greaterThanOrEqual(outputAmount.quotient, this.reserveOf(outputAmount.currency).quotient) || JSBI.greaterThanOrEqual(outputAmountBeforeTax.quotient, this.reserveOf(outputAmount.currency).quotient)) {
throw new InsufficientReservesError();
}
var outputReserve = this.reserveOf(outputAmount.currency);

@@ -483,3 +427,2 @@ var inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);

};
_proto.getLiquidityMinted = function getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {

@@ -491,3 +434,2 @@ !totalSupply.currency.equals(this.liquidityToken) ? invariant(false, 'LIQUIDITY') : void 0;

var liquidity;
if (JSBI.equal(totalSupply.quotient, ZERO)) {

@@ -500,10 +442,7 @@ liquidity = JSBI.subtract(sdkCore.sqrt(JSBI.multiply(tokenAmounts[0].quotient, tokenAmounts[1].quotient)), MINIMUM_LIQUIDITY);

}
if (!JSBI.greaterThan(liquidity, ZERO)) {
throw new InsufficientInputAmountError();
}
return sdkCore.CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity);
};
_proto.getLiquidityValue = function getLiquidityValue(token, totalSupply, liquidity, feeOn, kLast) {

@@ -513,3 +452,2 @@ if (feeOn === void 0) {

}
!this.involvesToken(token) ? invariant(false, 'TOKEN') : void 0;

@@ -520,3 +458,2 @@ !totalSupply.currency.equals(this.liquidityToken) ? invariant(false, 'TOTAL_SUPPLY') : void 0;

var totalSupplyAdjusted;
if (!feeOn) {

@@ -527,7 +464,5 @@ totalSupplyAdjusted = totalSupply;

var kLastParsed = JSBI.BigInt(kLast);
if (!JSBI.equal(kLastParsed, ZERO)) {
var rootK = sdkCore.sqrt(JSBI.multiply(this.reserve0.quotient, this.reserve1.quotient));
var rootKLast = sdkCore.sqrt(kLastParsed);
if (JSBI.greaterThan(rootK, rootKLast)) {

@@ -545,9 +480,6 @@ var numerator = JSBI.multiply(totalSupply.quotient, JSBI.subtract(rootK, rootKLast));

}
return sdkCore.CurrencyAmount.fromRawAmount(token, JSBI.divide(JSBI.multiply(liquidity.quotient, this.reserveOf(token).quotient), totalSupplyAdjusted.quotient));
};
_proto.derivePercentAfterSellFees = function derivePercentAfterSellFees(inputAmount) {
var sellFeeBips = this.token0.wrapped.equals(inputAmount.wrapped.currency) ? this.token0.wrapped.sellFeeBps : this.token1.wrapped.sellFeeBps;
if (sellFeeBips != null && sellFeeBips.gt(bignumber.BigNumber.from(0))) {

@@ -559,6 +491,4 @@ return ONE_HUNDRED_PERCENT.subtract(new sdkCore.Percent(JSBI.BigInt(sellFeeBips)).divide(BASIS_POINTS));

};
_proto.derivePercentAfterBuyFees = function derivePercentAfterBuyFees(outputAmount) {
var buyFeeBps = this.token0.wrapped.equals(outputAmount.wrapped.currency) ? this.token0.wrapped.buyFeeBps : this.token1.wrapped.buyFeeBps;
if (buyFeeBps != null && buyFeeBps.gt(bignumber.BigNumber.from(0))) {

@@ -570,3 +500,2 @@ return ONE_HUNDRED_PERCENT.subtract(new sdkCore.Percent(JSBI.BigInt(buyFeeBps)).divide(BASIS_POINTS));

};
_createClass(Pair, [{

@@ -581,3 +510,2 @@ key: "token0Price",

*/
}, {

@@ -615,3 +543,2 @@ key: "token1Price",

}]);
return Pair;

@@ -632,15 +559,11 @@ }();

var path = [wrappedInput];
for (var _iterator = _createForOfIteratorHelperLoose(pairs.entries()), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
i = _step$value[0],
pair = _step$value[1];
i = _step$value[0],
pair = _step$value[1];
var currentInput = path[i];
!(currentInput.equals(pair.token0) || currentInput.equals(pair.token1)) ? invariant(false, 'PATH') : void 0;
var _output = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
path.push(_output);
}
this.pairs = pairs;

@@ -651,3 +574,2 @@ this.path = path;

}
_createClass(Route, [{

@@ -658,10 +580,8 @@ key: "midPrice",

var prices = [];
for (var _iterator2 = _createForOfIteratorHelperLoose(this.pairs.entries()), _step2; !(_step2 = _iterator2()).done;) {
var _step2$value = _step2.value,
i = _step2$value[0],
pair = _step2$value[1];
i = _step2$value[0],
pair = _step2$value[1];
prices.push(this.path[i].equals(pair.token0) ? new sdkCore.Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new sdkCore.Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient));
}
var reduced = prices.slice(1).reduce(function (accumulator, currentValue) {

@@ -678,8 +598,7 @@ return accumulator.multiply(currentValue);

}]);
return Route;
}();
// comparator function that allows sorting trades by their output amounts, in decreasing order, and then input amounts
// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first
function inputOutputComparator(a, b) {

@@ -689,9 +608,7 @@ // must have same input and output token for comparison

!a.outputAmount.currency.equals(b.outputAmount.currency) ? invariant(false, 'OUTPUT_CURRENCY') : void 0;
if (a.outputAmount.equalTo(b.outputAmount)) {
if (a.inputAmount.equalTo(b.inputAmount)) {
return 0;
} // trade A requires less input than trade B, so A should come first
}
// trade A requires less input than trade B, so A should come first
if (a.inputAmount.lessThan(b.inputAmount)) {

@@ -710,12 +627,10 @@ return -1;

}
} // extension of the input output comparator that also considers other dimensions of the trade in ranking them
}
// extension of the input output comparator that also considers other dimensions of the trade in ranking them
function tradeComparator(a, b) {
var ioComp = inputOutputComparator(a, b);
if (ioComp !== 0) {
return ioComp;
} // consider lowest slippage next, since these are less likely to fail
}
// consider lowest slippage next, since these are less likely to fail
if (a.priceImpact.lessThan(b.priceImpact)) {

@@ -725,5 +640,4 @@ return -1;

return 1;
} // finally consider the number of hops since each hop costs gas
}
// finally consider the number of hops since each hop costs gas
return a.route.path.length - b.route.path.length;

@@ -735,3 +649,2 @@ }

*/
var Trade = /*#__PURE__*/function () {

@@ -742,16 +655,11 @@ function Trade(route, amount, tradeType) {

var tokenAmounts = new Array(route.path.length);
if (tradeType === sdkCore.TradeType.EXACT_INPUT) {
!amount.currency.equals(route.input) ? invariant(false, 'INPUT') : void 0;
tokenAmounts[0] = amount.wrapped;
for (var i = 0; i < route.path.length - 1; i++) {
var pair = route.pairs[i];
var _pair$getOutputAmount = pair.getOutputAmount(tokenAmounts[i]),
outputAmount = _pair$getOutputAmount[0];
outputAmount = _pair$getOutputAmount[0];
tokenAmounts[i + 1] = outputAmount;
}
this.inputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);

@@ -762,16 +670,11 @@ this.outputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.output, tokenAmounts[tokenAmounts.length - 1].numerator, tokenAmounts[tokenAmounts.length - 1].denominator);

tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
for (var _i = route.path.length - 1; _i > 0; _i--) {
var _pair = route.pairs[_i - 1];
var _pair$getInputAmount = _pair.getInputAmount(tokenAmounts[_i]),
inputAmount = _pair$getInputAmount[0];
inputAmount = _pair$getInputAmount[0];
tokenAmounts[_i - 1] = inputAmount;
}
this.inputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.input, tokenAmounts[0].numerator, tokenAmounts[0].denominator);
this.outputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
}
this.executionPrice = new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);

@@ -785,4 +688,2 @@ this.priceImpact = sdkCore.computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);

*/
Trade.exactIn = function exactIn(route, amountIn) {

@@ -795,5 +696,3 @@ return new Trade(route, amountIn, sdkCore.TradeType.EXACT_INPUT);

* @param amountOut the amount returned by the trade
*/
;
*/;
Trade.exactOut = function exactOut(route, amountOut) {

@@ -805,10 +704,6 @@ return new Trade(route, amountOut, sdkCore.TradeType.EXACT_OUTPUT);

* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
*/
;
*/;
var _proto = Trade.prototype;
_proto.minimumAmountOut = function minimumAmountOut(slippageTolerance) {
!!slippageTolerance.lessThan(ZERO) ? invariant(false, 'SLIPPAGE_TOLERANCE') : void 0;
if (this.tradeType === sdkCore.TradeType.EXACT_OUTPUT) {

@@ -824,8 +719,5 @@ return this.outputAmount;

* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
*/
;
*/;
_proto.maximumAmountIn = function maximumAmountIn(slippageTolerance) {
!!slippageTolerance.lessThan(ZERO) ? invariant(false, 'SLIPPAGE_TOLERANCE') : void 0;
if (this.tradeType === sdkCore.TradeType.EXACT_INPUT) {

@@ -851,25 +743,20 @@ return this.inputAmount;

* @param bestTrades used in recursion; the current list of best trades
*/
;
Trade.bestTradeExactIn = function bestTradeExactIn(pairs, currencyAmountIn, currencyOut, _temp, // used in recursion.
*/;
Trade.bestTradeExactIn = function bestTradeExactIn(pairs, currencyAmountIn, currencyOut, _temp,
// used in recursion.
currentPairs, nextAmountIn, bestTrades) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$maxNumResults = _ref.maxNumResults,
maxNumResults = _ref$maxNumResults === void 0 ? 3 : _ref$maxNumResults,
_ref$maxHops = _ref.maxHops,
maxHops = _ref$maxHops === void 0 ? 3 : _ref$maxHops;
_ref$maxNumResults = _ref.maxNumResults,
maxNumResults = _ref$maxNumResults === void 0 ? 3 : _ref$maxNumResults,
_ref$maxHops = _ref.maxHops,
maxHops = _ref$maxHops === void 0 ? 3 : _ref$maxHops;
if (currentPairs === void 0) {
currentPairs = [];
}
if (nextAmountIn === void 0) {
nextAmountIn = currencyAmountIn;
}
if (bestTrades === void 0) {
bestTrades = [];
}
!(pairs.length > 0) ? invariant(false, 'PAIRS') : void 0;

@@ -880,15 +767,11 @@ !(maxHops > 0) ? invariant(false, 'MAX_HOPS') : void 0;

var tokenOut = currencyOut.wrapped;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i]; // pair irrelevant
var pair = pairs[i];
// pair irrelevant
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;
var amountOut = void 0;
try {
;
var _pair$getOutputAmount2 = pair.getOutputAmount(amountIn);
amountOut = _pair$getOutputAmount2[0];

@@ -900,12 +783,10 @@ } catch (error) {

}
throw error;
} // we have arrived at the output token, so this is the final trade of one of the paths
}
// we have arrived at the output token, so this is the final trade of one of the paths
if (amountOut.currency.equals(tokenOut)) {
sdkCore.sortedInsert(bestTrades, new Trade(new Route([].concat(currentPairs, [pair]), currencyAmountIn.currency, currencyOut), currencyAmountIn, sdkCore.TradeType.EXACT_INPUT), maxNumResults, tradeComparator);
} else if (maxHops > 1 && pairs.length > 1) {
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)); // otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
// otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops
Trade.bestTradeExactIn(pairsExcludingThisPair, currencyAmountIn, currencyOut, {

@@ -917,3 +798,2 @@ maxNumResults: maxNumResults,

}
return bestTrades;

@@ -924,5 +804,3 @@ }

* @param slippageTolerance the allowed tolerated slippage
*/
;
*/;
_proto.worstExecutionPrice = function worstExecutionPrice(slippageTolerance) {

@@ -945,25 +823,20 @@ return new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);

* @param bestTrades used in recursion; the current list of best trades
*/
;
Trade.bestTradeExactOut = function bestTradeExactOut(pairs, currencyIn, currencyAmountOut, _temp2, // used in recursion.
*/;
Trade.bestTradeExactOut = function bestTradeExactOut(pairs, currencyIn, currencyAmountOut, _temp2,
// used in recursion.
currentPairs, nextAmountOut, bestTrades) {
var _ref2 = _temp2 === void 0 ? {} : _temp2,
_ref2$maxNumResults = _ref2.maxNumResults,
maxNumResults = _ref2$maxNumResults === void 0 ? 3 : _ref2$maxNumResults,
_ref2$maxHops = _ref2.maxHops,
maxHops = _ref2$maxHops === void 0 ? 3 : _ref2$maxHops;
_ref2$maxNumResults = _ref2.maxNumResults,
maxNumResults = _ref2$maxNumResults === void 0 ? 3 : _ref2$maxNumResults,
_ref2$maxHops = _ref2.maxHops,
maxHops = _ref2$maxHops === void 0 ? 3 : _ref2$maxHops;
if (currentPairs === void 0) {
currentPairs = [];
}
if (nextAmountOut === void 0) {
nextAmountOut = currencyAmountOut;
}
if (bestTrades === void 0) {
bestTrades = [];
}
!(pairs.length > 0) ? invariant(false, 'PAIRS') : void 0;

@@ -974,15 +847,11 @@ !(maxHops > 0) ? invariant(false, 'MAX_HOPS') : void 0;

var tokenIn = currencyIn.wrapped;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i]; // pair irrelevant
var pair = pairs[i];
// pair irrelevant
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;
var amountIn = void 0;
try {
;
var _pair$getInputAmount2 = pair.getInputAmount(amountOut);
amountIn = _pair$getInputAmount2[0];

@@ -994,12 +863,10 @@ } catch (error) {

}
throw error;
} // we have arrived at the input token, so this is the first trade of one of the paths
}
// we have arrived at the input token, so this is the first trade of one of the paths
if (amountIn.currency.equals(tokenIn)) {
sdkCore.sortedInsert(bestTrades, new Trade(new Route([pair].concat(currentPairs), currencyIn, currencyAmountOut.currency), currencyAmountOut, sdkCore.TradeType.EXACT_OUTPUT), maxNumResults, tradeComparator);
} else if (maxHops > 1 && pairs.length > 1) {
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)); // otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
// otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops
Trade.bestTradeExactOut(pairsExcludingThisPair, currencyIn, currencyAmountOut, {

@@ -1011,6 +878,4 @@ maxNumResults: maxNumResults,

}
return bestTrades;
};
return Trade;

@@ -1022,3 +887,2 @@ }();

}
var ZERO_HEX = '0x0';

@@ -1028,3 +892,2 @@ /**

*/
var Router = /*#__PURE__*/function () {

@@ -1040,8 +903,6 @@ /**

*/
Router.swapCallParameters = function swapCallParameters(trade, options) {
var etherIn = trade.inputAmount.currency.isNative;
var etherOut = trade.outputAmount.currency.isNative; // the router does not support both ether in and out
var etherOut = trade.outputAmount.currency.isNative;
// the router does not support both ether in and out
!!(etherIn && etherOut) ? invariant(false, 'ETHER_IN_OUT') : void 0;

@@ -1060,47 +921,41 @@ !(!('ttl' in options) || options.ttl > 0) ? invariant(false, 'TTL') : void 0;

var value;
switch (trade.tradeType) {
case sdkCore.TradeType.EXACT_INPUT:
if (etherIn) {
methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens'; // (uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens';
// (uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountOut, path, to, deadline];
value = amountIn;
} else if (etherOut) {
methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH'; // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH';
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountIn, amountOut, path, to, deadline];
value = ZERO_HEX;
} else {
methodName = useFeeOnTransfer ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' : 'swapExactTokensForTokens'; // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' : 'swapExactTokensForTokens';
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountIn, amountOut, path, to, deadline];
value = ZERO_HEX;
}
break;
case sdkCore.TradeType.EXACT_OUTPUT:
!!useFeeOnTransfer ? invariant(false, 'EXACT_OUT_FOT') : void 0;
if (etherIn) {
methodName = 'swapETHForExactTokens'; // (uint amountOut, address[] calldata path, address to, uint deadline)
methodName = 'swapETHForExactTokens';
// (uint amountOut, address[] calldata path, address to, uint deadline)
args = [amountOut, path, to, deadline];
value = amountIn;
} else if (etherOut) {
methodName = 'swapTokensForExactETH'; // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
methodName = 'swapTokensForExactETH';
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
args = [amountOut, amountIn, path, to, deadline];
value = ZERO_HEX;
} else {
methodName = 'swapTokensForExactTokens'; // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
methodName = 'swapTokensForExactTokens';
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
args = [amountOut, amountIn, path, to, deadline];
value = ZERO_HEX;
}
break;
}
return {

@@ -1112,3 +967,2 @@ methodName: methodName,

};
return Router;

@@ -1115,0 +969,0 @@ }();

@@ -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=require("@uniswap/sdk-core"),r=t(require("jsbi")),n=require("@ethersproject/address"),u=require("@ethersproject/bignumber"),o=require("@ethersproject/solidity"),i=t(require("tiny-invariant")),s=e.V2_FACTORY_ADDRESSES,a="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",c=r.BigInt(1e3),p=r.BigInt(0),l=r.BigInt(1),m=r.BigInt(5),h=r.BigInt(997),f=r.BigInt(1e3),d=r.BigInt(1e4),y=new e.Percent(p),v=new e.Percent(l);function A(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function T(t,e,r){return e&&A(t.prototype,e),r&&A(t,r),t}function q(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function k(t){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function w(t,e){return(w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(){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 I(t,e,r){return(I=g()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var u=new(Function.bind.apply(t,n));return r&&w(u,r.prototype),u}).apply(null,arguments)}function b(t){var e="function"==typeof Map?new Map:void 0;return(b=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,r)}function r(){return I(t,arguments,k(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)})(t)}function O(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function P(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return x(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}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(r=t[Symbol.iterator]()).next.bind(r)}var E="setPrototypeOf"in Object,C=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,E&&Object.setPrototypeOf(O(r),(this instanceof e?this.constructor:void 0).prototype),r}return q(e,t),e}(b(Error)),_=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,E&&Object.setPrototypeOf(O(r),(this instanceof e?this.constructor:void 0).prototype),r}return q(e,t),e}(b(Error)),F=function(t){var e=t.factoryAddress,r=t.tokenA,u=t.tokenB,i=r.sortsBefore(u)?[r,u]:[u,r];return n.getCreate2Address(e,o.keccak256(["bytes"],[o.pack(["address","address"],[i[0].address,i[1].address])]),a)},R=function(){function t(r,n){var u=r.currency.sortsBefore(n.currency)?[r,n]:[n,r];this.liquidityToken=new e.Token(u[0].currency.chainId,t.getAddress(u[0].currency,u[1].currency),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=u}t.getAddress=function(t,e){var r,n=null!=(r=s[t.chainId])?r:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";return F({factoryAddress:n,tokenA:t,tokenB:e})};var n=t.prototype;return n.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},n.priceOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.token0Price:this.token1Price},n.reserveOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.reserve0:this.reserve1},n.getOutputAmount=function(n,u){if(void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new C;var o=this.reserveOf(n.currency),s=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),a=u?this.derivePercentAfterSellFees(n):y,c=a.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,a.multiply(n).quotient):n,l=r.multiply(c.quotient,h),m=r.multiply(l,s.quotient),d=r.add(r.multiply(o.quotient,f),l),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.divide(m,d));if(r.equal(v.quotient,p))throw new _;var A=u?this.derivePercentAfterBuyFees(v):y,T=A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,p))throw new _;return[T,new t(o.add(c),s.subtract(T))]},n.getInputAmount=function(n,u){void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1);var o=u?this.derivePercentAfterBuyFees(n):y,s=o.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,r.add(n.divide(o).quotient,l)):n;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(n.quotient,this.reserveOf(n.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(n.currency).quotient))throw new C;var a=this.reserveOf(n.currency),c=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),m=r.multiply(r.multiply(c.quotient,s.quotient),f),d=r.multiply(r.subtract(a.quotient,s.quotient),h),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(m,d),l)),A=u?this.derivePercentAfterSellFees(v):y;return[A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,l)):v,new t(c.add(v),a.subtract(n))]},n.getLiquidityMinted=function(t,n,u){t.currency.equals(this.liquidityToken)||i(!1);var o,s=n.currency.sortsBefore(u.currency)?[n,u]:[u,n];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||i(!1),r.equal(t.quotient,p))o=r.subtract(e.sqrt(r.multiply(s[0].quotient,s[1].quotient)),c);else{var a=r.divide(r.multiply(s[0].quotient,t.quotient),this.reserve0.quotient),l=r.divide(r.multiply(s[1].quotient,t.quotient),this.reserve1.quotient);o=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(o,p))throw new _;return e.CurrencyAmount.fromRawAmount(this.liquidityToken,o)},n.getLiquidityValue=function(t,n,u,o,s){var a;if(void 0===o&&(o=!1),this.involvesToken(t)||i(!1),n.currency.equals(this.liquidityToken)||i(!1),u.currency.equals(this.liquidityToken)||i(!1),r.lessThanOrEqual(u.quotient,n.quotient)||i(!1),o){s||i(!1);var c=r.BigInt(s);if(r.equal(c,p))a=n;else{var l=e.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),h=e.sqrt(c);if(r.greaterThan(l,h)){var f=r.multiply(n.quotient,r.subtract(l,h)),d=r.add(r.multiply(l,m),h),y=r.divide(f,d);a=n.add(e.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=n}}else a=n;return e.CurrencyAmount.fromRawAmount(t,r.divide(r.multiply(u.quotient,this.reserveOf(t).quotient),a.quotient))},n.derivePercentAfterSellFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.sellFeeBps:this.token1.wrapped.sellFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},n.derivePercentAfterBuyFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.buyFeeBps:this.token1.wrapped.buyFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},T(t,[{key:"token0Price",get:function(){var t=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new e.Price(this.token0,this.token1,t.denominator,t.numerator)}},{key:"token1Price",get:function(){var t=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new e.Price(this.token1,this.token0,t.denominator,t.numerator)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].currency}},{key:"token1",get:function(){return this.tokenAmounts[1].currency}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),B=function(){function t(t,e,r){this._midPrice=null,t.length>0||i(!1);var n=t[0].chainId;t.every((function(t){return t.chainId===n}))||i(!1);var u=e.wrapped;t[0].involvesToken(u)||i(!1),void 0===r||t[t.length-1].involvesToken(r.wrapped)||i(!1);for(var o,s=[u],a=P(t.entries());!(o=a()).done;){var c=o.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||i(!1);var m=l.equals(p.token0)?p.token1:p.token0;s.push(m)}this.pairs=t,this.path=s,this.input=e,this.output=r}return T(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,r=[],n=P(this.pairs.entries());!(t=n()).done;){var u=t.value,o=u[1];r.push(this.path[u[0]].equals(o.token0)?new e.Price(o.reserve0.currency,o.reserve1.currency,o.reserve0.quotient,o.reserve1.quotient):new e.Price(o.reserve1.currency,o.reserve0.currency,o.reserve1.quotient,o.reserve0.quotient))}var i=r.slice(1).reduce((function(t,e){return t.multiply(e)}),r[0]);return this._midPrice=new e.Price(this.input,this.output,i.denominator,i.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}();function S(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||i(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||i(!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 j(t,e){var r=S(t,e);return 0!==r?r:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}var U=function(){function t(t,r,n){this.route=t,this.tradeType=n;var u=new Array(t.path.length);if(n===e.TradeType.EXACT_INPUT){r.currency.equals(t.input)||i(!1),u[0]=r.wrapped;for(var o=0;o<t.path.length-1;o++){var s=t.pairs[o].getOutputAmount(u[o]);u[o+1]=s[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,r.numerator,r.denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,u[u.length-1].numerator,u[u.length-1].denominator)}else{r.currency.equals(t.output)||i(!1),u[u.length-1]=r.wrapped;for(var a=t.path.length-1;a>0;a--){var c=t.pairs[a-1].getInputAmount(u[a]);u[a-1]=c[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,u[0].numerator,u[0].denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,r.numerator,r.denominator)}this.executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=e.computePriceImpact(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(r,n){return new t(r,n,e.TradeType.EXACT_INPUT)},t.exactOut=function(r,n){return new t(r,n,e.TradeType.EXACT_OUTPUT)};var r=t.prototype;return r.minimumAmountOut=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new e.Fraction(l).add(t).invert().multiply(this.outputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var r=new e.Fraction(l).add(t).multiply(this.inputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},t.bestTradeExactIn=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,m=l.maxNumResults,h=void 0===m?3:m,f=l.maxHops,d=void 0===f?3:f;void 0===s&&(s=[]),void 0===a&&(a=n),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),n===a||s.length>0||i(!1);for(var y=a.wrapped,v=u.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getOutputAmount(y)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new B([].concat(s,[T]),n.currency,u),n,e.TradeType.EXACT_INPUT),h,j);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactIn(k,n,u,{maxNumResults:h,maxHops:d-1},[].concat(s,[T]),q,c)}}}return c},r.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactOut=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,m=l.maxNumResults,h=void 0===m?3:m,f=l.maxHops,d=void 0===f?3:f;void 0===s&&(s=[]),void 0===a&&(a=u),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),u===a||s.length>0||i(!1);for(var y=a.wrapped,v=n.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getInputAmount(y)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new B([T].concat(s),n,u.currency),u,e.TradeType.EXACT_OUTPUT),h,j);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactOut(k,n,u,{maxNumResults:h,maxHops:d-1},[T].concat(s),q,c)}}}return c},t}();function N(t){return"0x"+t.quotient.toString(16)}var H=function(){function t(){}return t.swapCallParameters=function(t,r){var n=t.inputAmount.currency.isNative,u=t.outputAmount.currency.isNative;n&&u&&i(!1),!("ttl"in r)||r.ttl>0||i(!1);var o,s,a,c=e.validateAndParseAddress(r.recipient),p=N(t.maximumAmountIn(r.allowedSlippage)),l=N(t.minimumAmountOut(r.allowedSlippage)),m=t.route.path.map((function(t){return t.address})),h="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),f=Boolean(r.feeOnTransfer);switch(t.tradeType){case e.TradeType.EXACT_INPUT:n?(o=f?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,m,c,h],a=p):u?(o=f?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,m,c,h],a="0x0"):(o=f?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,m,c,h],a="0x0");break;case e.TradeType.EXACT_OUTPUT:f&&i(!1),n?(o="swapETHForExactTokens",s=[l,m,c,h],a=p):u?(o="swapTokensForExactETH",s=[l,p,m,c,h],a="0x0"):(o="swapTokensForExactTokens",s=[l,p,m,c,h],a="0x0")}return{methodName:o,args:s,value:a}},t}();exports.FACTORY_ADDRESS_MAP=s,exports.INIT_CODE_HASH=a,exports.InsufficientInputAmountError=_,exports.InsufficientReservesError=C,exports.MINIMUM_LIQUIDITY=c,exports.Pair=R,exports.Route=B,exports.Router=H,exports.Trade=U,exports.computePairAddress=F,exports.inputOutputComparator=S,exports.tradeComparator=j;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@uniswap/sdk-core"),r=t(require("jsbi")),n=require("@ethersproject/address"),o=require("@ethersproject/bignumber"),u=require("@ethersproject/solidity"),i=t(require("tiny-invariant")),s=e.V2_FACTORY_ADDRESSES,a="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",c=r.BigInt(1e3),p=r.BigInt(0),l=r.BigInt(1),m=r.BigInt(5),f=r.BigInt(997),h=r.BigInt(1e3),d=r.BigInt(1e4),y=new e.Percent(p),v=new e.Percent(l);function A(t,e,r){if(T())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&I(o,r.prototype),o}function T(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(T=function(){return!!t})()}function q(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}function k(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,q(n.key),n)}}function w(t,e,r){return e&&k(t.prototype,e),r&&k(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,I(t,e)}function b(t){return(b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function I(t,e){return(I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function O(t){var e="function"==typeof Map?new Map:void 0;return(O=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))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,r)}function r(){return A(t,arguments,b(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),I(r,t)})(t)}function P(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function E(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return x(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}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 C="setPrototypeOf"in Object,F=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,C&&Object.setPrototypeOf(P(r),(this instanceof e?this.constructor:void 0).prototype),r}return g(e,t),e}(O(Error)),B=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,C&&Object.setPrototypeOf(P(r),(this instanceof e?this.constructor:void 0).prototype),r}return g(e,t),e}(O(Error)),_=function(t){var e=t.factoryAddress,r=t.tokenA,o=t.tokenB,i=r.sortsBefore(o)?[r,o]:[o,r];return n.getCreate2Address(e,u.keccak256(["bytes"],[u.pack(["address","address"],[i[0].address,i[1].address])]),a)},R=function(){function t(r,n){var o=r.currency.sortsBefore(n.currency)?[r,n]:[n,r];this.liquidityToken=new e.Token(o[0].currency.chainId,t.getAddress(o[0].currency,o[1].currency),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=o}t.getAddress=function(t,e){var r,n=null!=(r=s[t.chainId])?r:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";return _({factoryAddress:n,tokenA:t,tokenB:e})};var n=t.prototype;return n.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},n.priceOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.token0Price:this.token1Price},n.reserveOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.reserve0:this.reserve1},n.getOutputAmount=function(n,o){if(void 0===o&&(o=!0),this.involvesToken(n.currency)||i(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new F;var u=this.reserveOf(n.currency),s=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),a=o?this.derivePercentAfterSellFees(n):y,c=a.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,a.multiply(n).quotient):n,l=r.multiply(c.quotient,f),m=r.multiply(l,s.quotient),d=r.add(r.multiply(u.quotient,h),l),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.divide(m,d));if(r.equal(v.quotient,p))throw new B;var A=o?this.derivePercentAfterBuyFees(v):y,T=A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,p))throw new B;return[T,new t(u.add(c),s.subtract(T))]},n.getInputAmount=function(n,o){void 0===o&&(o=!0),this.involvesToken(n.currency)||i(!1);var u=o?this.derivePercentAfterBuyFees(n):y,s=u.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,r.add(n.divide(u).quotient,l)):n;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(n.quotient,this.reserveOf(n.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(n.currency).quotient))throw new F;var a=this.reserveOf(n.currency),c=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),m=r.multiply(r.multiply(c.quotient,s.quotient),h),d=r.multiply(r.subtract(a.quotient,s.quotient),f),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(m,d),l)),A=o?this.derivePercentAfterSellFees(v):y;return[A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,l)):v,new t(c.add(v),a.subtract(n))]},n.getLiquidityMinted=function(t,n,o){t.currency.equals(this.liquidityToken)||i(!1);var u,s=n.currency.sortsBefore(o.currency)?[n,o]:[o,n];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||i(!1),r.equal(t.quotient,p))u=r.subtract(e.sqrt(r.multiply(s[0].quotient,s[1].quotient)),c);else{var a=r.divide(r.multiply(s[0].quotient,t.quotient),this.reserve0.quotient),l=r.divide(r.multiply(s[1].quotient,t.quotient),this.reserve1.quotient);u=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(u,p))throw new B;return e.CurrencyAmount.fromRawAmount(this.liquidityToken,u)},n.getLiquidityValue=function(t,n,o,u,s){var a;if(void 0===u&&(u=!1),this.involvesToken(t)||i(!1),n.currency.equals(this.liquidityToken)||i(!1),o.currency.equals(this.liquidityToken)||i(!1),r.lessThanOrEqual(o.quotient,n.quotient)||i(!1),u){s||i(!1);var c=r.BigInt(s);if(r.equal(c,p))a=n;else{var l=e.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),f=e.sqrt(c);if(r.greaterThan(l,f)){var h=r.multiply(n.quotient,r.subtract(l,f)),d=r.add(r.multiply(l,m),f),y=r.divide(h,d);a=n.add(e.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=n}}else a=n;return e.CurrencyAmount.fromRawAmount(t,r.divide(r.multiply(o.quotient,this.reserveOf(t).quotient),a.quotient))},n.derivePercentAfterSellFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.sellFeeBps:this.token1.wrapped.sellFeeBps;return null!=n&&n.gt(o.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},n.derivePercentAfterBuyFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.buyFeeBps:this.token1.wrapped.buyFeeBps;return null!=n&&n.gt(o.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},w(t,[{key:"token0Price",get:function(){var t=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new e.Price(this.token0,this.token1,t.denominator,t.numerator)}},{key:"token1Price",get:function(){var t=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new e.Price(this.token1,this.token0,t.denominator,t.numerator)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].currency}},{key:"token1",get:function(){return this.tokenAmounts[1].currency}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),S=function(){function t(t,e,r){this._midPrice=null,t.length>0||i(!1);var n=t[0].chainId;t.every((function(t){return t.chainId===n}))||i(!1);var o=e.wrapped;t[0].involvesToken(o)||i(!1),void 0===r||t[t.length-1].involvesToken(r.wrapped)||i(!1);for(var u,s=[o],a=E(t.entries());!(u=a()).done;){var c=u.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||i(!1);var m=l.equals(p.token0)?p.token1:p.token0;s.push(m)}this.pairs=t,this.path=s,this.input=e,this.output=r}return w(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,r=[],n=E(this.pairs.entries());!(t=n()).done;){var o=t.value,u=o[1];r.push(this.path[o[0]].equals(u.token0)?new e.Price(u.reserve0.currency,u.reserve1.currency,u.reserve0.quotient,u.reserve1.quotient):new e.Price(u.reserve1.currency,u.reserve0.currency,u.reserve1.quotient,u.reserve0.quotient))}var i=r.slice(1).reduce((function(t,e){return t.multiply(e)}),r[0]);return this._midPrice=new e.Price(this.input,this.output,i.denominator,i.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}();function j(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||i(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||i(!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 U(t,e){var r=j(t,e);return 0!==r?r:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}var N=function(){function t(t,r,n){this.route=t,this.tradeType=n;var o=new Array(t.path.length);if(n===e.TradeType.EXACT_INPUT){r.currency.equals(t.input)||i(!1),o[0]=r.wrapped;for(var u=0;u<t.path.length-1;u++){var s=t.pairs[u].getOutputAmount(o[u]);o[u+1]=s[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,r.numerator,r.denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,o[o.length-1].numerator,o[o.length-1].denominator)}else{r.currency.equals(t.output)||i(!1),o[o.length-1]=r.wrapped;for(var a=t.path.length-1;a>0;a--){var c=t.pairs[a-1].getInputAmount(o[a]);o[a-1]=c[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,o[0].numerator,o[0].denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,r.numerator,r.denominator)}this.executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=e.computePriceImpact(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(r,n){return new t(r,n,e.TradeType.EXACT_INPUT)},t.exactOut=function(r,n){return new t(r,n,e.TradeType.EXACT_OUTPUT)};var r=t.prototype;return r.minimumAmountOut=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new e.Fraction(l).add(t).invert().multiply(this.outputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var r=new e.Fraction(l).add(t).multiply(this.inputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},t.bestTradeExactIn=function(r,n,o,u,s,a,c){var l=void 0===u?{}:u,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=n),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),n===a||s.length>0||i(!1);for(var y=a.wrapped,v=o.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getOutputAmount(y)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new S([].concat(s,[T]),n.currency,o),n,e.TradeType.EXACT_INPUT),f,U);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactIn(k,n,o,{maxNumResults:f,maxHops:d-1},[].concat(s,[T]),q,c)}}}return c},r.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactOut=function(r,n,o,u,s,a,c){var l=void 0===u?{}:u,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=o),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),o===a||s.length>0||i(!1);for(var y=a.wrapped,v=n.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getInputAmount(y)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new S([T].concat(s),n,o.currency),o,e.TradeType.EXACT_OUTPUT),f,U);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactOut(k,n,o,{maxNumResults:f,maxHops:d-1},[T].concat(s),q,c)}}}return c},t}();function H(t){return"0x"+t.quotient.toString(16)}var M=function(){function t(){}return t.swapCallParameters=function(t,r){var n=t.inputAmount.currency.isNative,o=t.outputAmount.currency.isNative;n&&o&&i(!1),!("ttl"in r)||r.ttl>0||i(!1);var u,s,a,c=e.validateAndParseAddress(r.recipient),p=H(t.maximumAmountIn(r.allowedSlippage)),l=H(t.minimumAmountOut(r.allowedSlippage)),m=t.route.path.map((function(t){return t.address})),f="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),h=Boolean(r.feeOnTransfer);switch(t.tradeType){case e.TradeType.EXACT_INPUT:n?(u=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,m,c,f],a=p):o?(u=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,m,c,f],a="0x0"):(u=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,m,c,f],a="0x0");break;case e.TradeType.EXACT_OUTPUT:h&&i(!1),n?(u="swapETHForExactTokens",s=[l,m,c,f],a=p):o?(u="swapTokensForExactETH",s=[l,p,m,c,f],a="0x0"):(u="swapTokensForExactTokens",s=[l,p,m,c,f],a="0x0")}return{methodName:u,args:s,value:a}},t}();exports.FACTORY_ADDRESS_MAP=s,exports.INIT_CODE_HASH=a,exports.InsufficientInputAmountError=B,exports.InsufficientReservesError=F,exports.MINIMUM_LIQUIDITY=c,exports.Pair=R,exports.Route=S,exports.Router=M,exports.Trade=N,exports.computePairAddress=_,exports.inputOutputComparator=j,exports.tradeComparator=U;
//# sourceMappingURL=v2-sdk.cjs.production.min.js.map

@@ -11,8 +11,7 @@ import { V2_FACTORY_ADDRESSES, Percent, CurrencyAmount, sqrt, Token, Price, TradeType, Fraction, computePriceImpact, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';

*/
var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
var FACTORY_ADDRESS_MAP = V2_FACTORY_ADDRESSES;
var INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f';
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption
var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000);
// exports for internal consumption
var ZERO = /*#__PURE__*/JSBI.BigInt(0);

@@ -27,2 +26,31 @@ var ONE = /*#__PURE__*/JSBI.BigInt(1);

function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : String(i);
}
function _defineProperties(target, props) {

@@ -34,20 +62,20 @@ for (var i = 0; i < props.length; i++) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
_setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);

@@ -57,66 +85,30 @@ };

}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
function _isNativeFunction(fn) {
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
return Function.toString.call(fn).indexOf("[native code]") !== -1;
} catch (e) {
return false;
return typeof fn === "function";
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {

@@ -132,6 +124,4 @@ constructor: {

};
return _wrapNativeSuper(Class);
}
function _assertThisInitialized(self) {

@@ -141,6 +131,4 @@ if (self === void 0) {

}
return self;
}
function _unsupportedIterableToArray(o, minLen) {

@@ -154,34 +142,24 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
}
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 {
done: false,
value: o[i++]
};
};
}
it = o[Symbol.iterator]();
return it.next.bind(it);
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

@@ -195,9 +173,6 @@

*/
var InsufficientReservesError = /*#__PURE__*/function (_Error) {
_inheritsLoose(InsufficientReservesError, _Error);
function InsufficientReservesError() {
var _this;
_this = _Error.call(this) || this;

@@ -209,3 +184,2 @@ _this.isInsufficientReservesError = true;

}
return InsufficientReservesError;

@@ -217,9 +191,6 @@ }( /*#__PURE__*/_wrapNativeSuper(Error));

*/
var InsufficientInputAmountError = /*#__PURE__*/function (_Error2) {
_inheritsLoose(InsufficientInputAmountError, _Error2);
function InsufficientInputAmountError() {
var _this2;
_this2 = _Error2.call(this) || this;

@@ -231,3 +202,2 @@ _this2.isInsufficientInputAmountError = true;

}
return InsufficientInputAmountError;

@@ -238,10 +208,7 @@ }( /*#__PURE__*/_wrapNativeSuper(Error));

var factoryAddress = _ref.factoryAddress,
tokenA = _ref.tokenA,
tokenB = _ref.tokenB;
tokenA = _ref.tokenA,
tokenB = _ref.tokenB;
var _ref2 = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA],
token0 = _ref2[0],
token1 = _ref2[1]; // does safety checks
token0 = _ref2[0],
token1 = _ref2[1]; // does safety checks
return getCreate2Address(factoryAddress, keccak256(['bytes'], [pack(['address', 'address'], [token0.address, token1.address])]), INIT_CODE_HASH);

@@ -256,6 +223,4 @@ };

}
Pair.getAddress = function getAddress(tokenA, tokenB) {
var _FACTORY_ADDRESS_MAP$;
var factoryAddress = (_FACTORY_ADDRESS_MAP$ = FACTORY_ADDRESS_MAP[tokenA.chainId]) != null ? _FACTORY_ADDRESS_MAP$ : FACTORY_ADDRESS;

@@ -271,7 +236,4 @@ return computePairAddress({

* @param token to check
*/
;
*/;
var _proto = Pair.prototype;
_proto.involvesToken = function involvesToken(token) {

@@ -282,5 +244,3 @@ return token.equals(this.token0) || token.equals(this.token1);

* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
*/
;
*/;
/**

@@ -296,5 +256,3 @@ * Return the price of the given token in terms of the other token in the pair.

* Returns the chain ID of the tokens in the pair.
*/
;
*/;
_proto.reserveOf = function reserveOf(token) {

@@ -363,5 +321,3 @@ !this.involvesToken(token) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;

* @param calculateFotFees
*/
;
*/;
_proto.getOutputAmount = function getOutputAmount(inputAmount, calculateFotFees) {

@@ -371,9 +327,6 @@ if (calculateFotFees === void 0) {

}
!this.involvesToken(inputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
if (JSBI.equal(this.reserve0.quotient, ZERO) || JSBI.equal(this.reserve1.quotient, ZERO)) {
throw new InsufficientReservesError();
}
var inputReserve = this.reserveOf(inputAmount.currency);

@@ -389,15 +342,11 @@ var outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);

);
if (JSBI.equal(outputAmount.quotient, ZERO)) {
throw new InsufficientInputAmountError();
}
var percentAfterBuyFees = calculateFotFees ? this.derivePercentAfterBuyFees(outputAmount) : ZERO_PERCENT;
var outputAmountAfterTax = percentAfterBuyFees.greaterThan(ZERO_PERCENT) ? CurrencyAmount.fromRawAmount(outputAmount.currency, outputAmount.multiply(percentAfterBuyFees).quotient // fraction.quotient will round down by itself, which is desired
) : outputAmount;
if (JSBI.equal(outputAmountAfterTax.quotient, ZERO)) {
throw new InsufficientInputAmountError();
}
return [outputAmountAfterTax, new Pair(inputReserve.add(inputAmountAfterTax), outputReserve.subtract(outputAmountAfterTax))];

@@ -446,5 +395,3 @@ }

* @param outputAmount
*/
;
*/;
_proto.getInputAmount = function getInputAmount(outputAmount, calculateFotFees) {

@@ -454,3 +401,2 @@ if (calculateFotFees === void 0) {

}
!this.involvesToken(outputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;

@@ -460,7 +406,5 @@ var percentAfterBuyFees = calculateFotFees ? this.derivePercentAfterBuyFees(outputAmount) : ZERO_PERCENT;

) : outputAmount;
if (JSBI.equal(this.reserve0.quotient, ZERO) || JSBI.equal(this.reserve1.quotient, ZERO) || JSBI.greaterThanOrEqual(outputAmount.quotient, this.reserveOf(outputAmount.currency).quotient) || JSBI.greaterThanOrEqual(outputAmountBeforeTax.quotient, this.reserveOf(outputAmount.currency).quotient)) {
throw new InsufficientReservesError();
}
var outputReserve = this.reserveOf(outputAmount.currency);

@@ -477,3 +421,2 @@ var inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);

};
_proto.getLiquidityMinted = function getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {

@@ -485,3 +428,2 @@ !totalSupply.currency.equals(this.liquidityToken) ? process.env.NODE_ENV !== "production" ? invariant(false, 'LIQUIDITY') : invariant(false) : void 0;

var liquidity;
if (JSBI.equal(totalSupply.quotient, ZERO)) {

@@ -494,10 +436,7 @@ liquidity = JSBI.subtract(sqrt(JSBI.multiply(tokenAmounts[0].quotient, tokenAmounts[1].quotient)), MINIMUM_LIQUIDITY);

}
if (!JSBI.greaterThan(liquidity, ZERO)) {
throw new InsufficientInputAmountError();
}
return CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity);
};
_proto.getLiquidityValue = function getLiquidityValue(token, totalSupply, liquidity, feeOn, kLast) {

@@ -507,3 +446,2 @@ if (feeOn === void 0) {

}
!this.involvesToken(token) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;

@@ -514,3 +452,2 @@ !totalSupply.currency.equals(this.liquidityToken) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOTAL_SUPPLY') : invariant(false) : void 0;

var totalSupplyAdjusted;
if (!feeOn) {

@@ -521,7 +458,5 @@ totalSupplyAdjusted = totalSupply;

var kLastParsed = JSBI.BigInt(kLast);
if (!JSBI.equal(kLastParsed, ZERO)) {
var rootK = sqrt(JSBI.multiply(this.reserve0.quotient, this.reserve1.quotient));
var rootKLast = sqrt(kLastParsed);
if (JSBI.greaterThan(rootK, rootKLast)) {

@@ -539,9 +474,6 @@ var numerator = JSBI.multiply(totalSupply.quotient, JSBI.subtract(rootK, rootKLast));

}
return CurrencyAmount.fromRawAmount(token, JSBI.divide(JSBI.multiply(liquidity.quotient, this.reserveOf(token).quotient), totalSupplyAdjusted.quotient));
};
_proto.derivePercentAfterSellFees = function derivePercentAfterSellFees(inputAmount) {
var sellFeeBips = this.token0.wrapped.equals(inputAmount.wrapped.currency) ? this.token0.wrapped.sellFeeBps : this.token1.wrapped.sellFeeBps;
if (sellFeeBips != null && sellFeeBips.gt(BigNumber.from(0))) {

@@ -553,6 +485,4 @@ return ONE_HUNDRED_PERCENT.subtract(new Percent(JSBI.BigInt(sellFeeBips)).divide(BASIS_POINTS));

};
_proto.derivePercentAfterBuyFees = function derivePercentAfterBuyFees(outputAmount) {
var buyFeeBps = this.token0.wrapped.equals(outputAmount.wrapped.currency) ? this.token0.wrapped.buyFeeBps : this.token1.wrapped.buyFeeBps;
if (buyFeeBps != null && buyFeeBps.gt(BigNumber.from(0))) {

@@ -564,3 +494,2 @@ return ONE_HUNDRED_PERCENT.subtract(new Percent(JSBI.BigInt(buyFeeBps)).divide(BASIS_POINTS));

};
_createClass(Pair, [{

@@ -575,3 +504,2 @@ key: "token0Price",

*/
}, {

@@ -609,3 +537,2 @@ key: "token1Price",

}]);
return Pair;

@@ -626,15 +553,11 @@ }();

var path = [wrappedInput];
for (var _iterator = _createForOfIteratorHelperLoose(pairs.entries()), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
i = _step$value[0],
pair = _step$value[1];
i = _step$value[0],
pair = _step$value[1];
var currentInput = path[i];
!(currentInput.equals(pair.token0) || currentInput.equals(pair.token1)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'PATH') : invariant(false) : void 0;
var _output = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
path.push(_output);
}
this.pairs = pairs;

@@ -645,3 +568,2 @@ this.path = path;

}
_createClass(Route, [{

@@ -652,10 +574,8 @@ key: "midPrice",

var prices = [];
for (var _iterator2 = _createForOfIteratorHelperLoose(this.pairs.entries()), _step2; !(_step2 = _iterator2()).done;) {
var _step2$value = _step2.value,
i = _step2$value[0],
pair = _step2$value[1];
i = _step2$value[0],
pair = _step2$value[1];
prices.push(this.path[i].equals(pair.token0) ? new Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient));
}
var reduced = prices.slice(1).reduce(function (accumulator, currentValue) {

@@ -672,8 +592,7 @@ return accumulator.multiply(currentValue);

}]);
return Route;
}();
// comparator function that allows sorting trades by their output amounts, in decreasing order, and then input amounts
// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first
function inputOutputComparator(a, b) {

@@ -683,9 +602,7 @@ // must have same input and output token for comparison

!a.outputAmount.currency.equals(b.outputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT_CURRENCY') : invariant(false) : void 0;
if (a.outputAmount.equalTo(b.outputAmount)) {
if (a.inputAmount.equalTo(b.inputAmount)) {
return 0;
} // trade A requires less input than trade B, so A should come first
}
// trade A requires less input than trade B, so A should come first
if (a.inputAmount.lessThan(b.inputAmount)) {

@@ -704,12 +621,10 @@ return -1;

}
} // extension of the input output comparator that also considers other dimensions of the trade in ranking them
}
// extension of the input output comparator that also considers other dimensions of the trade in ranking them
function tradeComparator(a, b) {
var ioComp = inputOutputComparator(a, b);
if (ioComp !== 0) {
return ioComp;
} // consider lowest slippage next, since these are less likely to fail
}
// consider lowest slippage next, since these are less likely to fail
if (a.priceImpact.lessThan(b.priceImpact)) {

@@ -719,5 +634,4 @@ return -1;

return 1;
} // finally consider the number of hops since each hop costs gas
}
// finally consider the number of hops since each hop costs gas
return a.route.path.length - b.route.path.length;

@@ -729,3 +643,2 @@ }

*/
var Trade = /*#__PURE__*/function () {

@@ -736,16 +649,11 @@ function Trade(route, amount, tradeType) {

var tokenAmounts = new Array(route.path.length);
if (tradeType === TradeType.EXACT_INPUT) {
!amount.currency.equals(route.input) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0;
tokenAmounts[0] = amount.wrapped;
for (var i = 0; i < route.path.length - 1; i++) {
var pair = route.pairs[i];
var _pair$getOutputAmount = pair.getOutputAmount(tokenAmounts[i]),
outputAmount = _pair$getOutputAmount[0];
outputAmount = _pair$getOutputAmount[0];
tokenAmounts[i + 1] = outputAmount;
}
this.inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);

@@ -756,16 +664,11 @@ this.outputAmount = CurrencyAmount.fromFractionalAmount(route.output, tokenAmounts[tokenAmounts.length - 1].numerator, tokenAmounts[tokenAmounts.length - 1].denominator);

tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
for (var _i = route.path.length - 1; _i > 0; _i--) {
var _pair = route.pairs[_i - 1];
var _pair$getInputAmount = _pair.getInputAmount(tokenAmounts[_i]),
inputAmount = _pair$getInputAmount[0];
inputAmount = _pair$getInputAmount[0];
tokenAmounts[_i - 1] = inputAmount;
}
this.inputAmount = CurrencyAmount.fromFractionalAmount(route.input, tokenAmounts[0].numerator, tokenAmounts[0].denominator);
this.outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
}
this.executionPrice = new Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);

@@ -779,4 +682,2 @@ this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);

*/
Trade.exactIn = function exactIn(route, amountIn) {

@@ -789,5 +690,3 @@ return new Trade(route, amountIn, TradeType.EXACT_INPUT);

* @param amountOut the amount returned by the trade
*/
;
*/;
Trade.exactOut = function exactOut(route, amountOut) {

@@ -799,10 +698,6 @@ return new Trade(route, amountOut, TradeType.EXACT_OUTPUT);

* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
*/
;
*/;
var _proto = Trade.prototype;
_proto.minimumAmountOut = function minimumAmountOut(slippageTolerance) {
!!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
if (this.tradeType === TradeType.EXACT_OUTPUT) {

@@ -818,8 +713,5 @@ return this.outputAmount;

* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
*/
;
*/;
_proto.maximumAmountIn = function maximumAmountIn(slippageTolerance) {
!!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
if (this.tradeType === TradeType.EXACT_INPUT) {

@@ -845,25 +737,20 @@ return this.inputAmount;

* @param bestTrades used in recursion; the current list of best trades
*/
;
Trade.bestTradeExactIn = function bestTradeExactIn(pairs, currencyAmountIn, currencyOut, _temp, // used in recursion.
*/;
Trade.bestTradeExactIn = function bestTradeExactIn(pairs, currencyAmountIn, currencyOut, _temp,
// used in recursion.
currentPairs, nextAmountIn, bestTrades) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$maxNumResults = _ref.maxNumResults,
maxNumResults = _ref$maxNumResults === void 0 ? 3 : _ref$maxNumResults,
_ref$maxHops = _ref.maxHops,
maxHops = _ref$maxHops === void 0 ? 3 : _ref$maxHops;
_ref$maxNumResults = _ref.maxNumResults,
maxNumResults = _ref$maxNumResults === void 0 ? 3 : _ref$maxNumResults,
_ref$maxHops = _ref.maxHops,
maxHops = _ref$maxHops === void 0 ? 3 : _ref$maxHops;
if (currentPairs === void 0) {
currentPairs = [];
}
if (nextAmountIn === void 0) {
nextAmountIn = currencyAmountIn;
}
if (bestTrades === void 0) {
bestTrades = [];
}
!(pairs.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'PAIRS') : invariant(false) : void 0;

@@ -874,15 +761,11 @@ !(maxHops > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MAX_HOPS') : invariant(false) : void 0;

var tokenOut = currencyOut.wrapped;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i]; // pair irrelevant
var pair = pairs[i];
// pair irrelevant
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;
var amountOut = void 0;
try {
;
var _pair$getOutputAmount2 = pair.getOutputAmount(amountIn);
amountOut = _pair$getOutputAmount2[0];

@@ -894,12 +777,10 @@ } catch (error) {

}
throw error;
} // we have arrived at the output token, so this is the final trade of one of the paths
}
// we have arrived at the output token, so this is the final trade of one of the paths
if (amountOut.currency.equals(tokenOut)) {
sortedInsert(bestTrades, new Trade(new Route([].concat(currentPairs, [pair]), currencyAmountIn.currency, currencyOut), currencyAmountIn, TradeType.EXACT_INPUT), maxNumResults, tradeComparator);
} else if (maxHops > 1 && pairs.length > 1) {
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)); // otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
// otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops
Trade.bestTradeExactIn(pairsExcludingThisPair, currencyAmountIn, currencyOut, {

@@ -911,3 +792,2 @@ maxNumResults: maxNumResults,

}
return bestTrades;

@@ -918,5 +798,3 @@ }

* @param slippageTolerance the allowed tolerated slippage
*/
;
*/;
_proto.worstExecutionPrice = function worstExecutionPrice(slippageTolerance) {

@@ -939,25 +817,20 @@ return new Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);

* @param bestTrades used in recursion; the current list of best trades
*/
;
Trade.bestTradeExactOut = function bestTradeExactOut(pairs, currencyIn, currencyAmountOut, _temp2, // used in recursion.
*/;
Trade.bestTradeExactOut = function bestTradeExactOut(pairs, currencyIn, currencyAmountOut, _temp2,
// used in recursion.
currentPairs, nextAmountOut, bestTrades) {
var _ref2 = _temp2 === void 0 ? {} : _temp2,
_ref2$maxNumResults = _ref2.maxNumResults,
maxNumResults = _ref2$maxNumResults === void 0 ? 3 : _ref2$maxNumResults,
_ref2$maxHops = _ref2.maxHops,
maxHops = _ref2$maxHops === void 0 ? 3 : _ref2$maxHops;
_ref2$maxNumResults = _ref2.maxNumResults,
maxNumResults = _ref2$maxNumResults === void 0 ? 3 : _ref2$maxNumResults,
_ref2$maxHops = _ref2.maxHops,
maxHops = _ref2$maxHops === void 0 ? 3 : _ref2$maxHops;
if (currentPairs === void 0) {
currentPairs = [];
}
if (nextAmountOut === void 0) {
nextAmountOut = currencyAmountOut;
}
if (bestTrades === void 0) {
bestTrades = [];
}
!(pairs.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'PAIRS') : invariant(false) : void 0;

@@ -968,15 +841,11 @@ !(maxHops > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MAX_HOPS') : invariant(false) : void 0;

var tokenIn = currencyIn.wrapped;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i]; // pair irrelevant
var pair = pairs[i];
// pair irrelevant
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;
var amountIn = void 0;
try {
;
var _pair$getInputAmount2 = pair.getInputAmount(amountOut);
amountIn = _pair$getInputAmount2[0];

@@ -988,12 +857,10 @@ } catch (error) {

}
throw error;
} // we have arrived at the input token, so this is the first trade of one of the paths
}
// we have arrived at the input token, so this is the first trade of one of the paths
if (amountIn.currency.equals(tokenIn)) {
sortedInsert(bestTrades, new Trade(new Route([pair].concat(currentPairs), currencyIn, currencyAmountOut.currency), currencyAmountOut, TradeType.EXACT_OUTPUT), maxNumResults, tradeComparator);
} else if (maxHops > 1 && pairs.length > 1) {
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)); // otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops
var pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
// otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops
Trade.bestTradeExactOut(pairsExcludingThisPair, currencyIn, currencyAmountOut, {

@@ -1005,6 +872,4 @@ maxNumResults: maxNumResults,

}
return bestTrades;
};
return Trade;

@@ -1016,3 +881,2 @@ }();

}
var ZERO_HEX = '0x0';

@@ -1022,3 +886,2 @@ /**

*/
var Router = /*#__PURE__*/function () {

@@ -1034,8 +897,6 @@ /**

*/
Router.swapCallParameters = function swapCallParameters(trade, options) {
var etherIn = trade.inputAmount.currency.isNative;
var etherOut = trade.outputAmount.currency.isNative; // the router does not support both ether in and out
var etherOut = trade.outputAmount.currency.isNative;
// 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;

@@ -1054,47 +915,41 @@ !(!('ttl' in options) || options.ttl > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TTL') : invariant(false) : void 0;

var value;
switch (trade.tradeType) {
case TradeType.EXACT_INPUT:
if (etherIn) {
methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens'; // (uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens';
// (uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountOut, path, to, deadline];
value = amountIn;
} else if (etherOut) {
methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH'; // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH';
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountIn, amountOut, path, to, deadline];
value = ZERO_HEX;
} else {
methodName = useFeeOnTransfer ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' : 'swapExactTokensForTokens'; // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
methodName = useFeeOnTransfer ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' : 'swapExactTokensForTokens';
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
args = [amountIn, amountOut, path, to, deadline];
value = ZERO_HEX;
}
break;
case TradeType.EXACT_OUTPUT:
!!useFeeOnTransfer ? process.env.NODE_ENV !== "production" ? invariant(false, 'EXACT_OUT_FOT') : invariant(false) : void 0;
if (etherIn) {
methodName = 'swapETHForExactTokens'; // (uint amountOut, address[] calldata path, address to, uint deadline)
methodName = 'swapETHForExactTokens';
// (uint amountOut, address[] calldata path, address to, uint deadline)
args = [amountOut, path, to, deadline];
value = amountIn;
} else if (etherOut) {
methodName = 'swapTokensForExactETH'; // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
methodName = 'swapTokensForExactETH';
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
args = [amountOut, amountIn, path, to, deadline];
value = ZERO_HEX;
} else {
methodName = 'swapTokensForExactTokens'; // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
methodName = 'swapTokensForExactTokens';
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
args = [amountOut, amountIn, path, to, deadline];
value = ZERO_HEX;
}
break;
}
return {

@@ -1106,3 +961,2 @@ methodName: methodName,

};
return Router;

@@ -1109,0 +963,0 @@ }();

{
"name": "@uniswap/v2-sdk",
"description": "🛠 An SDK for building applications on top of Uniswap V2",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
"uniswap",
"ethereum"
],
"license": "MIT",
"version": "4.3.0",
"description": "🛠 An SDK for building applications on top of Uniswap V2",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"module": "dist/v2-sdk.esm.js",
"files": [
"dist"
],
"repository": "https://github.com/Uniswap/uniswap-v2-sdk.git",
"keywords": [
"uniswap",
"ethereum"
],
"module": "dist/v2-sdk.esm.js",
"engines": {
"node": ">=10"
},
"scripts": {
"lint": "tsdx lint src test",
"build": "tsdx build",
"lint": "tsdx lint src",
"release": "semantic-release",
"start": "tsdx watch",
"test": "tsdx test",
"prepublishOnly": "tsdx build"
"test": "tsdx test"
},
"dependencies": {
"@ethersproject/address": "^5.0.0",
"@ethersproject/solidity": "^5.0.0",
"@ethersproject/address": "^5.0.2",
"@ethersproject/solidity": "^5.0.9",
"@uniswap/sdk-core": "^4.2.0",

@@ -35,7 +37,5 @@ "tiny-invariant": "^1.1.0",

"@uniswap/v2-core": "^1.0.1",
"eslint-config-react-app": "7.0.1",
"tsdx": "^0.14.1"
},
"engines": {
"node": ">=10"
},
"prettier": {

@@ -45,3 +45,40 @@ "printWidth": 120,

"singleQuote": true
}
},
"publishConfig": {
"access": "public"
},
"release": {
"extends": "semantic-release-monorepo",
"branches": [
{
"name": "main",
"prerelease": false
},
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": "../../publishing/release-rules.cjs"
}
],
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/exec",
{
"successCmd": "git restore yarn.lock && yarn",
"failCmd": "git restore yarn.lock && yarn",
"execCwd": "../.."
}
]
]
},
"version": "4.3.1-beta.1"
}
# Uniswap V2 SDK
[![Unit Tests](https://github.com/Uniswap/uniswap-v2-sdk/workflows/Unit%20Tests/badge.svg)](https://github.com/Uniswap/uniswap-v2-sdk/actions?query=workflow%3A%22Unit+Tests%22)
[![Lint](https://github.com/Uniswap/uniswap-v2-sdk/workflows/Lint/badge.svg)](https://github.com/Uniswap/uniswap-v2-sdk/actions?query=workflow%3ALint)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![npm version](https://img.shields.io/npm/v/@uniswap/v2-sdk/latest.svg)](https://www.npmjs.com/package/@uniswap/v2-sdk/v/latest)

@@ -7,0 +4,0 @@ [![npm bundle size (scoped version)](https://img.shields.io/bundlephobia/minzip/@uniswap/v2-sdk/latest.svg)](https://bundlephobia.com/result?p=@uniswap/v2-sdk@latest)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc