@kamino-finance/klend-sdk 5.11.5 → 5.11.6-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 (124) hide show
  1. package/dist/classes/action.d.ts +23 -23
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +195 -122
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/index.d.ts +0 -1
  6. package/dist/classes/index.d.ts.map +1 -1
  7. package/dist/classes/index.js +0 -1
  8. package/dist/classes/index.js.map +1 -1
  9. package/dist/classes/manager.d.ts +1 -6
  10. package/dist/classes/manager.d.ts.map +1 -1
  11. package/dist/classes/manager.js +1 -16
  12. package/dist/classes/manager.js.map +1 -1
  13. package/dist/classes/market.d.ts +3 -3
  14. package/dist/classes/market.d.ts.map +1 -1
  15. package/dist/classes/market.js +16 -30
  16. package/dist/classes/market.js.map +1 -1
  17. package/dist/classes/obligation.d.ts +0 -2
  18. package/dist/classes/obligation.d.ts.map +1 -1
  19. package/dist/classes/obligation.js +0 -5
  20. package/dist/classes/obligation.js.map +1 -1
  21. package/dist/classes/types.d.ts.map +1 -1
  22. package/dist/classes/vault.d.ts +0 -1
  23. package/dist/classes/vault.d.ts.map +1 -1
  24. package/dist/classes/vault.js +18 -21
  25. package/dist/classes/vault.js.map +1 -1
  26. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -6
  27. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  28. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -13
  29. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  30. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +1 -25
  31. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
  32. package/dist/idl_codegen_kamino_vault/errors/custom.js +1 -43
  33. package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
  34. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
  35. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
  36. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
  37. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
  38. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +0 -1
  39. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
  40. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +0 -1
  41. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
  42. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
  43. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
  44. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
  45. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
  46. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
  47. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
  48. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
  49. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
  50. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +1 -1
  51. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
  52. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
  53. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
  54. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
  55. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
  56. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
  57. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
  58. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
  59. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
  60. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
  61. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
  62. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +0 -13
  63. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
  64. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +1 -25
  65. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
  66. package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
  67. package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
  68. package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
  69. package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
  70. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  71. package/dist/lending_operations/repay_with_collateral_operations.js +8 -10
  72. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  73. package/dist/lending_operations/swap_collateral_operations.d.ts +2 -2
  74. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  75. package/dist/lending_operations/swap_collateral_operations.js +6 -11
  76. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  77. package/dist/leverage/operations.d.ts +7 -9
  78. package/dist/leverage/operations.d.ts.map +1 -1
  79. package/dist/leverage/operations.js +66 -78
  80. package/dist/leverage/operations.js.map +1 -1
  81. package/dist/leverage/types.d.ts +4 -4
  82. package/dist/leverage/types.d.ts.map +1 -1
  83. package/dist/utils/ObligationType.d.ts +1 -1
  84. package/dist/utils/ObligationType.d.ts.map +1 -1
  85. package/dist/utils/constants.d.ts +0 -1
  86. package/dist/utils/constants.d.ts.map +1 -1
  87. package/dist/utils/constants.js +1 -2
  88. package/dist/utils/constants.js.map +1 -1
  89. package/dist/utils/managerTypes.d.ts.map +1 -1
  90. package/dist/utils/managerTypes.js +52 -7
  91. package/dist/utils/managerTypes.js.map +1 -1
  92. package/dist/utils/oracle.d.ts +3 -3
  93. package/dist/utils/oracle.d.ts.map +1 -1
  94. package/dist/utils/oracle.js +3 -4
  95. package/dist/utils/oracle.js.map +1 -1
  96. package/package.json +2 -2
  97. package/src/classes/action.ts +211 -143
  98. package/src/classes/index.ts +0 -1
  99. package/src/classes/manager.ts +1 -27
  100. package/src/classes/market.ts +25 -34
  101. package/src/classes/obligation.ts +0 -6
  102. package/src/classes/types.ts +1 -1
  103. package/src/classes/vault.ts +22 -23
  104. package/src/client.ts +3 -8
  105. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -17
  106. package/src/idl_codegen_kamino_vault/errors/custom.ts +0 -42
  107. package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
  108. package/src/idl_codegen_kamino_vault/instructions/initVault.ts +0 -2
  109. package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
  110. package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
  111. package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
  112. package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
  113. package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
  114. package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +0 -30
  115. package/src/idl_codegen_kamino_vault/types/index.ts +0 -2
  116. package/src/idl_kamino_vault.json +8 -35
  117. package/src/lending_operations/repay_with_collateral_operations.ts +11 -15
  118. package/src/lending_operations/swap_collateral_operations.ts +7 -19
  119. package/src/leverage/operations.ts +66 -114
  120. package/src/leverage/types.ts +4 -4
  121. package/src/utils/ObligationType.ts +1 -1
  122. package/src/utils/constants.ts +0 -1
  123. package/src/utils/managerTypes.ts +52 -10
  124. package/src/utils/oracle.ts +6 -7
@@ -10,7 +10,7 @@ export interface UpdateReserveAllocationArgs {
10
10
  }
11
11
 
12
12
  export interface UpdateReserveAllocationAccounts {
13
- signer: PublicKey
13
+ adminAuthority: PublicKey
14
14
  vaultState: PublicKey
15
15
  baseVaultAuthority: PublicKey
16
16
  reserveCollateralMint: PublicKey
@@ -29,7 +29,7 @@ export function updateReserveAllocation(
29
29
  programId: PublicKey = PROGRAM_ID
30
30
  ) {
31
31
  const keys: Array<AccountMeta> = [
32
- { pubkey: accounts.signer, isSigner: true, isWritable: true },
32
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
33
33
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
34
34
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
35
35
  {
@@ -11,7 +11,7 @@ export interface UpdateSharesMetadataArgs {
11
11
  }
12
12
 
13
13
  export interface UpdateSharesMetadataAccounts {
14
- vaultAdminAuthority: PublicKey
14
+ adminAuthority: PublicKey
15
15
  vaultState: PublicKey
16
16
  baseVaultAuthority: PublicKey
17
17
  sharesMetadata: PublicKey
@@ -30,7 +30,7 @@ export function updateSharesMetadata(
30
30
  programId: PublicKey = PROGRAM_ID
31
31
  ) {
32
32
  const keys: Array<AccountMeta> = [
33
- { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
33
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
34
34
  { pubkey: accounts.vaultState, isSigner: false, isWritable: false },
35
35
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
36
36
  { pubkey: accounts.sharesMetadata, isSigner: false, isWritable: true },
@@ -10,7 +10,7 @@ export interface UpdateVaultConfigArgs {
10
10
  }
11
11
 
12
12
  export interface UpdateVaultConfigAccounts {
13
- vaultAdminAuthority: PublicKey
13
+ adminAuthority: PublicKey
14
14
  vaultState: PublicKey
15
15
  klendProgram: PublicKey
16
16
  }
@@ -26,7 +26,7 @@ export function updateVaultConfig(
26
26
  programId: PublicKey = PROGRAM_ID
27
27
  ) {
28
28
  const keys: Array<AccountMeta> = [
29
- { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: false },
29
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: false },
30
30
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
31
31
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
32
32
  ]
@@ -5,7 +5,7 @@ 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 WithdrawPendingFeesAccounts {
8
- vaultAdminAuthority: PublicKey
8
+ adminAuthority: PublicKey
9
9
  vaultState: PublicKey
10
10
  reserve: PublicKey
11
11
  tokenVault: PublicKey
@@ -29,7 +29,7 @@ export function withdrawPendingFees(
29
29
  programId: PublicKey = PROGRAM_ID
30
30
  ) {
31
31
  const keys: Array<AccountMeta> = [
32
- { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
32
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
33
33
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
34
34
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
35
35
  { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
@@ -256,29 +256,6 @@ export class Farm {
256
256
  }
257
257
  }
258
258
 
259
- export interface AllocationAdminJSON {
260
- kind: "AllocationAdmin"
261
- }
262
-
263
- export class AllocationAdmin {
264
- static readonly discriminator = 11
265
- static readonly kind = "AllocationAdmin"
266
- readonly discriminator = 11
267
- readonly kind = "AllocationAdmin"
268
-
269
- toJSON(): AllocationAdminJSON {
270
- return {
271
- kind: "AllocationAdmin",
272
- }
273
- }
274
-
275
- toEncodable() {
276
- return {
277
- AllocationAdmin: {},
278
- }
279
- }
280
- }
281
-
282
259
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
283
260
  export function fromDecoded(obj: any): types.VaultConfigFieldKind {
284
261
  if (typeof obj !== "object") {
@@ -318,9 +295,6 @@ export function fromDecoded(obj: any): types.VaultConfigFieldKind {
318
295
  if ("Farm" in obj) {
319
296
  return new Farm()
320
297
  }
321
- if ("AllocationAdmin" in obj) {
322
- return new AllocationAdmin()
323
- }
324
298
 
325
299
  throw new Error("Invalid enum object")
326
300
  }
@@ -362,9 +336,6 @@ export function fromJSON(
362
336
  case "Farm": {
363
337
  return new Farm()
364
338
  }
365
- case "AllocationAdmin": {
366
- return new AllocationAdmin()
367
- }
368
339
  }
369
340
  }
370
341
 
@@ -381,7 +352,6 @@ export function layout(property?: string) {
381
352
  borsh.struct([], "Name"),
382
353
  borsh.struct([], "LookupTable"),
383
354
  borsh.struct([], "Farm"),
384
- borsh.struct([], "AllocationAdmin"),
385
355
  ])
386
356
  if (property !== undefined) {
387
357
  return ret.replicate(property)
@@ -63,7 +63,6 @@ export type VaultConfigFieldKind =
63
63
  | VaultConfigField.Name
64
64
  | VaultConfigField.LookupTable
65
65
  | VaultConfigField.Farm
66
- | VaultConfigField.AllocationAdmin
67
66
  export type VaultConfigFieldJSON =
68
67
  | VaultConfigField.PerformanceFeeBpsJSON
69
68
  | VaultConfigField.ManagementFeeBpsJSON
@@ -76,7 +75,6 @@ export type VaultConfigFieldJSON =
76
75
  | VaultConfigField.NameJSON
77
76
  | VaultConfigField.LookupTableJSON
78
77
  | VaultConfigField.FarmJSON
79
- | VaultConfigField.AllocationAdminJSON
80
78
 
81
79
  export { VaultAllocation } from "./VaultAllocation"
82
80
  export type {
@@ -35,11 +35,6 @@
35
35
  "isMut": true,
36
36
  "isSigner": false
37
37
  },
38
- {
39
- "name": "adminTokenAccount",
40
- "isMut": true,
41
- "isSigner": false
42
- },
43
38
  {
44
39
  "name": "systemProgram",
45
40
  "isMut": false,
@@ -67,7 +62,7 @@
67
62
  "name": "updateReserveAllocation",
68
63
  "accounts": [
69
64
  {
70
- "name": "signer",
65
+ "name": "adminAuthority",
71
66
  "isMut": true,
72
67
  "isSigner": true
73
68
  },
@@ -403,7 +398,7 @@
403
398
  "name": "updateVaultConfig",
404
399
  "accounts": [
405
400
  {
406
- "name": "vaultAdminAuthority",
401
+ "name": "adminAuthority",
407
402
  "isMut": false,
408
403
  "isSigner": true
409
404
  },
@@ -435,7 +430,7 @@
435
430
  "name": "withdrawPendingFees",
436
431
  "accounts": [
437
432
  {
438
- "name": "vaultAdminAuthority",
433
+ "name": "adminAuthority",
439
434
  "isMut": true,
440
435
  "isSigner": true
441
436
  },
@@ -540,7 +535,7 @@
540
535
  "name": "giveUpPendingFees",
541
536
  "accounts": [
542
537
  {
543
- "name": "vaultAdminAuthority",
538
+ "name": "adminAuthority",
544
539
  "isMut": true,
545
540
  "isSigner": true
546
541
  },
@@ -566,7 +561,7 @@
566
561
  "name": "initializeSharesMetadata",
567
562
  "accounts": [
568
563
  {
569
- "name": "vaultAdminAuthority",
564
+ "name": "adminAuthority",
570
565
  "isMut": true,
571
566
  "isSigner": true
572
567
  },
@@ -625,7 +620,7 @@
625
620
  "name": "updateSharesMetadata",
626
621
  "accounts": [
627
622
  {
628
- "name": "vaultAdminAuthority",
623
+ "name": "adminAuthority",
629
624
  "isMut": true,
630
625
  "isSigner": true
631
626
  },
@@ -858,7 +853,7 @@
858
853
  "kind": "struct",
859
854
  "fields": [
860
855
  {
861
- "name": "vaultAdminAuthority",
856
+ "name": "adminAuthority",
862
857
  "type": "publicKey"
863
858
  },
864
859
  {
@@ -1001,16 +996,12 @@
1001
996
  "name": "padding1",
1002
997
  "type": "u64"
1003
998
  },
1004
- {
1005
- "name": "allocationAdmin",
1006
- "type": "publicKey"
1007
- },
1008
999
  {
1009
1000
  "name": "padding2",
1010
1001
  "type": {
1011
1002
  "array": [
1012
1003
  "u128",
1013
- 242
1004
+ 244
1014
1005
  ]
1015
1006
  }
1016
1007
  }
@@ -1883,9 +1874,6 @@
1883
1874
  },
1884
1875
  {
1885
1876
  "name": "Farm"
1886
- },
1887
- {
1888
- "name": "AllocationAdmin"
1889
1877
  }
1890
1878
  ]
1891
1879
  }
@@ -2172,21 +2160,6 @@
2172
2160
  "code": 7043,
2173
2161
  "name": "MissingReserveForBatchRefresh",
2174
2162
  "msg": "Missing reserve for batch refresh"
2175
- },
2176
- {
2177
- "code": 7044,
2178
- "name": "MinWithdrawAmountTooBig",
2179
- "msg": "Min withdraw amount is too big"
2180
- },
2181
- {
2182
- "code": 7045,
2183
- "name": "InvestTooSoon",
2184
- "msg": "Invest is called too soon after last invest"
2185
- },
2186
- {
2187
- "code": 7046,
2188
- "name": "WrongAdminOrAllocationAdmin",
2189
- "msg": "Wrong admin or allocation admin"
2190
2163
  }
2191
2164
  ]
2192
2165
  }
@@ -6,13 +6,12 @@ import {
6
6
  SwapIxs,
7
7
  SwapIxsProvider,
8
8
  SwapQuoteProvider,
9
- getScopeRefreshIx,
10
9
  } from '../leverage';
11
10
  import {
12
11
  createAtasIdempotent,
13
12
  getComputeBudgetAndPriorityFeeIxns,
14
13
  removeBudgetAndAtaIxns,
15
- ScopePriceRefreshConfig,
14
+ ScopeRefresh,
16
15
  U64_MAX,
17
16
  uniqueAccounts,
18
17
  } from '../utils';
@@ -52,7 +51,7 @@ interface RepayWithCollSwapInputsProps<QuoteResponse> {
52
51
  repayAmount: Decimal;
53
52
  isClosingPosition: boolean;
54
53
  budgetAndPriorityFeeIxs?: TransactionInstruction[];
55
- scopeRefreshConfig?: ScopePriceRefreshConfig;
54
+ scopeRefresh?: ScopeRefresh;
56
55
  useV2Ixs: boolean;
57
56
  quoter: SwapQuoteProvider<QuoteResponse>;
58
57
  }
@@ -68,7 +67,7 @@ export async function getRepayWithCollSwapInputs<QuoteResponse>({
68
67
  repayAmount,
69
68
  isClosingPosition,
70
69
  budgetAndPriorityFeeIxs,
71
- scopeRefreshConfig,
70
+ scopeRefresh,
72
71
  useV2Ixs,
73
72
  }: RepayWithCollSwapInputsProps<QuoteResponse>): Promise<{
74
73
  swapInputs: SwapInputs;
@@ -127,7 +126,7 @@ export async function getRepayWithCollSwapInputs<QuoteResponse>({
127
126
  referrer,
128
127
  currentSlot,
129
128
  budgetAndPriorityFeeIxs,
130
- scopeRefreshConfig,
129
+ scopeRefresh,
131
130
  {
132
131
  preActionIxs: [],
133
132
  swapIxs: [],
@@ -192,7 +191,7 @@ export async function getRepayWithCollIxs<QuoteResponse>({
192
191
  quoter,
193
192
  swapper,
194
193
  referrer,
195
- scopeRefreshConfig,
194
+ scopeRefresh,
196
195
  useV2Ixs,
197
196
  logger = console.log,
198
197
  }: RepayWithCollIxsProps<QuoteResponse>): Promise<RepayWithCollIxsResponse<QuoteResponse>> {
@@ -207,7 +206,7 @@ export async function getRepayWithCollIxs<QuoteResponse>({
207
206
  repayAmount,
208
207
  isClosingPosition,
209
208
  budgetAndPriorityFeeIxs,
210
- scopeRefreshConfig,
209
+ scopeRefresh,
211
210
  useV2Ixs,
212
211
  });
213
212
  const { debtRepayAmountLamports, flashRepayAmountLamports, maxCollateralWithdrawLamports, swapQuote } = initialInputs;
@@ -245,7 +244,7 @@ export async function getRepayWithCollIxs<QuoteResponse>({
245
244
  referrer,
246
245
  currentSlot,
247
246
  budgetAndPriorityFeeIxs,
248
- scopeRefreshConfig,
247
+ scopeRefresh,
249
248
  swapResponse,
250
249
  isClosingPosition,
251
250
  debtRepayAmountLamports,
@@ -269,7 +268,7 @@ async function buildRepayWithCollateralIxs(
269
268
  referrer: PublicKey,
270
269
  currentSlot: number,
271
270
  budgetAndPriorityFeeIxs: TransactionInstruction[] | undefined,
272
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
271
+ scopeRefresh: ScopeRefresh | undefined,
273
272
  swapQuoteIxs: SwapIxs,
274
273
  isClosingPosition: boolean,
275
274
  debtRepayAmountLamports: Decimal,
@@ -287,11 +286,9 @@ async function buildRepayWithCollateralIxs(
287
286
  const atasAndIxs = createAtasIdempotent(obligation.state.owner, atas);
288
287
  const [, { ata: debtTokenAta }] = atasAndIxs;
289
288
 
290
- const scopeRefreshIxn = await getScopeRefreshIx(market, collReserve, debtReserve, obligation, scopeRefreshConfig);
291
-
292
289
  // 2. Flash borrow & repay the debt to repay amount needed
293
290
  const { flashBorrowIxn, flashRepayIxn } = getFlashLoanInstructions({
294
- borrowIxnIndex: budgetIxns.length + atasAndIxs.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
291
+ borrowIxnIndex: budgetIxns.length + atasAndIxs.length,
295
292
  walletPublicKey: obligation.state.owner,
296
293
  lendingMarketAuthority: market.getLendingMarketAuthority(),
297
294
  lendingMarketAddress: market.getAddress(),
@@ -317,13 +314,13 @@ async function buildRepayWithCollateralIxs(
317
314
  currentSlot,
318
315
  obligation,
319
316
  useV2Ixs,
320
- undefined,
321
317
  0,
322
318
  false,
323
319
  requestElevationGroup,
324
320
  undefined,
325
321
  undefined,
326
- referrer
322
+ referrer,
323
+ scopeRefresh
327
324
  );
328
325
 
329
326
  // 4. Swap collateral to debt to repay flash loan
@@ -331,7 +328,6 @@ async function buildRepayWithCollateralIxs(
331
328
  const swapInstructions = removeBudgetAndAtaIxns(swapIxs, []);
332
329
 
333
330
  return [
334
- ...scopeRefreshIxn,
335
331
  ...budgetIxns,
336
332
  ...atasAndIxs.map((x) => x.createAtaIx),
337
333
  flashBorrowIxn,
@@ -6,14 +6,14 @@ import {
6
6
  KaminoObligation,
7
7
  KaminoReserve,
8
8
  } from '../classes';
9
- import { getFlashLoanInstructions, getScopeRefreshIx, SwapIxsProvider, SwapQuoteProvider } from '../leverage';
9
+ import { getFlashLoanInstructions, SwapIxsProvider, SwapQuoteProvider } from '../leverage';
10
10
  import {
11
11
  createAtasIdempotent,
12
12
  DEFAULT_MAX_COMPUTE_UNITS,
13
13
  getAssociatedTokenAddress,
14
14
  getComputeBudgetAndPriorityFeeIxns,
15
15
  PublicKeySet,
16
- ScopePriceRefreshConfig,
16
+ ScopeRefresh,
17
17
  U64_MAX,
18
18
  uniqueAccounts,
19
19
  } from '../utils';
@@ -61,7 +61,7 @@ export interface SwapCollIxnsInputs<QuoteResponse> {
61
61
  referrer: PublicKey;
62
62
  currentSlot: number;
63
63
  budgetAndPriorityFeeIxns?: TransactionInstruction[];
64
- scopeRefreshConfig?: ScopePriceRefreshConfig;
64
+ scopeRefresh?: ScopeRefresh;
65
65
  useV2Ixs: boolean;
66
66
  quoter: SwapQuoteProvider<QuoteResponse>;
67
67
  swapper: SwapIxsProvider<QuoteResponse>;
@@ -205,7 +205,7 @@ type SwapCollContext<QuoteResponse> = {
205
205
  referrer: PublicKey;
206
206
  currentSlot: number;
207
207
  useV2Ixs: boolean;
208
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
208
+ scopeRefresh: ScopeRefresh | undefined;
209
209
  logger: (msg: string, ...extra: any[]) => void;
210
210
  };
211
211
 
@@ -235,7 +235,7 @@ function extractArgsAndContext<QuoteResponse>(
235
235
  quoter: inputs.quoter,
236
236
  swapper: inputs.swapper,
237
237
  referrer: inputs.referrer,
238
- scopeRefreshConfig: inputs.scopeRefreshConfig,
238
+ scopeRefresh: inputs.scopeRefresh,
239
239
  currentSlot: inputs.currentSlot,
240
240
  useV2Ixs: inputs.useV2Ixs,
241
241
  },
@@ -264,18 +264,6 @@ async function getKlendIxns(
264
264
  const { ataCreationIxns, targetCollAta } = getAtaCreationIxns(context);
265
265
  const setupIxns = [...context.budgetAndPriorityFeeIxns, ...ataCreationIxns];
266
266
 
267
- const scopeRefreshIxn = await getScopeRefreshIx(
268
- context.market,
269
- context.sourceCollReserve,
270
- context.targetCollReserve,
271
- context.obligation,
272
- context.scopeRefreshConfig
273
- );
274
-
275
- if (scopeRefreshIxn) {
276
- setupIxns.unshift(...scopeRefreshIxn);
277
- }
278
-
279
267
  const targetCollFlashBorrowedAmount = calculateTargetCollFlashBorrowedAmount(targetCollSwapOutAmount, context);
280
268
  const { targetCollFlashBorrowIxn, targetCollFlashRepayIxn } = getTargetCollFlashLoanIxns(
281
269
  targetCollFlashBorrowedAmount,
@@ -392,7 +380,6 @@ async function getDepositTargetCollIxns(
392
380
  context.obligation.state.owner,
393
381
  context.obligation,
394
382
  context.useV2Ixs,
395
- undefined, // we create the scope refresh ixn outside of KaminoAction
396
383
  0, // no extra compute budget
397
384
  false, // we do not need ATA ixns here (we construct and close them ourselves)
398
385
  removesElevationGroup, // we may need to (temporarily) remove the elevation group; the same or a different one will be set on withdraw, if requested
@@ -400,6 +387,7 @@ async function getDepositTargetCollIxns(
400
387
  false, // we do not need to create a lookup table, dealing with an existing obligation
401
388
  context.referrer,
402
389
  context.currentSlot,
390
+ context.scopeRefresh,
403
391
  removesElevationGroup ? 0 : undefined // only applicable when removing the group
404
392
  );
405
393
  return {
@@ -442,7 +430,6 @@ async function getWithdrawSourceCollIxns(
442
430
  context.obligation.state.owner,
443
431
  context.obligation,
444
432
  context.useV2Ixs,
445
- undefined, // we create the scope refresh ixn outside of KaminoAction
446
433
  0, // no extra compute budget
447
434
  false, // we do not need ATA ixns here (we construct and close them ourselves)
448
435
  requestedElevationGroup !== undefined, // the `elevationGroupIdToRequestAfterWithdraw()` has already decided on this
@@ -450,6 +437,7 @@ async function getWithdrawSourceCollIxns(
450
437
  false, // we do not need to create a lookup table, dealing with an existing obligation
451
438
  context.referrer,
452
439
  context.currentSlot,
440
+ undefined, // we have refreshed scope already, during depositing
453
441
  requestedElevationGroup,
454
442
  context.obligation.deposits.has(context.targetCollReserve.address) // if our obligation already had the target coll...
455
443
  ? undefined // ... then we need no customizations here, but otherwise...