@curvefi/api 2.38.0 → 2.40.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.
@@ -12,6 +12,7 @@ export var ALIASES_ETHEREUM = lowerCaseValues({
12
12
  "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
13
13
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
14
14
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
15
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
15
16
  "registry_exchange": "",
16
17
  "factory_admin": "",
17
18
  });
@@ -28,6 +29,7 @@ export var ALIASES_POLYGON = lowerCaseValues({
28
29
  "factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
29
30
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
30
31
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
32
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
31
33
  "registry_exchange": "",
32
34
  "factory_admin": "",
33
35
  });
@@ -44,6 +46,7 @@ export var ALIASES_FANTOM = lowerCaseValues({
44
46
  "factory": "0x686d67265703d1f124c45e33d47d794c566889ba",
45
47
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
46
48
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
49
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
47
50
  "registry_exchange": "",
48
51
  "factory_admin": "",
49
52
  });
@@ -60,6 +63,7 @@ export var ALIASES_AVALANCHE = lowerCaseValues({
60
63
  "factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
61
64
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
62
65
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
66
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
63
67
  "registry_exchange": "",
64
68
  "factory_admin": "",
65
69
  });
@@ -76,6 +80,7 @@ export var ALIASES_ARBITRUM = lowerCaseValues({
76
80
  "factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
77
81
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
78
82
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
83
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
79
84
  "registry_exchange": "",
80
85
  "factory_admin": "",
81
86
  });
@@ -92,6 +97,7 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
92
97
  "factory": '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
93
98
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
94
99
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
100
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
95
101
  "registry_exchange": "",
96
102
  "factory_admin": "",
97
103
  });
@@ -108,6 +114,7 @@ export var ALIASES_XDAI = lowerCaseValues({
108
114
  "factory": '0xD19Baeadc667Cf2015e395f2B08668Ef120f41F5',
109
115
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
110
116
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
117
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
111
118
  "registry_exchange": "",
112
119
  "factory_admin": "",
113
120
  });
@@ -124,6 +131,7 @@ export var ALIASES_MOONBEAM = lowerCaseValues({
124
131
  "factory": '0x4244eB811D6e0Ef302326675207A95113dB4E1F8',
125
132
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
126
133
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
134
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
127
135
  "registry_exchange": "",
128
136
  "factory_admin": "",
129
137
  });
@@ -140,6 +148,7 @@ export var ALIASES_AURORA = lowerCaseValues({
140
148
  "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
141
149
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
142
150
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
151
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
143
152
  "registry_exchange": "",
144
153
  "factory_admin": "",
145
154
  });
@@ -156,6 +165,7 @@ export var ALIASES_KAVA = lowerCaseValues({
156
165
  "factory": '0x40bc62805471eF53DdD5C5cF99ed3d9e5aa81b48',
157
166
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
158
167
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
168
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
159
169
  "registry_exchange": "",
160
170
  "factory_admin": "",
161
171
  });
@@ -172,6 +182,7 @@ export var ALIASES_CELO = lowerCaseValues({
172
182
  "factory": '0x5277A0226d10392295E8D383E9724D6E416d6e6C',
173
183
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
174
184
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
185
+ "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
175
186
  "registry_exchange": "",
176
187
  "factory_admin": "",
177
188
  });
package/lib/curve.d.ts CHANGED
@@ -50,6 +50,7 @@ declare class Curve implements ICurve {
50
50
  FACTORY_POOLS_DATA: IDict<IPoolData>;
51
51
  CRVUSD_FACTORY_POOLS_DATA: IDict<IPoolData>;
52
52
  CRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>;
53
+ TRICRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>;
53
54
  LLAMMAS_DATA: IDict<IPoolData>;
54
55
  COINS: IDict<string>;
55
56
  DECIMALS: IDict<number>;
@@ -77,15 +78,20 @@ declare class Curve implements ICurve {
77
78
  fetchFactoryPools: (useApi?: boolean) => Promise<void>;
78
79
  fetchCrvusdFactoryPools: (useApi?: boolean) => Promise<void>;
79
80
  fetchCryptoFactoryPools: (useApi?: boolean) => Promise<void>;
81
+ fetchTricryptoFactoryPools: (useApi?: boolean) => Promise<void>;
80
82
  fetchNewFactoryPools: () => Promise<string[]>;
81
83
  fetchNewCryptoFactoryPools: () => Promise<string[]>;
84
+ fetchNewTricryptoFactoryPools: () => Promise<string[]>;
82
85
  fetchRecentlyDeployedFactoryPool: (poolAddress: string) => Promise<string>;
83
86
  fetchRecentlyDeployedCryptoFactoryPool: (poolAddress: string) => Promise<string>;
87
+ fetchRecentlyDeployedTricryptoFactoryPool: (poolAddress: string) => Promise<string>;
84
88
  getMainPoolList: () => string[];
85
89
  getFactoryPoolList: () => string[];
86
90
  getCrvusdFactoryPoolList: () => string[];
87
91
  getCryptoFactoryPoolList: () => string[];
92
+ getTricryptoFactoryPoolList: () => string[];
88
93
  getPoolList: () => string[];
94
+ getPoolsData: () => IDict<IPoolData>;
89
95
  setCustomFeeData(customFeeData: {
90
96
  gasPrice?: number;
91
97
  maxFeePerGas?: number;
package/lib/curve.js CHANGED
@@ -59,6 +59,7 @@ 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' };
@@ -80,6 +81,7 @@ import streamerABI from './constants/abis/streamer.json' assert { type: 'json' }
80
81
  import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
81
82
  import factoryAdminABI from './constants/abis/factory-admin.json' assert { type: 'json' };
82
83
  import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
84
+ import tricryptoFactoryABI from './constants/abis/factory-tricrypto.json' assert { type: 'json' };
83
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';
84
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";
85
87
  import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
@@ -411,6 +413,43 @@ var Curve = /** @class */ (function () {
411
413
  });
412
414
  });
413
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
+ };
414
453
  this.fetchNewFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
415
454
  var currentPoolIds, lastPoolIdx, poolData, _a;
416
455
  return __generator(this, function (_b) {
@@ -449,6 +488,25 @@ var Curve = /** @class */ (function () {
449
488
  }
450
489
  });
451
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
+ }); };
452
510
  this.fetchRecentlyDeployedFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
453
511
  var poolData, _a;
454
512
  return __generator(this, function (_b) {
@@ -483,11 +541,30 @@ var Curve = /** @class */ (function () {
483
541
  }
484
542
  });
485
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
+ }); };
486
561
  this.getMainPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
487
562
  this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
488
563
  this.getCrvusdFactoryPoolList = function () { return Object.keys(_this.constants.CRVUSD_FACTORY_POOLS_DATA); };
489
564
  this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
490
- this.getPoolList = function () { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], _this.getMainPoolList(), true), _this.getFactoryPoolList(), true), _this.getCrvusdFactoryPoolList(), true), _this.getCryptoFactoryPoolList(), true); };
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)); };
491
568
  // @ts-ignore
492
569
  this.provider = null;
493
570
  // @ts-ignore
@@ -508,6 +585,7 @@ var Curve = /** @class */ (function () {
508
585
  FACTORY_POOLS_DATA: {},
509
586
  CRVUSD_FACTORY_POOLS_DATA: {},
510
587
  CRYPTO_FACTORY_POOLS_DATA: {},
588
+ TRICRYPTO_FACTORY_POOLS_DATA: {},
511
589
  LLAMMAS_DATA: {},
512
590
  COINS: {},
513
591
  DECIMALS: {},
@@ -544,6 +622,7 @@ var Curve = /** @class */ (function () {
544
622
  FACTORY_POOLS_DATA: {},
545
623
  CRVUSD_FACTORY_POOLS_DATA: {},
546
624
  CRYPTO_FACTORY_POOLS_DATA: {},
625
+ TRICRYPTO_FACTORY_POOLS_DATA: {},
547
626
  LLAMMAS_DATA: {},
548
627
  COINS: {},
549
628
  DECIMALS: {},
@@ -605,7 +684,7 @@ var Curve = /** @class */ (function () {
605
684
  case 10:
606
685
  network = _q.sent();
607
686
  console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
608
- this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
687
+ this.chainId = Number(network.chainId) === 133 || Number(network.chainId) === 31337 ? 1 : Number(network.chainId);
609
688
  this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
610
689
  this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
611
690
  this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
@@ -733,6 +812,7 @@ var Curve = /** @class */ (function () {
733
812
  case 21:
734
813
  this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
735
814
  this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
815
+ this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactoryABI);
736
816
  this.setContract(this.constants.ALIASES.anycall, anycallABI);
737
817
  this.setContract(this.constants.ALIASES.voting_escrow_oracle, this.chainId === 1 ? votingEscrowOracleEthABI : votingEscrowOracleABI);
738
818
  return [2 /*return*/];
@@ -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[];
@@ -8,9 +8,12 @@ export declare const setOracle: (poolAddress: string, oracleAddress?: string, me
8
8
  export declare const deployStableMetaPoolEstimateGas: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<number>;
9
9
  export declare const deployStableMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<ethers.ContractTransactionResponse>;
10
10
  export declare const getDeployedStableMetaPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
11
- export declare const deployCryptoPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number | string, initialPrice: number | string) => Promise<number>;
12
- export declare const deployCryptoPool: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number | string, initialPrice: number | string) => Promise<ethers.ContractTransactionResponse>;
11
+ export declare const deployCryptoPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number, initialPrice: number | string) => Promise<number>;
12
+ export declare const deployCryptoPool: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number, initialPrice: number | string) => Promise<ethers.ContractTransactionResponse>;
13
13
  export declare const getDeployedCryptoPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
14
- export declare const deployGaugeEstimateGas: (pool: string, isCrypto: boolean) => Promise<number>;
15
- export declare const deployGauge: (pool: string, isCrypto: boolean) => Promise<ethers.ContractTransactionResponse>;
14
+ export declare const deployTricryptoPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, emaTime: number, initialPrices: (number | string)[]) => Promise<number>;
15
+ export declare const deployTricryptoPool: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, emaTime: number, initialPrices: (number | string)[]) => Promise<ethers.ContractTransactionResponse>;
16
+ export declare const getDeployedTricryptoPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
17
+ export declare const deployGaugeEstimateGas: (pool: string, factory: string) => Promise<number>;
18
+ export declare const deployGauge: (pool: string, factory: string) => Promise<ethers.ContractTransactionResponse>;
16
19
  export declare const getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
@@ -103,7 +103,7 @@ oracleAddress, methodName, estimateGas) { return __awaiter(void 0, void 0, void
103
103
  contract = curve.contracts[contractAddress].contract;
104
104
  args = [name, symbol, _coins, _A, _fee, assetType, implementationIdx];
105
105
  if (useProxy || setOracle)
106
- args.push(curve.parseUnits((emaTime / Math.log(2)).toFixed(0), 0));
106
+ args.push(parseUnits(Math.floor(emaTime / Math.log(2)), 0));
107
107
  if (setOracle) {
108
108
  methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
109
109
  args.push(methodId, oracleAddress);
@@ -301,7 +301,7 @@ initialPrice, estimateGas) { return __awaiter(void 0, void 0, void 0, function (
301
301
  throw Error("Max symbol length = 10");
302
302
  if (coins.length !== 2)
303
303
  throw Error("Invalid number of coins. Must be 2");
304
- if (coins[1] === coins[2])
304
+ if (coins[0] === coins[1])
305
305
  throw Error("Coins must be different");
306
306
  if (BN(A).lt(4000))
307
307
  throw Error("A must be >= 4000. Passed A = ".concat(A));
@@ -402,14 +402,137 @@ export var getDeployedCryptoPoolAddress = function (tx) { return __awaiter(void
402
402
  }
403
403
  });
404
404
  }); };
405
+ // ------- TRICRYPTO POOLS -------
406
+ var _deployTricryptoPool = function (name, symbol, coins, A, gamma, midFee, // %
407
+ outFee, // %
408
+ allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
409
+ initialPrices, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
410
+ var _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, _emaTime, _initialPrices, contract, gas, gasLimit;
411
+ return __generator(this, function (_a) {
412
+ switch (_a.label) {
413
+ case 0:
414
+ if (name.length > 64)
415
+ throw Error("Max name length = 64");
416
+ if (symbol.length > 32)
417
+ throw Error("Max symbol length = 32");
418
+ if (coins.length !== 3)
419
+ throw Error("Invalid number of coins. Must be 3");
420
+ if (coins[0] === coins[1] || coins[1] === coins[2] || coins[0] === coins[2])
421
+ throw Error("Coins must be different");
422
+ if (BN(A).lt(2700))
423
+ throw Error("A must be >= 2700. Passed A = ".concat(A));
424
+ if (BN(A).gt(27 * (Math.pow(10, 7))))
425
+ throw Error("A must be <= 27 * 10 ** 7. Passed A = ".concat(A));
426
+ if (BN(gamma).lt(1e-8))
427
+ throw Error("gamma must be >= 1e-8. Passed gamma = ".concat(gamma));
428
+ if (BN(gamma).gt(0.05))
429
+ throw Error("gamma must be <= 0.05. Passed gamma = ".concat(gamma));
430
+ if (BN(midFee).lt(0))
431
+ throw Error("midFee must be >= 0. Passed midFee = ".concat(midFee));
432
+ if (BN(midFee).gt(100))
433
+ throw Error("midFee must be <= 100. Passed midFee = ".concat(midFee));
434
+ if (BN(outFee).lt(BN(midFee)))
435
+ throw Error("outFee must be >= midFee. Passed outFee = ".concat(outFee, " < midFee = ").concat(midFee));
436
+ if (BN(outFee).gt(100))
437
+ throw Error("outFee must be <= 100. Passed outFee = ".concat(outFee));
438
+ if (BN(allowedExtraProfit).lt(0))
439
+ throw Error("allowedExtraProfit must be >= 0. Passed allowedExtraProfit = ".concat(allowedExtraProfit));
440
+ if (BN(allowedExtraProfit).gt(1))
441
+ throw Error("allowedExtraProfit must be <= 1. Passed allowedExtraProfit = ".concat(allowedExtraProfit));
442
+ if (BN(feeGamma).lt(0))
443
+ throw Error("feeGamma must be >= 0. Passed feeGamma = ".concat(feeGamma));
444
+ if (BN(feeGamma).gt(1))
445
+ throw Error("feeGamma must be <= 1. Passed feeGamma = ".concat(feeGamma));
446
+ if (BN(adjustmentStep).lt(0))
447
+ throw Error("adjustmentStep must be >= 0. Passed adjustmentStep=".concat(adjustmentStep));
448
+ if (BN(adjustmentStep).gt(1))
449
+ throw Error("adjustmentStep must be <= 1. Passed adjustmentStep=".concat(adjustmentStep));
450
+ if (BN(emaTime).lt(60))
451
+ throw Error("maHalfTime must be >= 60. Passed maHalfTime=".concat(emaTime));
452
+ if (BN(emaTime).gt(604800))
453
+ throw Error("maHalfTime must be <= 604800. Passed maHalfTime=".concat(emaTime));
454
+ if (initialPrices.length !== 2)
455
+ throw Error("Invalid number of initial prices. Must be 2");
456
+ if (BN(initialPrices[0]).lt(1e-12))
457
+ throw Error("initialPrices[0] must be >= 1e-12. Passed initialPrices[0]=".concat(initialPrices[0]));
458
+ if (BN(initialPrices[0]).gt(1e12))
459
+ throw Error("initialPrices[0] must be <= 1e12. Passed initialPrices[0]=".concat(initialPrices[0]));
460
+ if (BN(initialPrices[1]).lt(1e-12))
461
+ throw Error("initialPrices[1] must be >= 1e-12. Passed initialPrices[1]=".concat(initialPrices[1]));
462
+ if (BN(initialPrices[1]).gt(1e12))
463
+ throw Error("initialPrices[1] must be <= 1e12. Passed initialPrices[1]=".concat(initialPrices[1]));
464
+ _A = parseUnits(A, 0);
465
+ _gamma = parseUnits(gamma);
466
+ _midFee = parseUnits(midFee, 8);
467
+ _outFee = parseUnits(outFee, 8);
468
+ _allowedExtraProfit = parseUnits(allowedExtraProfit);
469
+ _feeGamma = parseUnits(feeGamma);
470
+ _adjustmentStep = parseUnits(adjustmentStep);
471
+ _emaTime = parseUnits(Math.floor(emaTime / Math.log(2)), 0);
472
+ _initialPrices = [parseUnits(initialPrices[0]), parseUnits(initialPrices[1])];
473
+ contract = curve.contracts[curve.constants.ALIASES.tricrypto_factory].contract;
474
+ return [4 /*yield*/, contract.deploy_pool.estimateGas(name, symbol, coins, curve.constants.NATIVE_TOKEN.wrappedAddress, 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, curve.constantOptions)];
475
+ case 1:
476
+ gas = _a.sent();
477
+ if (estimateGas)
478
+ return [2 /*return*/, Number(gas)];
479
+ gasLimit = mulBy1_3(gas);
480
+ return [4 /*yield*/, curve.updateFeeData()];
481
+ case 2:
482
+ _a.sent();
483
+ return [4 /*yield*/, contract.deploy_pool(name, symbol, coins, curve.constants.NATIVE_TOKEN.wrappedAddress, 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
484
+ case 3: return [2 /*return*/, _a.sent()];
485
+ }
486
+ });
487
+ }); };
488
+ export var deployTricryptoPoolEstimateGas = function (name, symbol, coins, A, gamma, midFee, // %
489
+ outFee, // %
490
+ allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
491
+ initialPrices) { return __awaiter(void 0, void 0, void 0, function () {
492
+ return __generator(this, function (_a) {
493
+ switch (_a.label) {
494
+ case 0: return [4 /*yield*/, _deployTricryptoPool(name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, emaTime, initialPrices, true)];
495
+ case 1: return [2 /*return*/, _a.sent()];
496
+ }
497
+ });
498
+ }); };
499
+ export var deployTricryptoPool = function (name, symbol, coins, A, gamma, midFee, // %
500
+ outFee, // %
501
+ allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
502
+ initialPrices) { return __awaiter(void 0, void 0, void 0, function () {
503
+ return __generator(this, function (_a) {
504
+ switch (_a.label) {
505
+ case 0: return [4 /*yield*/, _deployTricryptoPool(name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, emaTime, initialPrices, false)];
506
+ case 1: return [2 /*return*/, _a.sent()];
507
+ }
508
+ });
509
+ }); };
510
+ export var getDeployedTricryptoPoolAddress = function (tx) { return __awaiter(void 0, void 0, void 0, function () {
511
+ var txInfo, i;
512
+ return __generator(this, function (_a) {
513
+ switch (_a.label) {
514
+ case 0: return [4 /*yield*/, tx.wait()];
515
+ case 1:
516
+ txInfo = _a.sent();
517
+ if (!txInfo)
518
+ throw Error("Can't get tx info");
519
+ for (i = txInfo.logs.length - 1; i > -1; i--) {
520
+ if ("args" in txInfo.logs[i]) {
521
+ // @ts-ignore
522
+ return [2 /*return*/, txInfo.logs[i].args[0]];
523
+ }
524
+ }
525
+ throw Error("Can't get deployed tricrypto pool address");
526
+ }
527
+ });
528
+ }); };
405
529
  // ------- GAUGE -------
406
- var _deployGauge = function (pool, isCrypto, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
407
- var contractAddress, contract, gas, gasLimit;
530
+ var _deployGauge = function (pool, factory, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
531
+ var contract, gas, gasLimit;
408
532
  return __generator(this, function (_a) {
409
533
  switch (_a.label) {
410
534
  case 0:
411
- contractAddress = isCrypto ? curve.constants.ALIASES.crypto_factory : curve.constants.ALIASES.factory;
412
- contract = curve.contracts[contractAddress].contract;
535
+ contract = curve.contracts[factory].contract;
413
536
  return [4 /*yield*/, contract.deploy_gauge.estimateGas(pool, curve.constantOptions)];
414
537
  case 1:
415
538
  gas = _a.sent();
@@ -424,15 +547,15 @@ var _deployGauge = function (pool, isCrypto, estimateGas) { return __awaiter(voi
424
547
  }
425
548
  });
426
549
  }); };
427
- export var deployGaugeEstimateGas = function (pool, isCrypto) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
550
+ export var deployGaugeEstimateGas = function (pool, factory) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
428
551
  switch (_a.label) {
429
- case 0: return [4 /*yield*/, _deployGauge(pool, isCrypto, true)];
552
+ case 0: return [4 /*yield*/, _deployGauge(pool, factory, true)];
430
553
  case 1: return [2 /*return*/, _a.sent()];
431
554
  }
432
555
  }); }); };
433
- export var deployGauge = function (pool, isCrypto) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
556
+ export var deployGauge = function (pool, factory) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
434
557
  switch (_a.label) {
435
- case 0: return [4 /*yield*/, _deployGauge(pool, isCrypto, false)];
558
+ case 0: return [4 /*yield*/, _deployGauge(pool, factory, false)];
436
559
  case 1: return [2 /*return*/, _a.sent()];
437
560
  }
438
561
  }); }); };
@@ -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
- poolData.implementationAddress = poolData.implementationAddress.toLowerCase();
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, isCrypto) {
90
+ function setFactorySwapContracts(rawPoolList, factoryType) {
91
91
  var _this = this;
92
- if (isCrypto) {
92
+ if (factoryType === "factory-crypto") {
93
93
  rawPoolList.forEach(function (pool) {
94
- var addr = pool.address;
95
- _this.contracts[addr] = {
96
- contract: new Contract(addr, cryptoFactorySwapABI, _this.signer || _this.provider),
97
- multicallContract: new MulticallContract(addr, cryptoFactorySwapABI),
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
- var addr = pool.address;
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
- var addr = pool.lpTokenAddress;
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
- var addr = pool.gaugeAddress;
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
- var addr = coin.address;
140
- if (addr in this.contracts)
128
+ if (coin.address in this.contracts)
141
129
  continue;
142
- this.contracts[addr] = {
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, isCrypto);
168
- if (isCrypto)
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 = {};
@@ -0,0 +1,2 @@
1
+ import { IDict, IPoolData, ICurve } from "../interfaces";
2
+ export declare function getTricryptoFactoryPoolData(this: ICurve, fromIdx?: number, swapAddress?: string): Promise<IDict<IPoolData>>;