@pancakeswap/sdk 3.0.0-2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +515 -7
- package/dist/index.js +1012 -5
- package/dist/index.mjs +945 -0
- package/package.json +20 -14
- package/dist/constants.d.ts +0 -43
- package/dist/entities/currency.d.ts +0 -23
- package/dist/entities/fractions/currencyAmount.d.ts +0 -19
- package/dist/entities/fractions/fraction.d.ts +0 -23
- package/dist/entities/fractions/index.d.ts +0 -5
- package/dist/entities/fractions/percent.d.ts +0 -6
- package/dist/entities/fractions/price.d.ts +0 -19
- package/dist/entities/fractions/tokenAmount.d.ts +0 -9
- package/dist/entities/index.d.ts +0 -6
- package/dist/entities/pair.d.ts +0 -41
- package/dist/entities/route.d.ts +0 -14
- package/dist/entities/token.d.ts +0 -35
- package/dist/entities/trade.d.ts +0 -106
- package/dist/errors.d.ts +0 -16
- package/dist/fetcher.d.ts +0 -28
- package/dist/router.d.ts +0 -63
- package/dist/sdk.cjs.development.js +0 -2367
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -2342
- package/dist/sdk.esm.js.map +0 -1
- package/dist/test/constants.test.d.ts +0 -1
- package/dist/test/data.test.d.ts +0 -1
- package/dist/test/entities.test.d.ts +0 -1
- package/dist/test/fraction.test.d.ts +0 -1
- package/dist/test/miscellaneous.test.d.ts +0 -1
- package/dist/test/pair.test.d.ts +0 -1
- package/dist/test/route.test.d.ts +0 -1
- package/dist/test/router.test.d.ts +0 -1
- package/dist/test/token.test.d.ts +0 -1
- package/dist/test/trade.test.d.ts +0 -1
- package/dist/utils.d.ts +0 -7
package/dist/index.js
CHANGED
|
@@ -1,8 +1,1015 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
22
|
|
|
2
|
-
|
|
23
|
+
// src/index.ts
|
|
24
|
+
var src_exports = {};
|
|
25
|
+
__export(src_exports, {
|
|
26
|
+
BaseCurrency: () => BaseCurrency,
|
|
27
|
+
ChainId: () => ChainId,
|
|
28
|
+
CurrencyAmount: () => CurrencyAmount2,
|
|
29
|
+
FACTORY_ADDRESS: () => FACTORY_ADDRESS,
|
|
30
|
+
FACTORY_ADDRESS_MAP: () => FACTORY_ADDRESS_MAP,
|
|
31
|
+
FIVE: () => FIVE,
|
|
32
|
+
Fraction: () => Fraction,
|
|
33
|
+
INIT_CODE_HASH: () => INIT_CODE_HASH,
|
|
34
|
+
INIT_CODE_HASH_MAP: () => INIT_CODE_HASH_MAP,
|
|
35
|
+
InsufficientInputAmountError: () => InsufficientInputAmountError,
|
|
36
|
+
InsufficientReservesError: () => InsufficientReservesError,
|
|
37
|
+
JSBI: () => import_jsbi8.default,
|
|
38
|
+
MINIMUM_LIQUIDITY: () => MINIMUM_LIQUIDITY,
|
|
39
|
+
MaxUint256: () => MaxUint256,
|
|
40
|
+
NATIVE: () => NATIVE,
|
|
41
|
+
Native: () => Native,
|
|
42
|
+
NativeCurrency: () => NativeCurrency,
|
|
43
|
+
ONE: () => ONE,
|
|
44
|
+
Pair: () => Pair,
|
|
45
|
+
Percent: () => Percent,
|
|
46
|
+
Price: () => Price2,
|
|
47
|
+
Rounding: () => Rounding,
|
|
48
|
+
Route: () => Route,
|
|
49
|
+
Router: () => Router,
|
|
50
|
+
SOLIDITY_TYPE_MAXIMA: () => SOLIDITY_TYPE_MAXIMA,
|
|
51
|
+
SolidityType: () => SolidityType,
|
|
52
|
+
TEN: () => TEN,
|
|
53
|
+
THREE: () => THREE,
|
|
54
|
+
TWO: () => TWO,
|
|
55
|
+
Token: () => Token,
|
|
56
|
+
Trade: () => Trade,
|
|
57
|
+
TradeType: () => TradeType,
|
|
58
|
+
WBNB: () => WBNB,
|
|
59
|
+
WETH9: () => WETH9,
|
|
60
|
+
WNATIVE: () => WNATIVE,
|
|
61
|
+
ZERO: () => ZERO,
|
|
62
|
+
_100: () => _100,
|
|
63
|
+
_10000: () => _10000,
|
|
64
|
+
_9975: () => _9975,
|
|
65
|
+
computePairAddress: () => computePairAddress,
|
|
66
|
+
computePriceImpact: () => computePriceImpact,
|
|
67
|
+
inputOutputComparator: () => inputOutputComparator,
|
|
68
|
+
tradeComparator: () => tradeComparator
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(src_exports);
|
|
71
|
+
var import_jsbi8 = __toESM(require("jsbi"));
|
|
3
72
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
73
|
+
// src/constants.ts
|
|
74
|
+
var import_jsbi2 = __toESM(require("jsbi"));
|
|
75
|
+
|
|
76
|
+
// src/entities/token.ts
|
|
77
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
78
|
+
|
|
79
|
+
// src/utils.ts
|
|
80
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
81
|
+
var import_tiny_warning = __toESM(require("tiny-warning"));
|
|
82
|
+
var import_jsbi = __toESM(require("jsbi"));
|
|
83
|
+
var import_address = require("@ethersproject/address");
|
|
84
|
+
function validateSolidityTypeInstance(value, solidityType) {
|
|
85
|
+
(0, import_tiny_invariant.default)(import_jsbi.default.greaterThanOrEqual(value, ZERO), `${value} is not a ${solidityType}.`);
|
|
86
|
+
(0, import_tiny_invariant.default)(import_jsbi.default.lessThanOrEqual(value, SOLIDITY_TYPE_MAXIMA[solidityType]), `${value} is not a ${solidityType}.`);
|
|
87
|
+
}
|
|
88
|
+
function validateAndParseAddress(address) {
|
|
89
|
+
try {
|
|
90
|
+
const checksummedAddress = (0, import_address.getAddress)(address);
|
|
91
|
+
(0, import_tiny_warning.default)(address === checksummedAddress, `${address} is not checksummed.`);
|
|
92
|
+
return checksummedAddress;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
(0, import_tiny_invariant.default)(false, `${address} is not a valid address.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function sqrt(y) {
|
|
98
|
+
validateSolidityTypeInstance(y, "uint256" /* uint256 */);
|
|
99
|
+
let z = ZERO;
|
|
100
|
+
let x;
|
|
101
|
+
if (import_jsbi.default.greaterThan(y, THREE)) {
|
|
102
|
+
z = y;
|
|
103
|
+
x = import_jsbi.default.add(import_jsbi.default.divide(y, TWO), ONE);
|
|
104
|
+
while (import_jsbi.default.lessThan(x, z)) {
|
|
105
|
+
z = x;
|
|
106
|
+
x = import_jsbi.default.divide(import_jsbi.default.add(import_jsbi.default.divide(y, x), x), TWO);
|
|
107
|
+
}
|
|
108
|
+
} else if (import_jsbi.default.notEqual(y, ZERO)) {
|
|
109
|
+
z = ONE;
|
|
110
|
+
}
|
|
111
|
+
return z;
|
|
112
|
+
}
|
|
113
|
+
function sortedInsert(items, add, maxSize, comparator) {
|
|
114
|
+
(0, import_tiny_invariant.default)(maxSize > 0, "MAX_SIZE_ZERO");
|
|
115
|
+
(0, import_tiny_invariant.default)(items.length <= maxSize, "ITEMS_SIZE");
|
|
116
|
+
if (items.length === 0) {
|
|
117
|
+
items.push(add);
|
|
118
|
+
return null;
|
|
119
|
+
} else {
|
|
120
|
+
const isFull = items.length === maxSize;
|
|
121
|
+
if (isFull && comparator(items[items.length - 1], add) <= 0) {
|
|
122
|
+
return add;
|
|
123
|
+
}
|
|
124
|
+
let lo = 0, hi = items.length;
|
|
125
|
+
while (lo < hi) {
|
|
126
|
+
const mid = lo + hi >>> 1;
|
|
127
|
+
if (comparator(items[mid], add) <= 0) {
|
|
128
|
+
lo = mid + 1;
|
|
129
|
+
} else {
|
|
130
|
+
hi = mid;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
items.splice(lo, 0, add);
|
|
134
|
+
return isFull ? items.pop() : null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function computePriceImpact(midPrice, inputAmount, outputAmount) {
|
|
138
|
+
const quotedOutputAmount = midPrice.quote(inputAmount);
|
|
139
|
+
const priceImpact = quotedOutputAmount.subtract(outputAmount).divide(quotedOutputAmount);
|
|
140
|
+
return new Percent(priceImpact.numerator, priceImpact.denominator);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/entities/baseCurrency.ts
|
|
144
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
145
|
+
var BaseCurrency = class {
|
|
146
|
+
constructor(chainId, decimals, symbol, name) {
|
|
147
|
+
(0, import_tiny_invariant2.default)(Number.isSafeInteger(chainId), "CHAIN_ID");
|
|
148
|
+
(0, import_tiny_invariant2.default)(decimals >= 0 && decimals < 255 && Number.isInteger(decimals), "DECIMALS");
|
|
149
|
+
this.chainId = chainId;
|
|
150
|
+
this.decimals = decimals;
|
|
151
|
+
this.symbol = symbol;
|
|
152
|
+
this.name = name;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/entities/token.ts
|
|
157
|
+
var Token = class extends BaseCurrency {
|
|
158
|
+
constructor(chainId, address, decimals, symbol, name, projectLink) {
|
|
159
|
+
super(chainId, decimals, symbol, name);
|
|
160
|
+
this.isNative = false;
|
|
161
|
+
this.isToken = true;
|
|
162
|
+
this.address = validateAndParseAddress(address);
|
|
163
|
+
this.projectLink = projectLink;
|
|
164
|
+
}
|
|
165
|
+
equals(other) {
|
|
166
|
+
return other.isToken && this.chainId === other.chainId && this.address === other.address;
|
|
167
|
+
}
|
|
168
|
+
sortsBefore(other) {
|
|
169
|
+
(0, import_tiny_invariant3.default)(this.chainId === other.chainId, "CHAIN_IDS");
|
|
170
|
+
(0, import_tiny_invariant3.default)(this.address !== other.address, "ADDRESSES");
|
|
171
|
+
return this.address.toLowerCase() < other.address.toLowerCase();
|
|
172
|
+
}
|
|
173
|
+
get wrapped() {
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
get serialize() {
|
|
177
|
+
return {
|
|
178
|
+
address: this.address,
|
|
179
|
+
chainId: this.chainId,
|
|
180
|
+
decimals: this.decimals,
|
|
181
|
+
symbol: this.symbol,
|
|
182
|
+
name: this.name,
|
|
183
|
+
projectLink: this.projectLink
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/constants.ts
|
|
189
|
+
var ChainId = /* @__PURE__ */ ((ChainId2) => {
|
|
190
|
+
ChainId2[ChainId2["ETHEREUM"] = 1] = "ETHEREUM";
|
|
191
|
+
ChainId2[ChainId2["RINKEBY"] = 4] = "RINKEBY";
|
|
192
|
+
ChainId2[ChainId2["GOERLI"] = 5] = "GOERLI";
|
|
193
|
+
ChainId2[ChainId2["BSC"] = 56] = "BSC";
|
|
194
|
+
ChainId2[ChainId2["BSC_TESTNET"] = 97] = "BSC_TESTNET";
|
|
195
|
+
return ChainId2;
|
|
196
|
+
})(ChainId || {});
|
|
197
|
+
var TradeType = /* @__PURE__ */ ((TradeType2) => {
|
|
198
|
+
TradeType2[TradeType2["EXACT_INPUT"] = 0] = "EXACT_INPUT";
|
|
199
|
+
TradeType2[TradeType2["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT";
|
|
200
|
+
return TradeType2;
|
|
201
|
+
})(TradeType || {});
|
|
202
|
+
var Rounding = /* @__PURE__ */ ((Rounding2) => {
|
|
203
|
+
Rounding2[Rounding2["ROUND_DOWN"] = 0] = "ROUND_DOWN";
|
|
204
|
+
Rounding2[Rounding2["ROUND_HALF_UP"] = 1] = "ROUND_HALF_UP";
|
|
205
|
+
Rounding2[Rounding2["ROUND_UP"] = 2] = "ROUND_UP";
|
|
206
|
+
return Rounding2;
|
|
207
|
+
})(Rounding || {});
|
|
208
|
+
var FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
|
|
209
|
+
var FACTORY_ADDRESS_ETH = "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362";
|
|
210
|
+
var FACTORY_ADDRESS_MAP = {
|
|
211
|
+
[1 /* ETHEREUM */]: FACTORY_ADDRESS_ETH,
|
|
212
|
+
[4 /* RINKEBY */]: FACTORY_ADDRESS_ETH,
|
|
213
|
+
[5 /* GOERLI */]: FACTORY_ADDRESS_ETH,
|
|
214
|
+
[56 /* BSC */]: FACTORY_ADDRESS,
|
|
215
|
+
[97 /* BSC_TESTNET */]: "0x6725f303b657a9451d8ba641348b6761a6cc7a17"
|
|
216
|
+
};
|
|
217
|
+
var INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5";
|
|
218
|
+
var INIT_CODE_HASH_ETH = "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d";
|
|
219
|
+
var INIT_CODE_HASH_MAP = {
|
|
220
|
+
[1 /* ETHEREUM */]: INIT_CODE_HASH_ETH,
|
|
221
|
+
[4 /* RINKEBY */]: INIT_CODE_HASH_ETH,
|
|
222
|
+
[5 /* GOERLI */]: INIT_CODE_HASH_ETH,
|
|
223
|
+
[56 /* BSC */]: INIT_CODE_HASH,
|
|
224
|
+
[97 /* BSC_TESTNET */]: "0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66"
|
|
225
|
+
};
|
|
226
|
+
var MINIMUM_LIQUIDITY = import_jsbi2.default.BigInt(1e3);
|
|
227
|
+
var ZERO = import_jsbi2.default.BigInt(0);
|
|
228
|
+
var ONE = import_jsbi2.default.BigInt(1);
|
|
229
|
+
var TWO = import_jsbi2.default.BigInt(2);
|
|
230
|
+
var THREE = import_jsbi2.default.BigInt(3);
|
|
231
|
+
var FIVE = import_jsbi2.default.BigInt(5);
|
|
232
|
+
var TEN = import_jsbi2.default.BigInt(10);
|
|
233
|
+
var _100 = import_jsbi2.default.BigInt(100);
|
|
234
|
+
var _9975 = import_jsbi2.default.BigInt(9975);
|
|
235
|
+
var _10000 = import_jsbi2.default.BigInt(1e4);
|
|
236
|
+
var MaxUint256 = import_jsbi2.default.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
237
|
+
var SolidityType = /* @__PURE__ */ ((SolidityType2) => {
|
|
238
|
+
SolidityType2["uint8"] = "uint8";
|
|
239
|
+
SolidityType2["uint256"] = "uint256";
|
|
240
|
+
return SolidityType2;
|
|
241
|
+
})(SolidityType || {});
|
|
242
|
+
var SOLIDITY_TYPE_MAXIMA = {
|
|
243
|
+
["uint8" /* uint8 */]: import_jsbi2.default.BigInt("0xff"),
|
|
244
|
+
["uint256" /* uint256 */]: import_jsbi2.default.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
245
|
+
};
|
|
246
|
+
var WETH9 = {
|
|
247
|
+
[1 /* ETHEREUM */]: new Token(1 /* ETHEREUM */, "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 18, "WETH", "Wrapped Ether", "https://weth.io"),
|
|
248
|
+
[4 /* RINKEBY */]: new Token(4 /* RINKEBY */, "0xc778417E063141139Fce010982780140Aa0cD5Ab", 18, "WETH", "Wrapped Ether", "https://weth.io"),
|
|
249
|
+
[5 /* GOERLI */]: new Token(5 /* GOERLI */, "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", 18, "WETH", "Wrapped Ether", "https://weth.io")
|
|
250
|
+
};
|
|
251
|
+
var WBNB = {
|
|
252
|
+
[1 /* ETHEREUM */]: new Token(1 /* ETHEREUM */, "0x418D75f65a02b3D53B2418FB8E1fe493759c7605", 18, "WBNB", "Wrapped BNB", "https://www.binance.org"),
|
|
253
|
+
[56 /* BSC */]: new Token(56 /* BSC */, "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", 18, "WBNB", "Wrapped BNB", "https://www.binance.org"),
|
|
254
|
+
[97 /* BSC_TESTNET */]: new Token(97 /* BSC_TESTNET */, "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", 18, "WBNB", "Wrapped BNB", "https://www.binance.org")
|
|
255
|
+
};
|
|
256
|
+
var WNATIVE = {
|
|
257
|
+
[1 /* ETHEREUM */]: WETH9[1 /* ETHEREUM */],
|
|
258
|
+
[4 /* RINKEBY */]: WETH9[4 /* RINKEBY */],
|
|
259
|
+
[5 /* GOERLI */]: WETH9[5 /* GOERLI */],
|
|
260
|
+
[56 /* BSC */]: WBNB[56 /* BSC */],
|
|
261
|
+
[97 /* BSC_TESTNET */]: WBNB[97 /* BSC_TESTNET */]
|
|
262
|
+
};
|
|
263
|
+
var NATIVE = {
|
|
264
|
+
[1 /* ETHEREUM */]: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
265
|
+
[4 /* RINKEBY */]: { name: "Rinkeby Ether", symbol: "RIN", decimals: 18 },
|
|
266
|
+
[5 /* GOERLI */]: { name: "Goerli Ether", symbol: "GOR", decimals: 18 },
|
|
267
|
+
[56 /* BSC */]: {
|
|
268
|
+
name: "Binance Chain Native Token",
|
|
269
|
+
symbol: "BNB",
|
|
270
|
+
decimals: 18
|
|
271
|
+
},
|
|
272
|
+
[97 /* BSC_TESTNET */]: {
|
|
273
|
+
name: "Binance Chain Native Token",
|
|
274
|
+
symbol: "tBNB",
|
|
275
|
+
decimals: 18
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/errors.ts
|
|
280
|
+
var CAN_SET_PROTOTYPE = "setPrototypeOf" in Object;
|
|
281
|
+
var InsufficientReservesError = class extends Error {
|
|
282
|
+
constructor() {
|
|
283
|
+
super();
|
|
284
|
+
this.isInsufficientReservesError = true;
|
|
285
|
+
this.name = this.constructor.name;
|
|
286
|
+
if (CAN_SET_PROTOTYPE)
|
|
287
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
var InsufficientInputAmountError = class extends Error {
|
|
291
|
+
constructor() {
|
|
292
|
+
super();
|
|
293
|
+
this.isInsufficientInputAmountError = true;
|
|
294
|
+
this.name = this.constructor.name;
|
|
295
|
+
if (CAN_SET_PROTOTYPE)
|
|
296
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/entities/pair.ts
|
|
301
|
+
var import_address2 = require("@ethersproject/address");
|
|
302
|
+
var import_solidity = require("@ethersproject/solidity");
|
|
303
|
+
var import_jsbi7 = __toESM(require("jsbi"));
|
|
304
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
305
|
+
|
|
306
|
+
// src/entities/fractions/price.ts
|
|
307
|
+
var import_jsbi5 = __toESM(require("jsbi"));
|
|
308
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
309
|
+
|
|
310
|
+
// src/entities/fractions/fraction.ts
|
|
311
|
+
var import_jsbi3 = __toESM(require("jsbi"));
|
|
312
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
313
|
+
var import_decimal = __toESM(require("decimal.js-light"));
|
|
314
|
+
var import_big = __toESM(require("big.js"));
|
|
315
|
+
var import_toformat = __toESM(require("toformat"));
|
|
316
|
+
var Decimal = (0, import_toformat.default)(import_decimal.default);
|
|
317
|
+
var Big = (0, import_toformat.default)(import_big.default);
|
|
318
|
+
var toSignificantRounding = {
|
|
319
|
+
[0 /* ROUND_DOWN */]: Decimal.ROUND_DOWN,
|
|
320
|
+
[1 /* ROUND_HALF_UP */]: Decimal.ROUND_HALF_UP,
|
|
321
|
+
[2 /* ROUND_UP */]: Decimal.ROUND_UP
|
|
322
|
+
};
|
|
323
|
+
var toFixedRounding = {
|
|
324
|
+
[0 /* ROUND_DOWN */]: 0 /* RoundDown */,
|
|
325
|
+
[1 /* ROUND_HALF_UP */]: 1 /* RoundHalfUp */,
|
|
326
|
+
[2 /* ROUND_UP */]: 3 /* RoundUp */
|
|
327
|
+
};
|
|
328
|
+
var Fraction = class {
|
|
329
|
+
constructor(numerator, denominator = import_jsbi3.default.BigInt(1)) {
|
|
330
|
+
this.numerator = import_jsbi3.default.BigInt(numerator);
|
|
331
|
+
this.denominator = import_jsbi3.default.BigInt(denominator);
|
|
332
|
+
}
|
|
333
|
+
static tryParseFraction(fractionish) {
|
|
334
|
+
if (fractionish instanceof import_jsbi3.default || typeof fractionish === "number" || typeof fractionish === "string")
|
|
335
|
+
return new Fraction(fractionish);
|
|
336
|
+
if ("numerator" in fractionish && "denominator" in fractionish)
|
|
337
|
+
return fractionish;
|
|
338
|
+
throw new Error("Could not parse fraction");
|
|
339
|
+
}
|
|
340
|
+
get quotient() {
|
|
341
|
+
return import_jsbi3.default.divide(this.numerator, this.denominator);
|
|
342
|
+
}
|
|
343
|
+
get remainder() {
|
|
344
|
+
return new Fraction(import_jsbi3.default.remainder(this.numerator, this.denominator), this.denominator);
|
|
345
|
+
}
|
|
346
|
+
invert() {
|
|
347
|
+
return new Fraction(this.denominator, this.numerator);
|
|
348
|
+
}
|
|
349
|
+
add(other) {
|
|
350
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
351
|
+
if (import_jsbi3.default.equal(this.denominator, otherParsed.denominator)) {
|
|
352
|
+
return new Fraction(import_jsbi3.default.add(this.numerator, otherParsed.numerator), this.denominator);
|
|
353
|
+
}
|
|
354
|
+
return new Fraction(import_jsbi3.default.add(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(otherParsed.numerator, this.denominator)), import_jsbi3.default.multiply(this.denominator, otherParsed.denominator));
|
|
355
|
+
}
|
|
356
|
+
subtract(other) {
|
|
357
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
358
|
+
if (import_jsbi3.default.equal(this.denominator, otherParsed.denominator)) {
|
|
359
|
+
return new Fraction(import_jsbi3.default.subtract(this.numerator, otherParsed.numerator), this.denominator);
|
|
360
|
+
}
|
|
361
|
+
return new Fraction(import_jsbi3.default.subtract(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(otherParsed.numerator, this.denominator)), import_jsbi3.default.multiply(this.denominator, otherParsed.denominator));
|
|
362
|
+
}
|
|
363
|
+
lessThan(other) {
|
|
364
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
365
|
+
return import_jsbi3.default.lessThan(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(otherParsed.numerator, this.denominator));
|
|
366
|
+
}
|
|
367
|
+
equalTo(other) {
|
|
368
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
369
|
+
return import_jsbi3.default.equal(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(otherParsed.numerator, this.denominator));
|
|
370
|
+
}
|
|
371
|
+
greaterThan(other) {
|
|
372
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
373
|
+
return import_jsbi3.default.greaterThan(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(otherParsed.numerator, this.denominator));
|
|
374
|
+
}
|
|
375
|
+
multiply(other) {
|
|
376
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
377
|
+
return new Fraction(import_jsbi3.default.multiply(this.numerator, otherParsed.numerator), import_jsbi3.default.multiply(this.denominator, otherParsed.denominator));
|
|
378
|
+
}
|
|
379
|
+
divide(other) {
|
|
380
|
+
const otherParsed = Fraction.tryParseFraction(other);
|
|
381
|
+
return new Fraction(import_jsbi3.default.multiply(this.numerator, otherParsed.denominator), import_jsbi3.default.multiply(this.denominator, otherParsed.numerator));
|
|
382
|
+
}
|
|
383
|
+
toSignificant(significantDigits, format = { groupSeparator: "" }, rounding = 1 /* ROUND_HALF_UP */) {
|
|
384
|
+
(0, import_tiny_invariant4.default)(Number.isInteger(significantDigits), `${significantDigits} is not an integer.`);
|
|
385
|
+
(0, import_tiny_invariant4.default)(significantDigits > 0, `${significantDigits} is not positive.`);
|
|
386
|
+
Decimal.set({ precision: significantDigits + 1, rounding: toSignificantRounding[rounding] });
|
|
387
|
+
const quotient = new Decimal(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(significantDigits);
|
|
388
|
+
return quotient.toFormat(quotient.decimalPlaces(), format);
|
|
389
|
+
}
|
|
390
|
+
toFixed(decimalPlaces, format = { groupSeparator: "" }, rounding = 1 /* ROUND_HALF_UP */) {
|
|
391
|
+
(0, import_tiny_invariant4.default)(Number.isInteger(decimalPlaces), `${decimalPlaces} is not an integer.`);
|
|
392
|
+
(0, import_tiny_invariant4.default)(decimalPlaces >= 0, `${decimalPlaces} is negative.`);
|
|
393
|
+
Big.DP = decimalPlaces;
|
|
394
|
+
Big.RM = toFixedRounding[rounding];
|
|
395
|
+
return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format);
|
|
396
|
+
}
|
|
397
|
+
get asFraction() {
|
|
398
|
+
return new Fraction(this.numerator, this.denominator);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// src/entities/fractions/currencyAmount.ts
|
|
403
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
404
|
+
var import_jsbi4 = __toESM(require("jsbi"));
|
|
405
|
+
var import_big2 = __toESM(require("big.js"));
|
|
406
|
+
var import_toformat2 = __toESM(require("toformat"));
|
|
407
|
+
var Big2 = (0, import_toformat2.default)(import_big2.default);
|
|
408
|
+
var CurrencyAmount2 = class extends Fraction {
|
|
409
|
+
constructor(currency, numerator, denominator) {
|
|
410
|
+
super(numerator, denominator);
|
|
411
|
+
(0, import_tiny_invariant5.default)(import_jsbi4.default.lessThanOrEqual(this.quotient, MaxUint256), "AMOUNT");
|
|
412
|
+
this.currency = currency;
|
|
413
|
+
this.decimalScale = import_jsbi4.default.exponentiate(import_jsbi4.default.BigInt(10), import_jsbi4.default.BigInt(currency.decimals));
|
|
414
|
+
}
|
|
415
|
+
static fromRawAmount(currency, rawAmount) {
|
|
416
|
+
return new CurrencyAmount2(currency, rawAmount);
|
|
417
|
+
}
|
|
418
|
+
static fromFractionalAmount(currency, numerator, denominator) {
|
|
419
|
+
return new CurrencyAmount2(currency, numerator, denominator);
|
|
420
|
+
}
|
|
421
|
+
add(other) {
|
|
422
|
+
(0, import_tiny_invariant5.default)(this.currency.equals(other.currency), "CURRENCY");
|
|
423
|
+
const added = super.add(other);
|
|
424
|
+
return CurrencyAmount2.fromFractionalAmount(this.currency, added.numerator, added.denominator);
|
|
425
|
+
}
|
|
426
|
+
subtract(other) {
|
|
427
|
+
(0, import_tiny_invariant5.default)(this.currency.equals(other.currency), "CURRENCY");
|
|
428
|
+
const subtracted = super.subtract(other);
|
|
429
|
+
return CurrencyAmount2.fromFractionalAmount(this.currency, subtracted.numerator, subtracted.denominator);
|
|
430
|
+
}
|
|
431
|
+
multiply(other) {
|
|
432
|
+
const multiplied = super.multiply(other);
|
|
433
|
+
return CurrencyAmount2.fromFractionalAmount(this.currency, multiplied.numerator, multiplied.denominator);
|
|
434
|
+
}
|
|
435
|
+
divide(other) {
|
|
436
|
+
const divided = super.divide(other);
|
|
437
|
+
return CurrencyAmount2.fromFractionalAmount(this.currency, divided.numerator, divided.denominator);
|
|
438
|
+
}
|
|
439
|
+
toSignificant(significantDigits = 6, format, rounding = 0 /* ROUND_DOWN */) {
|
|
440
|
+
return super.divide(this.decimalScale).toSignificant(significantDigits, format, rounding);
|
|
441
|
+
}
|
|
442
|
+
toFixed(decimalPlaces = this.currency.decimals, format, rounding = 0 /* ROUND_DOWN */) {
|
|
443
|
+
(0, import_tiny_invariant5.default)(decimalPlaces <= this.currency.decimals, "DECIMALS");
|
|
444
|
+
return super.divide(this.decimalScale).toFixed(decimalPlaces, format, rounding);
|
|
445
|
+
}
|
|
446
|
+
toExact(format = { groupSeparator: "" }) {
|
|
447
|
+
Big2.DP = this.currency.decimals;
|
|
448
|
+
return new Big2(this.quotient.toString()).div(this.decimalScale.toString()).toFormat(format);
|
|
449
|
+
}
|
|
450
|
+
get wrapped() {
|
|
451
|
+
if (this.currency.isToken)
|
|
452
|
+
return this;
|
|
453
|
+
return CurrencyAmount2.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// src/entities/fractions/price.ts
|
|
458
|
+
var Price2 = class extends Fraction {
|
|
459
|
+
constructor(...args) {
|
|
460
|
+
let baseCurrency, quoteCurrency, denominator, numerator;
|
|
461
|
+
if (args.length === 4) {
|
|
462
|
+
;
|
|
463
|
+
[baseCurrency, quoteCurrency, denominator, numerator] = args;
|
|
464
|
+
} else {
|
|
465
|
+
const result = args[0].quoteAmount.divide(args[0].baseAmount);
|
|
466
|
+
[baseCurrency, quoteCurrency, denominator, numerator] = [
|
|
467
|
+
args[0].baseAmount.currency,
|
|
468
|
+
args[0].quoteAmount.currency,
|
|
469
|
+
result.denominator,
|
|
470
|
+
result.numerator
|
|
471
|
+
];
|
|
472
|
+
}
|
|
473
|
+
super(numerator, denominator);
|
|
474
|
+
this.baseCurrency = baseCurrency;
|
|
475
|
+
this.quoteCurrency = quoteCurrency;
|
|
476
|
+
this.scalar = new Fraction(import_jsbi5.default.exponentiate(import_jsbi5.default.BigInt(10), import_jsbi5.default.BigInt(baseCurrency.decimals)), import_jsbi5.default.exponentiate(import_jsbi5.default.BigInt(10), import_jsbi5.default.BigInt(quoteCurrency.decimals)));
|
|
477
|
+
}
|
|
478
|
+
invert() {
|
|
479
|
+
return new Price2(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator);
|
|
480
|
+
}
|
|
481
|
+
multiply(other) {
|
|
482
|
+
(0, import_tiny_invariant6.default)(this.quoteCurrency.equals(other.baseCurrency), "TOKEN");
|
|
483
|
+
const fraction = super.multiply(other);
|
|
484
|
+
return new Price2(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator);
|
|
485
|
+
}
|
|
486
|
+
quote(currencyAmount) {
|
|
487
|
+
(0, import_tiny_invariant6.default)(currencyAmount.currency.equals(this.baseCurrency), "TOKEN");
|
|
488
|
+
const result = super.multiply(currencyAmount);
|
|
489
|
+
return CurrencyAmount2.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator);
|
|
490
|
+
}
|
|
491
|
+
get adjustedForDecimals() {
|
|
492
|
+
return super.multiply(this.scalar);
|
|
493
|
+
}
|
|
494
|
+
toSignificant(significantDigits = 6, format, rounding) {
|
|
495
|
+
return this.adjustedForDecimals.toSignificant(significantDigits, format, rounding);
|
|
496
|
+
}
|
|
497
|
+
toFixed(decimalPlaces = 4, format, rounding) {
|
|
498
|
+
return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
// src/entities/fractions/percent.ts
|
|
503
|
+
var import_jsbi6 = __toESM(require("jsbi"));
|
|
504
|
+
var ONE_HUNDRED = new Fraction(import_jsbi6.default.BigInt(100));
|
|
505
|
+
function toPercent(fraction) {
|
|
506
|
+
return new Percent(fraction.numerator, fraction.denominator);
|
|
507
|
+
}
|
|
508
|
+
var Percent = class extends Fraction {
|
|
509
|
+
constructor() {
|
|
510
|
+
super(...arguments);
|
|
511
|
+
this.isPercent = true;
|
|
512
|
+
}
|
|
513
|
+
add(other) {
|
|
514
|
+
return toPercent(super.add(other));
|
|
515
|
+
}
|
|
516
|
+
subtract(other) {
|
|
517
|
+
return toPercent(super.subtract(other));
|
|
518
|
+
}
|
|
519
|
+
multiply(other) {
|
|
520
|
+
return toPercent(super.multiply(other));
|
|
521
|
+
}
|
|
522
|
+
divide(other) {
|
|
523
|
+
return toPercent(super.divide(other));
|
|
524
|
+
}
|
|
525
|
+
toSignificant(significantDigits = 5, format, rounding) {
|
|
526
|
+
return super.multiply(ONE_HUNDRED).toSignificant(significantDigits, format, rounding);
|
|
527
|
+
}
|
|
528
|
+
toFixed(decimalPlaces = 2, format, rounding) {
|
|
529
|
+
return super.multiply(ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// src/entities/pair.ts
|
|
534
|
+
var PAIR_ADDRESS_CACHE = {};
|
|
535
|
+
var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
|
|
536
|
+
var computePairAddress = ({
|
|
537
|
+
factoryAddress,
|
|
538
|
+
tokenA,
|
|
539
|
+
tokenB
|
|
540
|
+
}) => {
|
|
541
|
+
const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
542
|
+
const key = composeKey(token0, token1);
|
|
543
|
+
if ((PAIR_ADDRESS_CACHE == null ? void 0 : PAIR_ADDRESS_CACHE[key]) === void 0) {
|
|
544
|
+
PAIR_ADDRESS_CACHE = {
|
|
545
|
+
...PAIR_ADDRESS_CACHE,
|
|
546
|
+
[key]: (0, import_address2.getCreate2Address)(factoryAddress, (0, import_solidity.keccak256)(["bytes"], [(0, import_solidity.pack)(["address", "address"], [token0.address, token1.address])]), INIT_CODE_HASH_MAP[token0.chainId])
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
return PAIR_ADDRESS_CACHE[key];
|
|
550
|
+
};
|
|
551
|
+
var Pair = class {
|
|
552
|
+
static getAddress(tokenA, tokenB) {
|
|
553
|
+
return computePairAddress({ factoryAddress: FACTORY_ADDRESS_MAP[tokenA.chainId], tokenA, tokenB });
|
|
554
|
+
}
|
|
555
|
+
constructor(currencyAmountA, tokenAmountB) {
|
|
556
|
+
const tokenAmounts = currencyAmountA.currency.sortsBefore(tokenAmountB.currency) ? [currencyAmountA, tokenAmountB] : [tokenAmountB, currencyAmountA];
|
|
557
|
+
this.liquidityToken = new Token(tokenAmounts[0].currency.chainId, Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency), 18, "Cake-LP", "Pancake LPs");
|
|
558
|
+
this.tokenAmounts = tokenAmounts;
|
|
559
|
+
}
|
|
560
|
+
involvesToken(token) {
|
|
561
|
+
return token.equals(this.token0) || token.equals(this.token1);
|
|
562
|
+
}
|
|
563
|
+
get token0Price() {
|
|
564
|
+
const result = this.tokenAmounts[1].divide(this.tokenAmounts[0]);
|
|
565
|
+
return new Price2(this.token0, this.token1, result.denominator, result.numerator);
|
|
566
|
+
}
|
|
567
|
+
get token1Price() {
|
|
568
|
+
const result = this.tokenAmounts[0].divide(this.tokenAmounts[1]);
|
|
569
|
+
return new Price2(this.token1, this.token0, result.denominator, result.numerator);
|
|
570
|
+
}
|
|
571
|
+
priceOf(token) {
|
|
572
|
+
(0, import_tiny_invariant7.default)(this.involvesToken(token), "TOKEN");
|
|
573
|
+
return token.equals(this.token0) ? this.token0Price : this.token1Price;
|
|
574
|
+
}
|
|
575
|
+
get chainId() {
|
|
576
|
+
return this.token0.chainId;
|
|
577
|
+
}
|
|
578
|
+
get token0() {
|
|
579
|
+
return this.tokenAmounts[0].currency;
|
|
580
|
+
}
|
|
581
|
+
get token1() {
|
|
582
|
+
return this.tokenAmounts[1].currency;
|
|
583
|
+
}
|
|
584
|
+
get reserve0() {
|
|
585
|
+
return this.tokenAmounts[0];
|
|
586
|
+
}
|
|
587
|
+
get reserve1() {
|
|
588
|
+
return this.tokenAmounts[1];
|
|
589
|
+
}
|
|
590
|
+
reserveOf(token) {
|
|
591
|
+
(0, import_tiny_invariant7.default)(this.involvesToken(token), "TOKEN");
|
|
592
|
+
return token.equals(this.token0) ? this.reserve0 : this.reserve1;
|
|
593
|
+
}
|
|
594
|
+
getOutputAmount(inputAmount) {
|
|
595
|
+
(0, import_tiny_invariant7.default)(this.involvesToken(inputAmount.currency), "TOKEN");
|
|
596
|
+
if (import_jsbi7.default.equal(this.reserve0.quotient, ZERO) || import_jsbi7.default.equal(this.reserve1.quotient, ZERO)) {
|
|
597
|
+
throw new InsufficientReservesError();
|
|
598
|
+
}
|
|
599
|
+
const inputReserve = this.reserveOf(inputAmount.currency);
|
|
600
|
+
const outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
601
|
+
const inputAmountWithFee = import_jsbi7.default.multiply(inputAmount.quotient, _9975);
|
|
602
|
+
const numerator = import_jsbi7.default.multiply(inputAmountWithFee, outputReserve.quotient);
|
|
603
|
+
const denominator = import_jsbi7.default.add(import_jsbi7.default.multiply(inputReserve.quotient, _10000), inputAmountWithFee);
|
|
604
|
+
const outputAmount = CurrencyAmount2.fromRawAmount(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0, import_jsbi7.default.divide(numerator, denominator));
|
|
605
|
+
if (import_jsbi7.default.equal(outputAmount.quotient, ZERO)) {
|
|
606
|
+
throw new InsufficientInputAmountError();
|
|
607
|
+
}
|
|
608
|
+
return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
609
|
+
}
|
|
610
|
+
getInputAmount(outputAmount) {
|
|
611
|
+
(0, import_tiny_invariant7.default)(this.involvesToken(outputAmount.currency), "TOKEN");
|
|
612
|
+
if (import_jsbi7.default.equal(this.reserve0.quotient, ZERO) || import_jsbi7.default.equal(this.reserve1.quotient, ZERO) || import_jsbi7.default.greaterThanOrEqual(outputAmount.quotient, this.reserveOf(outputAmount.currency).quotient)) {
|
|
613
|
+
throw new InsufficientReservesError();
|
|
614
|
+
}
|
|
615
|
+
const outputReserve = this.reserveOf(outputAmount.currency);
|
|
616
|
+
const inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
617
|
+
const numerator = import_jsbi7.default.multiply(import_jsbi7.default.multiply(inputReserve.quotient, outputAmount.quotient), _10000);
|
|
618
|
+
const denominator = import_jsbi7.default.multiply(import_jsbi7.default.subtract(outputReserve.quotient, outputAmount.quotient), _9975);
|
|
619
|
+
const inputAmount = CurrencyAmount2.fromRawAmount(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0, import_jsbi7.default.add(import_jsbi7.default.divide(numerator, denominator), ONE));
|
|
620
|
+
return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
621
|
+
}
|
|
622
|
+
getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {
|
|
623
|
+
(0, import_tiny_invariant7.default)(totalSupply.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
624
|
+
const tokenAmounts = tokenAmountA.currency.sortsBefore(tokenAmountB.currency) ? [tokenAmountA, tokenAmountB] : [tokenAmountB, tokenAmountA];
|
|
625
|
+
(0, import_tiny_invariant7.default)(tokenAmounts[0].currency.equals(this.token0) && tokenAmounts[1].currency.equals(this.token1), "TOKEN");
|
|
626
|
+
let liquidity;
|
|
627
|
+
if (import_jsbi7.default.equal(totalSupply.quotient, ZERO)) {
|
|
628
|
+
liquidity = import_jsbi7.default.subtract(sqrt(import_jsbi7.default.multiply(tokenAmounts[0].quotient, tokenAmounts[1].quotient)), MINIMUM_LIQUIDITY);
|
|
629
|
+
} else {
|
|
630
|
+
const amount0 = import_jsbi7.default.divide(import_jsbi7.default.multiply(tokenAmounts[0].quotient, totalSupply.quotient), this.reserve0.quotient);
|
|
631
|
+
const amount1 = import_jsbi7.default.divide(import_jsbi7.default.multiply(tokenAmounts[1].quotient, totalSupply.quotient), this.reserve1.quotient);
|
|
632
|
+
liquidity = import_jsbi7.default.lessThanOrEqual(amount0, amount1) ? amount0 : amount1;
|
|
633
|
+
}
|
|
634
|
+
if (!import_jsbi7.default.greaterThan(liquidity, ZERO)) {
|
|
635
|
+
throw new InsufficientInputAmountError();
|
|
636
|
+
}
|
|
637
|
+
return CurrencyAmount2.fromRawAmount(this.liquidityToken, liquidity);
|
|
638
|
+
}
|
|
639
|
+
getLiquidityValue(token, totalSupply, liquidity, feeOn = false, kLast) {
|
|
640
|
+
(0, import_tiny_invariant7.default)(this.involvesToken(token), "TOKEN");
|
|
641
|
+
(0, import_tiny_invariant7.default)(totalSupply.currency.equals(this.liquidityToken), "TOTAL_SUPPLY");
|
|
642
|
+
(0, import_tiny_invariant7.default)(liquidity.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
643
|
+
(0, import_tiny_invariant7.default)(import_jsbi7.default.lessThanOrEqual(liquidity.quotient, totalSupply.quotient), "LIQUIDITY");
|
|
644
|
+
let totalSupplyAdjusted;
|
|
645
|
+
if (!feeOn) {
|
|
646
|
+
totalSupplyAdjusted = totalSupply;
|
|
647
|
+
} else {
|
|
648
|
+
(0, import_tiny_invariant7.default)(!!kLast, "K_LAST");
|
|
649
|
+
const kLastParsed = import_jsbi7.default.BigInt(kLast);
|
|
650
|
+
if (!import_jsbi7.default.equal(kLastParsed, ZERO)) {
|
|
651
|
+
const rootK = sqrt(import_jsbi7.default.multiply(this.reserve0.quotient, this.reserve1.quotient));
|
|
652
|
+
const rootKLast = sqrt(kLastParsed);
|
|
653
|
+
if (import_jsbi7.default.greaterThan(rootK, rootKLast)) {
|
|
654
|
+
const numerator = import_jsbi7.default.multiply(totalSupply.quotient, import_jsbi7.default.subtract(rootK, rootKLast));
|
|
655
|
+
const denominator = import_jsbi7.default.add(import_jsbi7.default.multiply(rootK, FIVE), rootKLast);
|
|
656
|
+
const feeLiquidity = import_jsbi7.default.divide(numerator, denominator);
|
|
657
|
+
totalSupplyAdjusted = totalSupply.add(CurrencyAmount2.fromRawAmount(this.liquidityToken, feeLiquidity));
|
|
658
|
+
} else {
|
|
659
|
+
totalSupplyAdjusted = totalSupply;
|
|
660
|
+
}
|
|
661
|
+
} else {
|
|
662
|
+
totalSupplyAdjusted = totalSupply;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return CurrencyAmount2.fromRawAmount(token, import_jsbi7.default.divide(import_jsbi7.default.multiply(liquidity.quotient, this.reserveOf(token).quotient), totalSupplyAdjusted.quotient));
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
// src/entities/route.ts
|
|
670
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
671
|
+
var Route = class {
|
|
672
|
+
constructor(pairs, input, output) {
|
|
673
|
+
this._midPrice = null;
|
|
674
|
+
(0, import_tiny_invariant8.default)(pairs.length > 0, "PAIRS");
|
|
675
|
+
const chainId = pairs[0].chainId;
|
|
676
|
+
(0, import_tiny_invariant8.default)(pairs.every((pair) => pair.chainId === chainId), "CHAIN_IDS");
|
|
677
|
+
const wrappedInput = input.wrapped;
|
|
678
|
+
(0, import_tiny_invariant8.default)(pairs[0].involvesToken(wrappedInput), "INPUT");
|
|
679
|
+
(0, import_tiny_invariant8.default)(typeof output === "undefined" || pairs[pairs.length - 1].involvesToken(output.wrapped), "OUTPUT");
|
|
680
|
+
const path = [wrappedInput];
|
|
681
|
+
for (const [i, pair] of pairs.entries()) {
|
|
682
|
+
const currentInput = path[i];
|
|
683
|
+
(0, import_tiny_invariant8.default)(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), "PATH");
|
|
684
|
+
const output2 = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
|
|
685
|
+
path.push(output2);
|
|
686
|
+
}
|
|
687
|
+
this.pairs = pairs;
|
|
688
|
+
this.path = path;
|
|
689
|
+
this.input = input;
|
|
690
|
+
this.output = output;
|
|
691
|
+
}
|
|
692
|
+
get midPrice() {
|
|
693
|
+
if (this._midPrice !== null)
|
|
694
|
+
return this._midPrice;
|
|
695
|
+
const prices = [];
|
|
696
|
+
for (const [i, pair] of this.pairs.entries()) {
|
|
697
|
+
prices.push(this.path[i].equals(pair.token0) ? new Price2(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new Price2(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient));
|
|
698
|
+
}
|
|
699
|
+
const reduced = prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]);
|
|
700
|
+
return this._midPrice = new Price2(this.input, this.output, reduced.denominator, reduced.numerator);
|
|
701
|
+
}
|
|
702
|
+
get chainId() {
|
|
703
|
+
return this.pairs[0].chainId;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// src/entities/trade.ts
|
|
708
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
709
|
+
function inputOutputComparator(a, b) {
|
|
710
|
+
(0, import_tiny_invariant9.default)(a.inputAmount.currency.equals(b.inputAmount.currency), "INPUT_CURRENCY");
|
|
711
|
+
(0, import_tiny_invariant9.default)(a.outputAmount.currency.equals(b.outputAmount.currency), "OUTPUT_CURRENCY");
|
|
712
|
+
if (a.outputAmount.equalTo(b.outputAmount)) {
|
|
713
|
+
if (a.inputAmount.equalTo(b.inputAmount)) {
|
|
714
|
+
return 0;
|
|
715
|
+
}
|
|
716
|
+
if (a.inputAmount.lessThan(b.inputAmount)) {
|
|
717
|
+
return -1;
|
|
718
|
+
} else {
|
|
719
|
+
return 1;
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
if (a.outputAmount.lessThan(b.outputAmount)) {
|
|
723
|
+
return 1;
|
|
724
|
+
} else {
|
|
725
|
+
return -1;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function tradeComparator(a, b) {
|
|
730
|
+
const ioComp = inputOutputComparator(a, b);
|
|
731
|
+
if (ioComp !== 0) {
|
|
732
|
+
return ioComp;
|
|
733
|
+
}
|
|
734
|
+
if (a.priceImpact.lessThan(b.priceImpact)) {
|
|
735
|
+
return -1;
|
|
736
|
+
} else if (a.priceImpact.greaterThan(b.priceImpact)) {
|
|
737
|
+
return 1;
|
|
738
|
+
}
|
|
739
|
+
return a.route.path.length - b.route.path.length;
|
|
740
|
+
}
|
|
741
|
+
var Trade = class {
|
|
742
|
+
static exactIn(route, amountIn) {
|
|
743
|
+
return new Trade(route, amountIn, 0 /* EXACT_INPUT */);
|
|
744
|
+
}
|
|
745
|
+
static exactOut(route, amountOut) {
|
|
746
|
+
return new Trade(route, amountOut, 1 /* EXACT_OUTPUT */);
|
|
747
|
+
}
|
|
748
|
+
constructor(route, amount, tradeType) {
|
|
749
|
+
this.route = route;
|
|
750
|
+
this.tradeType = tradeType;
|
|
751
|
+
const tokenAmounts = new Array(route.path.length);
|
|
752
|
+
if (tradeType === 0 /* EXACT_INPUT */) {
|
|
753
|
+
(0, import_tiny_invariant9.default)(amount.currency.equals(route.input), "INPUT");
|
|
754
|
+
tokenAmounts[0] = amount.wrapped;
|
|
755
|
+
for (let i = 0; i < route.path.length - 1; i++) {
|
|
756
|
+
const pair = route.pairs[i];
|
|
757
|
+
const [outputAmount] = pair.getOutputAmount(tokenAmounts[i]);
|
|
758
|
+
tokenAmounts[i + 1] = outputAmount;
|
|
759
|
+
}
|
|
760
|
+
this.inputAmount = CurrencyAmount2.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
761
|
+
this.outputAmount = CurrencyAmount2.fromFractionalAmount(route.output, tokenAmounts[tokenAmounts.length - 1].numerator, tokenAmounts[tokenAmounts.length - 1].denominator);
|
|
762
|
+
} else {
|
|
763
|
+
(0, import_tiny_invariant9.default)(amount.currency.equals(route.output), "OUTPUT");
|
|
764
|
+
tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
|
|
765
|
+
for (let i = route.path.length - 1; i > 0; i--) {
|
|
766
|
+
const pair = route.pairs[i - 1];
|
|
767
|
+
const [inputAmount] = pair.getInputAmount(tokenAmounts[i]);
|
|
768
|
+
tokenAmounts[i - 1] = inputAmount;
|
|
769
|
+
}
|
|
770
|
+
this.inputAmount = CurrencyAmount2.fromFractionalAmount(route.input, tokenAmounts[0].numerator, tokenAmounts[0].denominator);
|
|
771
|
+
this.outputAmount = CurrencyAmount2.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
|
|
772
|
+
}
|
|
773
|
+
this.executionPrice = new Price2(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);
|
|
774
|
+
this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
|
|
775
|
+
}
|
|
776
|
+
minimumAmountOut(slippageTolerance) {
|
|
777
|
+
(0, import_tiny_invariant9.default)(!slippageTolerance.lessThan(ZERO), "SLIPPAGE_TOLERANCE");
|
|
778
|
+
if (this.tradeType === 1 /* EXACT_OUTPUT */) {
|
|
779
|
+
return this.outputAmount;
|
|
780
|
+
} else {
|
|
781
|
+
const slippageAdjustedAmountOut = new Fraction(ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
|
|
782
|
+
return CurrencyAmount2.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
maximumAmountIn(slippageTolerance) {
|
|
786
|
+
(0, import_tiny_invariant9.default)(!slippageTolerance.lessThan(ZERO), "SLIPPAGE_TOLERANCE");
|
|
787
|
+
if (this.tradeType === 0 /* EXACT_INPUT */) {
|
|
788
|
+
return this.inputAmount;
|
|
789
|
+
} else {
|
|
790
|
+
const slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
|
|
791
|
+
return CurrencyAmount2.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
static bestTradeExactIn(pairs, currencyAmountIn, currencyOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountIn = currencyAmountIn, bestTrades = []) {
|
|
795
|
+
(0, import_tiny_invariant9.default)(pairs.length > 0, "PAIRS");
|
|
796
|
+
(0, import_tiny_invariant9.default)(maxHops > 0, "MAX_HOPS");
|
|
797
|
+
(0, import_tiny_invariant9.default)(currencyAmountIn === nextAmountIn || currentPairs.length > 0, "INVALID_RECURSION");
|
|
798
|
+
const amountIn = nextAmountIn.wrapped;
|
|
799
|
+
const tokenOut = currencyOut.wrapped;
|
|
800
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
801
|
+
const pair = pairs[i];
|
|
802
|
+
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency))
|
|
803
|
+
continue;
|
|
804
|
+
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO))
|
|
805
|
+
continue;
|
|
806
|
+
let amountOut;
|
|
807
|
+
try {
|
|
808
|
+
;
|
|
809
|
+
[amountOut] = pair.getOutputAmount(amountIn);
|
|
810
|
+
} catch (error) {
|
|
811
|
+
if (error.isInsufficientInputAmountError) {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
816
|
+
if (amountOut.currency.equals(tokenOut)) {
|
|
817
|
+
sortedInsert(bestTrades, new Trade(new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut), currencyAmountIn, 0 /* EXACT_INPUT */), maxNumResults, tradeComparator);
|
|
818
|
+
} else if (maxHops > 1 && pairs.length > 1) {
|
|
819
|
+
const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
|
|
820
|
+
Trade.bestTradeExactIn(pairsExcludingThisPair, currencyAmountIn, currencyOut, {
|
|
821
|
+
maxNumResults,
|
|
822
|
+
maxHops: maxHops - 1
|
|
823
|
+
}, [...currentPairs, pair], amountOut, bestTrades);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return bestTrades;
|
|
827
|
+
}
|
|
828
|
+
worstExecutionPrice(slippageTolerance) {
|
|
829
|
+
return new Price2(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
830
|
+
}
|
|
831
|
+
static bestTradeExactOut(pairs, currencyIn, currencyAmountOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountOut = currencyAmountOut, bestTrades = []) {
|
|
832
|
+
(0, import_tiny_invariant9.default)(pairs.length > 0, "PAIRS");
|
|
833
|
+
(0, import_tiny_invariant9.default)(maxHops > 0, "MAX_HOPS");
|
|
834
|
+
(0, import_tiny_invariant9.default)(currencyAmountOut === nextAmountOut || currentPairs.length > 0, "INVALID_RECURSION");
|
|
835
|
+
const amountOut = nextAmountOut.wrapped;
|
|
836
|
+
const tokenIn = currencyIn.wrapped;
|
|
837
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
838
|
+
const pair = pairs[i];
|
|
839
|
+
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency))
|
|
840
|
+
continue;
|
|
841
|
+
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO))
|
|
842
|
+
continue;
|
|
843
|
+
let amountIn;
|
|
844
|
+
try {
|
|
845
|
+
;
|
|
846
|
+
[amountIn] = pair.getInputAmount(amountOut);
|
|
847
|
+
} catch (error) {
|
|
848
|
+
if (error.isInsufficientReservesError) {
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
throw error;
|
|
852
|
+
}
|
|
853
|
+
if (amountIn.currency.equals(tokenIn)) {
|
|
854
|
+
sortedInsert(bestTrades, new Trade(new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency), currencyAmountOut, 1 /* EXACT_OUTPUT */), maxNumResults, tradeComparator);
|
|
855
|
+
} else if (maxHops > 1 && pairs.length > 1) {
|
|
856
|
+
const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
|
|
857
|
+
Trade.bestTradeExactOut(pairsExcludingThisPair, currencyIn, currencyAmountOut, {
|
|
858
|
+
maxNumResults,
|
|
859
|
+
maxHops: maxHops - 1
|
|
860
|
+
}, [pair, ...currentPairs], amountIn, bestTrades);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return bestTrades;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// src/entities/nativeCurrency.ts
|
|
868
|
+
var NativeCurrency = class extends BaseCurrency {
|
|
869
|
+
constructor() {
|
|
870
|
+
super(...arguments);
|
|
871
|
+
this.isNative = true;
|
|
872
|
+
this.isToken = false;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
// src/entities/native.ts
|
|
877
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
878
|
+
var _Native = class extends NativeCurrency {
|
|
879
|
+
constructor({
|
|
880
|
+
chainId,
|
|
881
|
+
decimals,
|
|
882
|
+
name,
|
|
883
|
+
symbol
|
|
884
|
+
}) {
|
|
885
|
+
super(chainId, decimals, symbol, name);
|
|
886
|
+
}
|
|
887
|
+
get wrapped() {
|
|
888
|
+
const wnative = WNATIVE[this.chainId];
|
|
889
|
+
(0, import_tiny_invariant10.default)(!!wnative, "WRAPPED");
|
|
890
|
+
return wnative;
|
|
891
|
+
}
|
|
892
|
+
static onChain(chainId) {
|
|
893
|
+
if (chainId in this.cache) {
|
|
894
|
+
return this.cache[chainId];
|
|
895
|
+
}
|
|
896
|
+
(0, import_tiny_invariant10.default)(!!NATIVE[chainId], "NATIVE_CURRENCY");
|
|
897
|
+
const { decimals, name, symbol } = NATIVE[chainId];
|
|
898
|
+
return this.cache[chainId] = new _Native({ chainId, decimals, symbol, name });
|
|
899
|
+
}
|
|
900
|
+
equals(other) {
|
|
901
|
+
return other.isNative && other.chainId === this.chainId;
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
var Native = _Native;
|
|
905
|
+
Native.cache = {};
|
|
906
|
+
|
|
907
|
+
// src/router.ts
|
|
908
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
909
|
+
function toHex(currencyAmount) {
|
|
910
|
+
return `0x${currencyAmount.quotient.toString(16)}`;
|
|
8
911
|
}
|
|
912
|
+
var ZERO_HEX = "0x0";
|
|
913
|
+
var Router = class {
|
|
914
|
+
constructor() {
|
|
915
|
+
}
|
|
916
|
+
static swapCallParameters(trade, options) {
|
|
917
|
+
const etherIn = trade.inputAmount.currency.isNative;
|
|
918
|
+
const etherOut = trade.outputAmount.currency.isNative;
|
|
919
|
+
(0, import_tiny_invariant11.default)(!(etherIn && etherOut), "ETHER_IN_OUT");
|
|
920
|
+
(0, import_tiny_invariant11.default)(!("ttl" in options) || options.ttl > 0, "TTL");
|
|
921
|
+
const to = validateAndParseAddress(options.recipient);
|
|
922
|
+
const amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));
|
|
923
|
+
const amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));
|
|
924
|
+
const path = trade.route.path.map((token) => token.address);
|
|
925
|
+
const deadline = "ttl" in options ? `0x${(Math.floor(new Date().getTime() / 1e3) + options.ttl).toString(16)}` : `0x${options.deadline.toString(16)}`;
|
|
926
|
+
const useFeeOnTransfer = Boolean(options.feeOnTransfer);
|
|
927
|
+
let methodName;
|
|
928
|
+
let args;
|
|
929
|
+
let value;
|
|
930
|
+
switch (trade.tradeType) {
|
|
931
|
+
case 0 /* EXACT_INPUT */:
|
|
932
|
+
if (etherIn) {
|
|
933
|
+
methodName = useFeeOnTransfer ? "swapExactETHForTokensSupportingFeeOnTransferTokens" : "swapExactETHForTokens";
|
|
934
|
+
args = [amountOut, path, to, deadline];
|
|
935
|
+
value = amountIn;
|
|
936
|
+
} else if (etherOut) {
|
|
937
|
+
methodName = useFeeOnTransfer ? "swapExactTokensForETHSupportingFeeOnTransferTokens" : "swapExactTokensForETH";
|
|
938
|
+
args = [amountIn, amountOut, path, to, deadline];
|
|
939
|
+
value = ZERO_HEX;
|
|
940
|
+
} else {
|
|
941
|
+
methodName = useFeeOnTransfer ? "swapExactTokensForTokensSupportingFeeOnTransferTokens" : "swapExactTokensForTokens";
|
|
942
|
+
args = [amountIn, amountOut, path, to, deadline];
|
|
943
|
+
value = ZERO_HEX;
|
|
944
|
+
}
|
|
945
|
+
break;
|
|
946
|
+
case 1 /* EXACT_OUTPUT */:
|
|
947
|
+
(0, import_tiny_invariant11.default)(!useFeeOnTransfer, "EXACT_OUT_FOT");
|
|
948
|
+
if (etherIn) {
|
|
949
|
+
methodName = "swapETHForExactTokens";
|
|
950
|
+
args = [amountOut, path, to, deadline];
|
|
951
|
+
value = amountIn;
|
|
952
|
+
} else if (etherOut) {
|
|
953
|
+
methodName = "swapTokensForExactETH";
|
|
954
|
+
args = [amountOut, amountIn, path, to, deadline];
|
|
955
|
+
value = ZERO_HEX;
|
|
956
|
+
} else {
|
|
957
|
+
methodName = "swapTokensForExactTokens";
|
|
958
|
+
args = [amountOut, amountIn, path, to, deadline];
|
|
959
|
+
value = ZERO_HEX;
|
|
960
|
+
}
|
|
961
|
+
break;
|
|
962
|
+
}
|
|
963
|
+
return {
|
|
964
|
+
methodName,
|
|
965
|
+
args,
|
|
966
|
+
value
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
971
|
+
0 && (module.exports = {
|
|
972
|
+
BaseCurrency,
|
|
973
|
+
ChainId,
|
|
974
|
+
CurrencyAmount,
|
|
975
|
+
FACTORY_ADDRESS,
|
|
976
|
+
FACTORY_ADDRESS_MAP,
|
|
977
|
+
FIVE,
|
|
978
|
+
Fraction,
|
|
979
|
+
INIT_CODE_HASH,
|
|
980
|
+
INIT_CODE_HASH_MAP,
|
|
981
|
+
InsufficientInputAmountError,
|
|
982
|
+
InsufficientReservesError,
|
|
983
|
+
JSBI,
|
|
984
|
+
MINIMUM_LIQUIDITY,
|
|
985
|
+
MaxUint256,
|
|
986
|
+
NATIVE,
|
|
987
|
+
Native,
|
|
988
|
+
NativeCurrency,
|
|
989
|
+
ONE,
|
|
990
|
+
Pair,
|
|
991
|
+
Percent,
|
|
992
|
+
Price,
|
|
993
|
+
Rounding,
|
|
994
|
+
Route,
|
|
995
|
+
Router,
|
|
996
|
+
SOLIDITY_TYPE_MAXIMA,
|
|
997
|
+
SolidityType,
|
|
998
|
+
TEN,
|
|
999
|
+
THREE,
|
|
1000
|
+
TWO,
|
|
1001
|
+
Token,
|
|
1002
|
+
Trade,
|
|
1003
|
+
TradeType,
|
|
1004
|
+
WBNB,
|
|
1005
|
+
WETH9,
|
|
1006
|
+
WNATIVE,
|
|
1007
|
+
ZERO,
|
|
1008
|
+
_100,
|
|
1009
|
+
_10000,
|
|
1010
|
+
_9975,
|
|
1011
|
+
computePairAddress,
|
|
1012
|
+
computePriceImpact,
|
|
1013
|
+
inputOutputComparator,
|
|
1014
|
+
tradeComparator
|
|
1015
|
+
});
|