@kamino-finance/klend-sdk 7.4.0-beta.0 → 7.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts +3 -51
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +6 -39
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -24
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +21 -24
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +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/errors/custom.d.ts +1 -89
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +1 -155
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +0 -4
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +1 -6
- package/dist/@codegen/klend/instructions/index.js.map +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 +5 -60
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +7 -36
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +7 -33
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +13 -61
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -52
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -97
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/index.d.ts +8 -8
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +3 -5
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +5 -8
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +14 -17
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts +21 -91
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +141 -119
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/actionTypes.d.ts +310 -0
- package/dist/classes/actionTypes.d.ts.map +1 -0
- package/dist/classes/actionTypes.js +3 -0
- package/dist/classes/actionTypes.js.map +1 -0
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +0 -4
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +5 -11
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +29 -21
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +9 -9
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +49 -51
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +6 -3
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +1 -3
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/client/commands/borrow.d.ts +1 -1
- package/dist/client/commands/borrow.d.ts.map +1 -1
- package/dist/client/commands/borrow.js +11 -2
- package/dist/client/commands/borrow.js.map +1 -1
- package/dist/client/commands/deposit.d.ts +1 -1
- package/dist/client/commands/deposit.d.ts.map +1 -1
- package/dist/client/commands/deposit.js +11 -2
- package/dist/client/commands/deposit.js.map +1 -1
- package/dist/client/commands/printReserve.d.ts +1 -1
- package/dist/client/commands/printReserve.d.ts.map +1 -1
- package/dist/client/commands/printReserve.js +2 -4
- package/dist/client/commands/printReserve.js.map +1 -1
- package/dist/client/commands/repay.d.ts +1 -1
- package/dist/client/commands/repay.d.ts.map +1 -1
- package/dist/client/commands/repay.js +12 -2
- package/dist/client/commands/repay.js.map +1 -1
- package/dist/client/commands/withdraw.d.ts +1 -1
- package/dist/client/commands/withdraw.d.ts.map +1 -1
- package/dist/client/commands/withdraw.js +11 -2
- package/dist/client/commands/withdraw.js.map +1 -1
- package/dist/idl/klend.json +54 -581
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
- package/dist/lending_operations/repay_with_collateral_calcs.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 +43 -10
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +40 -21
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +6 -6
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +167 -52
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +2 -2
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/manager/client_kamino_manager.js +6 -12
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/obligation_orders/price_based.js +1 -0
- package/dist/obligation_orders/price_based.js.map +1 -1
- package/dist/utils/ObligationType.d.ts +33 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +81 -2
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +1 -3
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +2 -2
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +49 -25
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +8 -79
- package/src/@codegen/klend/accounts/Obligation.ts +31 -42
- package/src/@codegen/klend/accounts/Reserve.ts +1 -1
- package/src/@codegen/klend/accounts/UserState.ts +75 -0
- package/src/@codegen/klend/errors/custom.ts +0 -172
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +3 -0
- package/src/@codegen/klend/instructions/index.ts +0 -7
- 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 +9 -72
- package/src/@codegen/klend/types/UpdateConfigMode.ts +13 -73
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -120
- package/src/@codegen/klend/types/index.ts +14 -21
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +14 -17
- package/src/classes/action.ts +321 -347
- package/src/classes/actionTypes.ts +295 -0
- package/src/classes/manager.ts +0 -5
- package/src/classes/market.ts +42 -32
- package/src/classes/obligation.ts +55 -54
- package/src/classes/obligationOrder.ts +6 -3
- package/src/classes/reserve.ts +1 -3
- package/src/classes/shared.ts +2 -0
- package/src/client/client.ts +17 -18
- package/src/client/commands/borrow.ts +10 -9
- package/src/client/commands/deposit.ts +10 -9
- package/src/client/commands/printReserve.ts +2 -4
- package/src/client/commands/repay.ts +11 -10
- package/src/client/commands/withdraw.ts +15 -9
- package/src/idl/klend.json +54 -581
- package/src/lending_operations/repay_with_collateral_calcs.ts +3 -4
- package/src/lending_operations/repay_with_collateral_operations.ts +40 -38
- package/src/lending_operations/swap_collateral_operations.ts +47 -41
- package/src/leverage/operations.ts +168 -129
- package/src/leverage/types.ts +2 -2
- package/src/manager/client_kamino_manager.ts +6 -12
- package/src/obligation_orders/price_based.ts +1 -0
- package/src/utils/ObligationType.ts +92 -1
- package/src/utils/managerTypes.ts +1 -3
- package/src/utils/userMetadata.ts +64 -30
- 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/setBorrowOrder.d.ts +0 -33
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -66
- package/dist/@codegen/klend/instructions/setBorrowOrder.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/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -81
- package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { Address, Option, Slot, TransactionSigner } from '@solana/kit';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { ObligationType, ScopePriceRefreshConfig } from '../utils';
|
|
4
|
+
import { KaminoObligation } from './obligation';
|
|
5
|
+
import { KaminoMarket } from './market';
|
|
6
|
+
import { ActionType } from './action';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for KaminoAction.initialize
|
|
10
|
+
*/
|
|
11
|
+
export interface InitializeActionProps {
|
|
12
|
+
kaminoMarket: KaminoMarket;
|
|
13
|
+
action: ActionType;
|
|
14
|
+
amount: string | BN;
|
|
15
|
+
reserveAddress: Address;
|
|
16
|
+
owner: TransactionSigner;
|
|
17
|
+
obligation: KaminoObligation | ObligationType;
|
|
18
|
+
referrer?: Option<Address>;
|
|
19
|
+
currentSlot?: Slot;
|
|
20
|
+
payer?: TransactionSigner;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props for KaminoAction.buildDepositTxns
|
|
25
|
+
*/
|
|
26
|
+
export interface BuildDepositTxnsProps {
|
|
27
|
+
kaminoMarket: KaminoMarket;
|
|
28
|
+
amount: string | BN;
|
|
29
|
+
reserveAddress: Address;
|
|
30
|
+
owner: TransactionSigner;
|
|
31
|
+
obligation: KaminoObligation | ObligationType;
|
|
32
|
+
useV2Ixs: boolean;
|
|
33
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
34
|
+
extraComputeBudget?: number;
|
|
35
|
+
includeAtaIxs?: boolean;
|
|
36
|
+
requestElevationGroup?: boolean;
|
|
37
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
38
|
+
referrer?: Option<Address>;
|
|
39
|
+
currentSlot?: Slot;
|
|
40
|
+
overrideElevationGroupRequest?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Props for KaminoAction.buildBorrowTxns
|
|
45
|
+
*/
|
|
46
|
+
export interface BuildBorrowTxnsProps {
|
|
47
|
+
kaminoMarket: KaminoMarket;
|
|
48
|
+
amount: string | BN;
|
|
49
|
+
reserveAddress: Address;
|
|
50
|
+
owner: TransactionSigner;
|
|
51
|
+
obligation: KaminoObligation | ObligationType;
|
|
52
|
+
useV2Ixs: boolean;
|
|
53
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
54
|
+
extraComputeBudget?: number;
|
|
55
|
+
includeAtaIxs?: boolean;
|
|
56
|
+
requestElevationGroup?: boolean;
|
|
57
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
58
|
+
referrer?: Option<Address>;
|
|
59
|
+
currentSlot?: Slot;
|
|
60
|
+
overrideElevationGroupRequest?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Props for KaminoAction.buildDepositReserveLiquidityTxns
|
|
65
|
+
*/
|
|
66
|
+
export interface BuildDepositReserveLiquidityTxnsProps {
|
|
67
|
+
kaminoMarket: KaminoMarket;
|
|
68
|
+
amount: string | BN;
|
|
69
|
+
reserveAddress: Address;
|
|
70
|
+
owner: TransactionSigner;
|
|
71
|
+
obligation: KaminoObligation | ObligationType;
|
|
72
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
73
|
+
extraComputeBudget?: number;
|
|
74
|
+
includeAtaIxs?: boolean;
|
|
75
|
+
requestElevationGroup?: boolean;
|
|
76
|
+
referrer?: Option<Address>;
|
|
77
|
+
currentSlot?: Slot;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Props for KaminoAction.buildRedeemReserveCollateralTxns
|
|
82
|
+
*/
|
|
83
|
+
export interface BuildRedeemReserveCollateralTxnsProps {
|
|
84
|
+
kaminoMarket: KaminoMarket;
|
|
85
|
+
amount: string | BN;
|
|
86
|
+
reserveAddress: Address;
|
|
87
|
+
owner: TransactionSigner;
|
|
88
|
+
obligation: KaminoObligation | ObligationType;
|
|
89
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
90
|
+
extraComputeBudget?: number;
|
|
91
|
+
includeAtaIxs?: boolean;
|
|
92
|
+
requestElevationGroup?: boolean;
|
|
93
|
+
referrer?: Option<Address>;
|
|
94
|
+
currentSlot?: Slot;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Props for KaminoAction.buildWithdrawTxns
|
|
99
|
+
*/
|
|
100
|
+
export interface BuildWithdrawTxnsProps {
|
|
101
|
+
kaminoMarket: KaminoMarket;
|
|
102
|
+
amount: string | BN;
|
|
103
|
+
reserveAddress: Address;
|
|
104
|
+
owner: TransactionSigner;
|
|
105
|
+
obligation: KaminoObligation | ObligationType;
|
|
106
|
+
useV2Ixs: boolean;
|
|
107
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
108
|
+
extraComputeBudget?: number;
|
|
109
|
+
includeAtaIxs?: boolean;
|
|
110
|
+
requestElevationGroup?: boolean;
|
|
111
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
112
|
+
referrer?: Option<Address>;
|
|
113
|
+
currentSlot?: Slot;
|
|
114
|
+
overrideElevationGroupRequest?: number;
|
|
115
|
+
obligationCustomizations?: {
|
|
116
|
+
addedDepositReserves?: Address[];
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Props for KaminoAction.buildRepayTxns
|
|
122
|
+
*/
|
|
123
|
+
export interface BuildRepayTxnsProps {
|
|
124
|
+
kaminoMarket: KaminoMarket;
|
|
125
|
+
amount: string | BN;
|
|
126
|
+
reserveAddress: Address;
|
|
127
|
+
owner: TransactionSigner;
|
|
128
|
+
obligation: KaminoObligation | ObligationType;
|
|
129
|
+
useV2Ixs: boolean;
|
|
130
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
131
|
+
currentSlot: Slot;
|
|
132
|
+
extraComputeBudget?: number;
|
|
133
|
+
includeAtaIxs?: boolean;
|
|
134
|
+
requestElevationGroup?: boolean;
|
|
135
|
+
payer?: TransactionSigner;
|
|
136
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
137
|
+
referrer?: Option<Address>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Props for KaminoAction.buildDepositAndBorrowTxns
|
|
142
|
+
*/
|
|
143
|
+
export interface BuildDepositAndBorrowTxnsProps {
|
|
144
|
+
kaminoMarket: KaminoMarket;
|
|
145
|
+
depositAmount: string | BN;
|
|
146
|
+
depositReserveAddress: Address;
|
|
147
|
+
borrowAmount: string | BN;
|
|
148
|
+
borrowReserveAddress: Address;
|
|
149
|
+
owner: TransactionSigner;
|
|
150
|
+
obligation: KaminoObligation | ObligationType;
|
|
151
|
+
useV2Ixs: boolean;
|
|
152
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
153
|
+
extraComputeBudget?: number;
|
|
154
|
+
includeAtaIxs?: boolean;
|
|
155
|
+
requestElevationGroup?: boolean;
|
|
156
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
157
|
+
referrer?: Option<Address>;
|
|
158
|
+
currentSlot?: Slot;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Props for KaminoAction.buildRefreshObligationTxns
|
|
163
|
+
*/
|
|
164
|
+
export interface BuildRefreshObligationTxnsProps {
|
|
165
|
+
kaminoMarket: KaminoMarket;
|
|
166
|
+
payer: TransactionSigner;
|
|
167
|
+
obligation: KaminoObligation;
|
|
168
|
+
extraComputeBudget?: number;
|
|
169
|
+
currentSlot?: Slot;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Props for KaminoAction.buildRequestElevationGroupTxns
|
|
174
|
+
*/
|
|
175
|
+
export interface BuildRequestElevationGroupTxnsProps {
|
|
176
|
+
kaminoMarket: KaminoMarket;
|
|
177
|
+
owner: TransactionSigner;
|
|
178
|
+
obligation: KaminoObligation;
|
|
179
|
+
elevationGroup: number;
|
|
180
|
+
extraComputeBudget?: number;
|
|
181
|
+
currentSlot?: Slot;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Props for KaminoAction.buildDepositAndWithdrawV2Txns
|
|
186
|
+
*/
|
|
187
|
+
export interface BuildDepositAndWithdrawV2TxnsProps {
|
|
188
|
+
kaminoMarket: KaminoMarket;
|
|
189
|
+
depositAmount: string | BN;
|
|
190
|
+
depositReserveAddress: Address;
|
|
191
|
+
withdrawAmount: string | BN;
|
|
192
|
+
withdrawReserveAddress: Address;
|
|
193
|
+
owner: TransactionSigner;
|
|
194
|
+
currentSlot: Slot;
|
|
195
|
+
obligation: KaminoObligation | ObligationType;
|
|
196
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
197
|
+
extraComputeBudget?: number;
|
|
198
|
+
includeAtaIxs?: boolean;
|
|
199
|
+
requestElevationGroup?: boolean;
|
|
200
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
201
|
+
referrer?: Option<Address>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Props for KaminoAction.buildRepayAndWithdrawTxns
|
|
206
|
+
*/
|
|
207
|
+
export interface BuildRepayAndWithdrawTxnsProps {
|
|
208
|
+
kaminoMarket: KaminoMarket;
|
|
209
|
+
repayAmount: string | BN;
|
|
210
|
+
repayReserveAddress: Address;
|
|
211
|
+
withdrawAmount: string | BN;
|
|
212
|
+
withdrawReserveAddress: Address;
|
|
213
|
+
payer: TransactionSigner;
|
|
214
|
+
currentSlot: Slot;
|
|
215
|
+
obligation: KaminoObligation | ObligationType;
|
|
216
|
+
useV2Ixs: boolean;
|
|
217
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
218
|
+
extraComputeBudget?: number;
|
|
219
|
+
includeAtaIxs?: boolean;
|
|
220
|
+
requestElevationGroup?: boolean;
|
|
221
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
222
|
+
referrer?: Option<Address>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Props for KaminoAction.buildRepayAndWithdrawV2Txns
|
|
227
|
+
*/
|
|
228
|
+
export interface BuildRepayAndWithdrawV2TxnsProps {
|
|
229
|
+
kaminoMarket: KaminoMarket;
|
|
230
|
+
repayAmount: string | BN;
|
|
231
|
+
repayReserveAddress: Address;
|
|
232
|
+
withdrawAmount: string | BN;
|
|
233
|
+
withdrawReserveAddress: Address;
|
|
234
|
+
payer: TransactionSigner;
|
|
235
|
+
currentSlot: Slot;
|
|
236
|
+
obligation: KaminoObligation | ObligationType;
|
|
237
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
238
|
+
extraComputeBudget?: number;
|
|
239
|
+
includeAtaIxs?: boolean;
|
|
240
|
+
requestElevationGroup?: boolean;
|
|
241
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
242
|
+
referrer?: Option<Address>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Props for KaminoAction.buildLiquidateTxns
|
|
247
|
+
*/
|
|
248
|
+
export interface BuildLiquidateTxnsProps {
|
|
249
|
+
kaminoMarket: KaminoMarket;
|
|
250
|
+
amount: string | BN;
|
|
251
|
+
minCollateralReceiveAmount: string | BN;
|
|
252
|
+
repayReserveAddress: Address;
|
|
253
|
+
withdrawReserveAddress: Address;
|
|
254
|
+
liquidator: TransactionSigner;
|
|
255
|
+
obligationOwner: Address;
|
|
256
|
+
obligation: KaminoObligation | ObligationType;
|
|
257
|
+
useV2Ixs: boolean;
|
|
258
|
+
scopeRefreshConfig?: ScopePriceRefreshConfig;
|
|
259
|
+
extraComputeBudget?: number;
|
|
260
|
+
includeAtaIxs?: boolean;
|
|
261
|
+
requestElevationGroup?: boolean;
|
|
262
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
263
|
+
referrer?: Option<Address>;
|
|
264
|
+
maxAllowedLtvOverridePercent?: number;
|
|
265
|
+
currentSlot?: Slot;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Props for KaminoAction.buildWithdrawReferrerFeeTxns
|
|
270
|
+
*/
|
|
271
|
+
export interface BuildWithdrawReferrerFeeTxnsProps {
|
|
272
|
+
owner: TransactionSigner;
|
|
273
|
+
reserveAddress: Address;
|
|
274
|
+
kaminoMarket: KaminoMarket;
|
|
275
|
+
currentSlot?: Slot;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Props for KaminoAction.buildDepositObligationCollateralTxns
|
|
280
|
+
*/
|
|
281
|
+
export interface BuildDepositObligationCollateralTxnsProps {
|
|
282
|
+
kaminoMarket: KaminoMarket;
|
|
283
|
+
amount: string | BN;
|
|
284
|
+
reserveAddress: Address;
|
|
285
|
+
owner: TransactionSigner;
|
|
286
|
+
obligation: KaminoObligation | ObligationType;
|
|
287
|
+
useV2Ixs: boolean;
|
|
288
|
+
scopeRefreshConfig: ScopePriceRefreshConfig | undefined;
|
|
289
|
+
extraComputeBudget?: number;
|
|
290
|
+
includeAtaIxs?: boolean;
|
|
291
|
+
requestElevationGroup?: boolean;
|
|
292
|
+
initUserMetadata?: { skipInitialization: boolean; skipLutCreation: boolean };
|
|
293
|
+
referrer?: Option<Address>;
|
|
294
|
+
currentSlot?: Slot;
|
|
295
|
+
}
|
package/src/classes/manager.ts
CHANGED
|
@@ -1796,11 +1796,6 @@ export const MARKET_UPDATER = new ConfigUpdater(UpdateLendingMarketMode.fromDeco
|
|
|
1796
1796
|
[UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled.kind]: config.obligationOrderExecutionEnabled,
|
|
1797
1797
|
[UpdateLendingMarketMode.UpdateProposerAuthority.kind]: config.proposerAuthority,
|
|
1798
1798
|
[UpdateLendingMarketMode.UpdatePriceTriggeredLiquidationDisabled.kind]: config.priceTriggeredLiquidationDisabled,
|
|
1799
|
-
[UpdateLendingMarketMode.UpdateMatureReserveDebtLiquidationEnabled.kind]: config.matureReserveDebtLiquidationEnabled,
|
|
1800
|
-
[UpdateLendingMarketMode.UpdateObligationBorrowDebtTermLiquidationEnabled.kind]:
|
|
1801
|
-
config.obligationBorrowDebtTermLiquidationEnabled,
|
|
1802
|
-
[UpdateLendingMarketMode.UpdateBorrowOrderCreationEnabled.kind]: config.borrowOrderCreationEnabled,
|
|
1803
|
-
[UpdateLendingMarketMode.UpdateBorrowOrderExecutionEnabled.kind]: config.borrowOrderExecutionEnabled,
|
|
1804
1799
|
}));
|
|
1805
1800
|
|
|
1806
1801
|
function parseForChangesMarketConfigAndGetIxs(
|
package/src/classes/market.ts
CHANGED
|
@@ -34,8 +34,11 @@ import {
|
|
|
34
34
|
isNotNullPubkey,
|
|
35
35
|
lendingMarketAuthPda,
|
|
36
36
|
LendingObligation,
|
|
37
|
+
LendingObligationFixedRate,
|
|
37
38
|
LeverageObligation,
|
|
39
|
+
LeverageObligationFixedRate,
|
|
38
40
|
MultiplyObligation,
|
|
41
|
+
MultiplyObligationFixedRate,
|
|
39
42
|
ObligationType,
|
|
40
43
|
PythPrices,
|
|
41
44
|
referrerTokenStatePda,
|
|
@@ -121,22 +124,6 @@ export class KaminoMarket {
|
|
|
121
124
|
);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
/**
|
|
125
|
-
* TESTING ONLY!
|
|
126
|
-
*
|
|
127
|
-
* Used to create mock markets for testing
|
|
128
|
-
*/
|
|
129
|
-
static createMarket(
|
|
130
|
-
rpc: Rpc<KaminoMarketRpcApi>,
|
|
131
|
-
state: LendingMarket,
|
|
132
|
-
marketAddress: Address,
|
|
133
|
-
reserves: Map<Address, KaminoReserve>,
|
|
134
|
-
recentSlotDurationMs: number,
|
|
135
|
-
programId: Address = PROGRAM_ID
|
|
136
|
-
) {
|
|
137
|
-
return new KaminoMarket(rpc, state, marketAddress, reserves, recentSlotDurationMs, programId);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
127
|
/**
|
|
141
128
|
* Load a new market with all of its associated reserves
|
|
142
129
|
* @param rpc
|
|
@@ -307,14 +294,22 @@ export class KaminoMarket {
|
|
|
307
294
|
return parseZeroPaddedUtf8(this.state.name);
|
|
308
295
|
}
|
|
309
296
|
|
|
310
|
-
async getObligationDepositByWallet(
|
|
297
|
+
async getObligationDepositByWallet(
|
|
298
|
+
owner: Address,
|
|
299
|
+
depositReserveAddress: Address,
|
|
300
|
+
obligationType: ObligationType
|
|
301
|
+
): Promise<Decimal> {
|
|
311
302
|
const obligation = await this.getObligationByWallet(owner, obligationType);
|
|
312
|
-
return obligation?.
|
|
303
|
+
return obligation?.getDepositByReserve(depositReserveAddress)?.amount ?? new Decimal(0);
|
|
313
304
|
}
|
|
314
305
|
|
|
315
|
-
async getObligationBorrowByWallet(
|
|
306
|
+
async getObligationBorrowByWallet(
|
|
307
|
+
owner: Address,
|
|
308
|
+
borrowReserveAddress: Address,
|
|
309
|
+
obligationType: ObligationType
|
|
310
|
+
): Promise<Decimal> {
|
|
316
311
|
const obligation = await this.getObligationByWallet(owner, obligationType);
|
|
317
|
-
return obligation?.
|
|
312
|
+
return obligation?.getBorrowByReserve(borrowReserveAddress)?.amount ?? new Decimal(0);
|
|
318
313
|
}
|
|
319
314
|
|
|
320
315
|
getTotalDepositTVL(): Decimal {
|
|
@@ -333,10 +328,10 @@ export class KaminoMarket {
|
|
|
333
328
|
return tvl;
|
|
334
329
|
}
|
|
335
330
|
|
|
336
|
-
getMaxLeverageForPair(
|
|
331
|
+
getMaxLeverageForPair(collReserveAddress: Address, debtReserveAddress: Address): number {
|
|
337
332
|
const { maxLtv: maxCollateralLtv, borrowFactor } = this.getMaxAndLiquidationLtvAndBorrowFactorForPair(
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
collReserveAddress,
|
|
334
|
+
debtReserveAddress
|
|
340
335
|
);
|
|
341
336
|
|
|
342
337
|
const maxLeverage =
|
|
@@ -361,12 +356,11 @@ export class KaminoMarket {
|
|
|
361
356
|
}
|
|
362
357
|
|
|
363
358
|
getMaxAndLiquidationLtvAndBorrowFactorForPair(
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
collReserveAddress: Address,
|
|
360
|
+
debtReserveAddress: Address
|
|
366
361
|
): { maxLtv: number; liquidationLtv: number; borrowFactor: number } {
|
|
367
|
-
const collReserve: KaminoReserve | undefined = this.
|
|
368
|
-
const debtReserve: KaminoReserve | undefined = this.
|
|
369
|
-
|
|
362
|
+
const collReserve: KaminoReserve | undefined = this.getReserveByAddress(collReserveAddress);
|
|
363
|
+
const debtReserve: KaminoReserve | undefined = this.getReserveByAddress(debtReserveAddress);
|
|
370
364
|
if (!collReserve || !debtReserve) {
|
|
371
365
|
throw Error('Could not find one of the reserves.');
|
|
372
366
|
}
|
|
@@ -421,6 +415,22 @@ export class KaminoMarket {
|
|
|
421
415
|
);
|
|
422
416
|
break;
|
|
423
417
|
}
|
|
418
|
+
case LendingObligationFixedRate.tag: {
|
|
419
|
+
const reserveAddress = productType.toArgs().seed1;
|
|
420
|
+
obligations = obligations.filter((obligation) => obligation.getDepositByReserve(reserveAddress) !== undefined);
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
case LeverageObligationFixedRate.tag:
|
|
424
|
+
case MultiplyObligationFixedRate.tag: {
|
|
425
|
+
const collReserveAddress = productType.toArgs().seed1;
|
|
426
|
+
const debtReserveAddress = productType.toArgs().seed2;
|
|
427
|
+
obligations = obligations.filter((obligation) => {
|
|
428
|
+
const collDeposit = obligation.getDepositByReserve(collReserveAddress);
|
|
429
|
+
const debtBorrow = obligation.getBorrowByReserve(debtReserveAddress);
|
|
430
|
+
return collDeposit !== undefined && debtBorrow !== undefined;
|
|
431
|
+
});
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
424
434
|
default:
|
|
425
435
|
throw new Error('Invalid obligation type');
|
|
426
436
|
}
|
|
@@ -473,7 +483,7 @@ export class KaminoMarket {
|
|
|
473
483
|
obligation?: KaminoObligation
|
|
474
484
|
): Decimal {
|
|
475
485
|
return obligation
|
|
476
|
-
? obligation.getMaxBorrowAmount(this, debtReserve.
|
|
486
|
+
? obligation.getMaxBorrowAmount(this, debtReserve.address, slot, requestElevationGroup)
|
|
477
487
|
: debtReserve.getMaxBorrowAmountWithCollReserve(this, collReserve, slot);
|
|
478
488
|
}
|
|
479
489
|
|
|
@@ -584,7 +594,7 @@ export class KaminoMarket {
|
|
|
584
594
|
}
|
|
585
595
|
|
|
586
596
|
async getReserveFarmInfo(
|
|
587
|
-
|
|
597
|
+
reserveAddress: Address,
|
|
588
598
|
getRewardPrice: (mint: Address) => Promise<number>
|
|
589
599
|
): Promise<{ borrowingRewards: ReserveRewardInfo; depositingRewards: ReserveRewardInfo }> {
|
|
590
600
|
const { address } = this;
|
|
@@ -596,10 +606,10 @@ export class KaminoMarket {
|
|
|
596
606
|
}
|
|
597
607
|
|
|
598
608
|
// Find the reserve
|
|
599
|
-
const kaminoReserve = this.
|
|
609
|
+
const kaminoReserve = this.getReserveByAddress(reserveAddress);
|
|
600
610
|
|
|
601
611
|
if (!kaminoReserve) {
|
|
602
|
-
throw Error(`Could not find reserve
|
|
612
|
+
throw Error(`Could not find reserve ${reserveAddress}`);
|
|
603
613
|
}
|
|
604
614
|
|
|
605
615
|
const totalDepositAmount = lamportsToNumberDecimal(
|