@0dotxyz/p0-ts-sdk 2.2.1 → 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.
- package/dist/{dto-rate-model.types-gN82ZYyC.d.cts → dto-rate-model.types-AQ40wS-P.d.cts} +2 -46
- package/dist/{dto-rate-model.types-gN82ZYyC.d.ts → dto-rate-model.types-AQ40wS-P.d.ts} +2 -46
- package/dist/index-BDDVBMdM.d.cts +48 -0
- package/dist/index-BDDVBMdM.d.ts +48 -0
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -15390
- package/dist/index.d.ts +8 -15390
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions.cjs +344 -0
- package/dist/instructions.cjs.map +1 -0
- package/dist/instructions.d.cts +371 -0
- package/dist/instructions.d.ts +371 -0
- package/dist/instructions.js +338 -0
- package/dist/instructions.js.map +1 -0
- package/dist/types-DGWxbPM1.d.ts +15392 -0
- package/dist/types-ZvnTjjh4.d.cts +15392 -0
- package/dist/vendor.d.cts +3 -2
- package/dist/vendor.d.ts +3 -2
- package/package.json +6 -1
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var BN = require('bn.js');
|
|
4
|
+
var web3_js = require('@solana/web3.js');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
9
|
+
|
|
10
|
+
// src/instructions.ts
|
|
11
|
+
new web3_js.PublicKey(
|
|
12
|
+
"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
|
|
13
|
+
);
|
|
14
|
+
new web3_js.PublicKey(
|
|
15
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
16
|
+
);
|
|
17
|
+
var TOKEN_PROGRAM_ID = new web3_js.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
18
|
+
new web3_js.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
19
|
+
|
|
20
|
+
// src/instructions.ts
|
|
21
|
+
async function makeInitMarginfiAccountIx(mfProgram, accounts) {
|
|
22
|
+
return mfProgram.methods.marginfiAccountInitialize().accounts(accounts).instruction();
|
|
23
|
+
}
|
|
24
|
+
async function makeInitMarginfiAccountPdaIx(mfProgram, accounts, args) {
|
|
25
|
+
return mfProgram.methods.marginfiAccountInitializePda(args.accountIndex, args.thirdPartyId ?? null).accountsPartial({
|
|
26
|
+
marginfiGroup: accounts.marginfiGroup,
|
|
27
|
+
marginfiAccount: accounts.marginfiAccount,
|
|
28
|
+
authority: accounts.authority,
|
|
29
|
+
feePayer: accounts.feePayer
|
|
30
|
+
}).instruction();
|
|
31
|
+
}
|
|
32
|
+
async function makeJuplendDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
33
|
+
const {
|
|
34
|
+
marginfiAccount,
|
|
35
|
+
bank,
|
|
36
|
+
signerTokenAccount,
|
|
37
|
+
lendingAdmin,
|
|
38
|
+
supplyTokenReservesLiquidity,
|
|
39
|
+
lendingSupplyPositionOnLiquidity,
|
|
40
|
+
rateModel,
|
|
41
|
+
vault,
|
|
42
|
+
liquidity,
|
|
43
|
+
liquidityProgram,
|
|
44
|
+
rewardsRateModel,
|
|
45
|
+
tokenProgram,
|
|
46
|
+
...optionalAccounts
|
|
47
|
+
} = accounts;
|
|
48
|
+
return mfProgram.methods.juplendDeposit(args.amount).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
49
|
+
}
|
|
50
|
+
async function makeJuplendWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
51
|
+
const {
|
|
52
|
+
marginfiAccount,
|
|
53
|
+
bank,
|
|
54
|
+
destinationTokenAccount,
|
|
55
|
+
lendingAdmin,
|
|
56
|
+
supplyTokenReservesLiquidity,
|
|
57
|
+
lendingSupplyPositionOnLiquidity,
|
|
58
|
+
rateModel,
|
|
59
|
+
vault,
|
|
60
|
+
claimAccount,
|
|
61
|
+
liquidity,
|
|
62
|
+
liquidityProgram,
|
|
63
|
+
rewardsRateModel,
|
|
64
|
+
tokenProgram,
|
|
65
|
+
...optionalAccounts
|
|
66
|
+
} = accounts;
|
|
67
|
+
return mfProgram.methods.juplendWithdraw(args.amount, args.withdrawAll ?? null).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
68
|
+
}
|
|
69
|
+
async function makeKaminoDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
70
|
+
const {
|
|
71
|
+
marginfiAccount,
|
|
72
|
+
bank,
|
|
73
|
+
signerTokenAccount,
|
|
74
|
+
lendingMarket,
|
|
75
|
+
lendingMarketAuthority,
|
|
76
|
+
reserveLiquiditySupply,
|
|
77
|
+
reserveCollateralMint,
|
|
78
|
+
reserveDestinationDepositCollateral,
|
|
79
|
+
liquidityTokenProgram,
|
|
80
|
+
obligationFarmUserState,
|
|
81
|
+
reserveFarmState,
|
|
82
|
+
...optionalAccounts
|
|
83
|
+
} = accounts;
|
|
84
|
+
return mfProgram.methods.kaminoDeposit(args.amount).accounts(accounts).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
85
|
+
}
|
|
86
|
+
async function makeDriftDepositIx(mfProgram, accounts, args) {
|
|
87
|
+
const {
|
|
88
|
+
marginfiAccount,
|
|
89
|
+
bank,
|
|
90
|
+
signerTokenAccount,
|
|
91
|
+
driftState,
|
|
92
|
+
driftSpotMarketVault,
|
|
93
|
+
tokenProgram,
|
|
94
|
+
driftOracle,
|
|
95
|
+
...optionalAccounts
|
|
96
|
+
} = accounts;
|
|
97
|
+
return mfProgram.methods.driftDeposit(args.amount).accounts({
|
|
98
|
+
marginfiAccount,
|
|
99
|
+
bank,
|
|
100
|
+
signerTokenAccount,
|
|
101
|
+
driftState,
|
|
102
|
+
driftSpotMarketVault,
|
|
103
|
+
tokenProgram,
|
|
104
|
+
driftOracle
|
|
105
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
106
|
+
}
|
|
107
|
+
async function makeDepositIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
108
|
+
const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;
|
|
109
|
+
return mfProgram.methods.lendingAccountDeposit(args.amount, args.depositUpToLimit ?? null).accounts({
|
|
110
|
+
marginfiAccount,
|
|
111
|
+
signerTokenAccount,
|
|
112
|
+
bank,
|
|
113
|
+
tokenProgram
|
|
114
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
115
|
+
}
|
|
116
|
+
async function makeRepayIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
117
|
+
const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;
|
|
118
|
+
return mfProgram.methods.lendingAccountRepay(args.amount, args.repayAll ?? null).accounts({
|
|
119
|
+
marginfiAccount,
|
|
120
|
+
signerTokenAccount,
|
|
121
|
+
bank,
|
|
122
|
+
tokenProgram
|
|
123
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
124
|
+
}
|
|
125
|
+
async function makeDriftWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
126
|
+
const {
|
|
127
|
+
marginfiAccount,
|
|
128
|
+
bank,
|
|
129
|
+
destinationTokenAccount,
|
|
130
|
+
driftState,
|
|
131
|
+
driftSigner,
|
|
132
|
+
driftSpotMarketVault,
|
|
133
|
+
tokenProgram,
|
|
134
|
+
driftOracle,
|
|
135
|
+
driftRewardOracle,
|
|
136
|
+
driftRewardSpotMarket,
|
|
137
|
+
driftRewardMint,
|
|
138
|
+
driftRewardOracle2,
|
|
139
|
+
driftRewardSpotMarket2,
|
|
140
|
+
driftRewardMint2,
|
|
141
|
+
...optionalAccounts
|
|
142
|
+
} = accounts;
|
|
143
|
+
return mfProgram.methods.driftWithdraw(args.amount, args.withdrawAll).accounts({
|
|
144
|
+
marginfiAccount,
|
|
145
|
+
bank,
|
|
146
|
+
destinationTokenAccount,
|
|
147
|
+
driftState,
|
|
148
|
+
driftSigner,
|
|
149
|
+
driftSpotMarketVault,
|
|
150
|
+
tokenProgram,
|
|
151
|
+
driftOracle,
|
|
152
|
+
driftRewardOracle,
|
|
153
|
+
driftRewardSpotMarket,
|
|
154
|
+
driftRewardMint,
|
|
155
|
+
driftRewardOracle2,
|
|
156
|
+
driftRewardSpotMarket2,
|
|
157
|
+
driftRewardMint2
|
|
158
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
159
|
+
}
|
|
160
|
+
async function makeKaminoWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
161
|
+
const {
|
|
162
|
+
marginfiAccount,
|
|
163
|
+
bank,
|
|
164
|
+
destinationTokenAccount,
|
|
165
|
+
lendingMarket,
|
|
166
|
+
lendingMarketAuthority,
|
|
167
|
+
reserveLiquiditySupply,
|
|
168
|
+
reserveCollateralMint,
|
|
169
|
+
reserveSourceCollateral,
|
|
170
|
+
liquidityTokenProgram,
|
|
171
|
+
obligationFarmUserState,
|
|
172
|
+
reserveFarmState,
|
|
173
|
+
...optionalAccounts
|
|
174
|
+
} = accounts;
|
|
175
|
+
return mfProgram.methods.kaminoWithdraw(args.amount, args.isFinalWithdrawal).accounts({
|
|
176
|
+
marginfiAccount,
|
|
177
|
+
bank,
|
|
178
|
+
destinationTokenAccount,
|
|
179
|
+
lendingMarket,
|
|
180
|
+
lendingMarketAuthority,
|
|
181
|
+
reserveLiquiditySupply,
|
|
182
|
+
reserveCollateralMint,
|
|
183
|
+
reserveSourceCollateral,
|
|
184
|
+
liquidityTokenProgram,
|
|
185
|
+
obligationFarmUserState,
|
|
186
|
+
reserveFarmState
|
|
187
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
188
|
+
}
|
|
189
|
+
async function makeWithdrawIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
190
|
+
const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } = accounts;
|
|
191
|
+
return mfProgram.methods.lendingAccountWithdraw(args.amount, args.withdrawAll ?? null).accounts({
|
|
192
|
+
marginfiAccount,
|
|
193
|
+
destinationTokenAccount,
|
|
194
|
+
bank,
|
|
195
|
+
tokenProgram
|
|
196
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
197
|
+
}
|
|
198
|
+
async function makeBorrowIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
199
|
+
const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } = accounts;
|
|
200
|
+
return mfProgram.methods.lendingAccountBorrow(args.amount).accounts({
|
|
201
|
+
marginfiAccount,
|
|
202
|
+
destinationTokenAccount,
|
|
203
|
+
bank,
|
|
204
|
+
tokenProgram
|
|
205
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
206
|
+
}
|
|
207
|
+
function makeLendingAccountLiquidateIx(mfiProgram, accounts, args, remainingAccounts = []) {
|
|
208
|
+
const {
|
|
209
|
+
assetBank,
|
|
210
|
+
liabBank,
|
|
211
|
+
liquidatorMarginfiAccount,
|
|
212
|
+
liquidateeMarginfiAccount,
|
|
213
|
+
tokenProgram,
|
|
214
|
+
...optionalAccounts
|
|
215
|
+
} = accounts;
|
|
216
|
+
return mfiProgram.methods.lendingAccountLiquidate(args.assetAmount, args.liquidateeAccounts, args.liquidatorAccounts).accounts({
|
|
217
|
+
assetBank,
|
|
218
|
+
liabBank,
|
|
219
|
+
liquidatorMarginfiAccount,
|
|
220
|
+
liquidateeMarginfiAccount,
|
|
221
|
+
tokenProgram
|
|
222
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
223
|
+
}
|
|
224
|
+
function makeLendingAccountClearEmissionsIx(mfiProgram, accounts) {
|
|
225
|
+
return mfiProgram.methods.lendingAccountClearEmissions().accounts({
|
|
226
|
+
marginfiAccount: accounts.marginfiAccount,
|
|
227
|
+
bank: accounts.bank
|
|
228
|
+
}).instruction();
|
|
229
|
+
}
|
|
230
|
+
function makePoolConfigureBankIx(mfiProgram, accounts, args) {
|
|
231
|
+
const { bank, ...optionalAccounts } = accounts;
|
|
232
|
+
return mfiProgram.methods.lendingPoolConfigureBank(args.bankConfigOpt).accounts({
|
|
233
|
+
bank
|
|
234
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
235
|
+
}
|
|
236
|
+
function makeBeginFlashLoanIx(mfiProgram, accounts, args) {
|
|
237
|
+
const { marginfiAccount, ...optionalAccounts } = accounts;
|
|
238
|
+
return mfiProgram.methods.lendingAccountStartFlashloan(args.endIndex).accounts({
|
|
239
|
+
marginfiAccount
|
|
240
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
241
|
+
}
|
|
242
|
+
function makeEndFlashLoanIx(mfiProgram, accounts, remainingAccounts = []) {
|
|
243
|
+
const { marginfiAccount, ...optionalAccounts } = accounts;
|
|
244
|
+
return mfiProgram.methods.lendingAccountEndFlashloan().accounts({
|
|
245
|
+
marginfiAccount
|
|
246
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
247
|
+
}
|
|
248
|
+
async function makeAccountTransferToNewAccountIx(mfProgram, accounts) {
|
|
249
|
+
const { oldMarginfiAccount, newMarginfiAccount, newAuthority, feePayer, ...optionalAccounts } = accounts;
|
|
250
|
+
return mfProgram.methods.transferToNewAccount().accounts({
|
|
251
|
+
oldMarginfiAccount,
|
|
252
|
+
newMarginfiAccount,
|
|
253
|
+
newAuthority,
|
|
254
|
+
globalFeeWallet: feePayer
|
|
255
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
256
|
+
}
|
|
257
|
+
async function makeGroupInitIx(mfProgram, accounts) {
|
|
258
|
+
return mfProgram.methods.marginfiGroupInitialize().accounts({
|
|
259
|
+
marginfiGroup: accounts.marginfiGroup,
|
|
260
|
+
admin: accounts.admin
|
|
261
|
+
}).instruction();
|
|
262
|
+
}
|
|
263
|
+
async function makeLendingPoolConfigureBankOracleIx(mfProgram, accounts, args, remainingAccounts = []) {
|
|
264
|
+
const { bank, ...optionalAccounts } = accounts;
|
|
265
|
+
return mfProgram.methods.lendingPoolConfigureBankOracle(args.setup, args.feedId).accounts({
|
|
266
|
+
bank
|
|
267
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
268
|
+
}
|
|
269
|
+
async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remainingAccounts = [], args) {
|
|
270
|
+
const {
|
|
271
|
+
stakedSettings,
|
|
272
|
+
feePayer,
|
|
273
|
+
bankMint,
|
|
274
|
+
solPool,
|
|
275
|
+
stakePool,
|
|
276
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
277
|
+
...optionalAccounts
|
|
278
|
+
} = accounts;
|
|
279
|
+
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN__default.default(0)).accounts({
|
|
280
|
+
stakedSettings,
|
|
281
|
+
feePayer,
|
|
282
|
+
bankMint,
|
|
283
|
+
solPool,
|
|
284
|
+
stakePool,
|
|
285
|
+
tokenProgram
|
|
286
|
+
}).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
|
|
287
|
+
}
|
|
288
|
+
async function makePoolAddBankIx(mfProgram, accounts, args) {
|
|
289
|
+
const { marginfiGroup, feePayer, bankMint, bank, tokenProgram, ...optionalAccounts } = accounts;
|
|
290
|
+
return mfProgram.methods.lendingPoolAddBank({
|
|
291
|
+
...args.bankConfig,
|
|
292
|
+
configFlags: 0,
|
|
293
|
+
pad0: [0, 0, 0, 0, 0, 0, 0, 0]
|
|
294
|
+
}).accounts({
|
|
295
|
+
marginfiGroup,
|
|
296
|
+
feePayer,
|
|
297
|
+
bankMint,
|
|
298
|
+
bank,
|
|
299
|
+
tokenProgram
|
|
300
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
301
|
+
}
|
|
302
|
+
async function makeCloseAccountIx(mfProgram, accounts) {
|
|
303
|
+
const { marginfiAccount, feePayer, ...optionalAccounts } = accounts;
|
|
304
|
+
return mfProgram.methods.marginfiAccountClose().accounts({
|
|
305
|
+
marginfiAccount,
|
|
306
|
+
feePayer
|
|
307
|
+
}).accountsPartial(optionalAccounts).instruction();
|
|
308
|
+
}
|
|
309
|
+
async function makePulseHealthIx(mfProgram, accounts, remainingAccounts = []) {
|
|
310
|
+
return mfProgram.methods.lendingAccountPulseHealth().accounts({
|
|
311
|
+
marginfiAccount: accounts.marginfiAccount
|
|
312
|
+
}).remainingAccounts(remainingAccounts).instruction();
|
|
313
|
+
}
|
|
314
|
+
var instructions = {
|
|
315
|
+
makeDepositIx,
|
|
316
|
+
makeJuplendDepositIx,
|
|
317
|
+
makeDriftDepositIx,
|
|
318
|
+
makeKaminoDepositIx,
|
|
319
|
+
makeRepayIx,
|
|
320
|
+
makeWithdrawIx,
|
|
321
|
+
makeJuplendWithdrawIx,
|
|
322
|
+
makeDriftWithdrawIx,
|
|
323
|
+
makeKaminoWithdrawIx,
|
|
324
|
+
makeBorrowIx,
|
|
325
|
+
makeInitMarginfiAccountIx,
|
|
326
|
+
makeInitMarginfiAccountPdaIx,
|
|
327
|
+
makeLendingAccountLiquidateIx,
|
|
328
|
+
makeLendingAccountClearEmissionsIx,
|
|
329
|
+
makePoolAddBankIx,
|
|
330
|
+
makePoolConfigureBankIx,
|
|
331
|
+
makeBeginFlashLoanIx,
|
|
332
|
+
makeEndFlashLoanIx,
|
|
333
|
+
makeAccountTransferToNewAccountIx,
|
|
334
|
+
makeGroupInitIx,
|
|
335
|
+
makeCloseAccountIx,
|
|
336
|
+
makePoolAddPermissionlessStakedBankIx,
|
|
337
|
+
makeLendingPoolConfigureBankOracleIx,
|
|
338
|
+
makePulseHealthIx
|
|
339
|
+
};
|
|
340
|
+
var instructions_default = instructions;
|
|
341
|
+
|
|
342
|
+
module.exports = instructions_default;
|
|
343
|
+
//# sourceMappingURL=instructions.cjs.map
|
|
344
|
+
//# sourceMappingURL=instructions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vendor/spl/constants.ts","../src/instructions.ts"],"names":["PublicKey","BN"],"mappings":";;;;;;;;;;AAE0C,IAAIA,iBAAA;AAAA,EAC5C;AACF;AAGsD,IAAIA,iBAAA;AAAA,EACxD;AACF;AAEO,IAAM,gBAAA,GAAmB,IAAIA,iBAAA,CAAU,6CAA6C,CAAA;AACtD,IAAIA,iBAAA,CAAU,6CAA6C;;;ACLhG,eAAe,yBAAA,CACb,WACA,QAAA,EAMA;AACA,EAAA,OAAO,UAAU,OAAA,CAAQ,yBAAA,GAA4B,QAAA,CAAS,QAAQ,EAAE,WAAA,EAAY;AACtF;AAEA,eAAe,4BAAA,CACb,SAAA,EACA,QAAA,EAMA,IAAA,EAIA;AACA,EAAA,OAAO,SAAA,CAAU,QACd,4BAAA,CAA6B,IAAA,CAAK,cAAc,IAAA,CAAK,YAAA,IAAgB,IAAI,CAAA,CACzE,eAAA,CAAgB;AAAA,IACf,eAAe,QAAA,CAAS,aAAA;AAAA,IACxB,iBAAiB,QAAA,CAAS,eAAA;AAAA,IAC1B,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,UAAU,QAAA,CAAS;AAAA,GACpB,EACA,WAAA,EAAY;AACjB;AAEA,eAAe,qBACb,SAAA,EACA,QAAA,EAwBA,IAAA,EAGA,iBAAA,GAAmC,EAAC,EACpC;AACA,EAAA,MAAM;AAAA,IACJ,eAAA;AAAA,IACA,IAAA;AAAA,IACA,kBAAA;AAAA,IACA,YAAA;AAAA,IACA,4BAAA;AAAA,IACA,gCAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;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CAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAO,oBAAA,GAAQ","file":"instructions.cjs","sourcesContent":["import { PublicKey } from \"@solana/web3.js\";\n\nexport const MEMO_PROGRAM_ID: PublicKey = new PublicKey(\n \"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr\"\n);\n\n/** Address of the SPL Associated Token Account program */\nexport const ASSOCIATED_TOKEN_PROGRAM_ID: PublicKey = new PublicKey(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\"\n);\n\nexport const TOKEN_PROGRAM_ID = new PublicKey(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\nexport const TOKEN_2022_PROGRAM_ID = new PublicKey(\"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb\");\n","import { AccountMeta, PublicKey } from \"@solana/web3.js\";\nimport BN from \"bn.js\";\n\nimport { MarginfiProgram } from \"./types\";\nimport type { BankConfigCompactRaw, BankConfigOptRaw } from \"./services\";\nimport { TOKEN_PROGRAM_ID } from \"./vendor/spl\";\n\nasync function makeInitMarginfiAccountIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiGroup: PublicKey;\n marginfiAccount: PublicKey;\n authority: PublicKey;\n feePayer: PublicKey;\n }\n) {\n return mfProgram.methods.marginfiAccountInitialize().accounts(accounts).instruction();\n}\n\nasync function makeInitMarginfiAccountPdaIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiGroup: PublicKey;\n marginfiAccount: PublicKey;\n authority: PublicKey;\n feePayer: PublicKey;\n },\n args: {\n accountIndex: number;\n thirdPartyId?: number;\n }\n) {\n return mfProgram.methods\n .marginfiAccountInitializePda(args.accountIndex, args.thirdPartyId ?? null)\n .accountsPartial({\n marginfiGroup: accounts.marginfiGroup,\n marginfiAccount: accounts.marginfiAccount,\n authority: accounts.authority,\n feePayer: accounts.feePayer,\n })\n .instruction();\n}\n\nasync function makeJuplendDepositIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n signerTokenAccount: PublicKey;\n\n lendingAdmin: PublicKey;\n supplyTokenReservesLiquidity: PublicKey;\n lendingSupplyPositionOnLiquidity: PublicKey;\n rateModel: PublicKey;\n vault: PublicKey;\n liquidity: PublicKey;\n liquidityProgram: PublicKey;\n rewardsRateModel: PublicKey;\n tokenProgram: PublicKey;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n liquidityVault?: PublicKey;\n fTokenMint?: PublicKey;\n integrationAcc1?: PublicKey;\n integrationAcc2?: PublicKey;\n mint?: PublicKey;\n },\n args: {\n amount: BN;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n marginfiAccount,\n bank,\n signerTokenAccount,\n lendingAdmin,\n supplyTokenReservesLiquidity,\n lendingSupplyPositionOnLiquidity,\n rateModel,\n vault,\n liquidity,\n liquidityProgram,\n rewardsRateModel,\n tokenProgram,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .juplendDeposit(args.amount)\n .accounts(accounts)\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeJuplendWithdrawIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n destinationTokenAccount: PublicKey;\n lendingAdmin: PublicKey;\n supplyTokenReservesLiquidity: PublicKey;\n lendingSupplyPositionOnLiquidity: PublicKey;\n rateModel: PublicKey;\n vault: PublicKey;\n claimAccount: PublicKey;\n liquidity: PublicKey;\n liquidityProgram: PublicKey;\n rewardsRateModel: PublicKey;\n tokenProgram: PublicKey;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n mint?: PublicKey;\n integrationAcc1?: PublicKey;\n fTokenMint?: PublicKey;\n integrationAcc2?: PublicKey;\n integrationAcc3?: PublicKey;\n },\n args: {\n amount: BN;\n withdrawAll?: boolean | null;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n marginfiAccount,\n bank,\n destinationTokenAccount,\n lendingAdmin,\n supplyTokenReservesLiquidity,\n lendingSupplyPositionOnLiquidity,\n rateModel,\n vault,\n claimAccount,\n liquidity,\n liquidityProgram,\n rewardsRateModel,\n tokenProgram,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .juplendWithdraw(args.amount, args.withdrawAll ?? null)\n .accounts(accounts)\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeKaminoDepositIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n signerTokenAccount: PublicKey;\n lendingMarket: PublicKey;\n\n lendingMarketAuthority: PublicKey;\n reserveLiquiditySupply: PublicKey;\n reserveCollateralMint: PublicKey;\n reserveDestinationDepositCollateral: PublicKey;\n liquidityTokenProgram: PublicKey;\n\n obligationFarmUserState: PublicKey | null;\n reserveFarmState: PublicKey | null;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n liquidityVault?: PublicKey;\n integrationAcc1?: PublicKey;\n integrationAcc2?: PublicKey;\n mint?: PublicKey;\n },\n args: {\n amount: BN;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n marginfiAccount,\n bank,\n signerTokenAccount,\n lendingMarket,\n lendingMarketAuthority,\n reserveLiquiditySupply,\n reserveCollateralMint,\n reserveDestinationDepositCollateral,\n liquidityTokenProgram,\n obligationFarmUserState,\n reserveFarmState,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .kaminoDeposit(args.amount)\n .accounts(accounts)\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\n/**\n * Create a Drift deposit instruction\n * Deposits tokens into a Drift spot market through a marginfi bank account\n *\n * @param mfProgram - The marginfi program instance\n * @param accounts - Required and optional accounts for the instruction\n * @param accounts.marginfiAccount - The marginfi account depositing funds\n * @param accounts.bank - The marginfi bank account for the asset\n * @param accounts.signerTokenAccount - The signer's token account (source of funds)\n * @param accounts.driftState - The Drift program state account\n * @param accounts.driftSpotMarketVault - The Drift spot market vault receiving tokens\n * @param accounts.tokenProgram - The SPL token program\n * @param accounts.driftOracle - (Optional) Oracle account for the asset\n * @param args - Instruction arguments\n * @param args.amount - Amount to deposit in native token decimals\n */\nasync function makeDriftDepositIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n signerTokenAccount: PublicKey;\n driftState: PublicKey;\n driftSpotMarketVault: PublicKey;\n tokenProgram: PublicKey;\n driftOracle: PublicKey | null;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n liquidityVault?: PublicKey;\n integrationAcc2?: PublicKey;\n integrationAcc3?: PublicKey;\n integrationAcc1?: PublicKey;\n mint?: PublicKey;\n driftProgram?: PublicKey;\n systemProgram?: PublicKey;\n },\n args: {\n amount: BN;\n }\n) {\n const {\n marginfiAccount,\n bank,\n signerTokenAccount,\n driftState,\n driftSpotMarketVault,\n tokenProgram,\n driftOracle,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .driftDeposit(args.amount)\n .accounts({\n marginfiAccount,\n bank,\n signerTokenAccount,\n driftState,\n driftSpotMarketVault,\n tokenProgram,\n driftOracle,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\nasync function makeDepositIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n signerTokenAccount: PublicKey;\n bank: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n liquidityVault?: PublicKey;\n },\n args: {\n amount: BN;\n depositUpToLimit?: boolean;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingAccountDeposit(args.amount, args.depositUpToLimit ?? null)\n .accounts({\n marginfiAccount,\n signerTokenAccount,\n bank,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeRepayIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n signerTokenAccount: PublicKey;\n bank: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n liquidityVault?: PublicKey;\n },\n args: {\n amount: BN;\n repayAll?: boolean;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, signerTokenAccount, bank, tokenProgram, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingAccountRepay(args.amount, args.repayAll ?? null)\n .accounts({\n marginfiAccount,\n signerTokenAccount,\n bank,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeDriftWithdrawIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n destinationTokenAccount: PublicKey;\n\n driftState: PublicKey;\n driftSigner: PublicKey;\n driftSpotMarketVault: PublicKey;\n tokenProgram: PublicKey;\n\n driftOracle: PublicKey | null;\n driftRewardOracle: PublicKey | null;\n driftRewardSpotMarket: PublicKey | null;\n driftRewardMint: PublicKey | null;\n driftRewardOracle2: PublicKey | null;\n driftRewardSpotMarket2: PublicKey | null;\n driftRewardMint2: PublicKey | null;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n },\n args: {\n amount: BN;\n withdrawAll: boolean;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n marginfiAccount,\n bank,\n destinationTokenAccount,\n driftState,\n driftSigner,\n driftSpotMarketVault,\n tokenProgram,\n driftOracle,\n driftRewardOracle,\n driftRewardSpotMarket,\n driftRewardMint,\n driftRewardOracle2,\n driftRewardSpotMarket2,\n driftRewardMint2,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .driftWithdraw(args.amount, args.withdrawAll)\n .accounts({\n marginfiAccount,\n bank,\n destinationTokenAccount,\n driftState,\n driftSigner,\n driftSpotMarketVault,\n tokenProgram,\n driftOracle,\n driftRewardOracle,\n driftRewardSpotMarket,\n driftRewardMint,\n driftRewardOracle2,\n driftRewardSpotMarket2,\n driftRewardMint2,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeKaminoWithdrawIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n destinationTokenAccount: PublicKey;\n lendingMarket: PublicKey;\n mint: PublicKey;\n\n lendingMarketAuthority: PublicKey;\n reserveLiquiditySupply: PublicKey;\n reserveCollateralMint: PublicKey;\n reserveSourceCollateral: PublicKey;\n liquidityTokenProgram: PublicKey;\n\n obligationFarmUserState: PublicKey | null;\n reserveFarmState: PublicKey | null;\n\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n },\n args: {\n amount: BN;\n isFinalWithdrawal: boolean;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n marginfiAccount,\n bank,\n destinationTokenAccount,\n lendingMarket,\n lendingMarketAuthority,\n reserveLiquiditySupply,\n reserveCollateralMint,\n reserveSourceCollateral,\n liquidityTokenProgram,\n obligationFarmUserState,\n reserveFarmState,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .kaminoWithdraw(args.amount, args.isFinalWithdrawal)\n .accounts({\n marginfiAccount,\n bank,\n destinationTokenAccount,\n lendingMarket,\n lendingMarketAuthority,\n reserveLiquiditySupply,\n reserveCollateralMint,\n reserveSourceCollateral,\n liquidityTokenProgram,\n obligationFarmUserState,\n reserveFarmState,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeWithdrawIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n bank: PublicKey;\n destinationTokenAccount: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n },\n args: {\n amount: BN;\n withdrawAll?: boolean;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } =\n accounts;\n\n return mfProgram.methods\n .lendingAccountWithdraw(args.amount, args.withdrawAll ?? null)\n .accounts({\n marginfiAccount,\n destinationTokenAccount,\n bank,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeBorrowIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n bank: PublicKey;\n destinationTokenAccount: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n },\n args: {\n amount: BN;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, bank, destinationTokenAccount, tokenProgram, ...optionalAccounts } =\n accounts;\n\n return mfProgram.methods\n .lendingAccountBorrow(args.amount)\n .accounts({\n marginfiAccount,\n destinationTokenAccount,\n bank,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nfunction makeLendingAccountLiquidateIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n assetBank: PublicKey;\n liabBank: PublicKey;\n liquidatorMarginfiAccount: PublicKey;\n liquidateeMarginfiAccount: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n },\n args: {\n assetAmount: BN;\n liquidateeAccounts: number;\n liquidatorAccounts: number;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const {\n assetBank,\n liabBank,\n liquidatorMarginfiAccount,\n liquidateeMarginfiAccount,\n tokenProgram,\n ...optionalAccounts\n } = accounts;\n\n return mfiProgram.methods\n .lendingAccountLiquidate(args.assetAmount, args.liquidateeAccounts, args.liquidatorAccounts)\n .accounts({\n assetBank,\n liabBank,\n liquidatorMarginfiAccount,\n liquidateeMarginfiAccount,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nfunction makeLendingAccountClearEmissionsIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n bank: PublicKey;\n }\n) {\n return mfiProgram.methods\n .lendingAccountClearEmissions()\n .accounts({\n marginfiAccount: accounts.marginfiAccount,\n bank: accounts.bank,\n })\n .instruction();\n}\n\nfunction makePoolConfigureBankIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n bank: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n admin?: PublicKey;\n },\n args: {\n bankConfigOpt: BankConfigOptRaw;\n }\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfiProgram.methods\n .lendingPoolConfigureBank(args.bankConfigOpt)\n .accounts({\n bank,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\nfunction makeBeginFlashLoanIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n // Optional accounts - to override inference\n authority?: PublicKey;\n ixsSysvar?: PublicKey;\n },\n args: {\n endIndex: BN;\n }\n) {\n const { marginfiAccount, ...optionalAccounts } = accounts;\n\n return mfiProgram.methods\n .lendingAccountStartFlashloan(args.endIndex)\n .accounts({\n marginfiAccount,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\nfunction makeEndFlashLoanIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n // Optional accounts - to override inference\n authority?: PublicKey;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, ...optionalAccounts } = accounts;\n\n return mfiProgram.methods\n .lendingAccountEndFlashloan()\n .accounts({\n marginfiAccount,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makeAccountTransferToNewAccountIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n oldMarginfiAccount: PublicKey;\n newMarginfiAccount: PublicKey;\n newAuthority: PublicKey;\n feePayer: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n }\n) {\n const { oldMarginfiAccount, newMarginfiAccount, newAuthority, feePayer, ...optionalAccounts } =\n accounts;\n\n return mfProgram.methods\n .transferToNewAccount()\n .accounts({\n oldMarginfiAccount,\n newMarginfiAccount,\n newAuthority,\n globalFeeWallet: feePayer,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\nasync function makeGroupInitIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiGroup: PublicKey;\n admin: PublicKey;\n }\n) {\n return mfProgram.methods\n .marginfiGroupInitialize()\n .accounts({\n marginfiGroup: accounts.marginfiGroup,\n admin: accounts.admin,\n })\n .instruction();\n}\n\n/**\n * Configure the oracle for a bank\n * @param mfProgram The marginfi program\n * @param accounts The accounts required for this instruction\n * @param args The oracle setup index and feed id\n * @param remainingAccounts The remaining accounts required for this instruction, should include the feed oracle key\n */\nasync function makeLendingPoolConfigureBankOracleIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n bank: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n admin?: PublicKey;\n },\n args: {\n /**\n * The oracle setup index, see {@link serializeOracleSetupToIndex}\n */\n setup: number;\n /**\n * The oracle feed id\n */\n feedId: PublicKey;\n },\n /**\n * The remaining accounts required for this instruction, should include the feed oracle key (non writable & signable)\n */\n remainingAccounts: AccountMeta[] = []\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolConfigureBankOracle(args.setup, args.feedId)\n .accounts({\n bank,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\n/**\n * Creates an instruction to add a permissionless staked bank to a lending pool.\n * @param mfProgram - The marginfi program instance\n * @param accounts - The accounts required for this instruction\n * @param remainingAccounts - The remaining accounts required for this instruction, including pythOracle, solPool and bankMint\n * @param args - Optional arguments for this instruction\n */\nasync function makePoolAddPermissionlessStakedBankIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n stakedSettings: PublicKey;\n feePayer: PublicKey;\n bankMint: PublicKey;\n solPool: PublicKey;\n stakePool: PublicKey;\n // Optional accounts - to override inference\n marginfiGroup?: PublicKey;\n /**\n * The token program to use for this instruction, defaults to the SPL token program\n */\n tokenProgram?: PublicKey;\n },\n /**\n * The remaining accounts required for this instruction. Should include:\n * - pythOracle: The pyth oracle key (non writable & non signer)\n * - solPool: The sol pool key (non writable & non signer)\n * - bankMint: The bank mint key (non writable & non signer)\n */\n remainingAccounts: AccountMeta[] = [],\n args: {\n /**\n * The seed to use for the bank account. Defaults to 0 (new BN(0)).\n * If the seed is not specified, the seed is set to 0, and the bank account\n * will be created at the address {@link findPoolAddress} with the default\n * bump.\n */\n seed?: BN;\n }\n) {\n const {\n stakedSettings,\n feePayer,\n bankMint,\n solPool,\n stakePool,\n tokenProgram = TOKEN_PROGRAM_ID,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .lendingPoolAddBankPermissionless(args.seed ?? new BN(0))\n .accounts({\n stakedSettings,\n feePayer,\n bankMint,\n solPool,\n stakePool,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nasync function makePoolAddBankIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiGroup: PublicKey;\n feePayer: PublicKey;\n bankMint: PublicKey;\n bank: PublicKey;\n tokenProgram: PublicKey;\n // Optional accounts - to override inference\n admin?: PublicKey;\n globalFeeWallet?: PublicKey;\n },\n args: {\n bankConfig: BankConfigCompactRaw;\n }\n) {\n const { marginfiGroup, feePayer, bankMint, bank, tokenProgram, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolAddBank({\n ...args.bankConfig,\n configFlags: 0,\n pad0: [0, 0, 0, 0, 0, 0, 0, 0],\n })\n .accounts({\n marginfiGroup,\n feePayer,\n bankMint,\n bank,\n tokenProgram,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\nasync function makeCloseAccountIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n feePayer: PublicKey;\n // Optional accounts - to override inference\n authority?: PublicKey;\n }\n) {\n const { marginfiAccount, feePayer, ...optionalAccounts } = accounts;\n return mfProgram.methods\n .marginfiAccountClose()\n .accounts({\n marginfiAccount,\n feePayer,\n })\n .accountsPartial(optionalAccounts)\n .instruction();\n}\n\n// Deprecated\n// async function makeLendingAccountSortBalancesIx(\n// mfProgram: MarginfiProgram,\n// accounts: {\n// marginfiAccount: PublicKey;\n// }\n// ) {\n// return mfProgram.methods\n// .lendingAccountSortBalances()\n// .accounts({\n// marginfiAccount: accounts.marginfiAccount,\n// })\n// .instruction();\n// }\n\nasync function makePulseHealthIx(\n mfProgram: MarginfiProgram,\n accounts: {\n marginfiAccount: PublicKey;\n },\n /**\n * The remaining accounts required for this instruction. Should include:\n * - For each balance the user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>\n */\n remainingAccounts: AccountMeta[] = []\n) {\n return mfProgram.methods\n .lendingAccountPulseHealth()\n .accounts({\n marginfiAccount: accounts.marginfiAccount,\n })\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\nconst instructions = {\n makeDepositIx,\n makeJuplendDepositIx,\n makeDriftDepositIx,\n makeKaminoDepositIx,\n makeRepayIx,\n makeWithdrawIx,\n makeJuplendWithdrawIx,\n makeDriftWithdrawIx,\n makeKaminoWithdrawIx,\n makeBorrowIx,\n makeInitMarginfiAccountIx,\n makeInitMarginfiAccountPdaIx,\n makeLendingAccountLiquidateIx,\n makeLendingAccountClearEmissionsIx,\n makePoolAddBankIx,\n makePoolConfigureBankIx,\n makeBeginFlashLoanIx,\n makeEndFlashLoanIx,\n makeAccountTransferToNewAccountIx,\n makeGroupInitIx,\n makeCloseAccountIx,\n makePoolAddPermissionlessStakedBankIx,\n makeLendingPoolConfigureBankOracleIx,\n makePulseHealthIx,\n};\n\nexport default instructions;\n"]}
|