@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.
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +1 -2
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +2 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +29 -20
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +1 -2
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +7 -20
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/reserve.js +14 -14
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -2
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +2 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +7 -15
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.js +7 -3
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +310 -48
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +48 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +35 -8
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +30 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +23 -2
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.js +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +33 -1
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +57 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +7 -3
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +2 -5
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.js +3 -32
- package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts +12 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js +47 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +38 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +159 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.d.ts +78 -20
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +45 -14
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.js +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +40 -14
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +71 -23
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +37 -11
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +64 -16
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +4 -4
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +4 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +10 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/pyth/accounts/PriceUpdateV2.d.ts +30 -0
- package/dist/pyth/accounts/PriceUpdateV2.d.ts.map +1 -0
- package/dist/pyth/accounts/PriceUpdateV2.js +104 -0
- package/dist/pyth/accounts/PriceUpdateV2.js.map +1 -0
- package/dist/pyth/accounts/index.d.ts +3 -0
- package/dist/pyth/accounts/index.d.ts.map +1 -0
- package/dist/pyth/accounts/index.js +6 -0
- package/dist/pyth/accounts/index.js.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts +58 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.js +118 -0
- package/dist/pyth/types/PriceFeedMessage.js.map +1 -0
- package/dist/pyth/types/VerificationLevel.d.ts +45 -0
- package/dist/pyth/types/VerificationLevel.d.ts.map +1 -0
- package/dist/pyth/types/VerificationLevel.js +105 -0
- package/dist/pyth/types/VerificationLevel.js.map +1 -0
- package/dist/pyth/types/index.d.ts +7 -0
- package/dist/pyth/types/index.d.ts.map +1 -0
- package/dist/pyth/types/index.js +31 -0
- package/dist/pyth/types/index.js.map +1 -0
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +1 -2
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +5 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +9 -14
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/rpc.d.ts +2 -1
- package/dist/utils/rpc.d.ts.map +1 -1
- package/dist/utils/rpc.js +8 -6
- package/dist/utils/rpc.js.map +1 -1
- package/package.json +5 -6
- package/src/classes/action.ts +1 -3
- package/src/classes/manager.ts +39 -19
- package/src/classes/market.ts +8 -21
- package/src/classes/reserve.ts +16 -16
- package/src/classes/shared.ts +2 -2
- package/src/classes/vault.ts +10 -14
- package/src/client_kamino_manager.ts +7 -3
- package/src/idl_codegen/accounts/LendingMarket.ts +76 -13
- package/src/idl_codegen/accounts/Obligation.ts +47 -2
- package/src/idl_codegen/accounts/Reserve.ts +1 -1
- package/src/idl_codegen/errors/custom.ts +56 -0
- package/src/idl_codegen/instructions/index.ts +13 -6
- package/src/idl_codegen/instructions/initReferrerTokenState.ts +3 -15
- package/src/idl_codegen/instructions/markObligationForDeleveraging.ts +40 -0
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +177 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/programId.ts +1 -1
- package/src/idl_codegen/types/ReserveConfig.ts +100 -28
- package/src/idl_codegen/types/ReserveLiquidity.ts +25 -24
- package/src/idl_codegen/types/UpdateConfigMode.ts +86 -26
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +77 -17
- package/src/idl_codegen/types/index.ts +14 -6
- package/src/idl_codegen/zero_padding/ObligationZP.ts +10 -0
- package/src/pyth/accounts/PriceUpdateV2.ts +110 -0
- package/src/pyth/accounts/index.ts +2 -0
- package/src/pyth/types/PriceFeedMessage.ts +120 -0
- package/src/pyth/types/VerificationLevel.ts +98 -0
- package/src/pyth/types/index.ts +9 -0
- package/src/referrals/instructions.ts +1 -3
- package/src/utils/managerTypes.ts +5 -5
- package/src/utils/oracle.ts +9 -15
- 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
|
|
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
|
+
}
|
package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts
CHANGED
|
@@ -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:
|
|
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
|
{
|