@curvefi/api 2.61.6 → 2.61.8
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.
- package/lib/pools/PoolTemplate.d.ts +2 -20
- package/lib/pools/PoolTemplate.js +93 -317
- package/lib/pools/gaugePool.d.ts +41 -0
- package/lib/pools/gaugePool.js +281 -0
- package/lib/pools/utils.js +21 -21
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IDict } from '../interfaces';
|
|
2
|
+
export interface IGaugePool {
|
|
3
|
+
address: string;
|
|
4
|
+
poolName: string;
|
|
5
|
+
gaugeManager(): Promise<string>;
|
|
6
|
+
gaugeDistributors(): Promise<IDict<string>>;
|
|
7
|
+
gaugeVersion(): Promise<string | null>;
|
|
8
|
+
addReward(rewardToken: string, distributor: string): Promise<string>;
|
|
9
|
+
isDepositRewardAvailable(): Promise<boolean>;
|
|
10
|
+
depositRewardIsApproved(rewardToken: string, amount: number | string): Promise<boolean>;
|
|
11
|
+
depositReward(rewardToken: string, amount: string | number, epoch: number): Promise<string>;
|
|
12
|
+
depositRewardApprove(rewardToken: string, amount: number | string): Promise<string[]>;
|
|
13
|
+
estimateGas: {
|
|
14
|
+
addReward(rewardToken: string, distributor: string): Promise<number | number[]>;
|
|
15
|
+
depositReward(rewardToken: string, amount: string | number, epoch: number): Promise<number | number[]>;
|
|
16
|
+
depositRewardApprove(rewardToken: string, amount: number | string): Promise<number | number[]>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class GaugePool implements IGaugePool {
|
|
20
|
+
address: string;
|
|
21
|
+
poolName: string;
|
|
22
|
+
estimateGas: {
|
|
23
|
+
addReward: (rewardToken: string, distributor: string) => Promise<number | number[]>;
|
|
24
|
+
depositRewardApprove: (rewardToken: string, amount: number | string) => Promise<number | number[]>;
|
|
25
|
+
depositReward: (rewardToken: string, amount: string | number, epoch: number) => Promise<number | number[]>;
|
|
26
|
+
};
|
|
27
|
+
constructor(address: string, poolName: string);
|
|
28
|
+
gaugeManager(): Promise<string>;
|
|
29
|
+
gaugeDistributors(): Promise<IDict<string>>;
|
|
30
|
+
gaugeVersion(): Promise<string | null>;
|
|
31
|
+
private _addReward;
|
|
32
|
+
private addRewardEstimateGas;
|
|
33
|
+
addReward(rewardToken: string, distributor: string): Promise<string>;
|
|
34
|
+
isDepositRewardAvailable(): Promise<boolean>;
|
|
35
|
+
depositRewardIsApproved(rewardToken: string, amount: number | string): Promise<boolean>;
|
|
36
|
+
private depositRewardApproveEstimateGas;
|
|
37
|
+
depositRewardApprove(rewardToken: string, amount: number | string): Promise<string[]>;
|
|
38
|
+
private _depositReward;
|
|
39
|
+
depositRewardEstimateGas(rewardToken: string, amount: string | number, epoch: number): Promise<number | number[]>;
|
|
40
|
+
depositReward(rewardToken: string, amount: string | number, epoch: number): Promise<string>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
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
|
+
import { curve } from "../curve.js";
|
|
49
|
+
import { DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, smartNumber } from "../utils.js";
|
|
50
|
+
var GaugePool = /** @class */ (function () {
|
|
51
|
+
function GaugePool(address, poolName) {
|
|
52
|
+
this.address = address;
|
|
53
|
+
this.poolName = poolName;
|
|
54
|
+
this.estimateGas = {
|
|
55
|
+
addReward: this.addRewardEstimateGas,
|
|
56
|
+
depositRewardApprove: this.depositRewardApproveEstimateGas,
|
|
57
|
+
depositReward: this.depositRewardEstimateGas,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
GaugePool.prototype.gaugeManager = function () {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var e_1;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (!(!this.address || this.address === curve.constants.ZERO_ADDRESS)) return [3 /*break*/, 1];
|
|
67
|
+
return [2 /*return*/, curve.constants.ZERO_ADDRESS];
|
|
68
|
+
case 1:
|
|
69
|
+
_a.trys.push([1, 3, , 4]);
|
|
70
|
+
return [4 /*yield*/, curve.contracts[this.address].contract.manager()];
|
|
71
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
72
|
+
case 3:
|
|
73
|
+
e_1 = _a.sent();
|
|
74
|
+
return [2 /*return*/, curve.constants.ZERO_ADDRESS];
|
|
75
|
+
case 4: return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
GaugePool.prototype.gaugeDistributors = function () {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var gaugeContract, gaugeMulticallContract, rewardCount, _a, _b, _c, calls, i, rewardTokens, i, rewardData, gaugeDistributors, i;
|
|
83
|
+
return __generator(this, function (_d) {
|
|
84
|
+
switch (_d.label) {
|
|
85
|
+
case 0: return [4 /*yield*/, curve.contracts[this.address].contract];
|
|
86
|
+
case 1:
|
|
87
|
+
gaugeContract = _d.sent();
|
|
88
|
+
return [4 /*yield*/, curve.contracts[this.address].multicallContract];
|
|
89
|
+
case 2:
|
|
90
|
+
gaugeMulticallContract = _d.sent();
|
|
91
|
+
_a = Number;
|
|
92
|
+
_c = (_b = curve).formatUnits;
|
|
93
|
+
return [4 /*yield*/, gaugeContract.reward_count(curve.constantOptions)];
|
|
94
|
+
case 3:
|
|
95
|
+
rewardCount = _a.apply(void 0, [_c.apply(_b, [_d.sent(), 0])]);
|
|
96
|
+
calls = [];
|
|
97
|
+
for (i = 0; i < rewardCount; i++) {
|
|
98
|
+
calls.push(gaugeMulticallContract.reward_tokens(i));
|
|
99
|
+
}
|
|
100
|
+
return [4 /*yield*/, curve.multicallProvider.all(calls)];
|
|
101
|
+
case 4:
|
|
102
|
+
rewardTokens = _d.sent();
|
|
103
|
+
calls = [];
|
|
104
|
+
for (i = 0; i < rewardCount; i++) {
|
|
105
|
+
calls.push(gaugeMulticallContract.reward_data(rewardTokens[i]));
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, curve.multicallProvider.all(calls)];
|
|
108
|
+
case 5:
|
|
109
|
+
rewardData = _d.sent();
|
|
110
|
+
gaugeDistributors = {};
|
|
111
|
+
for (i = 0; i < rewardCount; i++) {
|
|
112
|
+
gaugeDistributors[rewardTokens[i]] = rewardData[i].distributor;
|
|
113
|
+
}
|
|
114
|
+
return [2 /*return*/, gaugeDistributors];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
GaugePool.prototype.gaugeVersion = function () {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
var e_2;
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (!(!this.address || this.address === curve.constants.ZERO_ADDRESS)) return [3 /*break*/, 1];
|
|
126
|
+
return [2 /*return*/, null];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.trys.push([1, 3, , 4]);
|
|
129
|
+
return [4 /*yield*/, curve.contracts[this.address].contract.version()];
|
|
130
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
131
|
+
case 3:
|
|
132
|
+
e_2 = _a.sent();
|
|
133
|
+
return [2 /*return*/, null];
|
|
134
|
+
case 4: return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
GaugePool.prototype._addReward = function (_reward_token, _distributor, estimateGas) {
|
|
140
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
var gas, gasLimit;
|
|
143
|
+
return __generator(this, function (_a) {
|
|
144
|
+
switch (_a.label) {
|
|
145
|
+
case 0:
|
|
146
|
+
if (!(this.address !== curve.constants.ZERO_ADDRESS && this.address)) return [3 /*break*/, 3];
|
|
147
|
+
return [4 /*yield*/, curve.contracts[this.address].contract.add_reward.estimateGas(_reward_token, _distributor, __assign({}, curve.constantOptions))];
|
|
148
|
+
case 1:
|
|
149
|
+
gas = _a.sent();
|
|
150
|
+
if (estimateGas)
|
|
151
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
152
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
153
|
+
return [4 /*yield*/, curve.contracts[this.address].contract.add_reward(_reward_token, _distributor, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
154
|
+
case 2: return [2 /*return*/, (_a.sent()).hash];
|
|
155
|
+
case 3: throw Error("Pool ".concat(this.poolName, " does not have gauge"));
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
GaugePool.prototype.addRewardEstimateGas = function (rewardToken, distributor) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
switch (_a.label) {
|
|
164
|
+
case 0: return [4 /*yield*/, this._addReward(rewardToken, distributor, true)];
|
|
165
|
+
case 1:
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
return [2 /*return*/, _a.sent()];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
GaugePool.prototype.addReward = function (rewardToken, distributor) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0: return [4 /*yield*/, this._addReward(rewardToken, distributor)];
|
|
177
|
+
case 1:
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
return [2 /*return*/, _a.sent()];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
GaugePool.prototype.isDepositRewardAvailable = function () {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
+
var versionsWithDepositReward, version;
|
|
187
|
+
return __generator(this, function (_a) {
|
|
188
|
+
switch (_a.label) {
|
|
189
|
+
case 0:
|
|
190
|
+
versionsWithDepositReward = ['v6.1.0'];
|
|
191
|
+
return [4 /*yield*/, this.gaugeVersion()];
|
|
192
|
+
case 1:
|
|
193
|
+
version = _a.sent();
|
|
194
|
+
return [2 /*return*/, version ? versionsWithDepositReward.includes(version) : Boolean(version)];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
GaugePool.prototype.depositRewardIsApproved = function (rewardToken, amount) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
switch (_a.label) {
|
|
203
|
+
case 0: return [4 /*yield*/, hasAllowance([rewardToken], [amount], curve.signerAddress, this.address)];
|
|
204
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
GaugePool.prototype.depositRewardApproveEstimateGas = function (rewardToken, amount) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
return __generator(this, function (_a) {
|
|
212
|
+
switch (_a.label) {
|
|
213
|
+
case 0: return [4 /*yield*/, ensureAllowanceEstimateGas([rewardToken], [amount], this.address)];
|
|
214
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
GaugePool.prototype.depositRewardApprove = function (rewardToken, amount) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0: return [4 /*yield*/, ensureAllowance([rewardToken], [amount], this.address)];
|
|
224
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
GaugePool.prototype._depositReward = function (rewardToken, amount, epoch, estimateGas) {
|
|
230
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var contract, gas, gasLimit;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0:
|
|
236
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
237
|
+
return [4 /*yield*/, ensureAllowance([rewardToken], [amount], this.address)];
|
|
238
|
+
case 1:
|
|
239
|
+
_a.sent();
|
|
240
|
+
_a.label = 2;
|
|
241
|
+
case 2:
|
|
242
|
+
contract = curve.contracts[this.address].contract;
|
|
243
|
+
return [4 /*yield*/, contract.deposit_reward_token.estimateGas(rewardToken, amount, __assign({}, curve.constantOptions))];
|
|
244
|
+
case 3:
|
|
245
|
+
gas = _a.sent();
|
|
246
|
+
if (estimateGas)
|
|
247
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
248
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
249
|
+
return [4 /*yield*/, contract.deposit_reward_token(rewardToken, amount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
250
|
+
case 4: return [2 /*return*/, (_a.sent()).hash];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
GaugePool.prototype.depositRewardEstimateGas = function (rewardToken, amount, epoch) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
return __generator(this, function (_a) {
|
|
258
|
+
switch (_a.label) {
|
|
259
|
+
case 0: return [4 /*yield*/, this._depositReward(rewardToken, amount, epoch, true)];
|
|
260
|
+
case 1:
|
|
261
|
+
// @ts-ignore
|
|
262
|
+
return [2 /*return*/, _a.sent()];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
GaugePool.prototype.depositReward = function (rewardToken, amount, epoch) {
|
|
268
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
+
return __generator(this, function (_a) {
|
|
270
|
+
switch (_a.label) {
|
|
271
|
+
case 0: return [4 /*yield*/, this._depositReward(rewardToken, amount, epoch)];
|
|
272
|
+
case 1:
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
return [2 /*return*/, _a.sent()];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
return GaugePool;
|
|
280
|
+
}());
|
|
281
|
+
export { GaugePool };
|
package/lib/pools/utils.js
CHANGED
|
@@ -66,8 +66,8 @@ var _getUserLpBalances = function (pools, address, useCache) { return __awaiter(
|
|
|
66
66
|
poolId = poolsToFetch_1[_i];
|
|
67
67
|
pool = getPool(poolId);
|
|
68
68
|
calls.push(curve.contracts[pool.lpToken].multicallContract.balanceOf(address));
|
|
69
|
-
if (pool.gauge !== curve.constants.ZERO_ADDRESS)
|
|
70
|
-
calls.push(curve.contracts[pool.gauge].multicallContract.balanceOf(address));
|
|
69
|
+
if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
|
|
70
|
+
calls.push(curve.contracts[pool.gauge.address].multicallContract.balanceOf(address));
|
|
71
71
|
}
|
|
72
72
|
return [4 /*yield*/, curve.multicallProvider.all(calls)];
|
|
73
73
|
case 1:
|
|
@@ -76,7 +76,7 @@ var _getUserLpBalances = function (pools, address, useCache) { return __awaiter(
|
|
|
76
76
|
poolId = poolsToFetch_2[_a];
|
|
77
77
|
pool = getPool(poolId);
|
|
78
78
|
_balance = _rawBalances.shift();
|
|
79
|
-
if (pool.gauge !== curve.constants.ZERO_ADDRESS)
|
|
79
|
+
if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
|
|
80
80
|
_balance = _balance + _rawBalances.shift();
|
|
81
81
|
if (!_userLpBalanceCache[address])
|
|
82
82
|
_userLpBalanceCache[address] = {};
|
|
@@ -158,22 +158,22 @@ var _getUserClaimable = function (pools, address, useCache) { return __awaiter(v
|
|
|
158
158
|
for (_i = 0, poolsToFetch_3 = poolsToFetch; _i < poolsToFetch_3.length; _i++) {
|
|
159
159
|
poolId = poolsToFetch_3[_i];
|
|
160
160
|
pool = getPool(poolId);
|
|
161
|
-
if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
|
|
161
|
+
if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
|
|
162
162
|
hasCrvReward.push(false);
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
165
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
166
166
|
hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
|
|
167
167
|
}
|
|
168
168
|
rewardCount = [];
|
|
169
169
|
for (_a = 0, poolsToFetch_4 = poolsToFetch; _a < poolsToFetch_4.length; _a++) {
|
|
170
170
|
poolId = poolsToFetch_4[_a];
|
|
171
171
|
pool = getPool(poolId);
|
|
172
|
-
if (pool.gauge === curve.constants.ZERO_ADDRESS) {
|
|
172
|
+
if (pool.gauge.address === curve.constants.ZERO_ADDRESS) {
|
|
173
173
|
rewardCount.push(0);
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
176
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
177
177
|
if ("reward_tokens(uint256)" in gaugeContract) { // gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
|
|
178
178
|
rewardCount.push(8);
|
|
179
179
|
}
|
|
@@ -189,7 +189,7 @@ var _getUserClaimable = function (pools, address, useCache) { return __awaiter(v
|
|
|
189
189
|
pool = getPool(poolsToFetch[i]);
|
|
190
190
|
if (rewardCount[i] !== -1) { // no_gauge, gauge, gauge_v2, gauge_v3, gauge_v4, gauge_v5, gauge_factory, gauge_rewards_only, gauge_child
|
|
191
191
|
for (count = 0; count < rewardCount[i]; count++) {
|
|
192
|
-
gaugeContract = curve.contracts[pool.gauge].multicallContract;
|
|
192
|
+
gaugeContract = curve.contracts[pool.gauge.address].multicallContract;
|
|
193
193
|
rewardTokenCalls.push(gaugeContract.reward_tokens(count));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -224,10 +224,10 @@ var _getUserClaimable = function (pools, address, useCache) { return __awaiter(v
|
|
|
224
224
|
for (i = 0; i < poolsToFetch.length; i++) {
|
|
225
225
|
poolId = poolsToFetch[i];
|
|
226
226
|
pool = getPool(poolId);
|
|
227
|
-
if (pool.gauge === curve.constants.ZERO_ADDRESS)
|
|
227
|
+
if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
|
|
228
228
|
continue;
|
|
229
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
230
|
-
gaugeMulticallContract = curve.contracts[pool.gauge].multicallContract;
|
|
229
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
230
|
+
gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
|
|
231
231
|
if (hasCrvReward[i]) {
|
|
232
232
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
|
|
233
233
|
}
|
|
@@ -253,9 +253,9 @@ var _getUserClaimable = function (pools, address, useCache) { return __awaiter(v
|
|
|
253
253
|
if (!_userClaimableCache[address])
|
|
254
254
|
_userClaimableCache[address] = {};
|
|
255
255
|
_userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
|
|
256
|
-
if (pool.gauge === curve.constants.ZERO_ADDRESS)
|
|
256
|
+
if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
|
|
257
257
|
continue;
|
|
258
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
258
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
259
259
|
if (hasCrvReward[i]) {
|
|
260
260
|
token = curve.constants.ALIASES.crv;
|
|
261
261
|
symbol = 'CRV';
|
|
@@ -302,11 +302,11 @@ var _getUserClaimableUseApi = function (pools, address, useCache) { return __awa
|
|
|
302
302
|
for (_i = 0, poolsToFetch_5 = poolsToFetch; _i < poolsToFetch_5.length; _i++) {
|
|
303
303
|
poolId = poolsToFetch_5[_i];
|
|
304
304
|
pool = getPool(poolId);
|
|
305
|
-
if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
|
|
305
|
+
if (curve.chainId === 324 || curve.chainId === 2222 || pool.gauge.address === curve.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
|
|
306
306
|
hasCrvReward.push(false);
|
|
307
307
|
continue;
|
|
308
308
|
}
|
|
309
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
309
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
310
310
|
hasCrvReward.push('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
|
|
311
311
|
}
|
|
312
312
|
rewardTokens = {};
|
|
@@ -318,7 +318,7 @@ var _getUserClaimableUseApi = function (pools, address, useCache) { return __awa
|
|
|
318
318
|
return [4 /*yield*/, _getRewardsFromApi()];
|
|
319
319
|
case 2:
|
|
320
320
|
rewards = _h.sent();
|
|
321
|
-
rewardTokens[poolsToFetch[i]] = ((_f = rewards[pool.gauge]) !== null && _f !== void 0 ? _f : [])
|
|
321
|
+
rewardTokens[poolsToFetch[i]] = ((_f = rewards[pool.gauge.address]) !== null && _f !== void 0 ? _f : [])
|
|
322
322
|
.map(function (r) { return ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }); });
|
|
323
323
|
_h.label = 3;
|
|
324
324
|
case 3:
|
|
@@ -329,10 +329,10 @@ var _getUserClaimableUseApi = function (pools, address, useCache) { return __awa
|
|
|
329
329
|
for (i = 0; i < poolsToFetch.length; i++) {
|
|
330
330
|
poolId = poolsToFetch[i];
|
|
331
331
|
pool = getPool(poolId);
|
|
332
|
-
if (pool.gauge === curve.constants.ZERO_ADDRESS)
|
|
332
|
+
if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
|
|
333
333
|
continue;
|
|
334
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
335
|
-
gaugeMulticallContract = curve.contracts[pool.gauge].multicallContract;
|
|
334
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
335
|
+
gaugeMulticallContract = curve.contracts[pool.gauge.address].multicallContract;
|
|
336
336
|
if (hasCrvReward[i]) {
|
|
337
337
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
|
|
338
338
|
}
|
|
@@ -356,9 +356,9 @@ var _getUserClaimableUseApi = function (pools, address, useCache) { return __awa
|
|
|
356
356
|
if (!_userClaimableCache[address])
|
|
357
357
|
_userClaimableCache[address] = {};
|
|
358
358
|
_userClaimableCache[address][poolId] = { rewards: [], time: Date.now() };
|
|
359
|
-
if (pool.gauge === curve.constants.ZERO_ADDRESS)
|
|
359
|
+
if (pool.gauge.address === curve.constants.ZERO_ADDRESS)
|
|
360
360
|
continue;
|
|
361
|
-
gaugeContract = curve.contracts[pool.gauge].contract;
|
|
361
|
+
gaugeContract = curve.contracts[pool.gauge.address].contract;
|
|
362
362
|
if (hasCrvReward[i]) {
|
|
363
363
|
token = curve.constants.ALIASES.crv;
|
|
364
364
|
symbol = 'CRV';
|