@kamino-finance/klend-sdk 5.11.2 → 5.11.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/action.d.ts +23 -23
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +69 -149
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +1 -1
- package/dist/classes/manager.js +1 -1
- package/dist/classes/market.d.ts +3 -3
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +30 -16
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +2 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +5 -0
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/vault.js +14 -14
- package/dist/classes/vault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -3
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +6 -6
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +10 -8
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +2 -2
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +11 -6
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +9 -7
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +78 -66
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -4
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +7 -52
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +3 -3
- package/dist/utils/oracle.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/classes/action.ts +75 -162
- package/src/classes/manager.ts +1 -1
- package/src/classes/market.ts +34 -25
- package/src/classes/obligation.ts +6 -0
- package/src/classes/vault.ts +14 -14
- package/src/client.ts +8 -3
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +8 -8
- package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
- package/src/idl_kamino_vault.json +7 -7
- package/src/lending_operations/repay_with_collateral_operations.ts +15 -11
- package/src/lending_operations/swap_collateral_operations.ts +19 -7
- package/src/leverage/operations.ts +114 -66
- package/src/leverage/types.ts +4 -4
- package/src/utils/ObligationType.ts +1 -1
- package/src/utils/managerTypes.ts +10 -52
- package/src/utils/oracle.ts +2 -2
package/dist/classes/action.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Connection, PublicKey, RpcResponseAndContext, SimulatedTransactionResponse, Transaction, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
-
import { ObligationType,
|
|
3
|
+
import { ObligationType, ScopePriceRefreshConfig } from '../utils';
|
|
4
4
|
import { KaminoMarket } from './market';
|
|
5
5
|
import { KaminoObligation } from './obligation';
|
|
6
6
|
import { KaminoReserve } from './reserve';
|
|
7
|
+
import { Scope } from '@kamino-finance/scope-sdk';
|
|
7
8
|
export type ActionType = 'deposit' | 'borrow' | 'withdraw' | 'repay' | 'mint' | 'redeem' | 'depositCollateral' | 'liquidate' | 'depositAndBorrow' | 'repayAndWithdraw' | 'refreshObligation' | 'requestElevationGroup' | 'withdrawReferrerFees';
|
|
8
9
|
export type AuxiliaryIx = 'setup' | 'inBetween' | 'cleanup';
|
|
9
10
|
export declare class KaminoAction {
|
|
@@ -54,40 +55,39 @@ export declare class KaminoAction {
|
|
|
54
55
|
currentSlot?: number): Promise<KaminoAction>;
|
|
55
56
|
static buildRequestElevationGroupTxns(kaminoMarket: KaminoMarket, payer: PublicKey, obligation: KaminoObligation, elevationGroup: number, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
56
57
|
currentSlot?: number): Promise<KaminoAction>;
|
|
57
|
-
static buildDepositTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
58
|
+
static buildDepositTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
58
59
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
59
60
|
requestElevationGroup?: boolean, // to be requested *before* the deposit
|
|
60
61
|
includeUserMetadata?: boolean, // if true it includes user metadata
|
|
61
|
-
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
static buildBorrowTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
62
|
+
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number, overrideElevationGroupRequest?: number | undefined): Promise<KaminoAction>;
|
|
63
|
+
addScopeRefreshIxs(scope: Scope, tokens: number[], feed?: string): Promise<void>;
|
|
64
|
+
static buildBorrowTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
65
65
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
66
66
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
67
|
-
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number,
|
|
68
|
-
static buildDepositReserveLiquidityTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
67
|
+
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number, overrideElevationGroupRequest?: number | undefined): Promise<KaminoAction>;
|
|
68
|
+
static buildDepositReserveLiquidityTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
69
69
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas
|
|
70
|
-
requestElevationGroup?: boolean, referrer?: PublicKey, currentSlot?: number
|
|
71
|
-
static buildRedeemReserveCollateralTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
70
|
+
requestElevationGroup?: boolean, referrer?: PublicKey, currentSlot?: number): Promise<KaminoAction>;
|
|
71
|
+
static buildRedeemReserveCollateralTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
72
72
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas
|
|
73
|
-
requestElevationGroup?: boolean, referrer?: PublicKey, currentSlot?: number
|
|
74
|
-
static buildDepositObligationCollateralTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
73
|
+
requestElevationGroup?: boolean, referrer?: PublicKey, currentSlot?: number): Promise<KaminoAction>;
|
|
74
|
+
static buildDepositObligationCollateralTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
75
75
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas
|
|
76
76
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
77
|
-
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number
|
|
78
|
-
static buildDepositAndBorrowTxns(kaminoMarket: KaminoMarket, depositAmount: string | BN, depositMint: PublicKey, borrowAmount: string | BN, borrowMint: PublicKey, payer: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
77
|
+
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number): Promise<KaminoAction>;
|
|
78
|
+
static buildDepositAndBorrowTxns(kaminoMarket: KaminoMarket, depositAmount: string | BN, depositMint: PublicKey, borrowAmount: string | BN, borrowMint: PublicKey, payer: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
79
79
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
80
80
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata,
|
|
81
|
-
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number
|
|
82
|
-
static buildRepayAndWithdrawTxns(kaminoMarket: KaminoMarket, repayAmount: string | BN, repayMint: PublicKey, withdrawAmount: string | BN, withdrawMint: PublicKey, payer: PublicKey, currentSlot: number, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
81
|
+
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number): Promise<KaminoAction>;
|
|
82
|
+
static buildRepayAndWithdrawTxns(kaminoMarket: KaminoMarket, repayAmount: string | BN, repayMint: PublicKey, withdrawAmount: string | BN, withdrawMint: PublicKey, payer: PublicKey, currentSlot: number, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
83
83
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
84
84
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata,
|
|
85
|
-
createLookupTable?: boolean, referrer?: PublicKey
|
|
86
|
-
static buildWithdrawTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
85
|
+
createLookupTable?: boolean, referrer?: PublicKey): Promise<KaminoAction>;
|
|
86
|
+
static buildWithdrawTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
87
87
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
88
88
|
requestElevationGroup?: boolean, // to be requested *after* the withdraw
|
|
89
89
|
includeUserMetadata?: boolean, // if true it includes user metadata
|
|
90
|
-
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number,
|
|
90
|
+
createLookupTable?: boolean, referrer?: PublicKey, currentSlot?: number, overrideElevationGroupRequest?: number, obligationCustomizations?: {
|
|
91
91
|
addedDepositReserves?: PublicKey[];
|
|
92
92
|
}): Promise<KaminoAction>;
|
|
93
93
|
/**
|
|
@@ -105,11 +105,11 @@ export declare class KaminoAction {
|
|
|
105
105
|
* @param includeUserMetadata - if true it includes user metadata
|
|
106
106
|
* @param referrer
|
|
107
107
|
*/
|
|
108
|
-
static buildRepayTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, currentSlot: number, payer?: PublicKey | undefined, extraComputeBudget?: number, includeAtaIxns?: boolean, requestElevationGroup?: boolean, includeUserMetadata?: boolean, createLookupTable?: boolean, referrer?: PublicKey
|
|
109
|
-
static buildLiquidateTxns(kaminoMarket: KaminoMarket, amount: string | BN, minCollateralReceiveAmount: string | BN, repayTokenMint: PublicKey, withdrawTokenMint: PublicKey, liquidator: PublicKey, obligationOwner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
108
|
+
static buildRepayTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, currentSlot: number, payer?: PublicKey | undefined, extraComputeBudget?: number, includeAtaIxns?: boolean, requestElevationGroup?: boolean, includeUserMetadata?: boolean, createLookupTable?: boolean, referrer?: PublicKey): Promise<KaminoAction>;
|
|
109
|
+
static buildLiquidateTxns(kaminoMarket: KaminoMarket, amount: string | BN, minCollateralReceiveAmount: string | BN, repayTokenMint: PublicKey, withdrawTokenMint: PublicKey, liquidator: PublicKey, obligationOwner: PublicKey, obligation: KaminoObligation | ObligationType, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
110
110
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
|
|
111
111
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
112
|
-
createLookupTable?: boolean, referrer?: PublicKey, maxAllowedLtvOverridePercent?: number, currentSlot?: number
|
|
112
|
+
createLookupTable?: boolean, referrer?: PublicKey, maxAllowedLtvOverridePercent?: number, currentSlot?: number): Promise<KaminoAction>;
|
|
113
113
|
static buildWithdrawReferrerFeeTxns(owner: PublicKey, tokenMint: PublicKey, kaminoMarket: KaminoMarket, currentSlot?: number): Promise<KaminoAction>;
|
|
114
114
|
getTransactions(): Promise<{
|
|
115
115
|
preLendingTxn: Transaction | null;
|
|
@@ -141,7 +141,7 @@ export declare class KaminoAction {
|
|
|
141
141
|
addInBetweenIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, addInitObligationForFarm: boolean, useV2Ixs: boolean): Promise<void>;
|
|
142
142
|
addRefreshObligation(crank: PublicKey): void;
|
|
143
143
|
addSupportIxsWithoutInitObligation(action: ActionType, includeAtaIxns: boolean, useV2Ixs: boolean, addAsSupportIx?: AuxiliaryIx, requestElevationGroup?: boolean, addInitObligationForFarm?: boolean, twoTokenAction?: boolean, overrideElevationGroupRequest?: number): Promise<void>;
|
|
144
|
-
addSupportIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, includeUserMetadata: boolean, addInitObligationForFarm: boolean, useV2Ixs: boolean, createLookupTable: boolean, twoTokenAction?: boolean, overrideElevationGroupRequest?: number): Promise<void>;
|
|
144
|
+
addSupportIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, includeUserMetadata: boolean, addInitObligationForFarm: boolean, useV2Ixs: boolean, scopeRefreshConfig: ScopePriceRefreshConfig | undefined, createLookupTable: boolean, twoTokenAction?: boolean, overrideElevationGroupRequest?: number): Promise<void>;
|
|
145
145
|
private static optionalAccount;
|
|
146
146
|
private addRefreshReserveIxs;
|
|
147
147
|
static getRefreshAllReserves(kaminoMarket: KaminoMarket, reserves: PublicKey[]): TransactionInstruction[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/classes/action.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,4BAA4B,EAI5B,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,MAAM,OAAO,CAAC;AAiCvB,OAAO,EAGL,cAAc,EAQd,
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/classes/action.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,4BAA4B,EAI5B,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,MAAM,OAAO,CAAC;AAiCvB,OAAO,EAGL,cAAc,EAQd,uBAAuB,EAGxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAA8B,YAAY,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAIlD,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,UAAU,GACV,OAAO,GACP,MAAM,GACN,QAAQ,GACR,mBAAmB,GACnB,WAAW,GACX,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,uBAAuB,GACvB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;AAE5D,qBAAa,YAAY;IACvB,YAAY,EAAE,YAAY,CAAC;IAE3B,OAAO,EAAE,aAAa,CAAC;IAEvB,cAAc,EAAE,aAAa,GAAG,SAAS,CAAC;IAE1C,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CA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AG,KAAK,CAAC,sBAAsB,CAAC;WAWvE,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;WAOrD,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;CAU3E"}
|
package/dist/classes/action.js
CHANGED
|
@@ -10,12 +10,12 @@ const bn_js_1 = __importDefault(require("bn.js"));
|
|
|
10
10
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
11
11
|
const instructions_1 = require("../idl_codegen/instructions");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const market_1 = require("./market");
|
|
13
14
|
const obligation_1 = require("./obligation");
|
|
14
15
|
const types_1 = require("../idl_codegen/types");
|
|
15
16
|
const farms_sdk_1 = require("@kamino-finance/farms-sdk");
|
|
16
17
|
const ObligationType_1 = require("../utils/ObligationType");
|
|
17
18
|
const lib_1 = require("../lib");
|
|
18
|
-
const scope_sdk_1 = require("@kamino-finance/scope-sdk");
|
|
19
19
|
const SOL_PADDING_FOR_INTEREST = new bn_js_1.default('1000000');
|
|
20
20
|
class KaminoAction {
|
|
21
21
|
kaminoMarket;
|
|
@@ -180,27 +180,18 @@ class KaminoAction {
|
|
|
180
180
|
axn.addRequestElevationIx(elevationGroup, 'setup');
|
|
181
181
|
return axn;
|
|
182
182
|
}
|
|
183
|
-
static async buildDepositTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
183
|
+
static async buildDepositTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
184
184
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
185
185
|
requestElevationGroup = false, // to be requested *before* the deposit
|
|
186
186
|
includeUserMetadata = true, // if true it includes user metadata
|
|
187
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0,
|
|
187
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0, overrideElevationGroupRequest = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
188
188
|
) {
|
|
189
189
|
const axn = await KaminoAction.initialize('deposit', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
190
190
|
const addInitObligationForFarm = true;
|
|
191
191
|
if (extraComputeBudget > 0) {
|
|
192
192
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
193
193
|
}
|
|
194
|
-
|
|
195
|
-
...axn.depositReserves,
|
|
196
|
-
...axn.borrowReserves,
|
|
197
|
-
axn.reserve.address,
|
|
198
|
-
]).toArray();
|
|
199
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
200
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
201
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
202
|
-
}
|
|
203
|
-
await axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable, undefined, overrideElevationGroupRequest);
|
|
194
|
+
await axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable, undefined, overrideElevationGroupRequest);
|
|
204
195
|
if (useV2Ixs) {
|
|
205
196
|
axn.addDepositIxV2();
|
|
206
197
|
}
|
|
@@ -210,54 +201,23 @@ class KaminoAction {
|
|
|
210
201
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
211
202
|
return axn;
|
|
212
203
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
|
|
217
|
-
if (!reserve) {
|
|
218
|
-
throw new Error(`Reserve not found for reserve ${reserveAddress.toBase58()}`);
|
|
219
|
-
}
|
|
220
|
-
if (!reserve.state.config.tokenInfo.scopeConfiguration.priceFeed.equals(web3_js_1.PublicKey.default)) {
|
|
221
|
-
reserve.state.config.tokenInfo.scopeConfiguration.priceChain.map((x) => {
|
|
222
|
-
if (x !== scope_sdk_1.U16_MAX) {
|
|
223
|
-
tokenIds.push(x);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
reserve.state.config.tokenInfo.scopeConfiguration.twapChain.map((x) => {
|
|
227
|
-
if (x !== scope_sdk_1.U16_MAX) {
|
|
228
|
-
tokenIds.push(x);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return tokenIds;
|
|
234
|
-
}
|
|
235
|
-
async addScopeRefreshIxs(tokens, feed = 'hubble') {
|
|
236
|
-
this.preTxnIxsLabels.unshift(`refreshScopePrices`);
|
|
237
|
-
this.preTxnIxs.unshift(await this.kaminoMarket.scope.refreshPriceListIx({
|
|
204
|
+
async addScopeRefreshIxs(scope, tokens, feed = 'hubble') {
|
|
205
|
+
this.setupIxsLabels.unshift(`refreshScopePrices`);
|
|
206
|
+
this.setupIxs.unshift(await scope.refreshPriceListIx({
|
|
238
207
|
feed: feed,
|
|
239
208
|
}, tokens));
|
|
240
209
|
}
|
|
241
|
-
static async buildBorrowTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
210
|
+
static async buildBorrowTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
242
211
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
243
212
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
244
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0,
|
|
213
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0, overrideElevationGroupRequest = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
245
214
|
) {
|
|
246
215
|
const axn = await KaminoAction.initialize('borrow', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
247
216
|
const addInitObligationForFarm = true;
|
|
248
217
|
if (extraComputeBudget > 0) {
|
|
249
218
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
250
219
|
}
|
|
251
|
-
|
|
252
|
-
...axn.depositReserves,
|
|
253
|
-
...axn.borrowReserves,
|
|
254
|
-
axn.reserve.address,
|
|
255
|
-
]).toArray();
|
|
256
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
257
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
258
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
259
|
-
}
|
|
260
|
-
await axn.addSupportIxs('borrow', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable, undefined, overrideElevationGroupRequest);
|
|
220
|
+
await axn.addSupportIxs('borrow', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable, undefined, overrideElevationGroupRequest);
|
|
261
221
|
if (useV2Ixs) {
|
|
262
222
|
axn.addBorrowIxV2();
|
|
263
223
|
}
|
|
@@ -267,69 +227,42 @@ class KaminoAction {
|
|
|
267
227
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
268
228
|
return axn;
|
|
269
229
|
}
|
|
270
|
-
static async buildDepositReserveLiquidityTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
230
|
+
static async buildDepositReserveLiquidityTxns(kaminoMarket, amount, mint, owner, obligation, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
271
231
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
272
|
-
requestElevationGroup = false, referrer = web3_js_1.PublicKey.default, currentSlot = 0
|
|
232
|
+
requestElevationGroup = false, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
273
233
|
const axn = await KaminoAction.initialize('mint', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
274
234
|
const addInitObligationForFarm = true;
|
|
275
235
|
if (extraComputeBudget > 0) {
|
|
276
236
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
277
237
|
}
|
|
278
|
-
|
|
279
|
-
...axn.depositReserves,
|
|
280
|
-
...axn.borrowReserves,
|
|
281
|
-
axn.reserve.address,
|
|
282
|
-
]).toArray();
|
|
283
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
284
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
285
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
286
|
-
}
|
|
287
|
-
await axn.addSupportIxs('mint', includeAtaIxns, requestElevationGroup, false, addInitObligationForFarm, false, false);
|
|
238
|
+
await axn.addSupportIxs('mint', includeAtaIxns, requestElevationGroup, false, addInitObligationForFarm, false, scopeRefreshConfig, false);
|
|
288
239
|
axn.addDepositReserveLiquidityIx();
|
|
289
240
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
290
241
|
return axn;
|
|
291
242
|
}
|
|
292
|
-
static async buildRedeemReserveCollateralTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
243
|
+
static async buildRedeemReserveCollateralTxns(kaminoMarket, amount, mint, owner, obligation, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
293
244
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
294
|
-
requestElevationGroup = false, referrer = web3_js_1.PublicKey.default, currentSlot = 0
|
|
245
|
+
requestElevationGroup = false, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
295
246
|
const axn = await KaminoAction.initialize('redeem', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
296
247
|
const addInitObligationForFarm = true;
|
|
297
248
|
if (extraComputeBudget > 0) {
|
|
298
249
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
299
250
|
}
|
|
300
|
-
|
|
301
|
-
...axn.depositReserves,
|
|
302
|
-
...axn.borrowReserves,
|
|
303
|
-
axn.reserve.address,
|
|
304
|
-
]).toArray();
|
|
305
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
306
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
307
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
308
|
-
}
|
|
309
|
-
await axn.addSupportIxs('redeem', includeAtaIxns, requestElevationGroup, false, addInitObligationForFarm, false, false);
|
|
251
|
+
await axn.addSupportIxs('redeem', includeAtaIxns, requestElevationGroup, false, addInitObligationForFarm, false, scopeRefreshConfig, false);
|
|
310
252
|
axn.addRedeemReserveCollateralIx();
|
|
311
253
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
312
254
|
return axn;
|
|
313
255
|
}
|
|
314
|
-
static async buildDepositObligationCollateralTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
256
|
+
static async buildDepositObligationCollateralTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
315
257
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
316
258
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
317
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0
|
|
259
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
318
260
|
const axn = await KaminoAction.initialize('depositCollateral', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
319
261
|
const addInitObligationForFarm = true;
|
|
320
262
|
if (extraComputeBudget > 0) {
|
|
321
263
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
322
264
|
}
|
|
323
|
-
|
|
324
|
-
...axn.depositReserves,
|
|
325
|
-
...axn.borrowReserves,
|
|
326
|
-
axn.reserve.address,
|
|
327
|
-
]).toArray();
|
|
328
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
329
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
330
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
331
|
-
}
|
|
332
|
-
await axn.addSupportIxs('depositCollateral', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable);
|
|
265
|
+
await axn.addSupportIxs('depositCollateral', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable);
|
|
333
266
|
if (useV2Ixs) {
|
|
334
267
|
axn.addDepositObligationCollateralIxV2();
|
|
335
268
|
}
|
|
@@ -339,10 +272,10 @@ class KaminoAction {
|
|
|
339
272
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
340
273
|
return axn;
|
|
341
274
|
}
|
|
342
|
-
static async buildDepositAndBorrowTxns(kaminoMarket, depositAmount, depositMint, borrowAmount, borrowMint, payer, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
275
|
+
static async buildDepositAndBorrowTxns(kaminoMarket, depositAmount, depositMint, borrowAmount, borrowMint, payer, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
343
276
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
344
277
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
|
|
345
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0
|
|
278
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
346
279
|
const axn = await KaminoAction.initializeMultiTokenAction(kaminoMarket, 'depositAndBorrow', depositAmount, depositMint, borrowMint, payer, payer, obligation, borrowAmount, referrer, currentSlot);
|
|
347
280
|
const addInitObligationForFarmForDeposit = true;
|
|
348
281
|
const addInitObligationForFarmForBorrow = false;
|
|
@@ -350,17 +283,7 @@ class KaminoAction {
|
|
|
350
283
|
if (extraComputeBudget > 0) {
|
|
351
284
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
352
285
|
}
|
|
353
|
-
|
|
354
|
-
...axn.depositReserves,
|
|
355
|
-
...axn.borrowReserves,
|
|
356
|
-
axn.reserve.address,
|
|
357
|
-
axn.outflowReserve.address,
|
|
358
|
-
]).toArray();
|
|
359
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
360
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
361
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
362
|
-
}
|
|
363
|
-
await axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarmForDeposit, useV2Ixs, createLookupTable, twoTokenAction);
|
|
286
|
+
await axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarmForDeposit, useV2Ixs, undefined, createLookupTable, twoTokenAction);
|
|
364
287
|
if (useV2Ixs) {
|
|
365
288
|
await axn.addDepositAndBorrowIxV2();
|
|
366
289
|
}
|
|
@@ -369,12 +292,24 @@ class KaminoAction {
|
|
|
369
292
|
}
|
|
370
293
|
await axn.addInBetweenIxs('depositAndBorrow', includeAtaIxns, requestElevationGroup, addInitObligationForFarmForBorrow, useV2Ixs);
|
|
371
294
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
295
|
+
// Create the scope refresh ixn in here to ensure it's the first ixn in the txn
|
|
296
|
+
const allReserves = new utils_1.PublicKeySet([
|
|
297
|
+
...axn.depositReserves,
|
|
298
|
+
...axn.borrowReserves,
|
|
299
|
+
axn.reserve.address,
|
|
300
|
+
...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
|
|
301
|
+
...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
|
|
302
|
+
]).toArray();
|
|
303
|
+
const tokenIds = (0, market_1.getTokenIdsForScopeRefresh)(axn.kaminoMarket, allReserves);
|
|
304
|
+
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
305
|
+
await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
306
|
+
}
|
|
372
307
|
return axn;
|
|
373
308
|
}
|
|
374
|
-
static async buildRepayAndWithdrawTxns(kaminoMarket, repayAmount, repayMint, withdrawAmount, withdrawMint, payer, currentSlot, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
309
|
+
static async buildRepayAndWithdrawTxns(kaminoMarket, repayAmount, repayMint, withdrawAmount, withdrawMint, payer, currentSlot, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
375
310
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
376
311
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
|
|
377
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default
|
|
312
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default) {
|
|
378
313
|
const axn = await KaminoAction.initializeMultiTokenAction(kaminoMarket, 'repayAndWithdraw', repayAmount, repayMint, withdrawMint, payer, payer, obligation, withdrawAmount, referrer, currentSlot);
|
|
379
314
|
const addInitObligationForFarmForRepay = true;
|
|
380
315
|
const addInitObligationForFarmForWithdraw = false;
|
|
@@ -382,17 +317,7 @@ class KaminoAction {
|
|
|
382
317
|
if (extraComputeBudget > 0) {
|
|
383
318
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
384
319
|
}
|
|
385
|
-
|
|
386
|
-
...axn.depositReserves,
|
|
387
|
-
...axn.borrowReserves,
|
|
388
|
-
axn.reserve.address,
|
|
389
|
-
axn.outflowReserve.address,
|
|
390
|
-
]).toArray();
|
|
391
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
392
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
393
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
394
|
-
}
|
|
395
|
-
await axn.addSupportIxs('repay', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarmForRepay, useV2Ixs, createLookupTable, twoTokenAction);
|
|
320
|
+
await axn.addSupportIxs('repay', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarmForRepay, useV2Ixs, undefined, createLookupTable, twoTokenAction);
|
|
396
321
|
const withdrawCollateralAmount = axn.getWithdrawCollateralAmount(axn.outflowReserve, axn.outflowAmount);
|
|
397
322
|
if (useV2Ixs) {
|
|
398
323
|
await axn.addRepayAndWithdrawIxsV2(withdrawCollateralAmount);
|
|
@@ -402,13 +327,25 @@ class KaminoAction {
|
|
|
402
327
|
}
|
|
403
328
|
await axn.addInBetweenIxs('repayAndWithdraw', includeAtaIxns, requestElevationGroup, addInitObligationForFarmForWithdraw, useV2Ixs);
|
|
404
329
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
330
|
+
// Create the scope refresh ixn in here to ensure it's the first ixn in the txn
|
|
331
|
+
const allReserves = new utils_1.PublicKeySet([
|
|
332
|
+
...axn.depositReserves,
|
|
333
|
+
...axn.borrowReserves,
|
|
334
|
+
axn.reserve.address,
|
|
335
|
+
...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
|
|
336
|
+
...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
|
|
337
|
+
]).toArray();
|
|
338
|
+
const tokenIds = (0, market_1.getTokenIdsForScopeRefresh)(axn.kaminoMarket, allReserves);
|
|
339
|
+
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
340
|
+
await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
341
|
+
}
|
|
405
342
|
return axn;
|
|
406
343
|
}
|
|
407
|
-
static async buildWithdrawTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
344
|
+
static async buildWithdrawTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
408
345
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
409
346
|
requestElevationGroup = false, // to be requested *after* the withdraw
|
|
410
347
|
includeUserMetadata = true, // if true it includes user metadata
|
|
411
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0,
|
|
348
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, currentSlot = 0, overrideElevationGroupRequest,
|
|
412
349
|
// Optional customizations which may be needed if the obligation was mutated by some previous ixn.
|
|
413
350
|
obligationCustomizations) {
|
|
414
351
|
const axn = await KaminoAction.initialize('withdraw', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
@@ -417,16 +354,7 @@ class KaminoAction {
|
|
|
417
354
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
418
355
|
}
|
|
419
356
|
axn.depositReserves.push(...(obligationCustomizations?.addedDepositReserves || []));
|
|
420
|
-
|
|
421
|
-
...axn.depositReserves,
|
|
422
|
-
...axn.borrowReserves,
|
|
423
|
-
axn.reserve.address,
|
|
424
|
-
]).toArray();
|
|
425
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
426
|
-
if (tokenIds.length > 0 && scopeRefresh && scopeRefresh.includeScopeRefresh) {
|
|
427
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
428
|
-
}
|
|
429
|
-
await axn.addSupportIxs('withdraw', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable, false, overrideElevationGroupRequest);
|
|
357
|
+
await axn.addSupportIxs('withdraw', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable, false, overrideElevationGroupRequest);
|
|
430
358
|
const collateralAmount = axn.getWithdrawCollateralAmount(axn.reserve, axn.amount);
|
|
431
359
|
if (useV2Ixs) {
|
|
432
360
|
await axn.addWithdrawIxV2(collateralAmount);
|
|
@@ -452,22 +380,13 @@ class KaminoAction {
|
|
|
452
380
|
* @param includeUserMetadata - if true it includes user metadata
|
|
453
381
|
* @param referrer
|
|
454
382
|
*/
|
|
455
|
-
static async buildRepayTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, currentSlot, payer = undefined, extraComputeBudget = 1_000_000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, createLookupTable = true, referrer = web3_js_1.PublicKey.default
|
|
383
|
+
static async buildRepayTxns(kaminoMarket, amount, mint, owner, obligation, useV2Ixs, scopeRefreshConfig, currentSlot, payer = undefined, extraComputeBudget = 1_000_000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, createLookupTable = true, referrer = web3_js_1.PublicKey.default) {
|
|
456
384
|
const axn = await KaminoAction.initialize('repay', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, payer);
|
|
457
385
|
const addInitObligationForFarm = true;
|
|
458
386
|
if (extraComputeBudget > 0) {
|
|
459
387
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
460
388
|
}
|
|
461
|
-
|
|
462
|
-
...axn.depositReserves,
|
|
463
|
-
...axn.borrowReserves,
|
|
464
|
-
axn.reserve.address,
|
|
465
|
-
]).toArray();
|
|
466
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
467
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
468
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
469
|
-
}
|
|
470
|
-
await axn.addSupportIxs('repay', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable);
|
|
389
|
+
await axn.addSupportIxs('repay', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable);
|
|
471
390
|
if (useV2Ixs) {
|
|
472
391
|
await axn.addRepayIxV2();
|
|
473
392
|
}
|
|
@@ -477,26 +396,16 @@ class KaminoAction {
|
|
|
477
396
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
478
397
|
return axn;
|
|
479
398
|
}
|
|
480
|
-
static async buildLiquidateTxns(kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, useV2Ixs, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
399
|
+
static async buildLiquidateTxns(kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, useV2Ixs, scopeRefreshConfig, extraComputeBudget = 1_000_000, // if > 0 then adds the ixn
|
|
481
400
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
|
|
482
401
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
483
|
-
createLookupTable = true, referrer = web3_js_1.PublicKey.default, maxAllowedLtvOverridePercent = 0, currentSlot = 0
|
|
402
|
+
createLookupTable = true, referrer = web3_js_1.PublicKey.default, maxAllowedLtvOverridePercent = 0, currentSlot = 0) {
|
|
484
403
|
const axn = await KaminoAction.initializeMultiTokenAction(kaminoMarket, 'liquidate', amount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, minCollateralReceiveAmount, referrer, currentSlot);
|
|
485
404
|
const addInitObligationForFarm = true;
|
|
486
405
|
if (extraComputeBudget > 0) {
|
|
487
406
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
488
407
|
}
|
|
489
|
-
|
|
490
|
-
...axn.depositReserves,
|
|
491
|
-
...axn.borrowReserves,
|
|
492
|
-
axn.reserve.address,
|
|
493
|
-
axn.outflowReserve.address,
|
|
494
|
-
]).toArray();
|
|
495
|
-
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
496
|
-
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
497
|
-
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
498
|
-
}
|
|
499
|
-
await axn.addSupportIxs('liquidate', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable);
|
|
408
|
+
await axn.addSupportIxs('liquidate', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable);
|
|
500
409
|
if (useV2Ixs) {
|
|
501
410
|
await axn.addLiquidateIxV2(maxAllowedLtvOverridePercent);
|
|
502
411
|
}
|
|
@@ -1521,7 +1430,7 @@ class KaminoAction {
|
|
|
1521
1430
|
}
|
|
1522
1431
|
}
|
|
1523
1432
|
}
|
|
1524
|
-
async addSupportIxs(action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, createLookupTable, twoTokenAction = false, overrideElevationGroupRequest) {
|
|
1433
|
+
async addSupportIxs(action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, useV2Ixs, scopeRefreshConfig, createLookupTable, twoTokenAction = false, overrideElevationGroupRequest) {
|
|
1525
1434
|
if (!['mint', 'redeem'].includes(action)) {
|
|
1526
1435
|
const [, ownerUserMetadata] = await this.kaminoMarket.getUserMetadata(this.owner);
|
|
1527
1436
|
if (!ownerUserMetadata && includeUserMetadata) {
|
|
@@ -1544,6 +1453,17 @@ class KaminoAction {
|
|
|
1544
1453
|
await this.addInitObligationIxs();
|
|
1545
1454
|
}
|
|
1546
1455
|
await this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, useV2Ixs, 'setup', requestElevationGroup, addInitObligationForFarm, twoTokenAction, overrideElevationGroupRequest);
|
|
1456
|
+
const allReserves = new utils_1.PublicKeySet([
|
|
1457
|
+
...this.depositReserves,
|
|
1458
|
+
...this.borrowReserves,
|
|
1459
|
+
this.reserve.address,
|
|
1460
|
+
...(this.outflowReserve ? [this.outflowReserve.address] : []),
|
|
1461
|
+
...(this.preLoadedDepositReservesSameTx ? this.preLoadedDepositReservesSameTx : []),
|
|
1462
|
+
]).toArray();
|
|
1463
|
+
const tokenIds = (0, market_1.getTokenIdsForScopeRefresh)(this.kaminoMarket, allReserves);
|
|
1464
|
+
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
1465
|
+
await this.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
1466
|
+
}
|
|
1547
1467
|
}
|
|
1548
1468
|
static optionalAccount(pubkey, programId = lib_1.PROGRAM_ID) {
|
|
1549
1469
|
if ((0, utils_1.isNotNullPubkey)(pubkey)) {
|