@kamino-finance/klend-sdk 5.2.14 → 5.4.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 (142) hide show
  1. package/dist/classes/action.d.ts.map +1 -1
  2. package/dist/classes/action.js +1 -2
  3. package/dist/classes/action.js.map +1 -1
  4. package/dist/classes/manager.d.ts +2 -4
  5. package/dist/classes/manager.d.ts.map +1 -1
  6. package/dist/classes/manager.js +29 -20
  7. package/dist/classes/manager.js.map +1 -1
  8. package/dist/classes/market.d.ts +1 -2
  9. package/dist/classes/market.d.ts.map +1 -1
  10. package/dist/classes/market.js +7 -20
  11. package/dist/classes/market.js.map +1 -1
  12. package/dist/classes/reserve.js +14 -14
  13. package/dist/classes/reserve.js.map +1 -1
  14. package/dist/classes/shared.d.ts +2 -2
  15. package/dist/classes/shared.d.ts.map +1 -1
  16. package/dist/classes/vault.d.ts +2 -4
  17. package/dist/classes/vault.d.ts.map +1 -1
  18. package/dist/classes/vault.js +7 -15
  19. package/dist/classes/vault.js.map +1 -1
  20. package/dist/client_kamino_manager.js +7 -3
  21. package/dist/client_kamino_manager.js.map +1 -1
  22. package/dist/idl.json +310 -48
  23. package/dist/idl_codegen/accounts/LendingMarket.d.ts +48 -3
  24. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  25. package/dist/idl_codegen/accounts/LendingMarket.js +35 -8
  26. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  27. package/dist/idl_codegen/accounts/Obligation.d.ts +30 -0
  28. package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
  29. package/dist/idl_codegen/accounts/Obligation.js +23 -2
  30. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  31. package/dist/idl_codegen/accounts/Reserve.js +1 -1
  32. package/dist/idl_codegen/errors/custom.d.ts +33 -1
  33. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  34. package/dist/idl_codegen/errors/custom.js +57 -1
  35. package/dist/idl_codegen/errors/custom.js.map +1 -1
  36. package/dist/idl_codegen/instructions/index.d.ts +7 -3
  37. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  38. package/dist/idl_codegen/instructions/index.js +7 -3
  39. package/dist/idl_codegen/instructions/index.js.map +1 -1
  40. package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +2 -5
  41. package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -1
  42. package/dist/idl_codegen/instructions/initReferrerTokenState.js +3 -32
  43. package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
  44. package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts +12 -0
  45. package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts.map +1 -0
  46. package/dist/idl_codegen/instructions/markObligationForDeleveraging.js +47 -0
  47. package/dist/idl_codegen/instructions/markObligationForDeleveraging.js.map +1 -0
  48. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +38 -0
  49. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -0
  50. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +159 -0
  51. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -0
  52. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
  53. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  54. package/dist/idl_codegen/types/ReserveConfig.d.ts +78 -20
  55. package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
  56. package/dist/idl_codegen/types/ReserveConfig.js +45 -14
  57. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  58. package/dist/idl_codegen/types/ReserveLiquidity.d.ts +16 -16
  59. package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -1
  60. package/dist/idl_codegen/types/ReserveLiquidity.js +16 -16
  61. package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
  62. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +40 -14
  63. package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
  64. package/dist/idl_codegen/types/UpdateConfigMode.js +71 -23
  65. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  66. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +37 -11
  67. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  68. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +64 -16
  69. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  70. package/dist/idl_codegen/types/index.d.ts +4 -4
  71. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  72. package/dist/idl_codegen/types/index.js.map +1 -1
  73. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +4 -0
  74. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
  75. package/dist/idl_codegen/zero_padding/ObligationZP.js +10 -0
  76. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  77. package/dist/pyth/accounts/PriceUpdateV2.d.ts +30 -0
  78. package/dist/pyth/accounts/PriceUpdateV2.d.ts.map +1 -0
  79. package/dist/pyth/accounts/PriceUpdateV2.js +104 -0
  80. package/dist/pyth/accounts/PriceUpdateV2.js.map +1 -0
  81. package/dist/pyth/accounts/index.d.ts +3 -0
  82. package/dist/pyth/accounts/index.d.ts.map +1 -0
  83. package/dist/pyth/accounts/index.js +6 -0
  84. package/dist/pyth/accounts/index.js.map +1 -0
  85. package/dist/pyth/types/PriceFeedMessage.d.ts +58 -0
  86. package/dist/pyth/types/PriceFeedMessage.d.ts.map +1 -0
  87. package/dist/pyth/types/PriceFeedMessage.js +118 -0
  88. package/dist/pyth/types/PriceFeedMessage.js.map +1 -0
  89. package/dist/pyth/types/VerificationLevel.d.ts +45 -0
  90. package/dist/pyth/types/VerificationLevel.d.ts.map +1 -0
  91. package/dist/pyth/types/VerificationLevel.js +105 -0
  92. package/dist/pyth/types/VerificationLevel.js.map +1 -0
  93. package/dist/pyth/types/index.d.ts +7 -0
  94. package/dist/pyth/types/index.d.ts.map +1 -0
  95. package/dist/pyth/types/index.js +31 -0
  96. package/dist/pyth/types/index.js.map +1 -0
  97. package/dist/referrals/instructions.d.ts.map +1 -1
  98. package/dist/referrals/instructions.js +1 -2
  99. package/dist/referrals/instructions.js.map +1 -1
  100. package/dist/utils/managerTypes.d.ts.map +1 -1
  101. package/dist/utils/managerTypes.js +5 -4
  102. package/dist/utils/managerTypes.js.map +1 -1
  103. package/dist/utils/oracle.d.ts.map +1 -1
  104. package/dist/utils/oracle.js +9 -14
  105. package/dist/utils/oracle.js.map +1 -1
  106. package/dist/utils/rpc.d.ts +2 -1
  107. package/dist/utils/rpc.d.ts.map +1 -1
  108. package/dist/utils/rpc.js +8 -6
  109. package/dist/utils/rpc.js.map +1 -1
  110. package/package.json +5 -6
  111. package/src/classes/action.ts +1 -3
  112. package/src/classes/manager.ts +39 -19
  113. package/src/classes/market.ts +8 -21
  114. package/src/classes/reserve.ts +16 -16
  115. package/src/classes/shared.ts +2 -2
  116. package/src/classes/vault.ts +10 -14
  117. package/src/client_kamino_manager.ts +7 -3
  118. package/src/idl_codegen/accounts/LendingMarket.ts +76 -13
  119. package/src/idl_codegen/accounts/Obligation.ts +47 -2
  120. package/src/idl_codegen/accounts/Reserve.ts +1 -1
  121. package/src/idl_codegen/errors/custom.ts +56 -0
  122. package/src/idl_codegen/instructions/index.ts +13 -6
  123. package/src/idl_codegen/instructions/initReferrerTokenState.ts +3 -15
  124. package/src/idl_codegen/instructions/markObligationForDeleveraging.ts +40 -0
  125. package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +177 -0
  126. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
  127. package/src/idl_codegen/programId.ts +1 -1
  128. package/src/idl_codegen/types/ReserveConfig.ts +100 -28
  129. package/src/idl_codegen/types/ReserveLiquidity.ts +25 -24
  130. package/src/idl_codegen/types/UpdateConfigMode.ts +86 -26
  131. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +77 -17
  132. package/src/idl_codegen/types/index.ts +14 -6
  133. package/src/idl_codegen/zero_padding/ObligationZP.ts +10 -0
  134. package/src/pyth/accounts/PriceUpdateV2.ts +110 -0
  135. package/src/pyth/accounts/index.ts +2 -0
  136. package/src/pyth/types/PriceFeedMessage.ts +120 -0
  137. package/src/pyth/types/VerificationLevel.ts +98 -0
  138. package/src/pyth/types/index.ts +9 -0
  139. package/src/referrals/instructions.ts +1 -3
  140. package/src/utils/managerTypes.ts +5 -5
  141. package/src/utils/oracle.ts +9 -15
  142. package/src/utils/rpc.ts +8 -5
@@ -111,6 +111,10 @@ export type CustomError =
111
111
  | InvalidTokenAccount
112
112
  | DepositDisabledOutsideElevationGroup
113
113
  | CannotCalculateReferralAmountDueToSlotsMismatch
114
+ | ObligationOwnersMustMatch
115
+ | ObligationsMustMatch
116
+ | LendingMarketsMustMatch
117
+ | ObligationAlreadyMarkedForDeleveraging
114
118
 
115
119
  export class InvalidMarketAuthority extends Error {
116
120
  static readonly code = 6000
@@ -1401,6 +1405,50 @@ export class CannotCalculateReferralAmountDueToSlotsMismatch extends Error {
1401
1405
  }
1402
1406
  }
1403
1407
 
1408
+ export class ObligationOwnersMustMatch extends Error {
1409
+ static readonly code = 6112
1410
+ readonly code = 6112
1411
+ readonly name = "ObligationOwnersMustMatch"
1412
+ readonly msg = "Obligation owners must match"
1413
+
1414
+ constructor(readonly logs?: string[]) {
1415
+ super("6112: Obligation owners must match")
1416
+ }
1417
+ }
1418
+
1419
+ export class ObligationsMustMatch extends Error {
1420
+ static readonly code = 6113
1421
+ readonly code = 6113
1422
+ readonly name = "ObligationsMustMatch"
1423
+ readonly msg = "Obligations must match"
1424
+
1425
+ constructor(readonly logs?: string[]) {
1426
+ super("6113: Obligations must match")
1427
+ }
1428
+ }
1429
+
1430
+ export class LendingMarketsMustMatch extends Error {
1431
+ static readonly code = 6114
1432
+ readonly code = 6114
1433
+ readonly name = "LendingMarketsMustMatch"
1434
+ readonly msg = "Lending markets must match"
1435
+
1436
+ constructor(readonly logs?: string[]) {
1437
+ super("6114: Lending markets must match")
1438
+ }
1439
+ }
1440
+
1441
+ export class ObligationAlreadyMarkedForDeleveraging extends Error {
1442
+ static readonly code = 6115
1443
+ readonly code = 6115
1444
+ readonly name = "ObligationAlreadyMarkedForDeleveraging"
1445
+ readonly msg = "Obligation is already marked for deleveraging"
1446
+
1447
+ constructor(readonly logs?: string[]) {
1448
+ super("6115: Obligation is already marked for deleveraging")
1449
+ }
1450
+ }
1451
+
1404
1452
  export function fromCode(code: number, logs?: string[]): CustomError | null {
1405
1453
  switch (code) {
1406
1454
  case 6000:
@@ -1627,6 +1675,14 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1627
1675
  return new DepositDisabledOutsideElevationGroup(logs)
1628
1676
  case 6111:
1629
1677
  return new CannotCalculateReferralAmountDueToSlotsMismatch(logs)
1678
+ case 6112:
1679
+ return new ObligationOwnersMustMatch(logs)
1680
+ case 6113:
1681
+ return new ObligationsMustMatch(logs)
1682
+ case 6114:
1683
+ return new LendingMarketsMustMatch(logs)
1684
+ case 6115:
1685
+ return new ObligationAlreadyMarkedForDeleveraging(logs)
1630
1686
  }
1631
1687
 
1632
1688
  return null
@@ -24,13 +24,18 @@ export type {
24
24
  } from "./updateReserveConfig"
25
25
  export { redeemFees } from "./redeemFees"
26
26
  export type { RedeemFeesAccounts } from "./redeemFees"
27
- export { socializeLoss } from "./socializeLoss"
28
- export type { SocializeLossArgs, SocializeLossAccounts } from "./socializeLoss"
29
27
  export { withdrawProtocolFee } from "./withdrawProtocolFee"
30
28
  export type {
31
29
  WithdrawProtocolFeeArgs,
32
30
  WithdrawProtocolFeeAccounts,
33
31
  } from "./withdrawProtocolFee"
32
+ export { socializeLoss } from "./socializeLoss"
33
+ export type { SocializeLossArgs, SocializeLossAccounts } from "./socializeLoss"
34
+ export { markObligationForDeleveraging } from "./markObligationForDeleveraging"
35
+ export type {
36
+ MarkObligationForDeleveragingArgs,
37
+ MarkObligationForDeleveragingAccounts,
38
+ } from "./markObligationForDeleveraging"
34
39
  export { refreshReserve } from "./refreshReserve"
35
40
  export type { RefreshReserveAccounts } from "./refreshReserve"
36
41
  export { refreshReservesBatch } from "./refreshReservesBatch"
@@ -82,6 +87,11 @@ export type {
82
87
  RepayObligationLiquidityArgs,
83
88
  RepayObligationLiquidityAccounts,
84
89
  } from "./repayObligationLiquidity"
90
+ export { repayAndWithdrawAndRedeem } from "./repayAndWithdrawAndRedeem"
91
+ export type {
92
+ RepayAndWithdrawAndRedeemArgs,
93
+ RepayAndWithdrawAndRedeemAccounts,
94
+ } from "./repayAndWithdrawAndRedeem"
85
95
  export { depositReserveLiquidityAndObligationCollateral } from "./depositReserveLiquidityAndObligationCollateral"
86
96
  export type {
87
97
  DepositReserveLiquidityAndObligationCollateralArgs,
@@ -113,10 +123,7 @@ export type {
113
123
  RequestElevationGroupAccounts,
114
124
  } from "./requestElevationGroup"
115
125
  export { initReferrerTokenState } from "./initReferrerTokenState"
116
- export type {
117
- InitReferrerTokenStateArgs,
118
- InitReferrerTokenStateAccounts,
119
- } from "./initReferrerTokenState"
126
+ export type { InitReferrerTokenStateAccounts } from "./initReferrerTokenState"
120
127
  export { initUserMetadata } from "./initUserMetadata"
121
128
  export type {
122
129
  InitUserMetadataArgs,
@@ -4,23 +4,17 @@ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-esl
4
4
  import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
5
  import { PROGRAM_ID } from "../programId"
6
6
 
7
- export interface InitReferrerTokenStateArgs {
8
- referrer: PublicKey
9
- }
10
-
11
7
  export interface InitReferrerTokenStateAccounts {
12
8
  payer: PublicKey
13
9
  lendingMarket: PublicKey
14
10
  reserve: PublicKey
11
+ referrer: PublicKey
15
12
  referrerTokenState: PublicKey
16
13
  rent: PublicKey
17
14
  systemProgram: PublicKey
18
15
  }
19
16
 
20
- export const layout = borsh.struct([borsh.publicKey("referrer")])
21
-
22
17
  export function initReferrerTokenState(
23
- args: InitReferrerTokenStateArgs,
24
18
  accounts: InitReferrerTokenStateAccounts,
25
19
  programId: PublicKey = PROGRAM_ID
26
20
  ) {
@@ -28,19 +22,13 @@ export function initReferrerTokenState(
28
22
  { pubkey: accounts.payer, isSigner: true, isWritable: true },
29
23
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
30
24
  { pubkey: accounts.reserve, isSigner: false, isWritable: false },
25
+ { pubkey: accounts.referrer, isSigner: false, isWritable: false },
31
26
  { pubkey: accounts.referrerTokenState, isSigner: false, isWritable: true },
32
27
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
33
28
  { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
34
29
  ]
35
30
  const identifier = Buffer.from([116, 45, 66, 148, 58, 13, 218, 115])
36
- const buffer = Buffer.alloc(1000)
37
- const len = layout.encode(
38
- {
39
- referrer: args.referrer,
40
- },
41
- buffer
42
- )
43
- const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
31
+ const data = identifier
44
32
  const ix = new TransactionInstruction({ keys, programId, data })
45
33
  return ix
46
34
  }
@@ -0,0 +1,40 @@
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 MarkObligationForDeleveragingArgs {
8
+ autodeleverageTargetLtvPct: number
9
+ }
10
+
11
+ export interface MarkObligationForDeleveragingAccounts {
12
+ riskCouncil: PublicKey
13
+ obligation: PublicKey
14
+ lendingMarket: PublicKey
15
+ }
16
+
17
+ export const layout = borsh.struct([borsh.u8("autodeleverageTargetLtvPct")])
18
+
19
+ export function markObligationForDeleveraging(
20
+ args: MarkObligationForDeleveragingArgs,
21
+ accounts: MarkObligationForDeleveragingAccounts,
22
+ programId: PublicKey = PROGRAM_ID
23
+ ) {
24
+ const keys: Array<AccountMeta> = [
25
+ { pubkey: accounts.riskCouncil, isSigner: true, isWritable: false },
26
+ { pubkey: accounts.obligation, isSigner: false, isWritable: true },
27
+ { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
28
+ ]
29
+ const identifier = Buffer.from([164, 35, 182, 19, 0, 116, 243, 127])
30
+ const buffer = Buffer.alloc(1000)
31
+ const len = layout.encode(
32
+ {
33
+ autodeleverageTargetLtvPct: args.autodeleverageTargetLtvPct,
34
+ },
35
+ buffer
36
+ )
37
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
38
+ const ix = new TransactionInstruction({ keys, programId, data })
39
+ return ix
40
+ }
@@ -0,0 +1,177 @@
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 RepayAndWithdrawAndRedeemArgs {
8
+ repayAmount: BN
9
+ withdrawCollateralAmount: BN
10
+ }
11
+
12
+ export interface RepayAndWithdrawAndRedeemAccounts {
13
+ repayAccounts: {
14
+ owner: PublicKey
15
+ obligation: PublicKey
16
+ lendingMarket: PublicKey
17
+ repayReserve: PublicKey
18
+ reserveLiquidityMint: PublicKey
19
+ reserveDestinationLiquidity: PublicKey
20
+ userSourceLiquidity: PublicKey
21
+ tokenProgram: PublicKey
22
+ instructionSysvarAccount: PublicKey
23
+ }
24
+ withdrawAccounts: {
25
+ owner: PublicKey
26
+ obligation: PublicKey
27
+ lendingMarket: PublicKey
28
+ lendingMarketAuthority: PublicKey
29
+ withdrawReserve: PublicKey
30
+ reserveLiquidityMint: PublicKey
31
+ reserveSourceCollateral: PublicKey
32
+ reserveCollateralMint: PublicKey
33
+ reserveLiquiditySupply: PublicKey
34
+ userDestinationLiquidity: PublicKey
35
+ placeholderUserDestinationCollateral: PublicKey
36
+ collateralTokenProgram: PublicKey
37
+ liquidityTokenProgram: PublicKey
38
+ instructionSysvarAccount: PublicKey
39
+ }
40
+ }
41
+
42
+ export const layout = borsh.struct([
43
+ borsh.u64("repayAmount"),
44
+ borsh.u64("withdrawCollateralAmount"),
45
+ ])
46
+
47
+ export function repayAndWithdrawAndRedeem(
48
+ args: RepayAndWithdrawAndRedeemArgs,
49
+ accounts: RepayAndWithdrawAndRedeemAccounts,
50
+ programId: PublicKey = PROGRAM_ID
51
+ ) {
52
+ const keys: Array<AccountMeta> = [
53
+ { pubkey: accounts.repayAccounts.owner, isSigner: true, isWritable: false },
54
+ {
55
+ pubkey: accounts.repayAccounts.obligation,
56
+ isSigner: false,
57
+ isWritable: true,
58
+ },
59
+ {
60
+ pubkey: accounts.repayAccounts.lendingMarket,
61
+ isSigner: false,
62
+ isWritable: false,
63
+ },
64
+ {
65
+ pubkey: accounts.repayAccounts.repayReserve,
66
+ isSigner: false,
67
+ isWritable: true,
68
+ },
69
+ {
70
+ pubkey: accounts.repayAccounts.reserveLiquidityMint,
71
+ isSigner: false,
72
+ isWritable: true,
73
+ },
74
+ {
75
+ pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
76
+ isSigner: false,
77
+ isWritable: true,
78
+ },
79
+ {
80
+ pubkey: accounts.repayAccounts.userSourceLiquidity,
81
+ isSigner: false,
82
+ isWritable: true,
83
+ },
84
+ {
85
+ pubkey: accounts.repayAccounts.tokenProgram,
86
+ isSigner: false,
87
+ isWritable: false,
88
+ },
89
+ {
90
+ pubkey: accounts.repayAccounts.instructionSysvarAccount,
91
+ isSigner: false,
92
+ isWritable: false,
93
+ },
94
+ {
95
+ pubkey: accounts.withdrawAccounts.owner,
96
+ isSigner: true,
97
+ isWritable: false,
98
+ },
99
+ {
100
+ pubkey: accounts.withdrawAccounts.obligation,
101
+ isSigner: false,
102
+ isWritable: true,
103
+ },
104
+ {
105
+ pubkey: accounts.withdrawAccounts.lendingMarket,
106
+ isSigner: false,
107
+ isWritable: false,
108
+ },
109
+ {
110
+ pubkey: accounts.withdrawAccounts.lendingMarketAuthority,
111
+ isSigner: false,
112
+ isWritable: false,
113
+ },
114
+ {
115
+ pubkey: accounts.withdrawAccounts.withdrawReserve,
116
+ isSigner: false,
117
+ isWritable: true,
118
+ },
119
+ {
120
+ pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
121
+ isSigner: false,
122
+ isWritable: true,
123
+ },
124
+ {
125
+ pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
126
+ isSigner: false,
127
+ isWritable: true,
128
+ },
129
+ {
130
+ pubkey: accounts.withdrawAccounts.reserveCollateralMint,
131
+ isSigner: false,
132
+ isWritable: true,
133
+ },
134
+ {
135
+ pubkey: accounts.withdrawAccounts.reserveLiquiditySupply,
136
+ isSigner: false,
137
+ isWritable: true,
138
+ },
139
+ {
140
+ pubkey: accounts.withdrawAccounts.userDestinationLiquidity,
141
+ isSigner: false,
142
+ isWritable: true,
143
+ },
144
+ {
145
+ pubkey: accounts.withdrawAccounts.placeholderUserDestinationCollateral,
146
+ isSigner: false,
147
+ isWritable: false,
148
+ },
149
+ {
150
+ pubkey: accounts.withdrawAccounts.collateralTokenProgram,
151
+ isSigner: false,
152
+ isWritable: false,
153
+ },
154
+ {
155
+ pubkey: accounts.withdrawAccounts.liquidityTokenProgram,
156
+ isSigner: false,
157
+ isWritable: false,
158
+ },
159
+ {
160
+ pubkey: accounts.withdrawAccounts.instructionSysvarAccount,
161
+ isSigner: false,
162
+ isWritable: false,
163
+ },
164
+ ]
165
+ const identifier = Buffer.from([2, 54, 152, 3, 148, 96, 109, 218])
166
+ const buffer = Buffer.alloc(1000)
167
+ const len = layout.encode(
168
+ {
169
+ repayAmount: args.repayAmount,
170
+ withdrawCollateralAmount: args.withdrawCollateralAmount,
171
+ },
172
+ buffer
173
+ )
174
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
175
+ const ix = new TransactionInstruction({ keys, programId, data })
176
+ return ix
177
+ }
@@ -33,7 +33,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateral(
33
33
  programId: PublicKey = PROGRAM_ID
34
34
  ) {
35
35
  const keys: Array<AccountMeta> = [
36
- { pubkey: accounts.owner, isSigner: true, isWritable: true },
36
+ { pubkey: accounts.owner, isSigner: true, isWritable: false },
37
37
  { pubkey: accounts.obligation, isSigner: false, isWritable: true },
38
38
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
39
39
  {
@@ -10,4 +10,4 @@ export let PROGRAM_ID: PublicKey = PROGRAM_ID_CLI
10
10
 
11
11
  export const setKLendProgramId = (programId: PublicKey) => {
12
12
  PROGRAM_ID = programId;
13
- };
13
+ };