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[], opts?: SimpleAccountFetchOptions): Promise<TransactionBuilder[]>
  • Collect all fees and rewards from a list of positions.

    experimental

    Parameters

    • positionAddresses: Address[]
    • Optional opts: SimpleAccountFetchOptions

      an options object to define fetch and cache options when accessing on-chain accounts

    Returns Promise<TransactionBuilder[]>

    A set of transaction-builders to resolve ATA for affliated tokens, collect fee & rewards for all positions.

  • collectProtocolFeesForPools(poolAddresses: Address[]): Promise<TransactionBuilder>
  • Collect protocol fees from a list of pools

    Parameters

    • poolAddresses: Address[]

      the addresses of the Whirlpool accounts to collect protocol fees from

    Returns Promise<TransactionBuilder>

    A transaction builder to resolve ATA for tokenA and tokenB if needed, and collect protocol fees for all pools

  • 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, opts?: SimpleAccountFetchOptions): 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 opts: SimpleAccountFetchOptions

      an options object to define fetch and cache options when accessing on-chain accounts

    Returns Promise<Whirlpool>

    a Whirlpool object to interact with

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

    Parameters

    • poolAddresses: Address[]

      the addresses of the Whirlpool accounts

    • Optional opts: SimpleAccountFetchOptions

      an options object to define fetch and cache options when accessing on-chain accounts

    Returns Promise<Whirlpool[]>

    a list of Whirlpool objects to interact with

  • getPosition(positionAddress: Address, opts?: SimpleAccountFetchOptions): 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 opts: SimpleAccountFetchOptions

      an options object to define fetch and cache options when accessing on-chain accounts

    Returns Promise<Position>

    a Position object to interact with.

  • getPositions(positionAddresses: Address[], opts?: SimpleAccountFetchOptions): 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 opts: SimpleAccountFetchOptions

      an options object to define fetch and cache options when accessing on-chain accounts

    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.

  • Get a WhirlpoolRouter to help generate the best prices when transacting across a set of pools.

    Parameters

    • poolAddresses: Address[]

      the addresses of the Whirlpool account addresses to route through

    Returns Promise<WhirlpoolRouter>

    a WhirlpoolRouter instance

Generated using TypeDoc