@curvefi/api 2.37.0 → 2.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/lib/boosting.d.ts +10 -1
- package/lib/boosting.js +189 -0
- package/lib/constants/abis/anycall.json +552 -0
- package/lib/constants/abis/factory-tricrypto/factory-tricrypto-pool.json +1502 -0
- package/lib/constants/abis/factory-tricrypto.json +664 -0
- package/lib/constants/abis/voting_escrow_oracle.json +450 -0
- package/lib/constants/abis/voting_escrow_oracle_eth.json +76 -0
- package/lib/constants/aliases.js +11 -0
- package/lib/curve.d.ts +6 -0
- package/lib/curve.js +89 -2
- package/lib/external-api.d.ts +8 -1
- package/lib/external-api.js +16 -0
- package/lib/factory/factory-api.d.ts +1 -1
- package/lib/factory/factory-api.js +22 -37
- package/lib/factory/factory-crypto.js +1 -1
- package/lib/factory/factory-tricrypto.d.ts +2 -0
- package/lib/factory/factory-tricrypto.js +303 -0
- package/lib/index.d.ts +19 -1
- package/lib/index.js +28 -2
- package/lib/interfaces.d.ts +3 -0
- package/lib/pools/PoolTemplate.js +5 -5
- package/lib/router.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +1 -1
package/lib/curve.js
CHANGED
|
@@ -59,12 +59,16 @@ import { Provider as MulticallProvider, Contract as MulticallContract } from 'et
|
|
|
59
59
|
import { getFactoryPoolData } from "./factory/factory.js";
|
|
60
60
|
import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
|
|
61
61
|
import { getCryptoFactoryPoolData } from "./factory/factory-crypto.js";
|
|
62
|
+
import { getTricryptoFactoryPoolData } from "./factory/factory-tricrypto.js";
|
|
62
63
|
import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
|
|
63
64
|
import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
|
|
64
65
|
import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
|
|
65
66
|
import minterABI from './constants/abis/minter.json' assert { type: 'json' };
|
|
66
67
|
import minterChildABI from './constants/abis/minter_child.json' assert { type: 'json' };
|
|
67
68
|
import votingEscrowABI from './constants/abis/votingescrow.json' assert { type: 'json' };
|
|
69
|
+
import anycallABI from './constants/abis/anycall.json' assert { type: 'json' };
|
|
70
|
+
import votingEscrowOracleABI from './constants/abis/voting_escrow_oracle.json' assert { type: 'json' };
|
|
71
|
+
import votingEscrowOracleEthABI from './constants/abis/voting_escrow_oracle_eth.json' assert { type: 'json' };
|
|
68
72
|
import feeDistributorABI from './constants/abis/fee_distributor.json' assert { type: 'json' };
|
|
69
73
|
import addressProviderABI from './constants/abis/address_provider.json' assert { type: 'json' };
|
|
70
74
|
import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert { type: 'json' };
|
|
@@ -77,6 +81,7 @@ import streamerABI from './constants/abis/streamer.json' assert { type: 'json' }
|
|
|
77
81
|
import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
|
|
78
82
|
import factoryAdminABI from './constants/abis/factory-admin.json' assert { type: 'json' };
|
|
79
83
|
import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
|
|
84
|
+
import tricryptoFactoryABI from './constants/abis/factory-tricrypto.json' assert { type: 'json' };
|
|
80
85
|
import { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, } from './constants/pools/index.js';
|
|
81
86
|
import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, } from "./constants/aliases.js";
|
|
82
87
|
import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
|
|
@@ -408,6 +413,43 @@ var Curve = /** @class */ (function () {
|
|
|
408
413
|
});
|
|
409
414
|
});
|
|
410
415
|
};
|
|
416
|
+
this.fetchTricryptoFactoryPools = function (useApi) {
|
|
417
|
+
if (useApi === void 0) { useApi = true; }
|
|
418
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
419
|
+
var _a, _b, _c, _d, _e;
|
|
420
|
+
return __generator(this, function (_f) {
|
|
421
|
+
switch (_f.label) {
|
|
422
|
+
case 0:
|
|
423
|
+
if (![1].includes(this.chainId))
|
|
424
|
+
return [2 /*return*/];
|
|
425
|
+
if (!useApi) return [3 /*break*/, 2];
|
|
426
|
+
_a = this.constants;
|
|
427
|
+
_b = lowerCasePoolDataAddresses;
|
|
428
|
+
return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, "factory-tricrypto")];
|
|
429
|
+
case 1:
|
|
430
|
+
_a.TRICRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
|
|
431
|
+
return [3 /*break*/, 4];
|
|
432
|
+
case 2:
|
|
433
|
+
_c = this.constants;
|
|
434
|
+
_d = lowerCasePoolDataAddresses;
|
|
435
|
+
return [4 /*yield*/, getTricryptoFactoryPoolData.call(this)];
|
|
436
|
+
case 3:
|
|
437
|
+
_c.TRICRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
|
|
438
|
+
_f.label = 4;
|
|
439
|
+
case 4:
|
|
440
|
+
_e = this.constants;
|
|
441
|
+
return [4 /*yield*/, this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA)];
|
|
442
|
+
case 5:
|
|
443
|
+
_e.TRICRYPTO_FACTORY_POOLS_DATA = _f.sent();
|
|
444
|
+
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
445
|
+
return [4 /*yield*/, _killGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA)];
|
|
446
|
+
case 6:
|
|
447
|
+
_f.sent();
|
|
448
|
+
return [2 /*return*/];
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
};
|
|
411
453
|
this.fetchNewFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
412
454
|
var currentPoolIds, lastPoolIdx, poolData, _a;
|
|
413
455
|
return __generator(this, function (_b) {
|
|
@@ -446,6 +488,25 @@ var Curve = /** @class */ (function () {
|
|
|
446
488
|
}
|
|
447
489
|
});
|
|
448
490
|
}); };
|
|
491
|
+
this.fetchNewTricryptoFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
492
|
+
var currentPoolIds, lastPoolIdx, poolData, _a;
|
|
493
|
+
return __generator(this, function (_b) {
|
|
494
|
+
switch (_b.label) {
|
|
495
|
+
case 0:
|
|
496
|
+
if (![1].includes(this.chainId))
|
|
497
|
+
return [2 /*return*/, []];
|
|
498
|
+
currentPoolIds = Object.keys(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
499
|
+
lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
|
|
500
|
+
_a = lowerCasePoolDataAddresses;
|
|
501
|
+
return [4 /*yield*/, getTricryptoFactoryPoolData.call(this, lastPoolIdx + 1)];
|
|
502
|
+
case 1:
|
|
503
|
+
poolData = _a.apply(void 0, [_b.sent()]);
|
|
504
|
+
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.TRICRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
505
|
+
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
506
|
+
return [2 /*return*/, Object.keys(poolData)];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}); };
|
|
449
510
|
this.fetchRecentlyDeployedFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
450
511
|
var poolData, _a;
|
|
451
512
|
return __generator(this, function (_b) {
|
|
@@ -480,11 +541,30 @@ var Curve = /** @class */ (function () {
|
|
|
480
541
|
}
|
|
481
542
|
});
|
|
482
543
|
}); };
|
|
544
|
+
this.fetchRecentlyDeployedTricryptoFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
545
|
+
var poolData, _a;
|
|
546
|
+
return __generator(this, function (_b) {
|
|
547
|
+
switch (_b.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
if (![1].includes(this.chainId))
|
|
550
|
+
return [2 /*return*/, ''];
|
|
551
|
+
_a = lowerCasePoolDataAddresses;
|
|
552
|
+
return [4 /*yield*/, getTricryptoFactoryPoolData.call(this, 0, poolAddress)];
|
|
553
|
+
case 1:
|
|
554
|
+
poolData = _a.apply(void 0, [_b.sent()]);
|
|
555
|
+
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.TRICRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
556
|
+
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
557
|
+
return [2 /*return*/, Object.keys(poolData)[0]]; // id
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}); };
|
|
483
561
|
this.getMainPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
|
|
484
562
|
this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
|
|
485
563
|
this.getCrvusdFactoryPoolList = function () { return Object.keys(_this.constants.CRVUSD_FACTORY_POOLS_DATA); };
|
|
486
564
|
this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
|
|
487
|
-
this.
|
|
565
|
+
this.getTricryptoFactoryPoolList = function () { return Object.keys(_this.constants.TRICRYPTO_FACTORY_POOLS_DATA); };
|
|
566
|
+
this.getPoolList = function () { return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], _this.getMainPoolList(), true), _this.getFactoryPoolList(), true), _this.getCrvusdFactoryPoolList(), true), _this.getCryptoFactoryPoolList(), true), _this.getTricryptoFactoryPoolList(), true); };
|
|
567
|
+
this.getPoolsData = function () { return (__assign(__assign(__assign(__assign(__assign(__assign({}, _this.constants.POOLS_DATA), _this.constants.FACTORY_POOLS_DATA), _this.constants.CRVUSD_FACTORY_POOLS_DATA), _this.constants.CRYPTO_FACTORY_POOLS_DATA), _this.constants.TRICRYPTO_FACTORY_POOLS_DATA), _this.constants.LLAMMAS_DATA)); };
|
|
488
568
|
// @ts-ignore
|
|
489
569
|
this.provider = null;
|
|
490
570
|
// @ts-ignore
|
|
@@ -505,6 +585,7 @@ var Curve = /** @class */ (function () {
|
|
|
505
585
|
FACTORY_POOLS_DATA: {},
|
|
506
586
|
CRVUSD_FACTORY_POOLS_DATA: {},
|
|
507
587
|
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
588
|
+
TRICRYPTO_FACTORY_POOLS_DATA: {},
|
|
508
589
|
LLAMMAS_DATA: {},
|
|
509
590
|
COINS: {},
|
|
510
591
|
DECIMALS: {},
|
|
@@ -541,6 +622,7 @@ var Curve = /** @class */ (function () {
|
|
|
541
622
|
FACTORY_POOLS_DATA: {},
|
|
542
623
|
CRVUSD_FACTORY_POOLS_DATA: {},
|
|
543
624
|
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
625
|
+
TRICRYPTO_FACTORY_POOLS_DATA: {},
|
|
544
626
|
LLAMMAS_DATA: {},
|
|
545
627
|
COINS: {},
|
|
546
628
|
DECIMALS: {},
|
|
@@ -602,10 +684,12 @@ var Curve = /** @class */ (function () {
|
|
|
602
684
|
case 10:
|
|
603
685
|
network = _q.sent();
|
|
604
686
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
|
|
605
|
-
this.chainId = Number(network.chainId) ===
|
|
687
|
+
this.chainId = Number(network.chainId) === 133 || Number(network.chainId) === 31337 ? 1 : Number(network.chainId);
|
|
606
688
|
this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
|
|
607
689
|
this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
|
|
608
690
|
this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
|
|
691
|
+
this.constants.ALIASES.anycall = "0x37414a8662bc1d25be3ee51fb27c2686e2490a89";
|
|
692
|
+
this.constants.ALIASES.voting_escrow_oracle = "0x12F407340697Ae0b177546E535b91A5be021fBF9";
|
|
609
693
|
this.constants.POOLS_DATA = NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
|
|
610
694
|
if (this.chainId === 1)
|
|
611
695
|
this.constants.LLAMMAS_DATA = NETWORK_CONSTANTS[this.chainId].LLAMMAS_DATA;
|
|
@@ -728,6 +812,9 @@ var Curve = /** @class */ (function () {
|
|
|
728
812
|
case 21:
|
|
729
813
|
this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
|
|
730
814
|
this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
|
|
815
|
+
this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactoryABI);
|
|
816
|
+
this.setContract(this.constants.ALIASES.anycall, anycallABI);
|
|
817
|
+
this.setContract(this.constants.ALIASES.voting_escrow_oracle, this.chainId === 1 ? votingEscrowOracleEthABI : votingEscrowOracleABI);
|
|
731
818
|
return [2 /*return*/];
|
|
732
819
|
}
|
|
733
820
|
});
|
package/lib/external-api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import memoize from "memoizee";
|
|
2
2
|
import { IExtendedPoolDataFromApi, ISubgraphPoolData, IDict, INetworkName } from "./interfaces";
|
|
3
|
-
export declare const _getPoolsFromApi: ((network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>>;
|
|
3
|
+
export declare const _getPoolsFromApi: ((network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto" | "factory-tricrypto") => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto" | "factory-tricrypto") => Promise<IExtendedPoolDataFromApi>>;
|
|
4
4
|
export declare const _getAllPoolsFromApi: (network: INetworkName) => Promise<IExtendedPoolDataFromApi[]>;
|
|
5
5
|
export declare const _getSubgraphData: ((network: INetworkName) => Promise<{
|
|
6
6
|
poolsData: ISubgraphPoolData[];
|
|
@@ -43,3 +43,10 @@ export declare const _getAllGauges: (() => Promise<IDict<{
|
|
|
43
43
|
is_killed?: boolean;
|
|
44
44
|
}>>>;
|
|
45
45
|
export declare const _getHiddenPools: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
|
|
46
|
+
export declare const _generateBoostingProof: ((block: number, address: string) => Promise<{
|
|
47
|
+
block_header_rlp: string;
|
|
48
|
+
proof_rlp: string;
|
|
49
|
+
}>) & memoize.Memoized<(block: number, address: string) => Promise<{
|
|
50
|
+
block_header_rlp: string;
|
|
51
|
+
proof_rlp: string;
|
|
52
|
+
}>>;
|
package/lib/external-api.js
CHANGED
|
@@ -167,3 +167,19 @@ export var _getHiddenPools = memoize(function () { return __awaiter(void 0, void
|
|
|
167
167
|
promise: true,
|
|
168
168
|
maxAge: 5 * 60 * 1000, // 5m
|
|
169
169
|
});
|
|
170
|
+
export var _generateBoostingProof = memoize(function (block, address) { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
var url, response;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
url = "https://prices.curve.fi/v1/general/get_merkle_proof?block=".concat(block, "&account_address=").concat(address);
|
|
176
|
+
return [4 /*yield*/, axios.get(url, { validateStatus: function () { return true; } })];
|
|
177
|
+
case 1:
|
|
178
|
+
response = _a.sent();
|
|
179
|
+
return [2 /*return*/, { block_header_rlp: response.data.block_header_rlp, proof_rlp: response.data.proof_rlp }];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}); }, {
|
|
183
|
+
promise: true,
|
|
184
|
+
maxAge: 5 * 60 * 1000, // 5m
|
|
185
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IDict, IPoolData, ICurve, IPoolDataFromApi } from "../interfaces";
|
|
2
2
|
export declare const lowerCasePoolDataAddresses: (poolsData: IPoolDataFromApi[]) => IPoolDataFromApi[];
|
|
3
|
-
export declare function getFactoryPoolsDataFromApi(this: ICurve, factoryType: "factory" | "factory-crvusd" | "factory-crypto"): Promise<IDict<IPoolData>>;
|
|
3
|
+
export declare function getFactoryPoolsDataFromApi(this: ICurve, factoryType: "factory" | "factory-crvusd" | "factory-crypto" | "factory-tricrypto"): Promise<IDict<IPoolData>>;
|
|
@@ -54,13 +54,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
54
54
|
}
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
|
-
import { Contract } from "ethers";
|
|
58
|
-
import { Contract as MulticallContract } from "ethcall";
|
|
59
57
|
import { curve } from "../curve.js";
|
|
60
58
|
import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
|
|
61
59
|
import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
|
|
62
60
|
import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
|
|
63
61
|
import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" assert { type: 'json' };
|
|
62
|
+
import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" assert { type: 'json' };
|
|
64
63
|
import { FACTORY_CONSTANTS } from "./constants.js";
|
|
65
64
|
import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
|
|
66
65
|
import { setFactoryZapContracts } from "./common.js";
|
|
@@ -74,7 +73,8 @@ export var lowerCasePoolDataAddresses = function (poolsData) {
|
|
|
74
73
|
poolData.lpTokenAddress = poolData.lpTokenAddress.toLowerCase();
|
|
75
74
|
if (poolData.gaugeAddress)
|
|
76
75
|
poolData.gaugeAddress = poolData.gaugeAddress.toLowerCase();
|
|
77
|
-
|
|
76
|
+
if (poolData.implementationAddress)
|
|
77
|
+
poolData.implementationAddress = poolData.implementationAddress.toLowerCase();
|
|
78
78
|
for (var _b = 0, _c = poolData.coins; _b < _c.length; _b++) {
|
|
79
79
|
var coin = _c[_b];
|
|
80
80
|
coin.address = coin.address.toLowerCase();
|
|
@@ -87,47 +87,36 @@ export var lowerCasePoolDataAddresses = function (poolsData) {
|
|
|
87
87
|
}
|
|
88
88
|
return poolsData;
|
|
89
89
|
};
|
|
90
|
-
function setFactorySwapContracts(rawPoolList,
|
|
90
|
+
function setFactorySwapContracts(rawPoolList, factoryType) {
|
|
91
91
|
var _this = this;
|
|
92
|
-
if (
|
|
92
|
+
if (factoryType === "factory-crypto") {
|
|
93
93
|
rawPoolList.forEach(function (pool) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
_this.setContract(pool.address, cryptoFactorySwapABI);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (factoryType === "factory-tricrypto") {
|
|
98
|
+
rawPoolList.forEach(function (pool) {
|
|
99
|
+
_this.setContract(pool.address, tricryptoFactorySwapABI);
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
else {
|
|
102
103
|
var implementationABIDict_1 = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
103
104
|
rawPoolList.forEach(function (pool) {
|
|
104
|
-
|
|
105
|
-
_this.contracts[addr] = {
|
|
106
|
-
contract: new Contract(addr, implementationABIDict_1[pool.implementationAddress], _this.signer || _this.provider),
|
|
107
|
-
multicallContract: new MulticallContract(addr, implementationABIDict_1[pool.implementationAddress]),
|
|
108
|
-
};
|
|
105
|
+
_this.setContract(pool.address, implementationABIDict_1[pool.implementationAddress]);
|
|
109
106
|
});
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
109
|
function setCryptoFactoryTokenContracts(rawPoolList) {
|
|
113
110
|
var _this = this;
|
|
114
111
|
rawPoolList.forEach(function (pool) {
|
|
115
|
-
|
|
116
|
-
_this.contracts[addr] = {
|
|
117
|
-
contract: new Contract(addr, ERC20ABI, _this.signer || _this.provider),
|
|
118
|
-
multicallContract: new MulticallContract(addr, ERC20ABI),
|
|
119
|
-
};
|
|
112
|
+
_this.setContract(pool.lpTokenAddress, ERC20ABI);
|
|
120
113
|
});
|
|
121
114
|
}
|
|
122
115
|
function setFactoryGaugeContracts(rawPoolList) {
|
|
123
116
|
var _this = this;
|
|
124
117
|
rawPoolList.forEach(function (pool) {
|
|
125
118
|
if (pool.gaugeAddress) {
|
|
126
|
-
|
|
127
|
-
_this.contracts[addr] = {
|
|
128
|
-
contract: new Contract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI, _this.signer || _this.provider),
|
|
129
|
-
multicallContract: new MulticallContract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI),
|
|
130
|
-
};
|
|
119
|
+
_this.setContract(pool.gaugeAddress, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
|
|
131
120
|
}
|
|
132
121
|
});
|
|
133
122
|
}
|
|
@@ -136,13 +125,9 @@ function setFactoryCoinsContracts(rawPoolList) {
|
|
|
136
125
|
var pool = rawPoolList_1[_i];
|
|
137
126
|
for (var _a = 0, _b = pool.coins; _a < _b.length; _a++) {
|
|
138
127
|
var coin = _b[_a];
|
|
139
|
-
|
|
140
|
-
if (addr in this.contracts)
|
|
128
|
+
if (coin.address in this.contracts)
|
|
141
129
|
continue;
|
|
142
|
-
this.
|
|
143
|
-
contract: new Contract(addr, ERC20ABI, this.signer || this.provider),
|
|
144
|
-
multicallContract: new MulticallContract(addr, ERC20ABI),
|
|
145
|
-
};
|
|
130
|
+
this.setContract(coin.address, ERC20ABI);
|
|
146
131
|
}
|
|
147
132
|
}
|
|
148
133
|
}
|
|
@@ -154,7 +139,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
154
139
|
switch (_b.label) {
|
|
155
140
|
case 0:
|
|
156
141
|
network = this.constants.NETWORK_NAME;
|
|
157
|
-
isCrypto = factoryType === "factory-crypto";
|
|
142
|
+
isCrypto = factoryType === "factory-crypto" || factoryType === "factory-tricrypto";
|
|
158
143
|
_a = lowerCasePoolDataAddresses;
|
|
159
144
|
return [4 /*yield*/, _getPoolsFromApi(network, factoryType)];
|
|
160
145
|
case 1:
|
|
@@ -164,8 +149,8 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
164
149
|
}
|
|
165
150
|
mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address; });
|
|
166
151
|
rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address); });
|
|
167
|
-
setFactorySwapContracts.call(this, rawPoolList,
|
|
168
|
-
if (
|
|
152
|
+
setFactorySwapContracts.call(this, rawPoolList, factoryType);
|
|
153
|
+
if (factoryType === "factory-crypto")
|
|
169
154
|
setCryptoFactoryTokenContracts.call(this, rawPoolList);
|
|
170
155
|
setFactoryGaugeContracts.call(this, rawPoolList);
|
|
171
156
|
setFactoryCoinsContracts.call(this, rawPoolList);
|
|
@@ -187,7 +172,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
187
172
|
var lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].lpTokenBasePoolIdDict;
|
|
188
173
|
var basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
|
|
189
174
|
var basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
|
|
190
|
-
if (basePoolId) { // isMeta
|
|
175
|
+
if (factoryType !== "factory-tricrypto" && basePoolId) { // isMeta
|
|
191
176
|
var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
|
|
192
177
|
var basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
|
|
193
178
|
var basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
|
|
@@ -220,7 +205,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
220
205
|
}
|
|
221
206
|
else {
|
|
222
207
|
FACTORY_POOLS_DATA[pool.id] = {
|
|
223
|
-
name: pool.name.split(": ")[1].trim(),
|
|
208
|
+
name: factoryType === "factory-tricrypto" ? pool.name : pool.name.split(": ")[1].trim(),
|
|
224
209
|
full_name: pool.name,
|
|
225
210
|
symbol: pool.symbol,
|
|
226
211
|
reference_asset: "CRYPTO",
|
|
@@ -236,7 +221,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
236
221
|
wrapped_coin_addresses: coinAddresses,
|
|
237
222
|
underlying_decimals: coinDecimals,
|
|
238
223
|
wrapped_decimals: coinDecimals,
|
|
239
|
-
swap_abi: cryptoFactorySwapABI,
|
|
224
|
+
swap_abi: factoryType === "factory-tricrypto" ? tricryptoFactorySwapABI : cryptoFactorySwapABI,
|
|
240
225
|
gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
241
226
|
in_api: true,
|
|
242
227
|
};
|
|
@@ -180,7 +180,7 @@ function setCryptoFactoryCoinsContracts(coinAddresses) {
|
|
|
180
180
|
}
|
|
181
181
|
function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
|
|
182
182
|
var _this = this;
|
|
183
|
-
return coinAddresses.map(function (coins) { return coins.map(function (c) { return c === _this.constants.NATIVE_TOKEN.wrappedAddress ? _this.constants.NATIVE_TOKEN.address : c; }); });
|
|
183
|
+
return __spreadArray([], coinAddresses.map(function (coins) { return coins.map(function (c) { return c === _this.constants.NATIVE_TOKEN.wrappedAddress ? _this.constants.NATIVE_TOKEN.address : c; }); }), true);
|
|
184
184
|
}
|
|
185
185
|
function getExistingCoinAddressNameDict() {
|
|
186
186
|
var dict = {};
|