@kamino-finance/klend-sdk 5.11.0-beta.0 → 5.11.1
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 +16 -17
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +61 -102
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +16 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +28 -3
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +6 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +4 -2
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +2 -2
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +15 -11
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types.d.ts +4 -0
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +1 -2
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +18 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +87 -30
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +8 -3
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +199 -152
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +15 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +11 -1
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +18 -2
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +31 -3
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts +52 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js +219 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +2 -2
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +3 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.js +5 -0
- package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +2 -2
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +2 -2
- 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 +10 -4
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +9 -7
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +25 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +43 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +13 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +25 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +5 -3
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +1 -1
- package/dist/leverage/calcs.d.ts.map +1 -1
- package/dist/leverage/calcs.js +12 -10
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/instructions.d.ts +1 -2
- package/dist/leverage/instructions.d.ts.map +1 -1
- package/dist/leverage/instructions.js +2 -6
- package/dist/leverage/instructions.js.map +1 -1
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +19 -13
- package/dist/leverage/operations.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -1
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +2 -2
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +5 -9
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +6 -10
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +1 -3
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +1 -0
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +2 -1
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +7 -7
- package/src/classes/action.ts +77 -105
- package/src/classes/manager.ts +35 -3
- package/src/classes/obligation.ts +8 -4
- package/src/classes/reserve.ts +16 -13
- package/src/classes/types.ts +5 -0
- package/src/classes/utils.ts +3 -3
- package/src/classes/vault.ts +103 -45
- package/src/client_kamino_manager.ts +10 -3
- package/src/idl.json +199 -152
- package/src/idl_codegen/accounts/LendingMarket.ts +21 -1
- package/src/idl_codegen/errors/custom.ts +39 -2
- package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/depositAndWithdraw.ts +241 -0
- package/src/idl_codegen/instructions/depositReserveLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +1 -1
- package/src/idl_codegen/instructions/index.ts +4 -4
- package/src/idl_codegen/instructions/initFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initReserve.ts +6 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +2 -2
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +2 -2
- package/src/idl_codegen/instructions/redeemFees.ts +1 -1
- package/src/idl_codegen/instructions/redeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +2 -2
- package/src/idl_codegen/instructions/repayObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +1 -1
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +1 -1
- package/src/idl_codegen/instructions/withdrawReferrerFees.ts +1 -1
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
- package/src/idl_codegen/types/index.ts +2 -0
- package/src/idl_codegen/zero_padding/ObligationZP.ts +12 -6
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -1
- package/src/idl_codegen_kamino_vault/errors/custom.ts +42 -0
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +2 -0
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +30 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +2 -0
- package/src/idl_kamino_vault.json +30 -3
- package/src/lending_operations/repay_with_collateral_operations.ts +1 -0
- package/src/lending_operations/swap_collateral_operations.ts +6 -5
- package/src/leverage/calcs.ts +16 -13
- package/src/leverage/instructions.ts +1 -6
- package/src/leverage/operations.ts +28 -18
- package/src/utils/ata.ts +1 -1
- package/src/utils/constants.ts +6 -11
- package/src/utils/instruction.ts +1 -3
- package/src/utils/managerTypes.ts +1 -0
- package/src/utils/userMetadata.ts +2 -2
|
@@ -120,6 +120,8 @@ export type CustomError =
|
|
|
120
120
|
| MinLtvAssetsPriority
|
|
121
121
|
| WorseLTVThanUnhealthyLTV
|
|
122
122
|
| FarmAccountsMissing
|
|
123
|
+
| RepayTooSmallForFullLiquidation
|
|
124
|
+
| InsufficientRepayAmount
|
|
123
125
|
|
|
124
126
|
export class InvalidMarketAuthority extends Error {
|
|
125
127
|
static readonly code = 6000
|
|
@@ -1458,10 +1460,13 @@ export class MaximumWithdrawValueZero extends Error {
|
|
|
1458
1460
|
static readonly code = 6116
|
|
1459
1461
|
readonly code = 6116
|
|
1460
1462
|
readonly name = "MaximumWithdrawValueZero"
|
|
1461
|
-
readonly msg =
|
|
1463
|
+
readonly msg =
|
|
1464
|
+
"Maximum withdrawable value of this collateral is zero, LTV needs improved"
|
|
1462
1465
|
|
|
1463
1466
|
constructor(readonly logs?: string[]) {
|
|
1464
|
-
super(
|
|
1467
|
+
super(
|
|
1468
|
+
"6116: Maximum withdrawable value of this collateral is zero, LTV needs improved"
|
|
1469
|
+
)
|
|
1465
1470
|
}
|
|
1466
1471
|
}
|
|
1467
1472
|
|
|
@@ -1515,6 +1520,34 @@ export class FarmAccountsMissing extends Error {
|
|
|
1515
1520
|
}
|
|
1516
1521
|
}
|
|
1517
1522
|
|
|
1523
|
+
export class RepayTooSmallForFullLiquidation extends Error {
|
|
1524
|
+
static readonly code = 6121
|
|
1525
|
+
readonly code = 6121
|
|
1526
|
+
readonly name = "RepayTooSmallForFullLiquidation"
|
|
1527
|
+
readonly msg =
|
|
1528
|
+
"Repay amount is too small to satisfy the mandatory full liquidation"
|
|
1529
|
+
|
|
1530
|
+
constructor(readonly logs?: string[]) {
|
|
1531
|
+
super(
|
|
1532
|
+
"6121: Repay amount is too small to satisfy the mandatory full liquidation"
|
|
1533
|
+
)
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
export class InsufficientRepayAmount extends Error {
|
|
1538
|
+
static readonly code = 6122
|
|
1539
|
+
readonly code = 6122
|
|
1540
|
+
readonly name = "InsufficientRepayAmount"
|
|
1541
|
+
readonly msg =
|
|
1542
|
+
"Liquidator provided repay amount lower than required by liquidation rules"
|
|
1543
|
+
|
|
1544
|
+
constructor(readonly logs?: string[]) {
|
|
1545
|
+
super(
|
|
1546
|
+
"6122: Liquidator provided repay amount lower than required by liquidation rules"
|
|
1547
|
+
)
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1518
1551
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1519
1552
|
switch (code) {
|
|
1520
1553
|
case 6000:
|
|
@@ -1759,6 +1792,10 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1759
1792
|
return new WorseLTVThanUnhealthyLTV(logs)
|
|
1760
1793
|
case 6120:
|
|
1761
1794
|
return new FarmAccountsMissing(logs)
|
|
1795
|
+
case 6121:
|
|
1796
|
+
return new RepayTooSmallForFullLiquidation(logs)
|
|
1797
|
+
case 6122:
|
|
1798
|
+
return new InsufficientRepayAmount(logs)
|
|
1762
1799
|
}
|
|
1763
1800
|
|
|
1764
1801
|
return null
|
|
@@ -0,0 +1,241 @@
|
|
|
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 DepositAndWithdrawArgs {
|
|
8
|
+
liquidityAmount: BN
|
|
9
|
+
withdrawCollateralAmount: BN
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DepositAndWithdrawAccounts {
|
|
13
|
+
depositAccounts: {
|
|
14
|
+
owner: PublicKey
|
|
15
|
+
obligation: PublicKey
|
|
16
|
+
lendingMarket: PublicKey
|
|
17
|
+
lendingMarketAuthority: PublicKey
|
|
18
|
+
reserve: PublicKey
|
|
19
|
+
reserveLiquidityMint: PublicKey
|
|
20
|
+
reserveLiquiditySupply: PublicKey
|
|
21
|
+
reserveCollateralMint: PublicKey
|
|
22
|
+
reserveDestinationDepositCollateral: PublicKey
|
|
23
|
+
userSourceLiquidity: PublicKey
|
|
24
|
+
placeholderUserDestinationCollateral: PublicKey
|
|
25
|
+
collateralTokenProgram: PublicKey
|
|
26
|
+
liquidityTokenProgram: PublicKey
|
|
27
|
+
instructionSysvarAccount: PublicKey
|
|
28
|
+
}
|
|
29
|
+
withdrawAccounts: {
|
|
30
|
+
owner: PublicKey
|
|
31
|
+
obligation: PublicKey
|
|
32
|
+
lendingMarket: PublicKey
|
|
33
|
+
lendingMarketAuthority: PublicKey
|
|
34
|
+
withdrawReserve: PublicKey
|
|
35
|
+
reserveLiquidityMint: PublicKey
|
|
36
|
+
reserveSourceCollateral: PublicKey
|
|
37
|
+
reserveCollateralMint: PublicKey
|
|
38
|
+
reserveLiquiditySupply: PublicKey
|
|
39
|
+
userDestinationLiquidity: PublicKey
|
|
40
|
+
placeholderUserDestinationCollateral: PublicKey
|
|
41
|
+
collateralTokenProgram: PublicKey
|
|
42
|
+
liquidityTokenProgram: PublicKey
|
|
43
|
+
instructionSysvarAccount: PublicKey
|
|
44
|
+
}
|
|
45
|
+
depositFarmsAccounts: {
|
|
46
|
+
obligationFarmUserState: PublicKey
|
|
47
|
+
reserveFarmState: PublicKey
|
|
48
|
+
}
|
|
49
|
+
withdrawFarmsAccounts: {
|
|
50
|
+
obligationFarmUserState: PublicKey
|
|
51
|
+
reserveFarmState: PublicKey
|
|
52
|
+
}
|
|
53
|
+
farmsProgram: PublicKey
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const layout = borsh.struct([
|
|
57
|
+
borsh.u64("liquidityAmount"),
|
|
58
|
+
borsh.u64("withdrawCollateralAmount"),
|
|
59
|
+
])
|
|
60
|
+
|
|
61
|
+
export function depositAndWithdraw(
|
|
62
|
+
args: DepositAndWithdrawArgs,
|
|
63
|
+
accounts: DepositAndWithdrawAccounts,
|
|
64
|
+
programId: PublicKey = PROGRAM_ID
|
|
65
|
+
) {
|
|
66
|
+
const keys: Array<AccountMeta> = [
|
|
67
|
+
{
|
|
68
|
+
pubkey: accounts.depositAccounts.owner,
|
|
69
|
+
isSigner: true,
|
|
70
|
+
isWritable: true,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
pubkey: accounts.depositAccounts.obligation,
|
|
74
|
+
isSigner: false,
|
|
75
|
+
isWritable: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
pubkey: accounts.depositAccounts.lendingMarket,
|
|
79
|
+
isSigner: false,
|
|
80
|
+
isWritable: false,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
pubkey: accounts.depositAccounts.lendingMarketAuthority,
|
|
84
|
+
isSigner: false,
|
|
85
|
+
isWritable: false,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
pubkey: accounts.depositAccounts.reserve,
|
|
89
|
+
isSigner: false,
|
|
90
|
+
isWritable: true,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
pubkey: accounts.depositAccounts.reserveLiquidityMint,
|
|
94
|
+
isSigner: false,
|
|
95
|
+
isWritable: false,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
pubkey: accounts.depositAccounts.reserveLiquiditySupply,
|
|
99
|
+
isSigner: false,
|
|
100
|
+
isWritable: true,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
pubkey: accounts.depositAccounts.reserveCollateralMint,
|
|
104
|
+
isSigner: false,
|
|
105
|
+
isWritable: true,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
pubkey: accounts.depositAccounts.reserveDestinationDepositCollateral,
|
|
109
|
+
isSigner: false,
|
|
110
|
+
isWritable: true,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
pubkey: accounts.depositAccounts.userSourceLiquidity,
|
|
114
|
+
isSigner: false,
|
|
115
|
+
isWritable: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
pubkey: accounts.depositAccounts.placeholderUserDestinationCollateral,
|
|
119
|
+
isSigner: false,
|
|
120
|
+
isWritable: false,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
pubkey: accounts.depositAccounts.collateralTokenProgram,
|
|
124
|
+
isSigner: false,
|
|
125
|
+
isWritable: false,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
pubkey: accounts.depositAccounts.liquidityTokenProgram,
|
|
129
|
+
isSigner: false,
|
|
130
|
+
isWritable: false,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
pubkey: accounts.depositAccounts.instructionSysvarAccount,
|
|
134
|
+
isSigner: false,
|
|
135
|
+
isWritable: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
pubkey: accounts.withdrawAccounts.owner,
|
|
139
|
+
isSigner: true,
|
|
140
|
+
isWritable: true,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
pubkey: accounts.withdrawAccounts.obligation,
|
|
144
|
+
isSigner: false,
|
|
145
|
+
isWritable: true,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
pubkey: accounts.withdrawAccounts.lendingMarket,
|
|
149
|
+
isSigner: false,
|
|
150
|
+
isWritable: false,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
pubkey: accounts.withdrawAccounts.lendingMarketAuthority,
|
|
154
|
+
isSigner: false,
|
|
155
|
+
isWritable: false,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
pubkey: accounts.withdrawAccounts.withdrawReserve,
|
|
159
|
+
isSigner: false,
|
|
160
|
+
isWritable: true,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
164
|
+
isSigner: false,
|
|
165
|
+
isWritable: false,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
169
|
+
isSigner: false,
|
|
170
|
+
isWritable: true,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
pubkey: accounts.withdrawAccounts.reserveCollateralMint,
|
|
174
|
+
isSigner: false,
|
|
175
|
+
isWritable: true,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
pubkey: accounts.withdrawAccounts.reserveLiquiditySupply,
|
|
179
|
+
isSigner: false,
|
|
180
|
+
isWritable: true,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
pubkey: accounts.withdrawAccounts.userDestinationLiquidity,
|
|
184
|
+
isSigner: false,
|
|
185
|
+
isWritable: true,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
pubkey: accounts.withdrawAccounts.placeholderUserDestinationCollateral,
|
|
189
|
+
isSigner: false,
|
|
190
|
+
isWritable: false,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
pubkey: accounts.withdrawAccounts.collateralTokenProgram,
|
|
194
|
+
isSigner: false,
|
|
195
|
+
isWritable: false,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
pubkey: accounts.withdrawAccounts.liquidityTokenProgram,
|
|
199
|
+
isSigner: false,
|
|
200
|
+
isWritable: false,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
pubkey: accounts.withdrawAccounts.instructionSysvarAccount,
|
|
204
|
+
isSigner: false,
|
|
205
|
+
isWritable: false,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
pubkey: accounts.depositFarmsAccounts.obligationFarmUserState,
|
|
209
|
+
isSigner: false,
|
|
210
|
+
isWritable: true,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
pubkey: accounts.depositFarmsAccounts.reserveFarmState,
|
|
214
|
+
isSigner: false,
|
|
215
|
+
isWritable: true,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
pubkey: accounts.withdrawFarmsAccounts.obligationFarmUserState,
|
|
219
|
+
isSigner: false,
|
|
220
|
+
isWritable: true,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
pubkey: accounts.withdrawFarmsAccounts.reserveFarmState,
|
|
224
|
+
isSigner: false,
|
|
225
|
+
isWritable: true,
|
|
226
|
+
},
|
|
227
|
+
{ pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
|
|
228
|
+
]
|
|
229
|
+
const identifier = Buffer.from([141, 153, 39, 15, 64, 61, 88, 84])
|
|
230
|
+
const buffer = Buffer.alloc(1000)
|
|
231
|
+
const len = layout.encode(
|
|
232
|
+
{
|
|
233
|
+
liquidityAmount: args.liquidityAmount,
|
|
234
|
+
withdrawCollateralAmount: args.withdrawCollateralAmount,
|
|
235
|
+
},
|
|
236
|
+
buffer
|
|
237
|
+
)
|
|
238
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
239
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
240
|
+
return ix
|
|
241
|
+
}
|
|
@@ -68,7 +68,7 @@ export function depositReserveLiquidityAndObligationCollateralV2(
|
|
|
68
68
|
{
|
|
69
69
|
pubkey: accounts.depositAccounts.reserveLiquidityMint,
|
|
70
70
|
isSigner: false,
|
|
71
|
-
isWritable:
|
|
71
|
+
isWritable: false,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
pubkey: accounts.depositAccounts.reserveLiquiditySupply,
|
|
@@ -117,11 +117,11 @@ export type {
|
|
|
117
117
|
RepayAndWithdrawAndRedeemArgs,
|
|
118
118
|
RepayAndWithdrawAndRedeemAccounts,
|
|
119
119
|
} from "./repayAndWithdrawAndRedeem"
|
|
120
|
-
export {
|
|
120
|
+
export { depositAndWithdraw } from "./depositAndWithdraw"
|
|
121
121
|
export type {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
} from "./
|
|
122
|
+
DepositAndWithdrawArgs,
|
|
123
|
+
DepositAndWithdrawAccounts,
|
|
124
|
+
} from "./depositAndWithdraw"
|
|
125
125
|
export { depositReserveLiquidityAndObligationCollateral } from "./depositReserveLiquidityAndObligationCollateral"
|
|
126
126
|
export type {
|
|
127
127
|
DepositReserveLiquidityAndObligationCollateralArgs,
|
|
@@ -34,7 +34,7 @@ export function initFarmsForReserve(
|
|
|
34
34
|
{
|
|
35
35
|
pubkey: accounts.lendingMarketAuthority,
|
|
36
36
|
isSigner: false,
|
|
37
|
-
isWritable:
|
|
37
|
+
isWritable: false,
|
|
38
38
|
},
|
|
39
39
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: true },
|
|
40
40
|
{ pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
|
|
@@ -36,7 +36,7 @@ export function initObligationFarmsForReserve(
|
|
|
36
36
|
{
|
|
37
37
|
pubkey: accounts.lendingMarketAuthority,
|
|
38
38
|
isSigner: false,
|
|
39
|
-
isWritable:
|
|
39
|
+
isWritable: false,
|
|
40
40
|
},
|
|
41
41
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: true },
|
|
42
42
|
{ pubkey: accounts.reserveFarmState, isSigner: false, isWritable: true },
|
|
@@ -14,6 +14,7 @@ export interface InitReserveAccounts {
|
|
|
14
14
|
feeReceiver: PublicKey
|
|
15
15
|
reserveCollateralMint: PublicKey
|
|
16
16
|
reserveCollateralSupply: PublicKey
|
|
17
|
+
initialLiquiditySource: PublicKey
|
|
17
18
|
rent: PublicKey
|
|
18
19
|
liquidityTokenProgram: PublicKey
|
|
19
20
|
collateralTokenProgram: PublicKey
|
|
@@ -54,6 +55,11 @@ export function initReserve(
|
|
|
54
55
|
isSigner: false,
|
|
55
56
|
isWritable: true,
|
|
56
57
|
},
|
|
58
|
+
{
|
|
59
|
+
pubkey: accounts.initialLiquiditySource,
|
|
60
|
+
isSigner: false,
|
|
61
|
+
isWritable: true,
|
|
62
|
+
},
|
|
57
63
|
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
58
64
|
{
|
|
59
65
|
pubkey: accounts.liquidityTokenProgram,
|
|
@@ -57,7 +57,7 @@ export function liquidateObligationAndRedeemReserveCollateral(
|
|
|
57
57
|
{
|
|
58
58
|
pubkey: accounts.repayReserveLiquidityMint,
|
|
59
59
|
isSigner: false,
|
|
60
|
-
isWritable:
|
|
60
|
+
isWritable: false,
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
pubkey: accounts.repayReserveLiquiditySupply,
|
|
@@ -68,7 +68,7 @@ export function liquidateObligationAndRedeemReserveCollateral(
|
|
|
68
68
|
{
|
|
69
69
|
pubkey: accounts.withdrawReserveLiquidityMint,
|
|
70
70
|
isSigner: false,
|
|
71
|
-
isWritable:
|
|
71
|
+
isWritable: false,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
pubkey: accounts.withdrawReserveCollateralMint,
|
|
@@ -84,7 +84,7 @@ export function liquidateObligationAndRedeemReserveCollateralV2(
|
|
|
84
84
|
{
|
|
85
85
|
pubkey: accounts.liquidationAccounts.repayReserveLiquidityMint,
|
|
86
86
|
isSigner: false,
|
|
87
|
-
isWritable:
|
|
87
|
+
isWritable: false,
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
pubkey: accounts.liquidationAccounts.repayReserveLiquiditySupply,
|
|
@@ -99,7 +99,7 @@ export function liquidateObligationAndRedeemReserveCollateralV2(
|
|
|
99
99
|
{
|
|
100
100
|
pubkey: accounts.liquidationAccounts.withdrawReserveLiquidityMint,
|
|
101
101
|
isSigner: false,
|
|
102
|
-
isWritable:
|
|
102
|
+
isWritable: false,
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
pubkey: accounts.liquidationAccounts.withdrawReserveCollateralMint,
|
|
@@ -78,7 +78,7 @@ export function repayAndWithdrawAndRedeem(
|
|
|
78
78
|
{
|
|
79
79
|
pubkey: accounts.repayAccounts.reserveLiquidityMint,
|
|
80
80
|
isSigner: false,
|
|
81
|
-
isWritable:
|
|
81
|
+
isWritable: false,
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
|
|
@@ -128,7 +128,7 @@ export function repayAndWithdrawAndRedeem(
|
|
|
128
128
|
{
|
|
129
129
|
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
130
130
|
isSigner: false,
|
|
131
|
-
isWritable:
|
|
131
|
+
isWritable: false,
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
134
|
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts
CHANGED
|
@@ -68,7 +68,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateralV2(
|
|
|
68
68
|
{
|
|
69
69
|
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
70
70
|
isSigner: false,
|
|
71
|
-
isWritable:
|
|
71
|
+
isWritable: false,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
@@ -486,6 +486,29 @@ export class UpdateIndividualAutodeleverageMarginCallPeriodSecs {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
export interface UpdateInitialDepositAmountJSON {
|
|
490
|
+
kind: "UpdateInitialDepositAmount"
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export class UpdateInitialDepositAmount {
|
|
494
|
+
static readonly discriminator = 21
|
|
495
|
+
static readonly kind = "UpdateInitialDepositAmount"
|
|
496
|
+
readonly discriminator = 21
|
|
497
|
+
readonly kind = "UpdateInitialDepositAmount"
|
|
498
|
+
|
|
499
|
+
toJSON(): UpdateInitialDepositAmountJSON {
|
|
500
|
+
return {
|
|
501
|
+
kind: "UpdateInitialDepositAmount",
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
toEncodable() {
|
|
506
|
+
return {
|
|
507
|
+
UpdateInitialDepositAmount: {},
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
489
512
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
490
513
|
export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
491
514
|
if (typeof obj !== "object") {
|
|
@@ -555,6 +578,9 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
555
578
|
if ("UpdateIndividualAutodeleverageMarginCallPeriodSecs" in obj) {
|
|
556
579
|
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
557
580
|
}
|
|
581
|
+
if ("UpdateInitialDepositAmount" in obj) {
|
|
582
|
+
return new UpdateInitialDepositAmount()
|
|
583
|
+
}
|
|
558
584
|
|
|
559
585
|
throw new Error("Invalid enum object")
|
|
560
586
|
}
|
|
@@ -626,6 +652,9 @@ export function fromJSON(
|
|
|
626
652
|
case "UpdateIndividualAutodeleverageMarginCallPeriodSecs": {
|
|
627
653
|
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
628
654
|
}
|
|
655
|
+
case "UpdateInitialDepositAmount": {
|
|
656
|
+
return new UpdateInitialDepositAmount()
|
|
657
|
+
}
|
|
629
658
|
}
|
|
630
659
|
}
|
|
631
660
|
|
|
@@ -652,6 +681,7 @@ export function layout(property?: string) {
|
|
|
652
681
|
borsh.struct([], "UpdatePaddingFields"),
|
|
653
682
|
borsh.struct([], "UpdateName"),
|
|
654
683
|
borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
|
|
684
|
+
borsh.struct([], "UpdateInitialDepositAmount"),
|
|
655
685
|
])
|
|
656
686
|
if (property !== undefined) {
|
|
657
687
|
return ret.replicate(property)
|
|
@@ -156,6 +156,7 @@ export type UpdateLendingMarketModeKind =
|
|
|
156
156
|
| UpdateLendingMarketMode.UpdatePaddingFields
|
|
157
157
|
| UpdateLendingMarketMode.UpdateName
|
|
158
158
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
|
|
159
|
+
| UpdateLendingMarketMode.UpdateInitialDepositAmount
|
|
159
160
|
export type UpdateLendingMarketModeJSON =
|
|
160
161
|
| UpdateLendingMarketMode.UpdateOwnerJSON
|
|
161
162
|
| UpdateLendingMarketMode.UpdateEmergencyModeJSON
|
|
@@ -178,6 +179,7 @@ export type UpdateLendingMarketModeJSON =
|
|
|
178
179
|
| UpdateLendingMarketMode.UpdatePaddingFieldsJSON
|
|
179
180
|
| UpdateLendingMarketMode.UpdateNameJSON
|
|
180
181
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
|
|
182
|
+
| UpdateLendingMarketMode.UpdateInitialDepositAmountJSON
|
|
181
183
|
|
|
182
184
|
export { LastUpdate } from "./LastUpdate"
|
|
183
185
|
export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
|
|
@@ -48,15 +48,21 @@ export class ObligationZP {
|
|
|
48
48
|
readonly referrer: PublicKey
|
|
49
49
|
/** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
|
|
50
50
|
readonly borrowingDisabled: number
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* A target LTV set by the risk council when marking this obligation for deleveraging.
|
|
53
|
+
* Only effective when `deleveraging_margin_call_started_slot != 0`.
|
|
54
|
+
* */
|
|
52
55
|
readonly autodeleverageTargetLtvPct: number
|
|
53
56
|
/** The lowest max LTV found amongst the collateral deposits */
|
|
54
57
|
readonly lowestReserveDepositMaxLtvPct: number
|
|
55
|
-
readonly reserved: Array<
|
|
58
|
+
readonly reserved: Array<number>
|
|
56
59
|
readonly highestBorrowFactorPct: BN
|
|
57
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* A timestamp at which the risk council most-recently marked this obligation for deleveraging.
|
|
62
|
+
* Zero if not currently subject to deleveraging.
|
|
63
|
+
* */
|
|
58
64
|
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
59
|
-
padding3: Array<BN> = new Array(0)
|
|
65
|
+
readonly padding3: Array<BN> = new Array(0)
|
|
60
66
|
|
|
61
67
|
static readonly layout = borsh.struct([
|
|
62
68
|
borsh.u64("tag"),
|
|
@@ -113,7 +119,7 @@ export class ObligationZP {
|
|
|
113
119
|
this.borrowingDisabled = fields.borrowingDisabled
|
|
114
120
|
this.autodeleverageTargetLtvPct = fields.autodeleverageTargetLtvPct
|
|
115
121
|
this.lowestReserveDepositMaxLtvPct = fields.lowestReserveDepositMaxLtvPct
|
|
116
|
-
this.reserved =
|
|
122
|
+
this.reserved = new Array<number>(0)
|
|
117
123
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
118
124
|
this.autodeleverageMarginCallStartedTimestamp = fields.autodeleverageMarginCallStartedTimestamp
|
|
119
125
|
this.padding3 = new Array<BN>(0);
|
|
@@ -198,4 +204,4 @@ export class ObligationZP {
|
|
|
198
204
|
padding3: [],
|
|
199
205
|
})
|
|
200
206
|
}
|
|
201
|
-
}
|
|
207
|
+
}
|