Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MangoAccount

Index

Constructors

Properties

Methods

Constructors

  • new MangoAccount(publicKey: PublicKey, group: PublicKey, owner: PublicKey, name: number[], delegate: PublicKey, accountNum: number, beingLiquidated: boolean, inHealthRegion: boolean, netDeposits: BN, perpSpotTransfers: BN, healthRegionBeginInitHealth: BN, frozenUntil: BN, buybackFeesAccruedCurrent: BN, buybackFeesAccruedPrevious: BN, buybackFeesExpiryTimestamp: BN, sequenceNumber: number, headerVersion: number, lastCollateralFeeCharge: BN, tokens: TokenPositionDto[], serum3: Serum3PositionDto[], openbookV2: OpenbookV2PositionDto[], perps: PerpPositionDto[], perpOpenOrders: PerpOoDto[], tokenConditionalSwaps: TokenConditionalSwapDto[], serum3OosMapByMarketIndex: Map<number, OpenOrders>, openbookV2OosMapByMarketIndex: Map<number, DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>>): MangoAccount
  • Parameters

    • publicKey: PublicKey
    • group: PublicKey
    • owner: PublicKey
    • name: number[]
    • delegate: PublicKey
    • accountNum: number
    • beingLiquidated: boolean
    • inHealthRegion: boolean
    • netDeposits: BN
    • perpSpotTransfers: BN
    • healthRegionBeginInitHealth: BN
    • frozenUntil: BN
    • buybackFeesAccruedCurrent: BN
    • buybackFeesAccruedPrevious: BN
    • buybackFeesExpiryTimestamp: BN
    • sequenceNumber: number
    • headerVersion: number
    • lastCollateralFeeCharge: BN
    • tokens: TokenPositionDto[]
    • serum3: Serum3PositionDto[]
    • openbookV2: OpenbookV2PositionDto[]
    • perps: PerpPositionDto[]
    • perpOpenOrders: PerpOoDto[]
    • tokenConditionalSwaps: TokenConditionalSwapDto[]
    • serum3OosMapByMarketIndex: Map<number, OpenOrders>
    • openbookV2OosMapByMarketIndex: Map<number, DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>>

    Returns MangoAccount

Properties

accountNum: number
beingLiquidated: boolean
buybackFeesAccruedCurrent: BN
buybackFeesAccruedPrevious: BN
buybackFeesExpiryTimestamp: BN
delegate: PublicKey
frozenUntil: BN
group: PublicKey
headerVersion: number
healthRegionBeginInitHealth: BN
inHealthRegion: boolean
lastCollateralFeeCharge: BN
name: string
netDeposits: BN
openbookV2: OpenbookV2Orders[]
openbookV2OosMapByMarketIndex: Map<number, DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>>
owner: PublicKey
perpOpenOrders: PerpOo[]
perpSpotTransfers: BN
perps: PerpPosition[]
publicKey: PublicKey
sequenceNumber: number
serum3: Serum3Orders[]
serum3OosMapByMarketIndex: Map<number, OpenOrders>
tokenConditionalSwaps: TokenConditionalSwap[]
tokens: TokenPosition[]

Methods

  • calculateEquivalentSourceAmount(sourceBank: Bank, targetBank: Bank, targetRemainingDepositLimit: BN): I80F48
  • getBuybackFeesAccrued(): BN
  • getBuybackFeesAccruedUi(): number
  • getCumulativeInterest(bank: Bank): number
  • Parameters

    Returns number

    token cumulative interest, in native token units. Sum of deposit and borrow interest. Caveat: This will only return cumulative interest since the tokenPosition was last opened. If the tokenPosition was closed and reopened multiple times it is necessary to add this result to cumulative interest at each of the prior tokenPosition closings (from mango API) to get the all time cumulative interest.

  • getHealthContributionPerAssetUi(group: Group, healthType: HealthType): { asset: string; contribution: number; contributionDetails: undefined | { perpMarketContributions: { contributionUi: number; market: string }[]; spotUi: number } }[]
  • getMaxBaseForSerum3AskUi(group: Group, externalMarketPk: PublicKey): number
  • TODO REWORK, know to break in binary search, also make work for limit orders

    Parameters

    • group: Group
    • externalMarketPk: PublicKey

    Returns number

    maximum ui base which can be traded at oracle price for quote token given current health

  • getMaxFeesBuyback(group: Group): BN
  • getMaxFeesBuybackUi(group: Group): number
  • TODO: also think about limit orders

    The max ui quote you can place a market/ioc bid on the market, price is the ui price at which you think the order would materialiase.

    Parameters

    Returns number

    maximum ui quote which can be traded at oracle price for quote token given current health

  • getMaxQuoteForSerum3BidUi(group: Group, externalMarketPk: PublicKey): number
  • TODO REWORK, know to break in binary search, also make work for limit orders

    Parameters

    • group: Group
    • externalMarketPk: PublicKey

    Returns number

    maximum ui quote which can be traded at oracle price for base token given current health

  • getMaxSourceUiForTokenSwap(group: Group, sourceMintPk: PublicKey, targetMintPk: PublicKey, slippageAndFeesFactor?: number): number
  • The max amount of given source ui token you can swap to a target token.

    Parameters

    • group: Group
    • sourceMintPk: PublicKey
    • targetMintPk: PublicKey
    • slippageAndFeesFactor: number = 1

    Returns number

    max amount of given source ui token you can swap to a target token, in ui token

  • getMaxWithdrawWithBorrowForToken(group: Group, mintPk: PublicKey): I80F48
  • The amount of given native token you can withdraw including borrows, considering all existing assets as collateral.

    Parameters

    • group: Group
    • mintPk: PublicKey

    Returns I80F48

    amount of given native token you can borrow, considering all existing assets as collateral, in native token

    TODO: take into account net_borrow_limit and min_vault_to_deposits_ratio TODO: see max_borrow_for_health_fn

  • getMaxWithdrawWithBorrowForTokenUi(group: Group, mintPk: PublicKey): number
  • getOpenbookV2OoAccount(marketIndex: MarketIndex): DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>
  • Parameters

    • marketIndex: MarketIndex

    Returns DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>

  • Parameters

    Returns I80F48

    Overall PNL, in native quote PNL is defined here as spot value + serum3 open orders value + perp value - net deposits value (evaluated at native quote price at the time of the deposit/withdraw) spot value + serum3 open orders value + perp value is returned by getEquity (open orders values are added to spot token values implicitly)

  • getSerum3Account(marketIndex: MarketIndex): undefined | Serum3Orders
  • getSerum3OoAccount(marketIndex: MarketIndex): OpenOrders
  • getTokenBalanceUi(bank: Bank): number
  • getTokenBorrowsUi(bank: Bank): number
  • getTokenDepositsUi(bank: Bank): number
  • isOperational(): boolean
  • loadOpenbookV2OpenOrders(openbookV2OosMapByOo: Map<string, DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>>): void
  • Parameters

    • openbookV2OosMapByOo: Map<string, DecodeStruct<{ fields: [{ name: "owner"; type: "publicKey" }, { name: "market"; type: "publicKey" }, { name: "name"; type: { array: ["u8", 32] } }, { name: "delegate"; type: { defined: "NonZeroPubkeyOption" } }, { name: "accountNum"; type: "u32" }, { name: "bump"; type: "u8" }, { name: "version"; type: "u8" }]; kind: "struct" }, DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], DecodedHelper<[{ docs: ["Like `Option`, but implemented for `Pubkey` to be used with `zero_copy`"]; name: "NonZeroPubkeyOption"; type: { fields: [{ name: "key"; type: "publicKey" }]; kind: "struct" } }, { name: "Position"; type: { fields: [{ docs: ["Base lots in open bids"]; name: "bidsBaseLots"; type: "i64" }, { docs: ["Base lots in open asks"]; name: "asksBaseLots"; type: "i64" }, { name: "baseFreeNative"; type: "u64" }, { name: "quoteFreeNative"; type: "u64" }, { name: "lockedMakerFees"; type: "u64" }]; kind: "struct" } }, { name: "OpenOrder"; type: { fields: [{ name: "id"; type: "u128" }, { name: "clientId"; type: "u64" }, { docs: ["Price at which user's assets were locked"]; name: "lockedPrice"; type: "i64" }, { name: "isFree"; type: "u8" }, { name: "sideAndTree"; type: "u8" }, { name: "padding"; type: { array: ["u8", 6] } }]; kind: "struct" } }], EmptyDefined>>>>

    Returns void

  • loadSerum3OpenOrders(serum3OosMapByOo: Map<string, OpenOrders>): void
  • loadSerum3OpenOrdersAccounts(client: MangoClient): Promise<OpenOrders[]>
  • loadSerum3OpenOrdersForMarket(client: MangoClient, group: Group, externalMarketPk: PublicKey): Promise<Order[]>
  • perpOrderExistsForMarket(perpMarket: PerpMarket): boolean
  • perpPositionExistsForMarket(perpMarket: PerpMarket): boolean
  • simHealthRatioWithSerum3AskUiChanges(group: Group, uiBaseAmount: number, externalMarketPk: PublicKey, healthType?: HealthType): number
  • simHealthRatioWithSerum3BidUiChanges(group: Group, uiQuoteAmount: number, externalMarketPk: PublicKey, healthType?: HealthType): number
  • simHealthRatioWithTokenPositionUiChanges(group: Group, uiTokenChanges: { mintPk: PublicKey; uiTokenAmount: number }[], healthType?: HealthType): number
  • Simulates new health ratio after applying tokenChanges to the token positions. Note: token changes are expected in ui amounts

    e.g. useful to simulate health after a potential swap. Note: health ratio is technically ∞ if liabs are 0

    Parameters

    • group: Group
    • uiTokenChanges: { mintPk: PublicKey; uiTokenAmount: number }[]
    • healthType: HealthType = HealthType.init

    Returns number

    health ratio, in percentage form

  • toString(group?: Group, onlyTokens?: boolean): string
  • from(publicKey: PublicKey, obj: { accountNum: number; beingLiquidated: number; buybackFeesAccruedCurrent: BN; buybackFeesAccruedPrevious: BN; buybackFeesExpiryTimestamp: BN; delegate: PublicKey; frozenUntil: BN; group: PublicKey; headerVersion: number; healthRegionBeginInitHealth: BN; inHealthRegion: number; lastCollateralFeeCharge: BN; name: number[]; netDeposits: BN; openbookV2: unknown; owner: PublicKey; perpOpenOrders: unknown; perpSpotTransfers: BN; perps: unknown; sequenceNumber: number; serum3: unknown; tokenConditionalSwaps: unknown; tokens: unknown }): MangoAccount
  • Parameters

    • publicKey: PublicKey
    • obj: { accountNum: number; beingLiquidated: number; buybackFeesAccruedCurrent: BN; buybackFeesAccruedPrevious: BN; buybackFeesExpiryTimestamp: BN; delegate: PublicKey; frozenUntil: BN; group: PublicKey; headerVersion: number; healthRegionBeginInitHealth: BN; inHealthRegion: number; lastCollateralFeeCharge: BN; name: number[]; netDeposits: BN; openbookV2: unknown; owner: PublicKey; perpOpenOrders: unknown; perpSpotTransfers: BN; perps: unknown; sequenceNumber: number; serum3: unknown; tokenConditionalSwaps: unknown; tokens: unknown }
      • accountNum: number
      • beingLiquidated: number
      • buybackFeesAccruedCurrent: BN
      • buybackFeesAccruedPrevious: BN
      • buybackFeesExpiryTimestamp: BN
      • delegate: PublicKey
      • frozenUntil: BN
      • group: PublicKey
      • headerVersion: number
      • healthRegionBeginInitHealth: BN
      • inHealthRegion: number
      • lastCollateralFeeCharge: BN
      • name: number[]
      • netDeposits: BN
      • openbookV2: unknown
      • owner: PublicKey
      • perpOpenOrders: unknown
      • perpSpotTransfers: BN
      • perps: unknown
      • sequenceNumber: number
      • serum3: unknown
      • tokenConditionalSwaps: unknown
      • tokens: unknown

    Returns MangoAccount

Generated using TypeDoc