@curvefi/api 2.25.4 → 2.25.5
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/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();
|
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,
|