@curvefi/api 2.25.4 → 2.26.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/README.md +5 -0
- package/lib/boosting.d.ts +1 -0
- package/lib/boosting.js +10 -2
- package/lib/constants/coins/avalanche.js +2 -0
- package/lib/constants/pools/avalanche.js +30 -0
- package/lib/factory/factory-api.js +1 -0
- package/lib/factory/factory.js +14 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1055,6 +1055,8 @@ import curve from "@curvefi/api";
|
|
|
1055
1055
|
// '0x07f6daedb705446cb56ab42c18ba9ec5302ef5ed9c7ef0bb5c3c92493abcfc79'
|
|
1056
1056
|
// ]
|
|
1057
1057
|
|
|
1058
|
+
curve.boosting.calcUnlockTime(365); // now (by default) + 365 days, rounded down by WEEK
|
|
1059
|
+
// 1657152000000
|
|
1058
1060
|
await curve.boosting.createLock(1000, 365);
|
|
1059
1061
|
// 99000.0 CRV
|
|
1060
1062
|
// { lockedAmount: '1000.0', unlockTime: 1657152000000 }
|
|
@@ -1067,6 +1069,9 @@ import curve from "@curvefi/api";
|
|
|
1067
1069
|
// 372.289692732093137414 veCRV
|
|
1068
1070
|
// 0.000009285953543912 veCRV %
|
|
1069
1071
|
|
|
1072
|
+
const { unlockTime: currentUnlockTime } = await curve.boosting.getLockedAmountAndUnlockTime();
|
|
1073
|
+
curve.boosting.calcUnlockTime(365, currentUnlockTime); // currentUnlockTime + 365 days, rounded down by WEEK
|
|
1074
|
+
// 1688601600000
|
|
1070
1075
|
await curve.boosting.increaseUnlockTime(365);
|
|
1071
1076
|
// 98500.0 CRV
|
|
1072
1077
|
// { lockedAmount: '1500.0', unlockTime: 1688601600000 }
|
package/lib/boosting.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const isApproved: (amount: number | string) => Promise<boolean>;
|
|
|
13
13
|
export declare const approveEstimateGas: (amount: number | string) => Promise<number>;
|
|
14
14
|
export declare const approve: (amount: number | string) => Promise<string[]>;
|
|
15
15
|
export declare const createLockEstimateGas: (amount: number | string, days: number) => Promise<number>;
|
|
16
|
+
export declare const calcUnlockTime: (days: number, start?: number) => number;
|
|
16
17
|
export declare const createLock: (amount: number | string, days: number) => Promise<string>;
|
|
17
18
|
export declare const increaseAmountEstimateGas: (amount: number | string) => Promise<number>;
|
|
18
19
|
export declare const increaseAmount: (amount: number | string) => Promise<string>;
|
package/lib/boosting.js
CHANGED
|
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.claimFees = exports.claimFeesEstimateGas = exports.claimableFees = exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
53
|
+
exports.claimFees = exports.claimFeesEstimateGas = exports.claimableFees = exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.calcUnlockTime = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
54
54
|
var ethers_1 = require("ethers");
|
|
55
55
|
var curve_1 = require("./curve");
|
|
56
56
|
var fee_distributor_view_json_1 = __importDefault(require("./constants/abis/fee_distributor_view.json"));
|
|
@@ -218,13 +218,21 @@ var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, v
|
|
|
218
218
|
});
|
|
219
219
|
}); };
|
|
220
220
|
exports.createLockEstimateGas = createLockEstimateGas;
|
|
221
|
+
var calcUnlockTime = function (days, start) {
|
|
222
|
+
if (start === void 0) { start = Date.now(); }
|
|
223
|
+
var week = 86400 * 7;
|
|
224
|
+
var now = start / 1000;
|
|
225
|
+
var unlockTime = now + (86400 * days);
|
|
226
|
+
return Math.floor(unlockTime / week) * week * 1000;
|
|
227
|
+
};
|
|
228
|
+
exports.calcUnlockTime = calcUnlockTime;
|
|
221
229
|
var createLock = function (amount, days) { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
230
|
var _amount, unlockTime, contract, gasLimit;
|
|
223
231
|
return __generator(this, function (_a) {
|
|
224
232
|
switch (_a.label) {
|
|
225
233
|
case 0:
|
|
226
234
|
_amount = (0, utils_2.parseUnits)(amount);
|
|
227
|
-
unlockTime = Math.floor(Date.now() / 1000) + (
|
|
235
|
+
unlockTime = Math.floor(Date.now() / 1000) + (86400 * days);
|
|
228
236
|
return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow)];
|
|
229
237
|
case 1:
|
|
230
238
|
_a.sent();
|
|
@@ -9,6 +9,8 @@ exports.COINS_AVALANCHE = (0, utils_1.lowerCaseValues)({
|
|
|
9
9
|
'dai.e': '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70',
|
|
10
10
|
'usdc.e': '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664',
|
|
11
11
|
'usdt.e': '0xc7198437980c041c805A1EDcbA50c1Ce5db95118',
|
|
12
|
+
'usdc': '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
13
|
+
'usdt': '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7',
|
|
12
14
|
'avdai': '0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a',
|
|
13
15
|
'avusdc': '0x46A51127C3ce23fb7AB1DE06226147F446e4a857',
|
|
14
16
|
'avusdt': '0x532E6537FEA298397212F09A61e03311686f548e',
|
|
@@ -103,4 +103,34 @@ exports.POOLS_DATA_AVALANCHE = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
103
103
|
gauge_abi: gauge_child_json_1.default,
|
|
104
104
|
deposit_abi: zap_json_1.default,
|
|
105
105
|
},
|
|
106
|
+
aaveV3: {
|
|
107
|
+
name: "aaveV3",
|
|
108
|
+
full_name: "aaveV3",
|
|
109
|
+
symbol: "aaveV3",
|
|
110
|
+
reference_asset: 'USD',
|
|
111
|
+
swap_address: '0xD2AcAe14ae2ee0f6557aC6C6D0e407a92C36214b',
|
|
112
|
+
token_address: '0x5bE26703a658c332CE612eAe3A497059dA98394a',
|
|
113
|
+
gauge_address: '0x55f9Ba282c39793DB29C68F8f113fC97D23a6445',
|
|
114
|
+
is_lending: true,
|
|
115
|
+
underlying_coins: ['DAI.e', 'USDC', 'USDt'],
|
|
116
|
+
wrapped_coins: ['aAvaDAI', 'aAvaUSDC', 'aAvaUSDT'],
|
|
117
|
+
underlying_coin_addresses: [
|
|
118
|
+
'0xd586E7F844cEa2F87f50152665BCbc2C279D8d70',
|
|
119
|
+
'0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
120
|
+
'0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7',
|
|
121
|
+
],
|
|
122
|
+
wrapped_coin_addresses: [
|
|
123
|
+
'0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE',
|
|
124
|
+
'0x625E7708f30cA75bfd92586e17077590C60eb4cD',
|
|
125
|
+
'0x6ab707Aca953eDAeFBc4fD23bA73294241490620',
|
|
126
|
+
],
|
|
127
|
+
underlying_decimals: [18, 6, 6],
|
|
128
|
+
wrapped_decimals: [18, 6, 6],
|
|
129
|
+
use_lending: [true, true, true],
|
|
130
|
+
swap_abi: swap_json_1.default,
|
|
131
|
+
gauge_abi: gauge_child_json_1.default,
|
|
132
|
+
// sCurveRewards_abi: paaveRewardsabi,
|
|
133
|
+
// sCurveRewards_address: '0xB504b6EB06760019801a91B451d3f7BD9f027fC9',
|
|
134
|
+
// reward_token: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
135
|
+
},
|
|
106
136
|
});
|
|
@@ -166,6 +166,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
|
|
|
166
166
|
return [4 /*yield*/, (0, external_api_1._getPoolsFromApi)(network, factoryType)];
|
|
167
167
|
case 1:
|
|
168
168
|
rawPoolList = _a.apply(void 0, [(_c.sent()).poolData]);
|
|
169
|
+
rawPoolList = rawPoolList.filter(function (p) { return p.implementationAddress in constants_1.FACTORY_CONSTANTS[_this.chainId].implementationABIDict; });
|
|
169
170
|
mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address; });
|
|
170
171
|
rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address); });
|
|
171
172
|
if (!(this.chainId !== 1)) return [3 /*break*/, 3];
|
package/lib/factory/factory.js
CHANGED
|
@@ -383,7 +383,7 @@ function getFactoryIsMeta(factorySwapAddresses) {
|
|
|
383
383
|
}
|
|
384
384
|
function getFactoryPoolData(swapAddress) {
|
|
385
385
|
return __awaiter(this, void 0, void 0, function () {
|
|
386
|
-
var _a,
|
|
386
|
+
var _a, rawPoolIds, rawSwapAddresses, _b, rawImplementations, poolIds, swapAddresses, implementations, implementationABIDict, i, swapABIs, gaugeAddresses, _c, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, implementationBasePoolIdDict, basePoolIds, FACTORY_POOLS_DATA, _loop_2, this_1, i;
|
|
387
387
|
return __generator(this, function (_e) {
|
|
388
388
|
switch (_e.label) {
|
|
389
389
|
case 0:
|
|
@@ -397,11 +397,21 @@ function getFactoryPoolData(swapAddress) {
|
|
|
397
397
|
_b = _e.sent();
|
|
398
398
|
_e.label = 4;
|
|
399
399
|
case 4:
|
|
400
|
-
_a = _b,
|
|
401
|
-
return [4 /*yield*/, getFactoryImplementations.call(this,
|
|
400
|
+
_a = _b, rawPoolIds = _a[0], rawSwapAddresses = _a[1];
|
|
401
|
+
return [4 /*yield*/, getFactoryImplementations.call(this, rawSwapAddresses)];
|
|
402
402
|
case 5:
|
|
403
|
-
|
|
403
|
+
rawImplementations = _e.sent();
|
|
404
|
+
poolIds = [];
|
|
405
|
+
swapAddresses = [];
|
|
406
|
+
implementations = [];
|
|
404
407
|
implementationABIDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
408
|
+
for (i = 0; i < rawPoolIds.length; i++) {
|
|
409
|
+
if (rawImplementations[i] in implementationABIDict) {
|
|
410
|
+
poolIds.push(rawPoolIds[i]);
|
|
411
|
+
swapAddresses.push(rawSwapAddresses[i]);
|
|
412
|
+
implementations.push(rawImplementations[i]);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
405
415
|
swapABIs = implementations.map(function (addr) { return implementationABIDict[addr]; });
|
|
406
416
|
setFactorySwapContracts.call(this, swapAddresses, swapABIs);
|
|
407
417
|
return [4 /*yield*/, getFactoryGaugeAddresses.call(this, swapAddresses)];
|
package/lib/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ declare const curve: {
|
|
|
96
96
|
}>;
|
|
97
97
|
getVeCrv: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").IDict<string>>;
|
|
98
98
|
getVeCrvPct: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").IDict<string>>;
|
|
99
|
+
calcUnlockTime: (days: number, start?: number) => number;
|
|
99
100
|
isApproved: (amount: string | number) => Promise<boolean>;
|
|
100
101
|
approve: (amount: string | number) => Promise<string[]>;
|
|
101
102
|
createLock: (amount: string | number, days: number) => Promise<string>;
|
package/lib/index.js
CHANGED
|
@@ -175,6 +175,7 @@ var curve = {
|
|
|
175
175
|
getLockedAmountAndUnlockTime: boosting_1.getLockedAmountAndUnlockTime,
|
|
176
176
|
getVeCrv: boosting_1.getVeCrv,
|
|
177
177
|
getVeCrvPct: boosting_1.getVeCrvPct,
|
|
178
|
+
calcUnlockTime: boosting_1.calcUnlockTime,
|
|
178
179
|
isApproved: boosting_1.isApproved,
|
|
179
180
|
approve: boosting_1.approve,
|
|
180
181
|
createLock: boosting_1.createLock,
|