@kamino-finance/klend-sdk 5.13.21-beta.0 → 5.13.21

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 (128) hide show
  1. package/dist/classes/farm_utils.d.ts.map +1 -1
  2. package/dist/classes/farm_utils.js +10 -3
  3. package/dist/classes/farm_utils.js.map +1 -1
  4. package/dist/classes/manager.d.ts +12 -5
  5. package/dist/classes/manager.d.ts.map +1 -1
  6. package/dist/classes/manager.js +300 -39
  7. package/dist/classes/manager.js.map +1 -1
  8. package/dist/classes/obligation.d.ts.map +1 -1
  9. package/dist/classes/obligation.js +0 -14
  10. package/dist/classes/obligation.js.map +1 -1
  11. package/dist/classes/reserve.d.ts +14 -5
  12. package/dist/classes/reserve.d.ts.map +1 -1
  13. package/dist/classes/reserve.js +463 -91
  14. package/dist/classes/reserve.js.map +1 -1
  15. package/dist/classes/utils.d.ts +0 -1
  16. package/dist/classes/utils.d.ts.map +1 -1
  17. package/dist/classes/utils.js +0 -12
  18. package/dist/classes/utils.js.map +1 -1
  19. package/dist/classes/vault.d.ts +2 -1
  20. package/dist/classes/vault.d.ts.map +1 -1
  21. package/dist/classes/vault.js +9 -5
  22. package/dist/classes/vault.js.map +1 -1
  23. package/dist/client_kamino_manager.d.ts.map +1 -1
  24. package/dist/client_kamino_manager.js +26 -27
  25. package/dist/client_kamino_manager.js.map +1 -1
  26. package/dist/idl.json +9 -186
  27. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -24
  28. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  29. package/dist/idl_codegen/accounts/LendingMarket.js +7 -25
  30. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  31. package/dist/idl_codegen/accounts/index.d.ts +0 -2
  32. package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
  33. package/dist/idl_codegen/accounts/index.js +1 -3
  34. package/dist/idl_codegen/accounts/index.js.map +1 -1
  35. package/dist/idl_codegen/errors/custom.d.ts +1 -25
  36. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  37. package/dist/idl_codegen/errors/custom.js +1 -43
  38. package/dist/idl_codegen/errors/custom.js.map +1 -1
  39. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -2
  40. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
  41. package/dist/idl_codegen/instructions/idlMissingTypes.js +1 -2
  42. package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
  43. package/dist/idl_codegen/instructions/index.d.ts +0 -6
  44. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  45. package/dist/idl_codegen/instructions/index.js +1 -7
  46. package/dist/idl_codegen/instructions/index.js.map +1 -1
  47. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +3 -4
  48. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
  49. package/dist/idl_codegen/instructions/updateReserveConfig.js +3 -5
  50. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  51. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
  52. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
  53. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +6 -2
  54. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  55. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -33
  56. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  57. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -60
  58. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  59. package/dist/idl_codegen/types/index.d.ts +2 -6
  60. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  61. package/dist/idl_codegen/types/index.js +1 -3
  62. package/dist/idl_codegen/types/index.js.map +1 -1
  63. package/dist/utils/accountListing.d.ts +1 -1
  64. package/dist/utils/accountListing.d.ts.map +1 -1
  65. package/dist/utils/accountListing.js +2 -2
  66. package/dist/utils/accountListing.js.map +1 -1
  67. package/dist/utils/lookupTable.d.ts.map +1 -1
  68. package/dist/utils/lookupTable.js +6 -1
  69. package/dist/utils/lookupTable.js.map +1 -1
  70. package/dist/utils/managerTypes.d.ts.map +1 -1
  71. package/dist/utils/managerTypes.js +4 -10
  72. package/dist/utils/managerTypes.js.map +1 -1
  73. package/dist/utils/seeds.d.ts +0 -16
  74. package/dist/utils/seeds.d.ts.map +1 -1
  75. package/dist/utils/seeds.js +1 -23
  76. package/dist/utils/seeds.js.map +1 -1
  77. package/package.json +1 -1
  78. package/src/classes/farm_utils.ts +11 -3
  79. package/src/classes/manager.ts +401 -51
  80. package/src/classes/obligation.ts +0 -16
  81. package/src/classes/reserve.ts +783 -119
  82. package/src/classes/utils.ts +0 -12
  83. package/src/classes/vault.ts +18 -7
  84. package/src/client_kamino_manager.ts +34 -42
  85. package/src/idl.json +9 -186
  86. package/src/idl_codegen/accounts/LendingMarket.ts +9 -41
  87. package/src/idl_codegen/accounts/index.ts +0 -2
  88. package/src/idl_codegen/errors/custom.ts +0 -45
  89. package/src/idl_codegen/instructions/idlMissingTypes.ts +2 -4
  90. package/src/idl_codegen/instructions/index.ts +0 -9
  91. package/src/idl_codegen/instructions/updateReserveConfig.ts +5 -7
  92. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +8 -4
  93. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -73
  94. package/src/idl_codegen/types/index.ts +2 -16
  95. package/src/utils/accountListing.ts +3 -2
  96. package/src/utils/lookupTable.ts +7 -1
  97. package/src/utils/managerTypes.ts +4 -10
  98. package/src/utils/seeds.ts +0 -25
  99. package/dist/classes/configItems.d.ts +0 -166
  100. package/dist/classes/configItems.d.ts.map +0 -1
  101. package/dist/classes/configItems.js +0 -202
  102. package/dist/classes/configItems.js.map +0 -1
  103. package/dist/idl_codegen/accounts/GlobalConfig.d.ts +0 -40
  104. package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +0 -1
  105. package/dist/idl_codegen/accounts/GlobalConfig.js +0 -116
  106. package/dist/idl_codegen/accounts/GlobalConfig.js.map +0 -1
  107. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +0 -10
  108. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +0 -1
  109. package/dist/idl_codegen/instructions/initGlobalConfig.js +0 -19
  110. package/dist/idl_codegen/instructions/initGlobalConfig.js.map +0 -1
  111. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +0 -13
  112. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +0 -1
  113. package/dist/idl_codegen/instructions/updateGlobalConfig.js +0 -61
  114. package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +0 -1
  115. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +0 -7
  116. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +0 -1
  117. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +0 -16
  118. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +0 -1
  119. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +0 -32
  120. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +0 -1
  121. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +0 -108
  122. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +0 -1
  123. package/src/classes/configItems.ts +0 -295
  124. package/src/idl_codegen/accounts/GlobalConfig.ts +0 -125
  125. package/src/idl_codegen/instructions/initGlobalConfig.ts +0 -30
  126. package/src/idl_codegen/instructions/updateGlobalConfig.ts +0 -47
  127. package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +0 -24
  128. package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +0 -90
@@ -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
- signer: PublicKey
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.signer, isSigner: true, isWritable: false },
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: types.UpdateConfigModeKind
8
+ mode: BN
9
9
  value: Uint8Array
10
10
  skipValidation: boolean
11
11
  }
12
12
 
13
13
  export interface UpdateReserveConfigAccounts {
14
- signer: PublicKey
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
- types.UpdateConfigMode.layout("mode"),
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.signer, isSigner: true, isWritable: false },
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.toEncodable(),
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
- globalConfig: PublicKey
12
+ lendingMarketOwner: PublicKey
13
13
  lendingMarket: PublicKey
14
14
  reserve: PublicKey
15
15
  reserveLiquidityMint: PublicKey
16
16
  lendingMarketAuthority: PublicKey
17
17
  feeVault: PublicKey
18
- feeCollectorAta: PublicKey
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.globalConfig, isSigner: false, isWritable: false },
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
- { pubkey: accounts.feeCollectorAta, isSigner: false, isWritable: true },
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 UpdateObligationOrderExecutionEnabledJSON {
513
- kind: "UpdateObligationOrderExecutionEnabled"
512
+ export interface UpdateObligationOrdersEnabledJSON {
513
+ kind: "UpdateObligationOrdersEnabled"
514
514
  }
515
515
 
516
- export class UpdateObligationOrderExecutionEnabled {
516
+ export class UpdateObligationOrdersEnabled {
517
517
  static readonly discriminator = 22
518
- static readonly kind = "UpdateObligationOrderExecutionEnabled"
518
+ static readonly kind = "UpdateObligationOrdersEnabled"
519
519
  readonly discriminator = 22
520
- readonly kind = "UpdateObligationOrderExecutionEnabled"
520
+ readonly kind = "UpdateObligationOrdersEnabled"
521
521
 
522
- toJSON(): UpdateObligationOrderExecutionEnabledJSON {
522
+ toJSON(): UpdateObligationOrdersEnabledJSON {
523
523
  return {
524
- kind: "UpdateObligationOrderExecutionEnabled",
524
+ kind: "UpdateObligationOrdersEnabled",
525
525
  }
526
526
  }
527
527
 
528
528
  toEncodable() {
529
529
  return {
530
- UpdateObligationOrderExecutionEnabled: {},
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 ("UpdateObligationOrderExecutionEnabled" in obj) {
654
- return new UpdateObligationOrderExecutionEnabled()
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 "UpdateObligationOrderExecutionEnabled": {
737
- return new UpdateObligationOrderExecutionEnabled()
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([], "UpdateObligationOrderExecutionEnabled"),
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.UpdateObligationOrderExecutionEnabled
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.UpdateObligationOrderExecutionEnabledJSON
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(PROGRAM_ID, {
63
+ const lendingMarkets = await connection.getProgramAccounts(programId, {
63
64
  filters: [
64
65
  {
65
66
  dataSize: LendingMarket.layout.span + 8,
@@ -15,7 +15,13 @@ export async function createLookupTableIx(
15
15
  connection: Connection,
16
16
  wallet: PublicKey
17
17
  ): Promise<[TransactionInstruction, PublicKey]> {
18
- return initLookupTableIx(wallet, await connection.getSlot('confirmed'));
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: new Array(20).fill(0),
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),
@@ -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
@@ -1,166 +0,0 @@
1
- import { Layout } from '@coral-xyz/borsh';
2
- /**
3
- * An object literal specifying *all* "update mode" enum values (of type {@code M}) and their corresponding config items
4
- * (belonging to a top-level config struct {@code C}).
5
- *
6
- * An instance of this type is needed to construct a {@link ConfigUpdater}, as shown below.
7
- *
8
- * @example
9
- * ```
10
- * // Define the updater using a "map" - the line below would NOT compile if you forgot about any `StarWarsUpdateMode`:
11
- * const STAR_WARS_UPDATER = new ConfigUpdater(StarWarsUpdateMode.fromDecoded, StarWars, (config) => ({
12
- * [StarWarsUpdateMode.ANewHope.kind]: config.aNewHope,
13
- * [StarWarsUpdateMode.TheEmpireStrikesBack.kind]: config.theEmpireStrikesBack,
14
- * [StarWarsUpdateMode.ReturnOfTheJedi.kind]: config.returnOfTheJedi,
15
- * }));
16
- * ```
17
- */
18
- export type ConfigItemMap<M extends BorshEnum, C> = BorshEnumMap<M, SingleOrArray<ConfigItem<C, any>>>;
19
- /**
20
- * As advertised.
21
- */
22
- export type SingleOrArray<T> = T | T[];
23
- /**
24
- * A set of everything required to create an update ix for a single config item of type {@code A} belonging to a
25
- * config object of type {@code C}.
26
- */
27
- export type ConfigItem<C, A> = {
28
- readonly __layout: Layout<A>;
29
- readonly __getter: Getter<C, A>;
30
- };
31
- /**
32
- * A {@link ConfigItem} representing a borsh structure.
33
- *
34
- * Such structure may be used:
35
- * - either directly (i.e. a borsh-serialized "fat" config item, e.g. `ReserveConfig.borrowRateCurve`),
36
- * - or just to access its fields (e.g. `ReserveConfig.tokenInfo.pythConfiguration.price`).
37
- */
38
- export type StructConfigItem<C, A extends Record<string, any>> = ConfigItem<C, A> & {
39
- [K in keyof A]: A[K] extends object ? StructConfigItem<C, A[K]> : ConfigItem<C, A>;
40
- };
41
- /**
42
- * A syntactic sugar allowing for auto-completion of values within {@link ConfigItemMap}.
43
- */
44
- export type AnyConfigItem<C, A> = A extends Record<string, any> ? StructConfigItem<C, A> : ConfigItem<C, A>;
45
- /**
46
- * A composite {@link ConfigItem}, allowing to encode multiple fields together.
47
- *
48
- * @example
49
- * ```
50
- * ...
51
- * [CartoonsUpdateMode.UpdateTomAndJerry.discriminator]: new CompositeConfigItem(
52
- * CARTOONS.value().characters.cats.tom,
53
- * CARTOONS.value().characters.rodents.jerry
54
- * ),
55
- * ...
56
- * ```
57
- */
58
- export declare class CompositeConfigItem<C> implements ConfigItem<C, Record<string, any>> {
59
- readonly __layout: Layout<Record<string, any>>;
60
- readonly __getter: Getter<C, Record<string, any>>;
61
- constructor(...components: AnyConfigItem<C, any>[]);
62
- }
63
- /**
64
- * Creates an array of config items - one per each element of the given array.
65
- *
66
- * An example use-case is `LendingMarket.elevationGroups[]`: to update all of them, we need N ixs:
67
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[0])`
68
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[1])`
69
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[2])`
70
- * ...
71
- *
72
- * So: conceptually, the *array* is not "a config item". Each *slot* in that array is its own config item.
73
- */
74
- export declare function arrayElementConfigItems<C, A>(arrayConfigItem: ConfigItem<C, A[]>): ConfigItem<C, A>[];
75
- /**
76
- * A constructor reference of a borsh structure.
77
- */
78
- export interface BorshStructClass<C> {
79
- new (...args: any[]): C;
80
- layout: any;
81
- }
82
- /**
83
- * A missing common type for borsh enums, which borsh should really have provided itself.
84
- */
85
- export interface BorshEnum {
86
- kind: string;
87
- }
88
- /**
89
- * A part of a {@link ConfigUpdater} responsible for a single config item.
90
- */
91
- export declare class ConfigItemUpdater<C, A> {
92
- private readonly item;
93
- constructor(item: ConfigItem<C, A>);
94
- /**
95
- * Returns a serialized value of the specific config item extracted from the given top-level {@code newConfig}, or
96
- * `undefined` if the value has not changed from the given {@code currentConfig}.
97
- */
98
- encodeUpdatedItemFrom(currentConfig: C | undefined, newConfig: C): Uint8Array | undefined;
99
- /**
100
- * Borsh-serializes the given value.
101
- *
102
- * Only exposed for some legacy callers which still construct the update ixs manually (in tests).
103
- */
104
- encodeItem(item: A): Uint8Array;
105
- }
106
- /**
107
- * A resolver of config item changes.
108
- */
109
- export declare class ConfigUpdater<M extends BorshEnum, C> {
110
- private readonly itemUpdaters;
111
- /**
112
- * A resolving constructor.
113
- *
114
- * The inputs:
115
- * - `fromDecoded`: a reference to the codegen'ed enum-decoding function, e.g. `UpdateConfigMode.fromDecoded`. Needed
116
- * to turn the `<enumClass>.kind` strings into enums (i.e. instances of `M`).
117
- * - `configClass`: a reference to the codegen'ed top-level config class, e.g. `ReserveConfig`. Need to create a
118
- * completion helper for the `itemMapBuilder`.
119
- * - `itemMapBuilder`: a function building a {@link ConfigItemMap} using the completion helper provided as its
120
- * argument, e.g. `(config) => ({[UpdateLendingMarketMode.UpdateImmutableFlag.kind]: config.immutable, ...})`.
121
- *
122
- * See the usage example at {@link ConfigItemMap}.
123
- */
124
- constructor(fromDecoded: (mode: any) => M, configClass: BorshStructClass<C>, itemMapBuilder: (config: AnyConfigItem<C, C>) => ConfigItemMap<M, C>);
125
- /**
126
- * Returns all changes between the given current and new configs - in particular, this will be *all* supported fields'
127
- * changes if the previous config does not exist.
128
- *
129
- * Please note that more than one {@link EncodedConfigUpdate}s can be associated with a single `M` enum value (in
130
- * cases where e.g. an array property is updated by individual updates of its elements).
131
- */
132
- encodeAllUpdates(currentConfig: C | undefined, newConfig: C): EncodedConfigUpdate<M>[];
133
- /**
134
- * Gets the single updater of the given config item.
135
- *
136
- * Throws an error if the updates are not supported (e.g. for deprecated modes) or if the given item is handled by
137
- * multiple updaters (e.g. for an array property) - to handle these cases, use {@link allForMode()}.
138
- */
139
- forMode(mode: M): ConfigItemUpdater<C, any>;
140
- /**
141
- * Gets all the updaters of the given config item.
142
- *
143
- * This may be an empty array (e.g. for deprecated modes), or multiple elements (e.g. if an array property is updated
144
- * by individual updates of its elements). If you expect a single updater, use {@link forMode()}.
145
- */
146
- allForMode(mode: M): ConfigItemUpdater<C, any>[];
147
- }
148
- /**
149
- * The update mode discriminator and the serialized value needed to construct an update ix.
150
- */
151
- export type EncodedConfigUpdate<M extends BorshEnum> = {
152
- mode: M;
153
- value: Uint8Array;
154
- };
155
- /**
156
- * Borsh-serializes the given value according to the given layout.
157
- *
158
- * Only exposed for some legacy callers which still construct the update ixs manually (in tests).
159
- */
160
- export declare function encodeUsingLayout<T>(layout: Layout<T>, value: T): Uint8Array;
161
- type BorshEnumMap<M extends BorshEnum, T> = {
162
- [Key in M['kind']]: T;
163
- };
164
- type Getter<C, A> = (config: C) => A;
165
- export {};
166
- //# sourceMappingURL=configItems.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configItems.d.ts","sourceRoot":"","sources":["../../src/classes/configItems.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,IAAI,YAAY,CAAC,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAEvG;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACjC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;KACjF,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;CACnF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,G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