@gearbox-protocol/sdk 3.0.0-next.158 → 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 +2 -0
- package/lib/apy/convexAPY.js +3 -6
- package/package.json +1 -1
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) {
|