@kamino-finance/klend-sdk 5.14.0 → 5.14.1-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.
Files changed (140) hide show
  1. package/dist/classes/configItems.d.ts +166 -0
  2. package/dist/classes/configItems.d.ts.map +1 -0
  3. package/dist/classes/configItems.js +202 -0
  4. package/dist/classes/configItems.js.map +1 -0
  5. package/dist/classes/farm_utils.d.ts.map +1 -1
  6. package/dist/classes/farm_utils.js +3 -10
  7. package/dist/classes/farm_utils.js.map +1 -1
  8. package/dist/classes/manager.d.ts +6 -21
  9. package/dist/classes/manager.d.ts.map +1 -1
  10. package/dist/classes/manager.js +40 -311
  11. package/dist/classes/manager.js.map +1 -1
  12. package/dist/classes/obligation.d.ts.map +1 -1
  13. package/dist/classes/obligation.js +14 -0
  14. package/dist/classes/obligation.js.map +1 -1
  15. package/dist/classes/reserve.d.ts +5 -14
  16. package/dist/classes/reserve.d.ts.map +1 -1
  17. package/dist/classes/reserve.js +91 -463
  18. package/dist/classes/reserve.js.map +1 -1
  19. package/dist/classes/shared.d.ts +0 -1
  20. package/dist/classes/shared.d.ts.map +1 -1
  21. package/dist/classes/shared.js.map +1 -1
  22. package/dist/classes/utils.d.ts +1 -0
  23. package/dist/classes/utils.d.ts.map +1 -1
  24. package/dist/classes/utils.js +12 -0
  25. package/dist/classes/utils.js.map +1 -1
  26. package/dist/classes/vault.d.ts +1 -11
  27. package/dist/classes/vault.d.ts.map +1 -1
  28. package/dist/classes/vault.js +6 -54
  29. package/dist/classes/vault.js.map +1 -1
  30. package/dist/client_kamino_manager.d.ts.map +1 -1
  31. package/dist/client_kamino_manager.js +27 -26
  32. package/dist/client_kamino_manager.js.map +1 -1
  33. package/dist/idl.json +186 -9
  34. package/dist/idl_codegen/accounts/GlobalConfig.d.ts +40 -0
  35. package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +1 -0
  36. package/dist/idl_codegen/accounts/GlobalConfig.js +116 -0
  37. package/dist/idl_codegen/accounts/GlobalConfig.js.map +1 -0
  38. package/dist/idl_codegen/accounts/LendingMarket.d.ts +24 -3
  39. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  40. package/dist/idl_codegen/accounts/LendingMarket.js +25 -7
  41. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  42. package/dist/idl_codegen/accounts/index.d.ts +2 -0
  43. package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
  44. package/dist/idl_codegen/accounts/index.js +3 -1
  45. package/dist/idl_codegen/accounts/index.js.map +1 -1
  46. package/dist/idl_codegen/errors/custom.d.ts +25 -1
  47. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  48. package/dist/idl_codegen/errors/custom.js +43 -1
  49. package/dist/idl_codegen/errors/custom.js.map +1 -1
  50. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +2 -1
  51. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
  52. package/dist/idl_codegen/instructions/idlMissingTypes.js +2 -1
  53. package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
  54. package/dist/idl_codegen/instructions/index.d.ts +6 -0
  55. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  56. package/dist/idl_codegen/instructions/index.js +7 -1
  57. package/dist/idl_codegen/instructions/index.js.map +1 -1
  58. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +10 -0
  59. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +1 -0
  60. package/dist/idl_codegen/instructions/initGlobalConfig.js +19 -0
  61. package/dist/idl_codegen/instructions/initGlobalConfig.js.map +1 -0
  62. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +13 -0
  63. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +1 -0
  64. package/dist/idl_codegen/instructions/updateGlobalConfig.js +61 -0
  65. package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +1 -0
  66. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +7 -0
  67. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
  68. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +16 -0
  69. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +1 -0
  70. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +4 -3
  71. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
  72. package/dist/idl_codegen/instructions/updateReserveConfig.js +5 -3
  73. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  74. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
  75. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
  76. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +2 -6
  77. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  78. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +32 -0
  79. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +1 -0
  80. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +108 -0
  81. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +1 -0
  82. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +33 -7
  83. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  84. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +60 -12
  85. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  86. package/dist/idl_codegen/types/index.d.ts +6 -2
  87. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  88. package/dist/idl_codegen/types/index.js +3 -1
  89. package/dist/idl_codegen/types/index.js.map +1 -1
  90. package/dist/utils/accountListing.d.ts +1 -1
  91. package/dist/utils/accountListing.d.ts.map +1 -1
  92. package/dist/utils/accountListing.js +2 -2
  93. package/dist/utils/accountListing.js.map +1 -1
  94. package/dist/utils/api.d.ts +1 -5
  95. package/dist/utils/api.d.ts.map +1 -1
  96. package/dist/utils/api.js +6 -15
  97. package/dist/utils/api.js.map +1 -1
  98. package/dist/utils/constants.d.ts +1 -1
  99. package/dist/utils/constants.js +1 -1
  100. package/dist/utils/lookupTable.d.ts.map +1 -1
  101. package/dist/utils/lookupTable.js +1 -6
  102. package/dist/utils/lookupTable.js.map +1 -1
  103. package/dist/utils/managerTypes.d.ts.map +1 -1
  104. package/dist/utils/managerTypes.js +10 -4
  105. package/dist/utils/managerTypes.js.map +1 -1
  106. package/dist/utils/seeds.d.ts +16 -0
  107. package/dist/utils/seeds.d.ts.map +1 -1
  108. package/dist/utils/seeds.js +23 -1
  109. package/dist/utils/seeds.js.map +1 -1
  110. package/package.json +1 -1
  111. package/src/classes/configItems.ts +295 -0
  112. package/src/classes/farm_utils.ts +3 -11
  113. package/src/classes/manager.ts +52 -417
  114. package/src/classes/obligation.ts +16 -0
  115. package/src/classes/reserve.ts +119 -783
  116. package/src/classes/shared.ts +0 -1
  117. package/src/classes/utils.ts +12 -0
  118. package/src/classes/vault.ts +7 -75
  119. package/src/client_kamino_manager.ts +42 -34
  120. package/src/idl.json +186 -9
  121. package/src/idl_codegen/accounts/GlobalConfig.ts +125 -0
  122. package/src/idl_codegen/accounts/LendingMarket.ts +41 -9
  123. package/src/idl_codegen/accounts/index.ts +2 -0
  124. package/src/idl_codegen/errors/custom.ts +45 -0
  125. package/src/idl_codegen/instructions/idlMissingTypes.ts +4 -2
  126. package/src/idl_codegen/instructions/index.ts +9 -0
  127. package/src/idl_codegen/instructions/initGlobalConfig.ts +30 -0
  128. package/src/idl_codegen/instructions/updateGlobalConfig.ts +47 -0
  129. package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +24 -0
  130. package/src/idl_codegen/instructions/updateReserveConfig.ts +7 -5
  131. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +4 -8
  132. package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +90 -0
  133. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +73 -13
  134. package/src/idl_codegen/types/index.ts +16 -2
  135. package/src/utils/accountListing.ts +2 -3
  136. package/src/utils/api.ts +6 -20
  137. package/src/utils/constants.ts +1 -1
  138. package/src/utils/lookupTable.ts +1 -7
  139. package/src/utils/managerTypes.ts +10 -4
  140. package/src/utils/seeds.ts +25 -0
@@ -0,0 +1,125 @@
1
+ import { PublicKey, Connection } from "@solana/web3.js"
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface GlobalConfigFields {
8
+ /** Global admin of the program */
9
+ globalAdmin: PublicKey
10
+ /** Pending admin must sign a specific transaction to become the global admin */
11
+ pendingAdmin: PublicKey
12
+ /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
13
+ feeCollector: PublicKey
14
+ /** Padding to make the struct size 1024 bytes */
15
+ padding: Array<number>
16
+ }
17
+
18
+ export interface GlobalConfigJSON {
19
+ /** Global admin of the program */
20
+ globalAdmin: string
21
+ /** Pending admin must sign a specific transaction to become the global admin */
22
+ pendingAdmin: string
23
+ /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
24
+ feeCollector: string
25
+ /** Padding to make the struct size 1024 bytes */
26
+ padding: Array<number>
27
+ }
28
+
29
+ export class GlobalConfig {
30
+ /** Global admin of the program */
31
+ readonly globalAdmin: PublicKey
32
+ /** Pending admin must sign a specific transaction to become the global admin */
33
+ readonly pendingAdmin: PublicKey
34
+ /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
35
+ readonly feeCollector: PublicKey
36
+ /** Padding to make the struct size 1024 bytes */
37
+ readonly padding: Array<number>
38
+
39
+ static readonly discriminator = Buffer.from([
40
+ 149, 8, 156, 202, 160, 252, 176, 217,
41
+ ])
42
+
43
+ static readonly layout = borsh.struct([
44
+ borsh.publicKey("globalAdmin"),
45
+ borsh.publicKey("pendingAdmin"),
46
+ borsh.publicKey("feeCollector"),
47
+ borsh.array(borsh.u8(), 928, "padding"),
48
+ ])
49
+
50
+ constructor(fields: GlobalConfigFields) {
51
+ this.globalAdmin = fields.globalAdmin
52
+ this.pendingAdmin = fields.pendingAdmin
53
+ this.feeCollector = fields.feeCollector
54
+ this.padding = fields.padding
55
+ }
56
+
57
+ static async fetch(
58
+ c: Connection,
59
+ address: PublicKey,
60
+ programId: PublicKey = PROGRAM_ID
61
+ ): Promise<GlobalConfig | null> {
62
+ const info = await c.getAccountInfo(address)
63
+
64
+ if (info === null) {
65
+ return null
66
+ }
67
+ if (!info.owner.equals(programId)) {
68
+ throw new Error("account doesn't belong to this program")
69
+ }
70
+
71
+ return this.decode(info.data)
72
+ }
73
+
74
+ static async fetchMultiple(
75
+ c: Connection,
76
+ addresses: PublicKey[],
77
+ programId: PublicKey = PROGRAM_ID
78
+ ): Promise<Array<GlobalConfig | null>> {
79
+ const infos = await c.getMultipleAccountsInfo(addresses)
80
+
81
+ return infos.map((info) => {
82
+ if (info === null) {
83
+ return null
84
+ }
85
+ if (!info.owner.equals(programId)) {
86
+ throw new Error("account doesn't belong to this program")
87
+ }
88
+
89
+ return this.decode(info.data)
90
+ })
91
+ }
92
+
93
+ static decode(data: Buffer): GlobalConfig {
94
+ if (!data.slice(0, 8).equals(GlobalConfig.discriminator)) {
95
+ throw new Error("invalid account discriminator")
96
+ }
97
+
98
+ const dec = GlobalConfig.layout.decode(data.slice(8))
99
+
100
+ return new GlobalConfig({
101
+ globalAdmin: dec.globalAdmin,
102
+ pendingAdmin: dec.pendingAdmin,
103
+ feeCollector: dec.feeCollector,
104
+ padding: dec.padding,
105
+ })
106
+ }
107
+
108
+ toJSON(): GlobalConfigJSON {
109
+ return {
110
+ globalAdmin: this.globalAdmin.toString(),
111
+ pendingAdmin: this.pendingAdmin.toString(),
112
+ feeCollector: this.feeCollector.toString(),
113
+ padding: this.padding,
114
+ }
115
+ }
116
+
117
+ static fromJSON(obj: GlobalConfigJSON): GlobalConfig {
118
+ return new GlobalConfig({
119
+ globalAdmin: new PublicKey(obj.globalAdmin),
120
+ pendingAdmin: new PublicKey(obj.pendingAdmin),
121
+ feeCollector: new PublicKey(obj.feeCollector),
122
+ padding: obj.padding,
123
+ })
124
+ }
125
+ }
@@ -73,7 +73,14 @@ export interface LendingMarketFields {
73
73
  */
74
74
  minInitialDepositAmount: BN
75
75
  /** Whether the obligation orders should be evaluated during liquidations. */
76
- obligationOrdersEnabled: number
76
+ obligationOrderExecutionEnabled: number
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
77
84
  padding2: Array<number>
78
85
  padding1: Array<BN>
79
86
  }
@@ -147,7 +154,14 @@ export interface LendingMarketJSON {
147
154
  */
148
155
  minInitialDepositAmount: string
149
156
  /** Whether the obligation orders should be evaluated during liquidations. */
150
- obligationOrdersEnabled: number
157
+ obligationOrderExecutionEnabled: number
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
151
165
  padding2: Array<number>
152
166
  padding1: Array<string>
153
167
  }
@@ -221,7 +235,14 @@ export class LendingMarket {
221
235
  */
222
236
  readonly minInitialDepositAmount: BN
223
237
  /** Whether the obligation orders should be evaluated during liquidations. */
224
- readonly obligationOrdersEnabled: number
238
+ readonly obligationOrderExecutionEnabled: number
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
225
246
  readonly padding2: Array<number>
226
247
  readonly padding1: Array<BN>
227
248
 
@@ -256,8 +277,10 @@ export class LendingMarket {
256
277
  borsh.u64("minValueSkipLiquidationBfChecks"),
257
278
  borsh.u64("individualAutodeleverageMarginCallPeriodSecs"),
258
279
  borsh.u64("minInitialDepositAmount"),
259
- borsh.u8("obligationOrdersEnabled"),
260
- borsh.array(borsh.u8(), 7, "padding2"),
280
+ borsh.u8("obligationOrderExecutionEnabled"),
281
+ borsh.u8("immutable"),
282
+ borsh.u8("obligationOrderCreationEnabled"),
283
+ borsh.array(borsh.u8(), 5, "padding2"),
261
284
  borsh.array(borsh.u64(), 169, "padding1"),
262
285
  ])
263
286
 
@@ -296,7 +319,10 @@ export class LendingMarket {
296
319
  this.individualAutodeleverageMarginCallPeriodSecs =
297
320
  fields.individualAutodeleverageMarginCallPeriodSecs
298
321
  this.minInitialDepositAmount = fields.minInitialDepositAmount
299
- this.obligationOrdersEnabled = fields.obligationOrdersEnabled
322
+ this.obligationOrderExecutionEnabled =
323
+ fields.obligationOrderExecutionEnabled
324
+ this.immutable = fields.immutable
325
+ this.obligationOrderCreationEnabled = fields.obligationOrderCreationEnabled
300
326
  this.padding2 = fields.padding2
301
327
  this.padding1 = fields.padding1
302
328
  }
@@ -377,7 +403,9 @@ export class LendingMarket {
377
403
  individualAutodeleverageMarginCallPeriodSecs:
378
404
  dec.individualAutodeleverageMarginCallPeriodSecs,
379
405
  minInitialDepositAmount: dec.minInitialDepositAmount,
380
- obligationOrdersEnabled: dec.obligationOrdersEnabled,
406
+ obligationOrderExecutionEnabled: dec.obligationOrderExecutionEnabled,
407
+ immutable: dec.immutable,
408
+ obligationOrderCreationEnabled: dec.obligationOrderCreationEnabled,
381
409
  padding2: dec.padding2,
382
410
  padding1: dec.padding1,
383
411
  })
@@ -418,7 +446,9 @@ export class LendingMarket {
418
446
  individualAutodeleverageMarginCallPeriodSecs:
419
447
  this.individualAutodeleverageMarginCallPeriodSecs.toString(),
420
448
  minInitialDepositAmount: this.minInitialDepositAmount.toString(),
421
- obligationOrdersEnabled: this.obligationOrdersEnabled,
449
+ obligationOrderExecutionEnabled: this.obligationOrderExecutionEnabled,
450
+ immutable: this.immutable,
451
+ obligationOrderCreationEnabled: this.obligationOrderCreationEnabled,
422
452
  padding2: this.padding2,
423
453
  padding1: this.padding1.map((item) => item.toString()),
424
454
  }
@@ -466,7 +496,9 @@ export class LendingMarket {
466
496
  obj.individualAutodeleverageMarginCallPeriodSecs
467
497
  ),
468
498
  minInitialDepositAmount: new BN(obj.minInitialDepositAmount),
469
- obligationOrdersEnabled: obj.obligationOrdersEnabled,
499
+ obligationOrderExecutionEnabled: obj.obligationOrderExecutionEnabled,
500
+ immutable: obj.immutable,
501
+ obligationOrderCreationEnabled: obj.obligationOrderCreationEnabled,
470
502
  padding2: obj.padding2,
471
503
  padding1: obj.padding1.map((item) => new BN(item)),
472
504
  })
@@ -1,5 +1,7 @@
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"
3
5
  export { LendingMarket } from "./LendingMarket"
4
6
  export type { LendingMarketFields, LendingMarketJSON } from "./LendingMarket"
5
7
  export { Obligation } from "./Obligation"
@@ -126,6 +126,9 @@ export type CustomError =
126
126
  | InvalidOrderConfiguration
127
127
  | OrderConfigurationNotSupportedByObligation
128
128
  | OperationNotPermittedWithCurrentObligationOrders
129
+ | OperationNotPermittedMarketImmutable
130
+ | OrderCreationDisabled
131
+ | NoUpgradeAuthority
129
132
 
130
133
  export class InvalidMarketAuthority extends Error {
131
134
  static readonly code = 6000
@@ -1602,6 +1605,42 @@ export class OperationNotPermittedWithCurrentObligationOrders extends Error {
1602
1605
  }
1603
1606
  }
1604
1607
 
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
+
1605
1644
  export function fromCode(code: number, logs?: string[]): CustomError | null {
1606
1645
  switch (code) {
1607
1646
  case 6000:
@@ -1858,6 +1897,12 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1858
1897
  return new OrderConfigurationNotSupportedByObligation(logs)
1859
1898
  case 6126:
1860
1899
  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)
1861
1906
  }
1862
1907
 
1863
1908
  return null
@@ -15,7 +15,8 @@ export interface IdlMissingTypesArgs {
15
15
  }
16
16
 
17
17
  export interface IdlMissingTypesAccounts {
18
- lendingMarketOwner: PublicKey
18
+ signer: PublicKey
19
+ globalConfig: PublicKey
19
20
  lendingMarket: PublicKey
20
21
  reserve: PublicKey
21
22
  }
@@ -36,7 +37,8 @@ export function idlMissingTypes(
36
37
  programId: PublicKey = PROGRAM_ID
37
38
  ) {
38
39
  const keys: Array<AccountMeta> = [
39
- { pubkey: accounts.lendingMarketOwner, isSigner: true, isWritable: false },
40
+ { pubkey: accounts.signer, isSigner: true, isWritable: false },
41
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: false },
40
42
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
41
43
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
42
44
  ]
@@ -188,6 +188,15 @@ 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"
191
200
  export { idlMissingTypes } from "./idlMissingTypes"
192
201
  export type {
193
202
  IdlMissingTypesArgs,
@@ -0,0 +1,30 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // 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 borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface InitGlobalConfigAccounts {
8
+ payer: PublicKey
9
+ globalConfig: PublicKey
10
+ programData: PublicKey
11
+ systemProgram: PublicKey
12
+ rent: PublicKey
13
+ }
14
+
15
+ export function initGlobalConfig(
16
+ accounts: InitGlobalConfigAccounts,
17
+ programId: PublicKey = PROGRAM_ID
18
+ ) {
19
+ const keys: Array<AccountMeta> = [
20
+ { pubkey: accounts.payer, isSigner: true, isWritable: true },
21
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: true },
22
+ { pubkey: accounts.programData, isSigner: false, isWritable: false },
23
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
24
+ { pubkey: accounts.rent, isSigner: false, isWritable: false },
25
+ ]
26
+ const identifier = Buffer.from([140, 136, 214, 48, 87, 0, 120, 255])
27
+ const data = identifier
28
+ const ix = new TransactionInstruction({ keys, programId, data })
29
+ return ix
30
+ }
@@ -0,0 +1,47 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // 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 borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface UpdateGlobalConfigArgs {
8
+ mode: types.UpdateGlobalConfigModeKind
9
+ value: Uint8Array
10
+ }
11
+
12
+ export interface UpdateGlobalConfigAccounts {
13
+ globalAdmin: PublicKey
14
+ globalConfig: PublicKey
15
+ }
16
+
17
+ export const layout = borsh.struct([
18
+ types.UpdateGlobalConfigMode.layout("mode"),
19
+ borsh.vecU8("value"),
20
+ ])
21
+
22
+ export function updateGlobalConfig(
23
+ args: UpdateGlobalConfigArgs,
24
+ accounts: UpdateGlobalConfigAccounts,
25
+ programId: PublicKey = PROGRAM_ID
26
+ ) {
27
+ const keys: Array<AccountMeta> = [
28
+ { pubkey: accounts.globalAdmin, isSigner: true, isWritable: false },
29
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: true },
30
+ ]
31
+ const identifier = Buffer.from([164, 84, 130, 189, 111, 58, 250, 200])
32
+ const buffer = Buffer.alloc(1000)
33
+ const len = layout.encode(
34
+ {
35
+ mode: args.mode.toEncodable(),
36
+ value: Buffer.from(
37
+ args.value.buffer,
38
+ args.value.byteOffset,
39
+ args.value.length
40
+ ),
41
+ },
42
+ buffer
43
+ )
44
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
45
+ const ix = new TransactionInstruction({ keys, programId, data })
46
+ return ix
47
+ }
@@ -0,0 +1,24 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // 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 borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface UpdateGlobalConfigAdminAccounts {
8
+ pendingAdmin: PublicKey
9
+ globalConfig: PublicKey
10
+ }
11
+
12
+ export function updateGlobalConfigAdmin(
13
+ accounts: UpdateGlobalConfigAdminAccounts,
14
+ programId: PublicKey = PROGRAM_ID
15
+ ) {
16
+ const keys: Array<AccountMeta> = [
17
+ { pubkey: accounts.pendingAdmin, isSigner: true, isWritable: false },
18
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: true },
19
+ ]
20
+ const identifier = Buffer.from([184, 87, 23, 193, 156, 238, 175, 119])
21
+ const data = identifier
22
+ const ix = new TransactionInstruction({ keys, programId, data })
23
+ return ix
24
+ }
@@ -5,19 +5,20 @@ 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: BN
8
+ mode: types.UpdateConfigModeKind
9
9
  value: Uint8Array
10
10
  skipValidation: boolean
11
11
  }
12
12
 
13
13
  export interface UpdateReserveConfigAccounts {
14
- lendingMarketOwner: PublicKey
14
+ signer: PublicKey
15
+ globalConfig: PublicKey
15
16
  lendingMarket: PublicKey
16
17
  reserve: PublicKey
17
18
  }
18
19
 
19
20
  export const layout = borsh.struct([
20
- borsh.u64("mode"),
21
+ types.UpdateConfigMode.layout("mode"),
21
22
  borsh.vecU8("value"),
22
23
  borsh.bool("skipValidation"),
23
24
  ])
@@ -28,7 +29,8 @@ export function updateReserveConfig(
28
29
  programId: PublicKey = PROGRAM_ID
29
30
  ) {
30
31
  const keys: Array<AccountMeta> = [
31
- { pubkey: accounts.lendingMarketOwner, isSigner: true, isWritable: false },
32
+ { pubkey: accounts.signer, isSigner: true, isWritable: false },
33
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: false },
32
34
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
33
35
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
34
36
  ]
@@ -36,7 +38,7 @@ export function updateReserveConfig(
36
38
  const buffer = Buffer.alloc(1000)
37
39
  const len = layout.encode(
38
40
  {
39
- mode: args.mode,
41
+ mode: args.mode.toEncodable(),
40
42
  value: Buffer.from(
41
43
  args.value.buffer,
42
44
  args.value.byteOffset,
@@ -9,13 +9,13 @@ export interface WithdrawProtocolFeeArgs {
9
9
  }
10
10
 
11
11
  export interface WithdrawProtocolFeeAccounts {
12
- lendingMarketOwner: PublicKey
12
+ globalConfig: PublicKey
13
13
  lendingMarket: PublicKey
14
14
  reserve: PublicKey
15
15
  reserveLiquidityMint: PublicKey
16
16
  lendingMarketAuthority: PublicKey
17
17
  feeVault: PublicKey
18
- lendingMarketOwnerAta: PublicKey
18
+ feeCollectorAta: 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.lendingMarketOwner, isSigner: true, isWritable: false },
30
+ { pubkey: accounts.globalConfig, isSigner: false, isWritable: false },
31
31
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
32
32
  { pubkey: accounts.reserve, isSigner: false, isWritable: false },
33
33
  {
@@ -41,11 +41,7 @@ export function withdrawProtocolFee(
41
41
  isWritable: false,
42
42
  },
43
43
  { pubkey: accounts.feeVault, isSigner: false, isWritable: true },
44
- {
45
- pubkey: accounts.lendingMarketOwnerAta,
46
- isSigner: false,
47
- isWritable: true,
48
- },
44
+ { pubkey: accounts.feeCollectorAta, isSigner: false, isWritable: true },
49
45
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
50
46
  ]
51
47
  const identifier = Buffer.from([158, 201, 158, 189, 33, 93, 162, 103])
@@ -0,0 +1,90 @@
1
+ import { PublicKey } from "@solana/web3.js" // 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
+
6
+ export interface PendingAdminJSON {
7
+ kind: "PendingAdmin"
8
+ }
9
+
10
+ export class PendingAdmin {
11
+ static readonly discriminator = 0
12
+ static readonly kind = "PendingAdmin"
13
+ readonly discriminator = 0
14
+ readonly kind = "PendingAdmin"
15
+
16
+ toJSON(): PendingAdminJSON {
17
+ return {
18
+ kind: "PendingAdmin",
19
+ }
20
+ }
21
+
22
+ toEncodable() {
23
+ return {
24
+ PendingAdmin: {},
25
+ }
26
+ }
27
+ }
28
+
29
+ export interface FeeCollectorJSON {
30
+ kind: "FeeCollector"
31
+ }
32
+
33
+ export class FeeCollector {
34
+ static readonly discriminator = 1
35
+ static readonly kind = "FeeCollector"
36
+ readonly discriminator = 1
37
+ readonly kind = "FeeCollector"
38
+
39
+ toJSON(): FeeCollectorJSON {
40
+ return {
41
+ kind: "FeeCollector",
42
+ }
43
+ }
44
+
45
+ toEncodable() {
46
+ return {
47
+ FeeCollector: {},
48
+ }
49
+ }
50
+ }
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ export function fromDecoded(obj: any): types.UpdateGlobalConfigModeKind {
54
+ if (typeof obj !== "object") {
55
+ throw new Error("Invalid enum object")
56
+ }
57
+
58
+ if ("PendingAdmin" in obj) {
59
+ return new PendingAdmin()
60
+ }
61
+ if ("FeeCollector" in obj) {
62
+ return new FeeCollector()
63
+ }
64
+
65
+ throw new Error("Invalid enum object")
66
+ }
67
+
68
+ export function fromJSON(
69
+ obj: types.UpdateGlobalConfigModeJSON
70
+ ): types.UpdateGlobalConfigModeKind {
71
+ switch (obj.kind) {
72
+ case "PendingAdmin": {
73
+ return new PendingAdmin()
74
+ }
75
+ case "FeeCollector": {
76
+ return new FeeCollector()
77
+ }
78
+ }
79
+ }
80
+
81
+ export function layout(property?: string) {
82
+ const ret = borsh.rustEnum([
83
+ borsh.struct([], "PendingAdmin"),
84
+ borsh.struct([], "FeeCollector"),
85
+ ])
86
+ if (property !== undefined) {
87
+ return ret.replicate(property)
88
+ }
89
+ return ret
90
+ }