@kamino-finance/klend-sdk 7.1.4-beta.0 → 7.1.5
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/@codegen/klend/accounts/LendingMarket.d.ts +3 -144
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +3 -105
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -30
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +21 -31
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.d.ts +0 -6
- package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +2 -9
- package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.d.ts +75 -0
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +25 -0
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/accounts/index.d.ts +0 -6
- package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/index.js +1 -7
- package/dist/@codegen/klend/accounts/index.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +2 -226
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +3 -396
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +2 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -6
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +0 -16
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +1 -18
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
- package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/initReserve.js +5 -1
- package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
- package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.js +1 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts +1 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.js +0 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.js.map +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.js +0 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
- package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
- package/dist/@codegen/klend/types/AssetTier.d.ts +45 -0
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +1 -0
- package/dist/@codegen/klend/types/AssetTier.js +132 -0
- package/dist/@codegen/klend/types/AssetTier.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +5 -35
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +7 -17
- package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
- package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
- package/dist/@codegen/klend/types/ReserveConfig.d.ts +29 -141
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +25 -89
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
- package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveFees.js +8 -8
- package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
- package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +8 -26
- package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveLiquidity.js +8 -14
- package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +14 -92
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +23 -168
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -130
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -241
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/index.d.ts +8 -10
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +3 -7
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +4 -9
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +13 -22
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts +3 -30
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +10 -364
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +3 -2
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +3 -12
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +2 -6
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +6 -26
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +7 -13
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/unstakingPool.d.ts +3 -20
- package/dist/classes/unstakingPool.d.ts.map +1 -1
- package/dist/classes/unstakingPool.js +8 -62
- package/dist/classes/unstakingPool.js.map +1 -1
- package/dist/classes/vault.d.ts +2 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +59 -38
- package/dist/classes/vault.js.map +1 -1
- package/dist/idl/klend.json +293 -2186
- package/dist/lending_operations/index.d.ts +0 -1
- package/dist/lending_operations/index.d.ts.map +1 -1
- package/dist/lending_operations/index.js +0 -1
- package/dist/lending_operations/index.js.map +1 -1
- package/dist/manager/client_kamino_manager.js +9 -12
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/ata.d.ts +10 -1
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +47 -0
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +4 -9
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +14 -10
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +22 -25
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +5 -210
- package/src/@codegen/klend/accounts/Obligation.ts +31 -53
- package/src/@codegen/klend/accounts/Reserve.ts +2 -13
- package/src/@codegen/klend/accounts/UserState.ts +75 -0
- package/src/@codegen/klend/accounts/index.ts +0 -6
- package/src/@codegen/klend/errors/custom.ts +2 -427
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +4 -7
- package/src/@codegen/klend/instructions/index.ts +0 -34
- package/src/@codegen/klend/instructions/initReserve.ts +6 -2
- package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.ts +1 -1
- package/src/@codegen/klend/instructions/updateGlobalConfig.ts +1 -2
- package/src/@codegen/klend/instructions/updateReserveConfig.ts +1 -2
- package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
- package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
- package/src/@codegen/klend/types/AssetTier.ts +119 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +9 -39
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +39 -171
- package/src/@codegen/klend/types/ReserveFees.ts +12 -12
- package/src/@codegen/klend/types/ReserveLiquidity.ts +12 -30
- package/src/@codegen/klend/types/UpdateConfigMode.ts +26 -206
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -300
- package/src/@codegen/klend/types/index.ts +16 -45
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +13 -22
- package/src/classes/action.ts +8 -577
- package/src/classes/manager.ts +7 -13
- package/src/classes/market.ts +5 -36
- package/src/classes/obligation.ts +1 -1
- package/src/classes/reserve.ts +8 -13
- package/src/classes/unstakingPool.ts +6 -83
- package/src/classes/vault.ts +75 -54
- package/src/idl/klend.json +294 -2187
- package/src/lending_operations/index.ts +0 -1
- package/src/manager/client_kamino_manager.ts +9 -13
- package/src/utils/ata.ts +79 -0
- package/src/utils/managerTypes.ts +4 -9
- package/src/utils/seeds.ts +26 -28
- package/dist/@codegen/klend/accounts/PoolState.d.ts +0 -53
- package/dist/@codegen/klend/accounts/PoolState.d.ts.map +0 -1
- package/dist/@codegen/klend/accounts/PoolState.js +0 -167
- package/dist/@codegen/klend/accounts/PoolState.js.map +0 -1
- package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts +0 -41
- package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts.map +0 -1
- package/dist/@codegen/klend/accounts/UnstakeTicket.js +0 -143
- package/dist/@codegen/klend/accounts/UnstakeTicket.js.map +0 -1
- package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +0 -132
- package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +0 -1
- package/dist/@codegen/klend/accounts/WithdrawTicket.js +0 -191
- package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +0 -1
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +0 -39
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +0 -67
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +0 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +0 -36
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +0 -49
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +0 -47
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +0 -66
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +0 -31
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -64
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts +0 -53
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js +0 -190
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js.map +0 -1
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts +0 -70
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js +0 -261
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js.map +0 -1
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts +0 -41
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.js +0 -135
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.js.map +0 -1
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +0 -51
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +0 -28
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +0 -192
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.js +0 -194
- package/dist/@codegen/klend/types/BorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +0 -39
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +0 -100
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +0 -1
- package/dist/@codegen/klend/types/WithdrawQueue.d.ts +0 -64
- package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +0 -1
- package/dist/@codegen/klend/types/WithdrawQueue.js +0 -104
- package/dist/@codegen/klend/types/WithdrawQueue.js.map +0 -1
- package/dist/lending_operations/unstake_lst_collateral.d.ts +0 -12
- package/dist/lending_operations/unstake_lst_collateral.d.ts.map +0 -1
- package/dist/lending_operations/unstake_lst_collateral.js +0 -104
- package/dist/lending_operations/unstake_lst_collateral.js.map +0 -1
- package/src/@codegen/klend/accounts/PoolState.ts +0 -192
- package/src/@codegen/klend/accounts/UnstakeTicket.ts +0 -160
- package/src/@codegen/klend/accounts/WithdrawTicket.ts +0 -256
- package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +0 -89
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
- package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +0 -96
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -77
- package/src/@codegen/klend/instructions/unstakeLstCollateralEnd.ts +0 -251
- package/src/@codegen/klend/instructions/unstakeLstCollateralStart.ts +0 -353
- package/src/@codegen/klend/instructions/withdrawObligationUsol.ts +0 -168
- package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +0 -92
- package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
- package/src/@codegen/klend/types/WithdrawQueue.ts +0 -117
- package/src/lending_operations/unstake_lst_collateral.ts +0 -174
package/dist/classes/action.js
CHANGED
|
@@ -19,15 +19,8 @@ const sysvars_1 = require("@solana/sysvars");
|
|
|
19
19
|
const token_2022_1 = require("@solana-program/token-2022");
|
|
20
20
|
const system_1 = require("@solana-program/system");
|
|
21
21
|
const signer_1 = require("../utils/signer");
|
|
22
|
-
const programId_2 = require("../@codegen/unstaking_pool/programId");
|
|
23
|
-
const unstakingPool_1 = require("./unstakingPool");
|
|
24
|
-
const programId_3 = require("../@codegen/klend/programId");
|
|
25
|
-
const UnstakeTicket_1 = require("../@codegen/unstaking_pool/accounts/UnstakeTicket");
|
|
26
|
-
const instructions_2 = require("../@codegen/unstaking_pool/instructions");
|
|
27
|
-
const unstakeLstCollateralEnd_1 = require("../@codegen/klend/instructions/unstakeLstCollateralEnd");
|
|
28
22
|
class KaminoAction {
|
|
29
23
|
kaminoMarket;
|
|
30
|
-
unstakingPool;
|
|
31
24
|
reserve;
|
|
32
25
|
outflowReserve;
|
|
33
26
|
owner;
|
|
@@ -59,7 +52,7 @@ class KaminoAction {
|
|
|
59
52
|
borrowReserves;
|
|
60
53
|
preLoadedDepositReservesSameTx;
|
|
61
54
|
currentSlot;
|
|
62
|
-
constructor(kaminoMarket, owner, obligation, mint, positions, amount, depositReserves, borrowReserves, reserveState, currentSlot,
|
|
55
|
+
constructor(kaminoMarket, owner, obligation, mint, positions, amount, depositReserves, borrowReserves, reserveState, currentSlot, secondaryMint, outflowReserveState, outflowAmount, referrer = (0, kit_1.none)(), payer) {
|
|
63
56
|
this.kaminoMarket = kaminoMarket;
|
|
64
57
|
this.obligation = obligation;
|
|
65
58
|
this.owner = owner;
|
|
@@ -88,23 +81,15 @@ class KaminoAction {
|
|
|
88
81
|
this.preLoadedDepositReservesSameTx = [];
|
|
89
82
|
this.referrer = referrer;
|
|
90
83
|
this.currentSlot = currentSlot;
|
|
91
|
-
this.unstakingPool = unstakingPool;
|
|
92
84
|
}
|
|
93
|
-
static async initialize(action, amount, mint, owner, kaminoMarket, obligation, referrer = (0, kit_1.none)(), currentSlot = 0n, payer = owner
|
|
85
|
+
static async initialize(action, amount, mint, owner, kaminoMarket, obligation, referrer = (0, kit_1.none)(), currentSlot = 0n, payer = owner) {
|
|
94
86
|
const reserve = kaminoMarket.getReserveByMint(mint);
|
|
95
87
|
if (reserve === undefined) {
|
|
96
88
|
throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress()}`);
|
|
97
89
|
}
|
|
98
90
|
const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = await KaminoAction.loadObligation(action, kaminoMarket, owner.address, reserve.address, obligation);
|
|
99
91
|
const referrerKey = await this.getReferrerKey(kaminoMarket, owner.address, kaminoObligation, referrer);
|
|
100
|
-
|
|
101
|
-
if (needsUnstakingPool) {
|
|
102
|
-
const unstakingPoolPk = kaminoMarket.state.unstakingPoolState;
|
|
103
|
-
const unstakingPoolProgramId = kaminoMarket.programId == programId_3.PROGRAM_ID ? programId_2.PROGRAM_ID : unstakingPool_1.UNSTAKING_POOL_STAGING_ID;
|
|
104
|
-
unstakingPool = new unstakingPool_1.UnstakingPool(unstakingPoolPk, undefined, unstakingPoolProgramId);
|
|
105
|
-
await unstakingPool.reloadState(kaminoMarket.getRpc());
|
|
106
|
-
}
|
|
107
|
-
return new KaminoAction(kaminoMarket, owner, kaminoObligation || obligation, mint, distinctReserveCount, amount, depositReserves, borrowReserves, reserve, currentSlot, unstakingPool, undefined, undefined, undefined, referrerKey, payer);
|
|
92
|
+
return new KaminoAction(kaminoMarket, owner, kaminoObligation || obligation, mint, distinctReserveCount, amount, depositReserves, borrowReserves, reserve, currentSlot, undefined, undefined, undefined, referrerKey, payer);
|
|
108
93
|
}
|
|
109
94
|
static async getUserAccountAddresses(owner, reserve) {
|
|
110
95
|
const [userTokenAccountAddress, userCollateralAccountAddress] = await Promise.all([
|
|
@@ -414,24 +399,6 @@ class KaminoAction {
|
|
|
414
399
|
}
|
|
415
400
|
return axn;
|
|
416
401
|
}
|
|
417
|
-
static async buildUnstakeLstCollateralStartTxns(kaminoMarket, lstToConvert, usolMint, lstMint, payer, currentSlot, obligation, depositStakedSolRemainingAccounts, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ix
|
|
418
|
-
includeAtaIxs = true, // if true it includes create and close wsol and token atas,
|
|
419
|
-
initUserMetadata = {
|
|
420
|
-
skipInitialization: false,
|
|
421
|
-
skipLutCreation: false,
|
|
422
|
-
}, referrer = (0, kit_1.none)()) {
|
|
423
|
-
const axn = await KaminoAction.initializeMultiTokenAction(kaminoMarket, 'unstakeLstCollateralStart', lstToConvert, usolMint, lstMint, payer, payer.address, obligation, undefined, referrer, currentSlot, true);
|
|
424
|
-
const addInitObligationForFarm = true;
|
|
425
|
-
const twoTokenAction = true;
|
|
426
|
-
const requestElevationGroup = false;
|
|
427
|
-
const useV2Ixs = true;
|
|
428
|
-
if (extraComputeBudget > 0) {
|
|
429
|
-
axn.addComputeBudgetIx(extraComputeBudget);
|
|
430
|
-
}
|
|
431
|
-
await axn.addSupportIxs('unstakeLstCollateralStart', includeAtaIxs, requestElevationGroup, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, initUserMetadata, twoTokenAction);
|
|
432
|
-
await axn.addUnstakeLstCollateralStartIxs(depositStakedSolRemainingAccounts);
|
|
433
|
-
return axn;
|
|
434
|
-
}
|
|
435
402
|
static async buildWithdrawTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ix
|
|
436
403
|
includeAtaIxs = true, // if true it includes create and close wsol and token atas,
|
|
437
404
|
requestElevationGroup = false, // to be requested *after* the withdraw
|
|
@@ -458,38 +425,6 @@ class KaminoAction {
|
|
|
458
425
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
459
426
|
return axn;
|
|
460
427
|
}
|
|
461
|
-
static async buildWithdrawUsolTxns(kaminoMarket, amount, mint, owner, obligation, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ix
|
|
462
|
-
includeAtaIxs = true, // if true it includes create and close wsol and token atas,
|
|
463
|
-
requestElevationGroup = false, // to be requested *after* the withdraw
|
|
464
|
-
initUserMetadata = {
|
|
465
|
-
skipInitialization: false,
|
|
466
|
-
skipLutCreation: false,
|
|
467
|
-
}, referrer = (0, kit_1.none)(), currentSlot = 0n, overrideElevationGroupRequest,
|
|
468
|
-
// Optional customizations which may be needed if the obligation was mutated by some previous ix.
|
|
469
|
-
obligationCustomizations, burnUsol = false) {
|
|
470
|
-
const axn = await KaminoAction.initialize('withdraw', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, undefined, true);
|
|
471
|
-
if (extraComputeBudget > 0) {
|
|
472
|
-
axn.addComputeBudgetIx(extraComputeBudget);
|
|
473
|
-
}
|
|
474
|
-
axn.depositReserves.push(...(obligationCustomizations?.addedDepositReserves || []));
|
|
475
|
-
const addInitObligationForFarm = true;
|
|
476
|
-
const useV2Ixs = true;
|
|
477
|
-
await axn.addSupportIxs('withdraw', includeAtaIxs, requestElevationGroup, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, initUserMetadata, false, overrideElevationGroupRequest);
|
|
478
|
-
// We need user SOL ata to be initialized so they can receive the SOL
|
|
479
|
-
// No need for other support ix (such as refresh reserve) as this burnUsolIx is called from unstaking pool
|
|
480
|
-
if (burnUsol) {
|
|
481
|
-
const [userAta, createUserTokenAccountIx] = await (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(axn.owner, utils_1.WRAPPED_SOL_MINT, axn.owner.address);
|
|
482
|
-
axn.setupIxs.unshift(createUserTokenAccountIx);
|
|
483
|
-
axn.setupIxsLabels.unshift(`CreateLiquidityUserAta[${userAta}]`);
|
|
484
|
-
}
|
|
485
|
-
const collateralAmount = axn.getWithdrawCollateralAmount(axn.reserve, axn.amount);
|
|
486
|
-
const unstakeTicket = await axn.addWithdrawUsolIx(collateralAmount);
|
|
487
|
-
if (burnUsol) {
|
|
488
|
-
await axn.addBurnAllUsolIx(unstakeTicket);
|
|
489
|
-
}
|
|
490
|
-
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
491
|
-
return axn;
|
|
492
|
-
}
|
|
493
428
|
/**
|
|
494
429
|
*
|
|
495
430
|
* @param kaminoMarket
|
|
@@ -547,26 +482,6 @@ class KaminoAction {
|
|
|
547
482
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
548
483
|
return axn;
|
|
549
484
|
}
|
|
550
|
-
static async buildUnstakeLstCollateralEndTxns(kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, scopeRefreshConfig = undefined, extraComputeBudget = 1_000_000, // if > 0 then adds the ix
|
|
551
|
-
includeAtaIxs = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
|
|
552
|
-
requestElevationGroup = false, initUserMetadata = {
|
|
553
|
-
skipInitialization: false,
|
|
554
|
-
skipLutCreation: false,
|
|
555
|
-
}, referrer = (0, kit_1.none)(), maxAllowedLtvOverridePercent = 0, currentSlot = 0n, burnUsol = false) {
|
|
556
|
-
const axn = await KaminoAction.initializeMultiTokenAction(kaminoMarket, 'liquidate', amount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, minCollateralReceiveAmount, referrer, currentSlot, true);
|
|
557
|
-
const addInitObligationForFarm = true;
|
|
558
|
-
const useV2Ixs = true;
|
|
559
|
-
if (extraComputeBudget > 0) {
|
|
560
|
-
axn.addComputeBudgetIx(extraComputeBudget);
|
|
561
|
-
}
|
|
562
|
-
await axn.addSupportIxs('liquidate', includeAtaIxs, requestElevationGroup, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, initUserMetadata);
|
|
563
|
-
const unstakeTicket = await axn.addUnstakeLstCollateralEndIx(maxAllowedLtvOverridePercent);
|
|
564
|
-
if (burnUsol) {
|
|
565
|
-
await axn.addBurnAllUsolIx(unstakeTicket);
|
|
566
|
-
}
|
|
567
|
-
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
568
|
-
return axn;
|
|
569
|
-
}
|
|
570
485
|
static async buildWithdrawReferrerFeeTxns(owner, tokenMint, kaminoMarket, currentSlot = 0n) {
|
|
571
486
|
const { axn, createAtaIxs } = await KaminoAction.initializeWithdrawReferrerFees(tokenMint, owner, kaminoMarket, currentSlot);
|
|
572
487
|
axn.setupIxs.push(...createAtaIxs);
|
|
@@ -684,100 +599,6 @@ class KaminoAction {
|
|
|
684
599
|
farmsProgram: programId_1.PROGRAM_ID,
|
|
685
600
|
}, undefined, this.kaminoMarket.programId));
|
|
686
601
|
}
|
|
687
|
-
async addUnstakeLstCollateralStartIxs(depositStakedSolRemainingAccounts) {
|
|
688
|
-
// Deposit USOL - our custom token issued by unstaking pool program
|
|
689
|
-
// and withdraw some kind of staked sol
|
|
690
|
-
this.lendingIxsLabels.push(`unstakeLstCollateral(depositReserve=${this.reserve.address})(withdrawReserve=${this.outflowReserve.address})(obligation=${this.getObligationPda()})`);
|
|
691
|
-
const depositReservesList = this.getAdditionalDepositReservesList();
|
|
692
|
-
const depositReserveAccountMetas = depositReservesList.map((reserve) => {
|
|
693
|
-
return { address: reserve, role: kit_1.AccountRole.WRITABLE };
|
|
694
|
-
});
|
|
695
|
-
const borrowReserveAccountMetas = this.borrowReserves.map((reserve) => {
|
|
696
|
-
return { address: reserve, role: kit_1.AccountRole.WRITABLE };
|
|
697
|
-
});
|
|
698
|
-
if (!this.outflowReserve) {
|
|
699
|
-
throw new Error(`outflowReserve not set`);
|
|
700
|
-
}
|
|
701
|
-
if (!this.unstakingPool || !this.unstakingPool.state) {
|
|
702
|
-
throw new Error(`unstaking pool not set`);
|
|
703
|
-
}
|
|
704
|
-
const basePoolAuthority = (await (0, unstakingPool_1.unstakingPoolBaseAuthorityPda)(this.unstakingPool.address, this.unstakingPool.programId))[0];
|
|
705
|
-
const ownerUsolToken = await this.getUserTokenAccountAddress(this.reserve);
|
|
706
|
-
const ownerLstToken = await this.getUserTokenAccountAddress(this.outflowReserve);
|
|
707
|
-
const unstakingPoolAuthority = (await (0, utils_1.unstakingPoolMarketAuthorityPda)(this.kaminoMarket.address, this.kaminoMarket.programId))[0];
|
|
708
|
-
const obligationPda = await this.getObligationPda();
|
|
709
|
-
const { collateralFarmAccounts: depositFarmsAccounts } = await KaminoAction.getFarmAccountsForReserve(obligationPda, this.reserve);
|
|
710
|
-
const { collateralFarmAccounts: withdrawFarmsAccounts } = await KaminoAction.getFarmAccountsForReserve(obligationPda, this.outflowReserve);
|
|
711
|
-
// Create unstake ticket
|
|
712
|
-
const unstakeTicket = await (0, kit_1.generateKeyPairSigner)();
|
|
713
|
-
const unstakeTicketSize = UnstakeTicket_1.UnstakeTicket.layout.span + 8;
|
|
714
|
-
const createUnstakeTicketIx = (0, system_1.getCreateAccountInstruction)({
|
|
715
|
-
payer: this.owner,
|
|
716
|
-
newAccount: unstakeTicket,
|
|
717
|
-
lamports: await this.kaminoMarket.getRpc().getMinimumBalanceForRentExemption(BigInt(unstakeTicketSize)).send(),
|
|
718
|
-
space: unstakeTicketSize,
|
|
719
|
-
programAddress: this.unstakingPool.programId,
|
|
720
|
-
});
|
|
721
|
-
this.lendingIxs.push(createUnstakeTicketIx);
|
|
722
|
-
const unstakeLstCollateralStartIx = (0, instructions_1.unstakeLstCollateralStart)({
|
|
723
|
-
lstToConvert: this.amount,
|
|
724
|
-
}, {
|
|
725
|
-
depositAndWithdrawAccounts: {
|
|
726
|
-
depositAccounts: {
|
|
727
|
-
owner: this.owner,
|
|
728
|
-
obligation: obligationPda,
|
|
729
|
-
lendingMarket: this.kaminoMarket.getAddress(),
|
|
730
|
-
lendingMarketAuthority: await this.kaminoMarket.getLendingMarketAuthority(),
|
|
731
|
-
reserve: this.reserve.address,
|
|
732
|
-
reserveLiquidityMint: this.reserve.getLiquidityMint(),
|
|
733
|
-
reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
|
|
734
|
-
reserveCollateralMint: this.reserve.getCTokenMint(),
|
|
735
|
-
reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault, // destinationCollateral
|
|
736
|
-
userSourceLiquidity: ownerUsolToken,
|
|
737
|
-
placeholderUserDestinationCollateral: (0, kit_1.none)(),
|
|
738
|
-
collateralTokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
739
|
-
liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
|
|
740
|
-
instructionSysvarAccount: sysvars_1.SYSVAR_INSTRUCTIONS_ADDRESS,
|
|
741
|
-
},
|
|
742
|
-
withdrawAccounts: {
|
|
743
|
-
owner: this.owner,
|
|
744
|
-
obligation: obligationPda,
|
|
745
|
-
lendingMarket: this.kaminoMarket.getAddress(),
|
|
746
|
-
lendingMarketAuthority: await this.kaminoMarket.getLendingMarketAuthority(),
|
|
747
|
-
withdrawReserve: this.outflowReserve.address,
|
|
748
|
-
reserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
|
|
749
|
-
reserveCollateralMint: this.outflowReserve.getCTokenMint(),
|
|
750
|
-
reserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
|
|
751
|
-
reserveSourceCollateral: this.outflowReserve.state.collateral.supplyVault,
|
|
752
|
-
userDestinationLiquidity: ownerLstToken,
|
|
753
|
-
placeholderUserDestinationCollateral: (0, kit_1.none)(),
|
|
754
|
-
collateralTokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
755
|
-
liquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
|
|
756
|
-
instructionSysvarAccount: sysvars_1.SYSVAR_INSTRUCTIONS_ADDRESS,
|
|
757
|
-
},
|
|
758
|
-
depositFarmsAccounts,
|
|
759
|
-
withdrawFarmsAccounts,
|
|
760
|
-
farmsProgram: programId_1.PROGRAM_ID,
|
|
761
|
-
},
|
|
762
|
-
depositStakedSolAccounts: {
|
|
763
|
-
owner: this.owner,
|
|
764
|
-
unstakingPoolAuthority,
|
|
765
|
-
ownerStakedSolToken: ownerLstToken,
|
|
766
|
-
ownerUnstakingSolToken: ownerUsolToken,
|
|
767
|
-
stakedSolMint: this.outflowReserve.getLiquidityMint(),
|
|
768
|
-
poolState: this.unstakingPool.address,
|
|
769
|
-
unstakingSolMint: this.reserve.getLiquidityMint(),
|
|
770
|
-
basePoolAuthority,
|
|
771
|
-
systemProgram: system_1.SYSTEM_PROGRAM_ADDRESS,
|
|
772
|
-
unstakingSolTokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
773
|
-
stakedSolTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
|
|
774
|
-
unstakeTicket: unstakeTicket.address,
|
|
775
|
-
unstakingTicketBurnAuthority: unstakingPoolAuthority,
|
|
776
|
-
},
|
|
777
|
-
unstakingPoolProgram: this.unstakingPool.programId,
|
|
778
|
-
}, [...depositStakedSolRemainingAccounts, ...depositReserveAccountMetas, ...borrowReserveAccountMetas], this.kaminoMarket.programId);
|
|
779
|
-
this.lendingIxs.push(unstakeLstCollateralStartIx);
|
|
780
|
-
}
|
|
781
602
|
/// @deprecated -- use addDepositObligationCollateralIxV2 instead
|
|
782
603
|
async addDepositObligationCollateralIx() {
|
|
783
604
|
this.lendingIxsLabels.push(`depositObligationCollateral`);
|
|
@@ -934,60 +755,6 @@ class KaminoAction {
|
|
|
934
755
|
farmsProgram: programId_1.PROGRAM_ID,
|
|
935
756
|
}, undefined, this.kaminoMarket.programId));
|
|
936
757
|
}
|
|
937
|
-
async addWithdrawUsolIx(collateralAmount) {
|
|
938
|
-
if (!(0, obligation_1.isKaminoObligation)(this.obligation)) {
|
|
939
|
-
throw new Error(`obligation is not a KaminoObligation`);
|
|
940
|
-
}
|
|
941
|
-
if (!this.unstakingPool || !this.unstakingPool.state) {
|
|
942
|
-
throw new Error(`unstaking pool not set`);
|
|
943
|
-
}
|
|
944
|
-
const obligationAddress = await this.getObligationPda();
|
|
945
|
-
const { collateralFarmAccounts: farmsAccounts } = await KaminoAction.getFarmAccountsForReserve(obligationAddress, this.reserve);
|
|
946
|
-
this.lendingIxsLabels.push(`withdrawUsol`);
|
|
947
|
-
const newUnstakeTicket = await (0, kit_1.generateKeyPairSigner)();
|
|
948
|
-
const unstakeTicketSize = UnstakeTicket_1.UnstakeTicket.layout.span + 8;
|
|
949
|
-
const createUnstakeTicketIx = (0, system_1.getCreateAccountInstruction)({
|
|
950
|
-
payer: this.owner,
|
|
951
|
-
newAccount: newUnstakeTicket,
|
|
952
|
-
lamports: await this.kaminoMarket.getRpc().getMinimumBalanceForRentExemption(BigInt(unstakeTicketSize)).send(),
|
|
953
|
-
space: unstakeTicketSize,
|
|
954
|
-
programAddress: this.unstakingPool.programId,
|
|
955
|
-
});
|
|
956
|
-
this.lendingIxs.push(createUnstakeTicketIx);
|
|
957
|
-
const unstakingPoolAuthority = (await (0, utils_1.unstakingPoolMarketAuthorityPda)(this.kaminoMarket.address, this.kaminoMarket.programId))[0];
|
|
958
|
-
this.lendingIxs.push((0, instructions_1.withdrawObligationUsol)({
|
|
959
|
-
collateralAmount,
|
|
960
|
-
}, {
|
|
961
|
-
withdrawAccounts: {
|
|
962
|
-
withdrawAccounts: {
|
|
963
|
-
owner: this.owner,
|
|
964
|
-
obligation: obligationAddress,
|
|
965
|
-
lendingMarket: this.kaminoMarket.getAddress(),
|
|
966
|
-
lendingMarketAuthority: await this.kaminoMarket.getLendingMarketAuthority(),
|
|
967
|
-
withdrawReserve: this.reserve.address,
|
|
968
|
-
reserveLiquidityMint: this.reserve.getLiquidityMint(),
|
|
969
|
-
reserveCollateralMint: this.reserve.getCTokenMint(),
|
|
970
|
-
reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
|
|
971
|
-
reserveSourceCollateral: this.reserve.state.collateral.supplyVault,
|
|
972
|
-
userDestinationLiquidity: await this.getUserTokenAccountAddress(this.reserve),
|
|
973
|
-
placeholderUserDestinationCollateral: (0, kit_1.none)(),
|
|
974
|
-
collateralTokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
975
|
-
liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
|
|
976
|
-
instructionSysvarAccount: sysvars_1.SYSVAR_INSTRUCTIONS_ADDRESS,
|
|
977
|
-
},
|
|
978
|
-
farmsAccounts: farmsAccounts,
|
|
979
|
-
farmsProgram: programId_1.PROGRAM_ID,
|
|
980
|
-
},
|
|
981
|
-
extraAccounts: {
|
|
982
|
-
unstakeTicket: this.obligation.state.unstakeTicket,
|
|
983
|
-
emptyUnstakeTicket: newUnstakeTicket.address,
|
|
984
|
-
unstakingPoolAuthority: unstakingPoolAuthority,
|
|
985
|
-
unstakingPoolProgram: this.unstakingPool.programId,
|
|
986
|
-
systemProgram: system_1.SYSTEM_PROGRAM_ADDRESS,
|
|
987
|
-
},
|
|
988
|
-
}, [], this.kaminoMarket.programId));
|
|
989
|
-
return newUnstakeTicket.address;
|
|
990
|
-
}
|
|
991
758
|
/// @deprecated -- use addRepayIxV2 instead
|
|
992
759
|
async addRepayIx() {
|
|
993
760
|
const obligationAddress = await this.getObligationPda();
|
|
@@ -1417,27 +1184,6 @@ class KaminoAction {
|
|
|
1417
1184
|
farmsProgram: programId_1.PROGRAM_ID,
|
|
1418
1185
|
}, undefined, this.kaminoMarket.programId));
|
|
1419
1186
|
}
|
|
1420
|
-
async addBurnAllUsolIx(unstakeTicket) {
|
|
1421
|
-
this.lendingIxsLabels.push(`burnUsolIx`);
|
|
1422
|
-
if (!this.unstakingPool || !this.unstakingPool.state) {
|
|
1423
|
-
throw new Error(`unstaking pool not set`);
|
|
1424
|
-
}
|
|
1425
|
-
this.lendingIxs.push((0, instructions_2.burn)({
|
|
1426
|
-
sharesToBurn: new bn_js_1.default(utils_1.U64_MAX),
|
|
1427
|
-
minWsolToReceive: new bn_js_1.default(0), // TODO: find a way to compute a reasonable slippage
|
|
1428
|
-
}, {
|
|
1429
|
-
user: this.owner,
|
|
1430
|
-
userUnstakingSolToken: await (0, utils_1.getAssociatedTokenAddress)(this.unstakingPool.state.unstakingSolMint, this.owner.address, token_1.TOKEN_PROGRAM_ADDRESS),
|
|
1431
|
-
userWsolToken: await (0, utils_1.getAssociatedTokenAddress)(utils_1.WRAPPED_SOL_MINT, this.owner.address, token_1.TOKEN_PROGRAM_ADDRESS),
|
|
1432
|
-
wsolVault: this.unstakingPool.state.wsolVault,
|
|
1433
|
-
wsolMint: utils_1.WRAPPED_SOL_MINT,
|
|
1434
|
-
poolState: this.unstakingPool.address,
|
|
1435
|
-
unstakeTicket,
|
|
1436
|
-
unstakingSolMint: this.unstakingPool.state.unstakingSolMint,
|
|
1437
|
-
basePoolAuthority: this.unstakingPool.state.basePoolAuthority,
|
|
1438
|
-
tokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
1439
|
-
}, this.unstakingPool.programId));
|
|
1440
|
-
}
|
|
1441
1187
|
async addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
|
|
1442
1188
|
this.lendingIxsLabels.push(`liquidateObligationAndRedeemReserveCollateral`);
|
|
1443
1189
|
if (!this.outflowReserve) {
|
|
@@ -1540,80 +1286,6 @@ class KaminoAction {
|
|
|
1540
1286
|
};
|
|
1541
1287
|
this.lendingIxs.push(liquidateIx);
|
|
1542
1288
|
}
|
|
1543
|
-
async addUnstakeLstCollateralEndIx(maxAllowedLtvOverridePercent = 0) {
|
|
1544
|
-
this.lendingIxsLabels.push(`unstakeLstCollateralEnd`);
|
|
1545
|
-
if (!this.outflowReserve) {
|
|
1546
|
-
throw Error(`Withdraw reserve during liquidation is not defined`);
|
|
1547
|
-
}
|
|
1548
|
-
if (!(0, obligation_1.isKaminoObligation)(this.obligation)) {
|
|
1549
|
-
throw new Error(`obligation is not a KaminoObligation`);
|
|
1550
|
-
}
|
|
1551
|
-
if (!this.unstakingPool || !this.unstakingPool.state) {
|
|
1552
|
-
throw new Error(`unstaking pool not set`);
|
|
1553
|
-
}
|
|
1554
|
-
const depositReservesList = this.getAdditionalDepositReservesList();
|
|
1555
|
-
const depositReserveAccountMetas = depositReservesList.map((reserve) => {
|
|
1556
|
-
return { address: reserve, role: kit_1.AccountRole.WRITABLE };
|
|
1557
|
-
});
|
|
1558
|
-
const obligationAddress = await this.getObligationPda();
|
|
1559
|
-
const { collateralFarmAccounts: collateralFarmsAccounts } = await KaminoAction.getFarmAccountsForReserve(obligationAddress, this.outflowReserve);
|
|
1560
|
-
const { debtFarmAccounts: debtFarmsAccounts } = await KaminoAction.getFarmAccountsForReserve(await this.getObligationPda(), this.reserve);
|
|
1561
|
-
const newUnstakeTicket = await (0, kit_1.generateKeyPairSigner)();
|
|
1562
|
-
const unstakeTicketSize = UnstakeTicket_1.UnstakeTicket.layout.span + 8;
|
|
1563
|
-
const createUnstakeTicketIx = (0, system_1.getCreateAccountInstruction)({
|
|
1564
|
-
payer: this.owner,
|
|
1565
|
-
newAccount: newUnstakeTicket,
|
|
1566
|
-
lamports: await this.kaminoMarket.getRpc().getMinimumBalanceForRentExemption(BigInt(unstakeTicketSize)).send(),
|
|
1567
|
-
space: unstakeTicketSize,
|
|
1568
|
-
programAddress: this.unstakingPool.programId,
|
|
1569
|
-
});
|
|
1570
|
-
this.lendingIxs.push(createUnstakeTicketIx);
|
|
1571
|
-
const unstakingPoolAuthority = (await (0, utils_1.unstakingPoolMarketAuthorityPda)(this.kaminoMarket.address, this.kaminoMarket.programId))[0];
|
|
1572
|
-
const extraAccounts = this.obligation.state.elevationGroup > 0 ? depositReserveAccountMetas : [];
|
|
1573
|
-
const liquidateIx = (0, unstakeLstCollateralEnd_1.unstakeLstCollateralEnd)({
|
|
1574
|
-
liquidityAmount: this.amount,
|
|
1575
|
-
// TODO: Configure this when updating liquidator with new interface
|
|
1576
|
-
minAcceptableReceivedLiquidityAmount: this.outflowAmount || new bn_js_1.default(0),
|
|
1577
|
-
maxAllowedLtvOverridePercent: new bn_js_1.default(maxAllowedLtvOverridePercent),
|
|
1578
|
-
}, {
|
|
1579
|
-
liquidationAccounts: {
|
|
1580
|
-
liquidationAccounts: {
|
|
1581
|
-
liquidator: this.owner,
|
|
1582
|
-
obligation: obligationAddress,
|
|
1583
|
-
lendingMarket: this.kaminoMarket.getAddress(),
|
|
1584
|
-
lendingMarketAuthority: await this.kaminoMarket.getLendingMarketAuthority(),
|
|
1585
|
-
repayReserve: this.reserve.address,
|
|
1586
|
-
repayReserveLiquidityMint: this.reserve.getLiquidityMint(),
|
|
1587
|
-
repayReserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
|
|
1588
|
-
withdrawReserve: this.outflowReserve.address,
|
|
1589
|
-
withdrawReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
|
|
1590
|
-
withdrawReserveCollateralMint: this.outflowReserve.getCTokenMint(),
|
|
1591
|
-
withdrawReserveCollateralSupply: this.outflowReserve.state.collateral.supplyVault,
|
|
1592
|
-
withdrawReserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
|
|
1593
|
-
userSourceLiquidity: await this.getUserTokenAccountAddress(this.reserve),
|
|
1594
|
-
userDestinationCollateral: await this.getUserCollateralAccountAddress(this.outflowReserve),
|
|
1595
|
-
userDestinationLiquidity: await this.getUserTokenAccountAddress(this.outflowReserve),
|
|
1596
|
-
withdrawReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
|
|
1597
|
-
collateralTokenProgram: token_1.TOKEN_PROGRAM_ADDRESS,
|
|
1598
|
-
repayLiquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
|
|
1599
|
-
withdrawLiquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
|
|
1600
|
-
instructionSysvarAccount: sysvars_1.SYSVAR_INSTRUCTIONS_ADDRESS,
|
|
1601
|
-
},
|
|
1602
|
-
debtFarmsAccounts,
|
|
1603
|
-
collateralFarmsAccounts,
|
|
1604
|
-
farmsProgram: programId_1.PROGRAM_ID,
|
|
1605
|
-
},
|
|
1606
|
-
extraAccounts: {
|
|
1607
|
-
unstakeTicket: this.obligation.state.unstakeTicket,
|
|
1608
|
-
emptyUnstakeTicket: newUnstakeTicket.address,
|
|
1609
|
-
unstakingPoolAuthority: unstakingPoolAuthority,
|
|
1610
|
-
unstakingPoolProgram: this.unstakingPool.programId,
|
|
1611
|
-
systemProgram: system_1.SYSTEM_PROGRAM_ADDRESS,
|
|
1612
|
-
},
|
|
1613
|
-
}, extraAccounts, this.kaminoMarket.programId);
|
|
1614
|
-
this.lendingIxs.push(liquidateIx);
|
|
1615
|
-
return newUnstakeTicket.address;
|
|
1616
|
-
}
|
|
1617
1289
|
async addInBetweenIxs(action, includeAtaIxs, requestElevationGroup, addInitObligationForFarm, useV2Ixs) {
|
|
1618
1290
|
await this.addSupportIxsWithoutInitObligation(action, includeAtaIxs, useV2Ixs, 'inBetween', requestElevationGroup, addInitObligationForFarm);
|
|
1619
1291
|
}
|
|
@@ -1644,7 +1316,6 @@ class KaminoAction {
|
|
|
1644
1316
|
'repayAndWithdrawV2',
|
|
1645
1317
|
'refreshObligation',
|
|
1646
1318
|
'depositAndWithdraw',
|
|
1647
|
-
'unstakeLstCollateralStart',
|
|
1648
1319
|
].includes(action)) {
|
|
1649
1320
|
// The support ixs in order are:
|
|
1650
1321
|
// 0. Init obligation ix
|
|
@@ -1662,17 +1333,13 @@ class KaminoAction {
|
|
|
1662
1333
|
if (action === 'liquidate' ||
|
|
1663
1334
|
action === 'depositAndBorrow' ||
|
|
1664
1335
|
action === 'repayAndWithdraw' ||
|
|
1665
|
-
action === 'repayAndWithdrawV2'
|
|
1666
|
-
action === 'unstakeLstCollateralStart') {
|
|
1336
|
+
action === 'repayAndWithdrawV2') {
|
|
1667
1337
|
if (!this.outflowReserve) {
|
|
1668
1338
|
throw new Error('outflowReserve is undefined');
|
|
1669
1339
|
}
|
|
1670
|
-
if (action === 'depositAndBorrow' ||
|
|
1671
|
-
action === 'repayAndWithdraw' ||
|
|
1672
|
-
action === 'repayAndWithdrawV2' ||
|
|
1673
|
-
action === 'unstakeLstCollateralStart') {
|
|
1340
|
+
if (action === 'depositAndBorrow' || action === 'repayAndWithdraw' || action === 'repayAndWithdrawV2') {
|
|
1674
1341
|
currentReserves = [this.reserve, this.outflowReserve];
|
|
1675
|
-
if (action === 'depositAndBorrow'
|
|
1342
|
+
if (action === 'depositAndBorrow') {
|
|
1676
1343
|
if ((0, obligation_1.isKaminoObligation)(this.obligation)) {
|
|
1677
1344
|
const deposit = this.obligation.getDepositByReserve(this.reserve.address);
|
|
1678
1345
|
if (!deposit) {
|
|
@@ -1725,12 +1392,6 @@ class KaminoAction {
|
|
|
1725
1392
|
await this.addInitObligationForFarm(this.outflowReserve, types_1.ReserveFarmKind.Collateral, addAsSupportIx);
|
|
1726
1393
|
}
|
|
1727
1394
|
}
|
|
1728
|
-
else if (action === 'unstakeLstCollateralStart') {
|
|
1729
|
-
await this.addInitObligationForFarm(this.reserve, types_1.ReserveFarmKind.Collateral, addAsSupportIx);
|
|
1730
|
-
if (this.outflowReserve) {
|
|
1731
|
-
await this.addInitObligationForFarm(this.outflowReserve, types_1.ReserveFarmKind.Collateral, addAsSupportIx);
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
1395
|
else {
|
|
1735
1396
|
await this.addInitObligationForFarm(this.reserve, types_1.ReserveFarmKind.Collateral, addAsSupportIx);
|
|
1736
1397
|
await this.addInitObligationForFarm(this.reserve, types_1.ReserveFarmKind.Debt, addAsSupportIx);
|
|
@@ -1754,13 +1415,6 @@ class KaminoAction {
|
|
|
1754
1415
|
: [];
|
|
1755
1416
|
await this.addRefreshObligationIx(addAsSupportIx, repaidBorrowReservesToSkip);
|
|
1756
1417
|
}
|
|
1757
|
-
else if (action == 'unstakeLstCollateralStart') {
|
|
1758
|
-
if (!(0, obligation_1.isKaminoObligation)(this.obligation)) {
|
|
1759
|
-
throw new Error(`obligation is not a KaminoObligation`);
|
|
1760
|
-
}
|
|
1761
|
-
// Usol reserve doesn't exist yet
|
|
1762
|
-
await this.addRefreshObligationIx(addAsSupportIx, [this.reserve.address]);
|
|
1763
|
-
}
|
|
1764
1418
|
else {
|
|
1765
1419
|
await this.addRefreshObligationIx(addAsSupportIx);
|
|
1766
1420
|
}
|
|
@@ -2387,32 +2041,24 @@ class KaminoAction {
|
|
|
2387
2041
|
this.cleanupIxs.push(...postIxs);
|
|
2388
2042
|
this.cleanupIxsLabels.push(...postIxsLabels);
|
|
2389
2043
|
}
|
|
2390
|
-
static async initializeMultiTokenAction(kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, signer, obligationOwner, obligation, outflowAmount, referrer = (0, kit_1.none)(), currentSlot = 0n
|
|
2044
|
+
static async initializeMultiTokenAction(kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, signer, obligationOwner, obligation, outflowAmount, referrer = (0, kit_1.none)(), currentSlot = 0n) {
|
|
2391
2045
|
const inflowReserve = kaminoMarket.getExistingReserveByMint(inflowTokenMint);
|
|
2392
2046
|
const outflowReserve = kaminoMarket.getExistingReserveByMint(outflowTokenMint);
|
|
2393
2047
|
const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = await KaminoAction.loadObligation(action, kaminoMarket, obligationOwner, inflowReserve.address, obligation, outflowReserve.address);
|
|
2394
2048
|
const referrerKey = await this.getReferrerKey(kaminoMarket, signer.address, kaminoObligation, referrer);
|
|
2395
2049
|
let secondaryMint;
|
|
2396
2050
|
let primaryMint;
|
|
2397
|
-
let unstakingPool = undefined;
|
|
2398
2051
|
if (action === 'liquidate' ||
|
|
2399
2052
|
action === 'depositAndBorrow' ||
|
|
2400
2053
|
action === 'repayAndWithdraw' ||
|
|
2401
|
-
action === 'repayAndWithdrawV2'
|
|
2402
|
-
action === 'unstakeLstCollateralStart') {
|
|
2054
|
+
action === 'repayAndWithdrawV2') {
|
|
2403
2055
|
primaryMint = inflowTokenMint;
|
|
2404
2056
|
secondaryMint = outflowTokenMint;
|
|
2405
|
-
if (needsUnstakingPool) {
|
|
2406
|
-
const unstakingPoolPk = kaminoMarket.state.unstakingPoolState;
|
|
2407
|
-
const unstakingPoolProgramId = kaminoMarket.programId == programId_3.PROGRAM_ID ? programId_2.PROGRAM_ID : unstakingPool_1.UNSTAKING_POOL_STAGING_ID;
|
|
2408
|
-
unstakingPool = new unstakingPool_1.UnstakingPool(unstakingPoolPk, undefined, unstakingPoolProgramId);
|
|
2409
|
-
await unstakingPool.reloadState(kaminoMarket.getRpc());
|
|
2410
|
-
}
|
|
2411
2057
|
}
|
|
2412
2058
|
else {
|
|
2413
2059
|
throw new Error('Invalid action');
|
|
2414
2060
|
}
|
|
2415
|
-
return new KaminoAction(kaminoMarket, signer, kaminoObligation || obligation, primaryMint, distinctReserveCount, inflowAmount, depositReserves, borrowReserves, inflowReserve, currentSlot,
|
|
2061
|
+
return new KaminoAction(kaminoMarket, signer, kaminoObligation || obligation, primaryMint, distinctReserveCount, inflowAmount, depositReserves, borrowReserves, inflowReserve, currentSlot, secondaryMint, outflowReserve, outflowAmount, referrerKey);
|
|
2416
2062
|
}
|
|
2417
2063
|
static async initializeWithdrawReferrerFees(mint, owner, kaminoMarket, currentSlot = 0n) {
|
|
2418
2064
|
const reserve = kaminoMarket.getReserveByMint(mint);
|
|
@@ -2426,7 +2072,7 @@ class KaminoAction {
|
|
|
2426
2072
|
},
|
|
2427
2073
|
]);
|
|
2428
2074
|
return {
|
|
2429
|
-
axn: new KaminoAction(kaminoMarket, owner, new ObligationType_1.VanillaObligation(kaminoMarket.programId), mint, 0, new bn_js_1.default(0), [], [], reserve, currentSlot, undefined, undefined, undefined, undefined, undefined
|
|
2075
|
+
axn: new KaminoAction(kaminoMarket, owner, new ObligationType_1.VanillaObligation(kaminoMarket.programId), mint, 0, new bn_js_1.default(0), [], [], reserve, currentSlot, undefined, undefined, undefined, undefined, undefined),
|
|
2430
2076
|
createAtaIxs: [createAtaIx],
|
|
2431
2077
|
};
|
|
2432
2078
|
}
|