Options
All
  • Public
  • Public/Protected
  • All
Menu

@blockworks-foundation/mango-client

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Properties

Variables

Functions

Type aliases

BlockhashTimes

BlockhashTimes: { blockhash: string; timestamp: number }

Type declaration

  • blockhash: string
  • timestamp: number

Cluster

Cluster: "devnet" | "mainnet" | "localnet" | "testnet"

MarketKind

MarketKind: "spot" | "perp"

Payer

Payer: Adapter | Keypair | WalletAdapter

PerpOrderType

PerpOrderType: "limit" | "ioc" | "postOnly" | "market" | "postOnlySlide"

Properties

IDL

IDL: { events: { fields: ({ index: boolean; name: string; type: string } | { index: boolean; name: string; type: { vec: string } })[]; name: string }[]; instructions: never[]; name: string; version: string }

Type declaration

  • events: { fields: ({ index: boolean; name: string; type: string } | { index: boolean; name: string; type: { vec: string } })[]; name: string }[]
  • instructions: never[]
  • name: string
  • version: string

IDS

IDS: { cluster_urls: { devnet: string; localnet: string; mainnet: string; testnet: string }; groups: { cluster: string; mangoProgramId: string; name: string; oracles: { publicKey: string; symbol: string }[]; perpMarkets: { asksKey: string; baseDecimals: number; baseSymbol: string; bidsKey: string; eventsKey: string; marketIndex: number; name: string; publicKey: string; quoteDecimals: number }[]; publicKey: string; quoteSymbol: string; serumProgramId: string; spotMarkets: { asksKey: string; baseDecimals: number; baseSymbol: string; bidsKey: string; eventsKey: string; marketIndex: number; name: string; publicKey: string; quoteDecimals: number }[]; tokens: { decimals: number; mintKey: string; nodeKeys: string[]; rootKey: string; symbol: string }[] }[] }

Type declaration

  • cluster_urls: { devnet: string; localnet: string; mainnet: string; testnet: string }
    • devnet: string
    • localnet: string
    • mainnet: string
    • testnet: string
  • groups: { cluster: string; mangoProgramId: string; name: string; oracles: { publicKey: string; symbol: string }[]; perpMarkets: { asksKey: string; baseDecimals: number; baseSymbol: string; bidsKey: string; eventsKey: string; marketIndex: number; name: string; publicKey: string; quoteDecimals: number }[]; publicKey: string; quoteSymbol: string; serumProgramId: string; spotMarkets: { asksKey: string; baseDecimals: number; baseSymbol: string; bidsKey: string; eventsKey: string; marketIndex: number; name: string; publicKey: string; quoteDecimals: number }[]; tokens: { decimals: number; mintKey: string; nodeKeys: string[]; rootKey: string; symbol: string }[] }[]

Variables

AdvancedOrdersLayout

AdvancedOrdersLayout: any = ...

CENTIBPS_PER_UNIT

CENTIBPS_PER_UNIT: 1000000 = 1_000_000

FREE_ORDER_SLOT

FREE_ORDER_SLOT: 255 = 255

INFO_LEN

INFO_LEN: 32 = 32

MAXIMUM_NUMBER_OF_BLOCKS_FOR_TRANSACTION

MAXIMUM_NUMBER_OF_BLOCKS_FOR_TRANSACTION: 152 = 152

If transaction is not confirmed by validators in 152 blocks from signing by the wallet it will never reach blockchain and is considered a timeout

(e.g. transaction is signed at 121398019 block if its not confirmed by the time blockchain reach 121398171 (121398019 + 152) it will never reach blockchain)

MAX_NODE_BANKS

MAX_NODE_BANKS: 8 = 8

MAX_NUM_IN_MARGIN_BASKET

MAX_NUM_IN_MARGIN_BASKET: 9 = 9

MAX_PAIRS

MAX_PAIRS: number = ...

MAX_PERP_OPEN_ORDERS

MAX_PERP_OPEN_ORDERS: 64 = 64

MAX_TOKENS

MAX_TOKENS: 16 = 16

MangoInstructionLayout

MangoInstructionLayout: MangoInstructionsUnion = ...

QUOTE_INDEX

QUOTE_INDEX: number = ...

delistedOracles

delistedOracles: { marketIndex: number; publicKey: PublicKey; symbol: string }[] = ...

delistedPerpMarkets

delistedPerpMarkets: { baseDecimals: number; baseSymbol: string; marketIndex: number; name: string; publicKey: PublicKey; quoteDecimals: number }[] = ...

delistedSpotMarkets

delistedSpotMarkets: { baseDecimals: number; baseSymbol: string; marketIndex: number; name: string; publicKey: PublicKey }[] = ...

delistedTokens

delistedTokens: { decimals: number; mintKey: PublicKey; symbol: string }[] = ...

mngoMints

mngoMints: { devnet: PublicKey; mainnet: PublicKey; testnet: PublicKey } = ...

Type declaration

msrmMints

msrmMints: { devnet: PublicKey; localnet: PublicKey; mainnet: PublicKey; testnet: PublicKey } = ...

Type declaration

Functions

advancedOrderTypeLayout

  • advancedOrderTypeLayout(property: any, span: any): EnumLayout

awaitTransactionSignatureConfirmation

  • awaitTransactionSignatureConfirmation(txid: string, timeout: number, connection: Connection, confirmLevel: TransactionConfirmationStatus, signedAtBlock?: Readonly<{ blockhash: string; lastValidBlockHeight: number }>): Promise<unknown>
  • Parameters

    • txid: string
    • timeout: number
    • connection: Connection
    • confirmLevel: TransactionConfirmationStatus
    • Optional signedAtBlock: Readonly<{ blockhash: string; lastValidBlockHeight: number }>

    Returns Promise<unknown>

calculateLotSizes

  • calculateLotSizes(baseDecimals: number, quoteDecimals: number, minTick: number, minSize: number): { baseLotSize: BN; quoteLotSize: BN }
  • Calculate the base lot size and quote lot size given a desired min tick and min size in the UI

    Parameters

    • baseDecimals: number
    • quoteDecimals: number
    • minTick: number
    • minSize: number

    Returns { baseLotSize: BN; quoteLotSize: BN }

    • baseLotSize: BN
    • quoteLotSize: BN

clamp

  • clamp(x: number, min: number, max: number): number

createAccountInstruction

  • createAccountInstruction(connection: Connection, payer: PublicKey, space: number, owner: PublicKey, lamports?: number): Promise<{ account: Keypair; instruction: TransactionInstruction }>
  • Parameters

    • connection: Connection
    • payer: PublicKey
    • space: number
    • owner: PublicKey
    • Optional lamports: number

    Returns Promise<{ account: Keypair; instruction: TransactionInstruction }>

createSignerKeyAndNonce

createTokenAccountInstructions

findLargestTokenAccountForOwner

findPerpMarketParams

  • findPerpMarketParams(nativeBaseDecimals: number, quoteDecimals: number, oraclePrice: number, leverage: number, mngoPerHour: number): { baseDecimals: number; baseLotSize: number; decimals: number; exp: number; initLeverage: number; liquidationFee: number; lmSizeShift: number; maintLeverage: number; makerFee: number; maxDepthBps: number; maxNumEvents: number; minSize: number; minTick: number; mngoPerPeriod: number; quoteLotSize: number; rate: number; takerFee: number; targetPeriodLength: number; version: number }
  • Return some standard params for a new perp market oraclePrice is the current oracle price for the perp market being added Assumes a rate 1000 MNGO per hour for 500k liquidity rewarded nativeBaseDecimals are the decimals for the asset on the native chain

    Parameters

    • nativeBaseDecimals: number
    • quoteDecimals: number
    • oraclePrice: number
    • leverage: number
    • mngoPerHour: number

    Returns { baseDecimals: number; baseLotSize: number; decimals: number; exp: number; initLeverage: number; liquidationFee: number; lmSizeShift: number; maintLeverage: number; makerFee: number; maxDepthBps: number; maxNumEvents: number; minSize: number; minTick: number; mngoPerPeriod: number; quoteLotSize: number; rate: number; takerFee: number; targetPeriodLength: number; version: number }

    • baseDecimals: number
    • baseLotSize: number
    • decimals: number
    • exp: number
    • initLeverage: number
    • liquidationFee: number
    • lmSizeShift: number
    • maintLeverage: number
    • makerFee: number
    • maxDepthBps: number
    • maxNumEvents: number
    • minSize: number
    • minTick: number
    • mngoPerPeriod: number
    • quoteLotSize: number
    • rate: number
    • takerFee: number
    • targetPeriodLength: number
    • version: number

getAllMarkets

getFilteredProgramAccounts

  • getFilteredProgramAccounts(connection: Connection, programId: PublicKey, filters: any): Promise<{ accountInfo: AccountInfo<Buffer>; publicKey: PublicKey }[]>

getMarketByBaseSymbolAndKind

getMarketByPublicKey

getMarketIndexBySymbol

  • getMarketIndexBySymbol(group: GroupConfig, symbol: string): number

getMultipleAccounts

  • getMultipleAccounts(connection: Connection, publicKeys: PublicKey[], commitment?: Commitment): Promise<{ accountInfo: AccountInfo<Buffer>; context: { slot: number }; publicKey: PublicKey }[]>
  • Parameters

    • connection: Connection
    • publicKeys: PublicKey[]
    • Optional commitment: Commitment

    Returns Promise<{ accountInfo: AccountInfo<Buffer>; context: { slot: number }; publicKey: PublicKey }[]>

getOracleBySymbol

getOracleConfig

getPerpMarketByBaseSymbol

getPerpMarketByIndex

getPerpMarketConfig

getPriceFromKey

  • getPriceFromKey(key: BN): BN

getSpotMarketByBaseSymbol

getSpotMarketConfig

getTokenAccountsByOwnerWithWrappedSol

getTokenByMint

getTokenBySymbol

getTokenConfig

Const getUnixTs

  • getUnixTs(): number
  • Get the current epoch timestamp in seconds with microsecond precision

    Returns number

getWeights

  • getWeights(mangoGroup: MangoGroup, marketIndex: number, healthType?: HealthType): { perpAssetWeight: I80F48; perpLiabWeight: I80F48; spotAssetWeight: I80F48; spotLiabWeight: I80F48 }
  • Return weights corresponding to health type; Weights are all 1 if no healthType provided

    Parameters

    • mangoGroup: MangoGroup
    • marketIndex: number
    • Optional healthType: HealthType

    Returns { perpAssetWeight: I80F48; perpLiabWeight: I80F48; spotAssetWeight: I80F48; spotLiabWeight: I80F48 }

nativeI80F48ToUi

nativeToUi

  • nativeToUi(amount: number, decimals: number): number

optionalBNFromString

  • optionalBNFromString(x?: string): BN | undefined

Const prependFeePrioritizationIx

  • prependFeePrioritizationIx(transaction: any, prioritizationFee: any): any

simulateTransaction

  • simulateTransaction(connection: Connection, transaction: Transaction, commitment: Commitment): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>
  • Parameters

    • connection: Connection
    • transaction: Transaction
    • commitment: Commitment

    Returns Promise<RpcResponseAndContext<SimulatedTransactionResponse>>

sleep

  • sleep(ms: any): Promise<unknown>

splitOpenOrders

  • splitOpenOrders(openOrders: OpenOrders): { baseFree: I80F48; baseLocked: I80F48; quoteFree: I80F48; quoteLocked: I80F48 }

triggerConditionLayout

  • triggerConditionLayout(property: any, span: any): EnumLayout

uiToNative

  • uiToNative(amount: number, decimals: number): BN

Generated using TypeDoc