@curvefi/api 2.54.6 → 2.54.7

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.
@@ -0,0 +1,156 @@
1
+ [
2
+ {
3
+ "stateMutability": "view",
4
+ "type": "function",
5
+ "name": "calc_token_amount",
6
+ "inputs": [
7
+ {
8
+ "name": "_pool",
9
+ "type": "address"
10
+ },
11
+ {
12
+ "name": "_amounts",
13
+ "type": "uint256[]"
14
+ },
15
+ {
16
+ "name": "_is_deposit",
17
+ "type": "bool"
18
+ }
19
+ ],
20
+ "outputs": [
21
+ {
22
+ "name": "",
23
+ "type": "uint256"
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "stateMutability": "nonpayable",
29
+ "type": "function",
30
+ "name": "add_liquidity",
31
+ "inputs": [
32
+ {
33
+ "name": "_pool",
34
+ "type": "address"
35
+ },
36
+ {
37
+ "name": "_deposit_amounts",
38
+ "type": "uint256[]"
39
+ },
40
+ {
41
+ "name": "_min_mint_amount",
42
+ "type": "uint256"
43
+ }
44
+ ],
45
+ "outputs": [
46
+ {
47
+ "name": "",
48
+ "type": "uint256"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "stateMutability": "view",
54
+ "type": "function",
55
+ "name": "calc_withdraw_one_coin",
56
+ "inputs": [
57
+ {
58
+ "name": "_pool",
59
+ "type": "address"
60
+ },
61
+ {
62
+ "name": "_token_amount",
63
+ "type": "uint256"
64
+ },
65
+ {
66
+ "name": "i",
67
+ "type": "int128"
68
+ }
69
+ ],
70
+ "outputs": [
71
+ {
72
+ "name": "",
73
+ "type": "uint256"
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ "stateMutability": "nonpayable",
79
+ "type": "function",
80
+ "name": "remove_liquidity",
81
+ "inputs": [
82
+ {
83
+ "name": "_pool",
84
+ "type": "address"
85
+ },
86
+ {
87
+ "name": "_burn_amount",
88
+ "type": "uint256"
89
+ },
90
+ {
91
+ "name": "_min_amounts",
92
+ "type": "uint256[]"
93
+ }
94
+ ],
95
+ "outputs": [
96
+ {
97
+ "name": "",
98
+ "type": "uint256[]"
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "stateMutability": "nonpayable",
104
+ "type": "function",
105
+ "name": "remove_liquidity_one_coin",
106
+ "inputs": [
107
+ {
108
+ "name": "_pool",
109
+ "type": "address"
110
+ },
111
+ {
112
+ "name": "_burn_amount",
113
+ "type": "uint256"
114
+ },
115
+ {
116
+ "name": "i",
117
+ "type": "int128"
118
+ },
119
+ {
120
+ "name": "_min_amount",
121
+ "type": "uint256"
122
+ }
123
+ ],
124
+ "outputs": [
125
+ {
126
+ "name": "",
127
+ "type": "uint256"
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "stateMutability": "nonpayable",
133
+ "type": "function",
134
+ "name": "remove_liquidity_imbalance",
135
+ "inputs": [
136
+ {
137
+ "name": "_pool",
138
+ "type": "address"
139
+ },
140
+ {
141
+ "name": "_amounts",
142
+ "type": "uint256[]"
143
+ },
144
+ {
145
+ "name": "_max_burn_amount",
146
+ "type": "uint256"
147
+ }
148
+ ],
149
+ "outputs": [
150
+ {
151
+ "name": "",
152
+ "type": "uint256"
153
+ }
154
+ ]
155
+ }
156
+ ]
@@ -64,6 +64,9 @@ export declare const basePoolIdZapDictBsc: IDict<{
64
64
  address: string;
65
65
  ABI: any;
66
66
  }>;
67
+ export declare const stableNgBasePoolZap: {
68
+ ABI: any;
69
+ };
67
70
  export declare const FACTORY_CONSTANTS: {
68
71
  [index: number]: {
69
72
  implementationABIDict: IDict<any>;
@@ -71,5 +74,8 @@ export declare const FACTORY_CONSTANTS: {
71
74
  address: string;
72
75
  ABI: any;
73
76
  }>;
77
+ stableNgBasePoolZap: {
78
+ ABI: any;
79
+ };
74
80
  };
75
81
  };
@@ -39,6 +39,7 @@ import MetaZapFantomABI from "../constants/abis/factory-v2/DepositZapFantom.json
39
39
  import MetaGeistUsdZapFantomABI from "../constants/abis/factory-v2/DepositZapMetaUsd2Fantom.json" assert { type: 'json' };
40
40
  import RenMetaZapABI from "../constants/abis/ren/meta_zap.json" assert { type: 'json' };
41
41
  import Sbtc2MetaZapABI from "../constants/abis/sbtc2/meta_zap.json" assert { type: 'json' };
42
+ import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" assert { type: 'json' };
42
43
  import { lowerCaseKeys } from "../constants/utils.js";
43
44
  export var implementationABIDictEthereum = lowerCaseKeys({
44
45
  "0x5F890841f657d90E081bAbdB532A05996Af79Fe6": factorySwapABI,
@@ -439,57 +440,73 @@ export var basePoolIdZapDictCelo = {};
439
440
  export var basePoolIdZapDictZkSync = {};
440
441
  export var basePoolIdZapDictBase = {};
441
442
  export var basePoolIdZapDictBsc = {};
443
+ export var stableNgBasePoolZap = {
444
+ ABI: StableNgBasePoolZapABI,
445
+ };
442
446
  export var FACTORY_CONSTANTS = {
443
447
  1: {
444
448
  implementationABIDict: implementationABIDictEthereum,
445
449
  basePoolIdZapDict: basePoolIdZapDictEthereum,
450
+ stableNgBasePoolZap: stableNgBasePoolZap,
446
451
  },
447
452
  10: {
448
453
  implementationABIDict: implementationABIDictOptimism,
449
454
  basePoolIdZapDict: basePoolIdZapDictOptimism,
455
+ stableNgBasePoolZap: stableNgBasePoolZap,
450
456
  },
451
457
  56: {
452
458
  implementationABIDict: implementationABIDictBsc,
453
459
  basePoolIdZapDict: basePoolIdZapDictBsc,
460
+ stableNgBasePoolZap: stableNgBasePoolZap,
454
461
  },
455
462
  100: {
456
463
  implementationABIDict: implementationABIDictXDai,
457
464
  basePoolIdZapDict: basePoolIdZapDictXDai,
465
+ stableNgBasePoolZap: stableNgBasePoolZap,
458
466
  },
459
467
  137: {
460
468
  implementationABIDict: implementationABIDictPolygon,
461
469
  basePoolIdZapDict: basePoolIdZapDictPolygon,
470
+ stableNgBasePoolZap: stableNgBasePoolZap,
462
471
  },
463
472
  250: {
464
473
  implementationABIDict: implementationABIDictFantom,
465
474
  basePoolIdZapDict: basePoolIdZapDictFantom,
475
+ stableNgBasePoolZap: stableNgBasePoolZap,
466
476
  },
467
477
  324: {
468
478
  implementationABIDict: implementationABIDictZkSync,
469
479
  basePoolIdZapDict: basePoolIdZapDictZkSync,
480
+ stableNgBasePoolZap: stableNgBasePoolZap,
470
481
  },
471
482
  1284: {
472
483
  implementationABIDict: implementationABIDictMoonbeam,
473
484
  basePoolIdZapDict: basePoolIdZapDictMoonbeam,
485
+ stableNgBasePoolZap: stableNgBasePoolZap,
474
486
  },
475
487
  2222: {
476
488
  implementationABIDict: implementationABIDictKava,
477
489
  basePoolIdZapDict: basePoolIdZapDictKava,
490
+ stableNgBasePoolZap: stableNgBasePoolZap,
478
491
  },
479
492
  8453: {
480
493
  implementationABIDict: implementationABIDictBase,
481
494
  basePoolIdZapDict: basePoolIdZapDictBase,
495
+ stableNgBasePoolZap: stableNgBasePoolZap,
482
496
  },
483
497
  42220: {
484
498
  implementationABIDict: implementationABIDictCelo,
485
499
  basePoolIdZapDict: basePoolIdZapDictCelo,
500
+ stableNgBasePoolZap: stableNgBasePoolZap,
486
501
  },
487
502
  43114: {
488
503
  implementationABIDict: implementationABIDictAvalanche,
489
504
  basePoolIdZapDict: basePoolIdZapDictAvalanche,
505
+ stableNgBasePoolZap: stableNgBasePoolZap,
490
506
  },
491
507
  42161: {
492
508
  implementationABIDict: implementationABIDictArbitrum,
493
509
  basePoolIdZapDict: basePoolIdZapDictArbitrum,
510
+ stableNgBasePoolZap: stableNgBasePoolZap,
494
511
  },
495
512
  };
@@ -64,7 +64,7 @@ import { FACTORY_CONSTANTS } from "./constants.js";
64
64
  import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
65
65
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
66
66
  import { _getPoolsFromApi } from "../external-api.js";
67
- import { assetTypeNameHandler, getPoolName } from "../utils.js";
67
+ import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
68
68
  export var lowerCasePoolDataAddresses = function (poolsData) {
69
69
  var _a;
70
70
  for (var _i = 0, poolsData_1 = poolsData; _i < poolsData_1.length; _i++) {
@@ -239,7 +239,10 @@ export function getFactoryPoolsDataFromApi(factoryType) {
239
239
  var basePoolCoinAddresses = (_b = allPoolsData[basePoolId]) === null || _b === void 0 ? void 0 : _b.underlying_coin_addresses;
240
240
  var basePoolDecimals = (_c = allPoolsData[basePoolId]) === null || _c === void 0 ? void 0 : _c.underlying_decimals;
241
241
  var basePoolIdZapDict = FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
242
- var basePoolZap = basePoolIdZapDict[basePoolId];
242
+ var basePoolZap = isStableNgPool(basePoolId) ? FACTORY_CONSTANTS[_this.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePoolId];
243
+ if (isStableNgPool(basePoolId)) {
244
+ _this.setContract(pool.basePoolAddress, FACTORY_CONSTANTS[_this.chainId].stableNgBasePoolZap);
245
+ }
243
246
  FACTORY_POOLS_DATA[pool.id] = {
244
247
  name: getPoolName(pool.name),
245
248
  full_name: pool.name,
@@ -248,7 +251,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
248
251
  swap_address: pool.address,
249
252
  token_address: pool.address,
250
253
  gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
251
- deposit_address: basePoolZap.address,
254
+ deposit_address: pool.basePoolAddress,
252
255
  implementation_address: pool.implementationAddress,
253
256
  is_meta: true,
254
257
  is_factory: true,
@@ -2,5 +2,8 @@ import { IDict, IPoolData, ICurve, IPoolDataShort } from "../interfaces";
2
2
  export declare const BLACK_LIST: {
3
3
  [index: number]: any;
4
4
  };
5
- export declare function getBasePoolIds(this: ICurve, factoryAddress: string, rawSwapAddresses: string[], tmpPools: IPoolDataShort[]): Promise<Array<string>>;
5
+ export declare function getBasePools(this: ICurve, factoryAddress: string, rawSwapAddresses: string[], tmpPools: IPoolDataShort[]): Promise<{
6
+ ids: string[];
7
+ addresses: string[];
8
+ }>;
6
9
  export declare function getFactoryPoolData(this: ICurve, fromIdx?: number, swapAddress?: string, factoryAddress?: string): Promise<IDict<IPoolData>>;
@@ -61,7 +61,7 @@ import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type
61
61
  import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
62
62
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
63
63
  import { FACTORY_CONSTANTS } from "./constants.js";
64
- import { getPoolName } from "../utils.js";
64
+ import { getPoolName, isStableNgPool } from "../utils.js";
65
65
  export var BLACK_LIST = {
66
66
  1: [
67
67
  "0x066b6e1e93fa7dcd3f0eb7f8bac7d5a747ce0bf9",
@@ -77,9 +77,9 @@ export var BLACK_LIST = {
77
77
  ],
78
78
  };
79
79
  var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
80
- export function getBasePoolIds(factoryAddress, rawSwapAddresses, tmpPools) {
80
+ export function getBasePools(factoryAddress, rawSwapAddresses, tmpPools) {
81
81
  return __awaiter(this, void 0, void 0, function () {
82
- var factoryMulticallContract, calls, _i, rawSwapAddresses_1, addr, result, basePoolIds;
82
+ var factoryMulticallContract, calls, _i, rawSwapAddresses_1, addr, result, basePoolIds, basePoolAddresses;
83
83
  return __generator(this, function (_a) {
84
84
  switch (_a.label) {
85
85
  case 0:
@@ -93,15 +93,21 @@ export function getBasePoolIds(factoryAddress, rawSwapAddresses, tmpPools) {
93
93
  case 1:
94
94
  result = _a.sent();
95
95
  basePoolIds = [];
96
+ basePoolAddresses = [];
96
97
  result.forEach(function (item) {
97
98
  if (item !== '0x0000000000000000000000000000000000000000') {
98
99
  basePoolIds.push(getPoolIdByAddress(tmpPools, item));
100
+ basePoolAddresses.push(item);
99
101
  }
100
102
  else {
101
103
  basePoolIds.push('');
104
+ basePoolAddresses.push(item);
102
105
  }
103
106
  });
104
- return [2 /*return*/, basePoolIds];
107
+ return [2 /*return*/, {
108
+ ids: basePoolIds,
109
+ addresses: basePoolAddresses,
110
+ }];
105
111
  }
106
112
  });
107
113
  });
@@ -331,7 +337,7 @@ export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
331
337
  if (fromIdx === void 0) { fromIdx = 0; }
332
338
  if (factoryAddress === void 0) { factoryAddress = curve.constants.ALIASES.factory; }
333
339
  return __awaiter(this, void 0, void 0, function () {
334
- var _a, rawPoolIds, rawSwapAddresses, _b, _c, rawImplementations, rawGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses, poolIds, swapAddresses, implementations, gaugeAddresses, referenceAssets, poolSymbols, poolNames, isMeta, coinAddresses, implementationABIDict, i, swapABIs, _e, coinAddressNameDict, coinAddressDecimalsDict, tmpPools, basePoolIds, FACTORY_POOLS_DATA, _loop_2, this_1, i;
340
+ var _a, rawPoolIds, rawSwapAddresses, _b, _c, rawImplementations, rawGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses, poolIds, swapAddresses, implementations, gaugeAddresses, referenceAssets, poolSymbols, poolNames, isMeta, coinAddresses, implementationABIDict, i, swapABIs, _e, coinAddressNameDict, coinAddressDecimalsDict, tmpPools, basePools, FACTORY_POOLS_DATA, _loop_2, this_1, i;
335
341
  return __generator(this, function (_f) {
336
342
  switch (_f.label) {
337
343
  case 0:
@@ -389,9 +395,9 @@ export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
389
395
  address: swapAddresses[index],
390
396
  });
391
397
  });
392
- return [4 /*yield*/, getBasePoolIds.call(this, factoryAddress, swapAddresses, tmpPools)];
398
+ return [4 /*yield*/, getBasePools.call(this, factoryAddress, swapAddresses, tmpPools)];
393
399
  case 7:
394
- basePoolIds = _f.sent();
400
+ basePools = _f.sent();
395
401
  FACTORY_POOLS_DATA = {};
396
402
  _loop_2 = function (i) {
397
403
  if (!isMeta[i]) {
@@ -420,13 +426,16 @@ export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
420
426
  else {
421
427
  var allPoolsData_1 = __assign(__assign(__assign({}, this_1.constants.POOLS_DATA), this_1.constants.FACTORY_POOLS_DATA), FACTORY_POOLS_DATA);
422
428
  // @ts-ignore
423
- var basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
429
+ var basePoolIdCoinsDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
424
430
  // @ts-ignore
425
- var basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
431
+ var basePoolIdCoinAddressesDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
426
432
  // @ts-ignore
427
- var basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
433
+ var basePoolIdDecimalsDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
428
434
  var basePoolIdZapDict = FACTORY_CONSTANTS[this_1.chainId].basePoolIdZapDict;
429
- var basePoolZap = basePoolIdZapDict[basePoolIds[i]];
435
+ var basePoolZap = isStableNgPool(basePools.ids[i]) ? FACTORY_CONSTANTS[this_1.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePools.ids[i]];
436
+ if (isStableNgPool(basePools.ids[i])) {
437
+ this_1.setContract(basePools.addresses[i], FACTORY_CONSTANTS[this_1.chainId].stableNgBasePoolZap);
438
+ }
430
439
  FACTORY_POOLS_DATA[poolIds[i]] = {
431
440
  name: getPoolName(poolNames[i]),
432
441
  full_name: poolNames[i],
@@ -435,16 +444,16 @@ export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
435
444
  swap_address: swapAddresses[i],
436
445
  token_address: swapAddresses[i],
437
446
  gauge_address: gaugeAddresses[i],
438
- deposit_address: basePoolIdZapDict[basePoolIds[i]].address,
447
+ deposit_address: basePools.addresses[i],
439
448
  implementation_address: implementations[i],
440
449
  is_meta: true,
441
450
  is_factory: true,
442
- base_pool: basePoolIds[i],
443
- underlying_coins: __spreadArray([coinAddressNameDict[coinAddresses[i][0]]], basePoolIdCoinsDict[basePoolIds[i]], true),
451
+ base_pool: basePools.ids[i],
452
+ underlying_coins: __spreadArray([coinAddressNameDict[coinAddresses[i][0]]], basePoolIdCoinsDict[basePools.ids[i]], true),
444
453
  wrapped_coins: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }), true),
445
- underlying_coin_addresses: __spreadArray([coinAddresses[i][0]], basePoolIdCoinAddressesDict[basePoolIds[i]], true),
454
+ underlying_coin_addresses: __spreadArray([coinAddresses[i][0]], basePoolIdCoinAddressesDict[basePools.ids[i]], true),
446
455
  wrapped_coin_addresses: coinAddresses[i],
447
- underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolIdDecimalsDict[basePoolIds[i]], true),
456
+ underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolIdDecimalsDict[basePools.ids[i]], true),
448
457
  wrapped_decimals: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
449
458
  swap_abi: swapABIs[i],
450
459
  gauge_abi: this_1.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
package/lib/utils.d.ts CHANGED
@@ -60,4 +60,5 @@ export declare const hasRouter: () => boolean;
60
60
  export declare const getCountArgsOfMethodByContract: (contract: Contract, methodName: string) => number;
61
61
  export declare const isMethodExist: (contract: Contract, methodName: string) => boolean;
62
62
  export declare const getPoolName: (name: string) => string;
63
+ export declare const isStableNgPool: (name: string) => boolean;
63
64
  export declare const assetTypeNameHandler: (assetTypeName: string) => REFERENCE_ASSET;
package/lib/utils.js CHANGED
@@ -918,6 +918,9 @@ export var getPoolName = function (name) {
918
918
  return separatedName[0].trim();
919
919
  }
920
920
  };
921
+ export var isStableNgPool = function (name) {
922
+ return name.includes('factory-stable-ng');
923
+ };
921
924
  export var assetTypeNameHandler = function (assetTypeName) {
922
925
  if (assetTypeName.toUpperCase() === 'UNKNOWN') {
923
926
  return 'OTHER';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.54.6",
3
+ "version": "2.54.7",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",