@kamino-finance/klend-sdk 7.3.10-beta.0 → 7.4.0-beta.0
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/dist/@codegen/klend/accounts/LendingMarket.d.ts +51 -3
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +39 -6
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +24 -15
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +24 -21
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +1 -1
- package/dist/@codegen/klend/accounts/UserState.d.ts +0 -75
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +0 -25
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +89 -1
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +155 -1
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +36 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +49 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +0 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +0 -2
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +4 -0
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +6 -1
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +33 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +66 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +192 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.js +194 -0
- package/dist/@codegen/klend/types/BorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +39 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +100 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +35 -5
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +17 -7
- package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
- package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
- package/dist/@codegen/klend/types/ReserveConfig.d.ts +60 -5
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +36 -7
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +33 -7
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +61 -13
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +52 -0
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +97 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/index.d.ts +8 -8
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +5 -3
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +8 -5
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +17 -14
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +11 -20
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/configItems.d.ts +1 -6
- package/dist/classes/configItems.d.ts.map +1 -1
- package/dist/classes/configItems.js +1 -93
- package/dist/classes/configItems.js.map +1 -1
- package/dist/classes/farm_utils.d.ts +1 -1
- package/dist/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +3 -1
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +4 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +6 -0
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +8 -0
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +7 -3
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +34 -44
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -2
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +28 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +103 -6
- package/dist/classes/vault.js.map +1 -1
- package/dist/classes/vault_types.d.ts +2 -1
- package/dist/classes/vault_types.d.ts.map +1 -1
- package/dist/idl/klend.json +581 -54
- package/dist/manager/client_kamino_manager.js +12 -6
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/Logger.d.ts +14 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +12 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/api.d.ts +13 -4
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +33 -31
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +3 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +79 -8
- package/src/@codegen/klend/accounts/Obligation.ts +42 -31
- package/src/@codegen/klend/accounts/Reserve.ts +1 -1
- package/src/@codegen/klend/accounts/UserState.ts +0 -75
- package/src/@codegen/klend/errors/custom.ts +172 -0
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +96 -0
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +0 -3
- package/src/@codegen/klend/instructions/index.ts +7 -0
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +81 -0
- package/src/@codegen/klend/types/BorrowOrder.ts +267 -0
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +87 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +39 -9
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +72 -9
- package/src/@codegen/klend/types/UpdateConfigMode.ts +73 -13
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +120 -0
- package/src/@codegen/klend/types/index.ts +21 -14
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +17 -14
- package/src/classes/action.ts +25 -25
- package/src/classes/configItems.ts +1 -99
- package/src/classes/farm_utils.ts +5 -1
- package/src/classes/manager.ts +5 -0
- package/src/classes/market.ts +16 -0
- package/src/classes/obligation.ts +1 -1
- package/src/classes/reserve.ts +120 -122
- package/src/classes/shared.ts +2 -2
- package/src/classes/vault.ts +160 -7
- package/src/classes/vault_types.ts +2 -1
- package/src/idl/klend.json +581 -54
- package/src/manager/client_kamino_manager.ts +12 -6
- package/src/utils/Logger.ts +14 -0
- package/src/utils/api.ts +56 -33
- package/src/utils/managerTypes.ts +3 -1
- package/dist/@codegen/klend/types/AssetTier.d.ts +0 -45
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +0 -1
- package/dist/@codegen/klend/types/AssetTier.js +0 -132
- package/dist/@codegen/klend/types/AssetTier.js.map +0 -1
- package/src/@codegen/klend/types/AssetTier.ts +0 -119
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
import { borshAddress } from "../utils"
|
|
6
|
+
|
|
7
|
+
export interface BorrowOrderConfigArgsFields {
|
|
8
|
+
remainingDebtAmount: BN
|
|
9
|
+
maxBorrowRateBps: number
|
|
10
|
+
minDebtTermSeconds: BN
|
|
11
|
+
fillableUntilTimestamp: BN
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface BorrowOrderConfigArgsJSON {
|
|
15
|
+
remainingDebtAmount: string
|
|
16
|
+
maxBorrowRateBps: number
|
|
17
|
+
minDebtTermSeconds: string
|
|
18
|
+
fillableUntilTimestamp: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A subset of [BorrowOrderConfig] excluding the accounts passed via [SetBorrowOrder]. */
|
|
22
|
+
export class BorrowOrderConfigArgs {
|
|
23
|
+
readonly remainingDebtAmount: BN
|
|
24
|
+
readonly maxBorrowRateBps: number
|
|
25
|
+
readonly minDebtTermSeconds: BN
|
|
26
|
+
readonly fillableUntilTimestamp: BN
|
|
27
|
+
|
|
28
|
+
constructor(fields: BorrowOrderConfigArgsFields) {
|
|
29
|
+
this.remainingDebtAmount = fields.remainingDebtAmount
|
|
30
|
+
this.maxBorrowRateBps = fields.maxBorrowRateBps
|
|
31
|
+
this.minDebtTermSeconds = fields.minDebtTermSeconds
|
|
32
|
+
this.fillableUntilTimestamp = fields.fillableUntilTimestamp
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static layout(property?: string) {
|
|
36
|
+
return borsh.struct(
|
|
37
|
+
[
|
|
38
|
+
borsh.u64("remainingDebtAmount"),
|
|
39
|
+
borsh.u32("maxBorrowRateBps"),
|
|
40
|
+
borsh.u64("minDebtTermSeconds"),
|
|
41
|
+
borsh.u64("fillableUntilTimestamp"),
|
|
42
|
+
],
|
|
43
|
+
property
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
static fromDecoded(obj: any) {
|
|
49
|
+
return new BorrowOrderConfigArgs({
|
|
50
|
+
remainingDebtAmount: obj.remainingDebtAmount,
|
|
51
|
+
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
52
|
+
minDebtTermSeconds: obj.minDebtTermSeconds,
|
|
53
|
+
fillableUntilTimestamp: obj.fillableUntilTimestamp,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static toEncodable(fields: BorrowOrderConfigArgsFields) {
|
|
58
|
+
return {
|
|
59
|
+
remainingDebtAmount: fields.remainingDebtAmount,
|
|
60
|
+
maxBorrowRateBps: fields.maxBorrowRateBps,
|
|
61
|
+
minDebtTermSeconds: fields.minDebtTermSeconds,
|
|
62
|
+
fillableUntilTimestamp: fields.fillableUntilTimestamp,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
toJSON(): BorrowOrderConfigArgsJSON {
|
|
67
|
+
return {
|
|
68
|
+
remainingDebtAmount: this.remainingDebtAmount.toString(),
|
|
69
|
+
maxBorrowRateBps: this.maxBorrowRateBps,
|
|
70
|
+
minDebtTermSeconds: this.minDebtTermSeconds.toString(),
|
|
71
|
+
fillableUntilTimestamp: this.fillableUntilTimestamp.toString(),
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static fromJSON(obj: BorrowOrderConfigArgsJSON): BorrowOrderConfigArgs {
|
|
76
|
+
return new BorrowOrderConfigArgs({
|
|
77
|
+
remainingDebtAmount: new BN(obj.remainingDebtAmount),
|
|
78
|
+
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
79
|
+
minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
|
|
80
|
+
fillableUntilTimestamp: new BN(obj.fillableUntilTimestamp),
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
toEncodable() {
|
|
85
|
+
return BorrowOrderConfigArgs.toEncodable(this)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -9,7 +9,17 @@ export interface ObligationLiquidityFields {
|
|
|
9
9
|
borrowReserve: Address
|
|
10
10
|
/** Borrow rate used for calculating interest (big scaled fraction) */
|
|
11
11
|
cumulativeBorrowRateBsf: types.BigFractionBytesFields
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The timestamp at which this debt was taken.
|
|
14
|
+
* More specifically: when the *first* borrow operation from this reserve happened.
|
|
15
|
+
* This means that:
|
|
16
|
+
* - adding debt of the same reserve does *not* change this timestamp,
|
|
17
|
+
* - repaying the entire debt of this reserve *does* reset this timestamp.
|
|
18
|
+
*
|
|
19
|
+
* Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
|
|
20
|
+
* fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
|
|
21
|
+
*/
|
|
22
|
+
firstBorrowedAtTimestamp: BN
|
|
13
23
|
/** Amount of liquidity borrowed plus interest (scaled fraction) */
|
|
14
24
|
borrowedAmountSf: BN
|
|
15
25
|
/** Liquidity market value in quote currency (scaled fraction) */
|
|
@@ -26,7 +36,17 @@ export interface ObligationLiquidityJSON {
|
|
|
26
36
|
borrowReserve: string
|
|
27
37
|
/** Borrow rate used for calculating interest (big scaled fraction) */
|
|
28
38
|
cumulativeBorrowRateBsf: types.BigFractionBytesJSON
|
|
29
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The timestamp at which this debt was taken.
|
|
41
|
+
* More specifically: when the *first* borrow operation from this reserve happened.
|
|
42
|
+
* This means that:
|
|
43
|
+
* - adding debt of the same reserve does *not* change this timestamp,
|
|
44
|
+
* - repaying the entire debt of this reserve *does* reset this timestamp.
|
|
45
|
+
*
|
|
46
|
+
* Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
|
|
47
|
+
* fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
|
|
48
|
+
*/
|
|
49
|
+
firstBorrowedAtTimestamp: string
|
|
30
50
|
/** Amount of liquidity borrowed plus interest (scaled fraction) */
|
|
31
51
|
borrowedAmountSf: string
|
|
32
52
|
/** Liquidity market value in quote currency (scaled fraction) */
|
|
@@ -44,7 +64,17 @@ export class ObligationLiquidity {
|
|
|
44
64
|
readonly borrowReserve: Address
|
|
45
65
|
/** Borrow rate used for calculating interest (big scaled fraction) */
|
|
46
66
|
readonly cumulativeBorrowRateBsf: types.BigFractionBytes
|
|
47
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The timestamp at which this debt was taken.
|
|
69
|
+
* More specifically: when the *first* borrow operation from this reserve happened.
|
|
70
|
+
* This means that:
|
|
71
|
+
* - adding debt of the same reserve does *not* change this timestamp,
|
|
72
|
+
* - repaying the entire debt of this reserve *does* reset this timestamp.
|
|
73
|
+
*
|
|
74
|
+
* Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
|
|
75
|
+
* fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
|
|
76
|
+
*/
|
|
77
|
+
readonly firstBorrowedAtTimestamp: BN
|
|
48
78
|
/** Amount of liquidity borrowed plus interest (scaled fraction) */
|
|
49
79
|
readonly borrowedAmountSf: BN
|
|
50
80
|
/** Liquidity market value in quote currency (scaled fraction) */
|
|
@@ -60,7 +90,7 @@ export class ObligationLiquidity {
|
|
|
60
90
|
this.cumulativeBorrowRateBsf = new types.BigFractionBytes({
|
|
61
91
|
...fields.cumulativeBorrowRateBsf,
|
|
62
92
|
})
|
|
63
|
-
this.
|
|
93
|
+
this.firstBorrowedAtTimestamp = fields.firstBorrowedAtTimestamp
|
|
64
94
|
this.borrowedAmountSf = fields.borrowedAmountSf
|
|
65
95
|
this.marketValueSf = fields.marketValueSf
|
|
66
96
|
this.borrowFactorAdjustedMarketValueSf =
|
|
@@ -75,7 +105,7 @@ export class ObligationLiquidity {
|
|
|
75
105
|
[
|
|
76
106
|
borshAddress("borrowReserve"),
|
|
77
107
|
types.BigFractionBytes.layout("cumulativeBorrowRateBsf"),
|
|
78
|
-
borsh.u64("
|
|
108
|
+
borsh.u64("firstBorrowedAtTimestamp"),
|
|
79
109
|
borsh.u128("borrowedAmountSf"),
|
|
80
110
|
borsh.u128("marketValueSf"),
|
|
81
111
|
borsh.u128("borrowFactorAdjustedMarketValueSf"),
|
|
@@ -93,7 +123,7 @@ export class ObligationLiquidity {
|
|
|
93
123
|
cumulativeBorrowRateBsf: types.BigFractionBytes.fromDecoded(
|
|
94
124
|
obj.cumulativeBorrowRateBsf
|
|
95
125
|
),
|
|
96
|
-
|
|
126
|
+
firstBorrowedAtTimestamp: obj.firstBorrowedAtTimestamp,
|
|
97
127
|
borrowedAmountSf: obj.borrowedAmountSf,
|
|
98
128
|
marketValueSf: obj.marketValueSf,
|
|
99
129
|
borrowFactorAdjustedMarketValueSf: obj.borrowFactorAdjustedMarketValueSf,
|
|
@@ -109,7 +139,7 @@ export class ObligationLiquidity {
|
|
|
109
139
|
cumulativeBorrowRateBsf: types.BigFractionBytes.toEncodable(
|
|
110
140
|
fields.cumulativeBorrowRateBsf
|
|
111
141
|
),
|
|
112
|
-
|
|
142
|
+
firstBorrowedAtTimestamp: fields.firstBorrowedAtTimestamp,
|
|
113
143
|
borrowedAmountSf: fields.borrowedAmountSf,
|
|
114
144
|
marketValueSf: fields.marketValueSf,
|
|
115
145
|
borrowFactorAdjustedMarketValueSf:
|
|
@@ -124,7 +154,7 @@ export class ObligationLiquidity {
|
|
|
124
154
|
return {
|
|
125
155
|
borrowReserve: this.borrowReserve,
|
|
126
156
|
cumulativeBorrowRateBsf: this.cumulativeBorrowRateBsf.toJSON(),
|
|
127
|
-
|
|
157
|
+
firstBorrowedAtTimestamp: this.firstBorrowedAtTimestamp.toString(),
|
|
128
158
|
borrowedAmountSf: this.borrowedAmountSf.toString(),
|
|
129
159
|
marketValueSf: this.marketValueSf.toString(),
|
|
130
160
|
borrowFactorAdjustedMarketValueSf:
|
|
@@ -141,7 +171,7 @@ export class ObligationLiquidity {
|
|
|
141
171
|
cumulativeBorrowRateBsf: types.BigFractionBytes.fromJSON(
|
|
142
172
|
obj.cumulativeBorrowRateBsf
|
|
143
173
|
),
|
|
144
|
-
|
|
174
|
+
firstBorrowedAtTimestamp: new BN(obj.firstBorrowedAtTimestamp),
|
|
145
175
|
borrowedAmountSf: new BN(obj.borrowedAmountSf),
|
|
146
176
|
marketValueSf: new BN(obj.marketValueSf),
|
|
147
177
|
borrowFactorAdjustedMarketValueSf: new BN(
|
|
@@ -77,7 +77,7 @@ export interface ObligationOrderFields {
|
|
|
77
77
|
*/
|
|
78
78
|
opportunityType: number
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Alignment padding.
|
|
81
81
|
* The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
|
|
82
82
|
* align with `u128`s.
|
|
83
83
|
*/
|
|
@@ -162,7 +162,7 @@ export interface ObligationOrderJSON {
|
|
|
162
162
|
*/
|
|
163
163
|
opportunityType: number
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
165
|
+
* Alignment padding.
|
|
166
166
|
* The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
|
|
167
167
|
* align with `u128`s.
|
|
168
168
|
*/
|
|
@@ -176,7 +176,7 @@ export interface ObligationOrderJSON {
|
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
178
|
* A single obligation order.
|
|
179
|
-
* See [Obligation::
|
|
179
|
+
* See [Obligation::obligation_orders].
|
|
180
180
|
*/
|
|
181
181
|
export class ObligationOrder {
|
|
182
182
|
/**
|
|
@@ -251,7 +251,7 @@ export class ObligationOrder {
|
|
|
251
251
|
*/
|
|
252
252
|
readonly opportunityType: number
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
254
|
+
* Alignment padding.
|
|
255
255
|
* The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
|
|
256
256
|
* align with `u128`s.
|
|
257
257
|
*/
|
|
@@ -8,7 +8,7 @@ export interface ReserveConfigFields {
|
|
|
8
8
|
/** Status of the reserve Active/Obsolete/Hidden */
|
|
9
9
|
status: number
|
|
10
10
|
/** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
|
|
11
|
-
|
|
11
|
+
paddingDeprecatedAssetTier: number
|
|
12
12
|
/** Flat rate that goes to the host */
|
|
13
13
|
hostFixedInterestRateBps: number
|
|
14
14
|
/** Starting bonus for deleveraging-related liquidations, in bps. */
|
|
@@ -105,13 +105,30 @@ export interface ReserveConfigFields {
|
|
|
105
105
|
* Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.
|
|
106
106
|
*/
|
|
107
107
|
deleveragingBonusIncreaseBpsPerDay: BN
|
|
108
|
+
/**
|
|
109
|
+
* The timestamp at which all [Obligation::borrows] using this reserve become liquidatable
|
|
110
|
+
* (on the same terms as reserve-wide deleveraging).
|
|
111
|
+
* Inactive when zeroed (i.e. debt never matures).
|
|
112
|
+
*
|
|
113
|
+
* Note: this feature is independent of [Self::debt_term_seconds] - the liquidation mechanism
|
|
114
|
+
* is based directly on the timestamp defined here, on Reserve's level.
|
|
115
|
+
*/
|
|
116
|
+
debtMaturityTimestamp: BN
|
|
117
|
+
/**
|
|
118
|
+
* The duration after which any debt coming from this Reserve must be repaid.
|
|
119
|
+
* Inactive when zeroed (i.e. funds can be borrowed indefinitely).
|
|
120
|
+
*
|
|
121
|
+
* Note: this feature is independent of [Self::debt_maturity_timestamp] - the liquidation
|
|
122
|
+
* mechanism is based on the [ObligationLiquidity::first_borrowed_at_timestamp].
|
|
123
|
+
*/
|
|
124
|
+
debtTermSeconds: BN
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
export interface ReserveConfigJSON {
|
|
111
128
|
/** Status of the reserve Active/Obsolete/Hidden */
|
|
112
129
|
status: number
|
|
113
130
|
/** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
|
|
114
|
-
|
|
131
|
+
paddingDeprecatedAssetTier: number
|
|
115
132
|
/** Flat rate that goes to the host */
|
|
116
133
|
hostFixedInterestRateBps: number
|
|
117
134
|
/** Starting bonus for deleveraging-related liquidations, in bps. */
|
|
@@ -208,6 +225,23 @@ export interface ReserveConfigJSON {
|
|
|
208
225
|
* Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.
|
|
209
226
|
*/
|
|
210
227
|
deleveragingBonusIncreaseBpsPerDay: string
|
|
228
|
+
/**
|
|
229
|
+
* The timestamp at which all [Obligation::borrows] using this reserve become liquidatable
|
|
230
|
+
* (on the same terms as reserve-wide deleveraging).
|
|
231
|
+
* Inactive when zeroed (i.e. debt never matures).
|
|
232
|
+
*
|
|
233
|
+
* Note: this feature is independent of [Self::debt_term_seconds] - the liquidation mechanism
|
|
234
|
+
* is based directly on the timestamp defined here, on Reserve's level.
|
|
235
|
+
*/
|
|
236
|
+
debtMaturityTimestamp: string
|
|
237
|
+
/**
|
|
238
|
+
* The duration after which any debt coming from this Reserve must be repaid.
|
|
239
|
+
* Inactive when zeroed (i.e. funds can be borrowed indefinitely).
|
|
240
|
+
*
|
|
241
|
+
* Note: this feature is independent of [Self::debt_maturity_timestamp] - the liquidation
|
|
242
|
+
* mechanism is based on the [ObligationLiquidity::first_borrowed_at_timestamp].
|
|
243
|
+
*/
|
|
244
|
+
debtTermSeconds: string
|
|
211
245
|
}
|
|
212
246
|
|
|
213
247
|
/** Reserve configuration values */
|
|
@@ -215,7 +249,7 @@ export class ReserveConfig {
|
|
|
215
249
|
/** Status of the reserve Active/Obsolete/Hidden */
|
|
216
250
|
readonly status: number
|
|
217
251
|
/** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
|
|
218
|
-
readonly
|
|
252
|
+
readonly paddingDeprecatedAssetTier: number
|
|
219
253
|
/** Flat rate that goes to the host */
|
|
220
254
|
readonly hostFixedInterestRateBps: number
|
|
221
255
|
/** Starting bonus for deleveraging-related liquidations, in bps. */
|
|
@@ -312,10 +346,27 @@ export class ReserveConfig {
|
|
|
312
346
|
* Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.
|
|
313
347
|
*/
|
|
314
348
|
readonly deleveragingBonusIncreaseBpsPerDay: BN
|
|
349
|
+
/**
|
|
350
|
+
* The timestamp at which all [Obligation::borrows] using this reserve become liquidatable
|
|
351
|
+
* (on the same terms as reserve-wide deleveraging).
|
|
352
|
+
* Inactive when zeroed (i.e. debt never matures).
|
|
353
|
+
*
|
|
354
|
+
* Note: this feature is independent of [Self::debt_term_seconds] - the liquidation mechanism
|
|
355
|
+
* is based directly on the timestamp defined here, on Reserve's level.
|
|
356
|
+
*/
|
|
357
|
+
readonly debtMaturityTimestamp: BN
|
|
358
|
+
/**
|
|
359
|
+
* The duration after which any debt coming from this Reserve must be repaid.
|
|
360
|
+
* Inactive when zeroed (i.e. funds can be borrowed indefinitely).
|
|
361
|
+
*
|
|
362
|
+
* Note: this feature is independent of [Self::debt_maturity_timestamp] - the liquidation
|
|
363
|
+
* mechanism is based on the [ObligationLiquidity::first_borrowed_at_timestamp].
|
|
364
|
+
*/
|
|
365
|
+
readonly debtTermSeconds: BN
|
|
315
366
|
|
|
316
367
|
constructor(fields: ReserveConfigFields) {
|
|
317
368
|
this.status = fields.status
|
|
318
|
-
this.
|
|
369
|
+
this.paddingDeprecatedAssetTier = fields.paddingDeprecatedAssetTier
|
|
319
370
|
this.hostFixedInterestRateBps = fields.hostFixedInterestRateBps
|
|
320
371
|
this.minDeleveragingBonusBps = fields.minDeleveragingBonusBps
|
|
321
372
|
this.blockCtokenUsage = fields.blockCtokenUsage
|
|
@@ -358,13 +409,15 @@ export class ReserveConfig {
|
|
|
358
409
|
fields.borrowLimitAgainstThisCollateralInElevationGroup
|
|
359
410
|
this.deleveragingBonusIncreaseBpsPerDay =
|
|
360
411
|
fields.deleveragingBonusIncreaseBpsPerDay
|
|
412
|
+
this.debtMaturityTimestamp = fields.debtMaturityTimestamp
|
|
413
|
+
this.debtTermSeconds = fields.debtTermSeconds
|
|
361
414
|
}
|
|
362
415
|
|
|
363
416
|
static layout(property?: string) {
|
|
364
417
|
return borsh.struct(
|
|
365
418
|
[
|
|
366
419
|
borsh.u8("status"),
|
|
367
|
-
borsh.u8("
|
|
420
|
+
borsh.u8("paddingDeprecatedAssetTier"),
|
|
368
421
|
borsh.u16("hostFixedInterestRateBps"),
|
|
369
422
|
borsh.u16("minDeleveragingBonusBps"),
|
|
370
423
|
borsh.u8("blockCtokenUsage"),
|
|
@@ -399,6 +452,8 @@ export class ReserveConfig {
|
|
|
399
452
|
"borrowLimitAgainstThisCollateralInElevationGroup"
|
|
400
453
|
),
|
|
401
454
|
borsh.u64("deleveragingBonusIncreaseBpsPerDay"),
|
|
455
|
+
borsh.u64("debtMaturityTimestamp"),
|
|
456
|
+
borsh.u64("debtTermSeconds"),
|
|
402
457
|
],
|
|
403
458
|
property
|
|
404
459
|
)
|
|
@@ -408,7 +463,7 @@ export class ReserveConfig {
|
|
|
408
463
|
static fromDecoded(obj: any) {
|
|
409
464
|
return new ReserveConfig({
|
|
410
465
|
status: obj.status,
|
|
411
|
-
|
|
466
|
+
paddingDeprecatedAssetTier: obj.paddingDeprecatedAssetTier,
|
|
412
467
|
hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
|
|
413
468
|
minDeleveragingBonusBps: obj.minDeleveragingBonusBps,
|
|
414
469
|
blockCtokenUsage: obj.blockCtokenUsage,
|
|
@@ -447,13 +502,15 @@ export class ReserveConfig {
|
|
|
447
502
|
obj.borrowLimitAgainstThisCollateralInElevationGroup,
|
|
448
503
|
deleveragingBonusIncreaseBpsPerDay:
|
|
449
504
|
obj.deleveragingBonusIncreaseBpsPerDay,
|
|
505
|
+
debtMaturityTimestamp: obj.debtMaturityTimestamp,
|
|
506
|
+
debtTermSeconds: obj.debtTermSeconds,
|
|
450
507
|
})
|
|
451
508
|
}
|
|
452
509
|
|
|
453
510
|
static toEncodable(fields: ReserveConfigFields) {
|
|
454
511
|
return {
|
|
455
512
|
status: fields.status,
|
|
456
|
-
|
|
513
|
+
paddingDeprecatedAssetTier: fields.paddingDeprecatedAssetTier,
|
|
457
514
|
hostFixedInterestRateBps: fields.hostFixedInterestRateBps,
|
|
458
515
|
minDeleveragingBonusBps: fields.minDeleveragingBonusBps,
|
|
459
516
|
blockCtokenUsage: fields.blockCtokenUsage,
|
|
@@ -494,13 +551,15 @@ export class ReserveConfig {
|
|
|
494
551
|
fields.borrowLimitAgainstThisCollateralInElevationGroup,
|
|
495
552
|
deleveragingBonusIncreaseBpsPerDay:
|
|
496
553
|
fields.deleveragingBonusIncreaseBpsPerDay,
|
|
554
|
+
debtMaturityTimestamp: fields.debtMaturityTimestamp,
|
|
555
|
+
debtTermSeconds: fields.debtTermSeconds,
|
|
497
556
|
}
|
|
498
557
|
}
|
|
499
558
|
|
|
500
559
|
toJSON(): ReserveConfigJSON {
|
|
501
560
|
return {
|
|
502
561
|
status: this.status,
|
|
503
|
-
|
|
562
|
+
paddingDeprecatedAssetTier: this.paddingDeprecatedAssetTier,
|
|
504
563
|
hostFixedInterestRateBps: this.hostFixedInterestRateBps,
|
|
505
564
|
minDeleveragingBonusBps: this.minDeleveragingBonusBps,
|
|
506
565
|
blockCtokenUsage: this.blockCtokenUsage,
|
|
@@ -539,13 +598,15 @@ export class ReserveConfig {
|
|
|
539
598
|
),
|
|
540
599
|
deleveragingBonusIncreaseBpsPerDay:
|
|
541
600
|
this.deleveragingBonusIncreaseBpsPerDay.toString(),
|
|
601
|
+
debtMaturityTimestamp: this.debtMaturityTimestamp.toString(),
|
|
602
|
+
debtTermSeconds: this.debtTermSeconds.toString(),
|
|
542
603
|
}
|
|
543
604
|
}
|
|
544
605
|
|
|
545
606
|
static fromJSON(obj: ReserveConfigJSON): ReserveConfig {
|
|
546
607
|
return new ReserveConfig({
|
|
547
608
|
status: obj.status,
|
|
548
|
-
|
|
609
|
+
paddingDeprecatedAssetTier: obj.paddingDeprecatedAssetTier,
|
|
549
610
|
hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
|
|
550
611
|
minDeleveragingBonusBps: obj.minDeleveragingBonusBps,
|
|
551
612
|
blockCtokenUsage: obj.blockCtokenUsage,
|
|
@@ -590,6 +651,8 @@ export class ReserveConfig {
|
|
|
590
651
|
deleveragingBonusIncreaseBpsPerDay: new BN(
|
|
591
652
|
obj.deleveragingBonusIncreaseBpsPerDay
|
|
592
653
|
),
|
|
654
|
+
debtMaturityTimestamp: new BN(obj.debtMaturityTimestamp),
|
|
655
|
+
debtTermSeconds: new BN(obj.debtTermSeconds),
|
|
593
656
|
})
|
|
594
657
|
}
|
|
595
658
|
|
|
@@ -763,25 +763,25 @@ export class UpdateBorrowFactor {
|
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
765
|
|
|
766
|
-
export interface
|
|
767
|
-
kind: "
|
|
766
|
+
export interface DeprecatedUpdateAssetTierJSON {
|
|
767
|
+
kind: "DeprecatedUpdateAssetTier"
|
|
768
768
|
}
|
|
769
769
|
|
|
770
|
-
export class
|
|
770
|
+
export class DeprecatedUpdateAssetTier {
|
|
771
771
|
static readonly discriminator = 33
|
|
772
|
-
static readonly kind = "
|
|
772
|
+
static readonly kind = "DeprecatedUpdateAssetTier"
|
|
773
773
|
readonly discriminator = 33
|
|
774
|
-
readonly kind = "
|
|
774
|
+
readonly kind = "DeprecatedUpdateAssetTier"
|
|
775
775
|
|
|
776
|
-
toJSON():
|
|
776
|
+
toJSON(): DeprecatedUpdateAssetTierJSON {
|
|
777
777
|
return {
|
|
778
|
-
kind: "
|
|
778
|
+
kind: "DeprecatedUpdateAssetTier",
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
781
|
|
|
782
782
|
toEncodable() {
|
|
783
783
|
return {
|
|
784
|
-
|
|
784
|
+
DeprecatedUpdateAssetTier: {},
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
787
|
}
|
|
@@ -1223,6 +1223,52 @@ export class UpdateBlockCTokenUsage {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
}
|
|
1225
1225
|
|
|
1226
|
+
export interface UpdateDebtMaturityTimestampJSON {
|
|
1227
|
+
kind: "UpdateDebtMaturityTimestamp"
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
export class UpdateDebtMaturityTimestamp {
|
|
1231
|
+
static readonly discriminator = 53
|
|
1232
|
+
static readonly kind = "UpdateDebtMaturityTimestamp"
|
|
1233
|
+
readonly discriminator = 53
|
|
1234
|
+
readonly kind = "UpdateDebtMaturityTimestamp"
|
|
1235
|
+
|
|
1236
|
+
toJSON(): UpdateDebtMaturityTimestampJSON {
|
|
1237
|
+
return {
|
|
1238
|
+
kind: "UpdateDebtMaturityTimestamp",
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
toEncodable() {
|
|
1243
|
+
return {
|
|
1244
|
+
UpdateDebtMaturityTimestamp: {},
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
export interface UpdateDebtTermSecondsJSON {
|
|
1250
|
+
kind: "UpdateDebtTermSeconds"
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
export class UpdateDebtTermSeconds {
|
|
1254
|
+
static readonly discriminator = 54
|
|
1255
|
+
static readonly kind = "UpdateDebtTermSeconds"
|
|
1256
|
+
readonly discriminator = 54
|
|
1257
|
+
readonly kind = "UpdateDebtTermSeconds"
|
|
1258
|
+
|
|
1259
|
+
toJSON(): UpdateDebtTermSecondsJSON {
|
|
1260
|
+
return {
|
|
1261
|
+
kind: "UpdateDebtTermSeconds",
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
toEncodable() {
|
|
1266
|
+
return {
|
|
1267
|
+
UpdateDebtTermSeconds: {},
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1226
1272
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1227
1273
|
export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
1228
1274
|
if (typeof obj !== "object") {
|
|
@@ -1328,8 +1374,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1328
1374
|
if ("UpdateBorrowFactor" in obj) {
|
|
1329
1375
|
return new UpdateBorrowFactor()
|
|
1330
1376
|
}
|
|
1331
|
-
if ("
|
|
1332
|
-
return new
|
|
1377
|
+
if ("DeprecatedUpdateAssetTier" in obj) {
|
|
1378
|
+
return new DeprecatedUpdateAssetTier()
|
|
1333
1379
|
}
|
|
1334
1380
|
if ("UpdateElevationGroup" in obj) {
|
|
1335
1381
|
return new UpdateElevationGroup()
|
|
@@ -1388,6 +1434,12 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1388
1434
|
if ("UpdateBlockCTokenUsage" in obj) {
|
|
1389
1435
|
return new UpdateBlockCTokenUsage()
|
|
1390
1436
|
}
|
|
1437
|
+
if ("UpdateDebtMaturityTimestamp" in obj) {
|
|
1438
|
+
return new UpdateDebtMaturityTimestamp()
|
|
1439
|
+
}
|
|
1440
|
+
if ("UpdateDebtTermSeconds" in obj) {
|
|
1441
|
+
return new UpdateDebtTermSeconds()
|
|
1442
|
+
}
|
|
1391
1443
|
|
|
1392
1444
|
throw new Error("Invalid enum object")
|
|
1393
1445
|
}
|
|
@@ -1495,8 +1547,8 @@ export function fromJSON(
|
|
|
1495
1547
|
case "UpdateBorrowFactor": {
|
|
1496
1548
|
return new UpdateBorrowFactor()
|
|
1497
1549
|
}
|
|
1498
|
-
case "
|
|
1499
|
-
return new
|
|
1550
|
+
case "DeprecatedUpdateAssetTier": {
|
|
1551
|
+
return new DeprecatedUpdateAssetTier()
|
|
1500
1552
|
}
|
|
1501
1553
|
case "UpdateElevationGroup": {
|
|
1502
1554
|
return new UpdateElevationGroup()
|
|
@@ -1555,6 +1607,12 @@ export function fromJSON(
|
|
|
1555
1607
|
case "UpdateBlockCTokenUsage": {
|
|
1556
1608
|
return new UpdateBlockCTokenUsage()
|
|
1557
1609
|
}
|
|
1610
|
+
case "UpdateDebtMaturityTimestamp": {
|
|
1611
|
+
return new UpdateDebtMaturityTimestamp()
|
|
1612
|
+
}
|
|
1613
|
+
case "UpdateDebtTermSeconds": {
|
|
1614
|
+
return new UpdateDebtTermSeconds()
|
|
1615
|
+
}
|
|
1558
1616
|
}
|
|
1559
1617
|
}
|
|
1560
1618
|
|
|
@@ -1593,7 +1651,7 @@ export function layout(property?: string) {
|
|
|
1593
1651
|
borsh.struct([], "UpdateMinLiquidationBonusBps"),
|
|
1594
1652
|
borsh.struct([], "UpdateDeleveragingMarginCallPeriod"),
|
|
1595
1653
|
borsh.struct([], "UpdateBorrowFactor"),
|
|
1596
|
-
borsh.struct([], "
|
|
1654
|
+
borsh.struct([], "DeprecatedUpdateAssetTier"),
|
|
1597
1655
|
borsh.struct([], "UpdateElevationGroup"),
|
|
1598
1656
|
borsh.struct([], "UpdateDeleveragingThresholdDecreaseBpsPerDay"),
|
|
1599
1657
|
borsh.struct([], "DeprecatedUpdateMultiplierSideBoost"),
|
|
@@ -1613,6 +1671,8 @@ export function layout(property?: string) {
|
|
|
1613
1671
|
borsh.struct([], "UpdateProposerAuthorityLock"),
|
|
1614
1672
|
borsh.struct([], "UpdateMinDeleveragingBonusBps"),
|
|
1615
1673
|
borsh.struct([], "UpdateBlockCTokenUsage"),
|
|
1674
|
+
borsh.struct([], "UpdateDebtMaturityTimestamp"),
|
|
1675
|
+
borsh.struct([], "UpdateDebtTermSeconds"),
|
|
1616
1676
|
])
|
|
1617
1677
|
if (property !== undefined) {
|
|
1618
1678
|
return ret.replicate(property)
|