@0dotxyz/p0-ts-sdk 2.2.0 → 2.2.2

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.
@@ -0,0 +1,371 @@
1
+ import * as _solana_web3_js from '@solana/web3.js';
2
+ import { PublicKey, AccountMeta } from '@solana/web3.js';
3
+ import BN from 'bn.js';
4
+ import { M as MarginfiProgram, _ as BankConfigCompactRaw, k as BankConfigOptRaw } from './types-DGWxbPM1.js';
5
+ import '@coral-xyz/anchor';
6
+ import 'bignumber.js';
7
+ import './dto-rate-model.types-AQ40wS-P.js';
8
+
9
+ declare function makeInitMarginfiAccountIx(mfProgram: MarginfiProgram, accounts: {
10
+ marginfiGroup: PublicKey;
11
+ marginfiAccount: PublicKey;
12
+ authority: PublicKey;
13
+ feePayer: PublicKey;
14
+ }): Promise<_solana_web3_js.TransactionInstruction>;
15
+ declare function makeInitMarginfiAccountPdaIx(mfProgram: MarginfiProgram, accounts: {
16
+ marginfiGroup: PublicKey;
17
+ marginfiAccount: PublicKey;
18
+ authority: PublicKey;
19
+ feePayer: PublicKey;
20
+ }, args: {
21
+ accountIndex: number;
22
+ thirdPartyId?: number;
23
+ }): Promise<_solana_web3_js.TransactionInstruction>;
24
+ declare function makeJuplendDepositIx(mfProgram: MarginfiProgram, accounts: {
25
+ marginfiAccount: PublicKey;
26
+ bank: PublicKey;
27
+ signerTokenAccount: PublicKey;
28
+ lendingAdmin: PublicKey;
29
+ supplyTokenReservesLiquidity: PublicKey;
30
+ lendingSupplyPositionOnLiquidity: PublicKey;
31
+ rateModel: PublicKey;
32
+ vault: PublicKey;
33
+ liquidity: PublicKey;
34
+ liquidityProgram: PublicKey;
35
+ rewardsRateModel: PublicKey;
36
+ tokenProgram: PublicKey;
37
+ group?: PublicKey;
38
+ authority?: PublicKey;
39
+ liquidityVault?: PublicKey;
40
+ fTokenMint?: PublicKey;
41
+ integrationAcc1?: PublicKey;
42
+ integrationAcc2?: PublicKey;
43
+ mint?: PublicKey;
44
+ }, args: {
45
+ amount: BN;
46
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
47
+ declare function makeJuplendWithdrawIx(mfProgram: MarginfiProgram, accounts: {
48
+ marginfiAccount: PublicKey;
49
+ bank: PublicKey;
50
+ destinationTokenAccount: PublicKey;
51
+ lendingAdmin: PublicKey;
52
+ supplyTokenReservesLiquidity: PublicKey;
53
+ lendingSupplyPositionOnLiquidity: PublicKey;
54
+ rateModel: PublicKey;
55
+ vault: PublicKey;
56
+ claimAccount: PublicKey;
57
+ liquidity: PublicKey;
58
+ liquidityProgram: PublicKey;
59
+ rewardsRateModel: PublicKey;
60
+ tokenProgram: PublicKey;
61
+ group?: PublicKey;
62
+ authority?: PublicKey;
63
+ mint?: PublicKey;
64
+ integrationAcc1?: PublicKey;
65
+ fTokenMint?: PublicKey;
66
+ integrationAcc2?: PublicKey;
67
+ integrationAcc3?: PublicKey;
68
+ }, args: {
69
+ amount: BN;
70
+ withdrawAll?: boolean | null;
71
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
72
+ declare function makeKaminoDepositIx(mfProgram: MarginfiProgram, accounts: {
73
+ marginfiAccount: PublicKey;
74
+ bank: PublicKey;
75
+ signerTokenAccount: PublicKey;
76
+ lendingMarket: PublicKey;
77
+ lendingMarketAuthority: PublicKey;
78
+ reserveLiquiditySupply: PublicKey;
79
+ reserveCollateralMint: PublicKey;
80
+ reserveDestinationDepositCollateral: PublicKey;
81
+ liquidityTokenProgram: PublicKey;
82
+ obligationFarmUserState: PublicKey | null;
83
+ reserveFarmState: PublicKey | null;
84
+ group?: PublicKey;
85
+ authority?: PublicKey;
86
+ liquidityVault?: PublicKey;
87
+ integrationAcc1?: PublicKey;
88
+ integrationAcc2?: PublicKey;
89
+ mint?: PublicKey;
90
+ }, args: {
91
+ amount: BN;
92
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
93
+ /**
94
+ * Create a Drift deposit instruction
95
+ * Deposits tokens into a Drift spot market through a marginfi bank account
96
+ *
97
+ * @param mfProgram - The marginfi program instance
98
+ * @param accounts - Required and optional accounts for the instruction
99
+ * @param accounts.marginfiAccount - The marginfi account depositing funds
100
+ * @param accounts.bank - The marginfi bank account for the asset
101
+ * @param accounts.signerTokenAccount - The signer's token account (source of funds)
102
+ * @param accounts.driftState - The Drift program state account
103
+ * @param accounts.driftSpotMarketVault - The Drift spot market vault receiving tokens
104
+ * @param accounts.tokenProgram - The SPL token program
105
+ * @param accounts.driftOracle - (Optional) Oracle account for the asset
106
+ * @param args - Instruction arguments
107
+ * @param args.amount - Amount to deposit in native token decimals
108
+ */
109
+ declare function makeDriftDepositIx(mfProgram: MarginfiProgram, accounts: {
110
+ marginfiAccount: PublicKey;
111
+ bank: PublicKey;
112
+ signerTokenAccount: PublicKey;
113
+ driftState: PublicKey;
114
+ driftSpotMarketVault: PublicKey;
115
+ tokenProgram: PublicKey;
116
+ driftOracle: PublicKey | null;
117
+ group?: PublicKey;
118
+ authority?: PublicKey;
119
+ liquidityVault?: PublicKey;
120
+ integrationAcc2?: PublicKey;
121
+ integrationAcc3?: PublicKey;
122
+ integrationAcc1?: PublicKey;
123
+ mint?: PublicKey;
124
+ driftProgram?: PublicKey;
125
+ systemProgram?: PublicKey;
126
+ }, args: {
127
+ amount: BN;
128
+ }): Promise<_solana_web3_js.TransactionInstruction>;
129
+ declare function makeDepositIx(mfProgram: MarginfiProgram, accounts: {
130
+ marginfiAccount: PublicKey;
131
+ signerTokenAccount: PublicKey;
132
+ bank: PublicKey;
133
+ tokenProgram: PublicKey;
134
+ group?: PublicKey;
135
+ authority?: PublicKey;
136
+ liquidityVault?: PublicKey;
137
+ }, args: {
138
+ amount: BN;
139
+ depositUpToLimit?: boolean;
140
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
141
+ declare function makeRepayIx(mfProgram: MarginfiProgram, accounts: {
142
+ marginfiAccount: PublicKey;
143
+ signerTokenAccount: PublicKey;
144
+ bank: PublicKey;
145
+ tokenProgram: PublicKey;
146
+ group?: PublicKey;
147
+ authority?: PublicKey;
148
+ liquidityVault?: PublicKey;
149
+ }, args: {
150
+ amount: BN;
151
+ repayAll?: boolean;
152
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
153
+ declare function makeDriftWithdrawIx(mfProgram: MarginfiProgram, accounts: {
154
+ marginfiAccount: PublicKey;
155
+ bank: PublicKey;
156
+ destinationTokenAccount: PublicKey;
157
+ driftState: PublicKey;
158
+ driftSigner: PublicKey;
159
+ driftSpotMarketVault: PublicKey;
160
+ tokenProgram: PublicKey;
161
+ driftOracle: PublicKey | null;
162
+ driftRewardOracle: PublicKey | null;
163
+ driftRewardSpotMarket: PublicKey | null;
164
+ driftRewardMint: PublicKey | null;
165
+ driftRewardOracle2: PublicKey | null;
166
+ driftRewardSpotMarket2: PublicKey | null;
167
+ driftRewardMint2: PublicKey | null;
168
+ group?: PublicKey;
169
+ authority?: PublicKey;
170
+ }, args: {
171
+ amount: BN;
172
+ withdrawAll: boolean;
173
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
174
+ declare function makeKaminoWithdrawIx(mfProgram: MarginfiProgram, accounts: {
175
+ marginfiAccount: PublicKey;
176
+ bank: PublicKey;
177
+ destinationTokenAccount: PublicKey;
178
+ lendingMarket: PublicKey;
179
+ mint: PublicKey;
180
+ lendingMarketAuthority: PublicKey;
181
+ reserveLiquiditySupply: PublicKey;
182
+ reserveCollateralMint: PublicKey;
183
+ reserveSourceCollateral: PublicKey;
184
+ liquidityTokenProgram: PublicKey;
185
+ obligationFarmUserState: PublicKey | null;
186
+ reserveFarmState: PublicKey | null;
187
+ group?: PublicKey;
188
+ authority?: PublicKey;
189
+ }, args: {
190
+ amount: BN;
191
+ isFinalWithdrawal: boolean;
192
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
193
+ declare function makeWithdrawIx(mfProgram: MarginfiProgram, accounts: {
194
+ marginfiAccount: PublicKey;
195
+ bank: PublicKey;
196
+ destinationTokenAccount: PublicKey;
197
+ tokenProgram: PublicKey;
198
+ group?: PublicKey;
199
+ authority?: PublicKey;
200
+ }, args: {
201
+ amount: BN;
202
+ withdrawAll?: boolean;
203
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
204
+ declare function makeBorrowIx(mfProgram: MarginfiProgram, accounts: {
205
+ marginfiAccount: PublicKey;
206
+ bank: PublicKey;
207
+ destinationTokenAccount: PublicKey;
208
+ tokenProgram: PublicKey;
209
+ group?: PublicKey;
210
+ authority?: PublicKey;
211
+ }, args: {
212
+ amount: BN;
213
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
214
+ declare function makeLendingAccountLiquidateIx(mfiProgram: MarginfiProgram, accounts: {
215
+ assetBank: PublicKey;
216
+ liabBank: PublicKey;
217
+ liquidatorMarginfiAccount: PublicKey;
218
+ liquidateeMarginfiAccount: PublicKey;
219
+ tokenProgram: PublicKey;
220
+ group?: PublicKey;
221
+ authority?: PublicKey;
222
+ }, args: {
223
+ assetAmount: BN;
224
+ liquidateeAccounts: number;
225
+ liquidatorAccounts: number;
226
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
227
+ declare function makeLendingAccountClearEmissionsIx(mfiProgram: MarginfiProgram, accounts: {
228
+ marginfiAccount: PublicKey;
229
+ bank: PublicKey;
230
+ }): Promise<_solana_web3_js.TransactionInstruction>;
231
+ declare function makePoolConfigureBankIx(mfiProgram: MarginfiProgram, accounts: {
232
+ bank: PublicKey;
233
+ group?: PublicKey;
234
+ admin?: PublicKey;
235
+ }, args: {
236
+ bankConfigOpt: BankConfigOptRaw;
237
+ }): Promise<_solana_web3_js.TransactionInstruction>;
238
+ declare function makeBeginFlashLoanIx(mfiProgram: MarginfiProgram, accounts: {
239
+ marginfiAccount: PublicKey;
240
+ authority?: PublicKey;
241
+ ixsSysvar?: PublicKey;
242
+ }, args: {
243
+ endIndex: BN;
244
+ }): Promise<_solana_web3_js.TransactionInstruction>;
245
+ declare function makeEndFlashLoanIx(mfiProgram: MarginfiProgram, accounts: {
246
+ marginfiAccount: PublicKey;
247
+ authority?: PublicKey;
248
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
249
+ declare function makeAccountTransferToNewAccountIx(mfProgram: MarginfiProgram, accounts: {
250
+ oldMarginfiAccount: PublicKey;
251
+ newMarginfiAccount: PublicKey;
252
+ newAuthority: PublicKey;
253
+ feePayer: PublicKey;
254
+ group?: PublicKey;
255
+ authority?: PublicKey;
256
+ }): Promise<_solana_web3_js.TransactionInstruction>;
257
+ declare function makeGroupInitIx(mfProgram: MarginfiProgram, accounts: {
258
+ marginfiGroup: PublicKey;
259
+ admin: PublicKey;
260
+ }): Promise<_solana_web3_js.TransactionInstruction>;
261
+ /**
262
+ * Configure the oracle for a bank
263
+ * @param mfProgram The marginfi program
264
+ * @param accounts The accounts required for this instruction
265
+ * @param args The oracle setup index and feed id
266
+ * @param remainingAccounts The remaining accounts required for this instruction, should include the feed oracle key
267
+ */
268
+ declare function makeLendingPoolConfigureBankOracleIx(mfProgram: MarginfiProgram, accounts: {
269
+ bank: PublicKey;
270
+ group?: PublicKey;
271
+ admin?: PublicKey;
272
+ }, args: {
273
+ /**
274
+ * The oracle setup index, see {@link serializeOracleSetupToIndex}
275
+ */
276
+ setup: number;
277
+ /**
278
+ * The oracle feed id
279
+ */
280
+ feedId: PublicKey;
281
+ },
282
+ /**
283
+ * The remaining accounts required for this instruction, should include the feed oracle key (non writable & signable)
284
+ */
285
+ remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
286
+ /**
287
+ * Creates an instruction to add a permissionless staked bank to a lending pool.
288
+ * @param mfProgram - The marginfi program instance
289
+ * @param accounts - The accounts required for this instruction
290
+ * @param remainingAccounts - The remaining accounts required for this instruction, including pythOracle, solPool and bankMint
291
+ * @param args - Optional arguments for this instruction
292
+ */
293
+ declare function makePoolAddPermissionlessStakedBankIx(mfProgram: MarginfiProgram, accounts: {
294
+ stakedSettings: PublicKey;
295
+ feePayer: PublicKey;
296
+ bankMint: PublicKey;
297
+ solPool: PublicKey;
298
+ stakePool: PublicKey;
299
+ marginfiGroup?: PublicKey;
300
+ /**
301
+ * The token program to use for this instruction, defaults to the SPL token program
302
+ */
303
+ tokenProgram?: PublicKey;
304
+ },
305
+ /**
306
+ * The remaining accounts required for this instruction. Should include:
307
+ * - pythOracle: The pyth oracle key (non writable & non signer)
308
+ * - solPool: The sol pool key (non writable & non signer)
309
+ * - bankMint: The bank mint key (non writable & non signer)
310
+ */
311
+ remainingAccounts: AccountMeta[] | undefined, args: {
312
+ /**
313
+ * The seed to use for the bank account. Defaults to 0 (new BN(0)).
314
+ * If the seed is not specified, the seed is set to 0, and the bank account
315
+ * will be created at the address {@link findPoolAddress} with the default
316
+ * bump.
317
+ */
318
+ seed?: BN;
319
+ }): Promise<_solana_web3_js.TransactionInstruction>;
320
+ declare function makePoolAddBankIx(mfProgram: MarginfiProgram, accounts: {
321
+ marginfiGroup: PublicKey;
322
+ feePayer: PublicKey;
323
+ bankMint: PublicKey;
324
+ bank: PublicKey;
325
+ tokenProgram: PublicKey;
326
+ admin?: PublicKey;
327
+ globalFeeWallet?: PublicKey;
328
+ }, args: {
329
+ bankConfig: BankConfigCompactRaw;
330
+ }): Promise<_solana_web3_js.TransactionInstruction>;
331
+ declare function makeCloseAccountIx(mfProgram: MarginfiProgram, accounts: {
332
+ marginfiAccount: PublicKey;
333
+ feePayer: PublicKey;
334
+ authority?: PublicKey;
335
+ }): Promise<_solana_web3_js.TransactionInstruction>;
336
+ declare function makePulseHealthIx(mfProgram: MarginfiProgram, accounts: {
337
+ marginfiAccount: PublicKey;
338
+ },
339
+ /**
340
+ * The remaining accounts required for this instruction. Should include:
341
+ * - For each balance the user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>
342
+ */
343
+ remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
344
+ declare const instructions: {
345
+ makeDepositIx: typeof makeDepositIx;
346
+ makeJuplendDepositIx: typeof makeJuplendDepositIx;
347
+ makeDriftDepositIx: typeof makeDriftDepositIx;
348
+ makeKaminoDepositIx: typeof makeKaminoDepositIx;
349
+ makeRepayIx: typeof makeRepayIx;
350
+ makeWithdrawIx: typeof makeWithdrawIx;
351
+ makeJuplendWithdrawIx: typeof makeJuplendWithdrawIx;
352
+ makeDriftWithdrawIx: typeof makeDriftWithdrawIx;
353
+ makeKaminoWithdrawIx: typeof makeKaminoWithdrawIx;
354
+ makeBorrowIx: typeof makeBorrowIx;
355
+ makeInitMarginfiAccountIx: typeof makeInitMarginfiAccountIx;
356
+ makeInitMarginfiAccountPdaIx: typeof makeInitMarginfiAccountPdaIx;
357
+ makeLendingAccountLiquidateIx: typeof makeLendingAccountLiquidateIx;
358
+ makeLendingAccountClearEmissionsIx: typeof makeLendingAccountClearEmissionsIx;
359
+ makePoolAddBankIx: typeof makePoolAddBankIx;
360
+ makePoolConfigureBankIx: typeof makePoolConfigureBankIx;
361
+ makeBeginFlashLoanIx: typeof makeBeginFlashLoanIx;
362
+ makeEndFlashLoanIx: typeof makeEndFlashLoanIx;
363
+ makeAccountTransferToNewAccountIx: typeof makeAccountTransferToNewAccountIx;
364
+ makeGroupInitIx: typeof makeGroupInitIx;
365
+ makeCloseAccountIx: typeof makeCloseAccountIx;
366
+ makePoolAddPermissionlessStakedBankIx: typeof makePoolAddPermissionlessStakedBankIx;
367
+ makeLendingPoolConfigureBankOracleIx: typeof makeLendingPoolConfigureBankOracleIx;
368
+ makePulseHealthIx: typeof makePulseHealthIx;
369
+ };
370
+
371
+ export { instructions as default };
@@ -0,0 +1,338 @@
1
+ import BN from 'bn.js';
2
+ import { PublicKey } from '@solana/web3.js';
3
+
4
+ // src/instructions.ts
5
+ new PublicKey(
6
+ "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
7
+ );
8
+ new PublicKey(
9
+ "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
10
+ );
11
+ var TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
12
+ new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
13
+
14
+ // src/instructions.ts
15
+ async function makeInitMarginfiAccountIx(mfProgram, accounts) {
16
+ return mfProgram.methods.marginfiAccountInitialize().accounts(accounts).instruction();
17
+ }
18
+ async function makeInitMarginfiAccountPdaIx(mfProgram, accounts, args) {
19
+ return mfProgram.methods.marginfiAccountInitializePda(args.accountIndex, args.thirdPartyId ?? null).accountsPartial({
20
+ marginfiGroup: accounts.marginfiGroup,
21
+ marginfiAccount: accounts.marginfiAccount,
22
+ authority: accounts.authority,
23
+ feePayer: accounts.feePayer
24
+ }).instruction();
25
+ }
26
+ async function makeJuplendDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
27
+ const {
28
+ marginfiAccount,
29
+ bank,
30
+ signerTokenAccount,
31
+ lendingAdmin,
32
+ supplyTokenReservesLiquidity,
33
+ lendingSupplyPositionOnLiquidity,
34
+ rateModel,
35
+ vault,
36
+ liquidity,
37
+ liquidityProgram,
38
+ rewardsRateModel,
39
+ tokenProgram,
40
+ ...optionalAccounts
41
+ } = accounts;
42
+ return mfProgram.methods.juplendDeposit(args.amount).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
43
+ }
44
+ async function makeJuplendWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
45
+ const {
46
+ marginfiAccount,
47
+ bank,
48
+ destinationTokenAccount,
49
+ lendingAdmin,
50
+ supplyTokenReservesLiquidity,
51
+ lendingSupplyPositionOnLiquidity,
52
+ rateModel,
53
+ vault,
54
+ claimAccount,
55
+ liquidity,
56
+ liquidityProgram,
57
+ rewardsRateModel,
58
+ tokenProgram,
59
+ ...optionalAccounts
60
+ } = accounts;
61
+ return mfProgram.methods.juplendWithdraw(args.amount, args.withdrawAll ?? null).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
62
+ }
63
+ async function makeKaminoDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
64
+ const {
65
+ marginfiAccount,
66
+ bank,
67
+ signerTokenAccount,
68
+ lendingMarket,
69
+ lendingMarketAuthority,
70
+ reserveLiquiditySupply,
71
+ reserveCollateralMint,
72
+ reserveDestinationDepositCollateral,
73
+ liquidityTokenProgram,
74
+ obligationFarmUserState,
75
+ reserveFarmState,
76
+ ...optionalAccounts
77
+ } = accounts;
78
+ return mfProgram.methods.kaminoDeposit(args.amount).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
79
+ }
80
+ async function makeDriftDepositIx(mfProgram, accounts, args) {
81
+ const {
82
+ marginfiAccount,
83
+ bank,
84
+ signerTokenAccount,
85
+ driftState,
86
+ driftSpotMarketVault,
87
+ tokenProgram,
88
+ driftOracle,
89
+ ...optionalAccounts
90
+ } = accounts;
91
+ return mfProgram.methods.driftDeposit(args.amount).accounts({
92
+ marginfiAccount,
93
+ bank,
94
+ signerTokenAccount,
95
+ driftState,
96
+ driftSpotMarketVault,
97
+ tokenProgram,
98
+ driftOracle
99
+ }).accountsPartial(optionalAccounts).instruction();
100
+ }
101
+ async function makeDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
102
+ const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;
103
+ return mfProgram.methods.lendingAccountDeposit(args.amount, args.depositUpToLimit ?? null).accounts({
104
+ marginfiAccount,
105
+ signerTokenAccount,
106
+ bank,
107
+ tokenProgram
108
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
109
+ }
110
+ async function makeRepayIx(mfProgram, accounts, args, remainingAccounts = []) {
111
+ const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;
112
+ return mfProgram.methods.lendingAccountRepay(args.amount, args.repayAll ?? null).accounts({
113
+ marginfiAccount,
114
+ signerTokenAccount,
115
+ bank,
116
+ tokenProgram
117
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
118
+ }
119
+ async function makeDriftWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
120
+ const {
121
+ marginfiAccount,
122
+ bank,
123
+ destinationTokenAccount,
124
+ driftState,
125
+ driftSigner,
126
+ driftSpotMarketVault,
127
+ tokenProgram,
128
+ driftOracle,
129
+ driftRewardOracle,
130
+ driftRewardSpotMarket,
131
+ driftRewardMint,
132
+ driftRewardOracle2,
133
+ driftRewardSpotMarket2,
134
+ driftRewardMint2,
135
+ ...optionalAccounts
136
+ } = accounts;
137
+ return mfProgram.methods.driftWithdraw(args.amount, args.withdrawAll).accounts({
138
+ marginfiAccount,
139
+ bank,
140
+ destinationTokenAccount,
141
+ driftState,
142
+ driftSigner,
143
+ driftSpotMarketVault,
144
+ tokenProgram,
145
+ driftOracle,
146
+ driftRewardOracle,
147
+ driftRewardSpotMarket,
148
+ driftRewardMint,
149
+ driftRewardOracle2,
150
+ driftRewardSpotMarket2,
151
+ driftRewardMint2
152
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
153
+ }
154
+ async function makeKaminoWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
155
+ const {
156
+ marginfiAccount,
157
+ bank,
158
+ destinationTokenAccount,
159
+ lendingMarket,
160
+ lendingMarketAuthority,
161
+ reserveLiquiditySupply,
162
+ reserveCollateralMint,
163
+ reserveSourceCollateral,
164
+ liquidityTokenProgram,
165
+ obligationFarmUserState,
166
+ reserveFarmState,
167
+ ...optionalAccounts
168
+ } = accounts;
169
+ return mfProgram.methods.kaminoWithdraw(args.amount, args.isFinalWithdrawal).accounts({
170
+ marginfiAccount,
171
+ bank,
172
+ destinationTokenAccount,
173
+ lendingMarket,
174
+ lendingMarketAuthority,
175
+ reserveLiquiditySupply,
176
+ reserveCollateralMint,
177
+ reserveSourceCollateral,
178
+ liquidityTokenProgram,
179
+ obligationFarmUserState,
180
+ reserveFarmState
181
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
182
+ }
183
+ async function makeWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
184
+ const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } = accounts;
185
+ return mfProgram.methods.lendingAccountWithdraw(args.amount, args.withdrawAll ?? null).accounts({
186
+ marginfiAccount,
187
+ destinationTokenAccount,
188
+ bank,
189
+ tokenProgram
190
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
191
+ }
192
+ async function makeBorrowIx(mfProgram, accounts, args, remainingAccounts = []) {
193
+ const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } = accounts;
194
+ return mfProgram.methods.lendingAccountBorrow(args.amount).accounts({
195
+ marginfiAccount,
196
+ destinationTokenAccount,
197
+ bank,
198
+ tokenProgram
199
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
200
+ }
201
+ function makeLendingAccountLiquidateIx(mfiProgram, accounts, args, remainingAccounts = []) {
202
+ const {
203
+ assetBank,
204
+ liabBank,
205
+ liquidatorMarginfiAccount,
206
+ liquidateeMarginfiAccount,
207
+ tokenProgram,
208
+ ...optionalAccounts
209
+ } = accounts;
210
+ return mfiProgram.methods.lendingAccountLiquidate(args.assetAmount, args.liquidateeAccounts, args.liquidatorAccounts).accounts({
211
+ assetBank,
212
+ liabBank,
213
+ liquidatorMarginfiAccount,
214
+ liquidateeMarginfiAccount,
215
+ tokenProgram
216
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
217
+ }
218
+ function makeLendingAccountClearEmissionsIx(mfiProgram, accounts) {
219
+ return mfiProgram.methods.lendingAccountClearEmissions().accounts({
220
+ marginfiAccount: accounts.marginfiAccount,
221
+ bank: accounts.bank
222
+ }).instruction();
223
+ }
224
+ function makePoolConfigureBankIx(mfiProgram, accounts, args) {
225
+ const { bank, ...optionalAccounts } = accounts;
226
+ return mfiProgram.methods.lendingPoolConfigureBank(args.bankConfigOpt).accounts({
227
+ bank
228
+ }).accountsPartial(optionalAccounts).instruction();
229
+ }
230
+ function makeBeginFlashLoanIx(mfiProgram, accounts, args) {
231
+ const { marginfiAccount, ...optionalAccounts } = accounts;
232
+ return mfiProgram.methods.lendingAccountStartFlashloan(args.endIndex).accounts({
233
+ marginfiAccount
234
+ }).accountsPartial(optionalAccounts).instruction();
235
+ }
236
+ function makeEndFlashLoanIx(mfiProgram, accounts, remainingAccounts = []) {
237
+ const { marginfiAccount, ...optionalAccounts } = accounts;
238
+ return mfiProgram.methods.lendingAccountEndFlashloan().accounts({
239
+ marginfiAccount
240
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
241
+ }
242
+ async function makeAccountTransferToNewAccountIx(mfProgram, accounts) {
243
+ const { oldMarginfiAccount, newMarginfiAccount, newAuthority, feePayer, ...optionalAccounts } = accounts;
244
+ return mfProgram.methods.transferToNewAccount().accounts({
245
+ oldMarginfiAccount,
246
+ newMarginfiAccount,
247
+ newAuthority,
248
+ globalFeeWallet: feePayer
249
+ }).accountsPartial(optionalAccounts).instruction();
250
+ }
251
+ async function makeGroupInitIx(mfProgram, accounts) {
252
+ return mfProgram.methods.marginfiGroupInitialize().accounts({
253
+ marginfiGroup: accounts.marginfiGroup,
254
+ admin: accounts.admin
255
+ }).instruction();
256
+ }
257
+ async function makeLendingPoolConfigureBankOracleIx(mfProgram, accounts, args, remainingAccounts = []) {
258
+ const { bank, ...optionalAccounts } = accounts;
259
+ return mfProgram.methods.lendingPoolConfigureBankOracle(args.setup, args.feedId).accounts({
260
+ bank
261
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
262
+ }
263
+ async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remainingAccounts = [], args) {
264
+ const {
265
+ stakedSettings,
266
+ feePayer,
267
+ bankMint,
268
+ solPool,
269
+ stakePool,
270
+ tokenProgram = TOKEN_PROGRAM_ID,
271
+ ...optionalAccounts
272
+ } = accounts;
273
+ return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN(0)).accounts({
274
+ stakedSettings,
275
+ feePayer,
276
+ bankMint,
277
+ solPool,
278
+ stakePool,
279
+ tokenProgram
280
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
281
+ }
282
+ async function makePoolAddBankIx(mfProgram, accounts, args) {
283
+ const { marginfiGroup, feePayer, bankMint, bank, tokenProgram, ...optionalAccounts } = accounts;
284
+ return mfProgram.methods.lendingPoolAddBank({
285
+ ...args.bankConfig,
286
+ configFlags: 0,
287
+ pad0: [0, 0, 0, 0, 0, 0, 0, 0]
288
+ }).accounts({
289
+ marginfiGroup,
290
+ feePayer,
291
+ bankMint,
292
+ bank,
293
+ tokenProgram
294
+ }).accountsPartial(optionalAccounts).instruction();
295
+ }
296
+ async function makeCloseAccountIx(mfProgram, accounts) {
297
+ const { marginfiAccount, feePayer, ...optionalAccounts } = accounts;
298
+ return mfProgram.methods.marginfiAccountClose().accounts({
299
+ marginfiAccount,
300
+ feePayer
301
+ }).accountsPartial(optionalAccounts).instruction();
302
+ }
303
+ async function makePulseHealthIx(mfProgram, accounts, remainingAccounts = []) {
304
+ return mfProgram.methods.lendingAccountPulseHealth().accounts({
305
+ marginfiAccount: accounts.marginfiAccount
306
+ }).remainingAccounts(remainingAccounts).instruction();
307
+ }
308
+ var instructions = {
309
+ makeDepositIx,
310
+ makeJuplendDepositIx,
311
+ makeDriftDepositIx,
312
+ makeKaminoDepositIx,
313
+ makeRepayIx,
314
+ makeWithdrawIx,
315
+ makeJuplendWithdrawIx,
316
+ makeDriftWithdrawIx,
317
+ makeKaminoWithdrawIx,
318
+ makeBorrowIx,
319
+ makeInitMarginfiAccountIx,
320
+ makeInitMarginfiAccountPdaIx,
321
+ makeLendingAccountLiquidateIx,
322
+ makeLendingAccountClearEmissionsIx,
323
+ makePoolAddBankIx,
324
+ makePoolConfigureBankIx,
325
+ makeBeginFlashLoanIx,
326
+ makeEndFlashLoanIx,
327
+ makeAccountTransferToNewAccountIx,
328
+ makeGroupInitIx,
329
+ makeCloseAccountIx,
330
+ makePoolAddPermissionlessStakedBankIx,
331
+ makeLendingPoolConfigureBankOracleIx,
332
+ makePulseHealthIx
333
+ };
334
+ var instructions_default = instructions;
335
+
336
+ export { instructions_default as default };
337
+ //# sourceMappingURL=instructions.js.map
338
+ //# sourceMappingURL=instructions.js.map