Options
All
  • Public
  • Public/Protected
  • All
Menu

Wrapper class around a specific marginfi marginfi account.

Hierarchy

  • MarginfiAccount

Index

Properties

_authority: PublicKey
_borrowRecord: BigNumber
_depositRecord: BigNumber
mango: UtpMangoAccount
observationCache: ObservationCache = ...
publicKey: PublicKey
zo: UtpZoAccount

Accessors

  • get activeUtps(): UtpAccount[]
  • get allUtps(): UtpAccount[]
  • get authority(): PublicKey
  • Marginfi account authority address

    Returns PublicKey

  • get borrows(): BigNumber
  • get deposits(): BigNumber

Methods

  • [customInspectSymbol](_depth: number, _inspectOptions: any, _inspect: any): string
  • Parameters

    • _depth: number
    • _inspectOptions: any
    • _inspect: any

    Returns string

  • canBeLiquidated(): boolean
  • checkBankruptcy(): Promise<void>
  • checkRebalance(): Promise<void>
  • checkRebalanceDeposit(): Promise<void>
  • checkRebalanceWithdraw(): Promise<void>
  • computeMaxRebalanceDepositAmount(utp: UtpAccount): BigNumber
  • computeMaxRebalanceWithdrawAmount(utp: UtpAccount): BigNumber
  • deposit(amount: UiAmount): Promise<string>
  • Deposit collateral into the marginfi account.

    Parameters

    • amount: UiAmount

      Amount to deposit (mint native unit)

    Returns Promise<string>

    Transaction signature

  • getObservationAccounts(): Promise<AccountMeta[]>
  • Create ordered list of account metas required to observe all active UTPs.

    Returns Promise<AccountMeta[]>

    AccountMeta[] list of account metas

  • handleBankruptcy(): Promise<string>
  • Handle a bankrupt account.

    Returns Promise<string>

    Transaction signature

  • isBankrupt(): boolean
  • isRebalanceWithdrawNeeded(): boolean
  • isUtpActive(utpIndex: UtpIndex): boolean
  • loadGroupAndAccountAi(): Promise<AccountInfo<Buffer>[]>
  • makeDepositIx(amount: UiAmount): Promise<TransactionInstruction[]>
  • Create transaction instruction to deposit collateral into the marginfi account.

    Parameters

    • amount: UiAmount

      Amount to deposit (mint native unit)

    Returns Promise<TransactionInstruction[]>

    MarginDepositCollateral transaction instruction

  • makeWithdrawIx(amount: UiAmount): Promise<TransactionInstruction[]>
  • Create transaction instruction to withdraw collateral from the marginfi account.

    Parameters

    • amount: UiAmount

      Amount to withdraw (mint native unit)

    Returns Promise<TransactionInstruction[]>

    MarginWithdrawCollateral transaction instruction

  • Refresh and retrieve the health cache for all active UTPs directly from the UTPs.

    Returns Promise<ObservationCache>

    List of health caches for all active UTPs

  • reload(observeUtps?: boolean): Promise<void>
  • Update instance data by fetching and storing the latest on-chain state.

    Parameters

    • observeUtps: boolean = false

    Returns Promise<void>

  • toString(): string
  • utpFromIndex(utpIndex: UtpIndex): UtpAccount
  • Retrieve the UTP interface instance from its index

    Parameters

    Returns UtpAccount

    UTP interface instance

  • withdraw(amount: UiAmount): Promise<string>
  • Withdraw collateral from the marginfi account.

    Parameters

    • amount: UiAmount

      Amount to withdraw (mint native unit)

    Returns Promise<string>

    Transaction signature

  • Fetch marginfi account data. Check sanity against provided config.

    Parameters

    Returns Promise<MarginfiAccountData>

    Decoded marginfi account data struct

  • Decode marginfi account data according to the Anchor IDL.

    Parameters

    • encoded: Buffer

      Raw data buffer

    Returns MarginfiAccountData

    Decoded marginfi account data struct

  • Decode marginfi account data according to the Anchor IDL.

    Parameters

    Returns Promise<Buffer>

    Raw data buffer

  • MarginfiAccount network factory

    Fetch account data according to the config and instantiate the corresponding MarginfiAccount.

    Parameters

    • marginfiAccountPk: PublicKey

      Address of the target account

    • client: MarginfiClient

      marginfi client

    Returns Promise<MarginfiAccount>

    MarginfiAccount instance

  • MarginfiAccount local factory (decoded)

    Instantiate a MarginfiAccount according to the provided decoded data. Check sanity against provided config.

    Parameters

    Returns MarginfiAccount

    MarginfiAccount instance

  • MarginfiAccount local factory (encoded)

    Instantiate a MarginfiAccount according to the provided encoded data. Check sanity against provided config.

    Parameters

    • marginfiAccountPk: PublicKey

      Address of the target account

    • client: MarginfiClient
    • marginfiAccountRawData: Buffer

      Encoded marginfi marginfi account data

    • marginfiGroup: MarginfiGroup

      MarginfiGroup instance

    Returns MarginfiAccount

    MarginfiAccount instance

Generated using TypeDoc