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

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/index.d.cts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as superstruct from 'superstruct';
2
2
  import { Infer } from 'superstruct';
3
- import { R as RiskTier, A as AssetTag, B as BankConfigFlag, O as OperationalState, a as OracleSetup, E as EmodeTag, b as EmodeEntryFlags, c as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, d as OperationalStateRaw, e as OracleSetupRaw, f as RiskTierRaw, M as MarginfiProgram, g as BankConfigOpt, h as InterestRateConfig, i as BankConfigType, j as BankConfigRaw, k as BankConfigOptRaw, l as BankType, m as EmodeSettingsType, n as BankRaw, o as EmodeSettingsRaw, p as MarginfiIdlType, q as OraclePrice, P as PriceWithConfidence, r as PriceBias, s as OraclePriceDto, H as HealthCacheFlags, t as HealthCacheStatus, u as AccountFlags, v as MarginfiAccountType, w as Amount, x as BankIntegrationMetadataMap, T as TypedAmount, y as BalanceType, z as HealthCacheType, C as EmodePair, D as ActiveEmodePair, F as ActionEmodeImpact, G as MarginRequirementType, J as EmodeImpactStatus, K as BankVaultType, L as BankIntegrationMetadataMapDto, N as BankIntegrationMetadataDto, Q as BankIntegrationMetadata, S as Bank, U as Environment, V as Project0Config, X as MintData } from './types-ZvnTjjh4.cjs';
4
- export { at as AccountType, ay as AmountType, as as BankAddress, Y as BankConfig, _ as BankConfigCompactRaw, av as BankMap, ar as BankMetadata, $ as BankMetadataRaw, ak as ComputeAssetUsdValueParams, ai as ComputeLiabilityUsdValueParams, ag as ComputeUsdValueParams, a4 as EmodeConfigRaw, a7 as EmodeEntry, a9 as EmodeImpact, Z as EmodeSettings, ab as GetAssetWeightParams, a1 as InterestRateConfigCompactRaw, a6 as InterestRateConfigOpt, a2 as InterestRateConfigOptRaw, au as KaminoStates, ao as MARGINFI_IDL, ax as MintDataMap, a8 as OracleConfigOpt, a3 as OracleConfigOptRaw, aw as OraclePriceMap, an as PriceWithConfidenceDto, ap as Program, a5 as RatePoint, a0 as RatePointRaw, aq as Wallet, al as computeAssetUsdValue, aj as computeLiabilityUsdValue, af as computeLoopingParams, ae as computeMaxLeverage, am as computeTvl, ah as computeUsdValue, ac as getAssetWeight, ad as getLiabilityWeight, aa as isWeightedPrice, az as resolveAmount } from './types-ZvnTjjh4.cjs';
3
+ import { R as RiskTier, A as AssetTag, b as BankConfigFlag, O as OperationalState, c as OracleSetup, E as EmodeTag, d as EmodeEntryFlags, e as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, f as OperationalStateRaw, g as OracleSetupRaw, h as RiskTierRaw, M as MarginfiProgram, i as BankConfigOpt, j as InterestRateConfig, k as BankConfigType, l as BankConfigRaw, a as BankConfigOptRaw, m as BankType, n as EmodeSettingsType, o as BankRaw, p as EmodeSettingsRaw, q as MarginfiIdlType, r as OraclePrice, P as PriceWithConfidence, s as PriceBias, t as OraclePriceDto, H as HealthCacheFlags, u as HealthCacheStatus, v as AccountFlags, w as MarginfiAccountType, x as Amount, y as BankIntegrationMetadataMap, T as TypedAmount, z as BalanceType, C as HealthCacheType, D as EmodePair, F as ActiveEmodePair, G as ActionEmodeImpact, J as MarginRequirementType, K as EmodeImpactStatus, L as BankVaultType, N as BankIntegrationMetadataMapDto, Q as BankIntegrationMetadataDto, S as BankIntegrationMetadata, U as Bank, V as Environment, X as Project0Config, Y as MintData } from './types-CsLjciLo.cjs';
4
+ export { at as AccountType, ay as AmountType, as as BankAddress, Z as BankConfig, B as BankConfigCompactRaw, av as BankMap, ar as BankMetadata, $ as BankMetadataRaw, ak as ComputeAssetUsdValueParams, ai as ComputeLiabilityUsdValueParams, ag as ComputeUsdValueParams, a4 as EmodeConfigRaw, a7 as EmodeEntry, a9 as EmodeImpact, _ as EmodeSettings, ab as GetAssetWeightParams, a1 as InterestRateConfigCompactRaw, a6 as InterestRateConfigOpt, a2 as InterestRateConfigOptRaw, au as KaminoStates, ao as MARGINFI_IDL, ax as MintDataMap, a8 as OracleConfigOpt, a3 as OracleConfigOptRaw, aw as OraclePriceMap, an as PriceWithConfidenceDto, ap as Program, a5 as RatePoint, a0 as RatePointRaw, aq as Wallet, al as computeAssetUsdValue, aj as computeLiabilityUsdValue, af as computeLoopingParams, ae as computeMaxLeverage, am as computeTvl, ah as computeUsdValue, ac as getAssetWeight, ad as getLiabilityWeight, aa as isWeightedPrice, az as resolveAmount } from './types-CsLjciLo.cjs';
5
5
  import * as _solana_web3_js from '@solana/web3.js';
6
6
  import { VersionedTransaction, Transaction, PublicKey, TransactionError, TransactionInstruction, Keypair, Signer, AddressLookupTableAccount, Blockhash, TransactionMessage, Connection, AccountInfo } from '@solana/web3.js';
7
7
  import { Idl, Instruction, AnchorProvider, Address } from '@coral-xyz/anchor';
8
8
  import BN from 'bn.js';
9
9
  import BigNumber$1 from 'bignumber.js';
10
- import { R as ReserveRaw, D as DriftSpotMarket, a as DriftRewards, J as JupLendingState, b as ReserveJSON, O as ObligationJSON, F as FarmStateJSON, c as ObligationRaw, d as FarmStateRaw, e as DriftSpotMarketJSON, f as DriftUserJSON, g as DriftRewardsJSON, h as DriftUserStatsJSON, i as DriftUser, j as DriftUserStats, k as JupLendingStateJSON, l as JupTokenReserveJSON, m as JupLendingRewardsRateModelJSON, n as JupRateModelJSON, o as JupTokenReserve, p as JupLendingRewardsRateModel, q as JupRateModel } from './dto-rate-model.types-AQ40wS-P.cjs';
11
- import { ConfigurationParameters, QuoteGetRequest, QuoteResponse } from '@jup-ag/api';
10
+ import { R as ReserveRaw, D as DriftSpotMarket, b as DriftRewards, J as JupLendingState, g as ReserveJSON, h as ObligationJSON, i as FarmStateJSON, O as ObligationRaw, F as FarmStateRaw, j as DriftSpotMarketJSON, k as DriftUserJSON, l as DriftRewardsJSON, m as DriftUserStatsJSON, a as DriftUser, c as DriftUserStats, n as JupLendingStateJSON, o as JupTokenReserveJSON, p as JupLendingRewardsRateModelJSON, q as JupRateModelJSON, d as JupTokenReserve, e as JupLendingRewardsRateModel, f as JupRateModel } from './dto-rate-model.types-DveIB9Ll.cjs';
11
+ import { JupiterClientConfig, QuoteGetRequest, QuoteResponse } from './jupiter.cjs';
12
12
  import { F as FeedResponse } from './index-BDDVBMdM.cjs';
13
13
 
14
14
  interface RpcSimulateBundleTransactionResult {
@@ -1014,10 +1014,10 @@ interface MakeAccountTransferToNewAccountTxParams {
1014
1014
  newMarginfiAccount: Signer;
1015
1015
  /** The wallet that will own the new account. */
1016
1016
  newAuthority: PublicKey;
1017
- /** Pays rent/fees the connected wallet, or a separate fee payer. */
1018
- feePayer: PublicKey;
1019
- /** Required only when `feePayer` is a separate keypair (not the connected wallet). */
1020
- feePayerKeypair?: Signer;
1017
+ /** Optional. Pays rent/fees. A `PublicKey` signs via the wallet adapter; a
1018
+ * `Keypair` is a separate fee payer that signs directly. Defaults to the
1019
+ * account's current authority. */
1020
+ feePayer?: PublicKey | Keypair;
1021
1021
  }
1022
1022
  interface TransactionBuilderResult {
1023
1023
  transactions: SolanaTransaction[];
@@ -2383,7 +2383,7 @@ interface ComputeMaxWithdrawForBankParams {
2383
2383
  */
2384
2384
  declare function computeMaxWithdrawForBank(params: ComputeMaxWithdrawForBankParams): BigNumber$1;
2385
2385
 
2386
- declare function toJupiterConfig(apiConfig?: SwapApiConfig): ConfigurationParameters | undefined;
2386
+ declare function toJupiterConfig(apiConfig?: SwapApiConfig): JupiterClientConfig | undefined;
2387
2387
  type GetJupiterSwapIxsForFlashloanParams = {
2388
2388
  quoteParams: QuoteGetRequest;
2389
2389
  authority: PublicKey;
@@ -2613,11 +2613,12 @@ declare function makeCloseMarginfiAccountTx({ connection, program, marginfiAccou
2613
2613
  * @param params.marginfiAccount - The account being transferred
2614
2614
  * @param params.newMarginfiAccount - Freshly generated keypair for the destination account
2615
2615
  * @param params.newAuthority - The wallet that will own the new account
2616
- * @param params.feePayer - Pays rent/fees (the connected wallet, or a separate fee payer)
2617
- * @param params.feePayerKeypair - Required only when `feePayer` is a separate keypair
2616
+ * @param params.feePayer - Optional. Pays rent/fees. A `PublicKey` signs via the
2617
+ * wallet adapter; a `Keypair` is a separate fee payer that signs directly.
2618
+ * Defaults to the account's current authority.
2618
2619
  * @returns Versioned transaction to transfer the account
2619
2620
  */
2620
- declare function makeAccountTransferToNewAccountTx({ connection, program, marginfiAccount, newMarginfiAccount, newAuthority, feePayer, feePayerKeypair, }: MakeAccountTransferToNewAccountTxParams): Promise<SolanaTransaction>;
2621
+ declare function makeAccountTransferToNewAccountTx({ connection, program, marginfiAccount, newMarginfiAccount, newAuthority, feePayer, }: MakeAccountTransferToNewAccountTxParams): Promise<ExtendedV0Transaction>;
2621
2622
  /**
2622
2623
  * Creates a new Marginfi account transaction with a projected account instance.
2623
2624
  *
@@ -4681,19 +4682,21 @@ declare class MarginfiAccount implements MarginfiAccountType {
4681
4682
  */
4682
4683
  makeEndFlashLoanIx(program: MarginfiProgram, bankMap: Map<string, Bank>, projectedActiveBanks: PublicKey[], authority?: PublicKey): Promise<InstructionsWrapper>;
4683
4684
  /**
4684
- * Creates an instruction to transfer this account to a new authority.
4685
+ * Builds a transaction to transfer this account to a new authority.
4685
4686
  *
4686
- * Transfers ownership of the marginfi account to a new authority and account address.
4687
+ * Thin wrapper over the {@link makeAccountTransferToNewAccountTx} action,
4688
+ * injecting the connection and this account from context. The global fee
4689
+ * wallet is derived inside the action from the program's fee state.
4687
4690
  *
4688
4691
  * @param program - The Marginfi program instance
4689
- * @param newMarginfiAccount - The new marginfi account public key
4692
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
4690
4693
  * @param newAuthority - The new authority public key
4694
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
4695
+ * payer); defaults to this account's authority
4691
4696
  *
4692
- * @returns Promise resolving to InstructionsWrapper containing the transfer instruction
4693
- *
4694
- * @see {@link makeAccountTransferToNewAccountIx} for implementation
4697
+ * @returns Promise resolving to the transfer transaction
4695
4698
  */
4696
- makeAccountTransferToNewAccountIx(program: MarginfiProgram, newMarginfiAccount: PublicKey, newAuthority: PublicKey, globalFeeWallet: PublicKey, feePayer: PublicKey): Promise<InstructionsWrapper>;
4699
+ makeAccountTransferToNewAccountTx(program: MarginfiProgram, newMarginfiAccount: Keypair, newAuthority: PublicKey, feePayer?: PublicKey | Keypair): Promise<ExtendedV0Transaction>;
4697
4700
  /**
4698
4701
  * Creates an instruction to close this marginfi account.
4699
4702
  *
@@ -5172,12 +5175,14 @@ declare class MarginfiAccountWrapper {
5172
5175
  */
5173
5176
  makeEndFlashLoanIx(projectedActiveBanks: PublicKey[], authority?: PublicKey): Promise<InstructionsWrapper>;
5174
5177
  /**
5175
- * Creates an account transfer instruction.
5178
+ * Builds a transaction to transfer this account to a new authority.
5176
5179
  *
5177
- * @param newMarginfiAccount - New account public key
5180
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
5178
5181
  * @param newAuthority - New authority public key
5182
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
5183
+ * payer); defaults to this account's authority
5179
5184
  */
5180
- makeAccountTransferToNewAccountIx(newMarginfiAccount: PublicKey, newAuthority: PublicKey, globalFeeWallet: PublicKey, feePayer: PublicKey): Promise<InstructionsWrapper>;
5185
+ makeAccountTransferToNewAccountTx(newMarginfiAccount: Keypair, newAuthority: PublicKey, feePayer?: PublicKey | Keypair): Promise<ExtendedV0Transaction>;
5181
5186
  /**
5182
5187
  * Creates a close account instruction.
5183
5188
  */
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as superstruct from 'superstruct';
2
2
  import { Infer } from 'superstruct';
3
- import { R as RiskTier, A as AssetTag, B as BankConfigFlag, O as OperationalState, a as OracleSetup, E as EmodeTag, b as EmodeEntryFlags, c as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, d as OperationalStateRaw, e as OracleSetupRaw, f as RiskTierRaw, M as MarginfiProgram, g as BankConfigOpt, h as InterestRateConfig, i as BankConfigType, j as BankConfigRaw, k as BankConfigOptRaw, l as BankType, m as EmodeSettingsType, n as BankRaw, o as EmodeSettingsRaw, p as MarginfiIdlType, q as OraclePrice, P as PriceWithConfidence, r as PriceBias, s as OraclePriceDto, H as HealthCacheFlags, t as HealthCacheStatus, u as AccountFlags, v as MarginfiAccountType, w as Amount, x as BankIntegrationMetadataMap, T as TypedAmount, y as BalanceType, z as HealthCacheType, C as EmodePair, D as ActiveEmodePair, F as ActionEmodeImpact, G as MarginRequirementType, J as EmodeImpactStatus, K as BankVaultType, L as BankIntegrationMetadataMapDto, N as BankIntegrationMetadataDto, Q as BankIntegrationMetadata, S as Bank, U as Environment, V as Project0Config, X as MintData } from './types-DGWxbPM1.js';
4
- export { at as AccountType, ay as AmountType, as as BankAddress, Y as BankConfig, _ as BankConfigCompactRaw, av as BankMap, ar as BankMetadata, $ as BankMetadataRaw, ak as ComputeAssetUsdValueParams, ai as ComputeLiabilityUsdValueParams, ag as ComputeUsdValueParams, a4 as EmodeConfigRaw, a7 as EmodeEntry, a9 as EmodeImpact, Z as EmodeSettings, ab as GetAssetWeightParams, a1 as InterestRateConfigCompactRaw, a6 as InterestRateConfigOpt, a2 as InterestRateConfigOptRaw, au as KaminoStates, ao as MARGINFI_IDL, ax as MintDataMap, a8 as OracleConfigOpt, a3 as OracleConfigOptRaw, aw as OraclePriceMap, an as PriceWithConfidenceDto, ap as Program, a5 as RatePoint, a0 as RatePointRaw, aq as Wallet, al as computeAssetUsdValue, aj as computeLiabilityUsdValue, af as computeLoopingParams, ae as computeMaxLeverage, am as computeTvl, ah as computeUsdValue, ac as getAssetWeight, ad as getLiabilityWeight, aa as isWeightedPrice, az as resolveAmount } from './types-DGWxbPM1.js';
3
+ import { R as RiskTier, A as AssetTag, b as BankConfigFlag, O as OperationalState, c as OracleSetup, E as EmodeTag, d as EmodeEntryFlags, e as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, f as OperationalStateRaw, g as OracleSetupRaw, h as RiskTierRaw, M as MarginfiProgram, i as BankConfigOpt, j as InterestRateConfig, k as BankConfigType, l as BankConfigRaw, a as BankConfigOptRaw, m as BankType, n as EmodeSettingsType, o as BankRaw, p as EmodeSettingsRaw, q as MarginfiIdlType, r as OraclePrice, P as PriceWithConfidence, s as PriceBias, t as OraclePriceDto, H as HealthCacheFlags, u as HealthCacheStatus, v as AccountFlags, w as MarginfiAccountType, x as Amount, y as BankIntegrationMetadataMap, T as TypedAmount, z as BalanceType, C as HealthCacheType, D as EmodePair, F as ActiveEmodePair, G as ActionEmodeImpact, J as MarginRequirementType, K as EmodeImpactStatus, L as BankVaultType, N as BankIntegrationMetadataMapDto, Q as BankIntegrationMetadataDto, S as BankIntegrationMetadata, U as Bank, V as Environment, X as Project0Config, Y as MintData } from './types-DuCxJVOn.js';
4
+ export { at as AccountType, ay as AmountType, as as BankAddress, Z as BankConfig, B as BankConfigCompactRaw, av as BankMap, ar as BankMetadata, $ as BankMetadataRaw, ak as ComputeAssetUsdValueParams, ai as ComputeLiabilityUsdValueParams, ag as ComputeUsdValueParams, a4 as EmodeConfigRaw, a7 as EmodeEntry, a9 as EmodeImpact, _ as EmodeSettings, ab as GetAssetWeightParams, a1 as InterestRateConfigCompactRaw, a6 as InterestRateConfigOpt, a2 as InterestRateConfigOptRaw, au as KaminoStates, ao as MARGINFI_IDL, ax as MintDataMap, a8 as OracleConfigOpt, a3 as OracleConfigOptRaw, aw as OraclePriceMap, an as PriceWithConfidenceDto, ap as Program, a5 as RatePoint, a0 as RatePointRaw, aq as Wallet, al as computeAssetUsdValue, aj as computeLiabilityUsdValue, af as computeLoopingParams, ae as computeMaxLeverage, am as computeTvl, ah as computeUsdValue, ac as getAssetWeight, ad as getLiabilityWeight, aa as isWeightedPrice, az as resolveAmount } from './types-DuCxJVOn.js';
5
5
  import * as _solana_web3_js from '@solana/web3.js';
6
6
  import { VersionedTransaction, Transaction, PublicKey, TransactionError, TransactionInstruction, Keypair, Signer, AddressLookupTableAccount, Blockhash, TransactionMessage, Connection, AccountInfo } from '@solana/web3.js';
7
7
  import { Idl, Instruction, AnchorProvider, Address } from '@coral-xyz/anchor';
8
8
  import BN from 'bn.js';
9
9
  import BigNumber$1 from 'bignumber.js';
10
- import { R as ReserveRaw, D as DriftSpotMarket, a as DriftRewards, J as JupLendingState, b as ReserveJSON, O as ObligationJSON, F as FarmStateJSON, c as ObligationRaw, d as FarmStateRaw, e as DriftSpotMarketJSON, f as DriftUserJSON, g as DriftRewardsJSON, h as DriftUserStatsJSON, i as DriftUser, j as DriftUserStats, k as JupLendingStateJSON, l as JupTokenReserveJSON, m as JupLendingRewardsRateModelJSON, n as JupRateModelJSON, o as JupTokenReserve, p as JupLendingRewardsRateModel, q as JupRateModel } from './dto-rate-model.types-AQ40wS-P.js';
11
- import { ConfigurationParameters, QuoteGetRequest, QuoteResponse } from '@jup-ag/api';
10
+ import { R as ReserveRaw, D as DriftSpotMarket, b as DriftRewards, J as JupLendingState, g as ReserveJSON, h as ObligationJSON, i as FarmStateJSON, O as ObligationRaw, F as FarmStateRaw, j as DriftSpotMarketJSON, k as DriftUserJSON, l as DriftRewardsJSON, m as DriftUserStatsJSON, a as DriftUser, c as DriftUserStats, n as JupLendingStateJSON, o as JupTokenReserveJSON, p as JupLendingRewardsRateModelJSON, q as JupRateModelJSON, d as JupTokenReserve, e as JupLendingRewardsRateModel, f as JupRateModel } from './dto-rate-model.types-DveIB9Ll.js';
11
+ import { JupiterClientConfig, QuoteGetRequest, QuoteResponse } from './jupiter.js';
12
12
  import { F as FeedResponse } from './index-BDDVBMdM.js';
13
13
 
14
14
  interface RpcSimulateBundleTransactionResult {
@@ -1014,10 +1014,10 @@ interface MakeAccountTransferToNewAccountTxParams {
1014
1014
  newMarginfiAccount: Signer;
1015
1015
  /** The wallet that will own the new account. */
1016
1016
  newAuthority: PublicKey;
1017
- /** Pays rent/fees the connected wallet, or a separate fee payer. */
1018
- feePayer: PublicKey;
1019
- /** Required only when `feePayer` is a separate keypair (not the connected wallet). */
1020
- feePayerKeypair?: Signer;
1017
+ /** Optional. Pays rent/fees. A `PublicKey` signs via the wallet adapter; a
1018
+ * `Keypair` is a separate fee payer that signs directly. Defaults to the
1019
+ * account's current authority. */
1020
+ feePayer?: PublicKey | Keypair;
1021
1021
  }
1022
1022
  interface TransactionBuilderResult {
1023
1023
  transactions: SolanaTransaction[];
@@ -2383,7 +2383,7 @@ interface ComputeMaxWithdrawForBankParams {
2383
2383
  */
2384
2384
  declare function computeMaxWithdrawForBank(params: ComputeMaxWithdrawForBankParams): BigNumber$1;
2385
2385
 
2386
- declare function toJupiterConfig(apiConfig?: SwapApiConfig): ConfigurationParameters | undefined;
2386
+ declare function toJupiterConfig(apiConfig?: SwapApiConfig): JupiterClientConfig | undefined;
2387
2387
  type GetJupiterSwapIxsForFlashloanParams = {
2388
2388
  quoteParams: QuoteGetRequest;
2389
2389
  authority: PublicKey;
@@ -2613,11 +2613,12 @@ declare function makeCloseMarginfiAccountTx({ connection, program, marginfiAccou
2613
2613
  * @param params.marginfiAccount - The account being transferred
2614
2614
  * @param params.newMarginfiAccount - Freshly generated keypair for the destination account
2615
2615
  * @param params.newAuthority - The wallet that will own the new account
2616
- * @param params.feePayer - Pays rent/fees (the connected wallet, or a separate fee payer)
2617
- * @param params.feePayerKeypair - Required only when `feePayer` is a separate keypair
2616
+ * @param params.feePayer - Optional. Pays rent/fees. A `PublicKey` signs via the
2617
+ * wallet adapter; a `Keypair` is a separate fee payer that signs directly.
2618
+ * Defaults to the account's current authority.
2618
2619
  * @returns Versioned transaction to transfer the account
2619
2620
  */
2620
- declare function makeAccountTransferToNewAccountTx({ connection, program, marginfiAccount, newMarginfiAccount, newAuthority, feePayer, feePayerKeypair, }: MakeAccountTransferToNewAccountTxParams): Promise<SolanaTransaction>;
2621
+ declare function makeAccountTransferToNewAccountTx({ connection, program, marginfiAccount, newMarginfiAccount, newAuthority, feePayer, }: MakeAccountTransferToNewAccountTxParams): Promise<ExtendedV0Transaction>;
2621
2622
  /**
2622
2623
  * Creates a new Marginfi account transaction with a projected account instance.
2623
2624
  *
@@ -4681,19 +4682,21 @@ declare class MarginfiAccount implements MarginfiAccountType {
4681
4682
  */
4682
4683
  makeEndFlashLoanIx(program: MarginfiProgram, bankMap: Map<string, Bank>, projectedActiveBanks: PublicKey[], authority?: PublicKey): Promise<InstructionsWrapper>;
4683
4684
  /**
4684
- * Creates an instruction to transfer this account to a new authority.
4685
+ * Builds a transaction to transfer this account to a new authority.
4685
4686
  *
4686
- * Transfers ownership of the marginfi account to a new authority and account address.
4687
+ * Thin wrapper over the {@link makeAccountTransferToNewAccountTx} action,
4688
+ * injecting the connection and this account from context. The global fee
4689
+ * wallet is derived inside the action from the program's fee state.
4687
4690
  *
4688
4691
  * @param program - The Marginfi program instance
4689
- * @param newMarginfiAccount - The new marginfi account public key
4692
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
4690
4693
  * @param newAuthority - The new authority public key
4694
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
4695
+ * payer); defaults to this account's authority
4691
4696
  *
4692
- * @returns Promise resolving to InstructionsWrapper containing the transfer instruction
4693
- *
4694
- * @see {@link makeAccountTransferToNewAccountIx} for implementation
4697
+ * @returns Promise resolving to the transfer transaction
4695
4698
  */
4696
- makeAccountTransferToNewAccountIx(program: MarginfiProgram, newMarginfiAccount: PublicKey, newAuthority: PublicKey, globalFeeWallet: PublicKey, feePayer: PublicKey): Promise<InstructionsWrapper>;
4699
+ makeAccountTransferToNewAccountTx(program: MarginfiProgram, newMarginfiAccount: Keypair, newAuthority: PublicKey, feePayer?: PublicKey | Keypair): Promise<ExtendedV0Transaction>;
4697
4700
  /**
4698
4701
  * Creates an instruction to close this marginfi account.
4699
4702
  *
@@ -5172,12 +5175,14 @@ declare class MarginfiAccountWrapper {
5172
5175
  */
5173
5176
  makeEndFlashLoanIx(projectedActiveBanks: PublicKey[], authority?: PublicKey): Promise<InstructionsWrapper>;
5174
5177
  /**
5175
- * Creates an account transfer instruction.
5178
+ * Builds a transaction to transfer this account to a new authority.
5176
5179
  *
5177
- * @param newMarginfiAccount - New account public key
5180
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
5178
5181
  * @param newAuthority - New authority public key
5182
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
5183
+ * payer); defaults to this account's authority
5179
5184
  */
5180
- makeAccountTransferToNewAccountIx(newMarginfiAccount: PublicKey, newAuthority: PublicKey, globalFeeWallet: PublicKey, feePayer: PublicKey): Promise<InstructionsWrapper>;
5185
+ makeAccountTransferToNewAccountTx(newMarginfiAccount: Keypair, newAuthority: PublicKey, feePayer?: PublicKey | Keypair): Promise<ExtendedV0Transaction>;
5181
5186
  /**
5182
5187
  * Creates a close account instruction.
5183
5188
  */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PublicKey, SolanaJSONRPCError, ComputeBudgetProgram, SystemProgram, TransactionMessage, VersionedTransaction, Transaction, AddressLookupTableAccount, SYSVAR_RENT_PUBKEY, StakeProgram, TransactionInstruction, LAMPORTS_PER_SOL, Keypair, StakeAuthorizationLayout, SYSVAR_INSTRUCTIONS_PUBKEY, STAKE_CONFIG_ID as STAKE_CONFIG_ID$1 } from '@solana/web3.js';
1
+ import { PublicKey, SolanaJSONRPCError, ComputeBudgetProgram, SystemProgram, TransactionMessage, VersionedTransaction, Keypair, Transaction, AddressLookupTableAccount, SYSVAR_RENT_PUBKEY, StakeProgram, TransactionInstruction, LAMPORTS_PER_SOL, StakeAuthorizationLayout, SYSVAR_INSTRUCTIONS_PUBKEY, STAKE_CONFIG_ID as STAKE_CONFIG_ID$1 } from '@solana/web3.js';
2
2
  import { object, string, enums, array, assert } from 'superstruct';
3
3
  import BigNumber3, { BigNumber } from 'bignumber.js';
4
4
  import BN11, { BN } from 'bn.js';
@@ -12,7 +12,6 @@ import * as borsh from '@coral-xyz/borsh';
12
12
  import { struct as struct$1, bool as bool$1, publicKey as publicKey$1, array as array$1, u64 as u64$1, u8 as u8$1, u32 as u32$1, u128 } from '@coral-xyz/borsh';
13
13
  import WebSocket from 'ws';
14
14
  import { Encoder, Decoder } from '@msgpack/msgpack';
15
- import { SwapApi, Configuration, createJupiterApiClient } from '@jup-ag/api';
16
15
  import { AnchorUtils, PullFeed } from '@switchboard-xyz/on-demand';
17
16
  import { CrossbarClient } from '@switchboard-xyz/common';
18
17
 
@@ -36098,9 +36097,9 @@ async function makeAccountTransferToNewAccountTx({
36098
36097
  marginfiAccount,
36099
36098
  newMarginfiAccount,
36100
36099
  newAuthority,
36101
- feePayer,
36102
- feePayerKeypair
36100
+ feePayer
36103
36101
  }) {
36102
+ const feePayerKey = feePayer instanceof Keypair ? feePayer.publicKey : feePayer ?? marginfiAccount.authority;
36104
36103
  const [feeStateKey] = PublicKey.findProgramAddressSync(
36105
36104
  [Buffer.from("feestate", "utf-8")],
36106
36105
  program.programId
@@ -36111,18 +36110,18 @@ async function makeAccountTransferToNewAccountTx({
36111
36110
  newMarginfiAccount: newMarginfiAccount.publicKey,
36112
36111
  newAuthority,
36113
36112
  globalFeeWallet: feeState.globalFeeWallet,
36114
- feePayer
36113
+ feePayer: feePayerKey
36115
36114
  });
36116
36115
  const {
36117
36116
  value: { blockhash }
36118
36117
  } = await connection.getLatestBlockhashAndContext("confirmed");
36119
36118
  const signers = [newMarginfiAccount];
36120
- if (feePayerKeypair) signers.push(feePayerKeypair);
36119
+ if (feePayer instanceof Keypair) signers.push(feePayer);
36121
36120
  const transferTx = addTransactionMetadata(
36122
36121
  new VersionedTransaction(
36123
36122
  new TransactionMessage({
36124
36123
  instructions: [transferIx],
36125
- payerKey: feePayer,
36124
+ payerKey: feePayerKey,
36126
36125
  recentBlockhash: blockhash
36127
36126
  }).compileToV0Message([])
36128
36127
  ),
@@ -49204,6 +49203,61 @@ function computeMaxWithdrawForBank(params) {
49204
49203
  const maxWithdraw = initUntiedCollateralForBank.div(initWeightedPrice);
49205
49204
  return maxWithdraw;
49206
49205
  }
49206
+
49207
+ // src/vendor/jupiter/client.ts
49208
+ var DEFAULT_BASE_PATH = "https://lite-api.jup.ag/swap/v1";
49209
+ var JupiterApiError = class _JupiterApiError extends Error {
49210
+ status;
49211
+ body;
49212
+ constructor(status, body) {
49213
+ super(`Jupiter API request failed with status ${status}: ${body}`);
49214
+ this.name = "JupiterApiError";
49215
+ Object.setPrototypeOf(this, _JupiterApiError.prototype);
49216
+ this.status = status;
49217
+ this.body = body;
49218
+ }
49219
+ };
49220
+ function buildQuoteSearchParams(request) {
49221
+ const params = new URLSearchParams();
49222
+ for (const [key, value] of Object.entries(request)) {
49223
+ if (value === void 0 || value === null) continue;
49224
+ if (Array.isArray(value)) {
49225
+ if (value.length > 0) params.append(key, value.join(","));
49226
+ continue;
49227
+ }
49228
+ params.append(key, String(value));
49229
+ }
49230
+ return params;
49231
+ }
49232
+ function createJupiterClient(config = {}) {
49233
+ const basePath = (config.basePath ?? DEFAULT_BASE_PATH).replace(/\/+$/, "");
49234
+ const baseHeaders = { ...config.headers };
49235
+ if (config.apiKey) baseHeaders["x-api-key"] = config.apiKey;
49236
+ const request = async (path, init) => {
49237
+ const response = await fetch(`${basePath}${path}`, init);
49238
+ if (!response.ok) {
49239
+ const body = await response.text().catch(() => "");
49240
+ throw new JupiterApiError(response.status, body);
49241
+ }
49242
+ return await response.json();
49243
+ };
49244
+ return {
49245
+ quoteGet(quoteRequest) {
49246
+ const search = buildQuoteSearchParams(quoteRequest);
49247
+ return request(`/quote?${search.toString()}`, {
49248
+ method: "GET",
49249
+ headers: baseHeaders
49250
+ });
49251
+ },
49252
+ swapInstructionsPost({ swapRequest }) {
49253
+ return request(`/swap-instructions`, {
49254
+ method: "POST",
49255
+ headers: { ...baseHeaders, "content-type": "application/json" },
49256
+ body: JSON.stringify(swapRequest)
49257
+ });
49258
+ }
49259
+ };
49260
+ }
49207
49261
  var TITAN_FEE_WALLET = new PublicKey("FEES6XLN7dMz2iBwKab9Hri9Kwc4WJ6TmDAiT4BNhyej");
49208
49262
  var getTitanFeeAccount = (mint) => {
49209
49263
  return getAssociatedTokenAddressSync(mint, TITAN_FEE_WALLET, true);
@@ -49581,15 +49635,17 @@ function getExactOutProviderFn({
49581
49635
  });
49582
49636
  case "JUPITER" /* JUPITER */:
49583
49637
  return async () => {
49584
- const configParams = toJupiterConfig(apiConfig);
49585
- const jupiterApiClient = configParams?.basePath ? new SwapApi(new Configuration(configParams)) : createJupiterApiClient(configParams);
49638
+ const jupiterApiClient = createJupiterClient(toJupiterConfig(apiConfig));
49586
49639
  const estimateQuote = await jupiterApiClient.quoteGet({
49587
49640
  inputMint,
49588
49641
  outputMint,
49589
49642
  amount,
49590
49643
  swapMode: "ExactOut",
49591
49644
  dynamicSlippage: swapOpts.swapConfig ? swapOpts.swapConfig.slippageMode === "DYNAMIC" : true,
49592
- slippageBps: swapOpts.swapConfig?.slippageBps
49645
+ slippageBps: swapOpts.swapConfig?.slippageBps,
49646
+ // Match the bundle-compatible routing used by the executed flashloan
49647
+ // swap so the ExactOut estimate reflects an achievable route.
49648
+ forJitoBundle: true
49593
49649
  });
49594
49650
  const quoteResult = mapJupiterQuoteToSwapQuoteResult(estimateQuote);
49595
49651
  return { otherAmountThreshold: quoteResult.otherAmountThreshold, quoteResult };
@@ -49745,7 +49801,7 @@ function toJupiterConfig(apiConfig) {
49745
49801
  if (!apiConfig) return void 0;
49746
49802
  return {
49747
49803
  basePath: apiConfig.basePath,
49748
- apiKey: apiConfig.apiKey ? () => apiConfig.apiKey : void 0,
49804
+ apiKey: apiConfig.apiKey,
49749
49805
  headers: apiConfig.headers
49750
49806
  };
49751
49807
  }
@@ -49757,8 +49813,7 @@ var getJupiterSwapIxsForFlashloan = async ({
49757
49813
  apiConfig,
49758
49814
  maxSwapAccounts
49759
49815
  }) => {
49760
- const configParams = toJupiterConfig(apiConfig);
49761
- const jupiterApiClient = configParams?.basePath ? new SwapApi(new Configuration(configParams)) : createJupiterApiClient(configParams);
49816
+ const jupiterApiClient = createJupiterClient(toJupiterConfig(apiConfig));
49762
49817
  const feeMint = quoteParams.swapMode === "ExactIn" ? quoteParams.outputMint : quoteParams.inputMint;
49763
49818
  const { feeAccount, hasFeeAccount } = await checkFeeAccount(connection, new PublicKey(feeMint));
49764
49819
  const project0JupiterLut = (await connection.getAddressLookupTable(ADDRESS_LOOKUP_TABLE_FOR_SWAP))?.value;
@@ -49777,7 +49832,10 @@ var getJupiterSwapIxsForFlashloan = async ({
49777
49832
  const maxAccounts = maxSwapAccounts !== void 0 ? maxSwapAccounts - JUPITER_MAX_ACCOUNTS_MARGIN : 40;
49778
49833
  const swapQuote = await jupiterApiClient.quoteGet({
49779
49834
  ...finalQuoteParams,
49780
- maxAccounts
49835
+ maxAccounts,
49836
+ // Flashloan swaps are landed via a Jito bundle, so restrict routing to
49837
+ // bundle-compatible DEXes (excludes e.g. HumidiFi).
49838
+ forJitoBundle: true
49781
49839
  });
49782
49840
  const swapInstructionResponse = await jupiterApiClient.swapInstructionsPost({
49783
49841
  swapRequest: {
@@ -54112,30 +54170,29 @@ var MarginfiAccount = class _MarginfiAccount {
54112
54170
  return makeEndFlashLoanIx3(program, this.address, banks, authority);
54113
54171
  }
54114
54172
  /**
54115
- * Creates an instruction to transfer this account to a new authority.
54173
+ * Builds a transaction to transfer this account to a new authority.
54116
54174
  *
54117
- * Transfers ownership of the marginfi account to a new authority and account address.
54175
+ * Thin wrapper over the {@link makeAccountTransferToNewAccountTx} action,
54176
+ * injecting the connection and this account from context. The global fee
54177
+ * wallet is derived inside the action from the program's fee state.
54118
54178
  *
54119
54179
  * @param program - The Marginfi program instance
54120
- * @param newMarginfiAccount - The new marginfi account public key
54180
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
54121
54181
  * @param newAuthority - The new authority public key
54182
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
54183
+ * payer); defaults to this account's authority
54122
54184
  *
54123
- * @returns Promise resolving to InstructionsWrapper containing the transfer instruction
54124
- *
54125
- * @see {@link makeAccountTransferToNewAccountIx} for implementation
54185
+ * @returns Promise resolving to the transfer transaction
54126
54186
  */
54127
- async makeAccountTransferToNewAccountIx(program, newMarginfiAccount, newAuthority, globalFeeWallet, feePayer) {
54128
- const accountTransferToNewAccountIx = await instructions_default.makeAccountTransferToNewAccountIx(
54187
+ async makeAccountTransferToNewAccountTx(program, newMarginfiAccount, newAuthority, feePayer) {
54188
+ return makeAccountTransferToNewAccountTx({
54189
+ connection: program.provider.connection,
54129
54190
  program,
54130
- {
54131
- oldMarginfiAccount: this.address,
54132
- newMarginfiAccount,
54133
- newAuthority,
54134
- globalFeeWallet,
54135
- feePayer
54136
- }
54137
- );
54138
- return { instructions: [accountTransferToNewAccountIx], keys: [] };
54191
+ marginfiAccount: this,
54192
+ newMarginfiAccount,
54193
+ newAuthority,
54194
+ feePayer
54195
+ });
54139
54196
  }
54140
54197
  /**
54141
54198
  * Creates an instruction to close this marginfi account.
@@ -54783,17 +54840,18 @@ var MarginfiAccountWrapper = class {
54783
54840
  );
54784
54841
  }
54785
54842
  /**
54786
- * Creates an account transfer instruction.
54843
+ * Builds a transaction to transfer this account to a new authority.
54787
54844
  *
54788
- * @param newMarginfiAccount - New account public key
54845
+ * @param newMarginfiAccount - Freshly generated keypair for the destination account
54789
54846
  * @param newAuthority - New authority public key
54847
+ * @param feePayer - Optional `PublicKey` (adapter-signed) or `Keypair` (separate
54848
+ * payer); defaults to this account's authority
54790
54849
  */
54791
- async makeAccountTransferToNewAccountIx(newMarginfiAccount, newAuthority, globalFeeWallet, feePayer) {
54792
- return this.account.makeAccountTransferToNewAccountIx(
54850
+ async makeAccountTransferToNewAccountTx(newMarginfiAccount, newAuthority, feePayer) {
54851
+ return this.account.makeAccountTransferToNewAccountTx(
54793
54852
  this.client.program,
54794
54853
  newMarginfiAccount,
54795
54854
  newAuthority,
54796
- globalFeeWallet,
54797
54855
  feePayer
54798
54856
  );
54799
54857
  }