@gearbox-protocol/sdk 1.15.22 → 1.15.24

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.
@@ -9,10 +9,6 @@ export interface StrategyPayload {
9
9
  leveragableCollateral: Array<string>;
10
10
  baseAssets: Array<string>;
11
11
  }
12
- interface PoolStats {
13
- borrowRate: number;
14
- }
15
- declare type PoolList = Record<string, PoolStats>;
16
12
  interface LiquidationPriceProps {
17
13
  prices: Record<string, BigNumber>;
18
14
  liquidationThresholds: Record<string, BigNumber>;
@@ -31,7 +27,7 @@ export declare class Strategy {
31
27
  baseAssets: Array<string>;
32
28
  constructor(payload: StrategyPayload);
33
29
  static maxLeverage(lpToken: string, cms: Array<PartialCM>): number;
34
- maxAPY(maxLeverage: number, poolApy: PoolList): number;
30
+ maxAPY(baseAPY: number, maxLeverage: number, borrowAPY: number): number;
35
31
  overallAPY(apy: number, leverage: number, depositCollateral: string, borrowAPY: number): number;
36
32
  liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }: LiquidationPriceProps): BigNumber;
37
33
  protected farmLev(leverage: number, depositCollateral: string): number;
@@ -26,9 +26,10 @@ var Strategy = /** @class */ (function () {
26
26
  var maxLeverage = ONE.mul(constants_1.LEVERAGE_DECIMALS).div(ONE.sub(maxThreshold));
27
27
  return maxLeverage.sub(constants_1.LEVERAGE_DECIMALS).toNumber();
28
28
  };
29
- Strategy.prototype.maxAPY = function (maxLeverage, poolApy) {
30
- var minApy = minBorrowApy(poolApy);
31
- return roi(this.apy || 0, maxLeverage, maxLeverage - constants_1.LEVERAGE_DECIMALS, minApy);
29
+ Strategy.prototype.maxAPY = function (baseAPY, maxLeverage, borrowAPY) {
30
+ return (baseAPY +
31
+ ((baseAPY - borrowAPY) * (maxLeverage - constants_1.LEVERAGE_DECIMALS)) /
32
+ constants_1.LEVERAGE_DECIMALS);
32
33
  };
33
34
  Strategy.prototype.overallAPY = function (apy, leverage, depositCollateral, borrowAPY) {
34
35
  var farmLev = this.farmLev(leverage, depositCollateral);
@@ -73,10 +74,6 @@ exports.Strategy = Strategy;
73
74
  function roi(apy, farmLev, debtLev, borrowAPY) {
74
75
  return (apy * farmLev - borrowAPY * debtLev) / constants_1.LEVERAGE_DECIMALS;
75
76
  }
76
- function minBorrowApy(poolApy) {
77
- var apys = Object.values(poolApy).sort(function (a, b) { return a.borrowRate - b.borrowRate; });
78
- return apys.length > 0 ? apys[0].borrowRate : 0;
79
- }
80
77
  function maxLeverageThreshold(lpToken, cms) {
81
78
  var lpTokenLC = lpToken.toLowerCase();
82
79
  var ltByCM = cms.map(function (cm) {
@@ -24,7 +24,7 @@ var lidoPayload = {
24
24
  var lidoStrategy = new strategy_1.Strategy(lidoPayload);
25
25
  var pools = {
26
26
  "0x1": {
27
- borrowRate: 7712,
27
+ borrowRate: 27543,
28
28
  },
29
29
  "0x2": {
30
30
  borrowRate: 5736,
@@ -42,8 +42,8 @@ var liquidationThresholds = (_b = {},
42
42
  _b);
43
43
  describe("Strategy test", function () {
44
44
  it("maxAPY calculation is correct", function () {
45
- var result = lidoStrategy.maxAPY(10 * constants_1.LEVERAGE_DECIMALS, pools);
46
- (0, chai_1.expect)(result).to.be.eq(332716);
45
+ var result = lidoStrategy.maxAPY(53203, 10 * constants_1.LEVERAGE_DECIMALS, pools["0x1"].borrowRate);
46
+ (0, chai_1.expect)(result).to.be.eq(284143);
47
47
  });
48
48
  it("overallAPY calculation is correct", function () {
49
49
  var result = lidoStrategy.overallAPY(lidoStrategy.apy || 0, 10 * constants_1.LEVERAGE_DECIMALS, token_1.tokenDataByNetwork.Mainnet.WETH, pools["0x2"].borrowRate);
@@ -251,7 +251,7 @@ exports.priceFeedsByNetwork = {
251
251
  priceFeedETH: {
252
252
  type: oracles_1.OracleType.CHAINLINK_ORACLE,
253
253
  address: {
254
- Mainnet: "0xcfe54b5cd566ab89272946f602d76ea879cab4a8",
254
+ Mainnet: "0x86392dC19c0b719886221c78AB11eb8Cf5c52812",
255
255
  Goerli: "0x0C539D95F202eF8b3981521782ABd3a12c5C4F95",
256
256
  },
257
257
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.15.22",
3
+ "version": "1.15.24",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",