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

interface WhirlpoolClient {
    collectFeesAndRewardsForPositions: ((positionAddresses, opts?) => Promise<TransactionBuilder[]>);
    collectProtocolFeesForPools: ((poolAddresses) => Promise<TransactionBuilder>);
    createPool: ((whirlpoolsConfig, tokenMintA, tokenMintB, tickSpacing, initialTick, funder) => Promise<{
        poolKey: PublicKey;
        tx: TransactionBuilder;
    }>);
    getContext: (() => WhirlpoolContext);
    getFetcher: (() => WhirlpoolAccountFetcherInterface);
    getPool: ((poolAddress, opts?) => Promise<Whirlpool>);
    getPools: ((poolAddresses, opts?) => Promise<Whirlpool[]>);
    getPosition: ((positionAddress, opts?) => Promise<Position>);
    getPositions: ((positionAddresses, opts?) => Promise<Record<string, null | Position>>);
    getRouter: ((poolAddresses) => Promise<WhirlpoolRouter>);
}

Properties

collectFeesAndRewardsForPositions: ((positionAddresses, opts?) => Promise<TransactionBuilder[]>)

Collect all fees and rewards from a list of positions.

Type declaration

    • (positionAddresses, opts?): Promise<TransactionBuilder[]>
    • Experimental

      Collect all fees and rewards from a list of positions.

      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.

Param: positionAddress

the addresses of the Position accounts to collect fee & rewards from.

Param: opts

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

Returns

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

collectProtocolFeesForPools: ((poolAddresses) => Promise<TransactionBuilder>)

Collect protocol fees from a list of pools

Type declaration

    • (poolAddresses): 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

Param: poolAddresses

the addresses of the Whirlpool accounts to collect protocol fees from

Returns

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

createPool: ((whirlpoolsConfig, tokenMintA, tokenMintB, tickSpacing, initialTick, funder) => Promise<{
    poolKey: PublicKey;
    tx: TransactionBuilder;
}>)

Create a Whirlpool account for a group of token A, token B and tick spacing

Type declaration

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

      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.

      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()).

Param: whirlpoolConfig

the address of the whirlpool config

Param: tokenMintA

the address of the token A

Param: tokenMintB

the address of the token B

Param: tickSpacing

the space between two ticks in the tick array

Param: initialTick

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

Param: funder

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

Returns

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

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()).

getContext: (() => WhirlpoolContext)

Get this client's WhirlpoolContext object

Type declaration

Returns

a WhirlpoolContext object

Get an WhirlpoolAccountCacheInterface to fetch and cache Whirlpool accounts

Type declaration

Returns

an WhirlpoolAccountCacheInterface instance

getPool: ((poolAddress, opts?) => Promise<Whirlpool>)

Get a Whirlpool object to interact with the Whirlpool account at the given address.

Type declaration

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

Param: poolAddress

the address of the Whirlpool account

Param: opts

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

Returns

a Whirlpool object to interact with

getPools: ((poolAddresses, opts?) => Promise<Whirlpool[]>)

Get a list of Whirlpool objects matching the provided list of addresses.

Type declaration

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

Param: poolAddresses

the addresses of the Whirlpool accounts

Param: opts

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

Returns

a list of Whirlpool objects to interact with

getPosition: ((positionAddress, opts?) => Promise<Position>)

Get a Position object to interact with the Position account at the given address.

Type declaration

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

      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.

      Throws

      error when address does not return a Position account.

Param: positionAddress

the address of the Position account

Param: opts

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

Returns

a Position object to interact with.

Throws

error when address does not return a Position account.

getPositions: ((positionAddresses, opts?) => Promise<Record<string, null | Position>>)

Get a list of Position objects to interact with the Position account at the given addresses.

Type declaration

    • (positionAddresses, opts?): 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.

Param: positionAddress

the addresses of the Position accounts

Param: opts

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

Returns

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

getRouter: ((poolAddresses) => Promise<WhirlpoolRouter>)

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

Type declaration

    • (poolAddresses): Promise<WhirlpoolRouter>
    • 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

      Deprecated

      WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.

Param: poolAddresses

the addresses of the Whirlpool account addresses to route through

Returns

a WhirlpoolRouter instance

Deprecated

WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.

Generated using TypeDoc