@curvefi/api 2.25.3 → 2.25.5
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 +5 -0
- package/lib/boosting.d.ts +1 -0
- package/lib/boosting.js +10 -2
- package/lib/curve.js +21 -119
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/router.d.ts +0 -3
- package/lib/router.js +15 -246
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1055,6 +1055,8 @@ import curve from "@curvefi/api";
|
|
|
1055
1055
|
// '0x07f6daedb705446cb56ab42c18ba9ec5302ef5ed9c7ef0bb5c3c92493abcfc79'
|
|
1056
1056
|
// ]
|
|
1057
1057
|
|
|
1058
|
+
curve.boosting.calcUnlockTime(365); // now (by default) + 365 days, rounded down by WEEK
|
|
1059
|
+
// 1657152000000
|
|
1058
1060
|
await curve.boosting.createLock(1000, 365);
|
|
1059
1061
|
// 99000.0 CRV
|
|
1060
1062
|
// { lockedAmount: '1000.0', unlockTime: 1657152000000 }
|
|
@@ -1067,6 +1069,9 @@ import curve from "@curvefi/api";
|
|
|
1067
1069
|
// 372.289692732093137414 veCRV
|
|
1068
1070
|
// 0.000009285953543912 veCRV %
|
|
1069
1071
|
|
|
1072
|
+
const { unlockTime: currentUnlockTime } = await curve.boosting.getLockedAmountAndUnlockTime();
|
|
1073
|
+
curve.boosting.calcUnlockTime(365, currentUnlockTime); // currentUnlockTime + 365 days, rounded down by WEEK
|
|
1074
|
+
// 1688601600000
|
|
1070
1075
|
await curve.boosting.increaseUnlockTime(365);
|
|
1071
1076
|
// 98500.0 CRV
|
|
1072
1077
|
// { lockedAmount: '1500.0', unlockTime: 1688601600000 }
|
package/lib/boosting.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const isApproved: (amount: number | string) => Promise<boolean>;
|
|
|
13
13
|
export declare const approveEstimateGas: (amount: number | string) => Promise<number>;
|
|
14
14
|
export declare const approve: (amount: number | string) => Promise<string[]>;
|
|
15
15
|
export declare const createLockEstimateGas: (amount: number | string, days: number) => Promise<number>;
|
|
16
|
+
export declare const calcUnlockTime: (days: number, start?: number) => number;
|
|
16
17
|
export declare const createLock: (amount: number | string, days: number) => Promise<string>;
|
|
17
18
|
export declare const increaseAmountEstimateGas: (amount: number | string) => Promise<number>;
|
|
18
19
|
export declare const increaseAmount: (amount: number | string) => Promise<string>;
|
package/lib/boosting.js
CHANGED
|
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.claimFees = exports.claimFeesEstimateGas = exports.claimableFees = exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
53
|
+
exports.claimFees = exports.claimFeesEstimateGas = exports.claimableFees = exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.calcUnlockTime = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
54
54
|
var ethers_1 = require("ethers");
|
|
55
55
|
var curve_1 = require("./curve");
|
|
56
56
|
var fee_distributor_view_json_1 = __importDefault(require("./constants/abis/fee_distributor_view.json"));
|
|
@@ -218,13 +218,21 @@ var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, v
|
|
|
218
218
|
});
|
|
219
219
|
}); };
|
|
220
220
|
exports.createLockEstimateGas = createLockEstimateGas;
|
|
221
|
+
var calcUnlockTime = function (days, start) {
|
|
222
|
+
if (start === void 0) { start = Date.now(); }
|
|
223
|
+
var week = 86400 * 7;
|
|
224
|
+
var now = start / 1000;
|
|
225
|
+
var unlockTime = now + (86400 * days);
|
|
226
|
+
return Math.floor(unlockTime / week) * week * 1000;
|
|
227
|
+
};
|
|
228
|
+
exports.calcUnlockTime = calcUnlockTime;
|
|
221
229
|
var createLock = function (amount, days) { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
230
|
var _amount, unlockTime, contract, gasLimit;
|
|
223
231
|
return __generator(this, function (_a) {
|
|
224
232
|
switch (_a.label) {
|
|
225
233
|
case 0:
|
|
226
234
|
_amount = (0, utils_2.parseUnits)(amount);
|
|
227
|
-
unlockTime = Math.floor(Date.now() / 1000) + (
|
|
235
|
+
unlockTime = Math.floor(Date.now() / 1000) + (86400 * days);
|
|
228
236
|
return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow)];
|
|
229
237
|
case 1:
|
|
230
238
|
_a.sent();
|
package/lib/curve.js
CHANGED
|
@@ -449,34 +449,19 @@ var Curve = /** @class */ (function () {
|
|
|
449
449
|
_o.sent();
|
|
450
450
|
for (_i = 0, _e = Object.values(this.constants.POOLS_DATA); _i < _e.length; _i++) {
|
|
451
451
|
pool = _e[_i];
|
|
452
|
-
this.
|
|
453
|
-
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
454
|
-
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
455
|
-
};
|
|
452
|
+
this.setContract(pool.swap_address, pool.swap_abi);
|
|
456
453
|
if (pool.token_address !== pool.swap_address) {
|
|
457
|
-
this.
|
|
458
|
-
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
459
|
-
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
460
|
-
};
|
|
454
|
+
this.setContract(pool.token_address, ERC20_json_1.default);
|
|
461
455
|
}
|
|
462
456
|
if (pool.gauge_address !== ethers_1.ethers.constants.AddressZero) {
|
|
463
|
-
this.
|
|
464
|
-
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
465
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
466
|
-
};
|
|
457
|
+
this.setContract(pool.gauge_address, pool.gauge_abi);
|
|
467
458
|
}
|
|
468
459
|
if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
|
|
469
|
-
this.
|
|
470
|
-
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
471
|
-
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
472
|
-
};
|
|
460
|
+
this.setContract(pool.deposit_address, pool.deposit_abi);
|
|
473
461
|
}
|
|
474
462
|
for (_f = 0, _g = pool.underlying_coin_addresses; _f < _g.length; _f++) {
|
|
475
463
|
coinAddr = _g[_f];
|
|
476
|
-
this.
|
|
477
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
478
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
479
|
-
};
|
|
464
|
+
this.setContract(coinAddr, ERC20_json_1.default);
|
|
480
465
|
}
|
|
481
466
|
for (_h = 0, _j = pool.wrapped_coin_addresses; _h < _j.length; _h++) {
|
|
482
467
|
coinAddr = _j[_h];
|
|
@@ -484,135 +469,52 @@ var Curve = /** @class */ (function () {
|
|
|
484
469
|
continue;
|
|
485
470
|
if (coinAddr in this.contracts)
|
|
486
471
|
continue;
|
|
487
|
-
this.
|
|
488
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
489
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
490
|
-
};
|
|
472
|
+
this.setContract(coinAddr, ERC20_json_1.default);
|
|
491
473
|
}
|
|
492
474
|
// TODO add all coins
|
|
493
475
|
for (_k = 0, _l = pool.wrapped_coin_addresses; _k < _l.length; _k++) {
|
|
494
476
|
coinAddr = _l[_k];
|
|
495
477
|
if (cTokens.includes(coinAddr)) {
|
|
496
|
-
this.
|
|
497
|
-
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
498
|
-
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
499
|
-
};
|
|
478
|
+
this.setContract(coinAddr, cERC20_json_1.default);
|
|
500
479
|
}
|
|
501
480
|
if (aTokens.includes(coinAddr)) {
|
|
502
|
-
this.
|
|
503
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
504
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
505
|
-
};
|
|
481
|
+
this.setContract(coinAddr, ERC20_json_1.default);
|
|
506
482
|
}
|
|
507
483
|
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
508
|
-
this.
|
|
509
|
-
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
510
|
-
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
511
|
-
};
|
|
484
|
+
this.setContract(coinAddr, yERC20_json_1.default);
|
|
512
485
|
}
|
|
513
486
|
}
|
|
514
487
|
if (pool.reward_contract) {
|
|
515
|
-
this.
|
|
516
|
-
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
517
|
-
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
518
|
-
};
|
|
488
|
+
this.setContract(pool.reward_contract, streamer_json_1.default);
|
|
519
489
|
}
|
|
520
490
|
if (pool.sCurveRewards_address) {
|
|
521
|
-
this.
|
|
522
|
-
contract: new ethers_1.Contract(pool.sCurveRewards_address, pool.sCurveRewards_abi, this.signer || this.provider),
|
|
523
|
-
multicallContract: new ethcall_1.Contract(pool.sCurveRewards_address, pool.sCurveRewards_abi),
|
|
524
|
-
};
|
|
491
|
+
this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
|
|
525
492
|
}
|
|
526
493
|
}
|
|
527
494
|
this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20_json_1.default);
|
|
528
|
-
this.
|
|
529
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
530
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default),
|
|
531
|
-
};
|
|
532
|
-
this.contracts[this.constants.ALIASES.crv.toLowerCase()] = {
|
|
533
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
534
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default),
|
|
535
|
-
};
|
|
495
|
+
this.setContract(this.constants.ALIASES.crv, ERC20_json_1.default);
|
|
536
496
|
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
537
497
|
_minterABI = this.chainId === 1 ? minter_json_1.default : minter_child_json_1.default;
|
|
538
|
-
this.
|
|
539
|
-
|
|
540
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.minter, _minterABI),
|
|
541
|
-
};
|
|
542
|
-
this.contracts[this.constants.ALIASES.minter.toLowerCase()] = {
|
|
543
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.minter, _minterABI, this.signer || this.provider),
|
|
544
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.minter, _minterABI),
|
|
545
|
-
};
|
|
546
|
-
this.contracts[this.constants.ALIASES.voting_escrow] = {
|
|
547
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
548
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
549
|
-
};
|
|
550
|
-
this.contracts[this.constants.ALIASES.voting_escrow.toLowerCase()] = {
|
|
551
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
552
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
553
|
-
};
|
|
498
|
+
this.setContract(this.constants.ALIASES.minter, _minterABI);
|
|
499
|
+
this.setContract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default);
|
|
554
500
|
this.setContract(this.constants.ALIASES.fee_distributor, fee_distributor_json_1.default);
|
|
555
|
-
this.
|
|
556
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
557
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default),
|
|
558
|
-
};
|
|
559
|
-
this.contracts[this.constants.ALIASES.address_provider.toLowerCase()] = {
|
|
560
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
561
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default),
|
|
562
|
-
};
|
|
501
|
+
this.setContract(this.constants.ALIASES.address_provider, address_provider_json_1.default);
|
|
563
502
|
addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
|
|
564
503
|
_m = this.constants.ALIASES;
|
|
565
504
|
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
566
505
|
case 12:
|
|
567
|
-
_m.registry_exchange = _o.sent();
|
|
568
|
-
this.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
};
|
|
572
|
-
this.contracts[this.constants.ALIASES.registry_exchange.toLowerCase()] = {
|
|
573
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
574
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
575
|
-
};
|
|
576
|
-
this.contracts[this.constants.ALIASES.gauge_controller] = {
|
|
577
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
578
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
579
|
-
};
|
|
580
|
-
this.contracts[this.constants.ALIASES.gauge_controller.toLowerCase()] = {
|
|
581
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
582
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
583
|
-
};
|
|
584
|
-
this.contracts[this.constants.ALIASES.router] = {
|
|
585
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
586
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.router, router_json_1.default),
|
|
587
|
-
};
|
|
588
|
-
this.contracts[this.constants.ALIASES.router.toLowerCase()] = {
|
|
589
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
590
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.router, router_json_1.default),
|
|
591
|
-
};
|
|
506
|
+
_m.registry_exchange = (_o.sent()).toLowerCase();
|
|
507
|
+
this.setContract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default);
|
|
508
|
+
this.setContract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default);
|
|
509
|
+
this.setContract(this.constants.ALIASES.router, router_json_1.default);
|
|
592
510
|
if (this.chainId === 137) {
|
|
593
511
|
this.setContract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_6coins_json_1.default);
|
|
594
|
-
this.setContract(this.constants.ALIASES.deposit_and_stake.toLowerCase(), deposit_and_stake_6coins_json_1.default);
|
|
595
512
|
}
|
|
596
513
|
else {
|
|
597
514
|
this.setContract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default);
|
|
598
|
-
this.setContract(this.constants.ALIASES.deposit_and_stake.toLowerCase(), deposit_and_stake_json_1.default);
|
|
599
515
|
}
|
|
600
|
-
this.
|
|
601
|
-
|
|
602
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.factory, factory_json_1.default),
|
|
603
|
-
};
|
|
604
|
-
this.contracts[this.constants.ALIASES.factory.toLowerCase()] = {
|
|
605
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.factory, factory_json_1.default, this.signer || this.provider),
|
|
606
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.factory, factory_json_1.default),
|
|
607
|
-
};
|
|
608
|
-
this.contracts[this.constants.ALIASES.crypto_factory] = {
|
|
609
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default, this.signer || this.provider),
|
|
610
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default),
|
|
611
|
-
};
|
|
612
|
-
this.contracts[this.constants.ALIASES.crypto_factory.toLowerCase()] = {
|
|
613
|
-
contract: new ethers_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default, this.signer || this.provider),
|
|
614
|
-
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default),
|
|
615
|
-
};
|
|
516
|
+
this.setContract(this.constants.ALIASES.factory, factory_json_1.default);
|
|
517
|
+
this.setContract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default);
|
|
616
518
|
return [2 /*return*/];
|
|
617
519
|
}
|
|
618
520
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ declare const curve: {
|
|
|
96
96
|
}>;
|
|
97
97
|
getVeCrv: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").IDict<string>>;
|
|
98
98
|
getVeCrvPct: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").IDict<string>>;
|
|
99
|
+
calcUnlockTime: (days: number, start?: number) => number;
|
|
99
100
|
isApproved: (amount: string | number) => Promise<boolean>;
|
|
100
101
|
approve: (amount: string | number) => Promise<string[]>;
|
|
101
102
|
createLock: (amount: string | number, days: number) => Promise<string>;
|
package/lib/index.js
CHANGED
|
@@ -175,6 +175,7 @@ var curve = {
|
|
|
175
175
|
getLockedAmountAndUnlockTime: boosting_1.getLockedAmountAndUnlockTime,
|
|
176
176
|
getVeCrv: boosting_1.getVeCrv,
|
|
177
177
|
getVeCrvPct: boosting_1.getVeCrvPct,
|
|
178
|
+
calcUnlockTime: boosting_1.calcUnlockTime,
|
|
178
179
|
isApproved: boosting_1.isApproved,
|
|
179
180
|
approve: boosting_1.approve,
|
|
180
181
|
createLock: boosting_1.createLock,
|
package/lib/router.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { IRouteStep } from "./interfaces";
|
|
3
|
-
export declare const _findAllRoutesTheShorterTheBetter: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
|
4
|
-
export declare const _findAllRoutesTvl: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
|
5
|
-
export declare const _findAllRoutes: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
|
6
3
|
export declare const getBestRouteAndOutput: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<{
|
|
7
4
|
route: IRouteStep[];
|
|
8
5
|
output: string;
|
package/lib/router.js
CHANGED
|
@@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.getSwappedAmount = exports.swap = exports.swapEstimateGas = exports.swapApprove = exports.swapApproveEstimateGas = exports.swapIsApproved = exports.swapPriceImpact = exports.swapExpected = exports.getBestRouteAndOutput =
|
|
62
|
+
exports.getSwappedAmount = exports.swap = exports.swapEstimateGas = exports.swapApprove = exports.swapApproveEstimateGas = exports.swapIsApproved = exports.swapPriceImpact = exports.swapExpected = exports.getBestRouteAndOutput = void 0;
|
|
63
63
|
var axios_1 = __importDefault(require("axios"));
|
|
64
64
|
var memoizee_1 = __importDefault(require("memoizee"));
|
|
65
65
|
var ethers_1 = require("ethers");
|
|
@@ -67,228 +67,6 @@ var curve_1 = require("./curve");
|
|
|
67
67
|
var utils_1 = require("./utils");
|
|
68
68
|
var pools_1 = require("./pools");
|
|
69
69
|
var utils_2 = require("./pools/utils");
|
|
70
|
-
// --------------------------- LEGACY ROUTER ---------------------------
|
|
71
|
-
// Inspired by Dijkstra's algorithm
|
|
72
|
-
var _findAllRoutesTheShorterTheBetter = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var ALL_POOLS, basePoolsSet, _i, ALL_POOLS_1, pool, basePoolIds, markedCoins, curCoins, nextCoins, routes, step, _a, curCoins_1, inCoin, _b, ALL_POOLS_2, _c, poolId, poolData, wrapped_coin_addresses, underlying_coin_addresses, base_pool, meta_coin_addresses, token_address, is_lending, inCoinIndexes, j, swapType, _d, _e, inCoinRoute, flag, swapType, _f, _h, inCoinRoute, j, tvl, _j, swapType, _k, _l, inCoinRoute, poolAddress, j, tvl, _m, hasEth, swapType, _o, _p, inCoinRoute;
|
|
74
|
-
var _q;
|
|
75
|
-
var _r, _s, _t, _u, _v, _w;
|
|
76
|
-
return __generator(this, function (_x) {
|
|
77
|
-
switch (_x.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
inputCoinAddress = inputCoinAddress.toLowerCase();
|
|
80
|
-
outputCoinAddress = outputCoinAddress.toLowerCase();
|
|
81
|
-
ALL_POOLS = Object.entries(__assign(__assign(__assign({}, curve_1.curve.constants.POOLS_DATA), curve_1.curve.constants.FACTORY_POOLS_DATA), curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA));
|
|
82
|
-
basePoolsSet = new Set();
|
|
83
|
-
for (_i = 0, ALL_POOLS_1 = ALL_POOLS; _i < ALL_POOLS_1.length; _i++) {
|
|
84
|
-
pool = ALL_POOLS_1[_i];
|
|
85
|
-
if (pool[1].wrapped_coin_addresses.length < 6)
|
|
86
|
-
basePoolsSet.add(pool[0]);
|
|
87
|
-
}
|
|
88
|
-
basePoolIds = Array.from(basePoolsSet);
|
|
89
|
-
markedCoins = [];
|
|
90
|
-
curCoins = [inputCoinAddress];
|
|
91
|
-
nextCoins = new Set();
|
|
92
|
-
routes = (_q = {},
|
|
93
|
-
_q[inputCoinAddress] = [[]],
|
|
94
|
-
_q);
|
|
95
|
-
step = 0;
|
|
96
|
-
_x.label = 1;
|
|
97
|
-
case 1:
|
|
98
|
-
if (!(step < 4)) return [3 /*break*/, 15];
|
|
99
|
-
_a = 0, curCoins_1 = curCoins;
|
|
100
|
-
_x.label = 2;
|
|
101
|
-
case 2:
|
|
102
|
-
if (!(_a < curCoins_1.length)) return [3 /*break*/, 13];
|
|
103
|
-
inCoin = curCoins_1[_a];
|
|
104
|
-
_b = 0, ALL_POOLS_2 = ALL_POOLS;
|
|
105
|
-
_x.label = 3;
|
|
106
|
-
case 3:
|
|
107
|
-
if (!(_b < ALL_POOLS_2.length)) return [3 /*break*/, 12];
|
|
108
|
-
_c = ALL_POOLS_2[_b], poolId = _c[0], poolData = _c[1];
|
|
109
|
-
wrapped_coin_addresses = poolData.wrapped_coin_addresses.map(function (a) { return a.toLowerCase(); });
|
|
110
|
-
underlying_coin_addresses = poolData.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); });
|
|
111
|
-
base_pool = poolData.is_meta ? curve_1.curve.constants.POOLS_DATA[poolData.base_pool] : null;
|
|
112
|
-
meta_coin_addresses = base_pool ? base_pool.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); }) : [];
|
|
113
|
-
token_address = poolData.token_address.toLowerCase();
|
|
114
|
-
is_lending = (_r = poolData.is_lending) !== null && _r !== void 0 ? _r : false;
|
|
115
|
-
inCoinIndexes = {
|
|
116
|
-
wrapped_coin: wrapped_coin_addresses.indexOf(inCoin),
|
|
117
|
-
underlying_coin: underlying_coin_addresses.indexOf(inCoin),
|
|
118
|
-
meta_coin: meta_coin_addresses ? meta_coin_addresses.indexOf(inCoin) : -1,
|
|
119
|
-
};
|
|
120
|
-
// LP -> wrapped coin "swaps" (actually remove_liquidity_one_coin)
|
|
121
|
-
if (basePoolIds.includes(poolId) && inCoin === token_address) {
|
|
122
|
-
for (j = 0; j < wrapped_coin_addresses.length; j++) {
|
|
123
|
-
// If this coin already marked or will be marked on the current step, no need to consider it on the next step
|
|
124
|
-
if (markedCoins.includes(wrapped_coin_addresses[j]) || curCoins.includes(wrapped_coin_addresses[j]))
|
|
125
|
-
continue;
|
|
126
|
-
// Looking for outputCoinAddress only on the final step
|
|
127
|
-
if (step === 3 && wrapped_coin_addresses[j] !== outputCoinAddress)
|
|
128
|
-
continue;
|
|
129
|
-
swapType = poolId === 'aave' ? 11 : 10;
|
|
130
|
-
for (_d = 0, _e = routes[inCoin]; _d < _e.length; _d++) {
|
|
131
|
-
inCoinRoute = _e[_d];
|
|
132
|
-
routes[wrapped_coin_addresses[j]] = ((_s = routes[wrapped_coin_addresses[j]]) !== null && _s !== void 0 ? _s : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
|
|
133
|
-
{
|
|
134
|
-
poolId: poolId,
|
|
135
|
-
poolAddress: poolData.swap_address,
|
|
136
|
-
inputCoinAddress: inCoin,
|
|
137
|
-
outputCoinAddress: wrapped_coin_addresses[j],
|
|
138
|
-
i: 0,
|
|
139
|
-
j: j,
|
|
140
|
-
swapType: swapType,
|
|
141
|
-
swapAddress: ethers_1.ethers.constants.AddressZero,
|
|
142
|
-
},
|
|
143
|
-
], false)]);
|
|
144
|
-
}
|
|
145
|
-
nextCoins.add(wrapped_coin_addresses[j]);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Wrapped coin -> LP "swaps" (actually add_liquidity)
|
|
149
|
-
if (basePoolIds.includes(poolId) && wrapped_coin_addresses.includes(inCoin)) {
|
|
150
|
-
flag = true;
|
|
151
|
-
// If this coin already marked or will be marked on the current step, no need to consider it on the next step
|
|
152
|
-
if (markedCoins.includes(token_address) || curCoins.includes(token_address))
|
|
153
|
-
flag = false;
|
|
154
|
-
// Looking for outputCoinAddress only on the final step
|
|
155
|
-
if (step === 3 && token_address !== outputCoinAddress)
|
|
156
|
-
flag = false;
|
|
157
|
-
if (flag) {
|
|
158
|
-
swapType = is_lending ? 9 : wrapped_coin_addresses.length === 2 ? 7 : 8;
|
|
159
|
-
for (_f = 0, _h = routes[inCoin]; _f < _h.length; _f++) {
|
|
160
|
-
inCoinRoute = _h[_f];
|
|
161
|
-
routes[token_address] = ((_t = routes[token_address]) !== null && _t !== void 0 ? _t : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
|
|
162
|
-
{
|
|
163
|
-
poolId: poolId,
|
|
164
|
-
poolAddress: poolData.swap_address,
|
|
165
|
-
inputCoinAddress: inCoin,
|
|
166
|
-
outputCoinAddress: token_address,
|
|
167
|
-
i: wrapped_coin_addresses.indexOf(inCoin),
|
|
168
|
-
j: 0,
|
|
169
|
-
swapType: swapType,
|
|
170
|
-
swapAddress: ethers_1.ethers.constants.AddressZero,
|
|
171
|
-
},
|
|
172
|
-
], false)]);
|
|
173
|
-
}
|
|
174
|
-
nextCoins.add(token_address);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// No input coin in this pool --> skip
|
|
178
|
-
if (inCoinIndexes.wrapped_coin === -1 && inCoinIndexes.underlying_coin === -1 && inCoinIndexes.meta_coin === -1)
|
|
179
|
-
return [3 /*break*/, 11];
|
|
180
|
-
if (!(inCoinIndexes.wrapped_coin >= 0 && !poolData.is_fake)) return [3 /*break*/, 7];
|
|
181
|
-
j = 0;
|
|
182
|
-
_x.label = 4;
|
|
183
|
-
case 4:
|
|
184
|
-
if (!(j < wrapped_coin_addresses.length)) return [3 /*break*/, 7];
|
|
185
|
-
// If this coin already marked or will be marked on the current step, no need to consider it on the next step
|
|
186
|
-
if (markedCoins.includes(wrapped_coin_addresses[j]) || curCoins.includes(wrapped_coin_addresses[j]))
|
|
187
|
-
return [3 /*break*/, 6];
|
|
188
|
-
// Native swaps spend less gas
|
|
189
|
-
if (wrapped_coin_addresses[j] !== outputCoinAddress && wrapped_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.wrappedAddress)
|
|
190
|
-
return [3 /*break*/, 6];
|
|
191
|
-
// Looking for outputCoinAddress only on the final step
|
|
192
|
-
if (step === 3 && wrapped_coin_addresses[j] !== outputCoinAddress)
|
|
193
|
-
return [3 /*break*/, 6];
|
|
194
|
-
_j = Number;
|
|
195
|
-
return [4 /*yield*/, ((0, pools_1.getPool)(poolId)).stats.totalLiquidity()];
|
|
196
|
-
case 5:
|
|
197
|
-
tvl = _j.apply(void 0, [_x.sent()]);
|
|
198
|
-
if (tvl === 0)
|
|
199
|
-
return [3 /*break*/, 6];
|
|
200
|
-
swapType = poolData.is_crypto ? 3 : 1;
|
|
201
|
-
for (_k = 0, _l = routes[inCoin]; _k < _l.length; _k++) {
|
|
202
|
-
inCoinRoute = _l[_k];
|
|
203
|
-
routes[wrapped_coin_addresses[j]] = ((_u = routes[wrapped_coin_addresses[j]]) !== null && _u !== void 0 ? _u : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
|
|
204
|
-
{
|
|
205
|
-
poolId: poolId,
|
|
206
|
-
poolAddress: poolData.swap_address,
|
|
207
|
-
inputCoinAddress: inCoin,
|
|
208
|
-
outputCoinAddress: wrapped_coin_addresses[j],
|
|
209
|
-
i: inCoinIndexes.wrapped_coin,
|
|
210
|
-
j: j,
|
|
211
|
-
swapType: swapType,
|
|
212
|
-
swapAddress: ethers_1.ethers.constants.AddressZero,
|
|
213
|
-
},
|
|
214
|
-
], false)]);
|
|
215
|
-
}
|
|
216
|
-
nextCoins.add(wrapped_coin_addresses[j]);
|
|
217
|
-
_x.label = 6;
|
|
218
|
-
case 6:
|
|
219
|
-
j++;
|
|
220
|
-
return [3 /*break*/, 4];
|
|
221
|
-
case 7:
|
|
222
|
-
poolAddress = (poolData.is_crypto && poolData.is_meta) || ((base_pool === null || base_pool === void 0 ? void 0 : base_pool.is_lending) && poolData.is_factory) ?
|
|
223
|
-
poolData.deposit_address : poolData.swap_address;
|
|
224
|
-
if (!(!poolData.is_plain && inCoinIndexes.underlying_coin >= 0)) return [3 /*break*/, 11];
|
|
225
|
-
j = 0;
|
|
226
|
-
_x.label = 8;
|
|
227
|
-
case 8:
|
|
228
|
-
if (!(j < underlying_coin_addresses.length)) return [3 /*break*/, 11];
|
|
229
|
-
// Don't swap metacoins since they can be swapped directly in base pool
|
|
230
|
-
if (inCoinIndexes.meta_coin >= 0 && meta_coin_addresses.includes(underlying_coin_addresses[j]))
|
|
231
|
-
return [3 /*break*/, 10];
|
|
232
|
-
// If this coin already marked or will be marked on the current step, no need to consider it on the next step
|
|
233
|
-
if (markedCoins.includes(underlying_coin_addresses[j]) || curCoins.includes(underlying_coin_addresses[j]))
|
|
234
|
-
return [3 /*break*/, 10];
|
|
235
|
-
// Looking for outputCoinAddress only on the final step
|
|
236
|
-
if (step === 3 && underlying_coin_addresses[j] !== outputCoinAddress)
|
|
237
|
-
return [3 /*break*/, 10];
|
|
238
|
-
_m = Number;
|
|
239
|
-
return [4 /*yield*/, ((0, pools_1.getPool)(poolId)).stats.totalLiquidity()];
|
|
240
|
-
case 9:
|
|
241
|
-
tvl = _m.apply(void 0, [_x.sent()]);
|
|
242
|
-
if (tvl === 0)
|
|
243
|
-
return [3 /*break*/, 10];
|
|
244
|
-
hasEth = (inCoin === curve_1.curve.constants.NATIVE_TOKEN.address || underlying_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.address);
|
|
245
|
-
swapType = (poolData.is_crypto && poolData.is_meta && poolData.is_factory) ? 6
|
|
246
|
-
: ((base_pool === null || base_pool === void 0 ? void 0 : base_pool.is_lending) && poolData.is_factory) ? 5
|
|
247
|
-
: hasEth ? 3
|
|
248
|
-
: poolData.is_crypto ? 4
|
|
249
|
-
: 2;
|
|
250
|
-
for (_o = 0, _p = routes[inCoin]; _o < _p.length; _o++) {
|
|
251
|
-
inCoinRoute = _p[_o];
|
|
252
|
-
routes[underlying_coin_addresses[j]] = ((_v = routes[underlying_coin_addresses[j]]) !== null && _v !== void 0 ? _v : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
|
|
253
|
-
{
|
|
254
|
-
poolId: poolId,
|
|
255
|
-
poolAddress: poolAddress,
|
|
256
|
-
inputCoinAddress: inCoin,
|
|
257
|
-
outputCoinAddress: underlying_coin_addresses[j],
|
|
258
|
-
i: inCoinIndexes.underlying_coin,
|
|
259
|
-
j: j,
|
|
260
|
-
swapType: swapType,
|
|
261
|
-
swapAddress: (swapType === 5 || swapType === 6) ? poolData.swap_address : ethers_1.ethers.constants.AddressZero,
|
|
262
|
-
},
|
|
263
|
-
], false)]);
|
|
264
|
-
}
|
|
265
|
-
nextCoins.add(underlying_coin_addresses[j]);
|
|
266
|
-
_x.label = 10;
|
|
267
|
-
case 10:
|
|
268
|
-
j++;
|
|
269
|
-
return [3 /*break*/, 8];
|
|
270
|
-
case 11:
|
|
271
|
-
_b++;
|
|
272
|
-
return [3 /*break*/, 3];
|
|
273
|
-
case 12:
|
|
274
|
-
_a++;
|
|
275
|
-
return [3 /*break*/, 2];
|
|
276
|
-
case 13:
|
|
277
|
-
// If target output coin is reached, search is finished. Assumption: the shorter route, the better.
|
|
278
|
-
if (outputCoinAddress in routes)
|
|
279
|
-
return [3 /*break*/, 15];
|
|
280
|
-
markedCoins.push.apply(markedCoins, curCoins);
|
|
281
|
-
curCoins = Array.from(nextCoins);
|
|
282
|
-
nextCoins = new Set();
|
|
283
|
-
_x.label = 14;
|
|
284
|
-
case 14:
|
|
285
|
-
step++;
|
|
286
|
-
return [3 /*break*/, 1];
|
|
287
|
-
case 15: return [2 /*return*/, (_w = routes[outputCoinAddress]) !== null && _w !== void 0 ? _w : []];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}); };
|
|
291
|
-
exports._findAllRoutesTheShorterTheBetter = _findAllRoutesTheShorterTheBetter;
|
|
292
70
|
var getNewRoute = function (route, poolId, poolAddress, inputCoinAddress, outputCoinAddress, i, j, swapType, swapAddress, tvl) {
|
|
293
71
|
var routePoolIds = route.steps.map(function (s) { return s.poolId; });
|
|
294
72
|
// Steps <= 4
|
|
@@ -303,14 +81,15 @@ var getNewRoute = function (route, poolId, poolAddress, inputCoinAddress, output
|
|
|
303
81
|
totalTvl: route.totalTvl + tvl,
|
|
304
82
|
};
|
|
305
83
|
};
|
|
306
|
-
// --------------------------- MAIN ROUTER ---------------------------
|
|
307
84
|
var MAX_ROUTES_FOR_ONE_COIN = 3;
|
|
308
85
|
var filterRoutes = function (routes, inputCoinAddress, sortFn) {
|
|
309
|
-
var routesByPoolIds = routes.map(function (r) { return r.steps.map(function (s) { return s.poolId; }).toString(); });
|
|
310
86
|
return routes
|
|
311
87
|
.filter(function (r) { return r.steps.length > 0; })
|
|
312
88
|
.filter(function (r) { return r.steps[0].inputCoinAddress === inputCoinAddress; }) // Truncated routes
|
|
313
|
-
.filter(function (r, i
|
|
89
|
+
.filter(function (r, i, _routes) {
|
|
90
|
+
var routesByPoolIds = _routes.map(function (r) { return r.steps.map(function (s) { return s.poolId; }).toString(); });
|
|
91
|
+
return routesByPoolIds.indexOf(r.steps.map(function (s) { return s.poolId; }).toString()) === i;
|
|
92
|
+
}) // Route duplications
|
|
314
93
|
.sort(sortFn).slice(0, MAX_ROUTES_FOR_ONE_COIN);
|
|
315
94
|
};
|
|
316
95
|
var sortByTvl = function (a, b) { return b.minTvl - a.minTvl || b.totalTvl - a.totalTvl || a.steps.length - b.steps.length; };
|
|
@@ -323,8 +102,8 @@ var filterMaticFactory83Route = function (routes) {
|
|
|
323
102
|
});
|
|
324
103
|
};
|
|
325
104
|
// Inspired by Dijkstra's algorithm
|
|
326
|
-
var
|
|
327
|
-
var ALL_POOLS, amplificationCoefficientDict, curCoins, nextCoins, routesByTvl, routesByLength, step, _loop_1, _i,
|
|
105
|
+
var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var ALL_POOLS, amplificationCoefficientDict, curCoins, nextCoins, routesByTvl, routesByLength, step, _loop_1, _i, curCoins_1, inCoin, routes;
|
|
328
107
|
var _a, _b;
|
|
329
108
|
var _c, _d, _e, _f, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
330
109
|
return __generator(this, function (_s) {
|
|
@@ -349,7 +128,7 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
349
128
|
case 2:
|
|
350
129
|
if (!(step < 4)) return [3 /*break*/, 8];
|
|
351
130
|
_loop_1 = function (inCoin) {
|
|
352
|
-
var outCoin_1, newRoutesByTvl, newRoutesByLength, _loop_2, _t,
|
|
131
|
+
var outCoin_1, newRoutesByTvl, newRoutesByLength, _loop_2, _t, ALL_POOLS_1, _u, poolId, poolData;
|
|
353
132
|
return __generator(this, function (_v) {
|
|
354
133
|
switch (_v.label) {
|
|
355
134
|
case 0:
|
|
@@ -518,11 +297,11 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
518
297
|
}
|
|
519
298
|
});
|
|
520
299
|
};
|
|
521
|
-
_t = 0,
|
|
300
|
+
_t = 0, ALL_POOLS_1 = ALL_POOLS;
|
|
522
301
|
_v.label = 1;
|
|
523
302
|
case 1:
|
|
524
|
-
if (!(_t <
|
|
525
|
-
_u =
|
|
303
|
+
if (!(_t < ALL_POOLS_1.length)) return [3 /*break*/, 4];
|
|
304
|
+
_u = ALL_POOLS_1[_t], poolId = _u[0], poolData = _u[1];
|
|
526
305
|
return [5 /*yield**/, _loop_2(poolId, poolData)];
|
|
527
306
|
case 2:
|
|
528
307
|
_v.sent();
|
|
@@ -534,11 +313,11 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
534
313
|
}
|
|
535
314
|
});
|
|
536
315
|
};
|
|
537
|
-
_i = 0,
|
|
316
|
+
_i = 0, curCoins_1 = curCoins;
|
|
538
317
|
_s.label = 3;
|
|
539
318
|
case 3:
|
|
540
|
-
if (!(_i <
|
|
541
|
-
inCoin =
|
|
319
|
+
if (!(_i < curCoins_1.length)) return [3 /*break*/, 6];
|
|
320
|
+
inCoin = curCoins_1[_i];
|
|
542
321
|
return [5 /*yield**/, _loop_1(inCoin)];
|
|
543
322
|
case 4:
|
|
544
323
|
_s.sent();
|
|
@@ -562,16 +341,6 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
562
341
|
}
|
|
563
342
|
});
|
|
564
343
|
}); };
|
|
565
|
-
exports._findAllRoutesTvl = _findAllRoutesTvl;
|
|
566
|
-
var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
567
|
-
return __generator(this, function (_a) {
|
|
568
|
-
switch (_a.label) {
|
|
569
|
-
case 0: return [4 /*yield*/, (0, exports._findAllRoutesTvl)(inputCoinAddress, outputCoinAddress)];
|
|
570
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
}); };
|
|
574
|
-
exports._findAllRoutes = _findAllRoutes;
|
|
575
344
|
var _getRouteKey = function (route, inputCoinAddress, outputCoinAddress) {
|
|
576
345
|
var sortedCoins = [inputCoinAddress, outputCoinAddress].sort();
|
|
577
346
|
var key = "".concat(sortedCoins[0], "-->");
|
|
@@ -654,7 +423,7 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
|
|
|
654
423
|
outputUsd: 0,
|
|
655
424
|
txCostUsd: 0,
|
|
656
425
|
}];
|
|
657
|
-
return [4 /*yield*/,
|
|
426
|
+
return [4 /*yield*/, _findAllRoutes(inputCoinAddress, outputCoinAddress)];
|
|
658
427
|
case 1:
|
|
659
428
|
routesRaw = (_f.sent()).map(function (steps) { return ({ steps: steps, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 }); });
|
|
660
429
|
routes = [];
|