@gearbox-protocol/sdk 3.0.0-next.217 → 3.0.0-next.219

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.
@@ -1,16 +1,13 @@
1
1
  import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
- type AdditionalTokensWithAPY = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH">;
3
- type AdditionalLPTokens = Extract<SupportedToken, "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH">;
4
- type ExtraFarmTokens = AdditionalTokensWithAPY | AdditionalLPTokens;
5
- export type LRTAndLSDTokens = Extract<ExtraFarmTokens, "weETH" | "rsETH" | "rswETH" | "pufETH" | "ezETH" | "STETH" | "wstETH" | "sfrxETH" | "osETH" | "cbETH" | "rETH">;
6
- export type TokensWithAPY = LPTokens | AdditionalTokensWithAPY;
7
- export type TokensWithApyRecord = PartialRecord<TokensWithAPY, number>;
8
- export type AllLPTokens = LPTokens | ExtraFarmTokens;
9
- export declare const isLRT_LSDToken: (t: unknown) => t is LRTAndLSDTokens;
10
- export declare const isAdditionalLPToken: (t: unknown) => t is AdditionalLPTokens;
11
- export declare const isAdditionalTokenWithAPY: (t: unknown) => t is AdditionalTokensWithAPY;
2
+ type ExtraFarmTokens = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH" | "LBTC">;
3
+ type ExtraTokensWithAPY = Extract<ExtraFarmTokens, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH">;
4
+ type LRTAndLSTTokens = Exclude<ExtraFarmTokens, "USDe">;
12
5
  export declare const isExtraFarmToken: (t: unknown) => t is ExtraFarmTokens;
6
+ export declare const isLRT_LSTToken: (t: unknown) => t is LRTAndLSTTokens;
7
+ export type TokensWithAPY = LPTokens | ExtraTokensWithAPY;
8
+ export type TokensWithApyRecord = PartialRecord<TokensWithAPY, number>;
13
9
  export declare const isTokenWithAPY: (t: unknown) => t is TokensWithAPY;
10
+ export type AllLPTokens = LPTokens | ExtraFarmTokens;
14
11
  export declare const isFarmToken: (t: unknown) => t is AllLPTokens;
15
12
  export * from "./convexAPY";
16
13
  export * from "./curveAPY";
package/lib/apy/index.js CHANGED
@@ -14,9 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isFarmToken = exports.isTokenWithAPY = exports.isExtraFarmToken = exports.isAdditionalTokenWithAPY = exports.isAdditionalLPToken = exports.isLRT_LSDToken = void 0;
17
+ exports.isFarmToken = exports.isTokenWithAPY = exports.isLRT_LSTToken = exports.isExtraFarmToken = void 0;
18
18
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
19
- const ADDITIONAL_LP_TOKENS = {
19
+ const EXTRA_FARM_TOKENS = {
20
+ STETH: true,
21
+ rETH: true,
22
+ osETH: true,
23
+ cbETH: true,
24
+ wstETH: true,
20
25
  weETH: true,
21
26
  ezETH: true,
22
27
  sfrxETH: true,
@@ -28,8 +33,15 @@ const ADDITIONAL_LP_TOKENS = {
28
33
  rstETH: true,
29
34
  steakLRT: true,
30
35
  amphrETH: true,
36
+ LBTC: true,
31
37
  };
32
- const TOKENS_WITH_APY = {
38
+ const isExtraFarmToken = (t) => {
39
+ if (typeof t !== "string")
40
+ return false;
41
+ return !!EXTRA_FARM_TOKENS[t];
42
+ };
43
+ exports.isExtraFarmToken = isExtraFarmToken;
44
+ const EXTRA_TOKENS_WITH_APY = {
33
45
  STETH: true,
34
46
  osETH: true,
35
47
  rETH: true,
@@ -37,43 +49,23 @@ const TOKENS_WITH_APY = {
37
49
  cbETH: true,
38
50
  sfrxETH: true,
39
51
  };
40
- const LRT_LSD = {
41
- weETH: true,
42
- rsETH: true,
43
- rswETH: true,
44
- pufETH: true,
45
- ezETH: true,
46
- STETH: true,
47
- wstETH: true,
48
- sfrxETH: true,
49
- osETH: true,
50
- cbETH: true,
51
- rETH: true,
52
- };
53
- const isLRT_LSDToken = (t) => {
54
- if (typeof t !== "string")
55
- return false;
56
- return !!LRT_LSD[t];
57
- };
58
- exports.isLRT_LSDToken = isLRT_LSDToken;
59
- const isAdditionalLPToken = (t) => {
52
+ const isExtraTokenWithAPY = (t) => {
60
53
  if (typeof t !== "string")
61
54
  return false;
62
- return !!ADDITIONAL_LP_TOKENS[t];
55
+ return !!EXTRA_TOKENS_WITH_APY[t];
63
56
  };
64
- exports.isAdditionalLPToken = isAdditionalLPToken;
65
- const isAdditionalTokenWithAPY = (t) => {
57
+ const { USDe, ...rest } = EXTRA_FARM_TOKENS;
58
+ const LRT_LST = rest;
59
+ const isLRT_LSTToken = (t) => {
66
60
  if (typeof t !== "string")
67
61
  return false;
68
- return !!TOKENS_WITH_APY[t];
62
+ return !!LRT_LST[t];
69
63
  };
70
- exports.isAdditionalTokenWithAPY = isAdditionalTokenWithAPY;
71
- const isExtraFarmToken = (t) => (0, exports.isAdditionalLPToken)(t) || (0, exports.isAdditionalTokenWithAPY)(t);
72
- exports.isExtraFarmToken = isExtraFarmToken;
64
+ exports.isLRT_LSTToken = isLRT_LSTToken;
73
65
  const isTokenWithAPY = (t) => {
74
66
  if (typeof t !== "string")
75
67
  return false;
76
- return (0, sdk_gov_1.isLPToken)(t) || (0, exports.isAdditionalTokenWithAPY)(t);
68
+ return (0, sdk_gov_1.isLPToken)(t) || isExtraTokenWithAPY(t);
77
69
  };
78
70
  exports.isTokenWithAPY = isTokenWithAPY;
79
71
  const isFarmToken = (t) => {
package/lib/core/pool.js CHANGED
@@ -137,10 +137,12 @@ class PoolData {
137
137
  return "universal";
138
138
  }
139
139
  static calculateUtilization(expected, available) {
140
- return expected > 0
141
- ? Number(((expected - available) * sdk_gov_1.PERCENTAGE_FACTOR) / expected) /
142
- Number(sdk_gov_1.PERCENTAGE_DECIMALS)
143
- : 0;
140
+ if (expected === 0n)
141
+ return 0;
142
+ const borrowed = expected - available;
143
+ const u = Number((borrowed * sdk_gov_1.PERCENTAGE_FACTOR) / expected) /
144
+ Number(sdk_gov_1.PERCENTAGE_DECIMALS);
145
+ return Math.max(0, u);
144
146
  }
145
147
  }
146
148
  exports.PoolData = PoolData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.217",
3
+ "version": "3.0.0-next.219",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@gearbox-protocol/bots-v3": "^1.5.1",
32
- "@gearbox-protocol/sdk-gov": "^2.15.1",
32
+ "@gearbox-protocol/sdk-gov": "^2.18.0",
33
33
  "@wagmi/cli": "^2.1.13",
34
34
  "axios": "^1.2.6",
35
35
  "decimal.js-light": "^2.5.1",