@pancakeswap/sdk 3.1.0 → 3.1.2
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/README.md +1 -1
- package/dist/index.d.ts +28 -274
- package/dist/index.js +126 -556
- package/dist/index.mjs +132 -518
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -17,74 +17,43 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
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
22
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
23
|
|
|
23
24
|
// src/index.ts
|
|
24
25
|
var src_exports = {};
|
|
25
26
|
__export(src_exports, {
|
|
26
|
-
BaseCurrency: () => BaseCurrency,
|
|
27
27
|
ChainId: () => ChainId,
|
|
28
|
-
|
|
28
|
+
ERC20Token: () => ERC20Token,
|
|
29
29
|
FACTORY_ADDRESS: () => FACTORY_ADDRESS,
|
|
30
30
|
FACTORY_ADDRESS_MAP: () => FACTORY_ADDRESS_MAP,
|
|
31
|
-
FIVE: () => FIVE,
|
|
32
|
-
Fraction: () => Fraction,
|
|
33
31
|
INIT_CODE_HASH: () => INIT_CODE_HASH,
|
|
34
32
|
INIT_CODE_HASH_MAP: () => INIT_CODE_HASH_MAP,
|
|
35
|
-
|
|
36
|
-
InsufficientReservesError: () => InsufficientReservesError,
|
|
37
|
-
JSBI: () => import_jsbi8.default,
|
|
38
|
-
MINIMUM_LIQUIDITY: () => MINIMUM_LIQUIDITY,
|
|
39
|
-
MaxUint256: () => MaxUint256,
|
|
33
|
+
JSBI: () => import_jsbi2.default,
|
|
40
34
|
NATIVE: () => NATIVE,
|
|
41
35
|
Native: () => Native,
|
|
42
|
-
NativeCurrency: () => NativeCurrency,
|
|
43
|
-
ONE: () => ONE,
|
|
44
36
|
Pair: () => Pair,
|
|
45
|
-
Percent: () => Percent,
|
|
46
|
-
Price: () => Price2,
|
|
47
|
-
Rounding: () => Rounding,
|
|
48
37
|
Route: () => Route,
|
|
49
38
|
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
39
|
Trade: () => Trade,
|
|
57
|
-
TradeType: () => TradeType,
|
|
58
40
|
WBNB: () => WBNB,
|
|
59
41
|
WETH9: () => WETH9,
|
|
60
42
|
WNATIVE: () => WNATIVE,
|
|
61
|
-
ZERO: () => ZERO,
|
|
62
|
-
_100: () => _100,
|
|
63
|
-
_10000: () => _10000,
|
|
64
|
-
_9975: () => _9975,
|
|
65
43
|
computePairAddress: () => computePairAddress,
|
|
66
|
-
computePriceImpact: () => computePriceImpact,
|
|
67
44
|
inputOutputComparator: () => inputOutputComparator,
|
|
68
45
|
tradeComparator: () => tradeComparator
|
|
69
46
|
});
|
|
70
47
|
module.exports = __toCommonJS(src_exports);
|
|
71
|
-
var import_jsbi8 = __toESM(require("jsbi"));
|
|
72
|
-
|
|
73
|
-
// src/constants.ts
|
|
74
48
|
var import_jsbi2 = __toESM(require("jsbi"));
|
|
75
49
|
|
|
76
50
|
// src/entities/token.ts
|
|
77
|
-
var
|
|
51
|
+
var import_swap_sdk_core = require("@pancakeswap/swap-sdk-core");
|
|
78
52
|
|
|
79
53
|
// src/utils.ts
|
|
54
|
+
var import_address = require("@ethersproject/address");
|
|
80
55
|
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
81
56
|
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
57
|
function validateAndParseAddress(address) {
|
|
89
58
|
try {
|
|
90
59
|
const checksummedAddress = (0, import_address.getAddress)(address);
|
|
@@ -94,122 +63,26 @@ function validateAndParseAddress(address) {
|
|
|
94
63
|
(0, import_tiny_invariant.default)(false, `${address} is not a valid address.`);
|
|
95
64
|
}
|
|
96
65
|
}
|
|
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
66
|
|
|
156
67
|
// src/entities/token.ts
|
|
157
|
-
var
|
|
68
|
+
var ERC20Token = class extends import_swap_sdk_core.Token {
|
|
158
69
|
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
|
-
};
|
|
70
|
+
super(chainId, validateAndParseAddress(address), decimals, symbol, name, projectLink);
|
|
185
71
|
}
|
|
186
72
|
};
|
|
187
73
|
|
|
188
74
|
// src/constants.ts
|
|
189
75
|
var ChainId = /* @__PURE__ */ ((ChainId2) => {
|
|
190
76
|
ChainId2[ChainId2["ETHEREUM"] = 1] = "ETHEREUM";
|
|
191
|
-
ChainId2[ChainId2["RINKEBY"] = 4] = "RINKEBY";
|
|
192
77
|
ChainId2[ChainId2["GOERLI"] = 5] = "GOERLI";
|
|
193
78
|
ChainId2[ChainId2["BSC"] = 56] = "BSC";
|
|
194
79
|
ChainId2[ChainId2["BSC_TESTNET"] = 97] = "BSC_TESTNET";
|
|
195
80
|
return ChainId2;
|
|
196
81
|
})(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
82
|
var FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
|
|
209
83
|
var FACTORY_ADDRESS_ETH = "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362";
|
|
210
84
|
var FACTORY_ADDRESS_MAP = {
|
|
211
85
|
[1 /* ETHEREUM */]: FACTORY_ADDRESS_ETH,
|
|
212
|
-
[4 /* RINKEBY */]: FACTORY_ADDRESS_ETH,
|
|
213
86
|
[5 /* GOERLI */]: FACTORY_ADDRESS_ETH,
|
|
214
87
|
[56 /* BSC */]: FACTORY_ADDRESS,
|
|
215
88
|
[97 /* BSC_TESTNET */]: "0x6725f303b657a9451d8ba641348b6761a6cc7a17"
|
|
@@ -218,51 +91,27 @@ var INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a
|
|
|
218
91
|
var INIT_CODE_HASH_ETH = "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d";
|
|
219
92
|
var INIT_CODE_HASH_MAP = {
|
|
220
93
|
[1 /* ETHEREUM */]: INIT_CODE_HASH_ETH,
|
|
221
|
-
[4 /* RINKEBY */]: INIT_CODE_HASH_ETH,
|
|
222
94
|
[5 /* GOERLI */]: INIT_CODE_HASH_ETH,
|
|
223
95
|
[56 /* BSC */]: INIT_CODE_HASH,
|
|
224
96
|
[97 /* BSC_TESTNET */]: "0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66"
|
|
225
97
|
};
|
|
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
98
|
var WETH9 = {
|
|
247
|
-
[1 /* ETHEREUM */]: new
|
|
248
|
-
[
|
|
249
|
-
[5 /* GOERLI */]: new Token(5 /* GOERLI */, "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", 18, "WETH", "Wrapped Ether", "https://weth.io")
|
|
99
|
+
[1 /* ETHEREUM */]: new ERC20Token(1 /* ETHEREUM */, "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 18, "WETH", "Wrapped Ether", "https://weth.io"),
|
|
100
|
+
[5 /* GOERLI */]: new ERC20Token(5 /* GOERLI */, "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", 18, "WETH", "Wrapped Ether", "https://weth.io")
|
|
250
101
|
};
|
|
251
102
|
var WBNB = {
|
|
252
|
-
[1 /* ETHEREUM */]: new
|
|
253
|
-
[56 /* BSC */]: new
|
|
254
|
-
[97 /* BSC_TESTNET */]: new
|
|
103
|
+
[1 /* ETHEREUM */]: new ERC20Token(1 /* ETHEREUM */, "0x418D75f65a02b3D53B2418FB8E1fe493759c7605", 18, "WBNB", "Wrapped BNB", "https://www.binance.org"),
|
|
104
|
+
[56 /* BSC */]: new ERC20Token(56 /* BSC */, "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", 18, "WBNB", "Wrapped BNB", "https://www.binance.org"),
|
|
105
|
+
[97 /* BSC_TESTNET */]: new ERC20Token(97 /* BSC_TESTNET */, "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", 18, "WBNB", "Wrapped BNB", "https://www.binance.org")
|
|
255
106
|
};
|
|
256
107
|
var WNATIVE = {
|
|
257
108
|
[1 /* ETHEREUM */]: WETH9[1 /* ETHEREUM */],
|
|
258
|
-
[4 /* RINKEBY */]: WETH9[4 /* RINKEBY */],
|
|
259
109
|
[5 /* GOERLI */]: WETH9[5 /* GOERLI */],
|
|
260
110
|
[56 /* BSC */]: WBNB[56 /* BSC */],
|
|
261
111
|
[97 /* BSC_TESTNET */]: WBNB[97 /* BSC_TESTNET */]
|
|
262
112
|
};
|
|
263
113
|
var NATIVE = {
|
|
264
114
|
[1 /* ETHEREUM */]: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
265
|
-
[4 /* RINKEBY */]: { name: "Rinkeby Ether", symbol: "RIN", decimals: 18 },
|
|
266
115
|
[5 /* GOERLI */]: { name: "Goerli Ether", symbol: "GOR", decimals: 18 },
|
|
267
116
|
[56 /* BSC */]: {
|
|
268
117
|
name: "Binance Chain Native Token",
|
|
@@ -276,261 +125,12 @@ var NATIVE = {
|
|
|
276
125
|
}
|
|
277
126
|
};
|
|
278
127
|
|
|
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
128
|
// src/entities/pair.ts
|
|
129
|
+
var import_swap_sdk_core2 = require("@pancakeswap/swap-sdk-core");
|
|
301
130
|
var import_address2 = require("@ethersproject/address");
|
|
302
131
|
var import_solidity = require("@ethersproject/solidity");
|
|
303
|
-
var
|
|
304
|
-
var
|
|
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
|
|
132
|
+
var import_jsbi = __toESM(require("jsbi"));
|
|
133
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
534
134
|
var PAIR_ADDRESS_CACHE = {};
|
|
535
135
|
var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
|
|
536
136
|
var computePairAddress = ({
|
|
@@ -554,7 +154,7 @@ var Pair = class {
|
|
|
554
154
|
}
|
|
555
155
|
constructor(currencyAmountA, tokenAmountB) {
|
|
556
156
|
const tokenAmounts = currencyAmountA.currency.sortsBefore(tokenAmountB.currency) ? [currencyAmountA, tokenAmountB] : [tokenAmountB, currencyAmountA];
|
|
557
|
-
this.liquidityToken = new
|
|
157
|
+
this.liquidityToken = new ERC20Token(tokenAmounts[0].currency.chainId, Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency), 18, "Cake-LP", "Pancake LPs");
|
|
558
158
|
this.tokenAmounts = tokenAmounts;
|
|
559
159
|
}
|
|
560
160
|
involvesToken(token) {
|
|
@@ -562,14 +162,14 @@ var Pair = class {
|
|
|
562
162
|
}
|
|
563
163
|
get token0Price() {
|
|
564
164
|
const result = this.tokenAmounts[1].divide(this.tokenAmounts[0]);
|
|
565
|
-
return new
|
|
165
|
+
return new import_swap_sdk_core2.Price(this.token0, this.token1, result.denominator, result.numerator);
|
|
566
166
|
}
|
|
567
167
|
get token1Price() {
|
|
568
168
|
const result = this.tokenAmounts[0].divide(this.tokenAmounts[1]);
|
|
569
|
-
return new
|
|
169
|
+
return new import_swap_sdk_core2.Price(this.token1, this.token0, result.denominator, result.numerator);
|
|
570
170
|
}
|
|
571
171
|
priceOf(token) {
|
|
572
|
-
(0,
|
|
172
|
+
(0, import_tiny_invariant2.default)(this.involvesToken(token), "TOKEN");
|
|
573
173
|
return token.equals(this.token0) ? this.token0Price : this.token1Price;
|
|
574
174
|
}
|
|
575
175
|
get chainId() {
|
|
@@ -588,73 +188,73 @@ var Pair = class {
|
|
|
588
188
|
return this.tokenAmounts[1];
|
|
589
189
|
}
|
|
590
190
|
reserveOf(token) {
|
|
591
|
-
(0,
|
|
191
|
+
(0, import_tiny_invariant2.default)(this.involvesToken(token), "TOKEN");
|
|
592
192
|
return token.equals(this.token0) ? this.reserve0 : this.reserve1;
|
|
593
193
|
}
|
|
594
194
|
getOutputAmount(inputAmount) {
|
|
595
|
-
(0,
|
|
596
|
-
if (
|
|
597
|
-
throw new InsufficientReservesError();
|
|
195
|
+
(0, import_tiny_invariant2.default)(this.involvesToken(inputAmount.currency), "TOKEN");
|
|
196
|
+
if (import_jsbi.default.equal(this.reserve0.quotient, import_swap_sdk_core2.ZERO) || import_jsbi.default.equal(this.reserve1.quotient, import_swap_sdk_core2.ZERO)) {
|
|
197
|
+
throw new import_swap_sdk_core2.InsufficientReservesError();
|
|
598
198
|
}
|
|
599
199
|
const inputReserve = this.reserveOf(inputAmount.currency);
|
|
600
200
|
const outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
601
|
-
const inputAmountWithFee =
|
|
602
|
-
const numerator =
|
|
603
|
-
const denominator =
|
|
604
|
-
const outputAmount =
|
|
605
|
-
if (
|
|
606
|
-
throw new InsufficientInputAmountError();
|
|
201
|
+
const inputAmountWithFee = import_jsbi.default.multiply(inputAmount.quotient, import_swap_sdk_core2._9975);
|
|
202
|
+
const numerator = import_jsbi.default.multiply(inputAmountWithFee, outputReserve.quotient);
|
|
203
|
+
const denominator = import_jsbi.default.add(import_jsbi.default.multiply(inputReserve.quotient, import_swap_sdk_core2._10000), inputAmountWithFee);
|
|
204
|
+
const outputAmount = import_swap_sdk_core2.CurrencyAmount.fromRawAmount(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0, import_jsbi.default.divide(numerator, denominator));
|
|
205
|
+
if (import_jsbi.default.equal(outputAmount.quotient, import_swap_sdk_core2.ZERO)) {
|
|
206
|
+
throw new import_swap_sdk_core2.InsufficientInputAmountError();
|
|
607
207
|
}
|
|
608
208
|
return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
609
209
|
}
|
|
610
210
|
getInputAmount(outputAmount) {
|
|
611
|
-
(0,
|
|
612
|
-
if (
|
|
613
|
-
throw new InsufficientReservesError();
|
|
211
|
+
(0, import_tiny_invariant2.default)(this.involvesToken(outputAmount.currency), "TOKEN");
|
|
212
|
+
if (import_jsbi.default.equal(this.reserve0.quotient, import_swap_sdk_core2.ZERO) || import_jsbi.default.equal(this.reserve1.quotient, import_swap_sdk_core2.ZERO) || import_jsbi.default.greaterThanOrEqual(outputAmount.quotient, this.reserveOf(outputAmount.currency).quotient)) {
|
|
213
|
+
throw new import_swap_sdk_core2.InsufficientReservesError();
|
|
614
214
|
}
|
|
615
215
|
const outputReserve = this.reserveOf(outputAmount.currency);
|
|
616
216
|
const inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
617
|
-
const numerator =
|
|
618
|
-
const denominator =
|
|
619
|
-
const inputAmount =
|
|
217
|
+
const numerator = import_jsbi.default.multiply(import_jsbi.default.multiply(inputReserve.quotient, outputAmount.quotient), import_swap_sdk_core2._10000);
|
|
218
|
+
const denominator = import_jsbi.default.multiply(import_jsbi.default.subtract(outputReserve.quotient, outputAmount.quotient), import_swap_sdk_core2._9975);
|
|
219
|
+
const inputAmount = import_swap_sdk_core2.CurrencyAmount.fromRawAmount(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0, import_jsbi.default.add(import_jsbi.default.divide(numerator, denominator), import_swap_sdk_core2.ONE));
|
|
620
220
|
return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
621
221
|
}
|
|
622
222
|
getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {
|
|
623
|
-
(0,
|
|
223
|
+
(0, import_tiny_invariant2.default)(totalSupply.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
624
224
|
const tokenAmounts = tokenAmountA.currency.sortsBefore(tokenAmountB.currency) ? [tokenAmountA, tokenAmountB] : [tokenAmountB, tokenAmountA];
|
|
625
|
-
(0,
|
|
225
|
+
(0, import_tiny_invariant2.default)(tokenAmounts[0].currency.equals(this.token0) && tokenAmounts[1].currency.equals(this.token1), "TOKEN");
|
|
626
226
|
let liquidity;
|
|
627
|
-
if (
|
|
628
|
-
liquidity =
|
|
227
|
+
if (import_jsbi.default.equal(totalSupply.quotient, import_swap_sdk_core2.ZERO)) {
|
|
228
|
+
liquidity = import_jsbi.default.subtract((0, import_swap_sdk_core2.sqrt)(import_jsbi.default.multiply(tokenAmounts[0].quotient, tokenAmounts[1].quotient)), import_swap_sdk_core2.MINIMUM_LIQUIDITY);
|
|
629
229
|
} else {
|
|
630
|
-
const amount0 =
|
|
631
|
-
const amount1 =
|
|
632
|
-
liquidity =
|
|
230
|
+
const amount0 = import_jsbi.default.divide(import_jsbi.default.multiply(tokenAmounts[0].quotient, totalSupply.quotient), this.reserve0.quotient);
|
|
231
|
+
const amount1 = import_jsbi.default.divide(import_jsbi.default.multiply(tokenAmounts[1].quotient, totalSupply.quotient), this.reserve1.quotient);
|
|
232
|
+
liquidity = import_jsbi.default.lessThanOrEqual(amount0, amount1) ? amount0 : amount1;
|
|
633
233
|
}
|
|
634
|
-
if (!
|
|
635
|
-
throw new InsufficientInputAmountError();
|
|
234
|
+
if (!import_jsbi.default.greaterThan(liquidity, import_swap_sdk_core2.ZERO)) {
|
|
235
|
+
throw new import_swap_sdk_core2.InsufficientInputAmountError();
|
|
636
236
|
}
|
|
637
|
-
return
|
|
237
|
+
return import_swap_sdk_core2.CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity);
|
|
638
238
|
}
|
|
639
239
|
getLiquidityValue(token, totalSupply, liquidity, feeOn = false, kLast) {
|
|
640
|
-
(0,
|
|
641
|
-
(0,
|
|
642
|
-
(0,
|
|
643
|
-
(0,
|
|
240
|
+
(0, import_tiny_invariant2.default)(this.involvesToken(token), "TOKEN");
|
|
241
|
+
(0, import_tiny_invariant2.default)(totalSupply.currency.equals(this.liquidityToken), "TOTAL_SUPPLY");
|
|
242
|
+
(0, import_tiny_invariant2.default)(liquidity.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
243
|
+
(0, import_tiny_invariant2.default)(import_jsbi.default.lessThanOrEqual(liquidity.quotient, totalSupply.quotient), "LIQUIDITY");
|
|
644
244
|
let totalSupplyAdjusted;
|
|
645
245
|
if (!feeOn) {
|
|
646
246
|
totalSupplyAdjusted = totalSupply;
|
|
647
247
|
} else {
|
|
648
|
-
(0,
|
|
649
|
-
const kLastParsed =
|
|
650
|
-
if (!
|
|
651
|
-
const rootK = sqrt(
|
|
652
|
-
const rootKLast = sqrt(kLastParsed);
|
|
653
|
-
if (
|
|
654
|
-
const numerator =
|
|
655
|
-
const denominator =
|
|
656
|
-
const feeLiquidity =
|
|
657
|
-
totalSupplyAdjusted = totalSupply.add(
|
|
248
|
+
(0, import_tiny_invariant2.default)(!!kLast, "K_LAST");
|
|
249
|
+
const kLastParsed = import_jsbi.default.BigInt(kLast);
|
|
250
|
+
if (!import_jsbi.default.equal(kLastParsed, import_swap_sdk_core2.ZERO)) {
|
|
251
|
+
const rootK = (0, import_swap_sdk_core2.sqrt)(import_jsbi.default.multiply(this.reserve0.quotient, this.reserve1.quotient));
|
|
252
|
+
const rootKLast = (0, import_swap_sdk_core2.sqrt)(kLastParsed);
|
|
253
|
+
if (import_jsbi.default.greaterThan(rootK, rootKLast)) {
|
|
254
|
+
const numerator = import_jsbi.default.multiply(totalSupply.quotient, import_jsbi.default.subtract(rootK, rootKLast));
|
|
255
|
+
const denominator = import_jsbi.default.add(import_jsbi.default.multiply(rootK, import_swap_sdk_core2.FIVE), rootKLast);
|
|
256
|
+
const feeLiquidity = import_jsbi.default.divide(numerator, denominator);
|
|
257
|
+
totalSupplyAdjusted = totalSupply.add(import_swap_sdk_core2.CurrencyAmount.fromRawAmount(this.liquidityToken, feeLiquidity));
|
|
658
258
|
} else {
|
|
659
259
|
totalSupplyAdjusted = totalSupply;
|
|
660
260
|
}
|
|
@@ -662,25 +262,26 @@ var Pair = class {
|
|
|
662
262
|
totalSupplyAdjusted = totalSupply;
|
|
663
263
|
}
|
|
664
264
|
}
|
|
665
|
-
return
|
|
265
|
+
return import_swap_sdk_core2.CurrencyAmount.fromRawAmount(token, import_jsbi.default.divide(import_jsbi.default.multiply(liquidity.quotient, this.reserveOf(token).quotient), totalSupplyAdjusted.quotient));
|
|
666
266
|
}
|
|
667
267
|
};
|
|
668
268
|
|
|
669
269
|
// src/entities/route.ts
|
|
670
|
-
var
|
|
270
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
271
|
+
var import_swap_sdk_core3 = require("@pancakeswap/swap-sdk-core");
|
|
671
272
|
var Route = class {
|
|
672
273
|
constructor(pairs, input, output) {
|
|
673
274
|
this._midPrice = null;
|
|
674
|
-
(0,
|
|
275
|
+
(0, import_tiny_invariant3.default)(pairs.length > 0, "PAIRS");
|
|
675
276
|
const chainId = pairs[0].chainId;
|
|
676
|
-
(0,
|
|
277
|
+
(0, import_tiny_invariant3.default)(pairs.every((pair) => pair.chainId === chainId), "CHAIN_IDS");
|
|
677
278
|
const wrappedInput = input.wrapped;
|
|
678
|
-
(0,
|
|
679
|
-
(0,
|
|
279
|
+
(0, import_tiny_invariant3.default)(pairs[0].involvesToken(wrappedInput), "INPUT");
|
|
280
|
+
(0, import_tiny_invariant3.default)(typeof output === "undefined" || pairs[pairs.length - 1].involvesToken(output.wrapped), "OUTPUT");
|
|
680
281
|
const path = [wrappedInput];
|
|
681
282
|
for (const [i, pair] of pairs.entries()) {
|
|
682
283
|
const currentInput = path[i];
|
|
683
|
-
(0,
|
|
284
|
+
(0, import_tiny_invariant3.default)(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), "PATH");
|
|
684
285
|
const output2 = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
|
|
685
286
|
path.push(output2);
|
|
686
287
|
}
|
|
@@ -694,10 +295,10 @@ var Route = class {
|
|
|
694
295
|
return this._midPrice;
|
|
695
296
|
const prices = [];
|
|
696
297
|
for (const [i, pair] of this.pairs.entries()) {
|
|
697
|
-
prices.push(this.path[i].equals(pair.token0) ? new
|
|
298
|
+
prices.push(this.path[i].equals(pair.token0) ? new import_swap_sdk_core3.Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new import_swap_sdk_core3.Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient));
|
|
698
299
|
}
|
|
699
300
|
const reduced = prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]);
|
|
700
|
-
return this._midPrice = new
|
|
301
|
+
return this._midPrice = new import_swap_sdk_core3.Price(this.input, this.output, reduced.denominator, reduced.numerator);
|
|
701
302
|
}
|
|
702
303
|
get chainId() {
|
|
703
304
|
return this.pairs[0].chainId;
|
|
@@ -705,26 +306,24 @@ var Route = class {
|
|
|
705
306
|
};
|
|
706
307
|
|
|
707
308
|
// src/entities/trade.ts
|
|
708
|
-
var
|
|
309
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
310
|
+
var import_swap_sdk_core4 = require("@pancakeswap/swap-sdk-core");
|
|
709
311
|
function inputOutputComparator(a, b) {
|
|
710
|
-
(0,
|
|
711
|
-
(0,
|
|
312
|
+
(0, import_tiny_invariant4.default)(a.inputAmount.currency.equals(b.inputAmount.currency), "INPUT_CURRENCY");
|
|
313
|
+
(0, import_tiny_invariant4.default)(a.outputAmount.currency.equals(b.outputAmount.currency), "OUTPUT_CURRENCY");
|
|
712
314
|
if (a.outputAmount.equalTo(b.outputAmount)) {
|
|
713
315
|
if (a.inputAmount.equalTo(b.inputAmount)) {
|
|
714
316
|
return 0;
|
|
715
317
|
}
|
|
716
318
|
if (a.inputAmount.lessThan(b.inputAmount)) {
|
|
717
319
|
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
320
|
}
|
|
321
|
+
return 1;
|
|
727
322
|
}
|
|
323
|
+
if (a.outputAmount.lessThan(b.outputAmount)) {
|
|
324
|
+
return 1;
|
|
325
|
+
}
|
|
326
|
+
return -1;
|
|
728
327
|
}
|
|
729
328
|
function tradeComparator(a, b) {
|
|
730
329
|
const ioComp = inputOutputComparator(a, b);
|
|
@@ -733,75 +332,74 @@ function tradeComparator(a, b) {
|
|
|
733
332
|
}
|
|
734
333
|
if (a.priceImpact.lessThan(b.priceImpact)) {
|
|
735
334
|
return -1;
|
|
736
|
-
}
|
|
335
|
+
}
|
|
336
|
+
if (a.priceImpact.greaterThan(b.priceImpact)) {
|
|
737
337
|
return 1;
|
|
738
338
|
}
|
|
739
339
|
return a.route.path.length - b.route.path.length;
|
|
740
340
|
}
|
|
741
341
|
var Trade = class {
|
|
742
342
|
static exactIn(route, amountIn) {
|
|
743
|
-
return new Trade(route, amountIn,
|
|
343
|
+
return new Trade(route, amountIn, import_swap_sdk_core4.TradeType.EXACT_INPUT);
|
|
744
344
|
}
|
|
745
345
|
static exactOut(route, amountOut) {
|
|
746
|
-
return new Trade(route, amountOut,
|
|
346
|
+
return new Trade(route, amountOut, import_swap_sdk_core4.TradeType.EXACT_OUTPUT);
|
|
747
347
|
}
|
|
748
348
|
constructor(route, amount, tradeType) {
|
|
749
349
|
this.route = route;
|
|
750
350
|
this.tradeType = tradeType;
|
|
751
351
|
const tokenAmounts = new Array(route.path.length);
|
|
752
|
-
if (tradeType ===
|
|
753
|
-
(0,
|
|
352
|
+
if (tradeType === import_swap_sdk_core4.TradeType.EXACT_INPUT) {
|
|
353
|
+
(0, import_tiny_invariant4.default)(amount.currency.equals(route.input), "INPUT");
|
|
754
354
|
tokenAmounts[0] = amount.wrapped;
|
|
755
355
|
for (let i = 0; i < route.path.length - 1; i++) {
|
|
756
356
|
const pair = route.pairs[i];
|
|
757
357
|
const [outputAmount] = pair.getOutputAmount(tokenAmounts[i]);
|
|
758
358
|
tokenAmounts[i + 1] = outputAmount;
|
|
759
359
|
}
|
|
760
|
-
this.inputAmount =
|
|
761
|
-
this.outputAmount =
|
|
360
|
+
this.inputAmount = import_swap_sdk_core4.CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
361
|
+
this.outputAmount = import_swap_sdk_core4.CurrencyAmount.fromFractionalAmount(route.output, tokenAmounts[tokenAmounts.length - 1].numerator, tokenAmounts[tokenAmounts.length - 1].denominator);
|
|
762
362
|
} else {
|
|
763
|
-
(0,
|
|
363
|
+
(0, import_tiny_invariant4.default)(amount.currency.equals(route.output), "OUTPUT");
|
|
764
364
|
tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
|
|
765
365
|
for (let i = route.path.length - 1; i > 0; i--) {
|
|
766
366
|
const pair = route.pairs[i - 1];
|
|
767
367
|
const [inputAmount] = pair.getInputAmount(tokenAmounts[i]);
|
|
768
368
|
tokenAmounts[i - 1] = inputAmount;
|
|
769
369
|
}
|
|
770
|
-
this.inputAmount =
|
|
771
|
-
this.outputAmount =
|
|
370
|
+
this.inputAmount = import_swap_sdk_core4.CurrencyAmount.fromFractionalAmount(route.input, tokenAmounts[0].numerator, tokenAmounts[0].denominator);
|
|
371
|
+
this.outputAmount = import_swap_sdk_core4.CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
|
|
772
372
|
}
|
|
773
|
-
this.executionPrice = new
|
|
774
|
-
this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
|
|
373
|
+
this.executionPrice = new import_swap_sdk_core4.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);
|
|
374
|
+
this.priceImpact = (0, import_swap_sdk_core4.computePriceImpact)(route.midPrice, this.inputAmount, this.outputAmount);
|
|
775
375
|
}
|
|
776
376
|
minimumAmountOut(slippageTolerance) {
|
|
777
|
-
(0,
|
|
778
|
-
if (this.tradeType ===
|
|
377
|
+
(0, import_tiny_invariant4.default)(!slippageTolerance.lessThan(import_swap_sdk_core4.ZERO), "SLIPPAGE_TOLERANCE");
|
|
378
|
+
if (this.tradeType === import_swap_sdk_core4.TradeType.EXACT_OUTPUT) {
|
|
779
379
|
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
380
|
}
|
|
381
|
+
const slippageAdjustedAmountOut = new import_swap_sdk_core4.Fraction(import_swap_sdk_core4.ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
|
|
382
|
+
return import_swap_sdk_core4.CurrencyAmount.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut);
|
|
784
383
|
}
|
|
785
384
|
maximumAmountIn(slippageTolerance) {
|
|
786
|
-
(0,
|
|
787
|
-
if (this.tradeType ===
|
|
385
|
+
(0, import_tiny_invariant4.default)(!slippageTolerance.lessThan(import_swap_sdk_core4.ZERO), "SLIPPAGE_TOLERANCE");
|
|
386
|
+
if (this.tradeType === import_swap_sdk_core4.TradeType.EXACT_INPUT) {
|
|
788
387
|
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
388
|
}
|
|
389
|
+
const slippageAdjustedAmountIn = new import_swap_sdk_core4.Fraction(import_swap_sdk_core4.ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
|
|
390
|
+
return import_swap_sdk_core4.CurrencyAmount.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn);
|
|
793
391
|
}
|
|
794
392
|
static bestTradeExactIn(pairs, currencyAmountIn, currencyOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountIn = currencyAmountIn, bestTrades = []) {
|
|
795
|
-
(0,
|
|
796
|
-
(0,
|
|
797
|
-
(0,
|
|
393
|
+
(0, import_tiny_invariant4.default)(pairs.length > 0, "PAIRS");
|
|
394
|
+
(0, import_tiny_invariant4.default)(maxHops > 0, "MAX_HOPS");
|
|
395
|
+
(0, import_tiny_invariant4.default)(currencyAmountIn === nextAmountIn || currentPairs.length > 0, "INVALID_RECURSION");
|
|
798
396
|
const amountIn = nextAmountIn.wrapped;
|
|
799
397
|
const tokenOut = currencyOut.wrapped;
|
|
800
398
|
for (let i = 0; i < pairs.length; i++) {
|
|
801
399
|
const pair = pairs[i];
|
|
802
400
|
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency))
|
|
803
401
|
continue;
|
|
804
|
-
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO))
|
|
402
|
+
if (pair.reserve0.equalTo(import_swap_sdk_core4.ZERO) || pair.reserve1.equalTo(import_swap_sdk_core4.ZERO))
|
|
805
403
|
continue;
|
|
806
404
|
let amountOut;
|
|
807
405
|
try {
|
|
@@ -814,7 +412,7 @@ var Trade = class {
|
|
|
814
412
|
throw error;
|
|
815
413
|
}
|
|
816
414
|
if (amountOut.currency.equals(tokenOut)) {
|
|
817
|
-
sortedInsert(bestTrades, new Trade(new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut), currencyAmountIn,
|
|
415
|
+
(0, import_swap_sdk_core4.sortedInsert)(bestTrades, new Trade(new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut), currencyAmountIn, import_swap_sdk_core4.TradeType.EXACT_INPUT), maxNumResults, tradeComparator);
|
|
818
416
|
} else if (maxHops > 1 && pairs.length > 1) {
|
|
819
417
|
const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
|
|
820
418
|
Trade.bestTradeExactIn(pairsExcludingThisPair, currencyAmountIn, currencyOut, {
|
|
@@ -826,19 +424,19 @@ var Trade = class {
|
|
|
826
424
|
return bestTrades;
|
|
827
425
|
}
|
|
828
426
|
worstExecutionPrice(slippageTolerance) {
|
|
829
|
-
return new
|
|
427
|
+
return new import_swap_sdk_core4.Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
830
428
|
}
|
|
831
429
|
static bestTradeExactOut(pairs, currencyIn, currencyAmountOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountOut = currencyAmountOut, bestTrades = []) {
|
|
832
|
-
(0,
|
|
833
|
-
(0,
|
|
834
|
-
(0,
|
|
430
|
+
(0, import_tiny_invariant4.default)(pairs.length > 0, "PAIRS");
|
|
431
|
+
(0, import_tiny_invariant4.default)(maxHops > 0, "MAX_HOPS");
|
|
432
|
+
(0, import_tiny_invariant4.default)(currencyAmountOut === nextAmountOut || currentPairs.length > 0, "INVALID_RECURSION");
|
|
835
433
|
const amountOut = nextAmountOut.wrapped;
|
|
836
434
|
const tokenIn = currencyIn.wrapped;
|
|
837
435
|
for (let i = 0; i < pairs.length; i++) {
|
|
838
436
|
const pair = pairs[i];
|
|
839
437
|
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency))
|
|
840
438
|
continue;
|
|
841
|
-
if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO))
|
|
439
|
+
if (pair.reserve0.equalTo(import_swap_sdk_core4.ZERO) || pair.reserve1.equalTo(import_swap_sdk_core4.ZERO))
|
|
842
440
|
continue;
|
|
843
441
|
let amountIn;
|
|
844
442
|
try {
|
|
@@ -851,7 +449,7 @@ var Trade = class {
|
|
|
851
449
|
throw error;
|
|
852
450
|
}
|
|
853
451
|
if (amountIn.currency.equals(tokenIn)) {
|
|
854
|
-
sortedInsert(bestTrades, new Trade(new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency), currencyAmountOut,
|
|
452
|
+
(0, import_swap_sdk_core4.sortedInsert)(bestTrades, new Trade(new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency), currencyAmountOut, import_swap_sdk_core4.TradeType.EXACT_OUTPUT), maxNumResults, tradeComparator);
|
|
855
453
|
} else if (maxHops > 1 && pairs.length > 1) {
|
|
856
454
|
const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
|
|
857
455
|
Trade.bestTradeExactOut(pairsExcludingThisPair, currencyIn, currencyAmountOut, {
|
|
@@ -864,18 +462,10 @@ var Trade = class {
|
|
|
864
462
|
}
|
|
865
463
|
};
|
|
866
464
|
|
|
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
465
|
// src/entities/native.ts
|
|
877
|
-
var
|
|
878
|
-
var
|
|
466
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
467
|
+
var import_swap_sdk_core5 = require("@pancakeswap/swap-sdk-core");
|
|
468
|
+
var _Native = class extends import_swap_sdk_core5.NativeCurrency {
|
|
879
469
|
constructor({
|
|
880
470
|
chainId,
|
|
881
471
|
decimals,
|
|
@@ -886,14 +476,14 @@ var _Native = class extends NativeCurrency {
|
|
|
886
476
|
}
|
|
887
477
|
get wrapped() {
|
|
888
478
|
const wnative = WNATIVE[this.chainId];
|
|
889
|
-
(0,
|
|
479
|
+
(0, import_tiny_invariant5.default)(!!wnative, "WRAPPED");
|
|
890
480
|
return wnative;
|
|
891
481
|
}
|
|
892
482
|
static onChain(chainId) {
|
|
893
483
|
if (chainId in this.cache) {
|
|
894
484
|
return this.cache[chainId];
|
|
895
485
|
}
|
|
896
|
-
(0,
|
|
486
|
+
(0, import_tiny_invariant5.default)(!!NATIVE[chainId], "NATIVE_CURRENCY");
|
|
897
487
|
const { decimals, name, symbol } = NATIVE[chainId];
|
|
898
488
|
return this.cache[chainId] = new _Native({ chainId, decimals, symbol, name });
|
|
899
489
|
}
|
|
@@ -905,7 +495,8 @@ var Native = _Native;
|
|
|
905
495
|
Native.cache = {};
|
|
906
496
|
|
|
907
497
|
// src/router.ts
|
|
908
|
-
var
|
|
498
|
+
var import_swap_sdk_core6 = require("@pancakeswap/swap-sdk-core");
|
|
499
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
909
500
|
function toHex(currencyAmount) {
|
|
910
501
|
return `0x${currencyAmount.quotient.toString(16)}`;
|
|
911
502
|
}
|
|
@@ -916,8 +507,8 @@ var Router = class {
|
|
|
916
507
|
static swapCallParameters(trade, options) {
|
|
917
508
|
const etherIn = trade.inputAmount.currency.isNative;
|
|
918
509
|
const etherOut = trade.outputAmount.currency.isNative;
|
|
919
|
-
(0,
|
|
920
|
-
(0,
|
|
510
|
+
(0, import_tiny_invariant6.default)(!(etherIn && etherOut), "ETHER_IN_OUT");
|
|
511
|
+
(0, import_tiny_invariant6.default)(!("ttl" in options) || options.ttl > 0, "TTL");
|
|
921
512
|
const to = validateAndParseAddress(options.recipient);
|
|
922
513
|
const amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));
|
|
923
514
|
const amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));
|
|
@@ -928,7 +519,7 @@ var Router = class {
|
|
|
928
519
|
let args;
|
|
929
520
|
let value;
|
|
930
521
|
switch (trade.tradeType) {
|
|
931
|
-
case
|
|
522
|
+
case import_swap_sdk_core6.TradeType.EXACT_INPUT:
|
|
932
523
|
if (etherIn) {
|
|
933
524
|
methodName = useFeeOnTransfer ? "swapExactETHForTokensSupportingFeeOnTransferTokens" : "swapExactETHForTokens";
|
|
934
525
|
args = [amountOut, path, to, deadline];
|
|
@@ -943,8 +534,8 @@ var Router = class {
|
|
|
943
534
|
value = ZERO_HEX;
|
|
944
535
|
}
|
|
945
536
|
break;
|
|
946
|
-
case
|
|
947
|
-
(0,
|
|
537
|
+
case import_swap_sdk_core6.TradeType.EXACT_OUTPUT:
|
|
538
|
+
(0, import_tiny_invariant6.default)(!useFeeOnTransfer, "EXACT_OUT_FOT");
|
|
948
539
|
if (etherIn) {
|
|
949
540
|
methodName = "swapETHForExactTokens";
|
|
950
541
|
args = [amountOut, path, to, deadline];
|
|
@@ -967,49 +558,28 @@ var Router = class {
|
|
|
967
558
|
};
|
|
968
559
|
}
|
|
969
560
|
};
|
|
561
|
+
|
|
562
|
+
// src/index.ts
|
|
563
|
+
__reExport(src_exports, require("@pancakeswap/swap-sdk-core"), module.exports);
|
|
970
564
|
// Annotate the CommonJS export names for ESM import in node:
|
|
971
565
|
0 && (module.exports = {
|
|
972
|
-
BaseCurrency,
|
|
973
566
|
ChainId,
|
|
974
|
-
|
|
567
|
+
ERC20Token,
|
|
975
568
|
FACTORY_ADDRESS,
|
|
976
569
|
FACTORY_ADDRESS_MAP,
|
|
977
|
-
FIVE,
|
|
978
|
-
Fraction,
|
|
979
570
|
INIT_CODE_HASH,
|
|
980
571
|
INIT_CODE_HASH_MAP,
|
|
981
|
-
InsufficientInputAmountError,
|
|
982
|
-
InsufficientReservesError,
|
|
983
572
|
JSBI,
|
|
984
|
-
MINIMUM_LIQUIDITY,
|
|
985
|
-
MaxUint256,
|
|
986
573
|
NATIVE,
|
|
987
574
|
Native,
|
|
988
|
-
NativeCurrency,
|
|
989
|
-
ONE,
|
|
990
575
|
Pair,
|
|
991
|
-
Percent,
|
|
992
|
-
Price,
|
|
993
|
-
Rounding,
|
|
994
576
|
Route,
|
|
995
577
|
Router,
|
|
996
|
-
SOLIDITY_TYPE_MAXIMA,
|
|
997
|
-
SolidityType,
|
|
998
|
-
TEN,
|
|
999
|
-
THREE,
|
|
1000
|
-
TWO,
|
|
1001
|
-
Token,
|
|
1002
578
|
Trade,
|
|
1003
|
-
TradeType,
|
|
1004
579
|
WBNB,
|
|
1005
580
|
WETH9,
|
|
1006
581
|
WNATIVE,
|
|
1007
|
-
ZERO,
|
|
1008
|
-
_100,
|
|
1009
|
-
_10000,
|
|
1010
|
-
_9975,
|
|
1011
582
|
computePairAddress,
|
|
1012
|
-
computePriceImpact,
|
|
1013
583
|
inputOutputComparator,
|
|
1014
584
|
tradeComparator
|
|
1015
585
|
});
|