@curvefi/api 2.32.0 → 2.33.0

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