@gearbox-protocol/sdk 1.20.14 → 1.20.15

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.
@@ -20,15 +20,17 @@ export interface GetConvexAPYBulkCallsProps {
20
20
  }
21
21
  export declare function getConvexAPYBulkCalls({ pools, networkType, }: GetConvexAPYBulkCallsProps): {
22
22
  poolsInfo: (readonly [ConvexPoolParams, string, string, CurveLPToken, string[], Record<SupportedToken, string>])[];
23
- calls: [MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool").ICurvePoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken").IConvexTokenInterface>, ...MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>[]][];
23
+ calls: [MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool").ICurvePoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken").IConvexTokenInterface>, ...MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>[]][];
24
24
  };
25
25
  export declare function getCVXMintAmount(crvAmount: BigNumber, cvxSupply: BigNumber): BigNumber;
26
26
  export interface CalculateConvexAPYProps {
27
+ baseRewardsFinish: BigNumber;
27
28
  basePoolRate: BigNumber;
28
29
  basePoolSupply: BigNumber;
29
30
  vPrice: BigNumber;
30
31
  cvxSupply: BigNumber;
31
32
  extra: Array<BigNumber>;
33
+ extraRewardsFinish: Array<BigNumber>;
32
34
  extraPoolAddresses: string[];
33
35
  poolParams: ConvexPoolParams;
34
36
  underlying: CurveLPToken;
@@ -26,14 +26,18 @@ function getConvexAPYBulk(_a) {
26
26
  return [acc, end];
27
27
  }, [[], 0])[0];
28
28
  var apyList = parsedResponse.map(function (_a, i) {
29
- var basePoolRate = _a[0], basePoolSupply = _a[1], vPrice = _a[2], cvxSupply = _a[3], extra = _a.slice(4);
29
+ var baseRewardsFinish = _a[0], basePoolRate = _a[1], basePoolSupply = _a[2], vPrice = _a[3], cvxSupply = _a[4], rest = _a.slice(5);
30
30
  var _b = poolsInfo[i], poolParams = _b[0], underlying = _b[3], extraPoolAddresses = _b[4], tokenList = _b[5];
31
+ var extra = rest.slice(0, extraPoolAddresses.length);
32
+ var extraRewardsFinish = rest.slice(extraPoolAddresses.length);
31
33
  var apy = calculateConvexAPY({
34
+ baseRewardsFinish: baseRewardsFinish,
32
35
  basePoolRate: basePoolRate,
33
36
  basePoolSupply: basePoolSupply,
34
37
  vPrice: vPrice,
35
38
  cvxSupply: cvxSupply,
36
39
  extra: extra,
40
+ extraRewardsFinish: extraRewardsFinish,
37
41
  extraPoolAddresses: extraPoolAddresses,
38
42
  poolParams: poolParams,
39
43
  underlying: underlying,
@@ -83,7 +87,12 @@ function getConvexAPYBulkCalls(_a) {
83
87
  exports.getConvexAPYBulkCalls = getConvexAPYBulkCalls;
84
88
  function getPoolDataCalls(_a) {
85
89
  var basePoolAddress = _a.basePoolAddress, swapPoolAddress = _a.swapPoolAddress, cvxAddress = _a.cvxAddress, extraPoolAddresses = _a.extraPoolAddresses;
86
- var calls = __spreadArray([
90
+ var calls = __spreadArray(__spreadArray([
91
+ {
92
+ address: basePoolAddress,
93
+ interface: types_1.IBaseRewardPool__factory.createInterface(),
94
+ method: "periodFinish()",
95
+ },
87
96
  {
88
97
  address: basePoolAddress,
89
98
  interface: types_1.IBaseRewardPool__factory.createInterface(),
@@ -108,6 +117,10 @@ function getPoolDataCalls(_a) {
108
117
  address: extraPoolAddress,
109
118
  interface: types_1.IBaseRewardPool__factory.createInterface(),
110
119
  method: "rewardRate()",
120
+ }); }), true), extraPoolAddresses.map(function (extraPoolAddress) { return ({
121
+ address: extraPoolAddress,
122
+ interface: types_1.IBaseRewardPool__factory.createInterface(),
123
+ method: "periodFinish()",
111
124
  }); }), true);
112
125
  return calls;
113
126
  }
@@ -125,11 +138,15 @@ function getCVXMintAmount(crvAmount, cvxSupply) {
125
138
  return ethers_1.BigNumber.from(0);
126
139
  }
127
140
  exports.getCVXMintAmount = getCVXMintAmount;
141
+ function getTimestampInSeconds() {
142
+ return Math.floor(Date.now() / 1000);
143
+ }
128
144
  var CURRENCY_LIST = {
129
145
  stkcvxsteCRV: "WETH",
130
146
  };
131
147
  function calculateConvexAPY(_a) {
132
- var basePoolRate = _a.basePoolRate, basePoolSupply = _a.basePoolSupply, vPrice = _a.vPrice, cvxSupply = _a.cvxSupply, extra = _a.extra, extraPoolAddresses = _a.extraPoolAddresses, poolParams = _a.poolParams, underlying = _a.underlying, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY, tokenList = _a.tokenList;
148
+ var baseRewardsFinish = _a.baseRewardsFinish, basePoolRate = _a.basePoolRate, basePoolSupply = _a.basePoolSupply, vPrice = _a.vPrice, cvxSupply = _a.cvxSupply, extra = _a.extra, extraRewardsFinish = _a.extraRewardsFinish, extraPoolAddresses = _a.extraPoolAddresses, poolParams = _a.poolParams, underlying = _a.underlying, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY, tokenList = _a.tokenList;
149
+ var currentTimestamp = getTimestampInSeconds();
133
150
  var currencySymbol = CURRENCY_LIST[poolParams.stakedToken];
134
151
  var currency = currencySymbol && tokenList[currencySymbol || ""];
135
152
  var cvxPrice = getTokenPrice(tokenList.CVX, currency);
@@ -139,16 +156,23 @@ function calculateConvexAPY(_a) {
139
156
  var crvPerUnderlying = crvPerSecond.mul(constants_1.WAD).div(virtualSupply);
140
157
  var crvPerYear = crvPerUnderlying.mul(constants_1.SECONDS_PER_YEAR);
141
158
  var cvxPerYear = getCVXMintAmount(crvPerYear, cvxSupply);
142
- var crvAPY = crvPerYear.mul(crvPrice).div(constants_1.PRICE_DECIMALS);
143
- var cvxAPY = cvxPerYear.mul(cvxPrice).div(constants_1.PRICE_DECIMALS);
159
+ var baseFinished = baseRewardsFinish.lte(currentTimestamp);
160
+ var crvAPY = baseFinished
161
+ ? ethers_1.BigNumber.from(0)
162
+ : crvPerYear.mul(crvPrice).div(constants_1.PRICE_DECIMALS);
163
+ var cvxAPY = baseFinished
164
+ ? ethers_1.BigNumber.from(0)
165
+ : cvxPerYear.mul(cvxPrice).div(constants_1.PRICE_DECIMALS);
144
166
  var extraAPRs = extraPoolAddresses.map(function (_, index) {
145
167
  var extraRewardSymbol = poolParams.extraRewards[index].rewardToken;
146
168
  var extraPoolRate = extra[index];
169
+ var extraFinished = extraRewardsFinish[index];
147
170
  var perUnderlying = extraPoolRate.mul(constants_1.WAD).div(virtualSupply);
148
171
  var perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
149
172
  var extraPrice = getTokenPrice(tokenList[extraRewardSymbol], currency);
150
173
  var extraAPY = perYear.mul(extraPrice).div(constants_1.PRICE_DECIMALS);
151
- return extraAPY;
174
+ var finished = extraFinished.lte(currentTimestamp);
175
+ return finished ? ethers_1.BigNumber.from(0) : extraAPY;
152
176
  });
153
177
  var extraAPYTotal = extraAPRs.reduce(function (acc, apy) { return acc.add(apy); }, ethers_1.BigNumber.from(0));
154
178
  var baseApyWAD = curveAPY[underlying].base;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.20.14",
3
+ "version": "1.20.15",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",