@gearbox-protocol/sdk 3.0.0-prevfour.15 → 3.0.0-prevfour.16
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,6 +1,5 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import { ChartsCreditManagerPayload, CreditManagerDataPayload, QuotaInfo } from "../payload/creditManager";
|
|
3
|
-
import { LinearModel } from "../payload/pool";
|
|
4
3
|
export type CreditManagerType = "universal" | "trade" | "farm" | "restaking";
|
|
5
4
|
export declare class CreditManagerData {
|
|
6
5
|
readonly address: Address;
|
|
@@ -32,11 +31,10 @@ export declare class CreditManagerData {
|
|
|
32
31
|
readonly collateralTokens: Array<Address>;
|
|
33
32
|
readonly supportedTokens: Record<Address, true>;
|
|
34
33
|
readonly usableTokens: Record<Address, true>;
|
|
35
|
-
readonly adapters: Record<Address,
|
|
34
|
+
readonly adapters: Record<Address, CreditManagerDataPayload["adapters"][1]>;
|
|
36
35
|
readonly contractsByAdapter: Record<Address, Address>;
|
|
37
36
|
readonly liquidationThresholds: Record<Address, bigint>;
|
|
38
37
|
readonly quotas: Record<Address, QuotaInfo>;
|
|
39
|
-
readonly interestModel: LinearModel;
|
|
40
38
|
constructor(payload: CreditManagerDataPayload);
|
|
41
39
|
isQuoted(token: Address): boolean;
|
|
42
40
|
static getTier(name: string): number;
|
|
@@ -36,7 +36,6 @@ class CreditManagerData {
|
|
|
36
36
|
contractsByAdapter = {};
|
|
37
37
|
liquidationThresholds;
|
|
38
38
|
quotas;
|
|
39
|
-
interestModel;
|
|
40
39
|
constructor(payload) {
|
|
41
40
|
this.address = payload.addr.toLowerCase();
|
|
42
41
|
this.underlyingToken = payload.underlying.toLowerCase();
|
|
@@ -70,14 +69,18 @@ class CreditManagerData {
|
|
|
70
69
|
this.liquidationDiscountExpired = Number(payload.liquidationDiscountExpired);
|
|
71
70
|
payload.adapters.forEach(a => {
|
|
72
71
|
const contractLc = a.targetContract.toLowerCase();
|
|
73
|
-
const
|
|
74
|
-
this.adapters[contractLc] =
|
|
75
|
-
|
|
72
|
+
const adapterLc = a.address.toLowerCase();
|
|
73
|
+
this.adapters[contractLc] = {
|
|
74
|
+
address: adapterLc,
|
|
75
|
+
contractType: a.contractType,
|
|
76
|
+
version: a.version,
|
|
77
|
+
name: a.name,
|
|
78
|
+
targetContract: contractLc,
|
|
79
|
+
};
|
|
80
|
+
this.contractsByAdapter[adapterLc] = contractLc;
|
|
76
81
|
});
|
|
77
|
-
this.liquidationThresholds = payload.liquidationThresholds.reduce((acc,
|
|
78
|
-
|
|
79
|
-
if (address)
|
|
80
|
-
acc[address.toLowerCase()] = threshold;
|
|
82
|
+
this.liquidationThresholds = payload.liquidationThresholds.reduce((acc, [token, threshold]) => {
|
|
83
|
+
acc[token.toLowerCase()] = BigInt(threshold);
|
|
81
84
|
return acc;
|
|
82
85
|
}, {});
|
|
83
86
|
this.quotas = payload.quotas.reduce((acc, q) => {
|
|
@@ -92,17 +95,6 @@ class CreditManagerData {
|
|
|
92
95
|
};
|
|
93
96
|
return acc;
|
|
94
97
|
}, {});
|
|
95
|
-
this.interestModel = {
|
|
96
|
-
interestModel: payload.lirm.interestModel.toLowerCase(),
|
|
97
|
-
U_1: BigInt(payload.lirm.U_1),
|
|
98
|
-
U_2: BigInt(payload.lirm.U_2),
|
|
99
|
-
R_base: BigInt(payload.lirm.R_base),
|
|
100
|
-
R_slope1: BigInt(payload.lirm.R_slope1),
|
|
101
|
-
R_slope2: BigInt(payload.lirm.R_slope2),
|
|
102
|
-
R_slope3: BigInt(payload.lirm.R_slope3),
|
|
103
|
-
version: Number(payload?.lirm?.version),
|
|
104
|
-
isBorrowingMoreU2Forbidden: payload?.lirm?.isBorrowingMoreU2Forbidden,
|
|
105
|
-
};
|
|
106
98
|
payload.collateralTokens.forEach(t => {
|
|
107
99
|
const tLc = t.toLowerCase();
|
|
108
100
|
const zeroLt = this.liquidationThresholds[tLc] === 0n;
|
|
@@ -48,7 +48,7 @@ class RewardConvex {
|
|
|
48
48
|
return Object.entries(cm.adapters)
|
|
49
49
|
.filter(([contract]) => !!convexPools[sdk_gov_1.contractsByAddress[contract.toLowerCase()]])
|
|
50
50
|
.map(([contract, adapter]) => ({
|
|
51
|
-
adapter,
|
|
51
|
+
adapter: adapter.address,
|
|
52
52
|
contractAddress: contract,
|
|
53
53
|
contract: sdk_gov_1.contractsByAddress[contract.toLowerCase()],
|
|
54
54
|
}));
|
|
@@ -49,7 +49,7 @@ class StakingRewards {
|
|
|
49
49
|
return Object.entries(cm.adapters)
|
|
50
50
|
.filter(([contract]) => !!contractsRecord[sdk_gov_1.contractsByAddress[contract.toLowerCase()]])
|
|
51
51
|
.map(([contract, adapter]) => ({
|
|
52
|
-
adapter,
|
|
52
|
+
adapter: adapter.address,
|
|
53
53
|
contractAddress: contract,
|
|
54
54
|
contract: sdk_gov_1.contractsByAddress[contract.toLowerCase()],
|
|
55
55
|
}));
|
|
@@ -15,6 +15,15 @@ export interface QuotaInfo {
|
|
|
15
15
|
limit: bigint;
|
|
16
16
|
isActive: boolean;
|
|
17
17
|
}
|
|
18
|
+
interface IBaseContract {
|
|
19
|
+
address: Address;
|
|
20
|
+
contractType: string;
|
|
21
|
+
version: number;
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
interface IAdapterContract extends IBaseContract {
|
|
25
|
+
targetContract: Address;
|
|
26
|
+
}
|
|
18
27
|
export interface CreditManagerDataPayload {
|
|
19
28
|
addr: Address;
|
|
20
29
|
name: string;
|
|
@@ -34,11 +43,8 @@ export interface CreditManagerDataPayload {
|
|
|
34
43
|
forbiddenTokenMask: bigint;
|
|
35
44
|
isPaused: boolean;
|
|
36
45
|
collateralTokens: readonly Address[];
|
|
37
|
-
adapters:
|
|
38
|
-
|
|
39
|
-
adapter: Address;
|
|
40
|
-
}[];
|
|
41
|
-
liquidationThresholds: readonly bigint[];
|
|
46
|
+
adapters: Array<IAdapterContract>;
|
|
47
|
+
liquidationThresholds: Array<[token: Address, lt: number]>;
|
|
42
48
|
maxEnabledTokensLength: number;
|
|
43
49
|
feeInterest: number;
|
|
44
50
|
feeLiquidation: number;
|
|
@@ -46,7 +52,6 @@ export interface CreditManagerDataPayload {
|
|
|
46
52
|
feeLiquidationExpired: number;
|
|
47
53
|
liquidationDiscountExpired: number;
|
|
48
54
|
quotas: PoolDataPayload["quotas"];
|
|
49
|
-
lirm: PoolDataPayload["lirm"];
|
|
50
55
|
isBorrowingForbidden: boolean;
|
|
51
56
|
}
|
|
52
57
|
export interface ChartsCreditManagerPayload {
|
|
@@ -96,3 +101,4 @@ export interface ChartsCreditManagerPayload {
|
|
|
96
101
|
liquidityThresholds: Record<Address, number>;
|
|
97
102
|
totalDebtLimit: BigNumberish;
|
|
98
103
|
}
|
|
104
|
+
export {};
|