@gearbox-protocol/sdk 1.20.14 → 1.20.16

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;
@@ -0,0 +1,6 @@
1
+ import { AbstractParser } from "./abstractParser";
2
+ import { IParser } from "./iParser";
3
+ export declare class PoolParser extends AbstractParser implements IParser {
4
+ constructor(version: number);
5
+ parse(calldata: string): string;
6
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PoolParser = void 0;
19
+ var types_1 = require("../types");
20
+ var abstractParser_1 = require("./abstractParser");
21
+ var PoolParser = /** @class */ (function (_super) {
22
+ __extends(PoolParser, _super);
23
+ function PoolParser(version) {
24
+ var _this = _super.call(this, "Pool_V".concat(version)) || this;
25
+ _this.ifc = types_1.PoolService__factory.createInterface();
26
+ return _this;
27
+ }
28
+ PoolParser.prototype.parse = function (calldata) {
29
+ var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
30
+ switch (functionFragment.name) {
31
+ default:
32
+ return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
33
+ }
34
+ };
35
+ return PoolParser;
36
+ }(abstractParser_1.AbstractParser));
37
+ exports.PoolParser = PoolParser;
@@ -38,6 +38,7 @@ export declare class TxParser {
38
38
  static addMulticall(address: string): void;
39
39
  static addAirdropDistributor(address: string): void;
40
40
  static addCreditManager(address: string, version: number): void;
41
+ static addPool(address: string, version: number): void;
41
42
  static getParser(address: string): IParser & AbstractParser;
42
43
  protected static chooseContractParser(address: string, contract: SupportedContract, adapterType: number, isContract: boolean): void;
43
44
  protected static _addParser(address: string, parser: IParser & AbstractParser): void;
@@ -20,6 +20,7 @@ var lidoOracleParser_1 = require("./lidoOracleParser");
20
20
  var lidoSTETHParser_1 = require("./lidoSTETHParser");
21
21
  var multicallParser_1 = require("./multicallParser");
22
22
  var offchainOracleParser_1 = require("./offchainOracleParser");
23
+ var poolParser_1 = require("./poolParser");
23
24
  var priceOracleParser_1 = require("./priceOracleParser");
24
25
  var uniV2AdapterParser_1 = require("./uniV2AdapterParser");
25
26
  var uniV3AdapterParser_1 = require("./uniV3AdapterParser");
@@ -120,6 +121,9 @@ var TxParser = /** @class */ (function () {
120
121
  TxParser.addCreditManager = function (address, version) {
121
122
  TxParser._addParser(address, new creditManagerParser_1.CreditManagerParser(version));
122
123
  };
124
+ TxParser.addPool = function (address, version) {
125
+ TxParser._addParser(address, new poolParser_1.PoolParser(version));
126
+ };
123
127
  TxParser.getParser = function (address) {
124
128
  var parser = TxParser.parsers[address.toLowerCase()];
125
129
  if (!parser)
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.16",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",