Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WhirlpoolClient

Helper class to help interact with Whirlpool Accounts with a simpler interface.

Hierarchy

  • WhirlpoolClient

Index

Methods

  • collectFeesAndRewardsForPositions(positionAddresses: Address[], refresh?: boolean): Promise<TransactionBuilder[]>
  • Collect all fees and rewards from a list of positions.

    experimental

    Parameters

    • positionAddresses: Address[]
    • Optional refresh: boolean

      true to always request newest data from chain with this request

    Returns Promise<TransactionBuilder[]>

    A set of transaction-builders to resolve ATA for affliated tokens, collect fee & rewards for all positions. The first transaction should always be processed as it contains all the resolve ATA instructions to receive tokens.

  • createPool(whirlpoolsConfig: Address, tokenMintA: Address, tokenMintB: Address, tickSpacing: number, initialTick: number, funder: Address): Promise<{ poolKey: PublicKey; tx: TransactionBuilder }>
  • Create a Whirlpool account for a group of token A, token B and tick spacing

    throws

    error when the tokens are not in the canonical byte-based ordering. To resolve this, invert the token order and the initialTick (see TickUtil.invertTick(), PriceMath.invertSqrtPriceX64(), or PriceMath.invertPrice()).

    Parameters

    • whirlpoolsConfig: Address
    • tokenMintA: Address

      the address of the token A

    • tokenMintB: Address

      the address of the token B

    • tickSpacing: number

      the space between two ticks in the tick array

    • initialTick: number

      the initial tick that the pool is set to (derived from initial price)

    • funder: Address

      the account to debit SOL from to fund the creation of the account(s)

    Returns Promise<{ poolKey: PublicKey; tx: TransactionBuilder }>

    poolKey: The public key of the newly created whirlpool account. tx: The transaction containing instructions for the on-chain operations.

  • getPool(poolAddress: Address, refresh?: boolean): Promise<Whirlpool>
  • Get a Whirlpool object to interact with the Whirlpool account at the given address.

    Parameters

    • poolAddress: Address

      the address of the Whirlpool account

    • Optional refresh: boolean

      true to always request newest data from chain with this request

    Returns Promise<Whirlpool>

    a Whirlpool object to interact with

  • getPools(poolAddresses: Address[], refresh?: boolean): Promise<Whirlpool[]>
  • Get a list of Whirlpool objects matching the provided list of addresses.

    Parameters

    • poolAddresses: Address[]

      the addresses of the Whirlpool accounts

    • Optional refresh: boolean

      true to always request newest data from chain with this request

    Returns Promise<Whirlpool[]>

    a list of Whirlpool objects to interact with

  • getPosition(positionAddress: Address, refresh?: boolean): Promise<Position>
  • Get a Position object to interact with the Position account at the given address.

    throws

    error when address does not return a Position account.

    Parameters

    • positionAddress: Address

      the address of the Position account

    • Optional refresh: boolean

      true to always request newest data from chain with this request

    Returns Promise<Position>

    a Position object to interact with.

  • getPositions(positionAddresses: Address[], refresh?: boolean): Promise<Record<string, null | Position>>
  • Get a list of Position objects to interact with the Position account at the given addresses.

    Parameters

    • positionAddresses: Address[]
    • Optional refresh: boolean

      true to always request newest data from chain with this request

    Returns Promise<Record<string, null | Position>>

    a Record object between account address and Position. If an address is not a Position account, it will be null.

Generated using TypeDoc