@curvefi/api 2.63.3 → 2.63.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.
@@ -2,8 +2,6 @@ import { lowerCaseValues } from "./utils.js";
2
2
  export const ALIASES_ETHEREUM = lowerCaseValues({
3
3
  "crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
4
4
  "minter": '0xd061D61a4d941c39E5453435B6345Dc261C2fcE0',
5
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
6
- "gauge_factory_fraxtal": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
7
5
  "voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
8
6
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
9
7
  "fee_distributor_crvusd": "0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914",
@@ -27,7 +25,8 @@ export const ALIASES_ETHEREUM = lowerCaseValues({
27
25
  });
28
26
  export const ALIASES_POLYGON = lowerCaseValues({
29
27
  "crv": "0x172370d5cd63279efa6d502dab29171933a610af",
30
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
28
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
29
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
31
30
  "voting_escrow": "0xb5acc710aede048600e10eedcefdf98d4abf4b1e",
32
31
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
33
32
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -47,7 +46,8 @@ export const ALIASES_POLYGON = lowerCaseValues({
47
46
  });
48
47
  export const ALIASES_FANTOM = lowerCaseValues({
49
48
  "crv": "0x1E4F97b9f9F913c46F1632781732927B9019C68b",
50
- "gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
49
+ "child_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
50
+ "root_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
51
51
  "voting_escrow": "0xb75dca485e21a77e1b433ecacb74475fc67e259c",
52
52
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
53
53
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -67,7 +67,8 @@ export const ALIASES_FANTOM = lowerCaseValues({
67
67
  });
68
68
  export const ALIASES_AVALANCHE = lowerCaseValues({
69
69
  "crv": "0x47536F17F4fF30e64A96a7555826b8f9e66ec468",
70
- "gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
70
+ "child_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
71
+ "root_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
71
72
  "voting_escrow": "0xc55837710bc500f1e3c7bb9dd1d51f7c5647e657",
72
73
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
73
74
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -87,7 +88,8 @@ export const ALIASES_AVALANCHE = lowerCaseValues({
87
88
  });
88
89
  export const ALIASES_ARBITRUM = lowerCaseValues({
89
90
  "crv": "0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978",
90
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
91
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
92
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
91
93
  "voting_escrow": "0x98c80fa823759b642c3e02f40533c164f40727ae",
92
94
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
93
95
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -107,7 +109,8 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
107
109
  });
108
110
  export const ALIASES_OPTIMISM = lowerCaseValues({
109
111
  "crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
110
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
112
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
113
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
111
114
  "voting_escrow": "0x65a0b01756e837e6670634816e4f5b3a3ff21107",
112
115
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
113
116
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -129,7 +132,9 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
129
132
  });
130
133
  export const ALIASES_XDAI = lowerCaseValues({
131
134
  "crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
132
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
135
+ "child_gauge_factory": "0x7BE6BD57A319A7180f71552E58c9d32Da32b6f96",
136
+ "root_gauge_factory": "0x06471ED238306a427241B3eA81352244E77B004F",
137
+ "child_gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
133
138
  "voting_escrow": "0xefde221f306152971d8e9f181bfe998447975810",
134
139
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
135
140
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -143,13 +148,14 @@ export const ALIASES_XDAI = lowerCaseValues({
143
148
  "eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
144
149
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
145
150
  "twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
146
- "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
151
+ "tricrypto_factory": '0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8',
147
152
  "stable_ng_factory": '0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8',
148
153
  "factory_admin": "",
149
154
  });
150
155
  export const ALIASES_MOONBEAM = lowerCaseValues({
151
156
  "crv": "0x7C598c96D02398d89FbCb9d41Eab3DF0C16F227D",
152
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
157
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
158
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
153
159
  "voting_escrow": "0x0000000000000000000000000000000000000000",
154
160
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
155
161
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -169,7 +175,7 @@ export const ALIASES_MOONBEAM = lowerCaseValues({
169
175
  });
170
176
  export const ALIASES_AURORA = lowerCaseValues({
171
177
  "crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
172
- "gauge_factory": "0x0000000000000000000000000000000000000000",
178
+ "child_gauge_factory": "0x0000000000000000000000000000000000000000",
173
179
  "voting_escrow": "0x0000000000000000000000000000000000000000",
174
180
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
175
181
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -189,7 +195,8 @@ export const ALIASES_AURORA = lowerCaseValues({
189
195
  });
190
196
  export const ALIASES_KAVA = lowerCaseValues({
191
197
  "crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
192
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
198
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
199
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
193
200
  "voting_escrow": "0x0000000000000000000000000000000000000000",
194
201
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
195
202
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -209,7 +216,8 @@ export const ALIASES_KAVA = lowerCaseValues({
209
216
  });
210
217
  export const ALIASES_CELO = lowerCaseValues({
211
218
  "crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
212
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
219
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
220
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
213
221
  "voting_escrow": "0x0000000000000000000000000000000000000000",
214
222
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
215
223
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -229,7 +237,7 @@ export const ALIASES_CELO = lowerCaseValues({
229
237
  });
230
238
  export const ALIASES_ZKSYNC = lowerCaseValues({
231
239
  "crv": "0x5945932099f124194452a4c62d34bB37f16183B2",
232
- "gauge_factory": "0x0000000000000000000000000000000000000000",
240
+ "child_gauge_factory": "0x0000000000000000000000000000000000000000",
233
241
  "voting_escrow": "0x0000000000000000000000000000000000000000",
234
242
  "fee_distributor": "0x0000000000000000000000000000000000000000",
235
243
  "gauge_controller": "0x0000000000000000000000000000000000000000",
@@ -249,7 +257,8 @@ export const ALIASES_ZKSYNC = lowerCaseValues({
249
257
  });
250
258
  export const ALIASES_BASE = lowerCaseValues({
251
259
  "crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
252
- "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
260
+ "child_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
261
+ "root_gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
253
262
  "voting_escrow": "0x0000000000000000000000000000000000000000",
254
263
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
255
264
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
@@ -271,7 +280,8 @@ export const ALIASES_BASE = lowerCaseValues({
271
280
  });
272
281
  export const ALIASES_BSC = lowerCaseValues({
273
282
  "crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
274
- "gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
283
+ "child_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
284
+ "root_gauge_factory": "0xDb205f215f568ADf21b9573b62566f6d9a40bed6",
275
285
  "voting_escrow": "0x0000000000000000000000000000000000000000",
276
286
  "fee_distributor": "0x0000000000000000000000000000000000000000",
277
287
  "gauge_controller": "0x0000000000000000000000000000000000000000",
@@ -291,7 +301,8 @@ export const ALIASES_BSC = lowerCaseValues({
291
301
  });
292
302
  export const ALIASES_FRAXTAL = lowerCaseValues({
293
303
  "crv": "0x331B9182088e2A7d6D3Fe4742AbA1fB231aEcc56",
294
- "gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
304
+ "child_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
305
+ "root_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
295
306
  "voting_escrow": "0x0000000000000000000000000000000000000000",
296
307
  "fee_distributor": "0x0000000000000000000000000000000000000000",
297
308
  "gauge_controller": "0x0000000000000000000000000000000000000000",
@@ -311,7 +322,8 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
311
322
  });
312
323
  export const ALIASES_XLAYER = lowerCaseValues({
313
324
  "crv": "0x0000000000000000000000000000000000000000",
314
- "gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
325
+ "child_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
326
+ "root_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
315
327
  "voting_escrow": "0x0000000000000000000000000000000000000000",
316
328
  "fee_distributor": "0x0000000000000000000000000000000000000000",
317
329
  "gauge_controller": "0x0000000000000000000000000000000000000000",
@@ -331,7 +343,8 @@ export const ALIASES_XLAYER = lowerCaseValues({
331
343
  });
332
344
  export const ALIASES_MANTLE = lowerCaseValues({
333
345
  "crv": "0x0000000000000000000000000000000000000000",
334
- "gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
346
+ "child_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
347
+ "root_gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
335
348
  "voting_escrow": "0x0000000000000000000000000000000000000000",
336
349
  "fee_distributor": "0x0000000000000000000000000000000000000000",
337
350
  "gauge_controller": "0x0000000000000000000000000000000000000000",
package/lib/curve.js CHANGED
@@ -16,9 +16,7 @@ import { getTricryptoFactoryPoolData } from "./factory/factory-tricrypto.js";
16
16
  import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
17
17
  import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
18
18
  import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
19
- import gaugeFactoryABI from './constants/abis/gauge_factory_mainnet.json' assert { type: 'json' };
20
- import gaugeFactoryForFraxtalABI from './constants/abis/gauge_factory_mainnet_for_fraxtal.json' assert { type: 'json' };
21
- import gaugeFactorySidechainABI from './constants/abis/gauge_factory_sidechain.json' assert { type: 'json' };
19
+ import childGaugeFactoryABI from './constants/abis/gauge_factory/child_gauge_factory.json' assert { type: 'json' };
22
20
  import minterMainnetABI from './constants/abis/minter_mainnet.json' assert { type: 'json' };
23
21
  import votingEscrowABI from './constants/abis/votingescrow.json' assert { type: 'json' };
24
22
  import anycallABI from './constants/abis/anycall.json' assert { type: 'json' };
@@ -39,7 +37,8 @@ import factoryEywaABI from './constants/abis/factory-eywa.json' assert { type: '
39
37
  import factoryAdminABI from './constants/abis/factory-admin.json' assert { type: 'json' };
40
38
  import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
41
39
  import twocryptoFactoryABI from './constants/abis/factory-twocrypto-ng.json' assert { type: 'json' };
42
- import tricryptoFactoryABI from './constants/abis/factory-tricrypto.json' assert { type: 'json' };
40
+ import tricryptoFactoryMainnetABI from './constants/abis/factory-tricrypto-mainnet.json' assert { type: 'json' };
41
+ import tricryptoFactorySidechainABI from './constants/abis/factory-tricrypto-sidechain.json' assert { type: 'json' };
43
42
  import stableNgFactoryABI from './constants/abis/factory-stable-ng.json' assert { type: 'json' };
44
43
  import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert { type: 'json' };
45
44
  import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert { type: 'json' };
@@ -456,7 +455,7 @@ class Curve {
456
455
  }
457
456
  else {
458
457
  this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-tricrypto"] =
459
- yield this.contracts[this.constants.ALIASES.gauge_factory].contract.get_implementation(this.constantOptions);
458
+ yield this.contracts[this.constants.ALIASES.child_gauge_factory].contract.get_implementation(this.constantOptions);
460
459
  }
461
460
  });
462
461
  this.fetchStableNgFactoryPools = (useApi = true) => __awaiter(this, void 0, void 0, function* () {
@@ -785,13 +784,16 @@ class Curve {
785
784
  this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
786
785
  this.setContract(this.constants.ALIASES.crv, ERC20Abi);
787
786
  this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
788
- const _gaugeFactoryABI = this.chainId === 1 ? gaugeFactoryABI : gaugeFactorySidechainABI;
789
- this.setContract(this.constants.ALIASES.gauge_factory, _gaugeFactoryABI);
790
787
  if (this.chainId === 1) {
791
788
  this.setContract(this.constants.ALIASES.minter, minterMainnetABI);
792
- this.setContract(this.constants.ALIASES.gauge_factory_fraxtal, gaugeFactoryForFraxtalABI);
793
789
  this.setContract(this.constants.ALIASES.fee_distributor_crvusd, feeDistributorCrvUSDABI);
794
790
  }
791
+ else {
792
+ this.setContract(this.constants.ALIASES.child_gauge_factory, childGaugeFactoryABI);
793
+ if ("child_gauge_factory_old" in this.constants.ALIASES) {
794
+ this.setContract(this.constants.ALIASES.child_gauge_factory_old, childGaugeFactoryABI);
795
+ }
796
+ }
795
797
  this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
796
798
  this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
797
799
  this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
@@ -817,7 +819,12 @@ class Curve {
817
819
  this.setContract(this.constants.ALIASES.eywa_factory, factoryEywaABI);
818
820
  this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
819
821
  this.setContract(this.constants.ALIASES.twocrypto_factory, twocryptoFactoryABI);
820
- this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactoryABI);
822
+ if (this.chainId == 1) {
823
+ this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactoryMainnetABI);
824
+ }
825
+ else {
826
+ this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactorySidechainABI);
827
+ }
821
828
  this.setContract(this.constants.ALIASES.stable_ng_factory, stableNgFactoryABI);
822
829
  this.setContract(this.constants.ALIASES.anycall, anycallABI);
823
830
  this.setContract(this.constants.ALIASES.voting_escrow_oracle, this.chainId === 1 ? votingEscrowOracleEthABI : votingEscrowOracleABI);
@@ -8,11 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { ethers, Contract, Typed } from "ethers";
11
- import { curve } from "../curve.js";
11
+ import { curve, NETWORK_CONSTANTS } from "../curve.js";
12
12
  import { getPool } from "../pools/index.js";
13
13
  import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress, DIGas, smartNumber } from '../utils.js';
14
14
  import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
15
15
  import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
16
+ import rootGaugeFactoryABI from '../constants/abis/gauge_factory/root_gauge_factory.json' assert { type: 'json' };
16
17
  import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
17
18
  // ------- STABLE PLAIN POOLS -------
18
19
  const _deployStablePlainPool = (name, symbol, coins, A, fee, // %
@@ -547,7 +548,7 @@ const _deployGauge = (pool, factory, estimateGas) => __awaiter(void 0, void 0, v
547
548
  const _deployGaugeSidechain = (pool, salt, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
548
549
  if (curve.chainId === 1)
549
550
  throw Error("There is no deployGaugeSidechain method on ethereum network");
550
- const contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
551
+ const contract = curve.contracts[curve.constants.ALIASES.child_gauge_factory].contract;
551
552
  const _salt = ethers.encodeBytes32String(salt);
552
553
  const gas = yield contract.deploy_gauge.estimateGas(pool, Typed.bytes32(_salt), curve.signerAddress, curve.constantOptions);
553
554
  if (estimateGas)
@@ -559,7 +560,9 @@ const _deployGaugeSidechain = (pool, salt, estimateGas) => __awaiter(void 0, voi
559
560
  const _deployGaugeMirror = (chainId, salt, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
560
561
  if (curve.chainId !== 1)
561
562
  throw Error("There is no deployGaugeMirror method on sidechain network");
562
- const contract = chainId === 252 ? curve.contracts[curve.constants.ALIASES.gauge_factory_fraxtal].contract : curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
563
+ const rootGaugeFactory = NETWORK_CONSTANTS[chainId].root_gauge_factory;
564
+ curve.setContract(rootGaugeFactory, rootGaugeFactoryABI);
565
+ const contract = curve.contracts[rootGaugeFactory].contract;
563
566
  const _salt = ethers.encodeBytes32String(salt);
564
567
  const gas = yield contract.deploy_gauge.estimateGas(chainId, Typed.bytes32(_salt), curve.constantOptions);
565
568
  if (estimateGas)
@@ -593,7 +596,9 @@ export const getDeployedGaugeMirrorAddressByTx = (tx) => __awaiter(void 0, void
593
596
  export const getDeployedGaugeMirrorAddress = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
594
597
  if (curve.chainId !== 1)
595
598
  throw Error("There is no getDeployedGaugeMirrorAddress method on sidechain network");
596
- const contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
599
+ const rootGaugeFactory = NETWORK_CONSTANTS[chainId].root_gauge_factory;
600
+ curve.setContract(rootGaugeFactory, rootGaugeFactoryABI);
601
+ const contract = curve.contracts[rootGaugeFactory].contract;
597
602
  const gaugeCount = yield contract.get_gauge_count(chainId);
598
603
  const currentIndex = Number(gaugeCount) - 1;
599
604
  return yield contract.get_gauge(chainId, currentIndex);
@@ -95,7 +95,7 @@ const getSwapAbiByFactoryType = (factoryType, pool) => {
95
95
  const map = {
96
96
  "factory-crypto": cryptoFactorySwapABI,
97
97
  "factory-twocrypto": twocryptoFactorySwapABI,
98
- "facroty-tricrypto": isETHDisabled ? tricryptoFactoryEthDisabledSwapABI : tricryptoFactorySwapABI,
98
+ "factory-tricrypto": isETHDisabled ? tricryptoFactoryEthDisabledSwapABI : tricryptoFactorySwapABI,
99
99
  };
100
100
  return map[factoryType];
101
101
  };
@@ -70,7 +70,8 @@ function _getLpTokenMap(factorySwapAddresses) {
70
70
  function getPoolsData(factorySwapAddresses) {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
72
  const factoryMulticallContract = this.contracts[this.constants.ALIASES.crypto_factory].multicallContract;
73
- const isfactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
73
+ const isChildGaugeFactoryNull = curve.chainId !== 1 && this.constants.ALIASES.child_gauge_factory === curve.constants.ZERO_ADDRESS;
74
+ const isChildGaugeFactoryOldNull = !("child_gauge_factory_old" in this.constants.ALIASES);
74
75
  const calls = [];
75
76
  if (this.chainId === 1) {
76
77
  for (const addr of factorySwapAddresses) {
@@ -80,29 +81,32 @@ function getPoolsData(factorySwapAddresses) {
80
81
  }
81
82
  }
82
83
  else {
83
- const factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
84
84
  const LpTokenMap = yield _getLpTokenMap.call(this, factorySwapAddresses);
85
85
  for (const addr of factorySwapAddresses) {
86
86
  calls.push(factoryMulticallContract.get_token(addr));
87
- if (!isfactoryGaugeNull) {
88
- calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(LpTokenMap[addr]));
87
+ if (!isChildGaugeFactoryNull) {
88
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory].multicallContract.get_gauge_from_lp_token(LpTokenMap[addr]));
89
+ }
90
+ if (!isChildGaugeFactoryOldNull) {
91
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory_old].multicallContract.get_gauge_from_lp_token(LpTokenMap[addr]));
89
92
  }
90
93
  calls.push(factoryMulticallContract.get_coins(addr));
91
94
  }
92
95
  }
93
96
  const res = yield this.multicallProvider.all(calls);
94
- if (isfactoryGaugeNull) {
95
- const tokenAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
96
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 1));
97
- const gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(() => '0x0000000000000000000000000000000000000000');
98
- return [tokenAddresses, gaugeAddresses, coinAddresses];
99
- }
100
- else {
101
- const tokenAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
102
- const gaugeAddresses = res.filter((a, i) => i % 3 == 1).map((a) => a.toLowerCase());
103
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 2));
104
- return [tokenAddresses, gaugeAddresses, coinAddresses];
97
+ if (isChildGaugeFactoryNull || isChildGaugeFactoryOldNull) {
98
+ for (let index = 0; index < res.length; index++) {
99
+ if (isChildGaugeFactoryNull && index % 4 == 1)
100
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
101
+ if (isChildGaugeFactoryOldNull && index % 4 == 2)
102
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
103
+ }
105
104
  }
105
+ const tokenAddresses = res.filter((a, i) => i % 4 == 0).map((a) => a.toLowerCase());
106
+ const gaugeAddresses = res.filter((a, i) => i % 4 == 1).map((a) => a.toLowerCase());
107
+ const gaugeOldAddresses = res.filter((a, i) => i % 4 == 2).map((a) => a.toLowerCase());
108
+ const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 4 == 3));
109
+ return [tokenAddresses, gaugeAddresses, gaugeOldAddresses, coinAddresses];
106
110
  });
107
111
  }
108
112
  function setCryptoFactorySwapContracts(factorySwapAddresses) {
@@ -199,7 +203,11 @@ export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
199
203
  : yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
200
204
  if (poolIds.length === 0)
201
205
  return {};
202
- const [tokenAddresses, gaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
206
+ const [tokenAddresses, rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
207
+ const gaugeAddresses = [];
208
+ for (let i = 0; i < rawGaugeAddresses.length; i++) {
209
+ gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
210
+ }
203
211
  setCryptoFactorySwapContracts.call(this, swapAddresses);
204
212
  setCryptoFactoryTokenContracts.call(this, tokenAddresses);
205
213
  setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { curve } from "../curve.js";
11
11
  import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
12
12
  import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" assert { type: 'json' };
13
+ import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" assert { type: 'json' };
13
14
  import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
14
15
  import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
15
16
  import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
@@ -48,46 +49,44 @@ function _handleCoinAddresses(coinAddresses) {
48
49
  }
49
50
  function getPoolsData(factorySwapAddresses) {
50
51
  return __awaiter(this, void 0, void 0, function* () {
52
+ const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
53
+ const isChildGaugeFactoryNull = curve.chainId !== 1 && this.constants.ALIASES.child_gauge_factory === curve.constants.ZERO_ADDRESS;
54
+ const isChildGaugeFactoryOldNull = !("child_gauge_factory_old" in this.constants.ALIASES);
55
+ const calls = [];
51
56
  if (this.chainId === 1) {
52
- const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
53
- const calls = [];
54
57
  for (const addr of factorySwapAddresses) {
55
58
  calls.push(factoryMulticallContract.get_gauge(addr));
56
59
  calls.push(factoryMulticallContract.get_coins(addr));
57
- calls.push(factoryMulticallContract.get_implementation_address(addr));
58
60
  }
59
- const res = yield this.multicallProvider.all(calls);
60
- const gaugeAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
61
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 1));
62
- const implementationAddresses = res.filter((a, i) => i % 3 == 2).map((a) => a.toLowerCase());
63
- return [gaugeAddresses, coinAddresses, implementationAddresses];
64
61
  }
65
62
  else {
66
- const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
67
- const isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
68
- const factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
69
- const calls = [];
70
63
  for (const addr of factorySwapAddresses) {
71
- if (!isFactoryGaugeNull) {
72
- calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(addr));
64
+ if (!isChildGaugeFactoryNull) {
65
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory].multicallContract.get_gauge_from_lp_token(addr));
66
+ }
67
+ if (!isChildGaugeFactoryOldNull) {
68
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory_old].multicallContract.get_gauge_from_lp_token(addr));
73
69
  }
74
70
  calls.push(factoryMulticallContract.get_coins(addr));
75
71
  calls.push(factoryMulticallContract.get_implementation_address(addr));
76
72
  }
77
- const res = yield this.multicallProvider.all(calls);
78
- if (!isFactoryGaugeNull) {
79
- const gaugeAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
80
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 1));
81
- const implementationAddresses = res.filter((a, i) => i % 3 == 2).map((a) => a.toLowerCase());
82
- return [gaugeAddresses, coinAddresses, implementationAddresses];
83
- }
84
- else {
85
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 0));
86
- const gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(() => '0x0000000000000000000000000000000000000000');
87
- const implementationAddresses = res.filter((a, i) => i % 2 == 1).map((a) => a.toLowerCase());
88
- return [gaugeAddresses, coinAddresses, implementationAddresses];
73
+ }
74
+ const res = yield this.multicallProvider.all(calls);
75
+ if (isChildGaugeFactoryNull || isChildGaugeFactoryOldNull || this.chainId === 1) {
76
+ for (let index = 0; index < res.length; index++) {
77
+ if (isChildGaugeFactoryNull && index % 4 == 0)
78
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
79
+ if (isChildGaugeFactoryOldNull && index % 4 == 1)
80
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
81
+ if (this.chainId === 1 && index % 4 == 3)
82
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
89
83
  }
90
84
  }
85
+ const gaugeAddresses = res.filter((a, i) => i % 4 == 0).map((a) => a.toLowerCase());
86
+ const gaugeOldAddresses = res.filter((a, i) => i % 4 == 1).map((a) => a.toLowerCase());
87
+ const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 4 == 2));
88
+ const implementationAddresses = res.filter((a, i) => i % 4 == 3).map((a) => a.toLowerCase());
89
+ return [gaugeAddresses, gaugeOldAddresses, coinAddresses, implementationAddresses];
91
90
  });
92
91
  }
93
92
  function setCryptoFactorySwapContracts(factorySwapAddresses) {
@@ -95,11 +94,6 @@ function setCryptoFactorySwapContracts(factorySwapAddresses) {
95
94
  this.setContract(addr, tricryptoFactorySwapABI);
96
95
  });
97
96
  }
98
- function setCryptoFactoryTokenContracts(factoryTokenAddresses) {
99
- factoryTokenAddresses.forEach((addr) => {
100
- this.setContract(addr, ERC20ABI);
101
- });
102
- }
103
97
  function setCryptoFactoryGaugeContracts(factoryGaugeAddresses) {
104
98
  factoryGaugeAddresses.filter((addr) => addr !== curve.constants.ZERO_ADDRESS).forEach((addr, i) => {
105
99
  this.setContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
@@ -180,7 +174,11 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
180
174
  : yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
181
175
  if (poolIds.length === 0)
182
176
  return {};
183
- const [gaugeAddresses, coinAddresses, implementationAddresses] = yield getPoolsData.call(this, swapAddresses);
177
+ const [rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses, implementationAddresses] = yield getPoolsData.call(this, swapAddresses);
178
+ const gaugeAddresses = [];
179
+ for (let i = 0; i < rawGaugeAddresses.length; i++) {
180
+ gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
181
+ }
184
182
  setCryptoFactorySwapContracts.call(this, swapAddresses);
185
183
  setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
186
184
  setCryptoFactoryCoinsContracts.call(this, coinAddresses);
@@ -189,8 +187,8 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
189
187
  const TRICRYPTO_FACTORY_POOLS_DATA = {};
190
188
  const nativeToken = this.constants.NATIVE_TOKEN;
191
189
  for (let i = 0; i < poolIds.length; i++) {
190
+ const isETHEnabled = this.chainId === 1 || implementationAddresses[i] === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
192
191
  const underlyingCoinAddresses = coinAddresses[i].map((addr) => {
193
- const isETHEnabled = implementationAddresses[i] === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
194
192
  if (isETHEnabled) {
195
193
  return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
196
194
  }
@@ -215,7 +213,7 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
215
213
  wrapped_coin_addresses: coinAddresses[i],
216
214
  underlying_decimals: [...underlyingCoinAddresses.map((addr) => coinAddressDecimalsDict[addr])],
217
215
  wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
218
- swap_abi: tricryptoFactorySwapABI,
216
+ swap_abi: isETHEnabled ? tricryptoFactorySwapABI : tricryptoFactoryEthDisabledSwapABI,
219
217
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
220
218
  is_ng: true,
221
219
  };
@@ -47,41 +47,40 @@ function _handleCoinAddresses(coinAddresses) {
47
47
  }
48
48
  function getPoolsData(factorySwapAddresses) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
+ const factoryMulticallContract = this.contracts[this.constants.ALIASES.twocrypto_factory].multicallContract;
51
+ const isChildGaugeFactoryNull = curve.chainId !== 1 && this.constants.ALIASES.child_gauge_factory === curve.constants.ZERO_ADDRESS;
52
+ const isChildGaugeFactoryOldNull = !("child_gauge_factory_old" in this.constants.ALIASES);
53
+ const calls = [];
50
54
  if (this.chainId === 1) {
51
- const factoryMulticallContract = this.contracts[this.constants.ALIASES.twocrypto_factory].multicallContract;
52
- const calls = [];
53
55
  for (const addr of factorySwapAddresses) {
54
56
  calls.push(factoryMulticallContract.get_gauge(addr));
55
57
  calls.push(factoryMulticallContract.get_coins(addr));
56
58
  }
57
- const res = yield this.multicallProvider.all(calls);
58
- const gaugeAddresses = res.filter((a, i) => i % 2 == 0).map((a) => a.toLowerCase());
59
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 1));
60
- return [gaugeAddresses, coinAddresses];
61
59
  }
62
60
  else {
63
- const factoryMulticallContract = this.contracts[this.constants.ALIASES.twocrypto_factory].multicallContract;
64
- const isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
65
- const factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
66
- const calls = [];
67
61
  for (const addr of factorySwapAddresses) {
68
- if (!isFactoryGaugeNull) {
69
- calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(addr));
62
+ if (!isChildGaugeFactoryNull) {
63
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory].multicallContract.get_gauge_from_lp_token(addr));
64
+ }
65
+ if (!isChildGaugeFactoryOldNull) {
66
+ calls.push(this.contracts[this.constants.ALIASES.child_gauge_factory_old].multicallContract.get_gauge_from_lp_token(addr));
70
67
  }
71
68
  calls.push(factoryMulticallContract.get_coins(addr));
72
69
  }
73
- const res = yield this.multicallProvider.all(calls);
74
- if (!isFactoryGaugeNull) {
75
- const gaugeAddresses = res.filter((a, i) => i % 2 == 0).map((a) => a.toLowerCase());
76
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 1));
77
- return [gaugeAddresses, coinAddresses];
78
- }
79
- else {
80
- const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 0));
81
- const gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(() => '0x0000000000000000000000000000000000000000');
82
- return [gaugeAddresses, coinAddresses];
70
+ }
71
+ const res = yield this.multicallProvider.all(calls);
72
+ if (isChildGaugeFactoryNull || isChildGaugeFactoryOldNull) {
73
+ for (let index = 0; index < res.length; index++) {
74
+ if (isChildGaugeFactoryNull && index % 3 == 0)
75
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
76
+ if (isChildGaugeFactoryOldNull && index % 3 == 1)
77
+ res.splice(index, 0, curve.constants.ZERO_ADDRESS);
83
78
  }
84
79
  }
80
+ const gaugeAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
81
+ const gaugeOldAddresses = res.filter((a, i) => i % 3 == 1).map((a) => a.toLowerCase());
82
+ const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 2));
83
+ return [gaugeAddresses, gaugeOldAddresses, coinAddresses];
85
84
  });
86
85
  }
87
86
  function setTwocryptoFactorySwapContracts(factorySwapAddresses) {
@@ -89,11 +88,6 @@ function setTwocryptoFactorySwapContracts(factorySwapAddresses) {
89
88
  this.setContract(addr, twocryptoFactorySwapABI);
90
89
  });
91
90
  }
92
- function setTwocryptoFactoryTokenContracts(factoryTokenAddresses) {
93
- factoryTokenAddresses.forEach((addr) => {
94
- this.setContract(addr, ERC20ABI);
95
- });
96
- }
97
91
  function setTwocryptoFactoryGaugeContracts(factoryGaugeAddresses) {
98
92
  factoryGaugeAddresses.filter((addr) => addr !== curve.constants.ZERO_ADDRESS).forEach((addr, i) => {
99
93
  this.setContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
@@ -177,7 +171,11 @@ export function getTwocryptoFactoryPoolData(fromIdx = 0, swapAddress) {
177
171
  : yield getTwocryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
178
172
  if (poolIds.length === 0)
179
173
  return {};
180
- const [gaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
174
+ const [rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
175
+ const gaugeAddresses = [];
176
+ for (let i = 0; i < rawGaugeAddresses.length; i++) {
177
+ gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
178
+ }
181
179
  setTwocryptoFactorySwapContracts.call(this, swapAddresses);
182
180
  setTwocryptoFactoryGaugeContracts.call(this, gaugeAddresses);
183
181
  setTwocryptoFactoryCoinsContracts.call(this, coinAddresses);