@gearbox-protocol/sdk 3.0.0-vfour.345 → 3.0.0-vfour.346

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.
@@ -26,7 +26,6 @@ var import_constants = require("../../constants/index.js");
26
26
  var import_utils = require("../../utils/index.js");
27
27
  class CreditManagerData_Legacy {
28
28
  address;
29
- type;
30
29
  underlyingToken;
31
30
  pool;
32
31
  creditFacade;
@@ -43,7 +42,6 @@ class CreditManagerData_Legacy {
43
42
  isBorrowingForbidden;
44
43
  maxEnabledTokensLength;
45
44
  name;
46
- tier;
47
45
  marketConfigurator;
48
46
  baseBorrowRate;
49
47
  minDebt;
@@ -59,6 +57,7 @@ class CreditManagerData_Legacy {
59
57
  collateralTokens = [];
60
58
  supportedTokens = {};
61
59
  usableTokens = {};
60
+ forbiddenTokens = {};
62
61
  adapters = {};
63
62
  contractsByAdapter = {};
64
63
  liquidationThresholds;
@@ -66,10 +65,8 @@ class CreditManagerData_Legacy {
66
65
  constructor(payload) {
67
66
  this.address = payload.addr.toLowerCase();
68
67
  this.underlyingToken = payload.underlying.toLowerCase();
69
- this.type = CreditManagerData_Legacy.getType(payload.name || "");
70
68
  this.name = payload.name;
71
69
  this.pool = payload.pool.toLowerCase();
72
- this.tier = CreditManagerData_Legacy.getTier(payload.name);
73
70
  this.creditFacade = payload.creditFacade.toLowerCase();
74
71
  this.creditConfigurator = payload.creditConfigurator.toLowerCase();
75
72
  this.degenNFT = payload.degenNFT.toLowerCase();
@@ -126,12 +123,15 @@ class CreditManagerData_Legacy {
126
123
  },
127
124
  {}
128
125
  );
129
- payload.collateralTokens.forEach((t) => {
126
+ payload.collateralTokens.forEach((t, index) => {
130
127
  const tLc = t.toLowerCase();
128
+ const mask = BigInt(1 << index);
129
+ const isForbidden = (mask & payload.forbiddenTokenMask) !== 0n;
131
130
  const zeroLt = this.liquidationThresholds[tLc] === 0n;
132
131
  const quotaNotActive = this.quotas[tLc]?.isActive === false;
133
- const allowed = !zeroLt && !quotaNotActive;
132
+ const allowed = !zeroLt && !quotaNotActive && !isForbidden;
134
133
  if (allowed) this.usableTokens[tLc] = true;
134
+ if (isForbidden) this.forbiddenTokens[tLc] = true;
135
135
  this.collateralTokens.push(tLc);
136
136
  this.supportedTokens[tLc] = true;
137
137
  });
@@ -139,22 +139,8 @@ class CreditManagerData_Legacy {
139
139
  isQuoted(token) {
140
140
  return !!this.quotas[token];
141
141
  }
142
- static getTier(name) {
143
- const DEFAULT_TIER = 99;
144
- const l = name.split(" ") || [];
145
- const index = l.findIndex((w) => w.toLowerCase() === "tier");
146
- if (index < 0) return DEFAULT_TIER;
147
- const number = l[index + 1];
148
- const n = Number(number || DEFAULT_TIER);
149
- return Number.isNaN(n) ? DEFAULT_TIER : n;
150
- }
151
- static getType(name) {
152
- const [identity = ""] = name.split(" ") || [];
153
- const lc = identity.toLowerCase();
154
- if (lc === "farm") return "farm";
155
- if (lc === "trade") return "trade";
156
- if (lc === "restaking") return "restaking";
157
- return "universal";
142
+ isForbidden(token) {
143
+ return !!this.forbiddenTokens[token];
158
144
  }
159
145
  }
160
146
  class ChartsCreditManagerData {
@@ -165,7 +151,6 @@ class ChartsCreditManagerData {
165
151
  pool;
166
152
  version;
167
153
  name;
168
- tier;
169
154
  borrowRate;
170
155
  borrowRateOld;
171
156
  borrowRateChange;
@@ -210,7 +195,6 @@ class ChartsCreditManagerData {
210
195
  this.pool = (payload.poolAddress || "").toLowerCase();
211
196
  this.version = payload.version || 2;
212
197
  this.name = payload.name || "";
213
- this.tier = CreditManagerData_Legacy.getTier(payload.name || "");
214
198
  this.borrowRate = Number(
215
199
  (0, import_utils.toBigInt)(payload.borrowRate || 0) * ((0, import_utils.toBigInt)(payload.feeInterest || 0) + import_constants.PERCENTAGE_FACTOR) * import_constants.PERCENTAGE_DECIMALS / import_constants.RAY
216
200
  );
@@ -6,7 +6,6 @@ import {
6
6
  import { toBigInt } from "../../utils/index.js";
7
7
  class CreditManagerData_Legacy {
8
8
  address;
9
- type;
10
9
  underlyingToken;
11
10
  pool;
12
11
  creditFacade;
@@ -23,7 +22,6 @@ class CreditManagerData_Legacy {
23
22
  isBorrowingForbidden;
24
23
  maxEnabledTokensLength;
25
24
  name;
26
- tier;
27
25
  marketConfigurator;
28
26
  baseBorrowRate;
29
27
  minDebt;
@@ -39,6 +37,7 @@ class CreditManagerData_Legacy {
39
37
  collateralTokens = [];
40
38
  supportedTokens = {};
41
39
  usableTokens = {};
40
+ forbiddenTokens = {};
42
41
  adapters = {};
43
42
  contractsByAdapter = {};
44
43
  liquidationThresholds;
@@ -46,10 +45,8 @@ class CreditManagerData_Legacy {
46
45
  constructor(payload) {
47
46
  this.address = payload.addr.toLowerCase();
48
47
  this.underlyingToken = payload.underlying.toLowerCase();
49
- this.type = CreditManagerData_Legacy.getType(payload.name || "");
50
48
  this.name = payload.name;
51
49
  this.pool = payload.pool.toLowerCase();
52
- this.tier = CreditManagerData_Legacy.getTier(payload.name);
53
50
  this.creditFacade = payload.creditFacade.toLowerCase();
54
51
  this.creditConfigurator = payload.creditConfigurator.toLowerCase();
55
52
  this.degenNFT = payload.degenNFT.toLowerCase();
@@ -106,12 +103,15 @@ class CreditManagerData_Legacy {
106
103
  },
107
104
  {}
108
105
  );
109
- payload.collateralTokens.forEach((t) => {
106
+ payload.collateralTokens.forEach((t, index) => {
110
107
  const tLc = t.toLowerCase();
108
+ const mask = BigInt(1 << index);
109
+ const isForbidden = (mask & payload.forbiddenTokenMask) !== 0n;
111
110
  const zeroLt = this.liquidationThresholds[tLc] === 0n;
112
111
  const quotaNotActive = this.quotas[tLc]?.isActive === false;
113
- const allowed = !zeroLt && !quotaNotActive;
112
+ const allowed = !zeroLt && !quotaNotActive && !isForbidden;
114
113
  if (allowed) this.usableTokens[tLc] = true;
114
+ if (isForbidden) this.forbiddenTokens[tLc] = true;
115
115
  this.collateralTokens.push(tLc);
116
116
  this.supportedTokens[tLc] = true;
117
117
  });
@@ -119,22 +119,8 @@ class CreditManagerData_Legacy {
119
119
  isQuoted(token) {
120
120
  return !!this.quotas[token];
121
121
  }
122
- static getTier(name) {
123
- const DEFAULT_TIER = 99;
124
- const l = name.split(" ") || [];
125
- const index = l.findIndex((w) => w.toLowerCase() === "tier");
126
- if (index < 0) return DEFAULT_TIER;
127
- const number = l[index + 1];
128
- const n = Number(number || DEFAULT_TIER);
129
- return Number.isNaN(n) ? DEFAULT_TIER : n;
130
- }
131
- static getType(name) {
132
- const [identity = ""] = name.split(" ") || [];
133
- const lc = identity.toLowerCase();
134
- if (lc === "farm") return "farm";
135
- if (lc === "trade") return "trade";
136
- if (lc === "restaking") return "restaking";
137
- return "universal";
122
+ isForbidden(token) {
123
+ return !!this.forbiddenTokens[token];
138
124
  }
139
125
  }
140
126
  class ChartsCreditManagerData {
@@ -145,7 +131,6 @@ class ChartsCreditManagerData {
145
131
  pool;
146
132
  version;
147
133
  name;
148
- tier;
149
134
  borrowRate;
150
135
  borrowRateOld;
151
136
  borrowRateChange;
@@ -190,7 +175,6 @@ class ChartsCreditManagerData {
190
175
  this.pool = (payload.poolAddress || "").toLowerCase();
191
176
  this.version = payload.version || 2;
192
177
  this.name = payload.name || "";
193
- this.tier = CreditManagerData_Legacy.getTier(payload.name || "");
194
178
  this.borrowRate = Number(
195
179
  toBigInt(payload.borrowRate || 0) * (toBigInt(payload.feeInterest || 0) + PERCENTAGE_FACTOR) * PERCENTAGE_DECIMALS / RAY
196
180
  );
@@ -1,9 +1,7 @@
1
1
  import type { Address } from "viem";
2
2
  import type { ChartsCreditManagerPayload, CreditManagerDataPayload, QuotaInfo } from "../payload/creditManager.js";
3
- export type CreditManagerType = "universal" | "trade" | "farm" | "restaking";
4
3
  export declare class CreditManagerData_Legacy {
5
4
  readonly address: Address;
6
- readonly type: CreditManagerType;
7
5
  readonly underlyingToken: Address;
8
6
  readonly pool: Address;
9
7
  readonly creditFacade: Address;
@@ -16,7 +14,6 @@ export declare class CreditManagerData_Legacy {
16
14
  readonly isBorrowingForbidden: boolean;
17
15
  readonly maxEnabledTokensLength: number;
18
16
  readonly name: string;
19
- readonly tier: number;
20
17
  readonly marketConfigurator: Address;
21
18
  readonly baseBorrowRate: number;
22
19
  readonly minDebt: bigint;
@@ -32,14 +29,14 @@ export declare class CreditManagerData_Legacy {
32
29
  readonly collateralTokens: Array<Address>;
33
30
  readonly supportedTokens: Record<Address, true>;
34
31
  readonly usableTokens: Record<Address, true>;
32
+ readonly forbiddenTokens: Record<Address, true>;
35
33
  readonly adapters: Record<Address, CreditManagerDataPayload["adapters"][1]>;
36
34
  readonly contractsByAdapter: Record<Address, Address>;
37
35
  readonly liquidationThresholds: Record<Address, bigint>;
38
36
  readonly quotas: Record<Address, QuotaInfo>;
39
37
  constructor(payload: CreditManagerDataPayload);
40
38
  isQuoted(token: Address): boolean;
41
- static getTier(name: string): number;
42
- static getType(name: string): CreditManagerType;
39
+ isForbidden(token: Address): boolean;
43
40
  }
44
41
  export declare class ChartsCreditManagerData {
45
42
  readonly address: Address;
@@ -49,7 +46,6 @@ export declare class ChartsCreditManagerData {
49
46
  readonly pool: Address;
50
47
  readonly version: number;
51
48
  readonly name: string;
52
- readonly tier: number;
53
49
  readonly borrowRate: number;
54
50
  readonly borrowRateOld: number;
55
51
  readonly borrowRateChange: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfour.345",
3
+ "version": "3.0.0-vfour.346",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",