Socket
Socket
Sign inDemoInstall

@uniswap/v2-sdk

Package Overview
Dependencies
Maintainers
8
Versions
36
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 3.0.0-alpha.0 to 3.0.0-alpha.1

4

dist/entities/pair.d.ts

@@ -1,2 +0,2 @@

import { BigintIsh, ChainId, Price, Token, CurrencyAmount } from '@uniswap/sdk-core';
import { BigintIsh, Price, Token, CurrencyAmount } from '@uniswap/sdk-core';
export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB }: {

@@ -33,3 +33,3 @@ factoryAddress: string;

*/
get chainId(): ChainId | number;
get chainId(): number;
get token0(): Token;

@@ -36,0 +36,0 @@ get token1(): Token;

@@ -1,2 +0,2 @@

import { ChainId, Currency, Price, Token } from '@uniswap/sdk-core';
import { Currency, Price, Token } from '@uniswap/sdk-core';
import { Pair } from './pair';

@@ -11,3 +11,3 @@ export declare class Route<TInput extends Currency, TOutput extends Currency> {

get midPrice(): Price<TInput, TOutput>;
get chainId(): ChainId | number;
get chainId(): number;
}

@@ -12,5 +12,2 @@ 'use strict';

var address = require('@ethersproject/address');
var _Decimal = _interopDefault(require('decimal.js-light'));
var _Big = _interopDefault(require('big.js'));
var toFormat = _interopDefault(require('toformat'));

@@ -436,5 +433,5 @@ var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';

}) ? invariant(false, 'CHAIN_IDS') : void 0;
var wrappedInput = sdkCore.wrappedCurrency(input, chainId);
var wrappedInput = input.wrapped;
!pairs[0].involvesToken(wrappedInput) ? invariant(false, 'INPUT') : void 0;
!(typeof output === 'undefined' || pairs[pairs.length - 1].involvesToken(sdkCore.wrappedCurrency(output, chainId))) ? invariant(false, 'OUTPUT') : void 0;
!(typeof output === 'undefined' || pairs[pairs.length - 1].involvesToken(output.wrapped)) ? invariant(false, 'OUTPUT') : void 0;
var path = [wrappedInput];

@@ -488,350 +485,2 @@

var ChainId;
(function (ChainId) {
ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
ChainId[ChainId["ROPSTEN"] = 3] = "ROPSTEN";
ChainId[ChainId["RINKEBY"] = 4] = "RINKEBY";
ChainId[ChainId["G\xD6RLI"] = 5] = "G\xD6RLI";
ChainId[ChainId["KOVAN"] = 42] = "KOVAN";
})(ChainId || (ChainId = {}));
var TradeType;
(function (TradeType) {
TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT";
TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT";
})(TradeType || (TradeType = {}));
var Rounding;
(function (Rounding) {
Rounding[Rounding["ROUND_DOWN"] = 0] = "ROUND_DOWN";
Rounding[Rounding["ROUND_HALF_UP"] = 1] = "ROUND_HALF_UP";
Rounding[Rounding["ROUND_UP"] = 2] = "ROUND_UP";
})(Rounding || (Rounding = {}));
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose$1(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* A currency is any fungible financial instrument on Ethereum, including Ether and all ERC20 tokens.
*
* The only instance of the base class `Currency` is Ether.
*/
var BaseCurrency =
/**
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`.
* @param decimals decimals of the currency
* @param symbol symbol of the currency
* @param name of the currency
*/
function BaseCurrency(decimals, symbol, name) {
!(decimals >= 0 && decimals < 255 && Number.isInteger(decimals)) ? invariant(false, 'DECIMALS') : void 0;
this.decimals = decimals;
this.symbol = symbol;
this.name = name;
};
var _toSignificantRoundin, _toFixedRounding;
var Decimal = /*#__PURE__*/toFormat(_Decimal);
var Big = /*#__PURE__*/toFormat(_Big);
var toSignificantRounding = (_toSignificantRoundin = {}, _toSignificantRoundin[Rounding.ROUND_DOWN] = Decimal.ROUND_DOWN, _toSignificantRoundin[Rounding.ROUND_HALF_UP] = Decimal.ROUND_HALF_UP, _toSignificantRoundin[Rounding.ROUND_UP] = Decimal.ROUND_UP, _toSignificantRoundin);
var toFixedRounding = (_toFixedRounding = {}, _toFixedRounding[Rounding.ROUND_DOWN] = 0, _toFixedRounding[Rounding.ROUND_HALF_UP] = 1, _toFixedRounding[Rounding.ROUND_UP] = 3, _toFixedRounding);
var Fraction = /*#__PURE__*/function () {
function Fraction(numerator, denominator) {
if (denominator === void 0) {
denominator = JSBI.BigInt(1);
}
this.numerator = JSBI.BigInt(numerator);
this.denominator = JSBI.BigInt(denominator);
}
Fraction.tryParseFraction = function tryParseFraction(fractionish) {
if (fractionish instanceof JSBI || typeof fractionish === 'number' || typeof fractionish === 'string') return new Fraction(fractionish);
if ('numerator' in fractionish && 'denominator' in fractionish) return fractionish;
throw new Error('Could not parse fraction');
} // performs floor division
;
var _proto = Fraction.prototype;
_proto.invert = function invert() {
return new Fraction(this.denominator, this.numerator);
};
_proto.add = function add(other) {
var otherParsed = Fraction.tryParseFraction(other);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.subtract = function subtract(other) {
var otherParsed = Fraction.tryParseFraction(other);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.lessThan = function lessThan(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.equalTo = function equalTo(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.greaterThan = function greaterThan(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.multiply = function multiply(other) {
var otherParsed = Fraction.tryParseFraction(other);
return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.divide = function divide(other) {
var otherParsed = Fraction.tryParseFraction(other);
return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator));
};
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
if (format === void 0) {
format = {
groupSeparator: ''
};
}
if (rounding === void 0) {
rounding = Rounding.ROUND_HALF_UP;
}
!Number.isInteger(significantDigits) ? invariant(false, significantDigits + " is not an integer.") : void 0;
!(significantDigits > 0) ? invariant(false, significantDigits + " is not positive.") : void 0;
Decimal.set({
precision: significantDigits + 1,
rounding: toSignificantRounding[rounding]
});
var quotient = new Decimal(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(significantDigits);
return quotient.toFormat(quotient.decimalPlaces(), format);
};
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
if (format === void 0) {
format = {
groupSeparator: ''
};
}
if (rounding === void 0) {
rounding = Rounding.ROUND_HALF_UP;
}
!Number.isInteger(decimalPlaces) ? invariant(false, decimalPlaces + " is not an integer.") : void 0;
!(decimalPlaces >= 0) ? invariant(false, decimalPlaces + " is negative.") : void 0;
Big.DP = decimalPlaces;
Big.RM = toFixedRounding[rounding];
return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format);
}
/**
* Helper method for converting any super class back to a fraction
*/
;
_createClass$1(Fraction, [{
key: "quotient",
get: function get() {
return JSBI.divide(this.numerator, this.denominator);
} // remainder after floor division
}, {
key: "remainder",
get: function get() {
return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator);
}
}, {
key: "asFraction",
get: function get() {
return new Fraction(this.numerator, this.denominator);
}
}]);
return Fraction;
}();
var ONE_HUNDRED = /*#__PURE__*/new Fraction( /*#__PURE__*/JSBI.BigInt(100));
/**
* Converts a fraction to a percent
* @param fraction the fraction to convert
*/
function toPercent(fraction) {
return new Percent(fraction.numerator, fraction.denominator);
}
var Percent = /*#__PURE__*/function (_Fraction) {
_inheritsLoose$1(Percent, _Fraction);
function Percent() {
var _this;
_this = _Fraction.apply(this, arguments) || this;
/**
* This boolean prevents a fraction from being interpreted as a Percent
*/
_this.isPercent = true;
return _this;
}
var _proto = Percent.prototype;
_proto.add = function add(other) {
return toPercent(_Fraction.prototype.add.call(this, other));
};
_proto.subtract = function subtract(other) {
return toPercent(_Fraction.prototype.subtract.call(this, other));
};
_proto.multiply = function multiply(other) {
return toPercent(_Fraction.prototype.multiply.call(this, other));
};
_proto.divide = function divide(other) {
return toPercent(_Fraction.prototype.divide.call(this, other));
};
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
if (significantDigits === void 0) {
significantDigits = 5;
}
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toSignificant(significantDigits, format, rounding);
};
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
if (decimalPlaces === void 0) {
decimalPlaces = 2;
}
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
};
return Percent;
}(Fraction);
/**
* Validates an address and returns the parsed (checksummed) version of that address
* @param address the unchecksummed hex address
*/
function validateAndParseAddress(address$1) {
try {
return address.getAddress(address$1);
} catch (error) {
throw new Error(address$1 + " is not a valid address.");
}
}
var _WETH;
/**
* Represents an ERC20 token with a unique address and some metadata.
*/
var Token = /*#__PURE__*/function (_BaseCurrency) {
_inheritsLoose$1(Token, _BaseCurrency);
function Token(chainId, address, decimals, symbol, name) {
var _this;
_this = _BaseCurrency.call(this, decimals, symbol, name) || this;
_this.isEther = false;
_this.isToken = true;
_this.chainId = chainId;
_this.address = validateAndParseAddress(address);
return _this;
}
/**
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
* @param other other token to compare
*/
var _proto = Token.prototype;
_proto.equals = function equals(other) {
// short circuit on reference equality
if (this === other) {
return true;
}
return this.chainId === other.chainId && this.address === other.address;
}
/**
* Returns true if the address of this token sorts before the address of the other token
* @param other other token to compare
* @throws if the tokens have the same address
* @throws if the tokens are on different chains
*/
;
_proto.sortsBefore = function sortsBefore(other) {
!(this.chainId === other.chainId) ? invariant(false, 'CHAIN_IDS') : void 0;
!(this.address !== other.address) ? invariant(false, 'ADDRESSES') : void 0;
return this.address.toLowerCase() < other.address.toLowerCase();
};
return Token;
}(BaseCurrency);
var WETH9 = (_WETH = {}, _WETH[ChainId.MAINNET] = /*#__PURE__*/new Token(ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.ROPSTEN] = /*#__PURE__*/new Token(ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.RINKEBY] = /*#__PURE__*/new Token(ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.GÖRLI] = /*#__PURE__*/new Token(ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.KOVAN] = /*#__PURE__*/new Token(ChainId.KOVAN, '0xd0A1E359811322d97991E03f863a0C30C2cF029C', 18, 'WETH9', 'Wrapped Ether'), _WETH);
/**
* Returns the percent difference between the mid price and the execution price, i.e. price impact.
* @param midPrice mid price before the trade
* @param inputAmount the input amount of the trade
* @param outputAmount the output amount of the trade
*/
function computePriceImpact(midPrice, inputAmount, outputAmount) {
var quotedOutputAmount = midPrice.quote(inputAmount); // calculate price impact := (exactQuote - outputAmount) / exactQuote
var priceImpact = quotedOutputAmount.subtract(outputAmount).divide(quotedOutputAmount);
return new Percent(priceImpact.numerator, priceImpact.denominator);
} // `maxSize` by removing the last item
// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first

@@ -841,4 +490,4 @@

// must have same input and output token for comparison
!sdkCore.currencyEquals(a.inputAmount.currency, b.inputAmount.currency) ? invariant(false, 'INPUT_CURRENCY') : void 0;
!sdkCore.currencyEquals(a.outputAmount.currency, b.outputAmount.currency) ? invariant(false, 'OUTPUT_CURRENCY') : void 0;
!a.inputAmount.currency.equals(b.inputAmount.currency) ? invariant(false, 'INPUT_CURRENCY') : void 0;
!a.outputAmount.currency.equals(b.outputAmount.currency) ? invariant(false, 'OUTPUT_CURRENCY') : void 0;

@@ -895,4 +544,4 @@ if (a.outputAmount.equalTo(b.outputAmount)) {

if (tradeType === sdkCore.TradeType.EXACT_INPUT) {
!sdkCore.currencyEquals(amount.currency, route.input) ? invariant(false, 'INPUT') : void 0;
tokenAmounts[0] = sdkCore.wrappedCurrencyAmount(amount, route.chainId);
!amount.currency.equals(route.input) ? invariant(false, 'INPUT') : void 0;
tokenAmounts[0] = amount.wrapped;

@@ -911,4 +560,4 @@ for (var i = 0; i < route.path.length - 1; i++) {

} else {
!sdkCore.currencyEquals(amount.currency, route.output) ? invariant(false, 'OUTPUT') : void 0;
tokenAmounts[tokenAmounts.length - 1] = sdkCore.wrappedCurrencyAmount(amount, route.chainId);
!amount.currency.equals(route.output) ? invariant(false, 'OUTPUT') : void 0;
tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;

@@ -929,3 +578,3 @@ for (var _i = route.path.length - 1; _i > 0; _i--) {

this.executionPrice = new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);
this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
this.priceImpact = sdkCore.computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
}

@@ -1025,6 +674,4 @@ /**

!(currencyAmountIn === nextAmountIn || currentPairs.length > 0) ? invariant(false, 'INVALID_RECURSION') : void 0;
var chainId = nextAmountIn.currency.isToken ? nextAmountIn.currency.chainId : currencyOut.isToken ? currencyOut.chainId : undefined;
!(chainId !== undefined) ? invariant(false, 'CHAIN_ID') : void 0;
var amountIn = sdkCore.wrappedCurrencyAmount(nextAmountIn, chainId);
var tokenOut = sdkCore.wrappedCurrency(currencyOut, chainId);
var amountIn = nextAmountIn.wrapped;
var tokenOut = currencyOut.wrapped;

@@ -1034,3 +681,3 @@ for (var i = 0; i < pairs.length; i++) {

if (!sdkCore.currencyEquals(pair.token0, amountIn.currency) && !sdkCore.currencyEquals(pair.token1, amountIn.currency)) continue;
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;

@@ -1055,3 +702,3 @@ var amountOut = void 0;

if (sdkCore.currencyEquals(amountOut.currency, tokenOut)) {
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);

@@ -1119,6 +766,4 @@ } else if (maxHops > 1 && pairs.length > 1) {

!(currencyAmountOut === nextAmountOut || currentPairs.length > 0) ? invariant(false, 'INVALID_RECURSION') : void 0;
var chainId = nextAmountOut.currency.isToken ? nextAmountOut.currency.chainId : currencyIn.isToken ? currencyIn.chainId : undefined;
!(chainId !== undefined) ? invariant(false, 'CHAIN_ID') : void 0;
var amountOut = sdkCore.wrappedCurrencyAmount(nextAmountOut, chainId);
var tokenIn = sdkCore.wrappedCurrency(currencyIn, chainId);
var amountOut = nextAmountOut.wrapped;
var tokenIn = currencyIn.wrapped;

@@ -1128,3 +773,3 @@ for (var i = 0; i < pairs.length; i++) {

if (!sdkCore.currencyEquals(pair.token0, amountOut.currency) && !sdkCore.currencyEquals(pair.token1, amountOut.currency)) continue;
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;

@@ -1149,3 +794,3 @@ var amountIn = void 0;

if (sdkCore.currencyEquals(amountIn.currency, tokenIn)) {
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);

@@ -1190,4 +835,4 @@ } else if (maxHops > 1 && pairs.length > 1) {

Router.swapCallParameters = function swapCallParameters(trade, options) {
var etherIn = trade.inputAmount.currency.isEther;
var etherOut = trade.outputAmount.currency.isEther; // the router does not support both ether in and out
var etherIn = trade.inputAmount.currency.isNative;
var etherOut = trade.outputAmount.currency.isNative; // the router does not support both ether in and out

@@ -1194,0 +839,0 @@ !!(etherIn && etherOut) ? invariant(false, 'ETHER_IN_OUT') : void 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=t(require("jsbi")),r=require("@uniswap/sdk-core"),n=t(require("tiny-invariant")),o=require("@ethersproject/solidity"),i=require("@ethersproject/address"),u=t(require("decimal.js-light")),a=t(require("big.js")),s=t(require("toformat")),c="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",p=e.BigInt(1e3),l=e.BigInt(0),d=e.BigInt(1),m=e.BigInt(5),h=e.BigInt(997),f=e.BigInt(1e3);function y(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 v(t,e,r){return e&&y(t.prototype,e),r&&y(t,r),t}function T(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function A(t){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function q(t,e){return(q=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 k(t,e,r){return(k=g()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&q(o,r.prototype),o}).apply(null,arguments)}function w(t){var e="function"==typeof Map?new Map:void 0;return(w=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 k(t,arguments,A(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,t)})(t)}function E(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function I(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 O(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 I(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)?I(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 b,P,x,_="setPrototypeOf"in Object,N=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,_&&Object.setPrototypeOf(E(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(w(Error)),R=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,_&&Object.setPrototypeOf(E(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(w(Error)),C=function(t){var e=t.factoryAddress,r=t.tokenA,n=t.tokenB,u=r.sortsBefore(n)?[r,n]:[n,r];return i.getCreate2Address(e,o.keccak256(["bytes"],[o.pack(["address","address"],[u[0].address,u[1].address])]),c)},U=function(){function t(e,n){var o=e.currency.sortsBefore(n.currency)?[e,n]:[n,e];this.liquidityToken=new r.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){return C({factoryAddress:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",tokenA:t,tokenB:e})};var o=t.prototype;return o.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},o.priceOf=function(t){return this.involvesToken(t)||n(!1),t.equals(this.token0)?this.token0Price:this.token1Price},o.reserveOf=function(t){return this.involvesToken(t)||n(!1),t.equals(this.token0)?this.reserve0:this.reserve1},o.getOutputAmount=function(o){if(this.involvesToken(o.currency)||n(!1),e.equal(this.reserve0.quotient,l)||e.equal(this.reserve1.quotient,l))throw new N;var i=this.reserveOf(o.currency),u=this.reserveOf(o.currency.equals(this.token0)?this.token1:this.token0),a=e.multiply(o.quotient,h),s=e.multiply(a,u.quotient),c=e.add(e.multiply(i.quotient,f),a),p=r.CurrencyAmount.fromRawAmount(o.currency.equals(this.token0)?this.token1:this.token0,e.divide(s,c));if(e.equal(p.quotient,l))throw new R;return[p,new t(i.add(o),u.subtract(p))]},o.getInputAmount=function(o){if(this.involvesToken(o.currency)||n(!1),e.equal(this.reserve0.quotient,l)||e.equal(this.reserve1.quotient,l)||e.greaterThanOrEqual(o.quotient,this.reserveOf(o.currency).quotient))throw new N;var i=this.reserveOf(o.currency),u=this.reserveOf(o.currency.equals(this.token0)?this.token1:this.token0),a=e.multiply(e.multiply(u.quotient,o.quotient),f),s=e.multiply(e.subtract(i.quotient,o.quotient),h),c=r.CurrencyAmount.fromRawAmount(o.currency.equals(this.token0)?this.token1:this.token0,e.add(e.divide(a,s),d));return[c,new t(u.add(c),i.subtract(o))]},o.getLiquidityMinted=function(t,o,i){t.currency.equals(this.liquidityToken)||n(!1);var u,a=o.currency.sortsBefore(i.currency)?[o,i]:[i,o];if(a[0].currency.equals(this.token0)&&a[1].currency.equals(this.token1)||n(!1),e.equal(t.quotient,l))u=e.subtract(r.sqrt(e.multiply(a[0].quotient,a[1].quotient)),p);else{var s=e.divide(e.multiply(a[0].quotient,t.quotient),this.reserve0.quotient),c=e.divide(e.multiply(a[1].quotient,t.quotient),this.reserve1.quotient);u=e.lessThanOrEqual(s,c)?s:c}if(!e.greaterThan(u,l))throw new R;return r.CurrencyAmount.fromRawAmount(this.liquidityToken,u)},o.getLiquidityValue=function(t,o,i,u,a){var s;if(void 0===u&&(u=!1),this.involvesToken(t)||n(!1),o.currency.equals(this.liquidityToken)||n(!1),i.currency.equals(this.liquidityToken)||n(!1),e.lessThanOrEqual(i.quotient,o.quotient)||n(!1),u){a||n(!1);var c=e.BigInt(a);if(e.equal(c,l))s=o;else{var p=r.sqrt(e.multiply(this.reserve0.quotient,this.reserve1.quotient)),d=r.sqrt(c);if(e.greaterThan(p,d)){var h=e.multiply(o.quotient,e.subtract(p,d)),f=e.add(e.multiply(p,m),d),y=e.divide(h,f);s=o.add(r.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else s=o}}else s=o;return r.CurrencyAmount.fromRawAmount(t,e.divide(e.multiply(i.quotient,this.reserveOf(t).quotient),s.quotient))},v(t,[{key:"token0Price",get:function(){var t=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new r.Price(this.token0,this.token1,t.denominator,t.numerator)}},{key:"token1Price",get:function(){var t=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new r.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}(),F=function(){function t(t,e,o){this._midPrice=null,t.length>0||n(!1);var i=t[0].chainId;t.every((function(t){return t.chainId===i}))||n(!1);var u=r.wrappedCurrency(e,i);t[0].involvesToken(u)||n(!1),void 0===o||t[t.length-1].involvesToken(r.wrappedCurrency(o,i))||n(!1);for(var a,s=[u],c=O(t.entries());!(a=c()).done;){var p=a.value,l=p[1],d=s[p[0]];d.equals(l.token0)||d.equals(l.token1)||n(!1);var m=d.equals(l.token0)?l.token1:l.token0;s.push(m)}this.pairs=t,this.path=s,this.input=e,this.output=o}return v(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,e=[],n=O(this.pairs.entries());!(t=n()).done;){var o=t.value,i=o[1];e.push(this.path[o[0]].equals(i.token0)?new r.Price(i.reserve0.currency,i.reserve1.currency,i.reserve0.quotient,i.reserve1.quotient):new r.Price(i.reserve1.currency,i.reserve0.currency,i.reserve1.quotient,i.reserve0.quotient))}var u=e.slice(1).reduce((function(t,e){return t.multiply(e)}),e[0]);return this._midPrice=new r.Price(this.input,this.output,u.denominator,u.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}();function D(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}!function(t){t[t.MAINNET=1]="MAINNET",t[t.ROPSTEN=3]="ROPSTEN",t[t.RINKEBY=4]="RINKEBY",t[t["GÖRLI"]=5]="GÖRLI",t[t.KOVAN=42]="KOVAN"}(b||(b={})),function(t){t[t.EXACT_INPUT=0]="EXACT_INPUT",t[t.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(P||(P={})),function(t){t[t.ROUND_DOWN=0]="ROUND_DOWN",t[t.ROUND_HALF_UP=1]="ROUND_HALF_UP",t[t.ROUND_UP=2]="ROUND_UP"}(x||(x={}));var S,B,H=function(t,e,r){t>=0&&t<255&&Number.isInteger(t)||n(!1),this.decimals=t,this.symbol=e,this.name=r},j=s(u),L=s(a),W=((S={})[x.ROUND_DOWN]=j.ROUND_DOWN,S[x.ROUND_HALF_UP]=j.ROUND_HALF_UP,S[x.ROUND_UP]=j.ROUND_UP,S),M=((B={})[x.ROUND_DOWN]=0,B[x.ROUND_HALF_UP]=1,B[x.ROUND_UP]=3,B),X=function(){function t(t,r){void 0===r&&(r=e.BigInt(1)),this.numerator=e.BigInt(t),this.denominator=e.BigInt(r)}t.tryParseFraction=function(r){if(r instanceof e||"number"==typeof r||"string"==typeof r)return new t(r);if("numerator"in r&&"denominator"in r)return r;throw new Error("Could not parse fraction")};var r,o=t.prototype;return o.invert=function(){return new t(this.denominator,this.numerator)},o.add=function(r){var n=t.tryParseFraction(r);return e.equal(this.denominator,n.denominator)?new t(e.add(this.numerator,n.numerator),this.denominator):new t(e.add(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator)),e.multiply(this.denominator,n.denominator))},o.subtract=function(r){var n=t.tryParseFraction(r);return e.equal(this.denominator,n.denominator)?new t(e.subtract(this.numerator,n.numerator),this.denominator):new t(e.subtract(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator)),e.multiply(this.denominator,n.denominator))},o.lessThan=function(r){var n=t.tryParseFraction(r);return e.lessThan(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},o.equalTo=function(r){var n=t.tryParseFraction(r);return e.equal(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},o.greaterThan=function(r){var n=t.tryParseFraction(r);return e.greaterThan(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},o.multiply=function(r){var n=t.tryParseFraction(r);return new t(e.multiply(this.numerator,n.numerator),e.multiply(this.denominator,n.denominator))},o.divide=function(r){var n=t.tryParseFraction(r);return new t(e.multiply(this.numerator,n.denominator),e.multiply(this.denominator,n.numerator))},o.toSignificant=function(t,e,r){void 0===e&&(e={groupSeparator:""}),void 0===r&&(r=x.ROUND_HALF_UP),Number.isInteger(t)||n(!1),t>0||n(!1),j.set({precision:t+1,rounding:W[r]});var o=new j(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return o.toFormat(o.decimalPlaces(),e)},o.toFixed=function(t,e,r){return void 0===e&&(e={groupSeparator:""}),void 0===r&&(r=x.ROUND_HALF_UP),Number.isInteger(t)||n(!1),t>=0||n(!1),L.DP=t,L.RM=M[r],new L(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},(r=[{key:"quotient",get:function(){return e.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(e.remainder(this.numerator,this.denominator),this.denominator)}},{key:"asFraction",get:function(){return new t(this.numerator,this.denominator)}}])&&function(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)}}(t.prototype,r),t}(),K=new X(e.BigInt(100));function V(t){return new G(t.numerator,t.denominator)}var Y,G=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).isPercent=!0,e}D(e,t);var r=e.prototype;return r.add=function(e){return V(t.prototype.add.call(this,e))},r.subtract=function(e){return V(t.prototype.subtract.call(this,e))},r.multiply=function(e){return V(t.prototype.multiply.call(this,e))},r.divide=function(e){return V(t.prototype.divide.call(this,e))},r.toSignificant=function(e,r,n){return void 0===e&&(e=5),t.prototype.multiply.call(this,K).toSignificant(e,r,n)},r.toFixed=function(e,r,n){return void 0===e&&(e=2),t.prototype.multiply.call(this,K).toFixed(e,r,n)},e}(X);function Q(t){try{return i.getAddress(t)}catch(e){throw new Error(t+" is not a valid address.")}}var $=function(t){function e(e,r,n,o,i){var u;return(u=t.call(this,n,o,i)||this).isEther=!1,u.isToken=!0,u.chainId=e,u.address=Q(r),u}D(e,t);var r=e.prototype;return r.equals=function(t){return this===t||this.chainId===t.chainId&&this.address===t.address},r.sortsBefore=function(t){return this.chainId!==t.chainId&&n(!1),this.address===t.address&&n(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(H);function z(t,e){return r.currencyEquals(t.inputAmount.currency,e.inputAmount.currency)||n(!1),r.currencyEquals(t.outputAmount.currency,e.outputAmount.currency)||n(!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=z(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}(Y={})[b.MAINNET]=new $(b.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH9","Wrapped Ether"),Y[b.ROPSTEN]=new $(b.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),Y[b.RINKEBY]=new $(b.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),Y[b.GÖRLI]=new $(b.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH9","Wrapped Ether"),Y[b.KOVAN]=new $(b.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH9","Wrapped Ether");var Z=function(){function t(t,e,o){this.route=t,this.tradeType=o;var i,u,a,s=new Array(t.path.length);if(o===r.TradeType.EXACT_INPUT){r.currencyEquals(e.currency,t.input)||n(!1),s[0]=r.wrappedCurrencyAmount(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var p=t.pairs[c].getOutputAmount(s[c]);s[c+1]=p[0]}this.inputAmount=r.CurrencyAmount.fromFractionalAmount(t.input,e.numerator,e.denominator),this.outputAmount=r.CurrencyAmount.fromFractionalAmount(t.output,s[s.length-1].numerator,s[s.length-1].denominator)}else{r.currencyEquals(e.currency,t.output)||n(!1),s[s.length-1]=r.wrappedCurrencyAmount(e,t.chainId);for(var l=t.path.length-1;l>0;l--){var d=t.pairs[l-1].getInputAmount(s[l]);s[l-1]=d[0]}this.inputAmount=r.CurrencyAmount.fromFractionalAmount(t.input,s[0].numerator,s[0].denominator),this.outputAmount=r.CurrencyAmount.fromFractionalAmount(t.output,e.numerator,e.denominator)}this.executionPrice=new r.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=(i=this.outputAmount,a=(u=t.midPrice.quote(this.inputAmount)).subtract(i).divide(u),new G(a.numerator,a.denominator))}t.exactIn=function(e,n){return new t(e,n,r.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,r.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(l)&&n(!1),this.tradeType===r.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new r.Fraction(d).add(t).invert().multiply(this.outputAmount.quotient).quotient;return r.CurrencyAmount.fromRawAmount(this.outputAmount.currency,e)},e.maximumAmountIn=function(t){if(t.lessThan(l)&&n(!1),this.tradeType===r.TradeType.EXACT_INPUT)return this.inputAmount;var e=new r.Fraction(d).add(t).multiply(this.inputAmount.quotient).quotient;return r.CurrencyAmount.fromRawAmount(this.inputAmount.currency,e)},t.bestTradeExactIn=function(e,o,i,u,a,s,c){var p=void 0===u?{}:u,d=p.maxNumResults,m=void 0===d?3:d,h=p.maxHops,f=void 0===h?3:h;void 0===a&&(a=[]),void 0===s&&(s=o),void 0===c&&(c=[]),e.length>0||n(!1),f>0||n(!1),o===s||a.length>0||n(!1);var y=s.currency.isToken?s.currency.chainId:i.isToken?i.chainId:void 0;void 0===y&&n(!1);for(var v=r.wrappedCurrencyAmount(s,y),T=r.wrappedCurrency(i,y),A=0;A<e.length;A++){var q=e[A];if((r.currencyEquals(q.token0,v.currency)||r.currencyEquals(q.token1,v.currency))&&!q.reserve0.equalTo(l)&&!q.reserve1.equalTo(l)){var g=void 0;try{g=q.getOutputAmount(v)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(r.currencyEquals(g.currency,T))r.sortedInsert(c,new t(new F([].concat(a,[q]),o.currency,i),o,r.TradeType.EXACT_INPUT),m,J);else if(f>1&&e.length>1){var k=e.slice(0,A).concat(e.slice(A+1,e.length));t.bestTradeExactIn(k,o,i,{maxNumResults:m,maxHops:f-1},[].concat(a,[q]),g,c)}}}return c},e.worstExecutionPrice=function(t){return new r.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactOut=function(e,o,i,u,a,s,c){var p=void 0===u?{}:u,d=p.maxNumResults,m=void 0===d?3:d,h=p.maxHops,f=void 0===h?3:h;void 0===a&&(a=[]),void 0===s&&(s=i),void 0===c&&(c=[]),e.length>0||n(!1),f>0||n(!1),i===s||a.length>0||n(!1);var y=s.currency.isToken?s.currency.chainId:o.isToken?o.chainId:void 0;void 0===y&&n(!1);for(var v=r.wrappedCurrencyAmount(s,y),T=r.wrappedCurrency(o,y),A=0;A<e.length;A++){var q=e[A];if((r.currencyEquals(q.token0,v.currency)||r.currencyEquals(q.token1,v.currency))&&!q.reserve0.equalTo(l)&&!q.reserve1.equalTo(l)){var g=void 0;try{g=q.getInputAmount(v)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(r.currencyEquals(g.currency,T))r.sortedInsert(c,new t(new F([q].concat(a),o,i.currency),i,r.TradeType.EXACT_OUTPUT),m,J);else if(f>1&&e.length>1){var k=e.slice(0,A).concat(e.slice(A+1,e.length));t.bestTradeExactOut(k,o,i,{maxNumResults:m,maxHops:f-1},[q].concat(a),g,c)}}}return c},t}();function tt(t){return"0x"+t.quotient.toString(16)}var et=function(){function t(){}return t.swapCallParameters=function(t,e){var o=t.inputAmount.currency.isEther,i=t.outputAmount.currency.isEther;o&&i&&n(!1),!("ttl"in e)||e.ttl>0||n(!1);var u,a,s,c=r.validateAndParseAddress(e.recipient),p=tt(t.maximumAmountIn(e.allowedSlippage)),l=tt(t.minimumAmountOut(e.allowedSlippage)),d=t.route.path.map((function(t){return t.address})),m="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),h=Boolean(e.feeOnTransfer);switch(t.tradeType){case r.TradeType.EXACT_INPUT:o?(u=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",a=[l,d,c,m],s=p):i?(u=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",a=[p,l,d,c,m],s="0x0"):(u=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",a=[p,l,d,c,m],s="0x0");break;case r.TradeType.EXACT_OUTPUT:h&&n(!1),o?(u="swapETHForExactTokens",a=[l,d,c,m],s=p):i?(u="swapTokensForExactETH",a=[l,p,d,c,m],s="0x0"):(u="swapTokensForExactTokens",a=[l,p,d,c,m],s="0x0")}return{methodName:u,args:a,value:s}},t}();exports.FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",exports.INIT_CODE_HASH=c,exports.InsufficientInputAmountError=R,exports.InsufficientReservesError=N,exports.MINIMUM_LIQUIDITY=p,exports.Pair=U,exports.Route=F,exports.Router=et,exports.Trade=Z,exports.computePairAddress=C,exports.inputOutputComparator=z,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=t(require("jsbi")),n=require("@uniswap/sdk-core"),r=t(require("tiny-invariant")),o=require("@ethersproject/solidity"),u=require("@ethersproject/address"),i="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",s=e.BigInt(1e3),a=e.BigInt(0),c=e.BigInt(1),p=e.BigInt(5),l=e.BigInt(997),f=e.BigInt(1e3);function m(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 h(t,e,n){return e&&m(t.prototype,e),n&&m(t,n),t}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function T(){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 A(t,e,n){return(A=T()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function q(t){var e="function"==typeof Map?new Map:void 0;return(q=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 A(t,arguments,y(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)})(t)}function k(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(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 w(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 g(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)?g(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 I="setPrototypeOf"in Object,x=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,I&&Object.setPrototypeOf(k(n),(this instanceof e?this.constructor:void 0).prototype),n}return d(e,t),e}(q(Error)),b=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,I&&Object.setPrototypeOf(k(n),(this instanceof e?this.constructor:void 0).prototype),n}return d(e,t),e}(q(Error)),O=function(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,s=n.sortsBefore(r)?[n,r]:[r,n];return u.getCreate2Address(e,o.keccak256(["bytes"],[o.pack(["address","address"],[s[0].address,s[1].address])]),i)},E=function(){function t(e,r){var o=e.currency.sortsBefore(r.currency)?[e,r]:[r,e];this.liquidityToken=new n.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){return O({factoryAddress:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",tokenA:t,tokenB:e})};var o=t.prototype;return o.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},o.priceOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.token0Price:this.token1Price},o.reserveOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.reserve0:this.reserve1},o.getOutputAmount=function(o){if(this.involvesToken(o.currency)||r(!1),e.equal(this.reserve0.quotient,a)||e.equal(this.reserve1.quotient,a))throw new x;var u=this.reserveOf(o.currency),i=this.reserveOf(o.currency.equals(this.token0)?this.token1:this.token0),s=e.multiply(o.quotient,l),c=e.multiply(s,i.quotient),p=e.add(e.multiply(u.quotient,f),s),m=n.CurrencyAmount.fromRawAmount(o.currency.equals(this.token0)?this.token1:this.token0,e.divide(c,p));if(e.equal(m.quotient,a))throw new b;return[m,new t(u.add(o),i.subtract(m))]},o.getInputAmount=function(o){if(this.involvesToken(o.currency)||r(!1),e.equal(this.reserve0.quotient,a)||e.equal(this.reserve1.quotient,a)||e.greaterThanOrEqual(o.quotient,this.reserveOf(o.currency).quotient))throw new x;var u=this.reserveOf(o.currency),i=this.reserveOf(o.currency.equals(this.token0)?this.token1:this.token0),s=e.multiply(e.multiply(i.quotient,o.quotient),f),p=e.multiply(e.subtract(u.quotient,o.quotient),l),m=n.CurrencyAmount.fromRawAmount(o.currency.equals(this.token0)?this.token1:this.token0,e.add(e.divide(s,p),c));return[m,new t(i.add(m),u.subtract(o))]},o.getLiquidityMinted=function(t,o,u){t.currency.equals(this.liquidityToken)||r(!1);var i,c=o.currency.sortsBefore(u.currency)?[o,u]:[u,o];if(c[0].currency.equals(this.token0)&&c[1].currency.equals(this.token1)||r(!1),e.equal(t.quotient,a))i=e.subtract(n.sqrt(e.multiply(c[0].quotient,c[1].quotient)),s);else{var p=e.divide(e.multiply(c[0].quotient,t.quotient),this.reserve0.quotient),l=e.divide(e.multiply(c[1].quotient,t.quotient),this.reserve1.quotient);i=e.lessThanOrEqual(p,l)?p:l}if(!e.greaterThan(i,a))throw new b;return n.CurrencyAmount.fromRawAmount(this.liquidityToken,i)},o.getLiquidityValue=function(t,o,u,i,s){var c;if(void 0===i&&(i=!1),this.involvesToken(t)||r(!1),o.currency.equals(this.liquidityToken)||r(!1),u.currency.equals(this.liquidityToken)||r(!1),e.lessThanOrEqual(u.quotient,o.quotient)||r(!1),i){s||r(!1);var l=e.BigInt(s);if(e.equal(l,a))c=o;else{var f=n.sqrt(e.multiply(this.reserve0.quotient,this.reserve1.quotient)),m=n.sqrt(l);if(e.greaterThan(f,m)){var h=e.multiply(o.quotient,e.subtract(f,m)),d=e.add(e.multiply(f,p),m),y=e.divide(h,d);c=o.add(n.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else c=o}}else c=o;return n.CurrencyAmount.fromRawAmount(t,e.divide(e.multiply(u.quotient,this.reserveOf(t).quotient),c.quotient))},h(t,[{key:"token0Price",get:function(){var t=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new n.Price(this.token0,this.token1,t.denominator,t.numerator)}},{key:"token1Price",get:function(){var t=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new n.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}(),P=function(){function t(t,e,n){this._midPrice=null,t.length>0||r(!1);var o=t[0].chainId;t.every((function(t){return t.chainId===o}))||r(!1);var u=e.wrapped;t[0].involvesToken(u)||r(!1),void 0===n||t[t.length-1].involvesToken(n.wrapped)||r(!1);for(var i,s=[u],a=w(t.entries());!(i=a()).done;){var c=i.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||r(!1);var f=l.equals(p.token0)?p.token1:p.token0;s.push(f)}this.pairs=t,this.path=s,this.input=e,this.output=n}return h(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,e=[],r=w(this.pairs.entries());!(t=r()).done;){var o=t.value,u=o[1];e.push(this.path[o[0]].equals(u.token0)?new n.Price(u.reserve0.currency,u.reserve1.currency,u.reserve0.quotient,u.reserve1.quotient):new n.Price(u.reserve1.currency,u.reserve0.currency,u.reserve1.quotient,u.reserve0.quotient))}var i=e.slice(1).reduce((function(t,e){return t.multiply(e)}),e[0]);return this._midPrice=new n.Price(this.input,this.output,i.denominator,i.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}();function C(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||r(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||r(!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 _(t,e){var n=C(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}var R=function(){function t(t,e,o){this.route=t,this.tradeType=o;var u=new Array(t.path.length);if(o===n.TradeType.EXACT_INPUT){e.currency.equals(t.input)||r(!1),u[0]=e.wrapped;for(var i=0;i<t.path.length-1;i++){var s=t.pairs[i].getOutputAmount(u[i]);u[i+1]=s[0]}this.inputAmount=n.CurrencyAmount.fromFractionalAmount(t.input,e.numerator,e.denominator),this.outputAmount=n.CurrencyAmount.fromFractionalAmount(t.output,u[u.length-1].numerator,u[u.length-1].denominator)}else{e.currency.equals(t.output)||r(!1),u[u.length-1]=e.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=n.CurrencyAmount.fromFractionalAmount(t.input,u[0].numerator,u[0].denominator),this.outputAmount=n.CurrencyAmount.fromFractionalAmount(t.output,e.numerator,e.denominator)}this.executionPrice=new n.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=n.computePriceImpact(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(e,r){return new t(e,r,n.TradeType.EXACT_INPUT)},t.exactOut=function(e,r){return new t(e,r,n.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(a)&&r(!1),this.tradeType===n.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new n.Fraction(c).add(t).invert().multiply(this.outputAmount.quotient).quotient;return n.CurrencyAmount.fromRawAmount(this.outputAmount.currency,e)},e.maximumAmountIn=function(t){if(t.lessThan(a)&&r(!1),this.tradeType===n.TradeType.EXACT_INPUT)return this.inputAmount;var e=new n.Fraction(c).add(t).multiply(this.inputAmount.quotient).quotient;return n.CurrencyAmount.fromRawAmount(this.inputAmount.currency,e)},t.bestTradeExactIn=function(e,o,u,i,s,c,p){var l=void 0===i?{}:i,f=l.maxNumResults,m=void 0===f?3:f,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===c&&(c=o),void 0===p&&(p=[]),e.length>0||r(!1),d>0||r(!1),o===c||s.length>0||r(!1);for(var y=c.wrapped,v=u.wrapped,T=0;T<e.length;T++){var A=e[T];if((A.token0.equals(y.currency)||A.token1.equals(y.currency))&&!A.reserve0.equalTo(a)&&!A.reserve1.equalTo(a)){var q=void 0;try{q=A.getOutputAmount(y)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(q.currency.equals(v))n.sortedInsert(p,new t(new P([].concat(s,[A]),o.currency,u),o,n.TradeType.EXACT_INPUT),m,_);else if(d>1&&e.length>1){var k=e.slice(0,T).concat(e.slice(T+1,e.length));t.bestTradeExactIn(k,o,u,{maxNumResults:m,maxHops:d-1},[].concat(s,[A]),q,p)}}}return p},e.worstExecutionPrice=function(t){return new n.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactOut=function(e,o,u,i,s,c,p){var l=void 0===i?{}:i,f=l.maxNumResults,m=void 0===f?3:f,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===c&&(c=u),void 0===p&&(p=[]),e.length>0||r(!1),d>0||r(!1),u===c||s.length>0||r(!1);for(var y=c.wrapped,v=o.wrapped,T=0;T<e.length;T++){var A=e[T];if((A.token0.equals(y.currency)||A.token1.equals(y.currency))&&!A.reserve0.equalTo(a)&&!A.reserve1.equalTo(a)){var q=void 0;try{q=A.getInputAmount(y)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(q.currency.equals(v))n.sortedInsert(p,new t(new P([A].concat(s),o,u.currency),u,n.TradeType.EXACT_OUTPUT),m,_);else if(d>1&&e.length>1){var k=e.slice(0,T).concat(e.slice(T+1,e.length));t.bestTradeExactOut(k,o,u,{maxNumResults:m,maxHops:d-1},[A].concat(s),q,p)}}}return p},t}();function F(t){return"0x"+t.quotient.toString(16)}var S=function(){function t(){}return t.swapCallParameters=function(t,e){var o=t.inputAmount.currency.isNative,u=t.outputAmount.currency.isNative;o&&u&&r(!1),!("ttl"in e)||e.ttl>0||r(!1);var i,s,a,c=n.validateAndParseAddress(e.recipient),p=F(t.maximumAmountIn(e.allowedSlippage)),l=F(t.minimumAmountOut(e.allowedSlippage)),f=t.route.path.map((function(t){return t.address})),m="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),h=Boolean(e.feeOnTransfer);switch(t.tradeType){case n.TradeType.EXACT_INPUT:o?(i=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,f,c,m],a=p):u?(i=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,f,c,m],a="0x0"):(i=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,f,c,m],a="0x0");break;case n.TradeType.EXACT_OUTPUT:h&&r(!1),o?(i="swapETHForExactTokens",s=[l,f,c,m],a=p):u?(i="swapTokensForExactETH",s=[l,p,f,c,m],a="0x0"):(i="swapTokensForExactTokens",s=[l,p,f,c,m],a="0x0")}return{methodName:i,args:s,value:a}},t}();exports.FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",exports.INIT_CODE_HASH=i,exports.InsufficientInputAmountError=b,exports.InsufficientReservesError=x,exports.MINIMUM_LIQUIDITY=s,exports.Pair=E,exports.Route=P,exports.Router=S,exports.Trade=R,exports.computePairAddress=O,exports.inputOutputComparator=C,exports.tradeComparator=_;
//# sourceMappingURL=v2-sdk.cjs.production.min.js.map
import JSBI from 'jsbi';
import { CurrencyAmount, sqrt, Token as Token$1, Price, wrappedCurrency, currencyEquals, TradeType as TradeType$1, Fraction as Fraction$1, wrappedCurrencyAmount, sortedInsert, validateAndParseAddress as validateAndParseAddress$1 } from '@uniswap/sdk-core';
import { CurrencyAmount, sqrt, Token, Price, TradeType, Fraction, computePriceImpact, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';
import invariant from 'tiny-invariant';
import { keccak256, pack } from '@ethersproject/solidity';
import { getCreate2Address, getAddress } from '@ethersproject/address';
import _Decimal from 'decimal.js-light';
import _Big from 'big.js';
import toFormat from 'toformat';
import { getCreate2Address } from '@ethersproject/address';

@@ -235,3 +232,3 @@ var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';

? [currencyAmountA, tokenAmountB] : [tokenAmountB, currencyAmountA];
this.liquidityToken = new Token$1(tokenAmounts[0].currency.chainId, Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency), 18, 'UNI-V2', 'Uniswap V2');
this.liquidityToken = new Token(tokenAmounts[0].currency.chainId, Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency), 18, 'UNI-V2', 'Uniswap V2');
this.tokenAmounts = tokenAmounts;

@@ -430,5 +427,5 @@ }

}) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_IDS') : invariant(false) : void 0;
var wrappedInput = wrappedCurrency(input, chainId);
var wrappedInput = input.wrapped;
!pairs[0].involvesToken(wrappedInput) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0;
!(typeof output === 'undefined' || pairs[pairs.length - 1].involvesToken(wrappedCurrency(output, chainId))) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0;
!(typeof output === 'undefined' || pairs[pairs.length - 1].involvesToken(output.wrapped)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0;
var path = [wrappedInput];

@@ -482,350 +479,2 @@

var ChainId;
(function (ChainId) {
ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
ChainId[ChainId["ROPSTEN"] = 3] = "ROPSTEN";
ChainId[ChainId["RINKEBY"] = 4] = "RINKEBY";
ChainId[ChainId["G\xD6RLI"] = 5] = "G\xD6RLI";
ChainId[ChainId["KOVAN"] = 42] = "KOVAN";
})(ChainId || (ChainId = {}));
var TradeType;
(function (TradeType) {
TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT";
TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT";
})(TradeType || (TradeType = {}));
var Rounding;
(function (Rounding) {
Rounding[Rounding["ROUND_DOWN"] = 0] = "ROUND_DOWN";
Rounding[Rounding["ROUND_HALF_UP"] = 1] = "ROUND_HALF_UP";
Rounding[Rounding["ROUND_UP"] = 2] = "ROUND_UP";
})(Rounding || (Rounding = {}));
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose$1(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* A currency is any fungible financial instrument on Ethereum, including Ether and all ERC20 tokens.
*
* The only instance of the base class `Currency` is Ether.
*/
var BaseCurrency =
/**
* Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`.
* @param decimals decimals of the currency
* @param symbol symbol of the currency
* @param name of the currency
*/
function BaseCurrency(decimals, symbol, name) {
!(decimals >= 0 && decimals < 255 && Number.isInteger(decimals)) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, 'DECIMALS') : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
this.decimals = decimals;
this.symbol = symbol;
this.name = name;
};
var _toSignificantRoundin, _toFixedRounding;
var Decimal = /*#__PURE__*/toFormat(_Decimal);
var Big = /*#__PURE__*/toFormat(_Big);
var toSignificantRounding = (_toSignificantRoundin = {}, _toSignificantRoundin[Rounding.ROUND_DOWN] = Decimal.ROUND_DOWN, _toSignificantRoundin[Rounding.ROUND_HALF_UP] = Decimal.ROUND_HALF_UP, _toSignificantRoundin[Rounding.ROUND_UP] = Decimal.ROUND_UP, _toSignificantRoundin);
var toFixedRounding = (_toFixedRounding = {}, _toFixedRounding[Rounding.ROUND_DOWN] = 0, _toFixedRounding[Rounding.ROUND_HALF_UP] = 1, _toFixedRounding[Rounding.ROUND_UP] = 3, _toFixedRounding);
var Fraction = /*#__PURE__*/function () {
function Fraction(numerator, denominator) {
if (denominator === void 0) {
denominator = JSBI.BigInt(1);
}
this.numerator = JSBI.BigInt(numerator);
this.denominator = JSBI.BigInt(denominator);
}
Fraction.tryParseFraction = function tryParseFraction(fractionish) {
if (fractionish instanceof JSBI || typeof fractionish === 'number' || typeof fractionish === 'string') return new Fraction(fractionish);
if ('numerator' in fractionish && 'denominator' in fractionish) return fractionish;
throw new Error('Could not parse fraction');
} // performs floor division
;
var _proto = Fraction.prototype;
_proto.invert = function invert() {
return new Fraction(this.denominator, this.numerator);
};
_proto.add = function add(other) {
var otherParsed = Fraction.tryParseFraction(other);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.subtract = function subtract(other) {
var otherParsed = Fraction.tryParseFraction(other);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.lessThan = function lessThan(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.equalTo = function equalTo(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.greaterThan = function greaterThan(other) {
var otherParsed = Fraction.tryParseFraction(other);
return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.multiply = function multiply(other) {
var otherParsed = Fraction.tryParseFraction(other);
return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.divide = function divide(other) {
var otherParsed = Fraction.tryParseFraction(other);
return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator));
};
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
if (format === void 0) {
format = {
groupSeparator: ''
};
}
if (rounding === void 0) {
rounding = Rounding.ROUND_HALF_UP;
}
!Number.isInteger(significantDigits) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, significantDigits + " is not an integer.") : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
!(significantDigits > 0) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, significantDigits + " is not positive.") : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
Decimal.set({
precision: significantDigits + 1,
rounding: toSignificantRounding[rounding]
});
var quotient = new Decimal(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(significantDigits);
return quotient.toFormat(quotient.decimalPlaces(), format);
};
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
if (format === void 0) {
format = {
groupSeparator: ''
};
}
if (rounding === void 0) {
rounding = Rounding.ROUND_HALF_UP;
}
!Number.isInteger(decimalPlaces) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, decimalPlaces + " is not an integer.") : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
!(decimalPlaces >= 0) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, decimalPlaces + " is negative.") : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
Big.DP = decimalPlaces;
Big.RM = toFixedRounding[rounding];
return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format);
}
/**
* Helper method for converting any super class back to a fraction
*/
;
_createClass$1(Fraction, [{
key: "quotient",
get: function get() {
return JSBI.divide(this.numerator, this.denominator);
} // remainder after floor division
}, {
key: "remainder",
get: function get() {
return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator);
}
}, {
key: "asFraction",
get: function get() {
return new Fraction(this.numerator, this.denominator);
}
}]);
return Fraction;
}();
var ONE_HUNDRED = /*#__PURE__*/new Fraction( /*#__PURE__*/JSBI.BigInt(100));
/**
* Converts a fraction to a percent
* @param fraction the fraction to convert
*/
function toPercent(fraction) {
return new Percent(fraction.numerator, fraction.denominator);
}
var Percent = /*#__PURE__*/function (_Fraction) {
_inheritsLoose$1(Percent, _Fraction);
function Percent() {
var _this;
_this = _Fraction.apply(this, arguments) || this;
/**
* This boolean prevents a fraction from being interpreted as a Percent
*/
_this.isPercent = true;
return _this;
}
var _proto = Percent.prototype;
_proto.add = function add(other) {
return toPercent(_Fraction.prototype.add.call(this, other));
};
_proto.subtract = function subtract(other) {
return toPercent(_Fraction.prototype.subtract.call(this, other));
};
_proto.multiply = function multiply(other) {
return toPercent(_Fraction.prototype.multiply.call(this, other));
};
_proto.divide = function divide(other) {
return toPercent(_Fraction.prototype.divide.call(this, other));
};
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
if (significantDigits === void 0) {
significantDigits = 5;
}
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toSignificant(significantDigits, format, rounding);
};
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
if (decimalPlaces === void 0) {
decimalPlaces = 2;
}
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
};
return Percent;
}(Fraction);
/**
* Validates an address and returns the parsed (checksummed) version of that address
* @param address the unchecksummed hex address
*/
function validateAndParseAddress(address) {
try {
return getAddress(address);
} catch (error) {
throw new Error(address + " is not a valid address.");
}
}
var _WETH;
/**
* Represents an ERC20 token with a unique address and some metadata.
*/
var Token = /*#__PURE__*/function (_BaseCurrency) {
_inheritsLoose$1(Token, _BaseCurrency);
function Token(chainId, address, decimals, symbol, name) {
var _this;
_this = _BaseCurrency.call(this, decimals, symbol, name) || this;
_this.isEther = false;
_this.isToken = true;
_this.chainId = chainId;
_this.address = validateAndParseAddress(address);
return _this;
}
/**
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
* @param other other token to compare
*/
var _proto = Token.prototype;
_proto.equals = function equals(other) {
// short circuit on reference equality
if (this === other) {
return true;
}
return this.chainId === other.chainId && this.address === other.address;
}
/**
* Returns true if the address of this token sorts before the address of the other token
* @param other other token to compare
* @throws if the tokens have the same address
* @throws if the tokens are on different chains
*/
;
_proto.sortsBefore = function sortsBefore(other) {
!(this.chainId === other.chainId) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_IDS') : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
!(this.address !== other.address) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, 'ADDRESSES') : invariant(false) : process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
return this.address.toLowerCase() < other.address.toLowerCase();
};
return Token;
}(BaseCurrency);
var WETH9 = (_WETH = {}, _WETH[ChainId.MAINNET] = /*#__PURE__*/new Token(ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.ROPSTEN] = /*#__PURE__*/new Token(ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.RINKEBY] = /*#__PURE__*/new Token(ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.GÖRLI] = /*#__PURE__*/new Token(ChainId.GÖRLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH9', 'Wrapped Ether'), _WETH[ChainId.KOVAN] = /*#__PURE__*/new Token(ChainId.KOVAN, '0xd0A1E359811322d97991E03f863a0C30C2cF029C', 18, 'WETH9', 'Wrapped Ether'), _WETH);
/**
* Returns the percent difference between the mid price and the execution price, i.e. price impact.
* @param midPrice mid price before the trade
* @param inputAmount the input amount of the trade
* @param outputAmount the output amount of the trade
*/
function computePriceImpact(midPrice, inputAmount, outputAmount) {
var quotedOutputAmount = midPrice.quote(inputAmount); // calculate price impact := (exactQuote - outputAmount) / exactQuote
var priceImpact = quotedOutputAmount.subtract(outputAmount).divide(quotedOutputAmount);
return new Percent(priceImpact.numerator, priceImpact.denominator);
} // `maxSize` by removing the last item
// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first

@@ -835,4 +484,4 @@

// must have same input and output token for comparison
!currencyEquals(a.inputAmount.currency, b.inputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT_CURRENCY') : invariant(false) : void 0;
!currencyEquals(a.outputAmount.currency, b.outputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT_CURRENCY') : invariant(false) : void 0;
!a.inputAmount.currency.equals(b.inputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT_CURRENCY') : invariant(false) : void 0;
!a.outputAmount.currency.equals(b.outputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT_CURRENCY') : invariant(false) : void 0;

@@ -888,5 +537,5 @@ if (a.outputAmount.equalTo(b.outputAmount)) {

if (tradeType === TradeType$1.EXACT_INPUT) {
!currencyEquals(amount.currency, route.input) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0;
tokenAmounts[0] = wrappedCurrencyAmount(amount, route.chainId);
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;

@@ -905,4 +554,4 @@ for (var i = 0; i < route.path.length - 1; i++) {

} else {
!currencyEquals(amount.currency, route.output) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0;
tokenAmounts[tokenAmounts.length - 1] = wrappedCurrencyAmount(amount, route.chainId);
!amount.currency.equals(route.output) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0;
tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;

@@ -933,3 +582,3 @@ for (var _i = route.path.length - 1; _i > 0; _i--) {

Trade.exactIn = function exactIn(route, amountIn) {
return new Trade(route, amountIn, TradeType$1.EXACT_INPUT);
return new Trade(route, amountIn, TradeType.EXACT_INPUT);
}

@@ -944,3 +593,3 @@ /**

Trade.exactOut = function exactOut(route, amountOut) {
return new Trade(route, amountOut, TradeType$1.EXACT_OUTPUT);
return new Trade(route, amountOut, TradeType.EXACT_OUTPUT);
}

@@ -958,6 +607,6 @@ /**

if (this.tradeType === TradeType$1.EXACT_OUTPUT) {
if (this.tradeType === TradeType.EXACT_OUTPUT) {
return this.outputAmount;
} else {
var slippageAdjustedAmountOut = new Fraction$1(ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
var slippageAdjustedAmountOut = new Fraction(ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
return CurrencyAmount.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut);

@@ -975,6 +624,6 @@ }

if (this.tradeType === TradeType$1.EXACT_INPUT) {
if (this.tradeType === TradeType.EXACT_INPUT) {
return this.inputAmount;
} else {
var slippageAdjustedAmountIn = new Fraction$1(ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
var slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
return CurrencyAmount.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn);

@@ -1022,6 +671,4 @@ }

!(currencyAmountIn === nextAmountIn || currentPairs.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INVALID_RECURSION') : invariant(false) : void 0;
var chainId = nextAmountIn.currency.isToken ? nextAmountIn.currency.chainId : currencyOut.isToken ? currencyOut.chainId : undefined;
!(chainId !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_ID') : invariant(false) : void 0;
var amountIn = wrappedCurrencyAmount(nextAmountIn, chainId);
var tokenOut = wrappedCurrency(currencyOut, chainId);
var amountIn = nextAmountIn.wrapped;
var tokenOut = currencyOut.wrapped;

@@ -1031,3 +678,3 @@ for (var i = 0; i < pairs.length; i++) {

if (!currencyEquals(pair.token0, amountIn.currency) && !currencyEquals(pair.token1, amountIn.currency)) continue;
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;

@@ -1052,4 +699,4 @@ var amountOut = void 0;

if (currencyEquals(amountOut.currency, tokenOut)) {
sortedInsert(bestTrades, new Trade(new Route([].concat(currentPairs, [pair]), currencyAmountIn.currency, currencyOut), currencyAmountIn, TradeType$1.EXACT_INPUT), maxNumResults, tradeComparator);
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) {

@@ -1116,6 +763,4 @@ 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

!(currencyAmountOut === nextAmountOut || currentPairs.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INVALID_RECURSION') : invariant(false) : void 0;
var chainId = nextAmountOut.currency.isToken ? nextAmountOut.currency.chainId : currencyIn.isToken ? currencyIn.chainId : undefined;
!(chainId !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_ID') : invariant(false) : void 0;
var amountOut = wrappedCurrencyAmount(nextAmountOut, chainId);
var tokenIn = wrappedCurrency(currencyIn, chainId);
var amountOut = nextAmountOut.wrapped;
var tokenIn = currencyIn.wrapped;

@@ -1125,3 +770,3 @@ for (var i = 0; i < pairs.length; i++) {

if (!currencyEquals(pair.token0, amountOut.currency) && !currencyEquals(pair.token1, amountOut.currency)) continue;
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency)) continue;
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue;

@@ -1146,4 +791,4 @@ var amountIn = void 0;

if (currencyEquals(amountIn.currency, tokenIn)) {
sortedInsert(bestTrades, new Trade(new Route([pair].concat(currentPairs), currencyIn, currencyAmountOut.currency), currencyAmountOut, TradeType$1.EXACT_OUTPUT), maxNumResults, tradeComparator);
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) {

@@ -1187,8 +832,8 @@ 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

Router.swapCallParameters = function swapCallParameters(trade, options) {
var etherIn = trade.inputAmount.currency.isEther;
var etherOut = trade.outputAmount.currency.isEther; // the router does not support both ether in and out
var etherIn = trade.inputAmount.currency.isNative;
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;
!(!('ttl' in options) || options.ttl > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TTL') : invariant(false) : void 0;
var to = validateAndParseAddress$1(options.recipient);
var to = validateAndParseAddress(options.recipient);
var amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));

@@ -1206,3 +851,3 @@ var amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));

switch (trade.tradeType) {
case TradeType$1.EXACT_INPUT:
case TradeType.EXACT_INPUT:
if (etherIn) {

@@ -1227,3 +872,3 @@ methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens'; // (uint amountOutMin, address[] calldata path, address to, uint deadline)

case TradeType$1.EXACT_OUTPUT:
case TradeType.EXACT_OUTPUT:
!!useFeeOnTransfer ? process.env.NODE_ENV !== "production" ? invariant(false, 'EXACT_OUT_FOT') : invariant(false) : void 0;

@@ -1230,0 +875,0 @@

{
"name": "@uniswap/v2-sdk",
"license": "MIT",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.1",
"description": "🛠 An SDK for building applications on top of Uniswap V2",

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

"@ethersproject/solidity": "^5.0.0",
"@uniswap/sdk-core": "^3.0.0-alpha.1",
"@uniswap/sdk-core": "^3.0.0-alpha.2",
"tiny-invariant": "^1.1.0",

@@ -30,0 +30,0 @@ "tiny-warning": "^1.0.3"

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