@kamino-finance/klend-sdk 5.14.1-beta.0 → 5.14.2
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/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +10 -3
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +21 -6
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +311 -40
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +0 -14
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +14 -5
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +463 -91
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/shared.js.map +1 -1
- package/dist/classes/utils.d.ts +0 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +0 -12
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +11 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +54 -6
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +29 -29
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +9 -186
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -24
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +7 -25
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +0 -2
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/index.js +1 -3
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +1 -25
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +1 -43
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -2
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js +1 -2
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +0 -6
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +1 -7
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +3 -4
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.js +3 -5
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +6 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -33
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -60
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +2 -6
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +1 -3
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/utils/accountListing.d.ts +1 -1
- package/dist/utils/accountListing.d.ts.map +1 -1
- package/dist/utils/accountListing.js +2 -2
- package/dist/utils/accountListing.js.map +1 -1
- package/dist/utils/api.d.ts +5 -1
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +12 -6
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +6 -1
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +4 -10
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +0 -16
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +1 -23
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/farm_utils.ts +11 -3
- package/src/classes/manager.ts +417 -52
- package/src/classes/obligation.ts +0 -16
- package/src/classes/reserve.ts +783 -119
- package/src/classes/shared.ts +1 -0
- package/src/classes/utils.ts +0 -12
- package/src/classes/vault.ts +75 -7
- package/src/client_kamino_manager.ts +40 -44
- package/src/idl.json +9 -186
- package/src/idl_codegen/accounts/LendingMarket.ts +9 -41
- package/src/idl_codegen/accounts/index.ts +0 -2
- package/src/idl_codegen/errors/custom.ts +0 -45
- package/src/idl_codegen/instructions/idlMissingTypes.ts +2 -4
- package/src/idl_codegen/instructions/index.ts +0 -9
- package/src/idl_codegen/instructions/updateReserveConfig.ts +5 -7
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +8 -4
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -73
- package/src/idl_codegen/types/index.ts +2 -16
- package/src/utils/accountListing.ts +3 -2
- package/src/utils/api.ts +19 -7
- package/src/utils/constants.ts +1 -1
- package/src/utils/lookupTable.ts +7 -1
- package/src/utils/managerTypes.ts +4 -10
- package/src/utils/seeds.ts +0 -25
- package/dist/classes/configItems.d.ts +0 -166
- package/dist/classes/configItems.d.ts.map +0 -1
- package/dist/classes/configItems.js +0 -202
- package/dist/classes/configItems.js.map +0 -1
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts +0 -40
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/accounts/GlobalConfig.js +0 -116
- package/dist/idl_codegen/accounts/GlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +0 -10
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.js +0 -19
- package/dist/idl_codegen/instructions/initGlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +0 -13
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfig.js +0 -61
- package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +0 -7
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +0 -16
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +0 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +0 -32
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +0 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +0 -108
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +0 -1
- package/src/classes/configItems.ts +0 -295
- package/src/idl_codegen/accounts/GlobalConfig.ts +0 -125
- package/src/idl_codegen/instructions/initGlobalConfig.ts +0 -30
- package/src/idl_codegen/instructions/updateGlobalConfig.ts +0 -47
- package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +0 -24
- package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +0 -90
|
@@ -73,14 +73,7 @@ export interface LendingMarketFields {
|
|
|
73
73
|
*/
|
|
74
74
|
minInitialDepositAmount: BN
|
|
75
75
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
76
|
-
|
|
77
|
-
/** Whether the lending market is set as immutable. */
|
|
78
|
-
immutable: number
|
|
79
|
-
/**
|
|
80
|
-
* Whether new obligation orders can be created.
|
|
81
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
82
|
-
*/
|
|
83
|
-
obligationOrderCreationEnabled: number
|
|
76
|
+
obligationOrdersEnabled: number
|
|
84
77
|
padding2: Array<number>
|
|
85
78
|
padding1: Array<BN>
|
|
86
79
|
}
|
|
@@ -154,14 +147,7 @@ export interface LendingMarketJSON {
|
|
|
154
147
|
*/
|
|
155
148
|
minInitialDepositAmount: string
|
|
156
149
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
157
|
-
|
|
158
|
-
/** Whether the lending market is set as immutable. */
|
|
159
|
-
immutable: number
|
|
160
|
-
/**
|
|
161
|
-
* Whether new obligation orders can be created.
|
|
162
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
163
|
-
*/
|
|
164
|
-
obligationOrderCreationEnabled: number
|
|
150
|
+
obligationOrdersEnabled: number
|
|
165
151
|
padding2: Array<number>
|
|
166
152
|
padding1: Array<string>
|
|
167
153
|
}
|
|
@@ -235,14 +221,7 @@ export class LendingMarket {
|
|
|
235
221
|
*/
|
|
236
222
|
readonly minInitialDepositAmount: BN
|
|
237
223
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
238
|
-
readonly
|
|
239
|
-
/** Whether the lending market is set as immutable. */
|
|
240
|
-
readonly immutable: number
|
|
241
|
-
/**
|
|
242
|
-
* Whether new obligation orders can be created.
|
|
243
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
244
|
-
*/
|
|
245
|
-
readonly obligationOrderCreationEnabled: number
|
|
224
|
+
readonly obligationOrdersEnabled: number
|
|
246
225
|
readonly padding2: Array<number>
|
|
247
226
|
readonly padding1: Array<BN>
|
|
248
227
|
|
|
@@ -277,10 +256,8 @@ export class LendingMarket {
|
|
|
277
256
|
borsh.u64("minValueSkipLiquidationBfChecks"),
|
|
278
257
|
borsh.u64("individualAutodeleverageMarginCallPeriodSecs"),
|
|
279
258
|
borsh.u64("minInitialDepositAmount"),
|
|
280
|
-
borsh.u8("
|
|
281
|
-
borsh.u8("
|
|
282
|
-
borsh.u8("obligationOrderCreationEnabled"),
|
|
283
|
-
borsh.array(borsh.u8(), 5, "padding2"),
|
|
259
|
+
borsh.u8("obligationOrdersEnabled"),
|
|
260
|
+
borsh.array(borsh.u8(), 7, "padding2"),
|
|
284
261
|
borsh.array(borsh.u64(), 169, "padding1"),
|
|
285
262
|
])
|
|
286
263
|
|
|
@@ -319,10 +296,7 @@ export class LendingMarket {
|
|
|
319
296
|
this.individualAutodeleverageMarginCallPeriodSecs =
|
|
320
297
|
fields.individualAutodeleverageMarginCallPeriodSecs
|
|
321
298
|
this.minInitialDepositAmount = fields.minInitialDepositAmount
|
|
322
|
-
this.
|
|
323
|
-
fields.obligationOrderExecutionEnabled
|
|
324
|
-
this.immutable = fields.immutable
|
|
325
|
-
this.obligationOrderCreationEnabled = fields.obligationOrderCreationEnabled
|
|
299
|
+
this.obligationOrdersEnabled = fields.obligationOrdersEnabled
|
|
326
300
|
this.padding2 = fields.padding2
|
|
327
301
|
this.padding1 = fields.padding1
|
|
328
302
|
}
|
|
@@ -403,9 +377,7 @@ export class LendingMarket {
|
|
|
403
377
|
individualAutodeleverageMarginCallPeriodSecs:
|
|
404
378
|
dec.individualAutodeleverageMarginCallPeriodSecs,
|
|
405
379
|
minInitialDepositAmount: dec.minInitialDepositAmount,
|
|
406
|
-
|
|
407
|
-
immutable: dec.immutable,
|
|
408
|
-
obligationOrderCreationEnabled: dec.obligationOrderCreationEnabled,
|
|
380
|
+
obligationOrdersEnabled: dec.obligationOrdersEnabled,
|
|
409
381
|
padding2: dec.padding2,
|
|
410
382
|
padding1: dec.padding1,
|
|
411
383
|
})
|
|
@@ -446,9 +418,7 @@ export class LendingMarket {
|
|
|
446
418
|
individualAutodeleverageMarginCallPeriodSecs:
|
|
447
419
|
this.individualAutodeleverageMarginCallPeriodSecs.toString(),
|
|
448
420
|
minInitialDepositAmount: this.minInitialDepositAmount.toString(),
|
|
449
|
-
|
|
450
|
-
immutable: this.immutable,
|
|
451
|
-
obligationOrderCreationEnabled: this.obligationOrderCreationEnabled,
|
|
421
|
+
obligationOrdersEnabled: this.obligationOrdersEnabled,
|
|
452
422
|
padding2: this.padding2,
|
|
453
423
|
padding1: this.padding1.map((item) => item.toString()),
|
|
454
424
|
}
|
|
@@ -496,9 +466,7 @@ export class LendingMarket {
|
|
|
496
466
|
obj.individualAutodeleverageMarginCallPeriodSecs
|
|
497
467
|
),
|
|
498
468
|
minInitialDepositAmount: new BN(obj.minInitialDepositAmount),
|
|
499
|
-
|
|
500
|
-
immutable: obj.immutable,
|
|
501
|
-
obligationOrderCreationEnabled: obj.obligationOrderCreationEnabled,
|
|
469
|
+
obligationOrdersEnabled: obj.obligationOrdersEnabled,
|
|
502
470
|
padding2: obj.padding2,
|
|
503
471
|
padding1: obj.padding1.map((item) => new BN(item)),
|
|
504
472
|
})
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { UserState } from "./UserState"
|
|
2
2
|
export type { UserStateFields, UserStateJSON } from "./UserState"
|
|
3
|
-
export { GlobalConfig } from "./GlobalConfig"
|
|
4
|
-
export type { GlobalConfigFields, GlobalConfigJSON } from "./GlobalConfig"
|
|
5
3
|
export { LendingMarket } from "./LendingMarket"
|
|
6
4
|
export type { LendingMarketFields, LendingMarketJSON } from "./LendingMarket"
|
|
7
5
|
export { Obligation } from "./Obligation"
|
|
@@ -126,9 +126,6 @@ export type CustomError =
|
|
|
126
126
|
| InvalidOrderConfiguration
|
|
127
127
|
| OrderConfigurationNotSupportedByObligation
|
|
128
128
|
| OperationNotPermittedWithCurrentObligationOrders
|
|
129
|
-
| OperationNotPermittedMarketImmutable
|
|
130
|
-
| OrderCreationDisabled
|
|
131
|
-
| NoUpgradeAuthority
|
|
132
129
|
|
|
133
130
|
export class InvalidMarketAuthority extends Error {
|
|
134
131
|
static readonly code = 6000
|
|
@@ -1605,42 +1602,6 @@ export class OperationNotPermittedWithCurrentObligationOrders extends Error {
|
|
|
1605
1602
|
}
|
|
1606
1603
|
}
|
|
1607
1604
|
|
|
1608
|
-
export class OperationNotPermittedMarketImmutable extends Error {
|
|
1609
|
-
static readonly code = 6127
|
|
1610
|
-
readonly code = 6127
|
|
1611
|
-
readonly name = "OperationNotPermittedMarketImmutable"
|
|
1612
|
-
readonly msg = "Cannot update lending market because it is set as immutable"
|
|
1613
|
-
|
|
1614
|
-
constructor(readonly logs?: string[]) {
|
|
1615
|
-
super("6127: Cannot update lending market because it is set as immutable")
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
export class OrderCreationDisabled extends Error {
|
|
1620
|
-
static readonly code = 6128
|
|
1621
|
-
readonly code = 6128
|
|
1622
|
-
readonly name = "OrderCreationDisabled"
|
|
1623
|
-
readonly msg = "Creation of new orders is disabled"
|
|
1624
|
-
|
|
1625
|
-
constructor(readonly logs?: string[]) {
|
|
1626
|
-
super("6128: Creation of new orders is disabled")
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
export class NoUpgradeAuthority extends Error {
|
|
1631
|
-
static readonly code = 6129
|
|
1632
|
-
readonly code = 6129
|
|
1633
|
-
readonly name = "NoUpgradeAuthority"
|
|
1634
|
-
readonly msg =
|
|
1635
|
-
"Cannot initialize global config because there is no upgrade authority to the program"
|
|
1636
|
-
|
|
1637
|
-
constructor(readonly logs?: string[]) {
|
|
1638
|
-
super(
|
|
1639
|
-
"6129: Cannot initialize global config because there is no upgrade authority to the program"
|
|
1640
|
-
)
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
1605
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1645
1606
|
switch (code) {
|
|
1646
1607
|
case 6000:
|
|
@@ -1897,12 +1858,6 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1897
1858
|
return new OrderConfigurationNotSupportedByObligation(logs)
|
|
1898
1859
|
case 6126:
|
|
1899
1860
|
return new OperationNotPermittedWithCurrentObligationOrders(logs)
|
|
1900
|
-
case 6127:
|
|
1901
|
-
return new OperationNotPermittedMarketImmutable(logs)
|
|
1902
|
-
case 6128:
|
|
1903
|
-
return new OrderCreationDisabled(logs)
|
|
1904
|
-
case 6129:
|
|
1905
|
-
return new NoUpgradeAuthority(logs)
|
|
1906
1861
|
}
|
|
1907
1862
|
|
|
1908
1863
|
return null
|
|
@@ -15,8 +15,7 @@ export interface IdlMissingTypesArgs {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface IdlMissingTypesAccounts {
|
|
18
|
-
|
|
19
|
-
globalConfig: PublicKey
|
|
18
|
+
lendingMarketOwner: PublicKey
|
|
20
19
|
lendingMarket: PublicKey
|
|
21
20
|
reserve: PublicKey
|
|
22
21
|
}
|
|
@@ -37,8 +36,7 @@ export function idlMissingTypes(
|
|
|
37
36
|
programId: PublicKey = PROGRAM_ID
|
|
38
37
|
) {
|
|
39
38
|
const keys: Array<AccountMeta> = [
|
|
40
|
-
{ pubkey: accounts.
|
|
41
|
-
{ pubkey: accounts.globalConfig, isSigner: false, isWritable: false },
|
|
39
|
+
{ pubkey: accounts.lendingMarketOwner, isSigner: true, isWritable: false },
|
|
42
40
|
{ pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
|
|
43
41
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: true },
|
|
44
42
|
]
|
|
@@ -188,15 +188,6 @@ export type {
|
|
|
188
188
|
SetObligationOrderArgs,
|
|
189
189
|
SetObligationOrderAccounts,
|
|
190
190
|
} from "./setObligationOrder"
|
|
191
|
-
export { initGlobalConfig } from "./initGlobalConfig"
|
|
192
|
-
export type { InitGlobalConfigAccounts } from "./initGlobalConfig"
|
|
193
|
-
export { updateGlobalConfig } from "./updateGlobalConfig"
|
|
194
|
-
export type {
|
|
195
|
-
UpdateGlobalConfigArgs,
|
|
196
|
-
UpdateGlobalConfigAccounts,
|
|
197
|
-
} from "./updateGlobalConfig"
|
|
198
|
-
export { updateGlobalConfigAdmin } from "./updateGlobalConfigAdmin"
|
|
199
|
-
export type { UpdateGlobalConfigAdminAccounts } from "./updateGlobalConfigAdmin"
|
|
200
191
|
export { idlMissingTypes } from "./idlMissingTypes"
|
|
201
192
|
export type {
|
|
202
193
|
IdlMissingTypesArgs,
|
|
@@ -5,20 +5,19 @@ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-u
|
|
|
5
5
|
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface UpdateReserveConfigArgs {
|
|
8
|
-
mode:
|
|
8
|
+
mode: BN
|
|
9
9
|
value: Uint8Array
|
|
10
10
|
skipValidation: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface UpdateReserveConfigAccounts {
|
|
14
|
-
|
|
15
|
-
globalConfig: PublicKey
|
|
14
|
+
lendingMarketOwner: PublicKey
|
|
16
15
|
lendingMarket: PublicKey
|
|
17
16
|
reserve: PublicKey
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export const layout = borsh.struct([
|
|
21
|
-
|
|
20
|
+
borsh.u64("mode"),
|
|
22
21
|
borsh.vecU8("value"),
|
|
23
22
|
borsh.bool("skipValidation"),
|
|
24
23
|
])
|
|
@@ -29,8 +28,7 @@ export function updateReserveConfig(
|
|
|
29
28
|
programId: PublicKey = PROGRAM_ID
|
|
30
29
|
) {
|
|
31
30
|
const keys: Array<AccountMeta> = [
|
|
32
|
-
{ pubkey: accounts.
|
|
33
|
-
{ pubkey: accounts.globalConfig, isSigner: false, isWritable: false },
|
|
31
|
+
{ pubkey: accounts.lendingMarketOwner, isSigner: true, isWritable: false },
|
|
34
32
|
{ pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
|
|
35
33
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: true },
|
|
36
34
|
]
|
|
@@ -38,7 +36,7 @@ export function updateReserveConfig(
|
|
|
38
36
|
const buffer = Buffer.alloc(1000)
|
|
39
37
|
const len = layout.encode(
|
|
40
38
|
{
|
|
41
|
-
mode: args.mode
|
|
39
|
+
mode: args.mode,
|
|
42
40
|
value: Buffer.from(
|
|
43
41
|
args.value.buffer,
|
|
44
42
|
args.value.byteOffset,
|
|
@@ -9,13 +9,13 @@ export interface WithdrawProtocolFeeArgs {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface WithdrawProtocolFeeAccounts {
|
|
12
|
-
|
|
12
|
+
lendingMarketOwner: PublicKey
|
|
13
13
|
lendingMarket: PublicKey
|
|
14
14
|
reserve: PublicKey
|
|
15
15
|
reserveLiquidityMint: PublicKey
|
|
16
16
|
lendingMarketAuthority: PublicKey
|
|
17
17
|
feeVault: PublicKey
|
|
18
|
-
|
|
18
|
+
lendingMarketOwnerAta: PublicKey
|
|
19
19
|
tokenProgram: PublicKey
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export function withdrawProtocolFee(
|
|
|
27
27
|
programId: PublicKey = PROGRAM_ID
|
|
28
28
|
) {
|
|
29
29
|
const keys: Array<AccountMeta> = [
|
|
30
|
-
{ pubkey: accounts.
|
|
30
|
+
{ pubkey: accounts.lendingMarketOwner, isSigner: true, isWritable: false },
|
|
31
31
|
{ pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
|
|
32
32
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: false },
|
|
33
33
|
{
|
|
@@ -41,7 +41,11 @@ export function withdrawProtocolFee(
|
|
|
41
41
|
isWritable: false,
|
|
42
42
|
},
|
|
43
43
|
{ pubkey: accounts.feeVault, isSigner: false, isWritable: true },
|
|
44
|
-
{
|
|
44
|
+
{
|
|
45
|
+
pubkey: accounts.lendingMarketOwnerAta,
|
|
46
|
+
isSigner: false,
|
|
47
|
+
isWritable: true,
|
|
48
|
+
},
|
|
45
49
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
46
50
|
]
|
|
47
51
|
const identifier = Buffer.from([158, 201, 158, 189, 33, 93, 162, 103])
|
|
@@ -509,71 +509,25 @@ export class UpdateInitialDepositAmount {
|
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
export interface
|
|
513
|
-
kind: "
|
|
512
|
+
export interface UpdateObligationOrdersEnabledJSON {
|
|
513
|
+
kind: "UpdateObligationOrdersEnabled"
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
-
export class
|
|
516
|
+
export class UpdateObligationOrdersEnabled {
|
|
517
517
|
static readonly discriminator = 22
|
|
518
|
-
static readonly kind = "
|
|
518
|
+
static readonly kind = "UpdateObligationOrdersEnabled"
|
|
519
519
|
readonly discriminator = 22
|
|
520
|
-
readonly kind = "
|
|
520
|
+
readonly kind = "UpdateObligationOrdersEnabled"
|
|
521
521
|
|
|
522
|
-
toJSON():
|
|
522
|
+
toJSON(): UpdateObligationOrdersEnabledJSON {
|
|
523
523
|
return {
|
|
524
|
-
kind: "
|
|
524
|
+
kind: "UpdateObligationOrdersEnabled",
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
toEncodable() {
|
|
529
529
|
return {
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
export interface UpdateImmutableFlagJSON {
|
|
536
|
-
kind: "UpdateImmutableFlag"
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export class UpdateImmutableFlag {
|
|
540
|
-
static readonly discriminator = 23
|
|
541
|
-
static readonly kind = "UpdateImmutableFlag"
|
|
542
|
-
readonly discriminator = 23
|
|
543
|
-
readonly kind = "UpdateImmutableFlag"
|
|
544
|
-
|
|
545
|
-
toJSON(): UpdateImmutableFlagJSON {
|
|
546
|
-
return {
|
|
547
|
-
kind: "UpdateImmutableFlag",
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
toEncodable() {
|
|
552
|
-
return {
|
|
553
|
-
UpdateImmutableFlag: {},
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
export interface UpdateObligationOrderCreationEnabledJSON {
|
|
559
|
-
kind: "UpdateObligationOrderCreationEnabled"
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
export class UpdateObligationOrderCreationEnabled {
|
|
563
|
-
static readonly discriminator = 24
|
|
564
|
-
static readonly kind = "UpdateObligationOrderCreationEnabled"
|
|
565
|
-
readonly discriminator = 24
|
|
566
|
-
readonly kind = "UpdateObligationOrderCreationEnabled"
|
|
567
|
-
|
|
568
|
-
toJSON(): UpdateObligationOrderCreationEnabledJSON {
|
|
569
|
-
return {
|
|
570
|
-
kind: "UpdateObligationOrderCreationEnabled",
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
toEncodable() {
|
|
575
|
-
return {
|
|
576
|
-
UpdateObligationOrderCreationEnabled: {},
|
|
530
|
+
UpdateObligationOrdersEnabled: {},
|
|
577
531
|
}
|
|
578
532
|
}
|
|
579
533
|
}
|
|
@@ -650,14 +604,8 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
650
604
|
if ("UpdateInitialDepositAmount" in obj) {
|
|
651
605
|
return new UpdateInitialDepositAmount()
|
|
652
606
|
}
|
|
653
|
-
if ("
|
|
654
|
-
return new
|
|
655
|
-
}
|
|
656
|
-
if ("UpdateImmutableFlag" in obj) {
|
|
657
|
-
return new UpdateImmutableFlag()
|
|
658
|
-
}
|
|
659
|
-
if ("UpdateObligationOrderCreationEnabled" in obj) {
|
|
660
|
-
return new UpdateObligationOrderCreationEnabled()
|
|
607
|
+
if ("UpdateObligationOrdersEnabled" in obj) {
|
|
608
|
+
return new UpdateObligationOrdersEnabled()
|
|
661
609
|
}
|
|
662
610
|
|
|
663
611
|
throw new Error("Invalid enum object")
|
|
@@ -733,14 +681,8 @@ export function fromJSON(
|
|
|
733
681
|
case "UpdateInitialDepositAmount": {
|
|
734
682
|
return new UpdateInitialDepositAmount()
|
|
735
683
|
}
|
|
736
|
-
case "
|
|
737
|
-
return new
|
|
738
|
-
}
|
|
739
|
-
case "UpdateImmutableFlag": {
|
|
740
|
-
return new UpdateImmutableFlag()
|
|
741
|
-
}
|
|
742
|
-
case "UpdateObligationOrderCreationEnabled": {
|
|
743
|
-
return new UpdateObligationOrderCreationEnabled()
|
|
684
|
+
case "UpdateObligationOrdersEnabled": {
|
|
685
|
+
return new UpdateObligationOrdersEnabled()
|
|
744
686
|
}
|
|
745
687
|
}
|
|
746
688
|
}
|
|
@@ -769,9 +711,7 @@ export function layout(property?: string) {
|
|
|
769
711
|
borsh.struct([], "UpdateName"),
|
|
770
712
|
borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
|
|
771
713
|
borsh.struct([], "UpdateInitialDepositAmount"),
|
|
772
|
-
borsh.struct([], "
|
|
773
|
-
borsh.struct([], "UpdateImmutableFlag"),
|
|
774
|
-
borsh.struct([], "UpdateObligationOrderCreationEnabled"),
|
|
714
|
+
borsh.struct([], "UpdateObligationOrdersEnabled"),
|
|
775
715
|
])
|
|
776
716
|
if (property !== undefined) {
|
|
777
717
|
return ret.replicate(property)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as UpdateConfigMode from "./UpdateConfigMode"
|
|
2
2
|
import * as UpdateLendingMarketConfigValue from "./UpdateLendingMarketConfigValue"
|
|
3
3
|
import * as UpdateLendingMarketMode from "./UpdateLendingMarketMode"
|
|
4
|
-
import * as UpdateGlobalConfigMode from "./UpdateGlobalConfigMode"
|
|
5
4
|
import * as AssetTier from "./AssetTier"
|
|
6
5
|
import * as FeeCalculation from "./FeeCalculation"
|
|
7
6
|
import * as ReserveFarmKind from "./ReserveFarmKind"
|
|
@@ -160,9 +159,7 @@ export type UpdateLendingMarketModeKind =
|
|
|
160
159
|
| UpdateLendingMarketMode.UpdateName
|
|
161
160
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
|
|
162
161
|
| UpdateLendingMarketMode.UpdateInitialDepositAmount
|
|
163
|
-
| UpdateLendingMarketMode.
|
|
164
|
-
| UpdateLendingMarketMode.UpdateImmutableFlag
|
|
165
|
-
| UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled
|
|
162
|
+
| UpdateLendingMarketMode.UpdateObligationOrdersEnabled
|
|
166
163
|
export type UpdateLendingMarketModeJSON =
|
|
167
164
|
| UpdateLendingMarketMode.UpdateOwnerJSON
|
|
168
165
|
| UpdateLendingMarketMode.UpdateEmergencyModeJSON
|
|
@@ -186,18 +183,7 @@ export type UpdateLendingMarketModeJSON =
|
|
|
186
183
|
| UpdateLendingMarketMode.UpdateNameJSON
|
|
187
184
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
|
|
188
185
|
| UpdateLendingMarketMode.UpdateInitialDepositAmountJSON
|
|
189
|
-
| UpdateLendingMarketMode.
|
|
190
|
-
| UpdateLendingMarketMode.UpdateImmutableFlagJSON
|
|
191
|
-
| UpdateLendingMarketMode.UpdateObligationOrderCreationEnabledJSON
|
|
192
|
-
|
|
193
|
-
export { UpdateGlobalConfigMode }
|
|
194
|
-
|
|
195
|
-
export type UpdateGlobalConfigModeKind =
|
|
196
|
-
| UpdateGlobalConfigMode.PendingAdmin
|
|
197
|
-
| UpdateGlobalConfigMode.FeeCollector
|
|
198
|
-
export type UpdateGlobalConfigModeJSON =
|
|
199
|
-
| UpdateGlobalConfigMode.PendingAdminJSON
|
|
200
|
-
| UpdateGlobalConfigMode.FeeCollectorJSON
|
|
186
|
+
| UpdateLendingMarketMode.UpdateObligationOrdersEnabledJSON
|
|
201
187
|
|
|
202
188
|
export { LastUpdate } from "./LastUpdate"
|
|
203
189
|
export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
|
|
@@ -56,10 +56,11 @@ export async function* getAllReserveAccounts(
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export async function* getAllLendingMarketAccounts(
|
|
59
|
-
connection: Connection
|
|
59
|
+
connection: Connection,
|
|
60
|
+
programId: PublicKey = PROGRAM_ID
|
|
60
61
|
): AsyncGenerator<[PublicKey, LendingMarket], void, unknown> {
|
|
61
62
|
// due to relatively very low count of lending markets, we technically don't really need a generator, but let's keep it consistent within this file
|
|
62
|
-
const lendingMarkets = await connection.getProgramAccounts(
|
|
63
|
+
const lendingMarkets = await connection.getProgramAccounts(programId, {
|
|
63
64
|
filters: [
|
|
64
65
|
{
|
|
65
66
|
dataSize: LendingMarket.layout.span + 8,
|
package/src/utils/api.ts
CHANGED
|
@@ -5,29 +5,41 @@ import { CDN_ENDPOINT, getApiEndpoint } from '../utils';
|
|
|
5
5
|
import { IBackOffOptions, backOff } from 'exponential-backoff';
|
|
6
6
|
import { PROGRAM_ID } from '../lib';
|
|
7
7
|
|
|
8
|
+
export type ApiFilterOptions = {
|
|
9
|
+
isCurated?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Fetch config from the API
|
|
10
14
|
* A good place to start to find active klend markets without expensive RPC calls
|
|
11
15
|
*
|
|
12
16
|
* @param programId - The program id to retrieve config for
|
|
13
17
|
* @param source - CDN is a json file hosted in the cloud, API is a webserver
|
|
18
|
+
* @param filterOptions - Config options to filter markets by
|
|
14
19
|
*/
|
|
15
20
|
export async function getMarketsFromApi(
|
|
16
21
|
programId: PublicKey = PROGRAM_ID,
|
|
17
|
-
source: 'API' | 'CDN' = 'CDN'
|
|
22
|
+
source: 'API' | 'CDN' = 'CDN',
|
|
23
|
+
filterOptions: ApiFilterOptions = {}
|
|
18
24
|
): Promise<ConfigType> {
|
|
19
|
-
let
|
|
20
|
-
|
|
25
|
+
let unfilteredConfigs: ConfigType = {} as ConfigType;
|
|
21
26
|
if (source === 'CDN') {
|
|
22
|
-
|
|
27
|
+
unfilteredConfigs = (await backOff(() => axios.get(CDN_ENDPOINT), KAMINO_CDN_RETRY)).data[
|
|
28
|
+
programId.toString()
|
|
29
|
+
] as ConfigType;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
if (!
|
|
32
|
+
if (!unfilteredConfigs || isEmptyObject(unfilteredConfigs)) {
|
|
26
33
|
const API_ENDPOINT = getApiEndpoint(programId);
|
|
27
|
-
|
|
34
|
+
unfilteredConfigs = (await backOff(() => axios.get(API_ENDPOINT), KAMINO_API_RETRY)).data as ConfigType;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
return
|
|
37
|
+
return unfilteredConfigs.filter((c) => {
|
|
38
|
+
if (filterOptions.isCurated !== undefined) {
|
|
39
|
+
return c.isCurated === filterOptions.isCurated;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
export const KAMINO_CDN_RETRY: Partial<IBackOffOptions> = {
|
package/src/utils/constants.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function getApiEndpoint(programId: PublicKey) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const CDN_ENDPOINT = 'https://cdn.kamino.finance/
|
|
30
|
+
export const CDN_ENDPOINT = 'https://cdn.kamino.finance/kamino_lend_config_v3.json';
|
|
31
31
|
|
|
32
32
|
export const ONE_HUNDRED_PCT_IN_BPS = 10_000;
|
|
33
33
|
|
package/src/utils/lookupTable.ts
CHANGED
|
@@ -15,7 +15,13 @@ export async function createLookupTableIx(
|
|
|
15
15
|
connection: Connection,
|
|
16
16
|
wallet: PublicKey
|
|
17
17
|
): Promise<[TransactionInstruction, PublicKey]> {
|
|
18
|
-
|
|
18
|
+
const [createLookupTableIxs, lookupTableAddress] = AddressLookupTableProgram.createLookupTable({
|
|
19
|
+
authority: wallet,
|
|
20
|
+
payer: wallet,
|
|
21
|
+
recentSlot: await connection.getSlot('confirmed'),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return [createLookupTableIxs, lookupTableAddress];
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export function extendLookupTableChunkIx(
|
|
@@ -262,7 +262,7 @@ export const DefaultConfigParams: AssetReserveConfigParams = {
|
|
|
262
262
|
borrowFeeSf: ZERO_FRACTION,
|
|
263
263
|
flashLoanFeeSf: ZERO_FRACTION,
|
|
264
264
|
protocolTakeRate: 0,
|
|
265
|
-
elevationGroups:
|
|
265
|
+
elevationGroups: [0, 0, 0, 0, 0],
|
|
266
266
|
priceFeed: null,
|
|
267
267
|
borrowLimit: new Decimal(1000.0),
|
|
268
268
|
depositLimit: new Decimal(1000.0),
|
|
@@ -334,9 +334,7 @@ function buildReserveConfig(fields: {
|
|
|
334
334
|
borrowRateCurve: fields.configParams.borrowRateCurve,
|
|
335
335
|
depositWithdrawalCap: new WithdrawalCaps({
|
|
336
336
|
configCapacity: new BN(
|
|
337
|
-
numberToLamportsDecimal(fields.configParams.depositLimit ?? new Decimal(0), fields.mintDecimals)
|
|
338
|
-
.floor()
|
|
339
|
-
.toString()
|
|
337
|
+
numberToLamportsDecimal(fields.configParams.depositLimit ?? new Decimal(0), fields.mintDecimals).floor().toString()
|
|
340
338
|
),
|
|
341
339
|
currentTotal: new BN(0),
|
|
342
340
|
lastIntervalStartTimestamp: new BN(0),
|
|
@@ -344,9 +342,7 @@ function buildReserveConfig(fields: {
|
|
|
344
342
|
}),
|
|
345
343
|
debtWithdrawalCap: new WithdrawalCaps({
|
|
346
344
|
configCapacity: new BN(
|
|
347
|
-
numberToLamportsDecimal(fields.debtWithdrawalCapConfigCapacity ?? new Decimal(0), fields.mintDecimals)
|
|
348
|
-
.floor()
|
|
349
|
-
.toString()
|
|
345
|
+
numberToLamportsDecimal(fields.debtWithdrawalCapConfigCapacity ?? new Decimal(0), fields.mintDecimals).floor().toString()
|
|
350
346
|
),
|
|
351
347
|
currentTotal: new BN(0),
|
|
352
348
|
lastIntervalStartTimestamp: new BN(0),
|
|
@@ -361,9 +357,7 @@ function buildReserveConfig(fields: {
|
|
|
361
357
|
hostFixedInterestRateBps: 0,
|
|
362
358
|
autodeleverageEnabled: 0,
|
|
363
359
|
borrowLimitOutsideElevationGroup: new BN(
|
|
364
|
-
numberToLamportsDecimal(fields.borrowLimitOutsideElevationGroup ?? new Decimal(0), fields.mintDecimals)
|
|
365
|
-
.floor()
|
|
366
|
-
.toString()
|
|
360
|
+
numberToLamportsDecimal(fields.borrowLimitOutsideElevationGroup ?? new Decimal(0), fields.mintDecimals).floor().toString()
|
|
367
361
|
),
|
|
368
362
|
borrowLimitAgainstThisCollateralInElevationGroup: Array(32).fill(new BN(0)),
|
|
369
363
|
deleveragingBonusIncreaseBpsPerDay: new BN(100),
|
package/src/utils/seeds.ts
CHANGED
|
@@ -39,10 +39,6 @@ export const BASE_SEED_REFERRER_STATE = 'ref_state';
|
|
|
39
39
|
* Short url seed
|
|
40
40
|
*/
|
|
41
41
|
export const BASE_SEED_SHORT_URL = 'short_url';
|
|
42
|
-
/**
|
|
43
|
-
* Short url seed
|
|
44
|
-
*/
|
|
45
|
-
export const BASE_SEED_GLOBAL_CONFIG_STATE = 'global_config';
|
|
46
42
|
/**
|
|
47
43
|
* Farm user state seed
|
|
48
44
|
*/
|
|
@@ -197,27 +193,6 @@ export function shortUrlPda(shortUrl: string, programId: PublicKey = PROGRAM_ID)
|
|
|
197
193
|
return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_SHORT_URL), Buffer.from(shortUrl)], programId);
|
|
198
194
|
}
|
|
199
195
|
|
|
200
|
-
/**
|
|
201
|
-
* Returns the PDA and bump for the global config state.
|
|
202
|
-
* @param programId
|
|
203
|
-
* @returns [pda, bump]
|
|
204
|
-
*/
|
|
205
|
-
export function globalConfigPda(programId: PublicKey = PROGRAM_ID) {
|
|
206
|
-
return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_GLOBAL_CONFIG_STATE)], programId);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Returns the PDA and bump for the program data.
|
|
211
|
-
* @param programId
|
|
212
|
-
* @returns [pda, bump]
|
|
213
|
-
*/
|
|
214
|
-
export function programDataPda(programId: PublicKey = PROGRAM_ID) {
|
|
215
|
-
return PublicKey.findProgramAddressSync(
|
|
216
|
-
[programId.toBuffer()],
|
|
217
|
-
new PublicKey('BPFLoaderUpgradeab1e11111111111111111111111')
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
196
|
/**
|
|
222
197
|
* Returns the PDA for the obligation farm state
|
|
223
198
|
* @param farm
|