@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
@@ -509,25 +509,71 @@ export class UpdateInitialDepositAmount {
509
509
  }
510
510
  }
511
511
 
512
- export interface UpdateObligationOrdersEnabledJSON {
513
- kind: "UpdateObligationOrdersEnabled"
512
+ export interface UpdateObligationOrderExecutionEnabledJSON {
513
+ kind: "UpdateObligationOrderExecutionEnabled"
514
514
  }
515
515
 
516
- export class UpdateObligationOrdersEnabled {
516
+ export class UpdateObligationOrderExecutionEnabled {
517
517
  static readonly discriminator = 22
518
- static readonly kind = "UpdateObligationOrdersEnabled"
518
+ static readonly kind = "UpdateObligationOrderExecutionEnabled"
519
519
  readonly discriminator = 22
520
- readonly kind = "UpdateObligationOrdersEnabled"
520
+ readonly kind = "UpdateObligationOrderExecutionEnabled"
521
521
 
522
- toJSON(): UpdateObligationOrdersEnabledJSON {
522
+ toJSON(): UpdateObligationOrderExecutionEnabledJSON {
523
523
  return {
524
- kind: "UpdateObligationOrdersEnabled",
524
+ kind: "UpdateObligationOrderExecutionEnabled",
525
525
  }
526
526
  }
527
527
 
528
528
  toEncodable() {
529
529
  return {
530
- UpdateObligationOrdersEnabled: {},
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: {},
531
577
  }
532
578
  }
533
579
  }
@@ -604,8 +650,14 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
604
650
  if ("UpdateInitialDepositAmount" in obj) {
605
651
  return new UpdateInitialDepositAmount()
606
652
  }
607
- if ("UpdateObligationOrdersEnabled" in obj) {
608
- return new UpdateObligationOrdersEnabled()
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()
609
661
  }
610
662
 
611
663
  throw new Error("Invalid enum object")
@@ -681,8 +733,14 @@ export function fromJSON(
681
733
  case "UpdateInitialDepositAmount": {
682
734
  return new UpdateInitialDepositAmount()
683
735
  }
684
- case "UpdateObligationOrdersEnabled": {
685
- return new UpdateObligationOrdersEnabled()
736
+ case "UpdateObligationOrderExecutionEnabled": {
737
+ return new UpdateObligationOrderExecutionEnabled()
738
+ }
739
+ case "UpdateImmutableFlag": {
740
+ return new UpdateImmutableFlag()
741
+ }
742
+ case "UpdateObligationOrderCreationEnabled": {
743
+ return new UpdateObligationOrderCreationEnabled()
686
744
  }
687
745
  }
688
746
  }
@@ -711,7 +769,9 @@ export function layout(property?: string) {
711
769
  borsh.struct([], "UpdateName"),
712
770
  borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
713
771
  borsh.struct([], "UpdateInitialDepositAmount"),
714
- borsh.struct([], "UpdateObligationOrdersEnabled"),
772
+ borsh.struct([], "UpdateObligationOrderExecutionEnabled"),
773
+ borsh.struct([], "UpdateImmutableFlag"),
774
+ borsh.struct([], "UpdateObligationOrderCreationEnabled"),
715
775
  ])
716
776
  if (property !== undefined) {
717
777
  return ret.replicate(property)
@@ -1,6 +1,7 @@
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"
4
5
  import * as AssetTier from "./AssetTier"
5
6
  import * as FeeCalculation from "./FeeCalculation"
6
7
  import * as ReserveFarmKind from "./ReserveFarmKind"
@@ -159,7 +160,9 @@ export type UpdateLendingMarketModeKind =
159
160
  | UpdateLendingMarketMode.UpdateName
160
161
  | UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
161
162
  | UpdateLendingMarketMode.UpdateInitialDepositAmount
162
- | UpdateLendingMarketMode.UpdateObligationOrdersEnabled
163
+ | UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled
164
+ | UpdateLendingMarketMode.UpdateImmutableFlag
165
+ | UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled
163
166
  export type UpdateLendingMarketModeJSON =
164
167
  | UpdateLendingMarketMode.UpdateOwnerJSON
165
168
  | UpdateLendingMarketMode.UpdateEmergencyModeJSON
@@ -183,7 +186,18 @@ export type UpdateLendingMarketModeJSON =
183
186
  | UpdateLendingMarketMode.UpdateNameJSON
184
187
  | UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
185
188
  | UpdateLendingMarketMode.UpdateInitialDepositAmountJSON
186
- | UpdateLendingMarketMode.UpdateObligationOrdersEnabledJSON
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
187
201
 
188
202
  export { LastUpdate } from "./LastUpdate"
189
203
  export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
@@ -56,11 +56,10 @@ export async function* getAllReserveAccounts(
56
56
  }
57
57
 
58
58
  export async function* getAllLendingMarketAccounts(
59
- connection: Connection,
60
- programId: PublicKey = PROGRAM_ID
59
+ connection: Connection
61
60
  ): AsyncGenerator<[PublicKey, LendingMarket], void, unknown> {
62
61
  // 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
63
- const lendingMarkets = await connection.getProgramAccounts(programId, {
62
+ const lendingMarkets = await connection.getProgramAccounts(PROGRAM_ID, {
64
63
  filters: [
65
64
  {
66
65
  dataSize: LendingMarket.layout.span + 8,
package/src/utils/api.ts CHANGED
@@ -5,43 +5,29 @@ import { CDN_ENDPOINT, getApiEndpoint } from '../utils';
5
5
  import { IBackOffOptions, backOff } from 'exponential-backoff';
6
6
  import { PROGRAM_ID } from '../lib';
7
7
 
8
- export type ApiFilterOptions = {
9
- includeCurated?: boolean;
10
- };
11
-
12
8
  /**
13
9
  * Fetch config from the API
14
10
  * A good place to start to find active klend markets without expensive RPC calls
15
11
  *
16
12
  * @param programId - The program id to retrieve config for
17
13
  * @param source - CDN is a json file hosted in the cloud, API is a webserver
18
- * @param filterOptions - Config options to filter markets by
19
14
  */
20
15
  export async function getMarketsFromApi(
21
16
  programId: PublicKey = PROGRAM_ID,
22
- source: 'API' | 'CDN' = 'CDN',
23
- filterOptions: ApiFilterOptions = {},
17
+ source: 'API' | 'CDN' = 'CDN'
24
18
  ): Promise<ConfigType> {
25
- const defaultedFilterOptions: Required<ApiFilterOptions> = {
26
- includeCurated: filterOptions.includeCurated || true
27
- };
19
+ let configs: ConfigType = {} as ConfigType;
28
20
 
29
- let unfilteredConfigs: ConfigType = {} as ConfigType;
30
21
  if (source === 'CDN') {
31
- unfilteredConfigs = (await backOff(() => axios.get(CDN_ENDPOINT), KAMINO_CDN_RETRY)).data[programId.toString()] as ConfigType;
22
+ configs = (await backOff(() => axios.get(CDN_ENDPOINT), KAMINO_CDN_RETRY)).data[programId.toString()] as ConfigType;
32
23
  }
33
24
 
34
- if (!unfilteredConfigs || isEmptyObject(unfilteredConfigs)) {
25
+ if (!configs || isEmptyObject(configs)) {
35
26
  const API_ENDPOINT = getApiEndpoint(programId);
36
- unfilteredConfigs = (await backOff(() => axios.get(API_ENDPOINT), KAMINO_API_RETRY)).data as ConfigType;
27
+ configs = (await backOff(() => axios.get(API_ENDPOINT), KAMINO_API_RETRY)).data as ConfigType;
37
28
  }
38
29
 
39
- return unfilteredConfigs.filter((c) => {
40
- if (!defaultedFilterOptions.includeCurated) {
41
- return !c.isCurated;
42
- }
43
- return true;
44
- });
30
+ return configs;
45
31
  }
46
32
 
47
33
  export const KAMINO_CDN_RETRY: Partial<IBackOffOptions> = {
@@ -27,7 +27,7 @@ export function getApiEndpoint(programId: PublicKey) {
27
27
  }
28
28
  }
29
29
 
30
- export const CDN_ENDPOINT = 'https://cdn.kamino.finance/kamino_lend_config_v3.json';
30
+ export const CDN_ENDPOINT = 'https://cdn.kamino.finance/kamino_lend_config_v2.json';
31
31
 
32
32
  export const ONE_HUNDRED_PCT_IN_BPS = 10_000;
33
33
 
@@ -15,13 +15,7 @@ export async function createLookupTableIx(
15
15
  connection: Connection,
16
16
  wallet: PublicKey
17
17
  ): Promise<[TransactionInstruction, PublicKey]> {
18
- const [createLookupTableIxs, lookupTableAddress] = AddressLookupTableProgram.createLookupTable({
19
- authority: wallet,
20
- payer: wallet,
21
- recentSlot: await connection.getSlot('confirmed'),
22
- });
23
-
24
- return [createLookupTableIxs, lookupTableAddress];
18
+ return initLookupTableIx(wallet, await connection.getSlot('confirmed'));
25
19
  }
26
20
 
27
21
  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: [0, 0, 0, 0, 0],
265
+ elevationGroups: new Array(20).fill(0),
266
266
  priceFeed: null,
267
267
  borrowLimit: new Decimal(1000.0),
268
268
  depositLimit: new Decimal(1000.0),
@@ -334,7 +334,9 @@ 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).floor().toString()
337
+ numberToLamportsDecimal(fields.configParams.depositLimit ?? new Decimal(0), fields.mintDecimals)
338
+ .floor()
339
+ .toString()
338
340
  ),
339
341
  currentTotal: new BN(0),
340
342
  lastIntervalStartTimestamp: new BN(0),
@@ -342,7 +344,9 @@ function buildReserveConfig(fields: {
342
344
  }),
343
345
  debtWithdrawalCap: new WithdrawalCaps({
344
346
  configCapacity: new BN(
345
- numberToLamportsDecimal(fields.debtWithdrawalCapConfigCapacity ?? new Decimal(0), fields.mintDecimals).floor().toString()
347
+ numberToLamportsDecimal(fields.debtWithdrawalCapConfigCapacity ?? new Decimal(0), fields.mintDecimals)
348
+ .floor()
349
+ .toString()
346
350
  ),
347
351
  currentTotal: new BN(0),
348
352
  lastIntervalStartTimestamp: new BN(0),
@@ -357,7 +361,9 @@ function buildReserveConfig(fields: {
357
361
  hostFixedInterestRateBps: 0,
358
362
  autodeleverageEnabled: 0,
359
363
  borrowLimitOutsideElevationGroup: new BN(
360
- numberToLamportsDecimal(fields.borrowLimitOutsideElevationGroup ?? new Decimal(0), fields.mintDecimals).floor().toString()
364
+ numberToLamportsDecimal(fields.borrowLimitOutsideElevationGroup ?? new Decimal(0), fields.mintDecimals)
365
+ .floor()
366
+ .toString()
361
367
  ),
362
368
  borrowLimitAgainstThisCollateralInElevationGroup: Array(32).fill(new BN(0)),
363
369
  deleveragingBonusIncreaseBpsPerDay: new BN(100),
@@ -39,6 +39,10 @@ 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';
42
46
  /**
43
47
  * Farm user state seed
44
48
  */
@@ -193,6 +197,27 @@ export function shortUrlPda(shortUrl: string, programId: PublicKey = PROGRAM_ID)
193
197
  return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_SHORT_URL), Buffer.from(shortUrl)], programId);
194
198
  }
195
199
 
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
+
196
221
  /**
197
222
  * Returns the PDA for the obligation farm state
198
223
  * @param farm