Options
All
  • Public
  • Public/Protected
  • All
Menu

@bonfida/bot

Index

Type aliases

MarketData

MarketData: { address: PublicKey; asksKey: PublicKey; bidsKey: PublicKey; coinLotSize: Numberu64; coinMintKey: PublicKey; coinVaultKey: PublicKey; eventQueueKey: PublicKey; pcLotSize: Numberu64; pcMintKey: PublicKey; pcVaultKey: PublicKey; reqQueueKey: PublicKey; vaultSignerNonce: Numberu64 }

Type declaration

  • address: PublicKey
  • asksKey: PublicKey
  • bidsKey: PublicKey
  • coinLotSize: Numberu64
  • coinMintKey: PublicKey
  • coinVaultKey: PublicKey
  • eventQueueKey: PublicKey
  • pcLotSize: Numberu64
  • pcMintKey: PublicKey
  • pcVaultKey: PublicKey
  • reqQueueKey: PublicKey
  • vaultSignerNonce: Numberu64

ParsedInstruction

PoolInfo

PoolInfo: { address: PublicKey; assetMintkeys: PublicKey[]; authorizedMarkets: PublicKey[]; feePeriod: Numberu64; feeRatio: Numberu16; mintKey: PublicKey; seed: Uint8Array; serumProgramId: PublicKey; signalProvider: PublicKey; status: PoolStatus }

Type declaration

  • address: PublicKey
  • assetMintkeys: PublicKey[]
  • authorizedMarkets: PublicKey[]
  • feePeriod: Numberu64
  • feeRatio: Numberu16
  • mintKey: PublicKey
  • seed: Uint8Array
  • serumProgramId: PublicKey
  • signalProvider: PublicKey
  • status: PoolStatus

PoolStatus

PoolStatus: [PoolStatusID, number]

Variables

Const ASSOCIATED_TOKEN_PROGRAM_ID

ASSOCIATED_TOKEN_PROGRAM_ID: PublicKey = ...

Const BONFIDABOT_PROGRAM_ID

BONFIDABOT_PROGRAM_ID: PublicKey = ...

Const BONFIDA_BNB_KEY

BONFIDA_BNB_KEY: PublicKey = ...

Const BONFIDA_FEE_KEY

BONFIDA_FEE_KEY: PublicKey = ...

Const ENDPOINTS

ENDPOINTS: { devnet: string; mainnet: string; mainnet2: string } = ...

Type declaration

  • devnet: string
  • mainnet: string
  • mainnet2: string

Const FIDA_KEY

FIDA_KEY: PublicKey = ...

Const PUBKEY_LENGTH

PUBKEY_LENGTH: number = 32

Const PUBLIC_POOLS_SEEDS

PUBLIC_POOLS_SEEDS: PublicKey[] = ...

Const SERUM_PROGRAM_ID

SERUM_PROGRAM_ID: PublicKey = ...

Functions

cancelOrder

  • cancelOrder(connection: Connection, poolSeed: Buffer | Uint8Array, market: PublicKey, openOrdersKey: PublicKey): Promise<TransactionInstruction[]>
  • This method is obsolete for now as all orders can only be passed as ImmediateOrCancel

    Parameters

    • connection: Connection
    • poolSeed: Buffer | Uint8Array
    • market: PublicKey
    • openOrdersKey: PublicKey

    Returns Promise<TransactionInstruction[]>

cancelOrderInstruction

  • cancelOrderInstruction(bonfidaBotProgramId: PublicKey, signalProviderKey: PublicKey, market: PublicKey, openOrdersKey: PublicKey, serumEventQueue: PublicKey, serumMarketBids: PublicKey, serumMarketAsks: PublicKey, poolKey: PublicKey, dexProgramKey: PublicKey, poolSeed: (Buffer | Uint8Array)[], side: OrderSide, orderId: Numberu128): TransactionInstruction
  • Parameters

    • bonfidaBotProgramId: PublicKey
    • signalProviderKey: PublicKey
    • market: PublicKey
    • openOrdersKey: PublicKey
    • serumEventQueue: PublicKey
    • serumMarketBids: PublicKey
    • serumMarketAsks: PublicKey
    • poolKey: PublicKey
    • dexProgramKey: PublicKey
    • poolSeed: (Buffer | Uint8Array)[]
    • side: OrderSide
    • orderId: Numberu128

    Returns TransactionInstruction

collectFees

  • collectFees(connection: Connection, poolSeed: (Buffer | Uint8Array)[]): Promise<TransactionInstruction[]>
  • Returns the solana instructions to collect the fees from the pool. See the readme for the payout destinations. (Permissionless)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • poolSeed: (Buffer | Uint8Array)[]

      The seed of the pool

    Returns Promise<TransactionInstruction[]>

collectFeesInstruction

  • collectFeesInstruction(splTokenProgramId: PublicKey, clockSysvarKey: PublicKey, bonfidaBotProgramId: PublicKey, poolKey: PublicKey, mintKey: PublicKey, signalProviderPoolTokenKey: PublicKey, bonfidaFeePoolTokenKey: PublicKey, bonfidaBnBPTKey: PublicKey, poolSeed: (Buffer | Uint8Array)[]): TransactionInstruction
  • Parameters

    • splTokenProgramId: PublicKey
    • clockSysvarKey: PublicKey
    • bonfidaBotProgramId: PublicKey
    • poolKey: PublicKey
    • mintKey: PublicKey
    • signalProviderPoolTokenKey: PublicKey
    • bonfidaFeePoolTokenKey: PublicKey
    • bonfidaBnBPTKey: PublicKey
    • poolSeed: (Buffer | Uint8Array)[]

    Returns TransactionInstruction

Const createAssociatedTokenAccount

  • createAssociatedTokenAccount(systemProgramId: PublicKey, fundingAddress: PublicKey, walletAddress: PublicKey, splTokenMintAddress: PublicKey): Promise<TransactionInstruction>
  • Parameters

    • systemProgramId: PublicKey
    • fundingAddress: PublicKey
    • walletAddress: PublicKey
    • splTokenMintAddress: PublicKey

    Returns Promise<TransactionInstruction>

createInstruction

  • createInstruction(splTokenProgramId: PublicKey, bonfidaBotProgramId: PublicKey, clockSysvarKey: PublicKey, mintKey: PublicKey, poolKey: PublicKey, poolSeed: (Buffer | Uint8Array)[], poolAssetKeys: PublicKey[], targetPoolTokenKey: PublicKey, sourceOwnerKey: PublicKey, sourceAssetKeys: PublicKey[], serumProgramId: PublicKey, signalProviderKey: PublicKey, depositAmounts: number[], markets: PublicKey[], feeCollectionPeriod: Numberu64, feeRatio: Numberu16): TransactionInstruction
  • Parameters

    • splTokenProgramId: PublicKey
    • bonfidaBotProgramId: PublicKey
    • clockSysvarKey: PublicKey
    • mintKey: PublicKey
    • poolKey: PublicKey
    • poolSeed: (Buffer | Uint8Array)[]
    • poolAssetKeys: PublicKey[]
    • targetPoolTokenKey: PublicKey
    • sourceOwnerKey: PublicKey
    • sourceAssetKeys: PublicKey[]
    • serumProgramId: PublicKey
    • signalProviderKey: PublicKey
    • depositAmounts: number[]
    • markets: PublicKey[]
    • feeCollectionPeriod: Numberu64
    • feeRatio: Numberu16

    Returns TransactionInstruction

createOrder

  • createOrder(connection: Connection, poolSeed: Buffer | Uint8Array, market: PublicKey, side: OrderSide, limitPrice: Numberu64, maxQuantityPercentage: number, orderType: OrderType, clientId: Numberu64, selfTradeBehavior: SelfTradeBehavior, srmDiscountKey: PublicKey | null, payerKey: PublicKey, amountToTrade?: number): Promise<[Account, TransactionInstruction[]]>
  • Returns the solana instructions to create a new serum order for the pool. (Signed by the SignalProvider account of the pool and the OpenOrder Account returned by this function)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • poolSeed: Buffer | Uint8Array

      The seed of the pool that should be traded on

    • market: PublicKey

      The address of the serum market to trade on

    • side: OrderSide

      The side of the order (ask or bid)

    • limitPrice: Numberu64

      The limit price for the order

    • maxQuantityPercentage: number

      The percentage (a number from 0 to 100) of the pool assets that should be invested

    • orderType: OrderType

      For now, all orders are to be set as type ImmediateOrCancel

    • clientId: Numberu64

      The serum clientId for the order, can be set as 0

    • selfTradeBehavior: SelfTradeBehavior

      The serum self trade behaviour for the order

    • srmDiscountKey: PublicKey | null

      The address of the srm discount key for the order (optional)

    • payerKey: PublicKey

      The address of the account that should pay for the allocation fees

    • Optional amountToTrade: number

      If this optional argument is given, it will overwrite the maxQuantityPercentage and fix the size of the order in base quantity. If you want to trade one and a half FIDA on FIDA/USDC for example, give 1.5 as an input here.

    Returns Promise<[Account, TransactionInstruction[]]>

createOrderInstruction

  • createOrderInstruction(bonfidaBotProgramId: PublicKey, signalProviderKey: PublicKey, market: PublicKey, payerPoolAssetKey: PublicKey, payerPoolAssetIndex: Numberu64, targetPoolAssetIndex: Numberu64, openOrdersKey: PublicKey, serumRequestQueue: PublicKey, serumEventQueue: PublicKey, serumMarketBids: PublicKey, serumMarketAsks: PublicKey, poolKey: PublicKey, coinVaultKey: PublicKey, pcVaultKey: PublicKey, splTokenProgramId: PublicKey, dexProgramKey: PublicKey, rentProgramId: PublicKey, srmReferrerKey: PublicKey | null, poolSeed: (Buffer | Uint8Array)[], side: OrderSide, limitPrice: Numberu64, market_index: Numberu16, coin_lot_size: Numberu64, pc_lot_size: Numberu64, target_mint: PublicKey, maxQuantity: Numberu16, orderType: OrderType, clientId: Numberu64, selfTradeBehavior: SelfTradeBehavior, serumLimit: Numberu16): TransactionInstruction
  • Parameters

    • bonfidaBotProgramId: PublicKey
    • signalProviderKey: PublicKey
    • market: PublicKey
    • payerPoolAssetKey: PublicKey
    • payerPoolAssetIndex: Numberu64
    • targetPoolAssetIndex: Numberu64
    • openOrdersKey: PublicKey
    • serumRequestQueue: PublicKey
    • serumEventQueue: PublicKey
    • serumMarketBids: PublicKey
    • serumMarketAsks: PublicKey
    • poolKey: PublicKey
    • coinVaultKey: PublicKey
    • pcVaultKey: PublicKey
    • splTokenProgramId: PublicKey
    • dexProgramKey: PublicKey
    • rentProgramId: PublicKey
    • srmReferrerKey: PublicKey | null
    • poolSeed: (Buffer | Uint8Array)[]
    • side: OrderSide
    • limitPrice: Numberu64
    • market_index: Numberu16
    • coin_lot_size: Numberu64
    • pc_lot_size: Numberu64
    • target_mint: PublicKey
    • maxQuantity: Numberu16
    • orderType: OrderType
    • clientId: Numberu64
    • selfTradeBehavior: SelfTradeBehavior
    • serumLimit: Numberu16

    Returns TransactionInstruction

createPool

  • createPool(connection: Connection, sourceOwnerKey: PublicKey, sourceAssetKeys: PublicKey[], signalProviderKey: PublicKey, depositAmounts: number[], maxNumberOfAssets: number, markets: PublicKey[], payer: PublicKey, feeCollectionPeriod: Numberu64, feePercentage: number): Promise<[Uint8Array, TransactionInstruction[]]>
  • Returns the solana instructions to create a new pool by performing the first deposit of any number of different tokens and setting the pubkey of the signal provider. The first deposit will fix the initial value of 1 pooltoken (credited to the target) with respect to the deposited tokens. (Signed by the sourceOwner account)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • sourceOwnerKey: PublicKey

      The address of the wallet that owns the tokens to be invested in the pool

    • sourceAssetKeys: PublicKey[]

      The adresses of the token accounts that hold the tokens to be invested in the pool

    • signalProviderKey: PublicKey

      The key of the account that will have the right to trade with the funds of the pool

    • depositAmounts: number[]

      An array of the amounts that should be invested for each token, in the same order as the sourceAssetKeys

    • maxNumberOfAssets: number

      The maximum number of different tokens the pool will ever be able to hold (solana memory allocation is fixed)

    • markets: PublicKey[]

      An array of the addresses of the serum markets that the signalProvider will be able to trade on

    • payer: PublicKey

      The address of the account that should pay for the allocation fees

    • feeCollectionPeriod: Numberu64

      The smallest period in seconds after which the trading fees can be payed out again (minimum is 604800 s or 1 week)

    • feePercentage: number

      The percentage (a number from 0 to 100) of the pool assets that should be collected as fees

    Returns Promise<[Uint8Array, TransactionInstruction[]]>

decodeInstruction

deposit

  • deposit(connection: Connection, sourceOwnerKey: PublicKey, sourceAssetKeys: PublicKey[], poolTokenAmount: Numberu64, poolSeed: (Buffer | Uint8Array)[], payer: PublicKey): Promise<TransactionInstruction[]>
  • Returns the solana instructions to buy into the pool. The source deposits tokens into the pool and the target receives a corresponding amount of pool-token in exchange. The program will try to maximize the deposit sum with regards to the amounts given by the source and the ratio of tokens present in the pool at that moment. Tokens can only be deposited in the exact ratio of tokens that are present in the pool. (Signed by the sourceOwnerKey)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • sourceOwnerKey: PublicKey

      The address of the wallet that owns the tokens to be invested in the pool

    • sourceAssetKeys: PublicKey[]

      The adresses of the token accounts that hold the tokens to be invested in the pool

    • poolTokenAmount: Numberu64

      The amount of pooltokens that should be bought (ie the amount of tokens that should be invested)

    • poolSeed: (Buffer | Uint8Array)[]

      The seed of the pool that should be invested into

    • payer: PublicKey

      The address of the account that should pay for the allocation fees

    Returns Promise<TransactionInstruction[]>

depositInstruction

  • depositInstruction(splTokenProgramId: PublicKey, bonfidaBotProgramId: PublicKey, sigProviderFeeReceiverKey: PublicKey, bonfidaFeeReceiverKey: PublicKey, bonfidaBuyAndBurnKey: PublicKey, mintKey: PublicKey, poolKey: PublicKey, poolAssetKeys: PublicKey[], targetPoolTokenKey: PublicKey, sourceOwnerKey: PublicKey, sourceAssetKeys: PublicKey[], poolSeed: (Buffer | Uint8Array)[], poolTokenAmount: Numberu64): TransactionInstruction
  • Parameters

    • splTokenProgramId: PublicKey
    • bonfidaBotProgramId: PublicKey
    • sigProviderFeeReceiverKey: PublicKey
    • bonfidaFeeReceiverKey: PublicKey
    • bonfidaBuyAndBurnKey: PublicKey
    • mintKey: PublicKey
    • poolKey: PublicKey
    • poolAssetKeys: PublicKey[]
    • targetPoolTokenKey: PublicKey
    • sourceOwnerKey: PublicKey
    • sourceAssetKeys: PublicKey[]
    • poolSeed: (Buffer | Uint8Array)[]
    • poolTokenAmount: Numberu64

    Returns TransactionInstruction

fetchPoolBalances

  • fetchPoolBalances(connection: Connection, poolSeed: Buffer | Uint8Array): Promise<[TokenAmount, PoolAssetBalance[]]>
  • Fetch the balances of the poolToken and the assets (returned in the same order as in the poolData)

    Parameters

    • connection: Connection
    • poolSeed: Buffer | Uint8Array

    Returns Promise<[TokenAmount, PoolAssetBalance[]]>

fetchPoolInfo

  • fetchPoolInfo(connection: Connection, poolSeed: Buffer | Uint8Array): Promise<PoolInfo>
  • Returns a structure containing most informations that one can parse from a pools state.

    Parameters

    • connection: Connection
    • poolSeed: Buffer | Uint8Array

    Returns Promise<PoolInfo>

Const findAndCreateAssociatedAccount

  • findAndCreateAssociatedAccount(systemProgramId: PublicKey, connection: Connection, address: PublicKey, mint: PublicKey, payer: PublicKey): Promise<[PublicKey, undefined | TransactionInstruction]>
  • Parameters

    • systemProgramId: PublicKey
    • connection: Connection
    • address: PublicKey
    • mint: PublicKey
    • payer: PublicKey

    Returns Promise<[PublicKey, undefined | TransactionInstruction]>

findAssociatedTokenAddress

  • findAssociatedTokenAddress(walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>
  • Parameters

    • walletAddress: PublicKey
    • tokenMintAddress: PublicKey

    Returns Promise<PublicKey>

Const getAccountFromSeed

  • getAccountFromSeed(seed: Buffer): Account

Const getDerivedSeed

  • getDerivedSeed(seed: Buffer): Uint8Array

getMarketData

  • getMarketData(connection: Connection, marketKey: PublicKey): Promise<MarketData>

Const getMidPrice

  • getMidPrice(connection: Connection, marketAddress: PublicKey): Promise<[Market, number]>
  • Parameters

    • connection: Connection
    • marketAddress: PublicKey

    Returns Promise<[Market, number]>

Const getPoolOrderInfos

  • getPoolOrderInfos(connection: Connection, poolSeed: Buffer | Uint8Array, n: number): Promise<PoolOrderInfo[]>

Const getPoolOrdersInfosFromSignature

  • getPoolOrdersInfosFromSignature(connection: Connection, poolInfo: PoolInfo, poolAssetMap: Map<string, string>, sig: ConfirmedSignatureInfo): Promise<undefined | PoolInstructionInfo[]>

Const getPoolTokenMintFromSeed

  • getPoolTokenMintFromSeed(poolSeed: Buffer | Uint8Array): Promise<PublicKey>

getPoolsSeedsBySigProvider

  • getPoolsSeedsBySigProvider(connection: Connection, signalProviderKey?: PublicKey): Promise<Buffer[]>
  • Returns the seeds of the pools managed by the given signal provider. Returns all poolseeds for the current BonfidaBot program if no signal provider was given.

    Parameters

    • connection: Connection
    • Optional signalProviderKey: PublicKey

    Returns Promise<Buffer[]>

getTotalNbTransactions

  • getTotalNbTransactions(connection: Connection): Promise<[number, string[]]>

getTotalValue

  • getTotalValue(connection: Connection): Promise<number>

initInstruction

  • initInstruction(splTokenProgramId: PublicKey, systemProgramId: PublicKey, rentProgramId: PublicKey, bonfidaBotProgramId: PublicKey, mintKey: PublicKey, payerKey: PublicKey, poolKey: PublicKey, poolSeed: (Buffer | Uint8Array)[], maxNumberOfAssets: number, number_of_markets: Numberu16): TransactionInstruction
  • Parameters

    • splTokenProgramId: PublicKey
    • systemProgramId: PublicKey
    • rentProgramId: PublicKey
    • bonfidaBotProgramId: PublicKey
    • mintKey: PublicKey
    • payerKey: PublicKey
    • poolKey: PublicKey
    • poolSeed: (Buffer | Uint8Array)[]
    • maxNumberOfAssets: number
    • number_of_markets: Numberu16

    Returns TransactionInstruction

Const loggablePoolOrderInfo

  • loggablePoolOrderInfo(o: PoolOrderInfo): { clientOrderId: number; limitPrice: number; market: string; openOrderAccount: string; orderType: string; poolSeed: string; ratioOfPoolAssetsToTrade: string; selfTradeBehavior: string; settledAmount: string; side: string; transactionSignature: string; transactionSlot: number; transferredAmount: number }
  • Parameters

    Returns { clientOrderId: number; limitPrice: number; market: string; openOrderAccount: string; orderType: string; poolSeed: string; ratioOfPoolAssetsToTrade: string; selfTradeBehavior: string; settledAmount: string; side: string; transactionSignature: string; transactionSlot: number; transferredAmount: number }

    • clientOrderId: number
    • limitPrice: number
    • market: string
    • openOrderAccount: string
    • orderType: string
    • poolSeed: string
    • ratioOfPoolAssetsToTrade: string
    • selfTradeBehavior: string
    • settledAmount: string
    • side: string
    • transactionSignature: string
    • transactionSlot: number
    • transferredAmount: number

Const parseCreateOrderInstruction

  • parseCreateOrderInstruction(instruction: TransactionInstruction, poolInfo: PoolInfo, sig: ConfirmedSignatureInfo, cpiInstructions: CompiledInstruction[], accounts: PublicKey[]): PoolOrderInfo

Const parseSettleInstruction

  • parseSettleInstruction(instruction: TransactionInstruction, sig: ConfirmedSignatureInfo, cpiInstructions: CompiledInstruction[], poolAssetMap: Map<string, string>, accounts: PublicKey[]): undefined | PoolSettleInfo
  • Parameters

    • instruction: TransactionInstruction
    • sig: ConfirmedSignatureInfo
    • cpiInstructions: CompiledInstruction[]
    • poolAssetMap: Map<string, string>
    • accounts: PublicKey[]

    Returns undefined | PoolSettleInfo

redeem

  • redeem(connection: Connection, sourcePoolTokenOwnerKey: PublicKey, sourcePoolTokenKey: PublicKey, targetAssetKeys: PublicKey[], poolSeed: (Buffer | Uint8Array)[], poolTokenAmount: Numberu64): Promise<TransactionInstruction[]>
  • Returns the solana instructions to buy out of the pool by redeeming (burning) pooltokens. This instruction needs to be executed after (and within the same transaction) having settled on all possible open orders for the pool. This is because as long as an order is open for the pool, redeeming is impossible. (Signed by the owner of the pooltokens)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • sourcePoolTokenOwnerKey: PublicKey

      The address of the account that owns the pooltokens to be redeemed

    • sourcePoolTokenKey: PublicKey

      The address that holds the pooltokens

    • targetAssetKeys: PublicKey[]

      An array of addresses to which the pool asset tokens are payed out to

    • poolSeed: (Buffer | Uint8Array)[]

      The seed of the pool that should be redeemed from

    • poolTokenAmount: Numberu64

      The amount of pooltokens that should be used (ie the amount of tokens that should be bought back)

    Returns Promise<TransactionInstruction[]>

redeemInstruction

  • redeemInstruction(splTokenProgramId: PublicKey, bonfidaBotProgramId: PublicKey, clockSysvarKey: PublicKey, mintKey: PublicKey, poolKey: PublicKey, poolAssetKeys: PublicKey[], sourcePoolTokenOwnerKey: PublicKey, sourcePoolTokenKey: PublicKey, targetAssetKeys: PublicKey[], poolSeed: (Buffer | Uint8Array)[], poolTokenAmount: Numberu64): TransactionInstruction
  • Parameters

    • splTokenProgramId: PublicKey
    • bonfidaBotProgramId: PublicKey
    • clockSysvarKey: PublicKey
    • mintKey: PublicKey
    • poolKey: PublicKey
    • poolAssetKeys: PublicKey[]
    • sourcePoolTokenOwnerKey: PublicKey
    • sourcePoolTokenKey: PublicKey
    • targetAssetKeys: PublicKey[]
    • poolSeed: (Buffer | Uint8Array)[]
    • poolTokenAmount: Numberu64

    Returns TransactionInstruction

settleFunds

  • settleFunds(connection: Connection, poolSeed: Buffer | Uint8Array, market: PublicKey, openOrdersKey: PublicKey, srmReferrerKey: PublicKey | null): Promise<TransactionInstruction[]>
  • Returns the solana instructions to a crank to settle funds out of one of the pool's active OpenOrders accounts. (Permissionless)

    Parameters

    • connection: Connection

      The connection object to the rpc node

    • poolSeed: Buffer | Uint8Array

      The seed of the pool that should be settled

    • market: PublicKey

      The address of the serum market on which the order is

    • openOrdersKey: PublicKey

      The address of the serum openOrder account to settle

    • srmReferrerKey: PublicKey | null

      The address of the referer that should receive the serum trading fees

    Returns Promise<TransactionInstruction[]>

settleFundsInstruction

  • settleFundsInstruction(bonfidaBotProgramId: PublicKey, market: PublicKey, openOrdersKey: PublicKey, poolKey: PublicKey, poolMintKey: PublicKey, coinVaultKey: PublicKey, pcVaultKey: PublicKey, coinPoolAssetKey: PublicKey, pcPoolAssetKey: PublicKey, vaultSignerKey: PublicKey, splTokenProgramId: PublicKey, dexProgramKey: PublicKey, srmReferrerKey: PublicKey | null, poolSeed: (Buffer | Uint8Array)[], pcPoolAssetIndex: Numberu64, coinPoolAssetIndex: Numberu64): TransactionInstruction
  • Parameters

    • bonfidaBotProgramId: PublicKey
    • market: PublicKey
    • openOrdersKey: PublicKey
    • poolKey: PublicKey
    • poolMintKey: PublicKey
    • coinVaultKey: PublicKey
    • pcVaultKey: PublicKey
    • coinPoolAssetKey: PublicKey
    • pcPoolAssetKey: PublicKey
    • vaultSignerKey: PublicKey
    • splTokenProgramId: PublicKey
    • dexProgramKey: PublicKey
    • srmReferrerKey: PublicKey | null
    • poolSeed: (Buffer | Uint8Array)[]
    • pcPoolAssetIndex: Numberu64
    • coinPoolAssetIndex: Numberu64

    Returns TransactionInstruction

settlePool

  • settlePool(connection: Connection, poolSeed: Buffer | Uint8Array, srmRefWallet?: PublicKey | null): Promise<TransactionInstruction[]>
  • Returns the solana instructions to settle all open orders for a given pool. If the returned transaction array is too large for it to be sent on Solana, you may need to process it batch-wise.

    Parameters

    • connection: Connection
    • poolSeed: Buffer | Uint8Array
    • srmRefWallet: PublicKey | null = null

    Returns Promise<TransactionInstruction[]>

Const signAndSendTransactionInstructions

  • signAndSendTransactionInstructions(connection: Connection, signers: Account[], feePayer: Account, txInstructions: TransactionInstruction[]): Promise<string>
  • Parameters

    • connection: Connection
    • signers: Account[]
    • feePayer: Account
    • txInstructions: TransactionInstruction[]

    Returns Promise<string>

singleTokenDeposit

  • singleTokenDeposit(connection: Connection, sourceOwner: Wallet, sourceTokenKey: PublicKey, user_amount: number, poolSeed: Buffer | Uint8Array, payer: Account): Promise<void>
  • This method lets the user deposit an arbitrary token into the pool by intermediately trading with serum in order to reach the pool asset ratio. (WIP)

    Parameters

    • connection: Connection
    • sourceOwner: Wallet
    • sourceTokenKey: PublicKey
    • user_amount: number
    • poolSeed: Buffer | Uint8Array
    • payer: Account

    Returns Promise<void>

Const sleep

  • sleep(ms: number): Promise<void>

unpack_assets

unpack_markets

  • unpack_markets(input: Buffer, numberOfMarkets: Numberu16): PublicKey[]

Generated using TypeDoc