@curvefi/api 2.63.0 → 2.63.2

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 (83) hide show
  1. package/lib/boosting.js +247 -645
  2. package/lib/constants/L2Networks.js +1 -1
  3. package/lib/constants/aliases.js +19 -19
  4. package/lib/constants/coins/arbitrum.js +5 -5
  5. package/lib/constants/coins/aurora.js +5 -5
  6. package/lib/constants/coins/avalanche.js +6 -6
  7. package/lib/constants/coins/base.js +5 -5
  8. package/lib/constants/coins/bsc.js +5 -5
  9. package/lib/constants/coins/celo.js +5 -5
  10. package/lib/constants/coins/ethereum.js +9 -9
  11. package/lib/constants/coins/fantom.js +7 -7
  12. package/lib/constants/coins/fraxtal.js +5 -5
  13. package/lib/constants/coins/kava.js +5 -5
  14. package/lib/constants/coins/mantle.js +5 -5
  15. package/lib/constants/coins/moonbeam.js +5 -5
  16. package/lib/constants/coins/optimism.js +5 -5
  17. package/lib/constants/coins/polygon.js +6 -6
  18. package/lib/constants/coins/xdai.js +5 -5
  19. package/lib/constants/coins/xlayer.js +5 -5
  20. package/lib/constants/coins/zksync.js +5 -5
  21. package/lib/constants/pools/arbitrum.js +1 -1
  22. package/lib/constants/pools/aurora.js +1 -1
  23. package/lib/constants/pools/avalanche.js +1 -1
  24. package/lib/constants/pools/base.js +1 -1
  25. package/lib/constants/pools/bsc.js +1 -1
  26. package/lib/constants/pools/celo.js +1 -1
  27. package/lib/constants/pools/ethereum.js +2 -2
  28. package/lib/constants/pools/fantom.js +1 -1
  29. package/lib/constants/pools/fraxtal.js +1 -1
  30. package/lib/constants/pools/kava.js +1 -1
  31. package/lib/constants/pools/mantle.js +1 -1
  32. package/lib/constants/pools/moonbeam.js +1 -1
  33. package/lib/constants/pools/optimism.js +1 -1
  34. package/lib/constants/pools/polygon.js +1 -1
  35. package/lib/constants/pools/xdai.js +1 -1
  36. package/lib/constants/pools/xlayer.js +1 -1
  37. package/lib/constants/pools/zksync.js +1 -1
  38. package/lib/constants/tricryptoDeployImplementations.js +1 -1
  39. package/lib/constants/utils.js +18 -19
  40. package/lib/constants/volumeNetworks.js +1 -1
  41. package/lib/curve.d.ts +10 -6
  42. package/lib/curve.js +534 -909
  43. package/lib/dao.js +351 -705
  44. package/lib/external-api.js +127 -256
  45. package/lib/factory/common.js +4 -4
  46. package/lib/factory/constants-crypto.js +33 -33
  47. package/lib/factory/constants.js +34 -34
  48. package/lib/factory/deploy.js +542 -907
  49. package/lib/factory/factory-api.js +205 -269
  50. package/lib/factory/factory-crypto.js +202 -342
  51. package/lib/factory/factory-tricrypto.js +164 -286
  52. package/lib/factory/factory-twocrypto.js +151 -269
  53. package/lib/factory/factory.js +245 -385
  54. package/lib/index.js +109 -198
  55. package/lib/interfaces.d.ts +46 -6
  56. package/lib/pools/PoolTemplate.js +1774 -3027
  57. package/lib/pools/gaugePool.js +112 -251
  58. package/lib/pools/mixins/common.js +22 -93
  59. package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
  60. package/lib/pools/mixins/depositMixins.js +160 -386
  61. package/lib/pools/mixins/depositWrappedMixins.js +79 -205
  62. package/lib/pools/mixins/poolBalancesMixin.js +24 -87
  63. package/lib/pools/mixins/swapMixins.js +139 -324
  64. package/lib/pools/mixins/swapWrappedMixins.js +111 -265
  65. package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
  66. package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
  67. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
  68. package/lib/pools/mixins/withdrawMixins.js +139 -359
  69. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
  70. package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
  73. package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
  74. package/lib/pools/poolConstructor.js +11 -31
  75. package/lib/pools/utils.js +301 -469
  76. package/lib/route-finder.worker.d.ts +9 -0
  77. package/lib/route-finder.worker.js +112 -0
  78. package/lib/route-graph.worker.d.ts +11 -0
  79. package/lib/route-graph.worker.js +334 -0
  80. package/lib/router.js +323 -912
  81. package/lib/utils.d.ts +8 -7
  82. package/lib/utils.js +540 -927
  83. package/package.json +3 -2
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,481 +7,324 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
8
  });
20
9
  };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
10
  import { getPool } from "./poolConstructor.js";
49
11
  import { curve } from "../curve.js";
50
12
  import { _getRewardsFromApi, _getUsdRate, _setContracts, toBN } from "../utils.js";
51
13
  import { _getAllPoolsFromApi } from "../external-api.js";
52
14
  import ERC20Abi from "../constants/abis/ERC20.json" assert { type: 'json' };
53
15
  // _userLpBalance: { address: { poolId: { _lpBalance: 0, time: 0 } } }
54
- var _userLpBalanceCache = {};
55
- var _isUserLpBalanceCacheExpired = function (address, poolId) { var _a, _b; return (((_b = (_a = _userLpBalanceCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
56
- var _getUserLpBalances = function (pools, address, useCache) { return __awaiter(void 0, void 0, void 0, function () {
57
- var poolsToFetch, calls, _i, poolsToFetch_1, poolId, pool, _rawBalances, _a, poolsToFetch_2, poolId, pool, _balance, _lpBalances, _b, pools_1, poolId;
58
- var _c;
59
- return __generator(this, function (_d) {
60
- switch (_d.label) {
61
- case 0:
62
- poolsToFetch = useCache ? pools.filter(function (poolId) { return _isUserLpBalanceCacheExpired(address, poolId); }) : pools;
63
- if (!(poolsToFetch.length > 0)) return [3 /*break*/, 2];
64
- calls = [];
65
- for (_i = 0, poolsToFetch_1 = poolsToFetch; _i < poolsToFetch_1.length; _i++) {
66
- poolId = poolsToFetch_1[_i];
67
- pool = getPool(poolId);
68
- calls.push(curve.contracts[pool.lpToken].multicallContract.balanceOf(address));
69
- if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
70
- calls.push(curve.contracts[pool.gauge.address].multicallContract.balanceOf(address));
71
- }
72
- return [4 /*yield*/, curve.multicallProvider.all(calls)];
73
- case 1:
74
- _rawBalances = _d.sent();
75
- for (_a = 0, poolsToFetch_2 = poolsToFetch; _a < poolsToFetch_2.length; _a++) {
76
- poolId = poolsToFetch_2[_a];
77
- pool = getPool(poolId);
78
- _balance = _rawBalances.shift();
79
- if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
80
- _balance = _balance + _rawBalances.shift();
81
- if (!_userLpBalanceCache[address])
82
- _userLpBalanceCache[address] = {};
83
- _userLpBalanceCache[address][poolId] = { '_lpBalance': _balance, 'time': Date.now() };
84
- }
85
- _d.label = 2;
86
- case 2:
87
- _lpBalances = [];
88
- for (_b = 0, pools_1 = pools; _b < pools_1.length; _b++) {
89
- poolId = pools_1[_b];
90
- _lpBalances.push((_c = _userLpBalanceCache[address]) === null || _c === void 0 ? void 0 : _c[poolId]._lpBalance);
91
- }
92
- return [2 /*return*/, _lpBalances];
16
+ const _userLpBalanceCache = {};
17
+ const _isUserLpBalanceCacheExpired = (address, poolId) => { var _a, _b; return (((_b = (_a = _userLpBalanceCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
18
+ const _getUserLpBalances = (pools, address, useCache) => __awaiter(void 0, void 0, void 0, function* () {
19
+ var _a;
20
+ const poolsToFetch = useCache ? pools.filter((poolId) => _isUserLpBalanceCacheExpired(address, poolId)) : pools;
21
+ if (poolsToFetch.length > 0) {
22
+ const calls = [];
23
+ for (const poolId of poolsToFetch) {
24
+ const pool = getPool(poolId);
25
+ calls.push(curve.contracts[pool.lpToken].multicallContract.balanceOf(address));
26
+ if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
27
+ calls.push(curve.contracts[pool.gauge.address].multicallContract.balanceOf(address));
93
28
  }
94
- });
95
- }); };
96
- export var getUserPoolListByLiquidity = function (address) {
97
- if (address === void 0) { address = curve.signerAddress; }
98
- return __awaiter(void 0, void 0, void 0, function () {
99
- var pools, _lpBalances, userPoolList, i;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0:
103
- pools = curve.getPoolList();
104
- return [4 /*yield*/, _getUserLpBalances(pools, address, false)];
105
- case 1:
106
- _lpBalances = _a.sent();
107
- userPoolList = [];
108
- for (i = 0; i < pools.length; i++) {
109
- if (_lpBalances[i] > 0) {
110
- userPoolList.push(pools[i]);
111
- }
112
- }
113
- return [2 /*return*/, userPoolList];
29
+ const _rawBalances = yield curve.multicallProvider.all(calls);
30
+ for (const poolId of poolsToFetch) {
31
+ const pool = getPool(poolId);
32
+ let _balance = _rawBalances.shift();
33
+ if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
34
+ _balance = _balance + _rawBalances.shift();
35
+ if (!_userLpBalanceCache[address])
36
+ _userLpBalanceCache[address] = {};
37
+ _userLpBalanceCache[address][poolId] = { '_lpBalance': _balance, 'time': Date.now() };
38
+ }
39
+ }
40
+ const _lpBalances = [];
41
+ for (const poolId of pools) {
42
+ _lpBalances.push((_a = _userLpBalanceCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]._lpBalance);
43
+ }
44
+ return _lpBalances;
45
+ });
46
+ export const getUserPoolListByLiquidity = (address = curve.signerAddress) => __awaiter(void 0, void 0, void 0, function* () {
47
+ const pools = curve.getPoolList();
48
+ const _lpBalances = yield _getUserLpBalances(pools, address, false);
49
+ const userPoolList = [];
50
+ for (let i = 0; i < pools.length; i++) {
51
+ if (_lpBalances[i] > 0) {
52
+ userPoolList.push(pools[i]);
53
+ }
54
+ }
55
+ return userPoolList;
56
+ });
57
+ export const getUserLiquidityUSD = (pools, address = curve.signerAddress) => __awaiter(void 0, void 0, void 0, function* () {
58
+ const _lpBalances = yield _getUserLpBalances(pools, address, true);
59
+ const userLiquidityUSD = [];
60
+ for (let i = 0; i < pools.length; i++) {
61
+ const pool = getPool(pools[i]);
62
+ const price = yield _getUsdRate(pool.lpToken);
63
+ userLiquidityUSD.push(toBN(_lpBalances[i]).times(price).toFixed(8));
64
+ }
65
+ return userLiquidityUSD;
66
+ });
67
+ // _userClaimable: { address: { poolId: { rewards: [ { token: '0x111...', 'symbol': 'TST', '', 'amount': 0 } ], time: 0 } }
68
+ const _userClaimableCache = {};
69
+ const _isUserClaimableCacheExpired = (address, poolId) => { var _a, _b; return (((_b = (_a = _userClaimableCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
70
+ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0, void 0, function* () {
71
+ var _b;
72
+ const poolsToFetch = useCache ? pools.filter((poolId) => _isUserClaimableCacheExpired(address, poolId)) : pools;
73
+ if (poolsToFetch.length > 0) {
74
+ // --- 1. CRV ---
75
+ const hasCrvReward = [];
76
+ for (const poolId of poolsToFetch) {
77
+ const pool = getPool(poolId);
78
+ if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
79
+ hasCrvReward.push(false);
80
+ continue;
114
81
  }
115
- });
116
- });
117
- };
118
- export var getUserLiquidityUSD = function (pools, address) {
119
- if (address === void 0) { address = curve.signerAddress; }
120
- return __awaiter(void 0, void 0, void 0, function () {
121
- var _lpBalances, userLiquidityUSD, i, pool, price;
122
- return __generator(this, function (_a) {
123
- switch (_a.label) {
124
- case 0: return [4 /*yield*/, _getUserLpBalances(pools, address, true)];
125
- case 1:
126
- _lpBalances = _a.sent();
127
- userLiquidityUSD = [];
128
- i = 0;
129
- _a.label = 2;
130
- case 2:
131
- if (!(i < pools.length)) return [3 /*break*/, 5];
132
- pool = getPool(pools[i]);
133
- return [4 /*yield*/, _getUsdRate(pool.lpToken)];
134
- case 3:
135
- price = _a.sent();
136
- userLiquidityUSD.push(toBN(_lpBalances[i]).times(price).toFixed(8));
137
- _a.label = 4;
138
- case 4:
139
- i++;
140
- return [3 /*break*/, 2];
141
- case 5: return [2 /*return*/, userLiquidityUSD];
82
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
83
+ hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
84
+ }
85
+ // --- 2. The number of reward tokens ---
86
+ const rewardCount = [];
87
+ for (const poolId of poolsToFetch) {
88
+ const pool = getPool(poolId);
89
+ if (pool.gauge.address === curve.constants.ZERO_ADDRESS) {
90
+ rewardCount.push(0);
91
+ continue;
92
+ }
93
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
94
+ if ("reward_tokens(uint256)" in gaugeContract) { // gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
95
+ rewardCount.push(8);
96
+ }
97
+ else if ('claimable_reward(address)' in gaugeContract) { // gauge_synthetix
98
+ rewardCount.push(-1);
99
+ }
100
+ else { // gauge
101
+ rewardCount.push(0);
142
102
  }
143
- });
144
- });
145
- };
146
- // _userClaimable: { address: { poolId: { rewards: [ { token: '0x111...', 'symbol': 'TST', '', 'amount': 0 } ], time: 0 } }
147
- var _userClaimableCache = {};
148
- var _isUserClaimableCacheExpired = function (address, poolId) { var _a, _b; return (((_b = (_a = _userClaimableCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
149
- var _getUserClaimable = function (pools, address, useCache) { return __awaiter(void 0, void 0, void 0, function () {
150
- var poolsToFetch, hasCrvReward, _i, poolsToFetch_3, poolId, pool, gaugeContract, rewardCount, _a, poolsToFetch_4, poolId, pool, gaugeContract, rewardTokenCalls, i, pool, count, gaugeContract, rewardContract, rewardMulticallContract, method, rawRewardTokens, rewardTokens, i, j, rewardAddress, rewardInfoCalls, i, poolId, pool, gaugeContract, gaugeMulticallContract, _b, _c, token, tokenMulticallContract, rawRewardInfo, i, poolId, pool, gaugeContract, token, symbol, decimals, _amount, amount, _d, _e, token, symbol, decimals, _amount, _claimedAmount, amount, _claimable, _f, pools_2, poolId;
151
- var _g;
152
- return __generator(this, function (_h) {
153
- switch (_h.label) {
154
- case 0:
155
- poolsToFetch = useCache ? pools.filter(function (poolId) { return _isUserClaimableCacheExpired(address, poolId); }) : pools;
156
- if (!(poolsToFetch.length > 0)) return [3 /*break*/, 3];
157
- hasCrvReward = [];
158
- for (_i = 0, poolsToFetch_3 = poolsToFetch; _i < poolsToFetch_3.length; _i++) {
159
- poolId = poolsToFetch_3[_i];
160
- pool = getPool(poolId);
161
- if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
162
- hasCrvReward.push(false);
163
- continue;
164
- }
165
- gaugeContract = curve.contracts[pool.gauge.address].contract;
166
- hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
167
- }
168
- rewardCount = [];
169
- for (_a = 0, poolsToFetch_4 = poolsToFetch; _a < poolsToFetch_4.length; _a++) {
170
- poolId = poolsToFetch_4[_a];
171
- pool = getPool(poolId);
172
- if (pool.gauge.address === curve.constants.ZERO_ADDRESS) {
173
- rewardCount.push(0);
174
- continue;
175
- }
176
- gaugeContract = curve.contracts[pool.gauge.address].contract;
177
- if ("reward_tokens(uint256)" in gaugeContract) { // gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
178
- rewardCount.push(8);
179
- }
180
- else if ('claimable_reward(address)' in gaugeContract) { // gauge_synthetix
181
- rewardCount.push(-1);
182
- }
183
- else { // gauge
184
- rewardCount.push(0);
185
- }
186
- }
187
- rewardTokenCalls = [];
188
- for (i = 0; i < poolsToFetch.length; i++) {
189
- pool = getPool(poolsToFetch[i]);
190
- if (rewardCount[i] !== -1) { // no_gauge, gauge, gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
191
- for (count = 0; count < rewardCount[i]; count++) {
192
- gaugeContract = curve.contracts[pool.gauge.address].multicallContract;
193
- rewardTokenCalls.push(gaugeContract.reward_tokens(count));
194
- }
195
- }
196
- else { // gauge_synthetix
197
- rewardCount[i] = 1;
198
- rewardContract = curve.contracts[pool.sRewardContract].contract;
199
- rewardMulticallContract = curve.contracts[pool.sRewardContract].multicallContract;
200
- method = "snx()" in rewardContract ? "snx" : "rewardsToken" // susd, tbtc : dusd, musd, rsv, sbtc
201
- ;
202
- rewardTokenCalls.push(rewardMulticallContract[method]());
203
- }
204
- }
205
- return [4 /*yield*/, curve.multicallProvider.all(rewardTokenCalls)];
206
- case 1:
207
- rawRewardTokens = (_h.sent()).map(function (t) { return t.toLowerCase(); });
208
- rewardTokens = {};
209
- for (i = 0; i < poolsToFetch.length; i++) {
210
- rewardTokens[poolsToFetch[i]] = [];
211
- for (j = 0; j < rewardCount[i]; j++) {
212
- rewardAddress = rawRewardTokens.shift();
213
- if (rewardAddress === curve.constants.ZERO_ADDRESS)
214
- continue;
215
- if (curve.chainId !== 1 && rewardAddress === curve.constants.COINS.crv)
216
- continue;
217
- // REYIELD shitcoin which breaks things, because symbol() throws an error
218
- if (rewardAddress === "0xf228ec3476318aCB4E719D2b290bb2ef8B34DFfA".toLowerCase())
219
- continue;
220
- rewardTokens[poolsToFetch[i]].push(rewardAddress);
221
- }
222
- }
223
- rewardInfoCalls = [];
224
- for (i = 0; i < poolsToFetch.length; i++) {
225
- poolId = poolsToFetch[i];
226
- pool = getPool(poolId);
227
- if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
228
- continue;
229
- gaugeContract = curve.contracts[pool.gauge.address].contract;
230
- gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
231
- if (hasCrvReward[i]) {
232
- rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
233
- }
234
- for (_b = 0, _c = rewardTokens[poolId]; _b < _c.length; _b++) {
235
- token = _c[_b];
236
- _setContracts(token, ERC20Abi);
237
- tokenMulticallContract = curve.contracts[token].multicallContract;
238
- rewardInfoCalls.push(tokenMulticallContract.symbol(), tokenMulticallContract.decimals());
239
- if ('claimable_reward(address,address)' in gaugeContract) {
240
- rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, token));
241
- }
242
- else if ('claimable_reward(address)' in gaugeContract) { // Synthetix Gauge
243
- rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address), gaugeMulticallContract.claimed_rewards_for(address));
244
- }
245
- }
246
- }
247
- return [4 /*yield*/, curve.multicallProvider.all(rewardInfoCalls)];
248
- case 2:
249
- rawRewardInfo = _h.sent();
250
- for (i = 0; i < poolsToFetch.length; i++) {
251
- poolId = poolsToFetch[i];
252
- pool = getPool(poolId);
253
- if (!_userClaimableCache[address])
254
- _userClaimableCache[address] = {};
255
- _userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
256
- if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
257
- continue;
258
- gaugeContract = curve.contracts[pool.gauge.address].contract;
259
- if (hasCrvReward[i]) {
260
- token = curve.constants.ALIASES.crv;
261
- symbol = 'CRV';
262
- decimals = 18;
263
- _amount = rawRewardInfo.shift();
264
- amount = curve.formatUnits(_amount, decimals);
265
- if (Number(amount) > 0)
266
- _userClaimableCache[address][poolId].rewards.push({ token: token, symbol: symbol, amount: amount });
267
- }
268
- for (_d = 0, _e = rewardTokens[poolId]; _d < _e.length; _d++) {
269
- token = _e[_d];
270
- symbol = rawRewardInfo.shift();
271
- decimals = rawRewardInfo.shift();
272
- _amount = rawRewardInfo.shift();
273
- if ('claimable_reward(address)' in gaugeContract) {
274
- _claimedAmount = rawRewardInfo.shift();
275
- _amount = _amount - _claimedAmount;
276
- }
277
- amount = curve.formatUnits(_amount, decimals);
278
- if (Number(amount) > 0)
279
- _userClaimableCache[address][poolId].rewards.push({ token: token, symbol: symbol, amount: amount });
280
- }
281
- }
282
- _h.label = 3;
283
- case 3:
284
- _claimable = [];
285
- for (_f = 0, pools_2 = pools; _f < pools_2.length; _f++) {
286
- poolId = pools_2[_f];
287
- _claimable.push((_g = _userClaimableCache[address]) === null || _g === void 0 ? void 0 : _g[poolId].rewards);
288
- }
289
- return [2 /*return*/, _claimable];
290
103
  }
291
- });
292
- }); };
293
- var _getUserClaimableUseApi = function (pools, address, useCache) { return __awaiter(void 0, void 0, void 0, function () {
294
- var poolsToFetch, hasCrvReward, _i, poolsToFetch_5, poolId, pool, gaugeContract, rewardTokens, i, pool, rewards, rewardInfoCalls, i, poolId, pool, gaugeContract, gaugeMulticallContract, _a, _b, r, rawRewardInfo, i, poolId, pool, gaugeContract, token, symbol, decimals, _amount, amount, _c, _d, r, _amount, _claimedAmount, amount, _claimable, _e, pools_3, poolId;
295
- var _f, _g;
296
- return __generator(this, function (_h) {
297
- switch (_h.label) {
298
- case 0:
299
- poolsToFetch = useCache ? pools.filter(function (poolId) { return _isUserClaimableCacheExpired(address, poolId); }) : pools;
300
- if (!(poolsToFetch.length > 0)) return [3 /*break*/, 6];
301
- hasCrvReward = [];
302
- for (_i = 0, poolsToFetch_5 = poolsToFetch; _i < poolsToFetch_5.length; _i++) {
303
- poolId = poolsToFetch_5[_i];
304
- pool = getPool(poolId);
305
- if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
306
- hasCrvReward.push(false);
307
- continue;
308
- }
309
- gaugeContract = curve.contracts[pool.gauge.address].contract;
310
- hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
104
+ // --- 3. Reward tokens ---
105
+ const rewardTokenCalls = [];
106
+ for (let i = 0; i < poolsToFetch.length; i++) {
107
+ const pool = getPool(poolsToFetch[i]);
108
+ if (rewardCount[i] !== -1) { // no_gauge, gauge, gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
109
+ for (let count = 0; count < rewardCount[i]; count++) {
110
+ const gaugeContract = curve.contracts[pool.gauge.address].multicallContract;
111
+ rewardTokenCalls.push(gaugeContract.reward_tokens(count));
311
112
  }
312
- rewardTokens = {};
313
- i = 0;
314
- _h.label = 1;
315
- case 1:
316
- if (!(i < poolsToFetch.length)) return [3 /*break*/, 4];
317
- pool = getPool(poolsToFetch[i]);
318
- return [4 /*yield*/, _getRewardsFromApi()];
319
- case 2:
320
- rewards = _h.sent();
321
- rewardTokens[poolsToFetch[i]] = ((_f = rewards[pool.gauge.address]) !== null && _f !== void 0 ? _f : [])
322
- .map(function (r) { return ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }); });
323
- _h.label = 3;
324
- case 3:
325
- i++;
326
- return [3 /*break*/, 1];
327
- case 4:
328
- rewardInfoCalls = [];
329
- for (i = 0; i < poolsToFetch.length; i++) {
330
- poolId = poolsToFetch[i];
331
- pool = getPool(poolId);
332
- if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
333
- continue;
334
- gaugeContract = curve.contracts[pool.gauge.address].contract;
335
- gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
336
- if (hasCrvReward[i]) {
337
- rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
338
- }
339
- for (_a = 0, _b = rewardTokens[poolId]; _a < _b.length; _a++) {
340
- r = _b[_a];
341
- _setContracts(r.token, ERC20Abi);
342
- if ('claimable_reward(address,address)' in gaugeContract) {
343
- rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, r.token));
344
- }
345
- else if ('claimable_reward(address)' in gaugeContract) { // Synthetix Gauge
346
- rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address), gaugeMulticallContract.claimed_rewards_for(address));
347
- }
348
- }
113
+ }
114
+ else { // gauge_synthetix
115
+ rewardCount[i] = 1;
116
+ const rewardContract = curve.contracts[pool.sRewardContract].contract;
117
+ const rewardMulticallContract = curve.contracts[pool.sRewardContract].multicallContract;
118
+ const method = "snx()" in rewardContract ? "snx" : "rewardsToken"; // susd, tbtc : dusd, musd, rsv, sbtc
119
+ rewardTokenCalls.push(rewardMulticallContract[method]());
120
+ }
121
+ }
122
+ const rawRewardTokens = (yield curve.multicallProvider.all(rewardTokenCalls)).map((t) => t.toLowerCase());
123
+ const rewardTokens = {};
124
+ for (let i = 0; i < poolsToFetch.length; i++) {
125
+ rewardTokens[poolsToFetch[i]] = [];
126
+ for (let j = 0; j < rewardCount[i]; j++) {
127
+ const rewardAddress = rawRewardTokens.shift();
128
+ if (rewardAddress === curve.constants.ZERO_ADDRESS)
129
+ continue;
130
+ if (curve.chainId !== 1 && rewardAddress === curve.constants.COINS.crv)
131
+ continue;
132
+ // REYIELD shitcoin which breaks things, because symbol() throws an error
133
+ if (rewardAddress === "0xf228ec3476318aCB4E719D2b290bb2ef8B34DFfA".toLowerCase())
134
+ continue;
135
+ rewardTokens[poolsToFetch[i]].push(rewardAddress);
136
+ }
137
+ }
138
+ // --- 4. Reward info ---
139
+ const rewardInfoCalls = [];
140
+ for (let i = 0; i < poolsToFetch.length; i++) {
141
+ const poolId = poolsToFetch[i];
142
+ const pool = getPool(poolId);
143
+ if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
144
+ continue;
145
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
146
+ const gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
147
+ if (hasCrvReward[i]) {
148
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
149
+ }
150
+ for (const token of rewardTokens[poolId]) {
151
+ _setContracts(token, ERC20Abi);
152
+ const tokenMulticallContract = curve.contracts[token].multicallContract;
153
+ rewardInfoCalls.push(tokenMulticallContract.symbol(), tokenMulticallContract.decimals());
154
+ if ('claimable_reward(address,address)' in gaugeContract) {
155
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, token));
349
156
  }
350
- return [4 /*yield*/, curve.multicallProvider.all(rewardInfoCalls)];
351
- case 5:
352
- rawRewardInfo = _h.sent();
353
- for (i = 0; i < poolsToFetch.length; i++) {
354
- poolId = poolsToFetch[i];
355
- pool = getPool(poolId);
356
- if (!_userClaimableCache[address])
357
- _userClaimableCache[address] = {};
358
- _userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
359
- if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
360
- continue;
361
- gaugeContract = curve.contracts[pool.gauge.address].contract;
362
- if (hasCrvReward[i]) {
363
- token = curve.constants.ALIASES.crv;
364
- symbol = 'CRV';
365
- decimals = 18;
366
- _amount = rawRewardInfo.shift();
367
- amount = curve.formatUnits(_amount, decimals);
368
- if (Number(amount) > 0)
369
- _userClaimableCache[address][poolId].rewards.push({ token: token, symbol: symbol, amount: amount });
370
- }
371
- for (_c = 0, _d = rewardTokens[poolId]; _c < _d.length; _c++) {
372
- r = _d[_c];
373
- _amount = rawRewardInfo.shift();
374
- if ('claimable_reward(address)' in gaugeContract) {
375
- _claimedAmount = rawRewardInfo.shift();
376
- _amount = _amount - _claimedAmount;
377
- }
378
- amount = curve.formatUnits(_amount, r.decimals);
379
- if (Number(amount) > 0)
380
- _userClaimableCache[address][poolId].rewards.push({ token: r.token, symbol: r.symbol, amount: amount });
381
- }
157
+ else if ('claimable_reward(address)' in gaugeContract) { // Synthetix Gauge
158
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address), gaugeMulticallContract.claimed_rewards_for(address));
382
159
  }
383
- _h.label = 6;
384
- case 6:
385
- _claimable = [];
386
- for (_e = 0, pools_3 = pools; _e < pools_3.length; _e++) {
387
- poolId = pools_3[_e];
388
- _claimable.push((_g = _userClaimableCache[address]) === null || _g === void 0 ? void 0 : _g[poolId].rewards);
160
+ }
161
+ }
162
+ const rawRewardInfo = yield curve.multicallProvider.all(rewardInfoCalls);
163
+ for (let i = 0; i < poolsToFetch.length; i++) {
164
+ const poolId = poolsToFetch[i];
165
+ const pool = getPool(poolId);
166
+ if (!_userClaimableCache[address])
167
+ _userClaimableCache[address] = {};
168
+ _userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
169
+ if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
170
+ continue;
171
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
172
+ if (hasCrvReward[i]) {
173
+ const token = curve.constants.ALIASES.crv;
174
+ const symbol = 'CRV';
175
+ const decimals = 18;
176
+ const _amount = rawRewardInfo.shift();
177
+ const amount = curve.formatUnits(_amount, decimals);
178
+ if (Number(amount) > 0)
179
+ _userClaimableCache[address][poolId].rewards.push({ token, symbol, amount });
180
+ }
181
+ for (const token of rewardTokens[poolId]) {
182
+ const symbol = rawRewardInfo.shift();
183
+ const decimals = rawRewardInfo.shift();
184
+ let _amount = rawRewardInfo.shift();
185
+ if ('claimable_reward(address)' in gaugeContract) {
186
+ const _claimedAmount = rawRewardInfo.shift();
187
+ _amount = _amount - _claimedAmount;
389
188
  }
390
- return [2 /*return*/, _claimable];
189
+ const amount = curve.formatUnits(_amount, decimals);
190
+ if (Number(amount) > 0)
191
+ _userClaimableCache[address][poolId].rewards.push({ token, symbol, amount });
192
+ }
391
193
  }
392
- });
393
- }); };
394
- export var getUserPoolListByClaimable = function (address) {
395
- if (address === void 0) { address = curve.signerAddress; }
396
- return __awaiter(void 0, void 0, void 0, function () {
397
- var pools, _claimable, userPoolList, i;
398
- return __generator(this, function (_a) {
399
- switch (_a.label) {
400
- case 0:
401
- pools = curve.getPoolList();
402
- return [4 /*yield*/, _getUserClaimable(pools, address, false)];
403
- case 1:
404
- _claimable = _a.sent();
405
- userPoolList = [];
406
- for (i = 0; i < pools.length; i++) {
407
- if (_claimable[i].length > 0) {
408
- userPoolList.push(pools[i]);
409
- }
410
- }
411
- return [2 /*return*/, userPoolList];
194
+ }
195
+ const _claimable = [];
196
+ for (const poolId of pools) {
197
+ _claimable.push((_b = _userClaimableCache[address]) === null || _b === void 0 ? void 0 : _b[poolId].rewards);
198
+ }
199
+ return _claimable;
200
+ });
201
+ const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0, void 0, void 0, function* () {
202
+ var _c, _d;
203
+ const poolsToFetch = useCache ? pools.filter((poolId) => _isUserClaimableCacheExpired(address, poolId)) : pools;
204
+ if (poolsToFetch.length > 0) {
205
+ // --- 1. CRV ---
206
+ const hasCrvReward = [];
207
+ for (const poolId of poolsToFetch) {
208
+ const pool = getPool(poolId);
209
+ if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
210
+ hasCrvReward.push(false);
211
+ continue;
412
212
  }
413
- });
414
- });
415
- };
416
- export var getUserClaimable = function (pools, address) {
417
- if (address === void 0) { address = curve.signerAddress; }
418
- return __awaiter(void 0, void 0, void 0, function () {
419
- var _claimable, claimableWithPrice, i, _i, _a, c, price;
420
- return __generator(this, function (_b) {
421
- switch (_b.label) {
422
- case 0: return [4 /*yield*/, _getUserClaimable(pools, address, true)];
423
- case 1:
424
- _claimable = _b.sent();
425
- claimableWithPrice = [];
426
- i = 0;
427
- _b.label = 2;
428
- case 2:
429
- if (!(i < pools.length)) return [3 /*break*/, 7];
430
- claimableWithPrice.push([]);
431
- _i = 0, _a = _claimable[i];
432
- _b.label = 3;
433
- case 3:
434
- if (!(_i < _a.length)) return [3 /*break*/, 6];
435
- c = _a[_i];
436
- return [4 /*yield*/, _getUsdRate(c.token)];
437
- case 4:
438
- price = _b.sent();
439
- claimableWithPrice[claimableWithPrice.length - 1].push(__assign(__assign({}, c), { price: price }));
440
- _b.label = 5;
441
- case 5:
442
- _i++;
443
- return [3 /*break*/, 3];
444
- case 6:
445
- i++;
446
- return [3 /*break*/, 2];
447
- case 7: return [2 /*return*/, claimableWithPrice];
213
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
214
+ hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
215
+ }
216
+ // --- 2. Reward tokens ---
217
+ const rewardTokens = {};
218
+ for (let i = 0; i < poolsToFetch.length; i++) {
219
+ const pool = getPool(poolsToFetch[i]);
220
+ const rewards = yield _getRewardsFromApi();
221
+ rewardTokens[poolsToFetch[i]] = ((_c = rewards[pool.gauge.address]) !== null && _c !== void 0 ? _c : [])
222
+ .map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }));
223
+ }
224
+ // --- 3. Reward info ---
225
+ const rewardInfoCalls = [];
226
+ for (let i = 0; i < poolsToFetch.length; i++) {
227
+ const poolId = poolsToFetch[i];
228
+ const pool = getPool(poolId);
229
+ if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
230
+ continue;
231
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
232
+ const gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
233
+ if (hasCrvReward[i]) {
234
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
448
235
  }
449
- });
450
- });
451
- };
452
- export var getUserPoolList = function (address, useApi) {
453
- if (address === void 0) { address = curve.signerAddress; }
454
- if (useApi === void 0) { useApi = true; }
455
- return __awaiter(void 0, void 0, void 0, function () {
456
- var pools, _a, _lpBalances, _claimable, userPoolList, i;
457
- return __generator(this, function (_b) {
458
- switch (_b.label) {
459
- case 0:
460
- pools = curve.getPoolList();
461
- return [4 /*yield*/, Promise.all([
462
- _getUserLpBalances(pools, address, false),
463
- useApi ? _getUserClaimableUseApi(pools, address, false) : _getUserClaimable(pools, address, false),
464
- ])];
465
- case 1:
466
- _a = _b.sent(), _lpBalances = _a[0], _claimable = _a[1];
467
- userPoolList = [];
468
- for (i = 0; i < pools.length; i++) {
469
- if (_lpBalances[i] > 0 || _claimable[i].length > 0) {
470
- userPoolList.push(pools[i]);
471
- }
472
- }
473
- return [2 /*return*/, userPoolList];
236
+ for (const r of rewardTokens[poolId]) {
237
+ _setContracts(r.token, ERC20Abi);
238
+ if ('claimable_reward(address,address)' in gaugeContract) {
239
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, r.token));
240
+ }
241
+ else if ('claimable_reward(address)' in gaugeContract) { // Synthetix Gauge
242
+ rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address), gaugeMulticallContract.claimed_rewards_for(address));
243
+ }
474
244
  }
475
- });
476
- });
477
- };
478
- export var _getAmplificationCoefficientsFromApi = function () { return __awaiter(void 0, void 0, void 0, function () {
479
- var network, allTypesExtendedPoolData, amplificationCoefficientDict, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool;
480
- return __generator(this, function (_c) {
481
- switch (_c.label) {
482
- case 0:
483
- network = curve.constants.NETWORK_NAME;
484
- return [4 /*yield*/, _getAllPoolsFromApi(network)];
485
- case 1:
486
- allTypesExtendedPoolData = _c.sent();
487
- amplificationCoefficientDict = {};
488
- for (_i = 0, allTypesExtendedPoolData_1 = allTypesExtendedPoolData; _i < allTypesExtendedPoolData_1.length; _i++) {
489
- extendedPoolData = allTypesExtendedPoolData_1[_i];
490
- for (_a = 0, _b = extendedPoolData.poolData; _a < _b.length; _a++) {
491
- pool = _b[_a];
492
- amplificationCoefficientDict[pool.address.toLowerCase()] = Number(pool.amplificationCoefficient);
493
- }
245
+ }
246
+ const rawRewardInfo = yield curve.multicallProvider.all(rewardInfoCalls);
247
+ for (let i = 0; i < poolsToFetch.length; i++) {
248
+ const poolId = poolsToFetch[i];
249
+ const pool = getPool(poolId);
250
+ if (!_userClaimableCache[address])
251
+ _userClaimableCache[address] = {};
252
+ _userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
253
+ if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
254
+ continue;
255
+ const gaugeContract = curve.contracts[pool.gauge.address].contract;
256
+ if (hasCrvReward[i]) {
257
+ const token = curve.constants.ALIASES.crv;
258
+ const symbol = 'CRV';
259
+ const decimals = 18;
260
+ const _amount = rawRewardInfo.shift();
261
+ const amount = curve.formatUnits(_amount, decimals);
262
+ if (Number(amount) > 0)
263
+ _userClaimableCache[address][poolId].rewards.push({ token, symbol, amount });
264
+ }
265
+ for (const r of rewardTokens[poolId]) {
266
+ let _amount = rawRewardInfo.shift();
267
+ if ('claimable_reward(address)' in gaugeContract) {
268
+ const _claimedAmount = rawRewardInfo.shift();
269
+ _amount = _amount - _claimedAmount;
494
270
  }
495
- return [2 /*return*/, amplificationCoefficientDict];
271
+ const amount = curve.formatUnits(_amount, r.decimals);
272
+ if (Number(amount) > 0)
273
+ _userClaimableCache[address][poolId].rewards.push({ token: r.token, symbol: r.symbol, amount });
274
+ }
496
275
  }
497
- });
498
- }); };
276
+ }
277
+ const _claimable = [];
278
+ for (const poolId of pools) {
279
+ _claimable.push((_d = _userClaimableCache[address]) === null || _d === void 0 ? void 0 : _d[poolId].rewards);
280
+ }
281
+ return _claimable;
282
+ });
283
+ export const getUserPoolListByClaimable = (address = curve.signerAddress) => __awaiter(void 0, void 0, void 0, function* () {
284
+ const pools = curve.getPoolList();
285
+ const _claimable = yield _getUserClaimable(pools, address, false);
286
+ const userPoolList = [];
287
+ for (let i = 0; i < pools.length; i++) {
288
+ if (_claimable[i].length > 0) {
289
+ userPoolList.push(pools[i]);
290
+ }
291
+ }
292
+ return userPoolList;
293
+ });
294
+ export const getUserClaimable = (pools, address = curve.signerAddress) => __awaiter(void 0, void 0, void 0, function* () {
295
+ const _claimable = yield _getUserClaimable(pools, address, true);
296
+ const claimableWithPrice = [];
297
+ for (let i = 0; i < pools.length; i++) {
298
+ claimableWithPrice.push([]);
299
+ for (const c of _claimable[i]) {
300
+ const price = yield _getUsdRate(c.token);
301
+ claimableWithPrice[claimableWithPrice.length - 1].push(Object.assign(Object.assign({}, c), { price }));
302
+ }
303
+ }
304
+ return claimableWithPrice;
305
+ });
306
+ export const getUserPoolList = (address = curve.signerAddress, useApi = true) => __awaiter(void 0, void 0, void 0, function* () {
307
+ const pools = curve.getPoolList();
308
+ const [_lpBalances, _claimable] = yield Promise.all([
309
+ _getUserLpBalances(pools, address, false),
310
+ useApi ? _getUserClaimableUseApi(pools, address, false) : _getUserClaimable(pools, address, false),
311
+ ]);
312
+ const userPoolList = [];
313
+ for (let i = 0; i < pools.length; i++) {
314
+ if (_lpBalances[i] > 0 || _claimable[i].length > 0) {
315
+ userPoolList.push(pools[i]);
316
+ }
317
+ }
318
+ return userPoolList;
319
+ });
320
+ export const _getAmplificationCoefficientsFromApi = () => __awaiter(void 0, void 0, void 0, function* () {
321
+ const network = curve.constants.NETWORK_NAME;
322
+ const allTypesExtendedPoolData = yield _getAllPoolsFromApi(network);
323
+ const amplificationCoefficientDict = {};
324
+ for (const extendedPoolData of allTypesExtendedPoolData) {
325
+ for (const pool of extendedPoolData.poolData) {
326
+ amplificationCoefficientDict[pool.address.toLowerCase()] = Number(pool.amplificationCoefficient);
327
+ }
328
+ }
329
+ return amplificationCoefficientDict;
330
+ });