@curvefi/api 2.65.28 → 2.65.29

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.
Files changed (53) hide show
  1. package/eslint.config.mjs +88 -0
  2. package/lib/boosting.js +13 -13
  3. package/lib/constants/coins/avalanche.js +4 -4
  4. package/lib/constants/coins/base.js +1 -1
  5. package/lib/constants/coins/celo.js +1 -1
  6. package/lib/constants/coins/ethereum.js +88 -88
  7. package/lib/constants/coins/fantom.js +5 -5
  8. package/lib/constants/coins/kava.js +1 -1
  9. package/lib/constants/coins/polygon.js +18 -18
  10. package/lib/constants/coins/zksync.js +1 -1
  11. package/lib/constants/factory/crypto.js +32 -32
  12. package/lib/constants/factory/stable.js +57 -57
  13. package/lib/constants/network_constants.js +37 -37
  14. package/lib/constants/pools/arbitrum.js +8 -8
  15. package/lib/constants/pools/aurora.js +2 -2
  16. package/lib/constants/pools/avalanche.js +13 -13
  17. package/lib/constants/pools/ethereum.js +89 -89
  18. package/lib/constants/pools/fantom.js +13 -13
  19. package/lib/constants/pools/moonbeam.js +3 -3
  20. package/lib/constants/pools/optimism.js +3 -3
  21. package/lib/constants/pools/polygon.js +21 -21
  22. package/lib/constants/pools/xdai.js +13 -13
  23. package/lib/curve.d.ts +1 -1
  24. package/lib/curve.js +38 -38
  25. package/lib/dao.js +12 -12
  26. package/lib/external-api.d.ts +0 -9
  27. package/lib/external-api.js +75 -104
  28. package/lib/factory/deploy.js +12 -12
  29. package/lib/factory/factory-api.js +13 -13
  30. package/lib/factory/factory-crypto.js +10 -10
  31. package/lib/factory/factory-tricrypto.js +11 -11
  32. package/lib/factory/factory-twocrypto.js +9 -9
  33. package/lib/factory/factory.js +13 -13
  34. package/lib/index.d.ts +59 -59
  35. package/lib/index.js +3 -3
  36. package/lib/pools/PoolTemplate.js +59 -59
  37. package/lib/pools/mixins/depositMixins.js +14 -14
  38. package/lib/pools/mixins/depositWrappedMixins.js +8 -8
  39. package/lib/pools/mixins/swapMixins.js +12 -12
  40. package/lib/pools/mixins/swapWrappedMixins.js +8 -8
  41. package/lib/pools/mixins/withdrawImbalanceMixins.js +12 -12
  42. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +6 -6
  43. package/lib/pools/mixins/withdrawMixins.js +14 -14
  44. package/lib/pools/mixins/withdrawOneCoinMixins.js +14 -14
  45. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +6 -6
  46. package/lib/pools/mixins/withdrawWrappedMixins.js +6 -6
  47. package/lib/pools/subClasses/gaugePool.js +4 -4
  48. package/lib/pools/subClasses/statsPool.js +3 -3
  49. package/lib/pools/utils.js +11 -11
  50. package/lib/route-graph.worker.js +3 -3
  51. package/lib/router.js +4 -5
  52. package/lib/utils.js +22 -24
  53. package/package.json +21 -18
package/lib/dao.js CHANGED
@@ -11,7 +11,7 @@ import { curve } from "./curve.js";
11
11
  import { Contract } from "ethers";
12
12
  import { _getAllGauges, _getDaoProposalList, _getDaoProposal } from './external-api.js';
13
13
  import { _getAddress, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, BN, } from './utils.js';
14
- import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" assert { type: 'json' };
14
+ import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" with { type: 'json' };
15
15
  // ----------------- Refactored boosting stuff -----------------
16
16
  export const crvSupplyStats = () => __awaiter(void 0, void 0, void 0, function* () {
17
17
  if (curve.chainId !== 1)
@@ -32,14 +32,14 @@ export const crvSupplyStats = () => __awaiter(void 0, void 0, void 0, function*
32
32
  averageLockTime: toBN(_veCrv).div(toBN(_locked)).times(4).toFixed(4), // years
33
33
  };
34
34
  });
35
- export const userCrv = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
35
+ export const userCrv = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
36
36
  if (curve.chainId !== 1)
37
37
  throw Error("Ethereum-only method");
38
38
  address = _getAddress(address);
39
39
  const _balance = yield curve.contracts[curve.constants.ALIASES.crv].contract.balanceOf(address);
40
40
  return curve.formatUnits(_balance);
41
41
  });
42
- export const userVeCrv = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
42
+ export const userVeCrv = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
43
43
  if (curve.chainId !== 1)
44
44
  throw Error("Ethereum-only method");
45
45
  address = _getAddress(address);
@@ -165,7 +165,7 @@ export const withdrawLockedCrvEstimateGas = () => __awaiter(void 0, void 0, void
165
165
  export const withdrawLockedCrv = () => __awaiter(void 0, void 0, void 0, function* () {
166
166
  return yield _withdrawLockedCrv(false);
167
167
  });
168
- export const claimableFees = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
168
+ export const claimableFees = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
169
169
  address = _getAddress(address);
170
170
  const contract = new Contract(curve.constants.ALIASES.fee_distributor, feeDistributorViewABI, curve.provider);
171
171
  return curve.formatUnits(yield contract.claim(address, curve.constantOptions));
@@ -180,10 +180,10 @@ const _claimFees = (address, estimateGas) => __awaiter(void 0, void 0, void 0, f
180
180
  const gasLimit = mulBy1_3(DIGas(gas));
181
181
  return (yield contract.claim(address, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
182
182
  });
183
- export const claimFeesEstimateGas = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
183
+ export const claimFeesEstimateGas = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
184
184
  return yield _claimFees(address, true);
185
185
  });
186
- export const claimFees = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
186
+ export const claimFees = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
187
187
  return yield _claimFees(address, false);
188
188
  });
189
189
  // ----------------- Gauge weights -----------------
@@ -215,8 +215,8 @@ export const getVotingGaugeList = () => __awaiter(void 0, void 0, void 0, functi
215
215
  }
216
216
  return res;
217
217
  });
218
- export const userGaugeVotes = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
219
- var _c, _d;
218
+ export const userGaugeVotes = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
219
+ var _a, _b;
220
220
  if (curve.chainId !== 1)
221
221
  throw Error("Ethereum-only method");
222
222
  address = _getAddress(address);
@@ -243,7 +243,7 @@ export const userGaugeVotes = (address = "") => __awaiter(void 0, void 0, void 0
243
243
  userFutureVeCrv: curve.formatUnits(veCrvBalance * votes[i][1] / BigInt(10000), 18),
244
244
  expired: dt === BigInt(0),
245
245
  gaugeData: {
246
- poolUrl: ((_c = gaugeData[i].poolUrls) === null || _c === void 0 ? void 0 : _c.swap[0]) || '',
246
+ poolUrl: ((_a = gaugeData[i].poolUrls) === null || _a === void 0 ? void 0 : _a.swap[0]) || '',
247
247
  network: gaugeData[i].blockchainId,
248
248
  gaugeAddress: gaugeData[i].gauge,
249
249
  poolAddress: gaugeData[i].swap || '',
@@ -251,7 +251,7 @@ export const userGaugeVotes = (address = "") => __awaiter(void 0, void 0, void 0
251
251
  poolName: gaugeData[i].shortName,
252
252
  totalVeCrv: curve.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
253
253
  relativeWeight: curve.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
254
- isKilled: (_d = gaugeData[i].is_killed) !== null && _d !== void 0 ? _d : false,
254
+ isKilled: (_b = gaugeData[i].is_killed) !== null && _b !== void 0 ? _b : false,
255
255
  },
256
256
  });
257
257
  powerUsed += votes[i][1];
@@ -303,7 +303,7 @@ export const getProposalList = () => __awaiter(void 0, void 0, void 0, function*
303
303
  export const getProposal = (type, id) => __awaiter(void 0, void 0, void 0, function* () {
304
304
  return yield _getDaoProposal(type, id);
305
305
  });
306
- export const userProposalVotes = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
306
+ export const userProposalVotes = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
307
307
  if (curve.chainId !== 1)
308
308
  throw Error("Ethereum-only method");
309
309
  address = _getAddress(address);
@@ -350,7 +350,7 @@ export const voteForProposalEstimateGas = (type, id, support) => __awaiter(void
350
350
  export const voteForProposal = (type, id, support) => __awaiter(void 0, void 0, void 0, function* () {
351
351
  return yield _voteForProposal(type, id, support, false);
352
352
  });
353
- const _executeVote = (type, id, estimateGas = false) => __awaiter(void 0, void 0, void 0, function* () {
353
+ const _executeVote = (type_1, id_1, ...args_1) => __awaiter(void 0, [type_1, id_1, ...args_1], void 0, function* (type, id, estimateGas = false) {
354
354
  if (curve.chainId !== 1)
355
355
  throw Error("Ethereum-only method");
356
356
  const contractAddress = type.toUpperCase() === "PARAMETER" ? curve.constants.ALIASES.voting_parameter : curve.constants.ALIASES.voting_ownership;
@@ -5,15 +5,6 @@ export declare const _getAllPoolsFromApi: (network: INetworkName, isLiteChain?:
5
5
  export declare const _getSubgraphData: ((network: INetworkName) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: INetworkName) => Promise<IVolumeAndAPYs>>;
6
6
  export declare const _getVolumes: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
7
7
  export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
8
- export declare const _getTotalVolumes: ((network: string) => Promise<{
9
- totalVolume: number;
10
- cryptoVolume: number;
11
- cryptoShare: number;
12
- }>) & memoize.Memoized<(network: string) => Promise<{
13
- totalVolume: number;
14
- cryptoVolume: number;
15
- cryptoShare: number;
16
- }>>;
17
8
  export declare const _getAllGauges: (() => Promise<IDict<IGaugesDataFromApi>>) & memoize.Memoized<() => Promise<IDict<IGaugesDataFromApi>>>;
18
9
  export declare const _getAllGaugesFormatted: (() => Promise<IDict<any>>) & memoize.Memoized<() => Promise<IDict<any>>>;
19
10
  export declare const _getHiddenPools: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
@@ -7,19 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import axios from "axios";
11
10
  import memoize from "memoizee";
12
- export const _getPoolsFromApi = memoize((network, poolType, isLiteChain = false) => __awaiter(void 0, void 0, void 0, function* () {
11
+ export const _getPoolsFromApi = memoize((network_1, poolType_1, ...args_1) => __awaiter(void 0, [network_1, poolType_1, ...args_1], void 0, function* (network, poolType, isLiteChain = false) {
13
12
  var _a;
14
13
  const api = isLiteChain ? "https://api-core.curve.fi/v1/" : "https://api.curve.fi/api";
15
14
  const url = `${api}/getPools/${network}/${poolType}`;
16
- const response = yield axios.get(url, { validateStatus: () => true });
17
- return (_a = response.data.data) !== null && _a !== void 0 ? _a : { poolData: [], tvl: 0, tvlAll: 0 };
15
+ return (_a = yield fetchData(url)) !== null && _a !== void 0 ? _a : { poolData: [], tvl: 0, tvlAll: 0 };
18
16
  }), {
19
17
  promise: true,
20
18
  maxAge: 5 * 60 * 1000, // 5m
21
19
  });
22
- export const _getAllPoolsFromApi = (network, isLiteChain = false) => __awaiter(void 0, void 0, void 0, function* () {
20
+ export const _getAllPoolsFromApi = (network_1, ...args_1) => __awaiter(void 0, [network_1, ...args_1], void 0, function* (network, isLiteChain = false) {
23
21
  if (isLiteChain) {
24
22
  return yield Promise.all([
25
23
  _getPoolsFromApi(network, "factory-twocrypto", isLiteChain),
@@ -42,106 +40,73 @@ export const _getAllPoolsFromApi = (network, isLiteChain = false) => __awaiter(v
42
40
  }
43
41
  });
44
42
  export const _getSubgraphData = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
45
- var _b, _c, _d;
46
- const url = `https://api.curve.fi/api/getSubgraphData/${network}`;
47
- const response = yield axios.get(url, { validateStatus: () => true });
48
- const poolsData = response.data.data.poolList.map((item) => {
49
- return {
50
- address: item.address,
51
- volumeUSD: item.volumeUSD,
52
- day: item.latestDailyApy,
53
- week: item.latestWeeklyApy,
54
- };
55
- });
43
+ var _a, _b, _c;
44
+ const data = yield fetchData(`https://api.curve.fi/api/getSubgraphData/${network}`);
45
+ const poolsData = data.poolList.map((data) => ({
46
+ address: data.address,
47
+ volumeUSD: data.volumeUSD,
48
+ day: data.latestDailyApy,
49
+ week: data.latestWeeklyApy,
50
+ }));
56
51
  return {
57
- poolsData: poolsData !== null && poolsData !== void 0 ? poolsData : [],
58
- totalVolume: (_b = response.data.data.totalVolume) !== null && _b !== void 0 ? _b : 0,
59
- cryptoVolume: (_c = response.data.data.cryptoVolume) !== null && _c !== void 0 ? _c : 0,
60
- cryptoShare: (_d = response.data.data.cryptoShare) !== null && _d !== void 0 ? _d : 0,
52
+ poolsData: poolsData,
53
+ totalVolume: (_a = data.totalVolume) !== null && _a !== void 0 ? _a : 0,
54
+ cryptoVolume: (_b = data.cryptoVolume) !== null && _b !== void 0 ? _b : 0,
55
+ cryptoShare: (_c = data.cryptoShare) !== null && _c !== void 0 ? _c : 0,
61
56
  };
62
57
  }), {
63
58
  promise: true,
64
59
  maxAge: 5 * 60 * 1000, // 5m
65
60
  });
66
61
  export const _getVolumes = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
67
- var _e, _f, _g;
68
- const url = `https://api.curve.fi/api/getVolumes/${network}`;
69
- const response = yield axios.get(url, { validateStatus: () => true });
70
- const poolsData = response.data.data.pools.map((item) => {
71
- return {
72
- address: item.address,
73
- volumeUSD: item.volumeUSD,
74
- day: item.latestDailyApyPcent,
75
- week: item.latestWeeklyApyPcent,
76
- };
77
- });
62
+ var _a, _b, _c;
63
+ const { pools, totalVolumes } = yield fetchData(`https://api.curve.fi/api/getVolumes/${network}`);
64
+ const poolsData = pools.map((data) => ({
65
+ address: data.address,
66
+ volumeUSD: data.volumeUSD,
67
+ day: data.latestDailyApyPcent,
68
+ week: data.latestWeeklyApyPcent,
69
+ }));
78
70
  return {
79
71
  poolsData: poolsData !== null && poolsData !== void 0 ? poolsData : [],
80
- totalVolume: (_e = response.data.data.totalVolumes.totalVolume) !== null && _e !== void 0 ? _e : 0,
81
- cryptoVolume: (_f = response.data.data.totalVolumes.totalCryptoVolume) !== null && _f !== void 0 ? _f : 0,
82
- cryptoShare: (_g = response.data.data.totalVolumes.cryptoVolumeSharePcent) !== null && _g !== void 0 ? _g : 0,
72
+ totalVolume: (_a = totalVolumes.totalVolume) !== null && _a !== void 0 ? _a : 0,
73
+ cryptoVolume: (_b = totalVolumes.totalCryptoVolume) !== null && _b !== void 0 ? _b : 0,
74
+ cryptoShare: (_c = totalVolumes.cryptoVolumeSharePcent) !== null && _c !== void 0 ? _c : 0,
83
75
  };
84
76
  }), {
85
77
  promise: true,
86
78
  maxAge: 5 * 60 * 1000, // 5m
87
79
  });
88
80
  export const _getFactoryAPYs = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
89
- var _h;
90
- const urlStable = `https://api.curve.fi/api/getFactoryAPYs/${network}/stable`;
91
- const urlCrypto = `https://api.curve.fi/api/getFactoryAPYs/${network}/crypto`;
92
- const response = yield Promise.all([
93
- axios.get(urlStable, { validateStatus: () => true }),
94
- axios.get(urlCrypto, { validateStatus: () => true }),
95
- ]);
96
- const stableVolume = response[0].data.data.totalVolumeUsd || response[0].data.data.totalVolume || 0;
97
- const cryptoVolume = response[1].data.data.totalVolumeUsd || response[1].data.data.totalVolume || 0;
98
- const poolsData = [...response[0].data.data.poolDetails, ...response[1].data.data.poolDetails].map((item) => {
99
- var _a, _b, _c;
100
- return {
101
- address: item.poolAddress,
102
- volumeUSD: (_a = item.totalVolumeUsd) !== null && _a !== void 0 ? _a : 0,
103
- day: (_b = item.apy) !== null && _b !== void 0 ? _b : 0,
104
- week: (_c = item.apy * 7) !== null && _c !== void 0 ? _c : 0, //Because api does not return week apy
105
- };
106
- });
81
+ const [stableData, cryptoData] = yield Promise.all(['stable', 'crypto'].map((type) => fetchData(`https://api.curve.fi/api/getFactoryAPYs/${network}/${type}`)));
82
+ const stableVolume = stableData.totalVolumeUsd || stableData.totalVolume || 0;
83
+ const cryptoVolume = cryptoData.totalVolumeUsd || cryptoData.totalVolume || 0;
107
84
  return {
108
- poolsData: poolsData !== null && poolsData !== void 0 ? poolsData : [],
109
- totalVolume: (_h = stableVolume + cryptoVolume) !== null && _h !== void 0 ? _h : 0,
110
- cryptoVolume: cryptoVolume !== null && cryptoVolume !== void 0 ? cryptoVolume : 0,
111
- cryptoShare: 100 * cryptoVolume / (stableVolume + cryptoVolume) || 0,
85
+ poolsData: [...stableData.poolDetails, ...cryptoData.poolDetails].map((item) => {
86
+ var _a, _b, _c;
87
+ return ({
88
+ address: item.poolAddress,
89
+ volumeUSD: (_a = item.totalVolumeUsd) !== null && _a !== void 0 ? _a : 0,
90
+ day: (_b = item.apy) !== null && _b !== void 0 ? _b : 0,
91
+ week: ((_c = item.apy) !== null && _c !== void 0 ? _c : 0) * 7, // Because api does not return week apy
92
+ });
93
+ }),
94
+ totalVolume: stableVolume + cryptoVolume,
95
+ cryptoVolume,
96
+ cryptoShare: 100 * cryptoVolume / (stableVolume + cryptoVolume),
112
97
  };
113
98
  }), {
114
99
  promise: true,
115
100
  maxAge: 5 * 60 * 1000, // 5m
116
101
  });
117
- //4
118
- export const _getTotalVolumes = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
119
- if (network === "aurora")
120
- return {
121
- totalVolume: 0,
122
- cryptoVolume: 0,
123
- cryptoShare: 0,
124
- }; // Exclude Aurora
125
- const url = `https://api.curve.fi/api/getSubgraphData/${network}`;
126
- const response = yield axios.get(url, { validateStatus: () => true });
127
- return response.data.data;
128
- }), {
129
- promise: true,
130
- maxAge: 5 * 60 * 1000, // 5m
131
- });
132
- export const _getAllGauges = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
133
- const url = `https://api.curve.fi/api/getAllGauges`;
134
- const response = yield axios.get(url, { validateStatus: () => true });
135
- return response.data.data;
136
- }), {
102
+ export const _getAllGauges = memoize(() => fetchData(`https://api.curve.fi/api/getAllGauges`), {
137
103
  promise: true,
138
104
  maxAge: 5 * 60 * 1000, // 5m
139
105
  });
140
106
  export const _getAllGaugesFormatted = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
141
- const url = `https://api.curve.fi/api/getAllGauges`;
142
- const response = yield axios.get(url, { validateStatus: () => true });
107
+ const data = yield fetchData(`https://api.curve.fi/api/getAllGauges`);
143
108
  const gaugesDict = {};
144
- Object.values(response.data.data).forEach((d) => {
109
+ Object.values(data).forEach((d) => {
145
110
  var _a, _b;
146
111
  gaugesDict[d.gauge.toLowerCase()] = {
147
112
  is_killed: (_a = d.is_killed) !== null && _a !== void 0 ? _a : false,
@@ -153,18 +118,14 @@ export const _getAllGaugesFormatted = memoize(() => __awaiter(void 0, void 0, vo
153
118
  promise: true,
154
119
  maxAge: 60 * 60 * 1000, // 60m
155
120
  });
156
- export const _getHiddenPools = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
157
- const url = `https://api.curve.fi/api/getHiddenPools`;
158
- const response = yield axios.get(url, { validateStatus: () => true });
159
- return response.data.data;
160
- }), {
121
+ export const _getHiddenPools = memoize(() => fetchData(`https://api.curve.fi/api/getHiddenPools`), {
161
122
  promise: true,
162
123
  maxAge: 5 * 60 * 1000, // 5m
163
124
  });
164
125
  export const _generateBoostingProof = memoize((block, address) => __awaiter(void 0, void 0, void 0, function* () {
165
126
  const url = `https://prices.curve.fi/v1/general/get_merkle_proof?block=${block}&account_address=${address}`;
166
- const response = yield axios.get(url, { validateStatus: () => true });
167
- return { block_header_rlp: response.data.block_header_rlp, proof_rlp: response.data.proof_rlp };
127
+ const { block_header_rlp, proof_rlp } = yield fetchJson(url);
128
+ return { block_header_rlp, proof_rlp };
168
129
  }), {
169
130
  promise: true,
170
131
  maxAge: 5 * 60 * 1000, // 5m
@@ -172,34 +133,31 @@ export const _generateBoostingProof = memoize((block, address) => __awaiter(void
172
133
  // --- DAO ---
173
134
  export const _getDaoProposalList = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
174
135
  const url = "https://api-py.llama.airforce/curve/v1/dao/proposals";
175
- const response = yield axios.get(url, { validateStatus: () => true });
176
- return response.data.proposals;
136
+ const { proposals } = yield fetchJson(url);
137
+ return proposals;
177
138
  }), {
178
139
  promise: true,
179
140
  maxAge: 5 * 60 * 1000, // 5m
180
141
  });
181
- export const _getDaoProposal = memoize((type, id) => __awaiter(void 0, void 0, void 0, function* () {
182
- const url = `https://api-py.llama.airforce/curve/v1/dao/proposals/${type.toLowerCase()}/${id}`;
183
- const response = yield axios.get(url, { validateStatus: () => true });
184
- return response.data;
185
- }), {
142
+ export const _getDaoProposal = memoize((type, id) => fetchJson(`https://api-py.llama.airforce/curve/v1/dao/proposals/${type.toLowerCase()}/${id}`), {
186
143
  promise: true,
187
144
  maxAge: 5 * 60 * 1000, // 5m
188
145
  });
189
146
  // --- CURVE LITE ---
190
147
  export const _getLiteNetworksData = memoize((networkName) => __awaiter(void 0, void 0, void 0, function* () {
191
- var _j, _k;
148
+ var _a, _b;
192
149
  try {
193
150
  const url = `https://api-core.curve.fi/v1/getDeployment/${networkName}`;
194
- const response = yield axios.get(url, { validateStatus: () => true });
195
- if (response.status !== 200 || !((_j = response.data) === null || _j === void 0 ? void 0 : _j.data)) {
196
- console.error('Failed to fetch network data:', response);
151
+ const response = yield fetch(url);
152
+ const { data } = (_a = yield response.json()) !== null && _a !== void 0 ? _a : {};
153
+ if (response.status !== 200 || !data) {
154
+ console.error('Failed to fetch network data:', response.status, data);
197
155
  return null;
198
156
  }
199
- const { config, contracts } = response.data.data;
157
+ const { config, contracts } = data;
200
158
  const network_name = config.network_name || 'Unknown Network';
201
159
  const native_currency_symbol = config.native_currency_symbol || 'N/A';
202
- const wrapped_native_token = ((_k = config.wrapped_native_token) === null || _k === void 0 ? void 0 : _k.toLowerCase()) || '';
160
+ const wrapped_native_token = ((_b = config.wrapped_native_token) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || '';
203
161
  return {
204
162
  NAME: network_name,
205
163
  ALIASES: {
@@ -236,14 +194,14 @@ export const _getLiteNetworksData = memoize((networkName) => __awaiter(void 0, v
236
194
  maxAge: 5 * 60 * 1000, // 5 minutes
237
195
  });
238
196
  export const _getCurveLiteNetworks = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
239
- var _l, _m;
240
- const url = `https://api-core.curve.fi/v1/getPlatforms`;
241
- const response = yield axios.get(url, { validateStatus: () => true });
242
- if (response.status !== 200 || !((_m = (_l = response.data) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.platforms)) {
197
+ var _a;
198
+ const response = yield fetch(`https://api-core.curve.fi/v1/getPlatforms`);
199
+ const { data } = (_a = yield response.json()) !== null && _a !== void 0 ? _a : {};
200
+ if (response.status !== 200 || !(data === null || data === void 0 ? void 0 : data.platforms)) {
243
201
  console.error('Failed to fetch Curve platforms:', response);
244
202
  return [];
245
203
  }
246
- const { platforms, platformsMetadata } = response.data.data;
204
+ const { platforms, platformsMetadata } = data;
247
205
  return Object.keys(platforms)
248
206
  .map((id) => {
249
207
  var _a;
@@ -263,3 +221,16 @@ export const _getCurveLiteNetworks = memoize(() => __awaiter(void 0, void 0, voi
263
221
  promise: true,
264
222
  maxAge: 5 * 60 * 1000, // 5 minutes
265
223
  });
224
+ function fetchJson(url) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ var _a;
227
+ const response = yield fetch(url);
228
+ return (_a = yield response.json()) !== null && _a !== void 0 ? _a : {};
229
+ });
230
+ }
231
+ function fetchData(url) {
232
+ return __awaiter(this, void 0, void 0, function* () {
233
+ const { data } = yield fetchJson(url);
234
+ return data;
235
+ });
236
+ }
@@ -12,8 +12,8 @@ import { curve } from "../curve.js";
12
12
  import { NETWORK_CONSTANTS } from "../constants/network_constants.js";
13
13
  import { getPool } from "../pools/index.js";
14
14
  import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress, DIGas, smartNumber } from '../utils.js';
15
- import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
16
- import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
15
+ import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" with { type: 'json' };
16
+ import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" with { type: 'json' };
17
17
  // ------- STABLE PLAIN POOLS -------
18
18
  const _deployStablePlainPool = (name, symbol, coins, A, fee, // %
19
19
  assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
@@ -65,22 +65,22 @@ oracleAddress, methodName, estimateGas) => __awaiter(void 0, void 0, void 0, fun
65
65
  yield curve.updateFeeData();
66
66
  return yield contract[methodToCall](...args, Object.assign(Object.assign({}, curve.options), { gasLimit }));
67
67
  });
68
- export const deployStablePlainPoolEstimateGas = (name, symbol, coins, A, fee, // %
68
+ export const deployStablePlainPoolEstimateGas = (name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1, ...args_1) => __awaiter(void 0, [name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1, ...args_1], void 0, function* (name, symbol, coins, A, fee, // %
69
69
  assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
70
70
  implementationIdx, emaTime = 600, // seconds
71
- oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") => __awaiter(void 0, void 0, void 0, function* () {
71
+ oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") {
72
72
  return yield _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, true);
73
73
  });
74
- export const deployStablePlainPool = (name, symbol, coins, A, fee, // %
74
+ export const deployStablePlainPool = (name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1, ...args_1) => __awaiter(void 0, [name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1, ...args_1], void 0, function* (name, symbol, coins, A, fee, // %
75
75
  assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
76
76
  implementationIdx, emaTime = 600, // seconds
77
- oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") => __awaiter(void 0, void 0, void 0, function* () {
77
+ oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") {
78
78
  return yield _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, false);
79
79
  });
80
- const _deployStableNgPlainPool = (name, symbol, coins, A, fee, // %
80
+ const _deployStableNgPlainPool = (name_1, symbol_1, coins_1, A_1, fee_1, offpegFeeMultiplier_1, assetTypes_1, implementationIdx_1, ...args_1) => __awaiter(void 0, [name_1, symbol_1, coins_1, A_1, fee_1, offpegFeeMultiplier_1, assetTypes_1, implementationIdx_1, ...args_1], void 0, function* (name, symbol, coins, A, fee, // %
81
81
  offpegFeeMultiplier, assetTypes, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
82
82
  implementationIdx, emaTime = 600, // seconds
83
- oracleAddresses, methodNames, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
83
+ oracleAddresses, methodNames, estimateGas) {
84
84
  if (name.length > 32)
85
85
  throw Error("Max name length = 32");
86
86
  if (symbol.length > 10)
@@ -171,10 +171,10 @@ export const _setOracle = (poolAddress, oracleAddress, methodName, estimateGas)
171
171
  yield curve.updateFeeData();
172
172
  return yield poolContract.set_oracle(methodId, oracleAddress, Object.assign(Object.assign({}, curve.options), { gasLimit }));
173
173
  });
174
- export const setOracleEstimateGas = (poolAddress, oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") => __awaiter(void 0, void 0, void 0, function* () {
174
+ export const setOracleEstimateGas = (poolAddress_1, ...args_1) => __awaiter(void 0, [poolAddress_1, ...args_1], void 0, function* (poolAddress, oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") {
175
175
  return yield _setOracle(poolAddress, oracleAddress, methodName, true);
176
176
  });
177
- export const setOracle = (poolAddress, oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") => __awaiter(void 0, void 0, void 0, function* () {
177
+ export const setOracle = (poolAddress_1, ...args_1) => __awaiter(void 0, [poolAddress_1, ...args_1], void 0, function* (poolAddress, oracleAddress = curve.constants.ZERO_ADDRESS, methodName = "0x00000000") {
178
178
  return yield _setOracle(poolAddress, oracleAddress, methodName, false);
179
179
  });
180
180
  // ------- STABLE META POOLS -------
@@ -208,10 +208,10 @@ export const deployStableMetaPool = (basePool, name, symbol, coin, A, fee, // %
208
208
  implementationIdx) => __awaiter(void 0, void 0, void 0, function* () {
209
209
  return yield _deployStableMetaPool(basePool, name, symbol, coin, A, fee, implementationIdx, false);
210
210
  });
211
- const _deployStableNgMetaPool = (basePool, name, symbol, coin, A, fee, // %
211
+ const _deployStableNgMetaPool = (basePool_1, name_1, symbol_1, coin_1, A_1, fee_1, offpegFeeMultiplier_1, assetType_1, ...args_1) => __awaiter(void 0, [basePool_1, name_1, symbol_1, coin_1, A_1, fee_1, offpegFeeMultiplier_1, assetType_1, ...args_1], void 0, function* (basePool, name, symbol, coin, A, fee, // %
212
212
  offpegFeeMultiplier, assetType, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
213
213
  emaTime = 600, // seconds
214
- implementationIdx = 0, methodName = "0x00000000", oracleAddress = curve.constants.ZERO_ADDRESS, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
214
+ implementationIdx = 0, methodName = "0x00000000", oracleAddress = curve.constants.ZERO_ADDRESS, estimateGas) {
215
215
  if (name.length > 32)
216
216
  throw Error("Max name length = 32");
217
217
  if (symbol.length > 10)
@@ -8,19 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { curve } from "../curve.js";
11
- import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
12
- import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
13
- import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
14
- import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" assert { type: 'json' };
15
- import twocryptoFactorySwapABI from "../constants/abis/factory-twocrypto/factory-twocrypto-pool.json" assert { type: 'json' };
16
- import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" assert { type: 'json' };
17
- import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" assert { type: 'json' };
11
+ import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type: 'json' };
12
+ import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: 'json' };
13
+ import ERC20ABI from "../constants/abis/ERC20.json" with { type: 'json' };
14
+ import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" with { type: 'json' };
15
+ import twocryptoFactorySwapABI from "../constants/abis/factory-twocrypto/factory-twocrypto-pool.json" with { type: 'json' };
16
+ import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" with { type: 'json' };
17
+ import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" with { type: 'json' };
18
18
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
19
19
  import { _getPoolsFromApi } from "../external-api.js";
20
20
  import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
21
- import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" assert { type: 'json' };
22
- import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" assert { type: 'json' };
23
- import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" assert { type: 'json' };
21
+ import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: 'json' };
22
+ import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" with { type: 'json' };
23
+ import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" with { type: 'json' };
24
24
  export const lowerCasePoolDataAddresses = (poolsData) => {
25
25
  var _a;
26
26
  for (const poolData of poolsData) {
@@ -85,8 +85,8 @@ function setFactoryCoinsContracts(rawPoolList) {
85
85
  }
86
86
  }
87
87
  export function getFactoryPoolsDataFromApi(factoryType) {
88
- var _a;
89
88
  return __awaiter(this, void 0, void 0, function* () {
89
+ var _a;
90
90
  const network = this.constants.NETWORK_NAME;
91
91
  const is_ng = ["factory-stable-ng", "factory-twocrypto", "factory-tricrypto"].includes(factoryType);
92
92
  const isCrypto = ["factory-crypto", "factory-twocrypto", "factory-tricrypto"].includes(factoryType);
@@ -239,7 +239,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
239
239
  token_address: pool.address,
240
240
  gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
241
241
  deposit_address,
242
- implementation_address: pool.implementationAddress,
242
+ implementation_address: pool.implementationAddress, // Only for testing
243
243
  is_meta: true,
244
244
  is_factory: true,
245
245
  base_pool: basePoolId,
@@ -265,7 +265,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
265
265
  swap_address: pool.address,
266
266
  token_address: pool.address,
267
267
  gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
268
- implementation_address: pool.implementationAddress,
268
+ implementation_address: pool.implementationAddress, // Only for testing
269
269
  is_plain: true,
270
270
  is_factory: true,
271
271
  underlying_coins: coinNames,
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { curve } from "../curve.js";
11
- import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
12
- import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" assert { type: 'json' };
13
- import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
14
- import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
11
+ import ERC20ABI from "../constants/abis/ERC20.json" with { type: 'json' };
12
+ import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" with { type: 'json' };
13
+ import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type: 'json' };
14
+ import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: 'json' };
15
15
  import { setFactoryZapContracts } from "./common.js";
16
16
  const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
17
17
  function getRecentlyCreatedCryptoPoolId(swapAddress) {
@@ -26,8 +26,8 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
26
26
  throw Error("Unknown pool");
27
27
  });
28
28
  }
29
- function getCryptoFactoryIdsAndSwapAddresses(fromIdx = 0) {
30
- return __awaiter(this, void 0, void 0, function* () {
29
+ function getCryptoFactoryIdsAndSwapAddresses() {
30
+ return __awaiter(this, arguments, void 0, function* (fromIdx = 0) {
31
31
  const factoryContract = this.contracts[this.constants.ALIASES.crypto_factory].contract;
32
32
  const factoryMulticallContract = this.contracts[this.constants.ALIASES.crypto_factory].multicallContract;
33
33
  const poolCount = Number(curve.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
@@ -195,9 +195,9 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
195
195
  return [tokenSymbols, tokenNames, coinAddrNamesDict, coinAddrDecimalsDict];
196
196
  });
197
197
  }
198
- export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
199
- var _a, _b;
200
- return __awaiter(this, void 0, void 0, function* () {
198
+ export function getCryptoFactoryPoolData() {
199
+ return __awaiter(this, arguments, void 0, function* (fromIdx = 0, swapAddress) {
200
+ var _a, _b;
201
201
  const [poolIds, swapAddresses] = swapAddress ?
202
202
  [[yield getRecentlyCreatedCryptoPoolId.call(this, swapAddress)], [swapAddress.toLowerCase()]]
203
203
  : yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
@@ -262,7 +262,7 @@ export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
262
262
  token_address: tokenAddresses[i],
263
263
  gauge_address: gaugeAddresses[i],
264
264
  is_crypto: true,
265
- is_plain: underlyingCoinAddresses[i].toString() === coinAddresses[i].toString(),
265
+ is_plain: underlyingCoinAddresses[i].toString() === coinAddresses[i].toString(), // WETH/ETH - NOT Plain
266
266
  is_factory: true,
267
267
  underlying_coins: [...underlyingCoinAddresses[i].map((addr) => coinAddressNameDict[addr])],
268
268
  wrapped_coins: [...coinAddresses[i].map((addr) => coinAddressNameDict[addr])],
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { curve } from "../curve.js";
11
- import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
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' };
14
- import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
15
- import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
11
+ import ERC20ABI from "../constants/abis/ERC20.json" with { type: 'json' };
12
+ import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" with { type: 'json' };
13
+ import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" with { type: 'json' };
14
+ import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type: 'json' };
15
+ import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: 'json' };
16
16
  const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
17
17
  function getRecentlyCreatedCryptoPoolId(swapAddress) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -26,8 +26,8 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
26
26
  throw Error("Unknown pool");
27
27
  });
28
28
  }
29
- function getCryptoFactoryIdsAndSwapAddresses(fromIdx = 0) {
30
- return __awaiter(this, void 0, void 0, function* () {
29
+ function getCryptoFactoryIdsAndSwapAddresses() {
30
+ return __awaiter(this, arguments, void 0, function* (fromIdx = 0) {
31
31
  const factoryContract = this.contracts[this.constants.ALIASES.tricrypto_factory].contract;
32
32
  const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
33
33
  const poolCount = Number(curve.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
@@ -166,9 +166,9 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
166
166
  return [tokenSymbols, tokenNames, coinAddrNamesDict, coinAddrDecimalsDict];
167
167
  });
168
168
  }
169
- export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
170
- var _a;
171
- return __awaiter(this, void 0, void 0, function* () {
169
+ export function getTricryptoFactoryPoolData() {
170
+ return __awaiter(this, arguments, void 0, function* (fromIdx = 0, swapAddress) {
171
+ var _a;
172
172
  const [poolIds, swapAddresses] = swapAddress ?
173
173
  [[yield getRecentlyCreatedCryptoPoolId.call(this, swapAddress)], [swapAddress.toLowerCase()]]
174
174
  : yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
@@ -205,7 +205,7 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
205
205
  token_address: swapAddresses[i],
206
206
  gauge_address: gaugeAddresses[i],
207
207
  is_crypto: true,
208
- is_plain: underlyingCoinAddresses.toString() === coinAddresses[i].toString(),
208
+ is_plain: underlyingCoinAddresses.toString() === coinAddresses[i].toString(), // WETH/ETH - NOT Plain
209
209
  is_factory: true,
210
210
  underlying_coins: [...underlyingCoinAddresses.map((addr) => coinAddressNameDict[addr])],
211
211
  wrapped_coins: [...coinAddresses[i].map((addr) => coinAddressNameDict[addr])],