@gearbox-protocol/sdk 3.0.0-next.185 → 3.0.0-next.187

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,13 +1,16 @@
1
1
  import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  type AdditionalTokensWithAPY = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH">;
3
3
  type AdditionalLPTokens = Extract<SupportedToken, "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH">;
4
- export declare const isAdditionalLPToken: (t: unknown) => t is AdditionalLPTokens;
4
+ type ExtraFarmTokens = AdditionalTokensWithAPY | AdditionalLPTokens;
5
+ export type LRTAndLSDTokens = Extract<ExtraFarmTokens, "weETH" | "rsETH" | "rswETH" | "pufETH" | "ezETH" | "STETH" | "wstETH" | "sfrxETH" | "osETH" | "cbETH" | "rETH">;
5
6
  export type TokensWithAPY = LPTokens | AdditionalTokensWithAPY;
6
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;
7
11
  export declare const isAdditionalTokenWithAPY: (t: unknown) => t is AdditionalTokensWithAPY;
8
- export declare const isExtraFarmToken: (t: unknown) => boolean;
12
+ export declare const isExtraFarmToken: (t: unknown) => t is ExtraFarmTokens;
9
13
  export declare const isTokenWithAPY: (t: unknown) => t is TokensWithAPY;
10
- export type AllLPTokens = LPTokens | AdditionalLPTokens | AdditionalTokensWithAPY;
11
14
  export declare const isFarmToken: (t: unknown) => t is AllLPTokens;
12
15
  export * from "./convexAPY";
13
16
  export * from "./curveAPY";
package/lib/apy/index.js CHANGED
@@ -14,7 +14,7 @@ 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 = void 0;
17
+ exports.isFarmToken = exports.isTokenWithAPY = exports.isExtraFarmToken = exports.isAdditionalTokenWithAPY = exports.isAdditionalLPToken = exports.isLRT_LSDToken = void 0;
18
18
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
19
19
  const ADDITIONAL_LP_TOKENS = {
20
20
  weETH: true,
@@ -33,6 +33,25 @@ const TOKENS_WITH_APY = {
33
33
  cbETH: true,
34
34
  sfrxETH: true,
35
35
  };
36
+ const LRT_LSD = {
37
+ weETH: true,
38
+ rsETH: true,
39
+ rswETH: true,
40
+ pufETH: true,
41
+ ezETH: true,
42
+ STETH: true,
43
+ wstETH: true,
44
+ sfrxETH: true,
45
+ osETH: true,
46
+ cbETH: true,
47
+ rETH: true,
48
+ };
49
+ const isLRT_LSDToken = (t) => {
50
+ if (typeof t !== "string")
51
+ return false;
52
+ return !!LRT_LSD[t];
53
+ };
54
+ exports.isLRT_LSDToken = isLRT_LSDToken;
36
55
  const isAdditionalLPToken = (t) => {
37
56
  if (typeof t !== "string")
38
57
  return false;
@@ -138,6 +138,7 @@ interface TxOpenMultitokenAccountProps extends EVMTxProps {
138
138
  creditManagerName?: string;
139
139
  underlyingToken: string;
140
140
  assets: Array<string>;
141
+ withdrawDebt: boolean;
141
142
  }
142
143
  export declare class TxOpenMultitokenAccount extends EVMTx implements CMEvent {
143
144
  readonly borrowedAmount: bigint;
@@ -145,6 +146,7 @@ export declare class TxOpenMultitokenAccount extends EVMTx implements CMEvent {
145
146
  readonly creditManagerName?: string;
146
147
  readonly underlyingToken: string;
147
148
  readonly assets: Array<string>;
149
+ readonly withdrawDebt: boolean;
148
150
  constructor(opts: TxOpenMultitokenAccountProps);
149
151
  toString(): string;
150
152
  serialize(): TxSerialized;
@@ -260,6 +260,7 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
260
260
  creditManagerName;
261
261
  underlyingToken;
262
262
  assets;
263
+ withdrawDebt;
263
264
  constructor(opts) {
264
265
  super(opts);
265
266
  this.borrowedAmount = opts.borrowedAmount;
@@ -267,16 +268,25 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
267
268
  this.creditManager = opts.creditManager;
268
269
  this.creditManagerName = opts.creditManagerName;
269
270
  this.assets = opts.assets;
271
+ this.withdrawDebt = opts.withdrawDebt;
270
272
  }
271
273
  toString() {
272
274
  const assetSymbols = this.assets.reduce((acc, assetAddress) => {
273
275
  const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(assetAddress);
274
- if (tokenSymbol)
276
+ const skip = this.withdrawDebt && this.underlyingToken === assetAddress;
277
+ if (!skip && tokenSymbol)
275
278
  acc.push(tokenSymbol);
276
279
  return acc;
277
280
  }, []);
281
+ const name = this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager);
278
282
  const [symbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
279
- return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, sdk_gov_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
283
+ const borrowedAmount = `${(0, sdk_gov_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}`;
284
+ const assets = assetSymbols.join(", ");
285
+ const withdraw = this.withdrawDebt ? [`Withdrawn: ${borrowedAmount}`] : [];
286
+ return [
287
+ `Credit Account ${name}: opening. Borrowed amount: ${borrowedAmount}; assets: ${assets}`,
288
+ ...withdraw,
289
+ ].join("; ");
280
290
  }
281
291
  serialize() {
282
292
  return {
@@ -14,6 +14,7 @@ const apy_1 = require("./apy");
14
14
  const POOL_POINTS = {
15
15
  Mainnet: {
16
16
  [contractsRegister_1.poolByNetwork.Mainnet.WETH_V3_TRADE]: {
17
+ // !& ezeth
17
18
  // ezETH: {
18
19
  // amount: PERCENTAGE_FACTOR,
19
20
  // symbol: "ezETH",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.185",
3
+ "version": "3.0.0-next.187",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@gearbox-protocol/bots-v3": "^1.5.1",
34
- "@gearbox-protocol/sdk-gov": "^2.2.5",
34
+ "@gearbox-protocol/sdk-gov": "^2.2.8",
35
35
  "axios": "^1.2.6",
36
36
  "decimal.js-light": "^2.5.1",
37
37
  "deep-eql": "^4.1.0",