@0dotxyz/p0-ts-sdk 2.10.0-alpha.1 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -228,6 +228,10 @@ function makePoolConfigureBankIx(mfiProgram, accounts, args) {
228
228
  bank
229
229
  }).accountsPartial(optionalAccounts).instruction();
230
230
  }
231
+ function makePoolConfigureBankGovIx(mfiProgram, accounts, args) {
232
+ const { bank, ...optionalAccounts } = accounts;
233
+ return mfiProgram.methods.lendingPoolConfigureBankGov(args.bankConfigOpt).accounts({ bank }).accountsPartial(optionalAccounts).instruction();
234
+ }
231
235
  function makeBeginFlashLoanIx(mfiProgram, accounts, args) {
232
236
  const { marginfiAccount, ...optionalAccounts } = accounts;
233
237
  return mfiProgram.methods.lendingAccountStartFlashloan(args.endIndex).accounts({
@@ -271,7 +275,9 @@ async function makeLendingPoolConfigureBankOracleIx(mfProgram, accounts, args, r
271
275
  }
272
276
  async function makeLendingPoolConfigureBankOracleScopeIx(mfProgram, accounts, args) {
273
277
  const { bank, ...optionalAccounts } = accounts;
274
- return mfProgram.methods.lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex).accounts({ bank }).accountsPartial(optionalAccounts).remainingAccounts([{ pubkey: args.oracle, isSigner: false, isWritable: false }]).instruction();
278
+ return mfProgram.methods.lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex).accounts({ bank }).accountsPartial(optionalAccounts).remainingAccounts(
279
+ [args.oracle, args.integrationAccount].filter((pubkey) => pubkey !== void 0).map((pubkey) => ({ pubkey, isSigner: false, isWritable: false }))
280
+ ).instruction();
275
281
  }
276
282
  async function makeLendingPoolSetOraclePriceIx(mfProgram, accounts, args, remainingAccounts = []) {
277
283
  const { bank, ...optionalAccounts } = accounts;
@@ -327,6 +333,22 @@ async function makePulseHealthIx(mfProgram, accounts, remainingAccounts = []) {
327
333
  group: accounts.group
328
334
  }).remainingAccounts(remainingAccounts).instruction();
329
335
  }
336
+ async function makePlaceOrderIx(mfProgram, accounts, args, remainingAccounts = []) {
337
+ const { marginfiAccount, feePayer, authority, order, globalFeeWallet, ...optionalAccounts } = accounts;
338
+ return mfProgram.methods.marginfiAccountPlaceOrder(args.bankKeys, args.trigger).accounts({
339
+ marginfiAccount,
340
+ feePayer,
341
+ order
342
+ }).accountsPartial({ authority, globalFeeWallet, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
343
+ }
344
+ async function makeCloseOrderIx(mfProgram, accounts, remainingAccounts = []) {
345
+ const { marginfiAccount, authority, order, feeRecipient, ...optionalAccounts } = accounts;
346
+ return mfProgram.methods.marginfiAccountCloseOrder().accounts({
347
+ authority,
348
+ order,
349
+ feeRecipient
350
+ }).accountsPartial({ marginfiAccount, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
351
+ }
330
352
  var instructions = {
331
353
  makeDepositIx,
332
354
  makeJuplendDepositIx,
@@ -343,6 +365,7 @@ var instructions = {
343
365
  makeLendingAccountLiquidateIx,
344
366
  makePoolAddBankIx,
345
367
  makePoolConfigureBankIx,
368
+ makePoolConfigureBankGovIx,
346
369
  makeBeginFlashLoanIx,
347
370
  makeEndFlashLoanIx,
348
371
  makeAccountTransferToNewAccountIx,
@@ -352,7 +375,9 @@ var instructions = {
352
375
  makeLendingPoolConfigureBankOracleIx,
353
376
  makeLendingPoolConfigureBankOracleScopeIx,
354
377
  makeLendingPoolSetOraclePriceIx,
355
- makePulseHealthIx
378
+ makePulseHealthIx,
379
+ makePlaceOrderIx,
380
+ makeCloseOrderIx
356
381
  };
357
382
  var instructions_default = instructions;
358
383
 
@@ -1 +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;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CAAkB,iBAAiB,EACnC,WAAA,EAAY;AACjB;AAEA,IAAM,YAAA,GAAe;AAAA,EACnB,aAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,qBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,4BAAA;AAAA,EACA,6BAAA;AAAA,EACA,iBAAA;AAAA,EACA,uBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iCAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,qCAAA;AAAA,EACA,oCAAA;AAAA,EACA,yCAAA;AAAA,EACA,+BAAA;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 type { BankConfigCompactRaw, BankConfigOptRaw } from \"./services\";\nimport { MarginfiProgram, WrappedI80F48 } from \"./types\";\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 /** 0.1.9-only: refresh the reserve in-instruction. Ignored by the 1.8 program. */\n refreshReserve?: boolean;\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, args.refreshReserve ?? null)\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 * 0.1.9-only: refresh the reserve via batch refresh (flags bit 1). Do NOT set while the\n * 1.8 program is deployed — its `Option<bool>` decoder rejects flag bytes above 1.\n */\n refreshReserve?: 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 // flags bit 0 = withdraw all, bit 1 = batch refresh. `isFinalWithdrawal ? 1 : null` is\n // byte-identical to the pre-0.1.9 `withdrawAll: Option<bool>` encoding, so it lands on\n // both the 1.8 and 1.9 programs.\n const flags = (args.isFinalWithdrawal ? 1 : 0) | (args.refreshReserve ? 2 : 0);\n\n return mfProgram.methods\n .kaminoWithdraw(args.amount, flags === 0 ? null : flags)\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 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\nasync function makeEndFlashLoanIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n // Optional accounts - to override inference\n authority?: PublicKey;\n // Pass explicitly when the account isn't on-chain yet (fresh-account flash loans)\n group?: 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 globalFeeWallet: PublicKey;\n feePayer: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n }\n) {\n const {\n oldMarginfiAccount,\n newMarginfiAccount,\n newAuthority,\n globalFeeWallet,\n feePayer,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .transferToNewAccount()\n .accounts({\n oldMarginfiAccount,\n newMarginfiAccount,\n newAuthority,\n globalFeeWallet,\n 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 * Configure a bank to use an entry in a Scope OraclePrices account.\n * @param mfProgram The marginfi program\n * @param accounts The group, admin, and bank accounts required by the instruction\n * @param args The Scope OraclePrices account and its entry index\n */\nasync function makeLendingPoolConfigureBankOracleScopeIx(\n mfProgram: MarginfiProgram,\n accounts: {\n bank: PublicKey;\n group?: PublicKey;\n admin?: PublicKey;\n },\n args: {\n oracle: PublicKey;\n entryIndex: number;\n }\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex)\n .accounts({ bank })\n .accountsPartial(optionalAccounts)\n .remainingAccounts([{ pubkey: args.oracle, isSigner: false, isWritable: false }])\n .instruction();\n}\n\n/** Configure a fixed or Exponent PT oracle through the 0.1.11 set-oracle-price instruction. */\nasync function makeLendingPoolSetOraclePriceIx(\n mfProgram: MarginfiProgram,\n accounts: {\n bank: PublicKey;\n group?: PublicKey;\n admin?: PublicKey;\n },\n args: {\n price: WrappedI80F48;\n setup: number;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolSetOraclePrice(args.price, args.setup)\n .accounts({ bank })\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 /** The SVSP on-ramp account, derived from the stake pool (0.1.9+ program only) */\n poolOnramp: PublicKey;\n stakePool: PublicKey;\n /** The validator vote account backing the stake pool (0.1.9+ program only) */\n validatorVoteAccount: 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 poolOnramp,\n stakePool,\n validatorVoteAccount,\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 poolOnramp,\n stakePool,\n validatorVoteAccount,\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 group: 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 .accountsPartial({\n marginfiAccount: accounts.marginfiAccount,\n group: accounts.group,\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 makePoolAddBankIx,\n makePoolConfigureBankIx,\n makeBeginFlashLoanIx,\n makeEndFlashLoanIx,\n makeAccountTransferToNewAccountIx,\n makeGroupInitIx,\n makeCloseAccountIx,\n makePoolAddPermissionlessStakedBankIx,\n makeLendingPoolConfigureBankOracleIx,\n makeLendingPoolConfigureBankOracleScopeIx,\n makeLendingPoolSetOraclePriceIx,\n makePulseHealthIx,\n};\n\nexport default instructions;\n"]}
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,EA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AA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,qBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,4BAAA;AAAA,EACA,6BAAA;AAAA,EACA,iBAAA;AAAA,EACA,uBAAA;AAAA,EACA,0BAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iCAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,qCAAA;AAAA,EACA,oCAAA;AAAA,EACA,yCAAA;AAAA,EACA,+BAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;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 type { BankConfigCompactRaw, BankConfigFastRaw, BankConfigGovRaw } from \"./services\";\nimport { MarginfiProgram, OrderTrigger, WrappedI80F48 } from \"./types\";\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 /** 0.1.9-only: refresh the reserve in-instruction. Ignored by the 1.8 program. */\n refreshReserve?: boolean;\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, args.refreshReserve ?? null)\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 * 0.1.9-only: refresh the reserve via batch refresh (flags bit 1). Do NOT set while the\n * 1.8 program is deployed — its `Option<bool>` decoder rejects flag bytes above 1.\n */\n refreshReserve?: 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 // flags bit 0 = withdraw all, bit 1 = batch refresh. `isFinalWithdrawal ? 1 : null` is\n // byte-identical to the pre-0.1.9 `withdrawAll: Option<bool>` encoding, so it lands on\n // both the 1.8 and 1.9 programs.\n const flags = (args.isFinalWithdrawal ? 1 : 0) | (args.refreshReserve ? 2 : 0);\n\n return mfProgram.methods\n .kaminoWithdraw(args.amount, flags === 0 ? null : flags)\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\n/**\n * Configure a bank's risk-reducing settings (limits, interest rates, fees, circuit breaker,\n * operational state toward paused/reduce-only), signed by the group admin. Weights, risk tier,\n * oracle limits and freezing go through {@link makePoolConfigureBankGovIx}.\n * @param mfiProgram The marginfi program\n * @param accounts The bank, plus optional group/admin overrides\n * @param args The settings to change; `null` leaves a setting unchanged\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: BankConfigFastRaw;\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\n/**\n * Configure a bank's risk-increasing settings (weights, risk tier, asset tag, oracle limits,\n * tokenless repayments, freezing, returning to operational), signed by the group's governance\n * admin.\n * @param mfiProgram The marginfi program\n * @param accounts The bank, plus optional group/governance admin overrides\n * @param args The settings to change; `null` leaves a setting unchanged\n */\nfunction makePoolConfigureBankGovIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n bank: PublicKey;\n group?: PublicKey;\n governanceAdmin?: PublicKey;\n },\n args: {\n bankConfigOpt: BankConfigGovRaw;\n }\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfiProgram.methods\n .lendingPoolConfigureBankGov(args.bankConfigOpt)\n .accounts({ bank })\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\nasync function makeEndFlashLoanIx(\n mfiProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n // Optional accounts - to override inference\n authority?: PublicKey;\n // Pass explicitly when the account isn't on-chain yet (fresh-account flash loans)\n group?: 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 globalFeeWallet: PublicKey;\n feePayer: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n authority?: PublicKey;\n }\n) {\n const {\n oldMarginfiAccount,\n newMarginfiAccount,\n newAuthority,\n globalFeeWallet,\n feePayer,\n ...optionalAccounts\n } = accounts;\n\n return mfProgram.methods\n .transferToNewAccount()\n .accounts({\n oldMarginfiAccount,\n newMarginfiAccount,\n newAuthority,\n globalFeeWallet,\n 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 governanceAdmin?: 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 * Configure a bank to use an entry in a Scope OraclePrices account. The program picks Scope,\n * ScopeKamino or ScopeJuplend from the bank's asset tag.\n * @param mfProgram The marginfi program\n * @param accounts The bank, plus optional group/governance admin overrides\n * @param args The Scope OraclePrices account, its entry index, and for Kamino/JupLend banks the\n * bank's Kamino reserve or JupLend lending account (its `oracleKeys[1]`)\n */\nasync function makeLendingPoolConfigureBankOracleScopeIx(\n mfProgram: MarginfiProgram,\n accounts: {\n bank: PublicKey;\n group?: PublicKey;\n governanceAdmin?: PublicKey;\n },\n args: {\n oracle: PublicKey;\n entryIndex: number;\n integrationAccount?: PublicKey;\n }\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex)\n .accounts({ bank })\n .accountsPartial(optionalAccounts)\n .remainingAccounts(\n [args.oracle, args.integrationAccount]\n .filter((pubkey) => pubkey !== undefined)\n .map((pubkey) => ({ pubkey, isSigner: false, isWritable: false }))\n )\n .instruction();\n}\n\n/** Configure a fixed or Exponent PT oracle through the set-oracle-price instruction. */\nasync function makeLendingPoolSetOraclePriceIx(\n mfProgram: MarginfiProgram,\n accounts: {\n bank: PublicKey;\n group?: PublicKey;\n governanceAdmin?: PublicKey;\n },\n args: {\n price: WrappedI80F48;\n setup: number;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { bank, ...optionalAccounts } = accounts;\n\n return mfProgram.methods\n .lendingPoolSetOraclePrice(args.price, args.setup)\n .accounts({ bank })\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 /** The SVSP on-ramp account, derived from the stake pool (0.1.9+ program only) */\n poolOnramp: PublicKey;\n stakePool: PublicKey;\n /** The validator vote account backing the stake pool (0.1.9+ program only) */\n validatorVoteAccount: 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 poolOnramp,\n stakePool,\n validatorVoteAccount,\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 poolOnramp,\n stakePool,\n validatorVoteAccount,\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 governanceAdmin?: 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 group: 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 .accountsPartial({\n marginfiAccount: accounts.marginfiAccount,\n group: accounts.group,\n })\n .remainingAccounts(remainingAccounts)\n .instruction();\n}\n\n/**\n * Creates an instruction to place a take-profit/stop-loss order on a collateral/debt bank pair.\n * The `order` account must be derived by the caller (see `deriveOrderPda`) — the IDL has no\n * pda block for it.\n */\nasync function makePlaceOrderIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n feePayer: PublicKey;\n authority: PublicKey;\n order: PublicKey;\n globalFeeWallet: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n },\n args: {\n /** Exactly two keys: one asset-side (collateral) bank and one liability-side (debt) bank. */\n bankKeys: PublicKey[];\n trigger: OrderTrigger;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, feePayer, authority, order, globalFeeWallet, ...optionalAccounts } =\n accounts;\n\n return (\n mfProgram.methods\n .marginfiAccountPlaceOrder(args.bankKeys, args.trigger)\n .accounts({\n marginfiAccount,\n feePayer,\n order,\n })\n // has_one relations are only accepted via accountsPartial; passing them skips resolver fetches\n .accountsPartial({ authority, globalFeeWallet, ...optionalAccounts })\n .remainingAccounts(remainingAccounts)\n .instruction()\n );\n}\n\n/**\n * Creates an instruction to close an existing order, returning rent to the fee recipient.\n */\nasync function makeCloseOrderIx(\n mfProgram: MarginfiProgram,\n accounts: {\n // Required accounts\n marginfiAccount: PublicKey;\n authority: PublicKey;\n order: PublicKey;\n feeRecipient: PublicKey;\n // Optional accounts - to override inference\n group?: PublicKey;\n },\n remainingAccounts: AccountMeta[] = []\n) {\n const { marginfiAccount, authority, order, feeRecipient, ...optionalAccounts } = accounts;\n\n return (\n mfProgram.methods\n .marginfiAccountCloseOrder()\n .accounts({\n authority,\n order,\n feeRecipient,\n })\n // has_one relation from `order`, only accepted via accountsPartial\n .accountsPartial({ marginfiAccount, ...optionalAccounts })\n .remainingAccounts(remainingAccounts)\n .instruction()\n );\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 makePoolAddBankIx,\n makePoolConfigureBankIx,\n makePoolConfigureBankGovIx,\n makeBeginFlashLoanIx,\n makeEndFlashLoanIx,\n makeAccountTransferToNewAccountIx,\n makeGroupInitIx,\n makeCloseAccountIx,\n makePoolAddPermissionlessStakedBankIx,\n makeLendingPoolConfigureBankOracleIx,\n makeLendingPoolConfigureBankOracleScopeIx,\n makeLendingPoolSetOraclePriceIx,\n makePulseHealthIx,\n makePlaceOrderIx,\n makeCloseOrderIx,\n};\n\nexport default instructions;\n"]}
@@ -1,10 +1,10 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, AccountMeta } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
- import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw, W as WrappedI80F48 } from './types-SQxOiZGm.cjs';
4
+ import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigFastRaw, b as BankConfigGovRaw, W as WrappedI80F48, O as OrderTrigger } from './types-DQD0k0pr.cjs';
5
5
  import '@coral-xyz/anchor';
6
6
  import 'bignumber.js';
7
- import './dto-farm.types-BAA9xrey.cjs';
7
+ import './dto-farm.types-6lrPBcZr.cjs';
8
8
 
9
9
  declare function makeInitMarginfiAccountIx(mfProgram: MarginfiProgram, accounts: {
10
10
  marginfiGroup: PublicKey;
@@ -231,12 +231,35 @@ declare function makeLendingAccountLiquidateIx(mfiProgram: MarginfiProgram, acco
231
231
  liquidateeAccounts: number;
232
232
  liquidatorAccounts: number;
233
233
  }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
234
+ /**
235
+ * Configure a bank's risk-reducing settings (limits, interest rates, fees, circuit breaker,
236
+ * operational state toward paused/reduce-only), signed by the group admin. Weights, risk tier,
237
+ * oracle limits and freezing go through {@link makePoolConfigureBankGovIx}.
238
+ * @param mfiProgram The marginfi program
239
+ * @param accounts The bank, plus optional group/admin overrides
240
+ * @param args The settings to change; `null` leaves a setting unchanged
241
+ */
234
242
  declare function makePoolConfigureBankIx(mfiProgram: MarginfiProgram, accounts: {
235
243
  bank: PublicKey;
236
244
  group?: PublicKey;
237
245
  admin?: PublicKey;
238
246
  }, args: {
239
- bankConfigOpt: BankConfigOptRaw;
247
+ bankConfigOpt: BankConfigFastRaw;
248
+ }): Promise<_solana_web3_js.TransactionInstruction>;
249
+ /**
250
+ * Configure a bank's risk-increasing settings (weights, risk tier, asset tag, oracle limits,
251
+ * tokenless repayments, freezing, returning to operational), signed by the group's governance
252
+ * admin.
253
+ * @param mfiProgram The marginfi program
254
+ * @param accounts The bank, plus optional group/governance admin overrides
255
+ * @param args The settings to change; `null` leaves a setting unchanged
256
+ */
257
+ declare function makePoolConfigureBankGovIx(mfiProgram: MarginfiProgram, accounts: {
258
+ bank: PublicKey;
259
+ group?: PublicKey;
260
+ governanceAdmin?: PublicKey;
261
+ }, args: {
262
+ bankConfigOpt: BankConfigGovRaw;
240
263
  }): Promise<_solana_web3_js.TransactionInstruction>;
241
264
  declare function makeBeginFlashLoanIx(mfiProgram: MarginfiProgram, accounts: {
242
265
  marginfiAccount: PublicKey;
@@ -273,7 +296,7 @@ declare function makeGroupInitIx(mfProgram: MarginfiProgram, accounts: {
273
296
  declare function makeLendingPoolConfigureBankOracleIx(mfProgram: MarginfiProgram, accounts: {
274
297
  bank: PublicKey;
275
298
  group?: PublicKey;
276
- admin?: PublicKey;
299
+ governanceAdmin?: PublicKey;
277
300
  }, args: {
278
301
  /**
279
302
  * The oracle setup index, see {@link serializeOracleSetupToIndex}
@@ -289,24 +312,27 @@ declare function makeLendingPoolConfigureBankOracleIx(mfProgram: MarginfiProgram
289
312
  */
290
313
  remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
291
314
  /**
292
- * Configure a bank to use an entry in a Scope OraclePrices account.
315
+ * Configure a bank to use an entry in a Scope OraclePrices account. The program picks Scope,
316
+ * ScopeKamino or ScopeJuplend from the bank's asset tag.
293
317
  * @param mfProgram The marginfi program
294
- * @param accounts The group, admin, and bank accounts required by the instruction
295
- * @param args The Scope OraclePrices account and its entry index
318
+ * @param accounts The bank, plus optional group/governance admin overrides
319
+ * @param args The Scope OraclePrices account, its entry index, and for Kamino/JupLend banks the
320
+ * bank's Kamino reserve or JupLend lending account (its `oracleKeys[1]`)
296
321
  */
297
322
  declare function makeLendingPoolConfigureBankOracleScopeIx(mfProgram: MarginfiProgram, accounts: {
298
323
  bank: PublicKey;
299
324
  group?: PublicKey;
300
- admin?: PublicKey;
325
+ governanceAdmin?: PublicKey;
301
326
  }, args: {
302
327
  oracle: PublicKey;
303
328
  entryIndex: number;
329
+ integrationAccount?: PublicKey;
304
330
  }): Promise<_solana_web3_js.TransactionInstruction>;
305
- /** Configure a fixed or Exponent PT oracle through the 0.1.11 set-oracle-price instruction. */
331
+ /** Configure a fixed or Exponent PT oracle through the set-oracle-price instruction. */
306
332
  declare function makeLendingPoolSetOraclePriceIx(mfProgram: MarginfiProgram, accounts: {
307
333
  bank: PublicKey;
308
334
  group?: PublicKey;
309
- admin?: PublicKey;
335
+ governanceAdmin?: PublicKey;
310
336
  }, args: {
311
337
  price: WrappedI80F48;
312
338
  setup: number;
@@ -355,7 +381,7 @@ declare function makePoolAddBankIx(mfProgram: MarginfiProgram, accounts: {
355
381
  bankMint: PublicKey;
356
382
  bank: PublicKey;
357
383
  tokenProgram: PublicKey;
358
- admin?: PublicKey;
384
+ governanceAdmin?: PublicKey;
359
385
  globalFeeWallet?: PublicKey;
360
386
  }, args: {
361
387
  bankConfig: BankConfigCompactRaw;
@@ -374,6 +400,33 @@ declare function makePulseHealthIx(mfProgram: MarginfiProgram, accounts: {
374
400
  * - For each balance the user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>
375
401
  */
376
402
  remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
403
+ /**
404
+ * Creates an instruction to place a take-profit/stop-loss order on a collateral/debt bank pair.
405
+ * The `order` account must be derived by the caller (see `deriveOrderPda`) — the IDL has no
406
+ * pda block for it.
407
+ */
408
+ declare function makePlaceOrderIx(mfProgram: MarginfiProgram, accounts: {
409
+ marginfiAccount: PublicKey;
410
+ feePayer: PublicKey;
411
+ authority: PublicKey;
412
+ order: PublicKey;
413
+ globalFeeWallet: PublicKey;
414
+ group?: PublicKey;
415
+ }, args: {
416
+ /** Exactly two keys: one asset-side (collateral) bank and one liability-side (debt) bank. */
417
+ bankKeys: PublicKey[];
418
+ trigger: OrderTrigger;
419
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
420
+ /**
421
+ * Creates an instruction to close an existing order, returning rent to the fee recipient.
422
+ */
423
+ declare function makeCloseOrderIx(mfProgram: MarginfiProgram, accounts: {
424
+ marginfiAccount: PublicKey;
425
+ authority: PublicKey;
426
+ order: PublicKey;
427
+ feeRecipient: PublicKey;
428
+ group?: PublicKey;
429
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
377
430
  declare const instructions: {
378
431
  makeDepositIx: typeof makeDepositIx;
379
432
  makeJuplendDepositIx: typeof makeJuplendDepositIx;
@@ -390,6 +443,7 @@ declare const instructions: {
390
443
  makeLendingAccountLiquidateIx: typeof makeLendingAccountLiquidateIx;
391
444
  makePoolAddBankIx: typeof makePoolAddBankIx;
392
445
  makePoolConfigureBankIx: typeof makePoolConfigureBankIx;
446
+ makePoolConfigureBankGovIx: typeof makePoolConfigureBankGovIx;
393
447
  makeBeginFlashLoanIx: typeof makeBeginFlashLoanIx;
394
448
  makeEndFlashLoanIx: typeof makeEndFlashLoanIx;
395
449
  makeAccountTransferToNewAccountIx: typeof makeAccountTransferToNewAccountIx;
@@ -400,6 +454,8 @@ declare const instructions: {
400
454
  makeLendingPoolConfigureBankOracleScopeIx: typeof makeLendingPoolConfigureBankOracleScopeIx;
401
455
  makeLendingPoolSetOraclePriceIx: typeof makeLendingPoolSetOraclePriceIx;
402
456
  makePulseHealthIx: typeof makePulseHealthIx;
457
+ makePlaceOrderIx: typeof makePlaceOrderIx;
458
+ makeCloseOrderIx: typeof makeCloseOrderIx;
403
459
  };
404
460
 
405
461
  export { instructions as default };
@@ -1,10 +1,10 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, AccountMeta } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
- import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw, W as WrappedI80F48 } from './types-Cj6aaTuh.js';
4
+ import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigFastRaw, b as BankConfigGovRaw, W as WrappedI80F48, O as OrderTrigger } from './types--m9sTr2x.js';
5
5
  import '@coral-xyz/anchor';
6
6
  import 'bignumber.js';
7
- import './dto-farm.types-BAA9xrey.js';
7
+ import './dto-farm.types-6lrPBcZr.js';
8
8
 
9
9
  declare function makeInitMarginfiAccountIx(mfProgram: MarginfiProgram, accounts: {
10
10
  marginfiGroup: PublicKey;
@@ -231,12 +231,35 @@ declare function makeLendingAccountLiquidateIx(mfiProgram: MarginfiProgram, acco
231
231
  liquidateeAccounts: number;
232
232
  liquidatorAccounts: number;
233
233
  }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
234
+ /**
235
+ * Configure a bank's risk-reducing settings (limits, interest rates, fees, circuit breaker,
236
+ * operational state toward paused/reduce-only), signed by the group admin. Weights, risk tier,
237
+ * oracle limits and freezing go through {@link makePoolConfigureBankGovIx}.
238
+ * @param mfiProgram The marginfi program
239
+ * @param accounts The bank, plus optional group/admin overrides
240
+ * @param args The settings to change; `null` leaves a setting unchanged
241
+ */
234
242
  declare function makePoolConfigureBankIx(mfiProgram: MarginfiProgram, accounts: {
235
243
  bank: PublicKey;
236
244
  group?: PublicKey;
237
245
  admin?: PublicKey;
238
246
  }, args: {
239
- bankConfigOpt: BankConfigOptRaw;
247
+ bankConfigOpt: BankConfigFastRaw;
248
+ }): Promise<_solana_web3_js.TransactionInstruction>;
249
+ /**
250
+ * Configure a bank's risk-increasing settings (weights, risk tier, asset tag, oracle limits,
251
+ * tokenless repayments, freezing, returning to operational), signed by the group's governance
252
+ * admin.
253
+ * @param mfiProgram The marginfi program
254
+ * @param accounts The bank, plus optional group/governance admin overrides
255
+ * @param args The settings to change; `null` leaves a setting unchanged
256
+ */
257
+ declare function makePoolConfigureBankGovIx(mfiProgram: MarginfiProgram, accounts: {
258
+ bank: PublicKey;
259
+ group?: PublicKey;
260
+ governanceAdmin?: PublicKey;
261
+ }, args: {
262
+ bankConfigOpt: BankConfigGovRaw;
240
263
  }): Promise<_solana_web3_js.TransactionInstruction>;
241
264
  declare function makeBeginFlashLoanIx(mfiProgram: MarginfiProgram, accounts: {
242
265
  marginfiAccount: PublicKey;
@@ -273,7 +296,7 @@ declare function makeGroupInitIx(mfProgram: MarginfiProgram, accounts: {
273
296
  declare function makeLendingPoolConfigureBankOracleIx(mfProgram: MarginfiProgram, accounts: {
274
297
  bank: PublicKey;
275
298
  group?: PublicKey;
276
- admin?: PublicKey;
299
+ governanceAdmin?: PublicKey;
277
300
  }, args: {
278
301
  /**
279
302
  * The oracle setup index, see {@link serializeOracleSetupToIndex}
@@ -289,24 +312,27 @@ declare function makeLendingPoolConfigureBankOracleIx(mfProgram: MarginfiProgram
289
312
  */
290
313
  remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
291
314
  /**
292
- * Configure a bank to use an entry in a Scope OraclePrices account.
315
+ * Configure a bank to use an entry in a Scope OraclePrices account. The program picks Scope,
316
+ * ScopeKamino or ScopeJuplend from the bank's asset tag.
293
317
  * @param mfProgram The marginfi program
294
- * @param accounts The group, admin, and bank accounts required by the instruction
295
- * @param args The Scope OraclePrices account and its entry index
318
+ * @param accounts The bank, plus optional group/governance admin overrides
319
+ * @param args The Scope OraclePrices account, its entry index, and for Kamino/JupLend banks the
320
+ * bank's Kamino reserve or JupLend lending account (its `oracleKeys[1]`)
296
321
  */
297
322
  declare function makeLendingPoolConfigureBankOracleScopeIx(mfProgram: MarginfiProgram, accounts: {
298
323
  bank: PublicKey;
299
324
  group?: PublicKey;
300
- admin?: PublicKey;
325
+ governanceAdmin?: PublicKey;
301
326
  }, args: {
302
327
  oracle: PublicKey;
303
328
  entryIndex: number;
329
+ integrationAccount?: PublicKey;
304
330
  }): Promise<_solana_web3_js.TransactionInstruction>;
305
- /** Configure a fixed or Exponent PT oracle through the 0.1.11 set-oracle-price instruction. */
331
+ /** Configure a fixed or Exponent PT oracle through the set-oracle-price instruction. */
306
332
  declare function makeLendingPoolSetOraclePriceIx(mfProgram: MarginfiProgram, accounts: {
307
333
  bank: PublicKey;
308
334
  group?: PublicKey;
309
- admin?: PublicKey;
335
+ governanceAdmin?: PublicKey;
310
336
  }, args: {
311
337
  price: WrappedI80F48;
312
338
  setup: number;
@@ -355,7 +381,7 @@ declare function makePoolAddBankIx(mfProgram: MarginfiProgram, accounts: {
355
381
  bankMint: PublicKey;
356
382
  bank: PublicKey;
357
383
  tokenProgram: PublicKey;
358
- admin?: PublicKey;
384
+ governanceAdmin?: PublicKey;
359
385
  globalFeeWallet?: PublicKey;
360
386
  }, args: {
361
387
  bankConfig: BankConfigCompactRaw;
@@ -374,6 +400,33 @@ declare function makePulseHealthIx(mfProgram: MarginfiProgram, accounts: {
374
400
  * - For each balance the user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>
375
401
  */
376
402
  remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
403
+ /**
404
+ * Creates an instruction to place a take-profit/stop-loss order on a collateral/debt bank pair.
405
+ * The `order` account must be derived by the caller (see `deriveOrderPda`) — the IDL has no
406
+ * pda block for it.
407
+ */
408
+ declare function makePlaceOrderIx(mfProgram: MarginfiProgram, accounts: {
409
+ marginfiAccount: PublicKey;
410
+ feePayer: PublicKey;
411
+ authority: PublicKey;
412
+ order: PublicKey;
413
+ globalFeeWallet: PublicKey;
414
+ group?: PublicKey;
415
+ }, args: {
416
+ /** Exactly two keys: one asset-side (collateral) bank and one liability-side (debt) bank. */
417
+ bankKeys: PublicKey[];
418
+ trigger: OrderTrigger;
419
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
420
+ /**
421
+ * Creates an instruction to close an existing order, returning rent to the fee recipient.
422
+ */
423
+ declare function makeCloseOrderIx(mfProgram: MarginfiProgram, accounts: {
424
+ marginfiAccount: PublicKey;
425
+ authority: PublicKey;
426
+ order: PublicKey;
427
+ feeRecipient: PublicKey;
428
+ group?: PublicKey;
429
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
377
430
  declare const instructions: {
378
431
  makeDepositIx: typeof makeDepositIx;
379
432
  makeJuplendDepositIx: typeof makeJuplendDepositIx;
@@ -390,6 +443,7 @@ declare const instructions: {
390
443
  makeLendingAccountLiquidateIx: typeof makeLendingAccountLiquidateIx;
391
444
  makePoolAddBankIx: typeof makePoolAddBankIx;
392
445
  makePoolConfigureBankIx: typeof makePoolConfigureBankIx;
446
+ makePoolConfigureBankGovIx: typeof makePoolConfigureBankGovIx;
393
447
  makeBeginFlashLoanIx: typeof makeBeginFlashLoanIx;
394
448
  makeEndFlashLoanIx: typeof makeEndFlashLoanIx;
395
449
  makeAccountTransferToNewAccountIx: typeof makeAccountTransferToNewAccountIx;
@@ -400,6 +454,8 @@ declare const instructions: {
400
454
  makeLendingPoolConfigureBankOracleScopeIx: typeof makeLendingPoolConfigureBankOracleScopeIx;
401
455
  makeLendingPoolSetOraclePriceIx: typeof makeLendingPoolSetOraclePriceIx;
402
456
  makePulseHealthIx: typeof makePulseHealthIx;
457
+ makePlaceOrderIx: typeof makePlaceOrderIx;
458
+ makeCloseOrderIx: typeof makeCloseOrderIx;
403
459
  };
404
460
 
405
461
  export { instructions as default };
@@ -222,6 +222,10 @@ function makePoolConfigureBankIx(mfiProgram, accounts, args) {
222
222
  bank
223
223
  }).accountsPartial(optionalAccounts).instruction();
224
224
  }
225
+ function makePoolConfigureBankGovIx(mfiProgram, accounts, args) {
226
+ const { bank, ...optionalAccounts } = accounts;
227
+ return mfiProgram.methods.lendingPoolConfigureBankGov(args.bankConfigOpt).accounts({ bank }).accountsPartial(optionalAccounts).instruction();
228
+ }
225
229
  function makeBeginFlashLoanIx(mfiProgram, accounts, args) {
226
230
  const { marginfiAccount, ...optionalAccounts } = accounts;
227
231
  return mfiProgram.methods.lendingAccountStartFlashloan(args.endIndex).accounts({
@@ -265,7 +269,9 @@ async function makeLendingPoolConfigureBankOracleIx(mfProgram, accounts, args, r
265
269
  }
266
270
  async function makeLendingPoolConfigureBankOracleScopeIx(mfProgram, accounts, args) {
267
271
  const { bank, ...optionalAccounts } = accounts;
268
- return mfProgram.methods.lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex).accounts({ bank }).accountsPartial(optionalAccounts).remainingAccounts([{ pubkey: args.oracle, isSigner: false, isWritable: false }]).instruction();
272
+ return mfProgram.methods.lendingPoolConfigureBankOracleScope(args.oracle, args.entryIndex).accounts({ bank }).accountsPartial(optionalAccounts).remainingAccounts(
273
+ [args.oracle, args.integrationAccount].filter((pubkey) => pubkey !== void 0).map((pubkey) => ({ pubkey, isSigner: false, isWritable: false }))
274
+ ).instruction();
269
275
  }
270
276
  async function makeLendingPoolSetOraclePriceIx(mfProgram, accounts, args, remainingAccounts = []) {
271
277
  const { bank, ...optionalAccounts } = accounts;
@@ -321,6 +327,22 @@ async function makePulseHealthIx(mfProgram, accounts, remainingAccounts = []) {
321
327
  group: accounts.group
322
328
  }).remainingAccounts(remainingAccounts).instruction();
323
329
  }
330
+ async function makePlaceOrderIx(mfProgram, accounts, args, remainingAccounts = []) {
331
+ const { marginfiAccount, feePayer, authority, order, globalFeeWallet, ...optionalAccounts } = accounts;
332
+ return mfProgram.methods.marginfiAccountPlaceOrder(args.bankKeys, args.trigger).accounts({
333
+ marginfiAccount,
334
+ feePayer,
335
+ order
336
+ }).accountsPartial({ authority, globalFeeWallet, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
337
+ }
338
+ async function makeCloseOrderIx(mfProgram, accounts, remainingAccounts = []) {
339
+ const { marginfiAccount, authority, order, feeRecipient, ...optionalAccounts } = accounts;
340
+ return mfProgram.methods.marginfiAccountCloseOrder().accounts({
341
+ authority,
342
+ order,
343
+ feeRecipient
344
+ }).accountsPartial({ marginfiAccount, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
345
+ }
324
346
  var instructions = {
325
347
  makeDepositIx,
326
348
  makeJuplendDepositIx,
@@ -337,6 +359,7 @@ var instructions = {
337
359
  makeLendingAccountLiquidateIx,
338
360
  makePoolAddBankIx,
339
361
  makePoolConfigureBankIx,
362
+ makePoolConfigureBankGovIx,
340
363
  makeBeginFlashLoanIx,
341
364
  makeEndFlashLoanIx,
342
365
  makeAccountTransferToNewAccountIx,
@@ -346,7 +369,9 @@ var instructions = {
346
369
  makeLendingPoolConfigureBankOracleIx,
347
370
  makeLendingPoolConfigureBankOracleScopeIx,
348
371
  makeLendingPoolSetOraclePriceIx,
349
- makePulseHealthIx
372
+ makePulseHealthIx,
373
+ makePlaceOrderIx,
374
+ makeCloseOrderIx
350
375
  };
351
376
  var instructions_default = instructions;
352
377