@gearbox-protocol/sdk 3.0.0-next.157 → 3.0.0-next.159
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/apy/convexAPY.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface GetConvexAPYBulkProps {
|
|
|
10
10
|
generated: GetConvexAPYBulkCallsReturns;
|
|
11
11
|
response: Array<BigNumberish>;
|
|
12
12
|
network: NetworkType;
|
|
13
|
+
currentTimestamp: number;
|
|
13
14
|
}
|
|
14
15
|
export declare function getConvexAPYBulk(props: GetConvexAPYBulkProps): number[];
|
|
15
16
|
interface PoolInfo {
|
|
@@ -44,6 +45,7 @@ export interface CalculateConvexAPYProps {
|
|
|
44
45
|
info: PoolInfo;
|
|
45
46
|
getTokenPrice: GetTokenPriceCallback;
|
|
46
47
|
curveAPY: CurveAPYResult | undefined;
|
|
48
|
+
currentTimestamp: number;
|
|
47
49
|
}
|
|
48
50
|
export declare function getCVXMintAmount(crvAmount: bigint, cvxTokenSupply: bigint): bigint;
|
|
49
51
|
export {};
|
package/lib/apy/convexAPY.js
CHANGED
|
@@ -37,6 +37,7 @@ function getConvexAPYBulk(props) {
|
|
|
37
37
|
info: poolsInfo[i],
|
|
38
38
|
getTokenPrice: props.getTokenPrice,
|
|
39
39
|
curveAPY: props.curveAPY,
|
|
40
|
+
currentTimestamp: props.currentTimestamp,
|
|
40
41
|
});
|
|
41
42
|
return apy;
|
|
42
43
|
});
|
|
@@ -140,7 +141,6 @@ const CURRENCY_LIST = {
|
|
|
140
141
|
};
|
|
141
142
|
function calculateConvexAPY(props) {
|
|
142
143
|
const { tokenList, cvxPool, crvToken, cvxExtraPools } = props.info;
|
|
143
|
-
const currentTimestamp = getTimestampInSeconds();
|
|
144
144
|
const currencySymbol = CURRENCY_LIST[cvxPool.stakedToken];
|
|
145
145
|
const currency = currencySymbol && tokenList[currencySymbol || ""];
|
|
146
146
|
const cvxPrice = props.getTokenPrice(tokenList.CVX, currency);
|
|
@@ -153,7 +153,7 @@ function calculateConvexAPY(props) {
|
|
|
153
153
|
const crvPerUnderlying = (crvPerSecond * sdk_gov_1.WAD) / virtualSupply;
|
|
154
154
|
const crvPerYear = crvPerUnderlying * BigInt(sdk_gov_1.SECONDS_PER_YEAR);
|
|
155
155
|
const cvxPerYear = getCVXMintAmount(crvPerYear, props.cvxTokenSupply);
|
|
156
|
-
const baseFinished = props.cvxPoolRewardsFinish <= currentTimestamp;
|
|
156
|
+
const baseFinished = props.cvxPoolRewardsFinish <= props.currentTimestamp;
|
|
157
157
|
const crvAPY = baseFinished ? 0n : (crvPerYear * crvPrice) / sdk_gov_1.PRICE_DECIMALS;
|
|
158
158
|
const cvxAPY = baseFinished ? 0n : (cvxPerYear * cvxPrice) / sdk_gov_1.PRICE_DECIMALS;
|
|
159
159
|
const extraAPRs = cvxExtraPools.map((_, index) => {
|
|
@@ -164,7 +164,7 @@ function calculateConvexAPY(props) {
|
|
|
164
164
|
const perYear = perUnderlying * BigInt(sdk_gov_1.SECONDS_PER_YEAR);
|
|
165
165
|
const extraPrice = props.getTokenPrice(tokenList[extraRewardSymbol], currency);
|
|
166
166
|
const extraAPY = (perYear * extraPrice) / sdk_gov_1.PRICE_DECIMALS;
|
|
167
|
-
const finished = extraFinished <= currentTimestamp;
|
|
167
|
+
const finished = extraFinished <= props.currentTimestamp;
|
|
168
168
|
return finished ? 0n : extraAPY;
|
|
169
169
|
});
|
|
170
170
|
const extraAPYTotal = extraAPRs.reduce((acc, apy) => acc + apy, 0n);
|
|
@@ -174,9 +174,6 @@ function calculateConvexAPY(props) {
|
|
|
174
174
|
const r = baseApy + Math.round(Number((apyTotalInPercent * 10n) / sdk_gov_1.WAD) / 10);
|
|
175
175
|
return r;
|
|
176
176
|
}
|
|
177
|
-
function getTimestampInSeconds() {
|
|
178
|
-
return Math.floor(Date.now() / 1000);
|
|
179
|
-
}
|
|
180
177
|
function getCVXMintAmount(crvAmount, cvxTokenSupply) {
|
|
181
178
|
const currentCliff = cvxTokenSupply / CVX_REDUCTION_PER_CLIFF;
|
|
182
179
|
if (currentCliff < CVX_TOTAL_CLIFFS) {
|
|
@@ -10,7 +10,7 @@ interface PoolEvent {
|
|
|
10
10
|
readonly poolName?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface TxSerialized {
|
|
13
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "
|
|
13
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral";
|
|
14
14
|
content: string;
|
|
15
15
|
}
|
|
16
16
|
export declare class TxSerializer {
|
|
@@ -162,14 +162,14 @@ export declare class TxClaimNFT extends EVMTx {
|
|
|
162
162
|
toString(): string;
|
|
163
163
|
serialize(): TxSerialized;
|
|
164
164
|
}
|
|
165
|
-
interface
|
|
165
|
+
interface TxClaimRewardsProps extends EVMTxProps {
|
|
166
166
|
token: string;
|
|
167
167
|
amount: bigint;
|
|
168
168
|
}
|
|
169
|
-
export declare class
|
|
169
|
+
export declare class TxClaimRewards extends EVMTx {
|
|
170
170
|
readonly token: string;
|
|
171
171
|
readonly amount: bigint;
|
|
172
|
-
constructor(opts:
|
|
172
|
+
constructor(opts: TxClaimRewardsProps);
|
|
173
173
|
toString(): string;
|
|
174
174
|
serialize(): TxSerialized;
|
|
175
175
|
}
|
package/lib/core/transactions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.
|
|
3
|
+
exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
6
6
|
const math_1 = require("../utils/math");
|
|
@@ -39,8 +39,8 @@ class TxSerializer {
|
|
|
39
39
|
return new TxClaimReward(params);
|
|
40
40
|
case "TxClaimNFT":
|
|
41
41
|
return new TxClaimNFT(params);
|
|
42
|
-
case "
|
|
43
|
-
return new
|
|
42
|
+
case "TxClaimRewards":
|
|
43
|
+
return new TxClaimRewards(params);
|
|
44
44
|
case "TxEnableTokens":
|
|
45
45
|
return new TxEnableTokens(params);
|
|
46
46
|
case "TxUpdateQuota":
|
|
@@ -313,7 +313,7 @@ class TxClaimNFT extends eventOrTx_1.EVMTx {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
exports.TxClaimNFT = TxClaimNFT;
|
|
316
|
-
class
|
|
316
|
+
class TxClaimRewards extends eventOrTx_1.EVMTx {
|
|
317
317
|
token;
|
|
318
318
|
amount;
|
|
319
319
|
constructor(opts) {
|
|
@@ -323,16 +323,16 @@ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
|
|
|
323
323
|
}
|
|
324
324
|
toString() {
|
|
325
325
|
const [symbol, decimals] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
326
|
-
return `
|
|
326
|
+
return `Rewards claimed: ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
|
|
327
327
|
}
|
|
328
328
|
serialize() {
|
|
329
329
|
return {
|
|
330
|
-
type: "
|
|
330
|
+
type: "TxClaimRewards",
|
|
331
331
|
content: JSON.stringify(this),
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
exports.
|
|
335
|
+
exports.TxClaimRewards = TxClaimRewards;
|
|
336
336
|
class TxRepayAccount extends eventOrTx_1.EVMTx {
|
|
337
337
|
creditManager;
|
|
338
338
|
creditManagerName;
|