@curvefi/api 2.5.0 → 2.7.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.
- package/lib/constants/abis/3pool-optimism/swap.json +1074 -0
- package/lib/constants/abis/eursusd2/swap.json +1199 -0
- package/lib/constants/abis/eursusd2/zap.json +270 -0
- package/lib/constants/abis/ren-arbitrum/swap.json +1069 -0
- package/lib/constants/aliases.d.ts +2 -0
- package/lib/constants/aliases.js +25 -1
- package/lib/constants/coins/arbitrum.d.ts +7 -0
- package/lib/constants/coins/arbitrum.js +23 -0
- package/lib/constants/coins/optimism.d.ts +7 -0
- package/lib/constants/coins/optimism.js +21 -0
- package/lib/constants/pools/arbitrum.d.ts +4 -0
- package/lib/constants/pools/arbitrum.js +125 -0
- package/lib/constants/pools/index.d.ts +3 -1
- package/lib/constants/pools/index.js +5 -1
- package/lib/constants/pools/optimism.d.ts +4 -0
- package/lib/constants/pools/optimism.js +37 -0
- package/lib/constants/pools/polygon.js +30 -0
- package/lib/curve.js +22 -0
- package/lib/factory/common.js +19 -0
- package/lib/factory/constants.d.ts +6 -0
- package/lib/factory/constants.js +75 -4
- package/lib/factory/factory-crypto.js +4 -0
- package/lib/factory/factory.js +6 -0
- package/lib/pools/PoolTemplate.d.ts +1 -1
- package/lib/pools/PoolTemplate.js +1 -1
- package/lib/pools/poolConstructor.js +3 -2
- package/lib/pools/utils.js +22 -14
- package/lib/utils.js +7 -1
- package/package.json +1 -1
|
@@ -262,7 +262,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
262
262
|
case 0:
|
|
263
263
|
if (this.gauge === ethers_1.ethers.constants.AddressZero)
|
|
264
264
|
return [2 /*return*/, []];
|
|
265
|
-
if (![137, 250, 43114].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
|
|
265
|
+
if (![10, 137, 250, 43114, 42161].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
|
|
266
266
|
apy = [];
|
|
267
267
|
return [4 /*yield*/, this.rewardTokens()];
|
|
268
268
|
case 1:
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.getPool = void 0;
|
|
19
|
+
var curve_1 = require("../curve");
|
|
19
20
|
var PoolTemplate_1 = require("./PoolTemplate");
|
|
20
21
|
var poolBalancesMixin_1 = require("./mixins/poolBalancesMixin");
|
|
21
22
|
var depositBalancedAmountsMixins_1 = require("./mixins/depositBalancedAmountsMixins");
|
|
@@ -226,7 +227,7 @@ var getPool = function (poolId) {
|
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
// swap and swapEstimateGas
|
|
229
|
-
if (
|
|
230
|
+
if ('exchange(uint256,uint256,uint256,uint256,bool)' in curve_1.curve.contracts[poolDummy.address].contract) { // tricrypto2 (eth), tricrypto (arbitrum)
|
|
230
231
|
Object.assign(Pool.prototype, swapMixins_1.swapTricrypto2Mixin);
|
|
231
232
|
}
|
|
232
233
|
else if (poolDummy.isMetaFactory && (0, exports.getPool)(poolDummy.basePool).isLending) {
|
|
@@ -238,7 +239,7 @@ var getPool = function (poolId) {
|
|
|
238
239
|
// swapWrapped and swapWrappedEstimateGas
|
|
239
240
|
if (!poolDummy.isPlain && !poolDummy.isFake) {
|
|
240
241
|
Object.assign(Pool.prototype, swapWrappedMixins_1.swapWrappedExpectedAndApproveMixin);
|
|
241
|
-
if (
|
|
242
|
+
if ('exchange(uint256,uint256,uint256,uint256,bool)' in curve_1.curve.contracts[poolDummy.address].contract) { // tricrypto2 (eth), tricrypto (arbitrum)
|
|
242
243
|
Object.assign(Pool.prototype, swapWrappedMixins_1.swapWrappedTricrypto2Mixin);
|
|
243
244
|
}
|
|
244
245
|
else {
|
package/lib/pools/utils.js
CHANGED
|
@@ -46,6 +46,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.getUserPoolList = exports.getCryptoFactoryPoolList = exports.getFactoryPoolList = exports.getPoolList = void 0;
|
|
49
|
+
var ethers_1 = require("ethers");
|
|
49
50
|
var curve_1 = require("../curve");
|
|
50
51
|
var poolConstructor_1 = require("./poolConstructor");
|
|
51
52
|
var getPoolList = function () { return Object.keys(curve_1.curve.constants.POOLS_DATA); };
|
|
@@ -55,27 +56,34 @@ exports.getFactoryPoolList = getFactoryPoolList;
|
|
|
55
56
|
var getCryptoFactoryPoolList = function () { return Object.keys(curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA); };
|
|
56
57
|
exports.getCryptoFactoryPoolList = getCryptoFactoryPoolList;
|
|
57
58
|
var getUserPoolList = function (address) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
-
var
|
|
59
|
-
return __generator(this, function (
|
|
60
|
-
switch (
|
|
59
|
+
var poolIds, calls, _i, poolIds_1, poolId, pool, userPoolList, _rawBalances, _a, poolIds_2, poolId, pool, _balance;
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
61
62
|
case 0:
|
|
62
63
|
if (!address)
|
|
63
64
|
address = curve_1.curve.signerAddress;
|
|
64
65
|
address = address;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (_i = 0,
|
|
68
|
-
|
|
69
|
-
pool = (0, poolConstructor_1.getPool)(
|
|
70
|
-
|
|
66
|
+
poolIds = __spreadArray(__spreadArray(__spreadArray([], (0, exports.getPoolList)(), true), (0, exports.getFactoryPoolList)(), true), (0, exports.getCryptoFactoryPoolList)(), true);
|
|
67
|
+
calls = [];
|
|
68
|
+
for (_i = 0, poolIds_1 = poolIds; _i < poolIds_1.length; _i++) {
|
|
69
|
+
poolId = poolIds_1[_i];
|
|
70
|
+
pool = (0, poolConstructor_1.getPool)(poolId);
|
|
71
|
+
calls.push(curve_1.curve.contracts[pool.lpToken].multicallContract.balanceOf(address));
|
|
72
|
+
if (pool.gauge !== ethers_1.ethers.constants.AddressZero)
|
|
73
|
+
calls.push(curve_1.curve.contracts[pool.gauge].multicallContract.balanceOf(address));
|
|
71
74
|
}
|
|
72
75
|
userPoolList = [];
|
|
73
|
-
return [4 /*yield*/,
|
|
76
|
+
return [4 /*yield*/, curve_1.curve.multicallProvider.all(calls)];
|
|
74
77
|
case 1:
|
|
75
|
-
|
|
76
|
-
for (
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
_rawBalances = _b.sent();
|
|
79
|
+
for (_a = 0, poolIds_2 = poolIds; _a < poolIds_2.length; _a++) {
|
|
80
|
+
poolId = poolIds_2[_a];
|
|
81
|
+
pool = (0, poolConstructor_1.getPool)(poolId);
|
|
82
|
+
_balance = _rawBalances.shift();
|
|
83
|
+
if (pool.gauge !== ethers_1.ethers.constants.AddressZero)
|
|
84
|
+
_balance = _balance.add(_rawBalances.shift());
|
|
85
|
+
if (_balance.gt(0)) {
|
|
86
|
+
userPoolList.push(poolId);
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
89
|
return [2 /*return*/, userPoolList];
|
package/lib/utils.js
CHANGED
|
@@ -240,7 +240,7 @@ var _getAllowance = function (coins, address, spender) { return __awaiter(void 0
|
|
|
240
240
|
_coins.splice(ethIndex, 1);
|
|
241
241
|
}
|
|
242
242
|
if (!(_coins.length === 1)) return [3 /*break*/, 2];
|
|
243
|
-
return [4 /*yield*/, curve_1.curve.contracts[_coins[0]].contract.allowance(address, spender)];
|
|
243
|
+
return [4 /*yield*/, curve_1.curve.contracts[_coins[0]].contract.allowance(address, spender, curve_1.curve.constantOptions)];
|
|
244
244
|
case 1:
|
|
245
245
|
allowance = [_a.sent()];
|
|
246
246
|
return [3 /*break*/, 4];
|
|
@@ -452,15 +452,19 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
452
452
|
return [2 /*return*/, 1];
|
|
453
453
|
chainName = {
|
|
454
454
|
1: 'ethereum',
|
|
455
|
+
10: 'optimistic-ethereum',
|
|
455
456
|
137: 'polygon-pos',
|
|
456
457
|
250: 'fantom',
|
|
457
458
|
43114: 'avalanche',
|
|
459
|
+
42161: 'arbitrum-one',
|
|
458
460
|
}[curve_1.curve.chainId];
|
|
459
461
|
nativeTokenName = {
|
|
460
462
|
1: 'ethereum',
|
|
463
|
+
10: 'optimism',
|
|
461
464
|
137: 'matic-network',
|
|
462
465
|
250: 'fantom',
|
|
463
466
|
43114: 'avalanche-2',
|
|
467
|
+
42161: 'ethereum',
|
|
464
468
|
}[curve_1.curve.chainId];
|
|
465
469
|
if (chainName === undefined) {
|
|
466
470
|
throw Error('curve object is not initialized');
|
|
@@ -523,9 +527,11 @@ var getTVL = function (chainId) {
|
|
|
523
527
|
case 0:
|
|
524
528
|
network = (_a = {
|
|
525
529
|
1: "ethereum",
|
|
530
|
+
10: 'optimism',
|
|
526
531
|
137: "polygon",
|
|
527
532
|
250: "fantom",
|
|
528
533
|
43114: "avalanche",
|
|
534
|
+
42161: "arbitrum",
|
|
529
535
|
}[chainId]) !== null && _a !== void 0 ? _a : "ethereum";
|
|
530
536
|
promises = [
|
|
531
537
|
(0, external_api_1._getPoolsFromApi)(network, "main"),
|