@kamino-finance/klend-sdk 5.14.3 → 5.14.5

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 (122) 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/manager.d.ts +4 -7
  6. package/dist/classes/manager.d.ts.map +1 -1
  7. package/dist/classes/manager.js +37 -292
  8. package/dist/classes/manager.js.map +1 -1
  9. package/dist/classes/market.d.ts.map +1 -1
  10. package/dist/classes/market.js.map +1 -1
  11. package/dist/classes/reserve.d.ts +5 -14
  12. package/dist/classes/reserve.d.ts.map +1 -1
  13. package/dist/classes/reserve.js +93 -465
  14. package/dist/classes/reserve.js.map +1 -1
  15. package/dist/classes/utils.d.ts +1 -0
  16. package/dist/classes/utils.d.ts.map +1 -1
  17. package/dist/classes/utils.js +12 -0
  18. package/dist/classes/utils.js.map +1 -1
  19. package/dist/classes/vault.d.ts.map +1 -1
  20. package/dist/classes/vault.js +28 -1
  21. package/dist/classes/vault.js.map +1 -1
  22. package/dist/classes/vault_types.d.ts +1 -0
  23. package/dist/classes/vault_types.d.ts.map +1 -1
  24. package/dist/client_kamino_manager.d.ts.map +1 -1
  25. package/dist/client_kamino_manager.js +24 -11
  26. package/dist/client_kamino_manager.js.map +1 -1
  27. package/dist/idl.json +193 -16
  28. package/dist/idl_codegen/accounts/GlobalConfig.d.ts +40 -0
  29. package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +1 -0
  30. package/dist/idl_codegen/accounts/GlobalConfig.js +116 -0
  31. package/dist/idl_codegen/accounts/GlobalConfig.js.map +1 -0
  32. package/dist/idl_codegen/accounts/LendingMarket.d.ts +24 -3
  33. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  34. package/dist/idl_codegen/accounts/LendingMarket.js +25 -7
  35. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  36. package/dist/idl_codegen/accounts/index.d.ts +2 -0
  37. package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
  38. package/dist/idl_codegen/accounts/index.js +3 -1
  39. package/dist/idl_codegen/accounts/index.js.map +1 -1
  40. package/dist/idl_codegen/errors/custom.d.ts +35 -11
  41. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  42. package/dist/idl_codegen/errors/custom.js +64 -22
  43. package/dist/idl_codegen/errors/custom.js.map +1 -1
  44. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +2 -1
  45. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
  46. package/dist/idl_codegen/instructions/idlMissingTypes.js +2 -1
  47. package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
  48. package/dist/idl_codegen/instructions/index.d.ts +6 -0
  49. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  50. package/dist/idl_codegen/instructions/index.js +7 -1
  51. package/dist/idl_codegen/instructions/index.js.map +1 -1
  52. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +10 -0
  53. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +1 -0
  54. package/dist/idl_codegen/instructions/initGlobalConfig.js +19 -0
  55. package/dist/idl_codegen/instructions/initGlobalConfig.js.map +1 -0
  56. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +13 -0
  57. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +1 -0
  58. package/dist/idl_codegen/instructions/updateGlobalConfig.js +61 -0
  59. package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +1 -0
  60. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +7 -0
  61. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
  62. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +16 -0
  63. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +1 -0
  64. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +5 -4
  65. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
  66. package/dist/idl_codegen/instructions/updateReserveConfig.js +7 -5
  67. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  68. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
  69. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
  70. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +2 -6
  71. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  72. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +32 -0
  73. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +1 -0
  74. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +108 -0
  75. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +1 -0
  76. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +33 -7
  77. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  78. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +60 -12
  79. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  80. package/dist/idl_codegen/types/index.d.ts +6 -2
  81. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  82. package/dist/idl_codegen/types/index.js +3 -1
  83. package/dist/idl_codegen/types/index.js.map +1 -1
  84. package/dist/utils/instruction.d.ts.map +1 -1
  85. package/dist/utils/instruction.js.map +1 -1
  86. package/dist/utils/lookupTable.d.ts.map +1 -1
  87. package/dist/utils/lookupTable.js +1 -6
  88. package/dist/utils/lookupTable.js.map +1 -1
  89. package/dist/utils/managerTypes.js +1 -1
  90. package/dist/utils/managerTypes.js.map +1 -1
  91. package/dist/utils/seeds.d.ts +16 -0
  92. package/dist/utils/seeds.d.ts.map +1 -1
  93. package/dist/utils/seeds.js +23 -1
  94. package/dist/utils/seeds.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/classes/configItems.ts +295 -0
  97. package/src/classes/manager.ts +49 -392
  98. package/src/classes/market.ts +2 -6
  99. package/src/classes/reserve.ts +122 -786
  100. package/src/classes/utils.ts +12 -0
  101. package/src/classes/vault.ts +47 -2
  102. package/src/classes/vault_types.ts +1 -0
  103. package/src/client_kamino_manager.ts +40 -14
  104. package/src/idl.json +193 -16
  105. package/src/idl_codegen/accounts/GlobalConfig.ts +125 -0
  106. package/src/idl_codegen/accounts/LendingMarket.ts +41 -9
  107. package/src/idl_codegen/accounts/index.ts +2 -0
  108. package/src/idl_codegen/errors/custom.ts +65 -20
  109. package/src/idl_codegen/instructions/idlMissingTypes.ts +4 -2
  110. package/src/idl_codegen/instructions/index.ts +9 -0
  111. package/src/idl_codegen/instructions/initGlobalConfig.ts +30 -0
  112. package/src/idl_codegen/instructions/updateGlobalConfig.ts +47 -0
  113. package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +24 -0
  114. package/src/idl_codegen/instructions/updateReserveConfig.ts +10 -8
  115. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +4 -8
  116. package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +90 -0
  117. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +73 -13
  118. package/src/idl_codegen/types/index.ts +16 -2
  119. package/src/utils/instruction.ts +2 -2
  120. package/src/utils/lookupTable.ts +1 -7
  121. package/src/utils/managerTypes.ts +1 -1
  122. package/src/utils/seeds.ts +25 -0
@@ -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"
@@ -92,14 +92,14 @@ export type CustomError =
92
92
  | DepositLimitExceeded
93
93
  | BorrowingDisabledOutsideElevationGroup
94
94
  | NetValueRemainingTooSmall
95
- | WorseLTVBlocked
95
+ | WorseLtvBlocked
96
96
  | LiabilitiesBiggerThanAssets
97
97
  | ReserveTokenBalanceMismatch
98
98
  | ReserveVaultBalanceMismatch
99
99
  | ReserveAccountingMismatch
100
100
  | BorrowingAboveUtilizationRateDisabled
101
101
  | LiquidationBorrowFactorPriority
102
- | LiquidationLowestLTVPriority
102
+ | LiquidationLowestLiquidationLtvPriority
103
103
  | ElevationGroupBorrowLimitExceeded
104
104
  | ElevationGroupWithoutDebtReserve
105
105
  | ElevationGroupMaxCollateralReserveZero
@@ -117,8 +117,8 @@ export type CustomError =
117
117
  | ObligationCurrentlyMarkedForDeleveraging
118
118
  | MaximumWithdrawValueZero
119
119
  | ZeroMaxLtvAssetsInDeposits
120
- | MinLtvAssetsPriority
121
- | WorseLTVThanUnhealthyLTV
120
+ | LowestLtvAssetsPriority
121
+ | WorseLtvThanUnhealthyLtv
122
122
  | FarmAccountsMissing
123
123
  | RepayTooSmallForFullLiquidation
124
124
  | InsufficientRepayAmount
@@ -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
@@ -1186,10 +1189,10 @@ export class NetValueRemainingTooSmall extends Error {
1186
1189
  }
1187
1190
  }
1188
1191
 
1189
- export class WorseLTVBlocked extends Error {
1192
+ export class WorseLtvBlocked extends Error {
1190
1193
  static readonly code = 6093
1191
1194
  readonly code = 6093
1192
- readonly name = "WorseLTVBlocked"
1195
+ readonly name = "WorseLtvBlocked"
1193
1196
  readonly msg = "Cannot get the obligation in a worse position"
1194
1197
 
1195
1198
  constructor(readonly logs?: string[]) {
@@ -1269,16 +1272,16 @@ export class LiquidationBorrowFactorPriority extends Error {
1269
1272
  }
1270
1273
  }
1271
1274
 
1272
- export class LiquidationLowestLTVPriority extends Error {
1275
+ export class LiquidationLowestLiquidationLtvPriority extends Error {
1273
1276
  static readonly code = 6100
1274
1277
  readonly code = 6100
1275
- readonly name = "LiquidationLowestLTVPriority"
1278
+ readonly name = "LiquidationLowestLiquidationLtvPriority"
1276
1279
  readonly msg =
1277
- "Liquidation must prioritize the collateral with the lowest LTV"
1280
+ "Liquidation must prioritize the collateral with the lowest liquidation LTV"
1278
1281
 
1279
1282
  constructor(readonly logs?: string[]) {
1280
1283
  super(
1281
- "6100: Liquidation must prioritize the collateral with the lowest LTV"
1284
+ "6100: Liquidation must prioritize the collateral with the lowest liquidation LTV"
1282
1285
  )
1283
1286
  }
1284
1287
  }
@@ -1488,24 +1491,24 @@ export class ZeroMaxLtvAssetsInDeposits extends Error {
1488
1491
  }
1489
1492
  }
1490
1493
 
1491
- export class MinLtvAssetsPriority extends Error {
1494
+ export class LowestLtvAssetsPriority extends Error {
1492
1495
  static readonly code = 6118
1493
1496
  readonly code = 6118
1494
- readonly name = "MinLtvAssetsPriority"
1497
+ readonly name = "LowestLtvAssetsPriority"
1495
1498
  readonly msg =
1496
- "The operation must prioritize the collateral with the lowest LTV"
1499
+ "Withdrawing must prioritize the collateral with the lowest reserve max-LTV"
1497
1500
 
1498
1501
  constructor(readonly logs?: string[]) {
1499
1502
  super(
1500
- "6118: The operation must prioritize the collateral with the lowest LTV"
1503
+ "6118: Withdrawing must prioritize the collateral with the lowest reserve max-LTV"
1501
1504
  )
1502
1505
  }
1503
1506
  }
1504
1507
 
1505
- export class WorseLTVThanUnhealthyLTV extends Error {
1508
+ export class WorseLtvThanUnhealthyLtv extends Error {
1506
1509
  static readonly code = 6119
1507
1510
  readonly code = 6119
1508
- readonly name = "WorseLTVThanUnhealthyLTV"
1511
+ readonly name = "WorseLtvThanUnhealthyLtv"
1509
1512
  readonly msg = "Cannot get the obligation liquidatable"
1510
1513
 
1511
1514
  constructor(readonly logs?: string[]) {
@@ -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:
@@ -1791,7 +1830,7 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1791
1830
  case 6092:
1792
1831
  return new NetValueRemainingTooSmall(logs)
1793
1832
  case 6093:
1794
- return new WorseLTVBlocked(logs)
1833
+ return new WorseLtvBlocked(logs)
1795
1834
  case 6094:
1796
1835
  return new LiabilitiesBiggerThanAssets(logs)
1797
1836
  case 6095:
@@ -1805,7 +1844,7 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1805
1844
  case 6099:
1806
1845
  return new LiquidationBorrowFactorPriority(logs)
1807
1846
  case 6100:
1808
- return new LiquidationLowestLTVPriority(logs)
1847
+ return new LiquidationLowestLiquidationLtvPriority(logs)
1809
1848
  case 6101:
1810
1849
  return new ElevationGroupBorrowLimitExceeded(logs)
1811
1850
  case 6102:
@@ -1841,9 +1880,9 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1841
1880
  case 6117:
1842
1881
  return new ZeroMaxLtvAssetsInDeposits(logs)
1843
1882
  case 6118:
1844
- return new MinLtvAssetsPriority(logs)
1883
+ return new LowestLtvAssetsPriority(logs)
1845
1884
  case 6119:
1846
- return new WorseLTVThanUnhealthyLTV(logs)
1885
+ return new WorseLtvThanUnhealthyLtv(logs)
1847
1886
  case 6120:
1848
1887
  return new FarmAccountsMissing(logs)
1849
1888
  case 6121:
@@ -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,21 +5,22 @@ 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
- skipValidation: boolean
10
+ skipConfigIntegrityValidation: 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
- borsh.bool("skipValidation"),
23
+ borsh.bool("skipConfigIntegrityValidation"),
23
24
  ])
24
25
 
25
26
  export function updateReserveConfig(
@@ -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,13 +38,13 @@ 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,
43
45
  args.value.length
44
46
  ),
45
- skipValidation: args.skipValidation,
47
+ skipConfigIntegrityValidation: args.skipConfigIntegrityValidation,
46
48
  },
47
49
  buffer
48
50
  )
@@ -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
+ }