@pancakeswap/sdk 3.1.5 → 3.2.1
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/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/entities/index.d.ts +6 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/native.d.ts +18 -0
- package/dist/entities/native.d.ts.map +1 -0
- package/dist/entities/pair.d.ts +45 -0
- package/dist/entities/pair.d.ts.map +1 -0
- package/dist/entities/route.d.ts +13 -0
- package/dist/entities/route.d.ts.map +1 -0
- package/dist/entities/token.d.ts +13 -0
- package/dist/entities/token.d.ts.map +1 -0
- package/dist/entities/trade.d.ts +104 -0
- package/dist/entities/trade.d.ts.map +1 -0
- package/dist/ether.d.ts +12 -0
- package/dist/ether.d.ts.map +1 -0
- package/dist/fetcher.d.ts +29 -0
- package/dist/fetcher.d.ts.map +1 -0
- package/dist/index.d.ts +10 -272
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +981 -233
- package/dist/index.mjs +878 -133
- package/dist/router.d.ts +61 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/trade.d.ts +5 -0
- package/dist/trade.d.ts.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +13 -6
package/dist/index.js
CHANGED
|
@@ -1,99 +1,49 @@
|
|
|
1
|
-
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
30
2
|
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
JSBI: () => import_jsbi2.default,
|
|
41
|
-
NATIVE: () => NATIVE,
|
|
42
|
-
Native: () => Native,
|
|
43
|
-
ONE_HUNDRED_PERCENT: () => ONE_HUNDRED_PERCENT,
|
|
44
|
-
Pair: () => Pair,
|
|
45
|
-
Route: () => Route,
|
|
46
|
-
Router: () => Router,
|
|
47
|
-
Trade: () => Trade,
|
|
48
|
-
WBNB: () => WBNB,
|
|
49
|
-
WETH9: () => WETH9,
|
|
50
|
-
WNATIVE: () => WNATIVE,
|
|
51
|
-
ZERO_PERCENT: () => ZERO_PERCENT,
|
|
52
|
-
computePairAddress: () => computePairAddress,
|
|
53
|
-
inputOutputComparator: () => inputOutputComparator,
|
|
54
|
-
isTradeBetter: () => isTradeBetter,
|
|
55
|
-
tradeComparator: () => tradeComparator
|
|
56
|
-
});
|
|
57
|
-
module.exports = __toCommonJS(src_exports);
|
|
58
|
-
var import_jsbi2 = __toESM(require("jsbi"));
|
|
3
|
+
var JSBI = require('jsbi');
|
|
4
|
+
var swapSdkCore = require('@pancakeswap/swap-sdk-core');
|
|
5
|
+
var address = require('@ethersproject/address');
|
|
6
|
+
var invariant4 = require('tiny-invariant');
|
|
7
|
+
var warning = require('tiny-warning');
|
|
8
|
+
var solidity = require('@ethersproject/solidity');
|
|
9
|
+
var contracts = require('@ethersproject/contracts');
|
|
10
|
+
var networks = require('@ethersproject/networks');
|
|
11
|
+
var providers = require('@ethersproject/providers');
|
|
59
12
|
|
|
60
|
-
|
|
61
|
-
var import_swap_sdk_core2 = require("@pancakeswap/swap-sdk-core");
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
62
14
|
|
|
63
|
-
|
|
64
|
-
var
|
|
15
|
+
var JSBI__default = /*#__PURE__*/_interopDefault(JSBI);
|
|
16
|
+
var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
|
|
17
|
+
var warning__default = /*#__PURE__*/_interopDefault(warning);
|
|
65
18
|
|
|
66
|
-
// src/
|
|
67
|
-
|
|
68
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
69
|
-
var import_tiny_warning = __toESM(require("tiny-warning"));
|
|
70
|
-
function validateAndParseAddress(address) {
|
|
19
|
+
// src/index.ts
|
|
20
|
+
function validateAndParseAddress(address$1) {
|
|
71
21
|
try {
|
|
72
|
-
const checksummedAddress =
|
|
73
|
-
|
|
22
|
+
const checksummedAddress = address.getAddress(address$1);
|
|
23
|
+
warning__default.default(address$1 === checksummedAddress, `${address$1} is not checksummed.`);
|
|
74
24
|
return checksummedAddress;
|
|
75
25
|
} catch (error) {
|
|
76
|
-
|
|
26
|
+
invariant4__default.default(false, `${address$1} is not a valid address.`);
|
|
77
27
|
}
|
|
78
28
|
}
|
|
79
29
|
|
|
80
30
|
// src/entities/token.ts
|
|
81
|
-
var ERC20Token = class extends
|
|
31
|
+
var ERC20Token = class extends swapSdkCore.Token {
|
|
82
32
|
constructor(chainId, address, decimals, symbol, name, projectLink) {
|
|
83
33
|
super(chainId, validateAndParseAddress(address), decimals, symbol, name, projectLink);
|
|
84
34
|
}
|
|
85
35
|
};
|
|
86
36
|
|
|
87
37
|
// src/constants.ts
|
|
88
|
-
var ChainId = /* @__PURE__ */ ((
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return
|
|
38
|
+
var ChainId = /* @__PURE__ */ ((ChainId3) => {
|
|
39
|
+
ChainId3[ChainId3["ETHEREUM"] = 1] = "ETHEREUM";
|
|
40
|
+
ChainId3[ChainId3["GOERLI"] = 5] = "GOERLI";
|
|
41
|
+
ChainId3[ChainId3["BSC"] = 56] = "BSC";
|
|
42
|
+
ChainId3[ChainId3["BSC_TESTNET"] = 97] = "BSC_TESTNET";
|
|
43
|
+
return ChainId3;
|
|
94
44
|
})(ChainId || {});
|
|
95
|
-
var ZERO_PERCENT = new
|
|
96
|
-
var ONE_HUNDRED_PERCENT = new
|
|
45
|
+
var ZERO_PERCENT = new swapSdkCore.Percent("0");
|
|
46
|
+
var ONE_HUNDRED_PERCENT = new swapSdkCore.Percent("1");
|
|
97
47
|
var FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
|
|
98
48
|
var FACTORY_ADDRESS_ETH = "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362";
|
|
99
49
|
var FACTORY_ADDRESS_MAP = {
|
|
@@ -126,6 +76,22 @@ var WETH9 = {
|
|
|
126
76
|
"WETH",
|
|
127
77
|
"Wrapped Ether",
|
|
128
78
|
"https://weth.io"
|
|
79
|
+
),
|
|
80
|
+
[56 /* BSC */]: new ERC20Token(
|
|
81
|
+
56 /* BSC */,
|
|
82
|
+
"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
|
|
83
|
+
18,
|
|
84
|
+
"ETH",
|
|
85
|
+
"Binance-Peg Ethereum Token",
|
|
86
|
+
"https://ethereum.org"
|
|
87
|
+
),
|
|
88
|
+
[97 /* BSC_TESTNET */]: new ERC20Token(
|
|
89
|
+
56 /* BSC */,
|
|
90
|
+
"0xE7bCB9e341D546b66a46298f4893f5650a56e99E",
|
|
91
|
+
18,
|
|
92
|
+
"ETH",
|
|
93
|
+
"ETH",
|
|
94
|
+
"https://ethereum.org"
|
|
129
95
|
)
|
|
130
96
|
};
|
|
131
97
|
var WBNB = {
|
|
@@ -191,13 +157,6 @@ function isTradeBetter(tradeA, tradeB, minimumDelta = ZERO_PERCENT) {
|
|
|
191
157
|
}
|
|
192
158
|
return tradeA.executionPrice.asFraction.multiply(minimumDelta.add(ONE_HUNDRED_PERCENT)).lessThan(tradeB.executionPrice);
|
|
193
159
|
}
|
|
194
|
-
|
|
195
|
-
// src/entities/pair.ts
|
|
196
|
-
var import_swap_sdk_core3 = require("@pancakeswap/swap-sdk-core");
|
|
197
|
-
var import_address2 = require("@ethersproject/address");
|
|
198
|
-
var import_solidity = require("@ethersproject/solidity");
|
|
199
|
-
var import_jsbi = __toESM(require("jsbi"));
|
|
200
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
201
160
|
var PAIR_ADDRESS_CACHE = {};
|
|
202
161
|
var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
|
|
203
162
|
var computePairAddress = ({
|
|
@@ -210,9 +169,9 @@ var computePairAddress = ({
|
|
|
210
169
|
if ((PAIR_ADDRESS_CACHE == null ? void 0 : PAIR_ADDRESS_CACHE[key]) === void 0) {
|
|
211
170
|
PAIR_ADDRESS_CACHE = {
|
|
212
171
|
...PAIR_ADDRESS_CACHE,
|
|
213
|
-
[key]:
|
|
172
|
+
[key]: address.getCreate2Address(
|
|
214
173
|
factoryAddress,
|
|
215
|
-
|
|
174
|
+
solidity.keccak256(["bytes"], [solidity.pack(["address", "address"], [token0.address, token1.address])]),
|
|
216
175
|
INIT_CODE_HASH_MAP[token0.chainId]
|
|
217
176
|
)
|
|
218
177
|
};
|
|
@@ -246,21 +205,21 @@ var Pair = class {
|
|
|
246
205
|
*/
|
|
247
206
|
get token0Price() {
|
|
248
207
|
const result = this.tokenAmounts[1].divide(this.tokenAmounts[0]);
|
|
249
|
-
return new
|
|
208
|
+
return new swapSdkCore.Price(this.token0, this.token1, result.denominator, result.numerator);
|
|
250
209
|
}
|
|
251
210
|
/**
|
|
252
211
|
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
253
212
|
*/
|
|
254
213
|
get token1Price() {
|
|
255
214
|
const result = this.tokenAmounts[0].divide(this.tokenAmounts[1]);
|
|
256
|
-
return new
|
|
215
|
+
return new swapSdkCore.Price(this.token1, this.token0, result.denominator, result.numerator);
|
|
257
216
|
}
|
|
258
217
|
/**
|
|
259
218
|
* Return the price of the given token in terms of the other token in the pair.
|
|
260
219
|
* @param token token to return price of
|
|
261
220
|
*/
|
|
262
221
|
priceOf(token) {
|
|
263
|
-
|
|
222
|
+
invariant4__default.default(this.involvesToken(token), "TOKEN");
|
|
264
223
|
return token.equals(this.token0) ? this.token0Price : this.token1Price;
|
|
265
224
|
}
|
|
266
225
|
/**
|
|
@@ -282,82 +241,82 @@ var Pair = class {
|
|
|
282
241
|
return this.tokenAmounts[1];
|
|
283
242
|
}
|
|
284
243
|
reserveOf(token) {
|
|
285
|
-
|
|
244
|
+
invariant4__default.default(this.involvesToken(token), "TOKEN");
|
|
286
245
|
return token.equals(this.token0) ? this.reserve0 : this.reserve1;
|
|
287
246
|
}
|
|
288
247
|
getOutputAmount(inputAmount) {
|
|
289
|
-
|
|
290
|
-
if (
|
|
291
|
-
throw new
|
|
248
|
+
invariant4__default.default(this.involvesToken(inputAmount.currency), "TOKEN");
|
|
249
|
+
if (JSBI__default.default.equal(this.reserve0.quotient, swapSdkCore.ZERO) || JSBI__default.default.equal(this.reserve1.quotient, swapSdkCore.ZERO)) {
|
|
250
|
+
throw new swapSdkCore.InsufficientReservesError();
|
|
292
251
|
}
|
|
293
252
|
const inputReserve = this.reserveOf(inputAmount.currency);
|
|
294
253
|
const outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
295
|
-
const inputAmountWithFee =
|
|
296
|
-
const numerator =
|
|
297
|
-
const denominator =
|
|
298
|
-
const outputAmount =
|
|
254
|
+
const inputAmountWithFee = JSBI__default.default.multiply(inputAmount.quotient, swapSdkCore._9975);
|
|
255
|
+
const numerator = JSBI__default.default.multiply(inputAmountWithFee, outputReserve.quotient);
|
|
256
|
+
const denominator = JSBI__default.default.add(JSBI__default.default.multiply(inputReserve.quotient, swapSdkCore._10000), inputAmountWithFee);
|
|
257
|
+
const outputAmount = swapSdkCore.CurrencyAmount.fromRawAmount(
|
|
299
258
|
inputAmount.currency.equals(this.token0) ? this.token1 : this.token0,
|
|
300
|
-
|
|
259
|
+
JSBI__default.default.divide(numerator, denominator)
|
|
301
260
|
);
|
|
302
|
-
if (
|
|
303
|
-
throw new
|
|
261
|
+
if (JSBI__default.default.equal(outputAmount.quotient, swapSdkCore.ZERO)) {
|
|
262
|
+
throw new swapSdkCore.InsufficientInputAmountError();
|
|
304
263
|
}
|
|
305
264
|
return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
306
265
|
}
|
|
307
266
|
getInputAmount(outputAmount) {
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
throw new
|
|
267
|
+
invariant4__default.default(this.involvesToken(outputAmount.currency), "TOKEN");
|
|
268
|
+
if (JSBI__default.default.equal(this.reserve0.quotient, swapSdkCore.ZERO) || JSBI__default.default.equal(this.reserve1.quotient, swapSdkCore.ZERO) || JSBI__default.default.greaterThanOrEqual(outputAmount.quotient, this.reserveOf(outputAmount.currency).quotient)) {
|
|
269
|
+
throw new swapSdkCore.InsufficientReservesError();
|
|
311
270
|
}
|
|
312
271
|
const outputReserve = this.reserveOf(outputAmount.currency);
|
|
313
272
|
const inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
|
|
314
|
-
const numerator =
|
|
315
|
-
const denominator =
|
|
316
|
-
const inputAmount =
|
|
273
|
+
const numerator = JSBI__default.default.multiply(JSBI__default.default.multiply(inputReserve.quotient, outputAmount.quotient), swapSdkCore._10000);
|
|
274
|
+
const denominator = JSBI__default.default.multiply(JSBI__default.default.subtract(outputReserve.quotient, outputAmount.quotient), swapSdkCore._9975);
|
|
275
|
+
const inputAmount = swapSdkCore.CurrencyAmount.fromRawAmount(
|
|
317
276
|
outputAmount.currency.equals(this.token0) ? this.token1 : this.token0,
|
|
318
|
-
|
|
277
|
+
JSBI__default.default.add(JSBI__default.default.divide(numerator, denominator), swapSdkCore.ONE)
|
|
319
278
|
);
|
|
320
279
|
return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
|
|
321
280
|
}
|
|
322
281
|
getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {
|
|
323
|
-
|
|
282
|
+
invariant4__default.default(totalSupply.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
324
283
|
const tokenAmounts = tokenAmountA.currency.sortsBefore(tokenAmountB.currency) ? [tokenAmountA, tokenAmountB] : [tokenAmountB, tokenAmountA];
|
|
325
|
-
|
|
284
|
+
invariant4__default.default(tokenAmounts[0].currency.equals(this.token0) && tokenAmounts[1].currency.equals(this.token1), "TOKEN");
|
|
326
285
|
let liquidity;
|
|
327
|
-
if (
|
|
328
|
-
liquidity =
|
|
329
|
-
|
|
330
|
-
|
|
286
|
+
if (JSBI__default.default.equal(totalSupply.quotient, swapSdkCore.ZERO)) {
|
|
287
|
+
liquidity = JSBI__default.default.subtract(
|
|
288
|
+
swapSdkCore.sqrt(JSBI__default.default.multiply(tokenAmounts[0].quotient, tokenAmounts[1].quotient)),
|
|
289
|
+
swapSdkCore.MINIMUM_LIQUIDITY
|
|
331
290
|
);
|
|
332
291
|
} else {
|
|
333
|
-
const amount0 =
|
|
334
|
-
const amount1 =
|
|
335
|
-
liquidity =
|
|
292
|
+
const amount0 = JSBI__default.default.divide(JSBI__default.default.multiply(tokenAmounts[0].quotient, totalSupply.quotient), this.reserve0.quotient);
|
|
293
|
+
const amount1 = JSBI__default.default.divide(JSBI__default.default.multiply(tokenAmounts[1].quotient, totalSupply.quotient), this.reserve1.quotient);
|
|
294
|
+
liquidity = JSBI__default.default.lessThanOrEqual(amount0, amount1) ? amount0 : amount1;
|
|
336
295
|
}
|
|
337
|
-
if (!
|
|
338
|
-
throw new
|
|
296
|
+
if (!JSBI__default.default.greaterThan(liquidity, swapSdkCore.ZERO)) {
|
|
297
|
+
throw new swapSdkCore.InsufficientInputAmountError();
|
|
339
298
|
}
|
|
340
|
-
return
|
|
299
|
+
return swapSdkCore.CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity);
|
|
341
300
|
}
|
|
342
301
|
getLiquidityValue(token, totalSupply, liquidity, feeOn = false, kLast) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
302
|
+
invariant4__default.default(this.involvesToken(token), "TOKEN");
|
|
303
|
+
invariant4__default.default(totalSupply.currency.equals(this.liquidityToken), "TOTAL_SUPPLY");
|
|
304
|
+
invariant4__default.default(liquidity.currency.equals(this.liquidityToken), "LIQUIDITY");
|
|
305
|
+
invariant4__default.default(JSBI__default.default.lessThanOrEqual(liquidity.quotient, totalSupply.quotient), "LIQUIDITY");
|
|
347
306
|
let totalSupplyAdjusted;
|
|
348
307
|
if (!feeOn) {
|
|
349
308
|
totalSupplyAdjusted = totalSupply;
|
|
350
309
|
} else {
|
|
351
|
-
|
|
352
|
-
const kLastParsed =
|
|
353
|
-
if (!
|
|
354
|
-
const rootK =
|
|
355
|
-
const rootKLast =
|
|
356
|
-
if (
|
|
357
|
-
const numerator =
|
|
358
|
-
const denominator =
|
|
359
|
-
const feeLiquidity =
|
|
360
|
-
totalSupplyAdjusted = totalSupply.add(
|
|
310
|
+
invariant4__default.default(!!kLast, "K_LAST");
|
|
311
|
+
const kLastParsed = JSBI__default.default.BigInt(kLast);
|
|
312
|
+
if (!JSBI__default.default.equal(kLastParsed, swapSdkCore.ZERO)) {
|
|
313
|
+
const rootK = swapSdkCore.sqrt(JSBI__default.default.multiply(this.reserve0.quotient, this.reserve1.quotient));
|
|
314
|
+
const rootKLast = swapSdkCore.sqrt(kLastParsed);
|
|
315
|
+
if (JSBI__default.default.greaterThan(rootK, rootKLast)) {
|
|
316
|
+
const numerator = JSBI__default.default.multiply(totalSupply.quotient, JSBI__default.default.subtract(rootK, rootKLast));
|
|
317
|
+
const denominator = JSBI__default.default.add(JSBI__default.default.multiply(rootK, swapSdkCore.FIVE), rootKLast);
|
|
318
|
+
const feeLiquidity = JSBI__default.default.divide(numerator, denominator);
|
|
319
|
+
totalSupplyAdjusted = totalSupply.add(swapSdkCore.CurrencyAmount.fromRawAmount(this.liquidityToken, feeLiquidity));
|
|
361
320
|
} else {
|
|
362
321
|
totalSupplyAdjusted = totalSupply;
|
|
363
322
|
}
|
|
@@ -365,32 +324,28 @@ var Pair = class {
|
|
|
365
324
|
totalSupplyAdjusted = totalSupply;
|
|
366
325
|
}
|
|
367
326
|
}
|
|
368
|
-
return
|
|
327
|
+
return swapSdkCore.CurrencyAmount.fromRawAmount(
|
|
369
328
|
token,
|
|
370
|
-
|
|
329
|
+
JSBI__default.default.divide(JSBI__default.default.multiply(liquidity.quotient, this.reserveOf(token).quotient), totalSupplyAdjusted.quotient)
|
|
371
330
|
);
|
|
372
331
|
}
|
|
373
332
|
};
|
|
374
|
-
|
|
375
|
-
// src/entities/route.ts
|
|
376
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
377
|
-
var import_swap_sdk_core4 = require("@pancakeswap/swap-sdk-core");
|
|
378
333
|
var Route = class {
|
|
379
334
|
constructor(pairs, input, output) {
|
|
380
335
|
this._midPrice = null;
|
|
381
|
-
|
|
336
|
+
invariant4__default.default(pairs.length > 0, "PAIRS");
|
|
382
337
|
const chainId = pairs[0].chainId;
|
|
383
|
-
|
|
338
|
+
invariant4__default.default(
|
|
384
339
|
pairs.every((pair) => pair.chainId === chainId),
|
|
385
340
|
"CHAIN_IDS"
|
|
386
341
|
);
|
|
387
342
|
const wrappedInput = input.wrapped;
|
|
388
|
-
|
|
389
|
-
|
|
343
|
+
invariant4__default.default(pairs[0].involvesToken(wrappedInput), "INPUT");
|
|
344
|
+
invariant4__default.default(typeof output === "undefined" || pairs[pairs.length - 1].involvesToken(output.wrapped), "OUTPUT");
|
|
390
345
|
const path = [wrappedInput];
|
|
391
346
|
for (const [i, pair] of pairs.entries()) {
|
|
392
347
|
const currentInput = path[i];
|
|
393
|
-
|
|
348
|
+
invariant4__default.default(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), "PATH");
|
|
394
349
|
const output2 = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
|
|
395
350
|
path.push(output2);
|
|
396
351
|
}
|
|
@@ -405,23 +360,19 @@ var Route = class {
|
|
|
405
360
|
const prices = [];
|
|
406
361
|
for (const [i, pair] of this.pairs.entries()) {
|
|
407
362
|
prices.push(
|
|
408
|
-
this.path[i].equals(pair.token0) ? new
|
|
363
|
+
this.path[i].equals(pair.token0) ? new swapSdkCore.Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new swapSdkCore.Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient)
|
|
409
364
|
);
|
|
410
365
|
}
|
|
411
366
|
const reduced = prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]);
|
|
412
|
-
return this._midPrice = new
|
|
367
|
+
return this._midPrice = new swapSdkCore.Price(this.input, this.output, reduced.denominator, reduced.numerator);
|
|
413
368
|
}
|
|
414
369
|
get chainId() {
|
|
415
370
|
return this.pairs[0].chainId;
|
|
416
371
|
}
|
|
417
372
|
};
|
|
418
|
-
|
|
419
|
-
// src/entities/trade.ts
|
|
420
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
421
|
-
var import_swap_sdk_core5 = require("@pancakeswap/swap-sdk-core");
|
|
422
373
|
function inputOutputComparator(a, b) {
|
|
423
|
-
|
|
424
|
-
|
|
374
|
+
invariant4__default.default(a.inputAmount.currency.equals(b.inputAmount.currency), "INPUT_CURRENCY");
|
|
375
|
+
invariant4__default.default(a.outputAmount.currency.equals(b.outputAmount.currency), "OUTPUT_CURRENCY");
|
|
425
376
|
if (a.outputAmount.equalTo(b.outputAmount)) {
|
|
426
377
|
if (a.inputAmount.equalTo(b.inputAmount)) {
|
|
427
378
|
return 0;
|
|
@@ -456,7 +407,7 @@ var Trade = class {
|
|
|
456
407
|
* @param amountIn the amount being passed in
|
|
457
408
|
*/
|
|
458
409
|
static exactIn(route, amountIn) {
|
|
459
|
-
return new Trade(route, amountIn,
|
|
410
|
+
return new Trade(route, amountIn, swapSdkCore.TradeType.EXACT_INPUT);
|
|
460
411
|
}
|
|
461
412
|
/**
|
|
462
413
|
* Constructs an exact out trade with the given amount out and route
|
|
@@ -464,72 +415,72 @@ var Trade = class {
|
|
|
464
415
|
* @param amountOut the amount returned by the trade
|
|
465
416
|
*/
|
|
466
417
|
static exactOut(route, amountOut) {
|
|
467
|
-
return new Trade(route, amountOut,
|
|
418
|
+
return new Trade(route, amountOut, swapSdkCore.TradeType.EXACT_OUTPUT);
|
|
468
419
|
}
|
|
469
420
|
constructor(route, amount, tradeType) {
|
|
470
421
|
this.route = route;
|
|
471
422
|
this.tradeType = tradeType;
|
|
472
423
|
const tokenAmounts = new Array(route.path.length);
|
|
473
|
-
if (tradeType ===
|
|
474
|
-
|
|
424
|
+
if (tradeType === swapSdkCore.TradeType.EXACT_INPUT) {
|
|
425
|
+
invariant4__default.default(amount.currency.equals(route.input), "INPUT");
|
|
475
426
|
tokenAmounts[0] = amount.wrapped;
|
|
476
427
|
for (let i = 0; i < route.path.length - 1; i++) {
|
|
477
428
|
const pair = route.pairs[i];
|
|
478
429
|
const [outputAmount] = pair.getOutputAmount(tokenAmounts[i]);
|
|
479
430
|
tokenAmounts[i + 1] = outputAmount;
|
|
480
431
|
}
|
|
481
|
-
this.inputAmount =
|
|
482
|
-
this.outputAmount =
|
|
432
|
+
this.inputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
433
|
+
this.outputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(
|
|
483
434
|
route.output,
|
|
484
435
|
tokenAmounts[tokenAmounts.length - 1].numerator,
|
|
485
436
|
tokenAmounts[tokenAmounts.length - 1].denominator
|
|
486
437
|
);
|
|
487
438
|
} else {
|
|
488
|
-
|
|
439
|
+
invariant4__default.default(amount.currency.equals(route.output), "OUTPUT");
|
|
489
440
|
tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
|
|
490
441
|
for (let i = route.path.length - 1; i > 0; i--) {
|
|
491
442
|
const pair = route.pairs[i - 1];
|
|
492
443
|
const [inputAmount] = pair.getInputAmount(tokenAmounts[i]);
|
|
493
444
|
tokenAmounts[i - 1] = inputAmount;
|
|
494
445
|
}
|
|
495
|
-
this.inputAmount =
|
|
446
|
+
this.inputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(
|
|
496
447
|
route.input,
|
|
497
448
|
tokenAmounts[0].numerator,
|
|
498
449
|
tokenAmounts[0].denominator
|
|
499
450
|
);
|
|
500
|
-
this.outputAmount =
|
|
451
|
+
this.outputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
|
|
501
452
|
}
|
|
502
|
-
this.executionPrice = new
|
|
453
|
+
this.executionPrice = new swapSdkCore.Price(
|
|
503
454
|
this.inputAmount.currency,
|
|
504
455
|
this.outputAmount.currency,
|
|
505
456
|
this.inputAmount.quotient,
|
|
506
457
|
this.outputAmount.quotient
|
|
507
458
|
);
|
|
508
|
-
this.priceImpact =
|
|
459
|
+
this.priceImpact = swapSdkCore.computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
|
|
509
460
|
}
|
|
510
461
|
/**
|
|
511
462
|
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
512
463
|
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
513
464
|
*/
|
|
514
465
|
minimumAmountOut(slippageTolerance) {
|
|
515
|
-
|
|
516
|
-
if (this.tradeType ===
|
|
466
|
+
invariant4__default.default(!slippageTolerance.lessThan(swapSdkCore.ZERO), "SLIPPAGE_TOLERANCE");
|
|
467
|
+
if (this.tradeType === swapSdkCore.TradeType.EXACT_OUTPUT) {
|
|
517
468
|
return this.outputAmount;
|
|
518
469
|
}
|
|
519
|
-
const slippageAdjustedAmountOut = new
|
|
520
|
-
return
|
|
470
|
+
const slippageAdjustedAmountOut = new swapSdkCore.Fraction(swapSdkCore.ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
|
|
471
|
+
return swapSdkCore.CurrencyAmount.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut);
|
|
521
472
|
}
|
|
522
473
|
/**
|
|
523
474
|
* Get the maximum amount in that can be spent via this trade for the given slippage tolerance
|
|
524
475
|
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
525
476
|
*/
|
|
526
477
|
maximumAmountIn(slippageTolerance) {
|
|
527
|
-
|
|
528
|
-
if (this.tradeType ===
|
|
478
|
+
invariant4__default.default(!slippageTolerance.lessThan(swapSdkCore.ZERO), "SLIPPAGE_TOLERANCE");
|
|
479
|
+
if (this.tradeType === swapSdkCore.TradeType.EXACT_INPUT) {
|
|
529
480
|
return this.inputAmount;
|
|
530
481
|
}
|
|
531
|
-
const slippageAdjustedAmountIn = new
|
|
532
|
-
return
|
|
482
|
+
const slippageAdjustedAmountIn = new swapSdkCore.Fraction(swapSdkCore.ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
|
|
483
|
+
return swapSdkCore.CurrencyAmount.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn);
|
|
533
484
|
}
|
|
534
485
|
/**
|
|
535
486
|
* Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
|
|
@@ -546,16 +497,16 @@ var Trade = class {
|
|
|
546
497
|
* @param bestTrades used in recursion; the current list of best trades
|
|
547
498
|
*/
|
|
548
499
|
static bestTradeExactIn(pairs, currencyAmountIn, currencyOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountIn = currencyAmountIn, bestTrades = []) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
500
|
+
invariant4__default.default(pairs.length > 0, "PAIRS");
|
|
501
|
+
invariant4__default.default(maxHops > 0, "MAX_HOPS");
|
|
502
|
+
invariant4__default.default(currencyAmountIn === nextAmountIn || currentPairs.length > 0, "INVALID_RECURSION");
|
|
552
503
|
const amountIn = nextAmountIn.wrapped;
|
|
553
504
|
const tokenOut = currencyOut.wrapped;
|
|
554
505
|
for (let i = 0; i < pairs.length; i++) {
|
|
555
506
|
const pair = pairs[i];
|
|
556
507
|
if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency))
|
|
557
508
|
continue;
|
|
558
|
-
if (pair.reserve0.equalTo(
|
|
509
|
+
if (pair.reserve0.equalTo(swapSdkCore.ZERO) || pair.reserve1.equalTo(swapSdkCore.ZERO))
|
|
559
510
|
continue;
|
|
560
511
|
let amountOut;
|
|
561
512
|
try {
|
|
@@ -568,12 +519,12 @@ var Trade = class {
|
|
|
568
519
|
throw error;
|
|
569
520
|
}
|
|
570
521
|
if (amountOut.currency.equals(tokenOut)) {
|
|
571
|
-
|
|
522
|
+
swapSdkCore.sortedInsert(
|
|
572
523
|
bestTrades,
|
|
573
524
|
new Trade(
|
|
574
525
|
new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut),
|
|
575
526
|
currencyAmountIn,
|
|
576
|
-
|
|
527
|
+
swapSdkCore.TradeType.EXACT_INPUT
|
|
577
528
|
),
|
|
578
529
|
maxNumResults,
|
|
579
530
|
tradeComparator
|
|
@@ -601,7 +552,7 @@ var Trade = class {
|
|
|
601
552
|
* @param slippageTolerance the allowed tolerated slippage
|
|
602
553
|
*/
|
|
603
554
|
worstExecutionPrice(slippageTolerance) {
|
|
604
|
-
return new
|
|
555
|
+
return new swapSdkCore.Price(
|
|
605
556
|
this.inputAmount.currency,
|
|
606
557
|
this.outputAmount.currency,
|
|
607
558
|
this.maximumAmountIn(slippageTolerance).quotient,
|
|
@@ -624,16 +575,16 @@ var Trade = class {
|
|
|
624
575
|
* @param bestTrades used in recursion; the current list of best trades
|
|
625
576
|
*/
|
|
626
577
|
static bestTradeExactOut(pairs, currencyIn, currencyAmountOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountOut = currencyAmountOut, bestTrades = []) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
578
|
+
invariant4__default.default(pairs.length > 0, "PAIRS");
|
|
579
|
+
invariant4__default.default(maxHops > 0, "MAX_HOPS");
|
|
580
|
+
invariant4__default.default(currencyAmountOut === nextAmountOut || currentPairs.length > 0, "INVALID_RECURSION");
|
|
630
581
|
const amountOut = nextAmountOut.wrapped;
|
|
631
582
|
const tokenIn = currencyIn.wrapped;
|
|
632
583
|
for (let i = 0; i < pairs.length; i++) {
|
|
633
584
|
const pair = pairs[i];
|
|
634
585
|
if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency))
|
|
635
586
|
continue;
|
|
636
|
-
if (pair.reserve0.equalTo(
|
|
587
|
+
if (pair.reserve0.equalTo(swapSdkCore.ZERO) || pair.reserve1.equalTo(swapSdkCore.ZERO))
|
|
637
588
|
continue;
|
|
638
589
|
let amountIn;
|
|
639
590
|
try {
|
|
@@ -646,12 +597,12 @@ var Trade = class {
|
|
|
646
597
|
throw error;
|
|
647
598
|
}
|
|
648
599
|
if (amountIn.currency.equals(tokenIn)) {
|
|
649
|
-
|
|
600
|
+
swapSdkCore.sortedInsert(
|
|
650
601
|
bestTrades,
|
|
651
602
|
new Trade(
|
|
652
603
|
new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency),
|
|
653
604
|
currencyAmountOut,
|
|
654
|
-
|
|
605
|
+
swapSdkCore.TradeType.EXACT_OUTPUT
|
|
655
606
|
),
|
|
656
607
|
maxNumResults,
|
|
657
608
|
tradeComparator
|
|
@@ -675,11 +626,7 @@ var Trade = class {
|
|
|
675
626
|
return bestTrades;
|
|
676
627
|
}
|
|
677
628
|
};
|
|
678
|
-
|
|
679
|
-
// src/entities/native.ts
|
|
680
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
681
|
-
var import_swap_sdk_core6 = require("@pancakeswap/swap-sdk-core");
|
|
682
|
-
var _Native = class extends import_swap_sdk_core6.NativeCurrency {
|
|
629
|
+
var _Native = class extends swapSdkCore.NativeCurrency {
|
|
683
630
|
constructor({
|
|
684
631
|
chainId,
|
|
685
632
|
decimals,
|
|
@@ -690,14 +637,14 @@ var _Native = class extends import_swap_sdk_core6.NativeCurrency {
|
|
|
690
637
|
}
|
|
691
638
|
get wrapped() {
|
|
692
639
|
const wnative = WNATIVE[this.chainId];
|
|
693
|
-
|
|
640
|
+
invariant4__default.default(!!wnative, "WRAPPED");
|
|
694
641
|
return wnative;
|
|
695
642
|
}
|
|
696
643
|
static onChain(chainId) {
|
|
697
644
|
if (chainId in this.cache) {
|
|
698
645
|
return this.cache[chainId];
|
|
699
646
|
}
|
|
700
|
-
|
|
647
|
+
invariant4__default.default(!!NATIVE[chainId], "NATIVE_CURRENCY");
|
|
701
648
|
const { decimals, name, symbol } = NATIVE[chainId];
|
|
702
649
|
return this.cache[chainId] = new _Native({ chainId, decimals, symbol, name });
|
|
703
650
|
}
|
|
@@ -707,20 +654,11 @@ var _Native = class extends import_swap_sdk_core6.NativeCurrency {
|
|
|
707
654
|
};
|
|
708
655
|
var Native = _Native;
|
|
709
656
|
Native.cache = {};
|
|
710
|
-
|
|
711
|
-
// src/router.ts
|
|
712
|
-
var import_swap_sdk_core7 = require("@pancakeswap/swap-sdk-core");
|
|
713
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
714
657
|
function toHex(currencyAmount) {
|
|
715
658
|
return `0x${currencyAmount.quotient.toString(16)}`;
|
|
716
659
|
}
|
|
717
660
|
var ZERO_HEX = "0x0";
|
|
718
661
|
var Router = class {
|
|
719
|
-
/**
|
|
720
|
-
* Cannot be constructed.
|
|
721
|
-
*/
|
|
722
|
-
constructor() {
|
|
723
|
-
}
|
|
724
662
|
/**
|
|
725
663
|
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
|
726
664
|
* @param trade to produce call parameters for
|
|
@@ -729,19 +667,19 @@ var Router = class {
|
|
|
729
667
|
static swapCallParameters(trade, options) {
|
|
730
668
|
const etherIn = trade.inputAmount.currency.isNative;
|
|
731
669
|
const etherOut = trade.outputAmount.currency.isNative;
|
|
732
|
-
|
|
733
|
-
|
|
670
|
+
invariant4__default.default(!(etherIn && etherOut), "ETHER_IN_OUT");
|
|
671
|
+
invariant4__default.default(!("ttl" in options) || options.ttl > 0, "TTL");
|
|
734
672
|
const to = validateAndParseAddress(options.recipient);
|
|
735
673
|
const amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));
|
|
736
674
|
const amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));
|
|
737
675
|
const path = trade.route.path.map((token) => token.address);
|
|
738
|
-
const deadline = "ttl" in options ? `0x${(Math.floor((
|
|
676
|
+
const deadline = "ttl" in options ? `0x${(Math.floor(( new Date()).getTime() / 1e3) + options.ttl).toString(16)}` : `0x${options.deadline.toString(16)}`;
|
|
739
677
|
const useFeeOnTransfer = Boolean(options.feeOnTransfer);
|
|
740
678
|
let methodName;
|
|
741
679
|
let args;
|
|
742
680
|
let value;
|
|
743
681
|
switch (trade.tradeType) {
|
|
744
|
-
case
|
|
682
|
+
case swapSdkCore.TradeType.EXACT_INPUT:
|
|
745
683
|
if (etherIn) {
|
|
746
684
|
methodName = useFeeOnTransfer ? "swapExactETHForTokensSupportingFeeOnTransferTokens" : "swapExactETHForTokens";
|
|
747
685
|
args = [amountOut, path, to, deadline];
|
|
@@ -756,8 +694,8 @@ var Router = class {
|
|
|
756
694
|
value = ZERO_HEX;
|
|
757
695
|
}
|
|
758
696
|
break;
|
|
759
|
-
case
|
|
760
|
-
|
|
697
|
+
case swapSdkCore.TradeType.EXACT_OUTPUT:
|
|
698
|
+
invariant4__default.default(!useFeeOnTransfer, "EXACT_OUT_FOT");
|
|
761
699
|
if (etherIn) {
|
|
762
700
|
methodName = "swapETHForExactTokens";
|
|
763
701
|
args = [amountOut, path, to, deadline];
|
|
@@ -780,31 +718,841 @@ var Router = class {
|
|
|
780
718
|
};
|
|
781
719
|
}
|
|
782
720
|
};
|
|
721
|
+
var _Ether = class extends swapSdkCore.NativeCurrency {
|
|
722
|
+
constructor(chainId) {
|
|
723
|
+
super(chainId, 18, "ETH", "Ether");
|
|
724
|
+
}
|
|
725
|
+
get wrapped() {
|
|
726
|
+
const weth9 = WETH9[this.chainId];
|
|
727
|
+
invariant4__default.default(!!weth9, "WRAPPED");
|
|
728
|
+
return weth9;
|
|
729
|
+
}
|
|
730
|
+
static onChain(chainId) {
|
|
731
|
+
if (!this._etherCache[chainId]) {
|
|
732
|
+
this._etherCache[chainId] = new _Ether(chainId);
|
|
733
|
+
}
|
|
734
|
+
return this._etherCache[chainId];
|
|
735
|
+
}
|
|
736
|
+
equals(other) {
|
|
737
|
+
return other.isNative && other.chainId === this.chainId;
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
var Ether = _Ether;
|
|
741
|
+
Ether._etherCache = {};
|
|
783
742
|
|
|
784
|
-
// src/
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
743
|
+
// src/abis/ERC20.json
|
|
744
|
+
var ERC20_default = [
|
|
745
|
+
{
|
|
746
|
+
constant: true,
|
|
747
|
+
inputs: [],
|
|
748
|
+
name: "decimals",
|
|
749
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
750
|
+
payable: false,
|
|
751
|
+
stateMutability: "view",
|
|
752
|
+
type: "function"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
constant: true,
|
|
756
|
+
inputs: [{ name: "", type: "address" }],
|
|
757
|
+
name: "balanceOf",
|
|
758
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
759
|
+
payable: false,
|
|
760
|
+
stateMutability: "view",
|
|
761
|
+
type: "function"
|
|
762
|
+
}
|
|
763
|
+
];
|
|
764
|
+
|
|
765
|
+
// src/abis/IPancakePair.json
|
|
766
|
+
var IPancakePair_default = [
|
|
767
|
+
{
|
|
768
|
+
anonymous: false,
|
|
769
|
+
inputs: [
|
|
770
|
+
{
|
|
771
|
+
indexed: true,
|
|
772
|
+
internalType: "address",
|
|
773
|
+
name: "owner",
|
|
774
|
+
type: "address"
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
indexed: true,
|
|
778
|
+
internalType: "address",
|
|
779
|
+
name: "spender",
|
|
780
|
+
type: "address"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
indexed: false,
|
|
784
|
+
internalType: "uint256",
|
|
785
|
+
name: "value",
|
|
786
|
+
type: "uint256"
|
|
787
|
+
}
|
|
788
|
+
],
|
|
789
|
+
name: "Approval",
|
|
790
|
+
type: "event"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
anonymous: false,
|
|
794
|
+
inputs: [
|
|
795
|
+
{
|
|
796
|
+
indexed: true,
|
|
797
|
+
internalType: "address",
|
|
798
|
+
name: "sender",
|
|
799
|
+
type: "address"
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
indexed: false,
|
|
803
|
+
internalType: "uint256",
|
|
804
|
+
name: "amount0",
|
|
805
|
+
type: "uint256"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
indexed: false,
|
|
809
|
+
internalType: "uint256",
|
|
810
|
+
name: "amount1",
|
|
811
|
+
type: "uint256"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
indexed: true,
|
|
815
|
+
internalType: "address",
|
|
816
|
+
name: "to",
|
|
817
|
+
type: "address"
|
|
818
|
+
}
|
|
819
|
+
],
|
|
820
|
+
name: "Burn",
|
|
821
|
+
type: "event"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
anonymous: false,
|
|
825
|
+
inputs: [
|
|
826
|
+
{
|
|
827
|
+
indexed: true,
|
|
828
|
+
internalType: "address",
|
|
829
|
+
name: "sender",
|
|
830
|
+
type: "address"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
indexed: false,
|
|
834
|
+
internalType: "uint256",
|
|
835
|
+
name: "amount0",
|
|
836
|
+
type: "uint256"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
indexed: false,
|
|
840
|
+
internalType: "uint256",
|
|
841
|
+
name: "amount1",
|
|
842
|
+
type: "uint256"
|
|
843
|
+
}
|
|
844
|
+
],
|
|
845
|
+
name: "Mint",
|
|
846
|
+
type: "event"
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
anonymous: false,
|
|
850
|
+
inputs: [
|
|
851
|
+
{
|
|
852
|
+
indexed: true,
|
|
853
|
+
internalType: "address",
|
|
854
|
+
name: "sender",
|
|
855
|
+
type: "address"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
indexed: false,
|
|
859
|
+
internalType: "uint256",
|
|
860
|
+
name: "amount0In",
|
|
861
|
+
type: "uint256"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
indexed: false,
|
|
865
|
+
internalType: "uint256",
|
|
866
|
+
name: "amount1In",
|
|
867
|
+
type: "uint256"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
indexed: false,
|
|
871
|
+
internalType: "uint256",
|
|
872
|
+
name: "amount0Out",
|
|
873
|
+
type: "uint256"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
indexed: false,
|
|
877
|
+
internalType: "uint256",
|
|
878
|
+
name: "amount1Out",
|
|
879
|
+
type: "uint256"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
indexed: true,
|
|
883
|
+
internalType: "address",
|
|
884
|
+
name: "to",
|
|
885
|
+
type: "address"
|
|
886
|
+
}
|
|
887
|
+
],
|
|
888
|
+
name: "Swap",
|
|
889
|
+
type: "event"
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
anonymous: false,
|
|
893
|
+
inputs: [
|
|
894
|
+
{
|
|
895
|
+
indexed: false,
|
|
896
|
+
internalType: "uint112",
|
|
897
|
+
name: "reserve0",
|
|
898
|
+
type: "uint112"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
indexed: false,
|
|
902
|
+
internalType: "uint112",
|
|
903
|
+
name: "reserve1",
|
|
904
|
+
type: "uint112"
|
|
905
|
+
}
|
|
906
|
+
],
|
|
907
|
+
name: "Sync",
|
|
908
|
+
type: "event"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
anonymous: false,
|
|
912
|
+
inputs: [
|
|
913
|
+
{
|
|
914
|
+
indexed: true,
|
|
915
|
+
internalType: "address",
|
|
916
|
+
name: "from",
|
|
917
|
+
type: "address"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
indexed: true,
|
|
921
|
+
internalType: "address",
|
|
922
|
+
name: "to",
|
|
923
|
+
type: "address"
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
indexed: false,
|
|
927
|
+
internalType: "uint256",
|
|
928
|
+
name: "value",
|
|
929
|
+
type: "uint256"
|
|
930
|
+
}
|
|
931
|
+
],
|
|
932
|
+
name: "Transfer",
|
|
933
|
+
type: "event"
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
constant: true,
|
|
937
|
+
inputs: [],
|
|
938
|
+
name: "DOMAIN_SEPARATOR",
|
|
939
|
+
outputs: [
|
|
940
|
+
{
|
|
941
|
+
internalType: "bytes32",
|
|
942
|
+
name: "",
|
|
943
|
+
type: "bytes32"
|
|
944
|
+
}
|
|
945
|
+
],
|
|
946
|
+
payable: false,
|
|
947
|
+
stateMutability: "view",
|
|
948
|
+
type: "function"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
constant: true,
|
|
952
|
+
inputs: [],
|
|
953
|
+
name: "MINIMUM_LIQUIDITY",
|
|
954
|
+
outputs: [
|
|
955
|
+
{
|
|
956
|
+
internalType: "uint256",
|
|
957
|
+
name: "",
|
|
958
|
+
type: "uint256"
|
|
959
|
+
}
|
|
960
|
+
],
|
|
961
|
+
payable: false,
|
|
962
|
+
stateMutability: "pure",
|
|
963
|
+
type: "function"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
constant: true,
|
|
967
|
+
inputs: [],
|
|
968
|
+
name: "PERMIT_TYPEHASH",
|
|
969
|
+
outputs: [
|
|
970
|
+
{
|
|
971
|
+
internalType: "bytes32",
|
|
972
|
+
name: "",
|
|
973
|
+
type: "bytes32"
|
|
974
|
+
}
|
|
975
|
+
],
|
|
976
|
+
payable: false,
|
|
977
|
+
stateMutability: "pure",
|
|
978
|
+
type: "function"
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
constant: true,
|
|
982
|
+
inputs: [
|
|
983
|
+
{
|
|
984
|
+
internalType: "address",
|
|
985
|
+
name: "owner",
|
|
986
|
+
type: "address"
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
internalType: "address",
|
|
990
|
+
name: "spender",
|
|
991
|
+
type: "address"
|
|
992
|
+
}
|
|
993
|
+
],
|
|
994
|
+
name: "allowance",
|
|
995
|
+
outputs: [
|
|
996
|
+
{
|
|
997
|
+
internalType: "uint256",
|
|
998
|
+
name: "",
|
|
999
|
+
type: "uint256"
|
|
1000
|
+
}
|
|
1001
|
+
],
|
|
1002
|
+
payable: false,
|
|
1003
|
+
stateMutability: "view",
|
|
1004
|
+
type: "function"
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
constant: false,
|
|
1008
|
+
inputs: [
|
|
1009
|
+
{
|
|
1010
|
+
internalType: "address",
|
|
1011
|
+
name: "spender",
|
|
1012
|
+
type: "address"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
internalType: "uint256",
|
|
1016
|
+
name: "value",
|
|
1017
|
+
type: "uint256"
|
|
1018
|
+
}
|
|
1019
|
+
],
|
|
1020
|
+
name: "approve",
|
|
1021
|
+
outputs: [
|
|
1022
|
+
{
|
|
1023
|
+
internalType: "bool",
|
|
1024
|
+
name: "",
|
|
1025
|
+
type: "bool"
|
|
1026
|
+
}
|
|
1027
|
+
],
|
|
1028
|
+
payable: false,
|
|
1029
|
+
stateMutability: "nonpayable",
|
|
1030
|
+
type: "function"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
constant: true,
|
|
1034
|
+
inputs: [
|
|
1035
|
+
{
|
|
1036
|
+
internalType: "address",
|
|
1037
|
+
name: "owner",
|
|
1038
|
+
type: "address"
|
|
1039
|
+
}
|
|
1040
|
+
],
|
|
1041
|
+
name: "balanceOf",
|
|
1042
|
+
outputs: [
|
|
1043
|
+
{
|
|
1044
|
+
internalType: "uint256",
|
|
1045
|
+
name: "",
|
|
1046
|
+
type: "uint256"
|
|
1047
|
+
}
|
|
1048
|
+
],
|
|
1049
|
+
payable: false,
|
|
1050
|
+
stateMutability: "view",
|
|
1051
|
+
type: "function"
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
constant: false,
|
|
1055
|
+
inputs: [
|
|
1056
|
+
{
|
|
1057
|
+
internalType: "address",
|
|
1058
|
+
name: "to",
|
|
1059
|
+
type: "address"
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
name: "burn",
|
|
1063
|
+
outputs: [
|
|
1064
|
+
{
|
|
1065
|
+
internalType: "uint256",
|
|
1066
|
+
name: "amount0",
|
|
1067
|
+
type: "uint256"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
internalType: "uint256",
|
|
1071
|
+
name: "amount1",
|
|
1072
|
+
type: "uint256"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
payable: false,
|
|
1076
|
+
stateMutability: "nonpayable",
|
|
1077
|
+
type: "function"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
constant: true,
|
|
1081
|
+
inputs: [],
|
|
1082
|
+
name: "decimals",
|
|
1083
|
+
outputs: [
|
|
1084
|
+
{
|
|
1085
|
+
internalType: "uint8",
|
|
1086
|
+
name: "",
|
|
1087
|
+
type: "uint8"
|
|
1088
|
+
}
|
|
1089
|
+
],
|
|
1090
|
+
payable: false,
|
|
1091
|
+
stateMutability: "pure",
|
|
1092
|
+
type: "function"
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
constant: true,
|
|
1096
|
+
inputs: [],
|
|
1097
|
+
name: "factory",
|
|
1098
|
+
outputs: [
|
|
1099
|
+
{
|
|
1100
|
+
internalType: "address",
|
|
1101
|
+
name: "",
|
|
1102
|
+
type: "address"
|
|
1103
|
+
}
|
|
1104
|
+
],
|
|
1105
|
+
payable: false,
|
|
1106
|
+
stateMutability: "view",
|
|
1107
|
+
type: "function"
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
constant: true,
|
|
1111
|
+
inputs: [],
|
|
1112
|
+
name: "getReserves",
|
|
1113
|
+
outputs: [
|
|
1114
|
+
{
|
|
1115
|
+
internalType: "uint112",
|
|
1116
|
+
name: "reserve0",
|
|
1117
|
+
type: "uint112"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
internalType: "uint112",
|
|
1121
|
+
name: "reserve1",
|
|
1122
|
+
type: "uint112"
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
internalType: "uint32",
|
|
1126
|
+
name: "blockTimestampLast",
|
|
1127
|
+
type: "uint32"
|
|
1128
|
+
}
|
|
1129
|
+
],
|
|
1130
|
+
payable: false,
|
|
1131
|
+
stateMutability: "view",
|
|
1132
|
+
type: "function"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
constant: false,
|
|
1136
|
+
inputs: [
|
|
1137
|
+
{
|
|
1138
|
+
internalType: "address",
|
|
1139
|
+
name: "",
|
|
1140
|
+
type: "address"
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
internalType: "address",
|
|
1144
|
+
name: "",
|
|
1145
|
+
type: "address"
|
|
1146
|
+
}
|
|
1147
|
+
],
|
|
1148
|
+
name: "initialize",
|
|
1149
|
+
outputs: [],
|
|
1150
|
+
payable: false,
|
|
1151
|
+
stateMutability: "nonpayable",
|
|
1152
|
+
type: "function"
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
constant: true,
|
|
1156
|
+
inputs: [],
|
|
1157
|
+
name: "kLast",
|
|
1158
|
+
outputs: [
|
|
1159
|
+
{
|
|
1160
|
+
internalType: "uint256",
|
|
1161
|
+
name: "",
|
|
1162
|
+
type: "uint256"
|
|
1163
|
+
}
|
|
1164
|
+
],
|
|
1165
|
+
payable: false,
|
|
1166
|
+
stateMutability: "view",
|
|
1167
|
+
type: "function"
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
constant: false,
|
|
1171
|
+
inputs: [
|
|
1172
|
+
{
|
|
1173
|
+
internalType: "address",
|
|
1174
|
+
name: "to",
|
|
1175
|
+
type: "address"
|
|
1176
|
+
}
|
|
1177
|
+
],
|
|
1178
|
+
name: "mint",
|
|
1179
|
+
outputs: [
|
|
1180
|
+
{
|
|
1181
|
+
internalType: "uint256",
|
|
1182
|
+
name: "liquidity",
|
|
1183
|
+
type: "uint256"
|
|
1184
|
+
}
|
|
1185
|
+
],
|
|
1186
|
+
payable: false,
|
|
1187
|
+
stateMutability: "nonpayable",
|
|
1188
|
+
type: "function"
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
constant: true,
|
|
1192
|
+
inputs: [],
|
|
1193
|
+
name: "name",
|
|
1194
|
+
outputs: [
|
|
1195
|
+
{
|
|
1196
|
+
internalType: "string",
|
|
1197
|
+
name: "",
|
|
1198
|
+
type: "string"
|
|
1199
|
+
}
|
|
1200
|
+
],
|
|
1201
|
+
payable: false,
|
|
1202
|
+
stateMutability: "pure",
|
|
1203
|
+
type: "function"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
constant: true,
|
|
1207
|
+
inputs: [
|
|
1208
|
+
{
|
|
1209
|
+
internalType: "address",
|
|
1210
|
+
name: "owner",
|
|
1211
|
+
type: "address"
|
|
1212
|
+
}
|
|
1213
|
+
],
|
|
1214
|
+
name: "nonces",
|
|
1215
|
+
outputs: [
|
|
1216
|
+
{
|
|
1217
|
+
internalType: "uint256",
|
|
1218
|
+
name: "",
|
|
1219
|
+
type: "uint256"
|
|
1220
|
+
}
|
|
1221
|
+
],
|
|
1222
|
+
payable: false,
|
|
1223
|
+
stateMutability: "view",
|
|
1224
|
+
type: "function"
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
constant: false,
|
|
1228
|
+
inputs: [
|
|
1229
|
+
{
|
|
1230
|
+
internalType: "address",
|
|
1231
|
+
name: "owner",
|
|
1232
|
+
type: "address"
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
internalType: "address",
|
|
1236
|
+
name: "spender",
|
|
1237
|
+
type: "address"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
internalType: "uint256",
|
|
1241
|
+
name: "value",
|
|
1242
|
+
type: "uint256"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
internalType: "uint256",
|
|
1246
|
+
name: "deadline",
|
|
1247
|
+
type: "uint256"
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
internalType: "uint8",
|
|
1251
|
+
name: "v",
|
|
1252
|
+
type: "uint8"
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
internalType: "bytes32",
|
|
1256
|
+
name: "r",
|
|
1257
|
+
type: "bytes32"
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
internalType: "bytes32",
|
|
1261
|
+
name: "s",
|
|
1262
|
+
type: "bytes32"
|
|
1263
|
+
}
|
|
1264
|
+
],
|
|
1265
|
+
name: "permit",
|
|
1266
|
+
outputs: [],
|
|
1267
|
+
payable: false,
|
|
1268
|
+
stateMutability: "nonpayable",
|
|
1269
|
+
type: "function"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
constant: true,
|
|
1273
|
+
inputs: [],
|
|
1274
|
+
name: "price0CumulativeLast",
|
|
1275
|
+
outputs: [
|
|
1276
|
+
{
|
|
1277
|
+
internalType: "uint256",
|
|
1278
|
+
name: "",
|
|
1279
|
+
type: "uint256"
|
|
1280
|
+
}
|
|
1281
|
+
],
|
|
1282
|
+
payable: false,
|
|
1283
|
+
stateMutability: "view",
|
|
1284
|
+
type: "function"
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
constant: true,
|
|
1288
|
+
inputs: [],
|
|
1289
|
+
name: "price1CumulativeLast",
|
|
1290
|
+
outputs: [
|
|
1291
|
+
{
|
|
1292
|
+
internalType: "uint256",
|
|
1293
|
+
name: "",
|
|
1294
|
+
type: "uint256"
|
|
1295
|
+
}
|
|
1296
|
+
],
|
|
1297
|
+
payable: false,
|
|
1298
|
+
stateMutability: "view",
|
|
1299
|
+
type: "function"
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
constant: false,
|
|
1303
|
+
inputs: [
|
|
1304
|
+
{
|
|
1305
|
+
internalType: "address",
|
|
1306
|
+
name: "to",
|
|
1307
|
+
type: "address"
|
|
1308
|
+
}
|
|
1309
|
+
],
|
|
1310
|
+
name: "skim",
|
|
1311
|
+
outputs: [],
|
|
1312
|
+
payable: false,
|
|
1313
|
+
stateMutability: "nonpayable",
|
|
1314
|
+
type: "function"
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
constant: false,
|
|
1318
|
+
inputs: [
|
|
1319
|
+
{
|
|
1320
|
+
internalType: "uint256",
|
|
1321
|
+
name: "amount0Out",
|
|
1322
|
+
type: "uint256"
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
internalType: "uint256",
|
|
1326
|
+
name: "amount1Out",
|
|
1327
|
+
type: "uint256"
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
internalType: "address",
|
|
1331
|
+
name: "to",
|
|
1332
|
+
type: "address"
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
internalType: "bytes",
|
|
1336
|
+
name: "data",
|
|
1337
|
+
type: "bytes"
|
|
1338
|
+
}
|
|
1339
|
+
],
|
|
1340
|
+
name: "swap",
|
|
1341
|
+
outputs: [],
|
|
1342
|
+
payable: false,
|
|
1343
|
+
stateMutability: "nonpayable",
|
|
1344
|
+
type: "function"
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
constant: true,
|
|
1348
|
+
inputs: [],
|
|
1349
|
+
name: "symbol",
|
|
1350
|
+
outputs: [
|
|
1351
|
+
{
|
|
1352
|
+
internalType: "string",
|
|
1353
|
+
name: "",
|
|
1354
|
+
type: "string"
|
|
1355
|
+
}
|
|
1356
|
+
],
|
|
1357
|
+
payable: false,
|
|
1358
|
+
stateMutability: "pure",
|
|
1359
|
+
type: "function"
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
constant: false,
|
|
1363
|
+
inputs: [],
|
|
1364
|
+
name: "sync",
|
|
1365
|
+
outputs: [],
|
|
1366
|
+
payable: false,
|
|
1367
|
+
stateMutability: "nonpayable",
|
|
1368
|
+
type: "function"
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
constant: true,
|
|
1372
|
+
inputs: [],
|
|
1373
|
+
name: "token0",
|
|
1374
|
+
outputs: [
|
|
1375
|
+
{
|
|
1376
|
+
internalType: "address",
|
|
1377
|
+
name: "",
|
|
1378
|
+
type: "address"
|
|
1379
|
+
}
|
|
1380
|
+
],
|
|
1381
|
+
payable: false,
|
|
1382
|
+
stateMutability: "view",
|
|
1383
|
+
type: "function"
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
constant: true,
|
|
1387
|
+
inputs: [],
|
|
1388
|
+
name: "token1",
|
|
1389
|
+
outputs: [
|
|
1390
|
+
{
|
|
1391
|
+
internalType: "address",
|
|
1392
|
+
name: "",
|
|
1393
|
+
type: "address"
|
|
1394
|
+
}
|
|
1395
|
+
],
|
|
1396
|
+
payable: false,
|
|
1397
|
+
stateMutability: "view",
|
|
1398
|
+
type: "function"
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
constant: true,
|
|
1402
|
+
inputs: [],
|
|
1403
|
+
name: "totalSupply",
|
|
1404
|
+
outputs: [
|
|
1405
|
+
{
|
|
1406
|
+
internalType: "uint256",
|
|
1407
|
+
name: "",
|
|
1408
|
+
type: "uint256"
|
|
1409
|
+
}
|
|
1410
|
+
],
|
|
1411
|
+
payable: false,
|
|
1412
|
+
stateMutability: "view",
|
|
1413
|
+
type: "function"
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
constant: false,
|
|
1417
|
+
inputs: [
|
|
1418
|
+
{
|
|
1419
|
+
internalType: "address",
|
|
1420
|
+
name: "to",
|
|
1421
|
+
type: "address"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
internalType: "uint256",
|
|
1425
|
+
name: "value",
|
|
1426
|
+
type: "uint256"
|
|
1427
|
+
}
|
|
1428
|
+
],
|
|
1429
|
+
name: "transfer",
|
|
1430
|
+
outputs: [
|
|
1431
|
+
{
|
|
1432
|
+
internalType: "bool",
|
|
1433
|
+
name: "",
|
|
1434
|
+
type: "bool"
|
|
1435
|
+
}
|
|
1436
|
+
],
|
|
1437
|
+
payable: false,
|
|
1438
|
+
stateMutability: "nonpayable",
|
|
1439
|
+
type: "function"
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
constant: false,
|
|
1443
|
+
inputs: [
|
|
1444
|
+
{
|
|
1445
|
+
internalType: "address",
|
|
1446
|
+
name: "from",
|
|
1447
|
+
type: "address"
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
internalType: "address",
|
|
1451
|
+
name: "to",
|
|
1452
|
+
type: "address"
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
internalType: "uint256",
|
|
1456
|
+
name: "value",
|
|
1457
|
+
type: "uint256"
|
|
1458
|
+
}
|
|
1459
|
+
],
|
|
1460
|
+
name: "transferFrom",
|
|
1461
|
+
outputs: [
|
|
1462
|
+
{
|
|
1463
|
+
internalType: "bool",
|
|
1464
|
+
name: "",
|
|
1465
|
+
type: "bool"
|
|
1466
|
+
}
|
|
1467
|
+
],
|
|
1468
|
+
payable: false,
|
|
1469
|
+
stateMutability: "nonpayable",
|
|
1470
|
+
type: "function"
|
|
1471
|
+
}
|
|
1472
|
+
];
|
|
1473
|
+
|
|
1474
|
+
// src/fetcher.ts
|
|
1475
|
+
var TOKEN_DECIMALS_CACHE = {
|
|
1476
|
+
[56 /* BSC */]: {}
|
|
1477
|
+
};
|
|
1478
|
+
var Fetcher = class {
|
|
1479
|
+
/**
|
|
1480
|
+
* Cannot be constructed.
|
|
1481
|
+
*/
|
|
1482
|
+
// eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-empty-function
|
|
1483
|
+
constructor() {
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Fetch information for a given token on the given chain, using the given ethers provider.
|
|
1487
|
+
* @param chainId chain of the token
|
|
1488
|
+
* @param address address of the token on the chain
|
|
1489
|
+
* @param provider provider used to fetch the token
|
|
1490
|
+
* @param symbol symbol of the token
|
|
1491
|
+
* @param name optional name of the token
|
|
1492
|
+
*/
|
|
1493
|
+
static async fetchTokenData(chainId, address, provider = providers.getDefaultProvider(networks.getNetwork(chainId)), symbol, name) {
|
|
1494
|
+
var _a;
|
|
1495
|
+
const parsedDecimals = typeof ((_a = TOKEN_DECIMALS_CACHE == null ? void 0 : TOKEN_DECIMALS_CACHE[chainId]) == null ? void 0 : _a[address]) === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await new contracts.Contract(address, ERC20_default, provider).decimals().then((decimals) => {
|
|
1496
|
+
TOKEN_DECIMALS_CACHE = {
|
|
1497
|
+
...TOKEN_DECIMALS_CACHE,
|
|
1498
|
+
[chainId]: {
|
|
1499
|
+
...TOKEN_DECIMALS_CACHE == null ? void 0 : TOKEN_DECIMALS_CACHE[chainId],
|
|
1500
|
+
[address]: decimals
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
return decimals;
|
|
1504
|
+
});
|
|
1505
|
+
return new swapSdkCore.Token(chainId, address, parsedDecimals, symbol, name);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Fetches information about a pair and constructs a pair from the given two tokens.
|
|
1509
|
+
* @param tokenA first token
|
|
1510
|
+
* @param tokenB second token
|
|
1511
|
+
* @param provider the provider to use to fetch the data
|
|
1512
|
+
*/
|
|
1513
|
+
static async fetchPairData(tokenA, tokenB, provider = providers.getDefaultProvider(networks.getNetwork(tokenA.chainId))) {
|
|
1514
|
+
invariant4__default.default(tokenA.chainId === tokenB.chainId, "CHAIN_ID");
|
|
1515
|
+
const address = Pair.getAddress(tokenA, tokenB);
|
|
1516
|
+
const [reserves0, reserves1] = await new contracts.Contract(address, IPancakePair_default, provider).getReserves();
|
|
1517
|
+
const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0];
|
|
1518
|
+
return new Pair(
|
|
1519
|
+
swapSdkCore.CurrencyAmount.fromRawAmount(tokenA, balances[0]),
|
|
1520
|
+
swapSdkCore.CurrencyAmount.fromRawAmount(tokenB, balances[1])
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
Object.defineProperty(exports, 'JSBI', {
|
|
1526
|
+
enumerable: true,
|
|
1527
|
+
get: function () { return JSBI__default.default; }
|
|
1528
|
+
});
|
|
1529
|
+
exports.ChainId = ChainId;
|
|
1530
|
+
exports.ERC20Token = ERC20Token;
|
|
1531
|
+
exports.Ether = Ether;
|
|
1532
|
+
exports.FACTORY_ADDRESS = FACTORY_ADDRESS;
|
|
1533
|
+
exports.FACTORY_ADDRESS_MAP = FACTORY_ADDRESS_MAP;
|
|
1534
|
+
exports.Fetcher = Fetcher;
|
|
1535
|
+
exports.INIT_CODE_HASH = INIT_CODE_HASH;
|
|
1536
|
+
exports.INIT_CODE_HASH_MAP = INIT_CODE_HASH_MAP;
|
|
1537
|
+
exports.NATIVE = NATIVE;
|
|
1538
|
+
exports.Native = Native;
|
|
1539
|
+
exports.ONE_HUNDRED_PERCENT = ONE_HUNDRED_PERCENT;
|
|
1540
|
+
exports.Pair = Pair;
|
|
1541
|
+
exports.Route = Route;
|
|
1542
|
+
exports.Router = Router;
|
|
1543
|
+
exports.Trade = Trade;
|
|
1544
|
+
exports.WBNB = WBNB;
|
|
1545
|
+
exports.WETH9 = WETH9;
|
|
1546
|
+
exports.WNATIVE = WNATIVE;
|
|
1547
|
+
exports.ZERO_PERCENT = ZERO_PERCENT;
|
|
1548
|
+
exports.computePairAddress = computePairAddress;
|
|
1549
|
+
exports.inputOutputComparator = inputOutputComparator;
|
|
1550
|
+
exports.isTradeBetter = isTradeBetter;
|
|
1551
|
+
exports.tradeComparator = tradeComparator;
|
|
1552
|
+
exports.validateAndParseAddress = validateAndParseAddress;
|
|
1553
|
+
Object.keys(swapSdkCore).forEach(function (k) {
|
|
1554
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1555
|
+
enumerable: true,
|
|
1556
|
+
get: function () { return swapSdkCore[k]; }
|
|
1557
|
+
});
|
|
810
1558
|
});
|