@gearbox-protocol/sdk 3.0.0-next.152 → 3.0.0-next.153
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.
- package/lib/core/pool.d.ts +2 -0
- package/lib/core/pool.js +16 -9
- package/package.json +1 -1
package/lib/core/pool.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare class PoolData {
|
|
|
19
19
|
readonly expectedLiquidityLimit: bigint;
|
|
20
20
|
readonly availableLiquidity: bigint;
|
|
21
21
|
readonly baseInterestIndex: bigint;
|
|
22
|
+
readonly utilization: number;
|
|
22
23
|
readonly totalBorrowed: bigint;
|
|
23
24
|
readonly totalDebtLimit: bigint;
|
|
24
25
|
readonly creditManagerDebtParams: Record<string, CreditManagerDebtParams>;
|
|
@@ -39,6 +40,7 @@ export declare class PoolData {
|
|
|
39
40
|
getPoolContractV3(signer: Signer): IPoolV3;
|
|
40
41
|
calculateBorrowRate({ provider, expectedLiquidity, availableLiquidity, }: CalculateBorrowRateProps): Promise<import("ethers").BigNumber>;
|
|
41
42
|
static getPoolType(name: string): PoolType;
|
|
43
|
+
static calculateUtilization(expected: bigint, available: bigint): number;
|
|
42
44
|
}
|
|
43
45
|
interface CalculateBorrowRateProps {
|
|
44
46
|
provider: providers.Provider;
|
package/lib/core/pool.js
CHANGED
|
@@ -21,6 +21,7 @@ class PoolData {
|
|
|
21
21
|
expectedLiquidityLimit;
|
|
22
22
|
availableLiquidity;
|
|
23
23
|
baseInterestIndex;
|
|
24
|
+
utilization;
|
|
24
25
|
totalBorrowed;
|
|
25
26
|
totalDebtLimit;
|
|
26
27
|
creditManagerDebtParams;
|
|
@@ -48,11 +49,14 @@ class PoolData {
|
|
|
48
49
|
this.gauge = payload.gauge.toLowerCase();
|
|
49
50
|
this.name = payload.name;
|
|
50
51
|
this.symbol = payload.symbol;
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
const expected = (0, sdk_gov_1.toBigInt)(payload.expectedLiquidity);
|
|
53
|
+
const available = (0, sdk_gov_1.toBigInt)(payload.availableLiquidity);
|
|
54
|
+
this.expectedLiquidity = expected;
|
|
55
|
+
this.availableLiquidity = available;
|
|
53
56
|
this.expectedLiquidityLimit =
|
|
54
57
|
this.expectedLiquidity + this.availableLiquidity;
|
|
55
58
|
this.baseInterestIndex = (0, sdk_gov_1.toBigInt)(payload.baseInterestIndex);
|
|
59
|
+
this.utilization = PoolData.calculateUtilization(expected, available);
|
|
56
60
|
this.totalBorrowed = (0, sdk_gov_1.toBigInt)(payload.totalBorrowed);
|
|
57
61
|
this.totalDebtLimit = (0, sdk_gov_1.toBigInt)(payload.totalDebtLimit);
|
|
58
62
|
this.creditManagerDebtParams = Object.fromEntries(payload.creditManagerDebtParams.map(p => {
|
|
@@ -134,6 +138,12 @@ class PoolData {
|
|
|
134
138
|
return "trade";
|
|
135
139
|
return "universal";
|
|
136
140
|
}
|
|
141
|
+
static calculateUtilization(expected, available) {
|
|
142
|
+
return expected > 0
|
|
143
|
+
? Number(((expected - available) * sdk_gov_1.PERCENTAGE_FACTOR) / expected) /
|
|
144
|
+
Number(sdk_gov_1.PERCENTAGE_DECIMALS)
|
|
145
|
+
: 0;
|
|
146
|
+
}
|
|
137
147
|
}
|
|
138
148
|
exports.PoolData = PoolData;
|
|
139
149
|
class ChartsPoolData {
|
|
@@ -197,12 +207,6 @@ class ChartsPoolData {
|
|
|
197
207
|
this.name = payload.name || "";
|
|
198
208
|
this.earned7D = payload.earned7D || 0;
|
|
199
209
|
this.earned7DInUSD = payload.earned7DInUSD || 0;
|
|
200
|
-
const expected = (0, sdk_gov_1.toBigInt)(payload.expectedLiquidity || 0);
|
|
201
|
-
this.utilization =
|
|
202
|
-
expected > 0
|
|
203
|
-
? Number(((0, sdk_gov_1.toBigInt)(payload.totalBorrowed || 0) * sdk_gov_1.PERCENTAGE_FACTOR) /
|
|
204
|
-
expected) / Number(sdk_gov_1.PERCENTAGE_DECIMALS)
|
|
205
|
-
: 0;
|
|
206
210
|
this.dieselRate = (0, formatter_1.rayToNumber)(payload.dieselRate_RAY || 0);
|
|
207
211
|
this.dieselRateRay = (0, sdk_gov_1.toBigInt)(payload.dieselRate_RAY || 0);
|
|
208
212
|
this.depositAPY =
|
|
@@ -212,11 +216,14 @@ class ChartsPoolData {
|
|
|
212
216
|
(0, formatter_1.rayToNumber)(payload.borrowAPY_RAY || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
213
217
|
this.borrowAPYRay = (0, sdk_gov_1.toBigInt)(payload.borrowAPY_RAY || 0);
|
|
214
218
|
this.lmAPY = (payload.lmAPY || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
215
|
-
|
|
219
|
+
const expected = (0, sdk_gov_1.toBigInt)(payload.expectedLiquidity || 0);
|
|
220
|
+
const available = (0, sdk_gov_1.toBigInt)(payload.availableLiquidity || 0);
|
|
221
|
+
this.availableLiquidity = available;
|
|
216
222
|
this.oldAvailableLiquidity = (0, sdk_gov_1.toBigInt)(payload.availableLiquidityOld || 0);
|
|
217
223
|
this.availableLiquidityChange =
|
|
218
224
|
(payload.availableLiquidity10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
219
225
|
this.availableLiquidityInUSD = payload.availableLiquidityInUSD || 0;
|
|
226
|
+
this.utilization = PoolData.calculateUtilization(expected, available);
|
|
220
227
|
this.caLockedValue = payload.caLockedValue || 0;
|
|
221
228
|
this.oldCALockedValue = payload.caLockedValueOld || 0;
|
|
222
229
|
this.caLockedValueChange =
|