Options
All
  • Public
  • Public/Protected
  • All
Menu

@orca-so/whirlpools-sdk

Index

Constants

Core

Instruction Types

Network

Other

PoolGraph

PriceModule

Quotes

Router

Solana Accounts

Whirlpool Utils

WhirlpoolClient

Constants

FEE_RATE_MUL_VALUE: BN = ...

The denominator which the fee rate is divided on.

MAX_SQRT_PRICE: "79226673515401279992447579055" = "79226673515401279992447579055"

The maximum sqrt-price supported by the Whirlpool program.

MAX_SWAP_TICK_ARRAYS: 3 = 3

The maximum number of tick-arrays that can traversed across in a swap.

MAX_TICK_INDEX: 443636 = 443636

The maximum tick index supported by the Whirlpool program.

METADATA_PROGRAM_ADDRESS: PublicKey = ...
MIN_SQRT_PRICE: "4295048016" = "4295048016"

The minimum sqrt-price supported by the Whirlpool program.

MIN_TICK_INDEX: -443636 = -443636

The minimum tick index supported by the Whirlpool program.

NUM_REWARDS: 3 = 3

The number of rewards supported by this whirlpool.

ORCA_SUPPORTED_TICK_SPACINGS: number[] = ...

Orca's supported tick spacings.

ORCA_WHIRLPOOLS_CONFIG: PublicKey = ...

Orca's WhirlpoolsConfig PublicKey.

ORCA_WHIRLPOOL_PROGRAM_ID: PublicKey = ...

Program ID hosting Orca's Whirlpool program.

POSITION_BUNDLE_SIZE: 256 = 256

The number of bundled positions that a position-bundle account can hold.

PROTOCOL_FEE_RATE_MUL_VALUE: BN = ...

The denominator which the protocol fee rate is divided on.

TICK_ARRAY_SIZE: 88 = 88

The number of initialized ticks that a tick-array account can hold.

WHIRLPOOL_NFT_UPDATE_AUTH: PublicKey = ...

The public key that is allowed to update the metadata of Whirlpool NFTs.

Core

AccountResolverOptions: { allowPDAOwnerAddress: boolean; createWrappedSolAccountMethod: WrappedSolAccountCreateMethod }

Default settings used when resolving token accounts.

Type declaration

  • allowPDAOwnerAddress: boolean
  • createWrappedSolAccountMethod: WrappedSolAccountCreateMethod
WhirlpoolContextOpts: { accountResolverOptions?: AccountResolverOptions; userDefaultBuildOptions?: Partial<BuildOptions>; userDefaultConfirmCommitment?: Commitment; userDefaultSendOptions?: Partial<SendOptions> }

Default settings used when interacting with transactions.

Type declaration

  • Optional accountResolverOptions?: AccountResolverOptions
  • Optional userDefaultBuildOptions?: Partial<BuildOptions>
  • Optional userDefaultConfirmCommitment?: Commitment
  • Optional userDefaultSendOptions?: Partial<SendOptions>

Instruction Types

CloseBundledPositionParams: { bundleIndex: number; bundledPosition: PublicKey; positionBundle: PublicKey; positionBundleAuthority: PublicKey; positionBundleTokenAccount: PublicKey; receiver: PublicKey }

Parameters to close a bundled position in a Whirlpool.

param bundledPosition

PublicKey for the bundled position.

param positionBundle

PublicKey for the position bundle.

param positionBundleTokenAccount

The associated token address for the position bundle token in the owners wallet.

param positionBundleAuthority

authority that owns the token corresponding to this desired bundled position.

param bundleIndex

The bundle index that holds the bundled position.

param receiver

PublicKey for the wallet that will receive the rented lamports.

Type declaration

  • bundleIndex: number
  • bundledPosition: PublicKey
  • positionBundle: PublicKey
  • positionBundleAuthority: PublicKey
  • positionBundleTokenAccount: PublicKey
  • receiver: PublicKey
ClosePositionParams: { position: PublicKey; positionAuthority: PublicKey; positionMint: PublicKey; positionTokenAccount: PublicKey; receiver: PublicKey }

Parameters to close a position in a Whirlpool.

param receiver

PublicKey for the wallet that will receive the rented lamports.

param position

PublicKey for the position.

param positionMint

PublicKey for the mint token for the Position token.

param positionTokenAccount

The associated token address for the position token in the owners wallet.

param positionAuthority

Authority that owns the position token.

Type declaration

  • position: PublicKey
  • positionAuthority: PublicKey
  • positionMint: PublicKey
  • positionTokenAccount: PublicKey
  • receiver: PublicKey
CollectAllParams: { payer?: PublicKey; positionAuthority?: PublicKey; positionOwner?: PublicKey; receiver?: PublicKey }
param receiver

The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.

param positionOwner

The wallet key that contains the position token. Defaults to ctx.wallet key.

param positionAuthority

The authority key that can authorize operation on the position. Defaults to ctx.wallet key.

param payer

The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.

Type declaration

  • Optional payer?: PublicKey
  • Optional positionAuthority?: PublicKey
  • Optional positionOwner?: PublicKey
  • Optional receiver?: PublicKey
CollectAllPositionAddressParams: { positions: Address[] } & CollectAllParams

Parameters to collect all fees and rewards from a list of positions.

param positionAddrs

An array of Whirlpool position addresses.

param receiver

The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.

param positionOwner

The wallet key that contains the position token. Defaults to ctx.wallet key.

param positionAuthority

The authority key that can authorize operation on the position. Defaults to ctx.wallet key.

param payer

The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.

CollectAllPositionParams: { positions: Record<string, PositionData> } & CollectAllParams

Parameters to collect all fees and rewards from a list of positions.

param positions

An array of Whirlpool positions.

param receiver

The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.

param positionOwner

The wallet key that contains the position token. Defaults to ctx.wallet key.

param positionAuthority

The authority key that can authorize operation on the position. Defaults to ctx.wallet key.

param payer

The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.

CollectFeesParams: { position: PublicKey; positionAuthority: PublicKey; positionTokenAccount: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey }

Parameters to collect fees from a position.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param position

PublicKey for the position will be opened for.

param positionTokenAccount

PublicKey for the position token's associated token address.

param tokenOwnerAccountA

PublicKey for the token A account that will be withdrawed from.

param tokenOwnerAccountB

PublicKey for the token B account that will be withdrawed from.

param tokenVaultA

PublicKey for the tokenA vault for this whirlpool.

param tokenVaultB

PublicKey for the tokenB vault for this whirlpool.

param positionAuthority

authority that owns the token corresponding to this desired position.

Type declaration

  • position: PublicKey
  • positionAuthority: PublicKey
  • positionTokenAccount: PublicKey
  • tokenOwnerAccountA: PublicKey
  • tokenOwnerAccountB: PublicKey
  • tokenVaultA: PublicKey
  • tokenVaultB: PublicKey
  • whirlpool: PublicKey
CollectProtocolFeesParams: { collectProtocolFeesAuthority: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to collect protocol fees for a Whirlpool

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param tokenVaultA

PublicKey for the tokenA vault for this whirlpool.

param tokenVaultB

PublicKey for the tokenB vault for this whirlpool.

param tokenOwnerAccountA

PublicKey for the associated token account for tokenA in the collection wallet

param tokenOwnerAccountB

PublicKey for the associated token account for tokenA in the collection wallet

param collectProtocolFeesAuthority

assigned authority in the WhirlpoolsConfig that can collect protocol fees

Type declaration

  • collectProtocolFeesAuthority: PublicKey
  • tokenOwnerAccountA: PublicKey
  • tokenOwnerAccountB: PublicKey
  • tokenVaultA: PublicKey
  • tokenVaultB: PublicKey
  • whirlpool: PublicKey
  • whirlpoolsConfig: PublicKey
CollectRewardParams: { position: PublicKey; positionAuthority: PublicKey; positionTokenAccount: PublicKey; rewardIndex: number; rewardOwnerAccount: PublicKey; rewardVault: PublicKey; whirlpool: PublicKey }

Parameters to collect rewards from a reward index in a position.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param position

PublicKey for the position will be opened for.

param positionTokenAccount

PublicKey for the position token's associated token address.

param rewardIndex

The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).

param rewardOwnerAccount

PublicKey for the reward token account that the reward will deposit into.

param rewardVault

PublicKey of the vault account that reward will be withdrawn from.

param positionAuthority

authority that owns the token corresponding to this desired position.

Type declaration

  • position: PublicKey
  • positionAuthority: PublicKey
  • positionTokenAccount: PublicKey
  • rewardIndex: number
  • rewardOwnerAccount: PublicKey
  • rewardVault: PublicKey
  • whirlpool: PublicKey
DecreaseLiquidityInput: { liquidityAmount: BN; tokenMinA: BN; tokenMinB: BN }

Type declaration

  • liquidityAmount: BN
  • tokenMinA: BN
  • tokenMinB: BN
DecreaseLiquidityParams: { position: PublicKey; positionAuthority: PublicKey; positionTokenAccount: PublicKey; tickArrayLower: PublicKey; tickArrayUpper: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey } & DecreaseLiquidityInput

Parameters to remove liquidity from a position.

param liquidityAmount

The total amount of Liquidity the user is withdrawing

param tokenMinA

The minimum amount of token A to remove from the position.

param tokenMinB

The minimum amount of token B to remove from the position.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param position

PublicKey for the position will be opened for.

param positionTokenAccount

PublicKey for the position token's associated token address.

param tokenOwnerAccountA

PublicKey for the token A account that will be withdrawed from.

param tokenOwnerAccountB

PublicKey for the token B account that will be withdrawed from.

param tokenVaultA

PublicKey for the tokenA vault for this whirlpool.

param tokenVaultB

PublicKey for the tokenB vault for this whirlpool.

param tickArrayLower

PublicKey for the tick-array account that hosts the tick at the lower tick index.

param tickArrayUpper

PublicKey for the tick-array account that hosts the tick at the upper tick index.

param positionAuthority

authority that owns the token corresponding to this desired position.

DeletePositionBundleParams: { owner: PublicKey; positionBundle: PublicKey; positionBundleMint: PublicKey; positionBundleTokenAccount: PublicKey; receiver: PublicKey }

Parameters to delete a PositionBundle account.

param owner

PublicKey for the wallet that owns the position bundle token.

param positionBundle

PublicKey for the position bundle.

param positionBundleMint

PublicKey for the mint for the position bundle token.

param positionBundleTokenAccount

The associated token address for the position bundle token in the owners wallet.

param receiver

PublicKey for the wallet that will receive the rented lamports.

Type declaration

  • owner: PublicKey
  • positionBundle: PublicKey
  • positionBundleMint: PublicKey
  • positionBundleTokenAccount: PublicKey
  • receiver: PublicKey
DevFeeSwapInput: SwapInput & { devFeeAmount: BN }

Parameters to swap on a Whirlpool with developer fees

param swapInput

Parameters in SwapInput

param devFeeAmount

FeeAmount (developer fees) charged on this swap

IncreaseLiquidityInput: { liquidityAmount: BN; tokenMaxA: BN; tokenMaxB: BN }

Input parameters to deposit liquidity into a position.

This type is usually generated by a quote class to estimate the amount of tokens required to deposit a certain amount of liquidity into a position.

param tokenMaxA

the maximum amount of tokenA allowed to withdraw from the source wallet.

param tokenMaxB

the maximum amount of tokenB allowed to withdraw from the source wallet.

param liquidityAmount

the desired amount of liquidity to deposit into the position/

Type declaration

  • liquidityAmount: BN
  • tokenMaxA: BN
  • tokenMaxB: BN
IncreaseLiquidityParams: { position: PublicKey; positionAuthority: PublicKey; positionTokenAccount: PublicKey; tickArrayLower: PublicKey; tickArrayUpper: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey } & IncreaseLiquidityInput

Parameters to increase liquidity for a position.

param liquidityAmount

The total amount of Liquidity the user is willing to deposit.

param tokenMaxA

The maximum amount of token A to add to the position.

param tokenMaxB

The maximum amount of token B to add to the position.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param position

PublicKey for the position will be opened for.

param positionTokenAccount

PublicKey for the position token's associated token address.

param tokenOwnerAccountA

PublicKey for the token A account that will be withdrawed from.

param tokenOwnerAccountB

PublicKey for the token B account that will be withdrawed from.

param tokenVaultA

PublicKey for the tokenA vault for this whirlpool.

param tokenVaultB

PublicKey for the tokenB vault for this whirlpool.

param tickArrayLower

PublicKey for the tick-array account that hosts the tick at the lower tick index.

param tickArrayUpper

PublicKey for the tick-array account that hosts the tick at the upper tick index.

param positionAuthority

authority that owns the token corresponding to this desired position.

InitConfigParams: { collectProtocolFeesAuthority: PublicKey; defaultProtocolFeeRate: number; feeAuthority: PublicKey; funder: PublicKey; rewardEmissionsSuperAuthority: PublicKey; whirlpoolsConfigKeypair: Keypair }

Parameters to initialize a WhirlpoolsConfig account.

param whirlpoolsConfigKeypair

Generated keypair for the WhirlpoolsConfig.

param feeAuthority

Authority authorized to initialize fee-tiers and set customs fees.

param collect_protocol_fees_authority

Authority authorized to collect protocol fees.

param rewardEmissionsSuperAuthority

Authority authorized to set reward authorities in pools.

param defaultProtocolFeeRate

The default protocol fee rate. Stored as a basis point of the total fees collected by feeRate.

param funder

The account that would fund the creation of this account

Type declaration

  • collectProtocolFeesAuthority: PublicKey
  • defaultProtocolFeeRate: number
  • feeAuthority: PublicKey
  • funder: PublicKey
  • rewardEmissionsSuperAuthority: PublicKey
  • whirlpoolsConfigKeypair: Keypair
InitFeeTierParams: { defaultFeeRate: number; feeAuthority: PublicKey; feeTierPda: PDA; funder: PublicKey; tickSpacing: number; whirlpoolsConfig: PublicKey }

Parameters to initialize a FeeTier account.

param whirlpoolsConfig

PublicKey for the whirlpool config space that the fee-tier will be initialized for.

param feeTierPda

PDA for the fee-tier account that will be initialized

param tickSpacing

The tick spacing this fee tier recommends its default fee rate for.

param defaultFeeRate

The default fee rate for this fee-tier. Stored as a hundredths of a basis point.

param feeAuthority

Authority authorized to initialize fee-tiers and set customs fees.

param funder

The account that would fund the creation of this account

Type declaration

  • defaultFeeRate: number
  • feeAuthority: PublicKey
  • feeTierPda: PDA
  • funder: PublicKey
  • tickSpacing: number
  • whirlpoolsConfig: PublicKey
InitPoolParams: { feeTierKey: PublicKey; funder: PublicKey; initSqrtPrice: BN; tickSpacing: number; tokenMintA: PublicKey; tokenMintB: PublicKey; tokenVaultAKeypair: Keypair; tokenVaultBKeypair: Keypair; whirlpoolPda: PDA; whirlpoolsConfig: PublicKey }

Parameters to initialize a Whirlpool account.

param initSqrtPrice

The desired initial sqrt-price for this pool

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param whirlpoolPda

PDA for the whirlpool account that would be initialized

param tokenMintA

Mint public key for token A

param tokenMintB

Mint public key for token B

param tokenVaultAKeypair

Keypair of the token A vault for this pool

param tokenVaultBKeypair

Keypair of the token B vault for this pool

param feeTierKey

PublicKey of the fee-tier account that this pool would use for the fee-rate

param tickSpacing

The desired tick spacing for this pool.

param funder

The account that would fund the creation of this account

Type declaration

  • feeTierKey: PublicKey
  • funder: PublicKey
  • initSqrtPrice: BN
  • tickSpacing: number
  • tokenMintA: PublicKey
  • tokenMintB: PublicKey
  • tokenVaultAKeypair: Keypair
  • tokenVaultBKeypair: Keypair
  • whirlpoolPda: PDA
  • whirlpoolsConfig: PublicKey
InitTickArrayParams: { funder: PublicKey; startTick: number; tickArrayPda: PDA; whirlpool: PublicKey }

Parameters to initialize a TickArray account.

param whirlpool

PublicKey for the whirlpool that the initialized tick-array will host ticks for.

param tickArrayPda

PDA for the tick array account that will be initialized

param startTick

The starting tick index for this tick-array. Has to be a multiple of TickArray size & the tick spacing of this pool.

param funder

The account that would fund the creation of this account

Type declaration

  • funder: PublicKey
  • startTick: number
  • tickArrayPda: PDA
  • whirlpool: PublicKey
InitializePositionBundleParams: { funder: PublicKey; owner: PublicKey; positionBundleMintKeypair: Keypair; positionBundlePda: PDA; positionBundleTokenAccount: PublicKey }

Parameters to initialize a PositionBundle account.

param owner

PublicKey for the wallet that will host the minted position bundle token.

param positionBundlePda

PDA for the derived position bundle address.

param positionBundleMintKeypair

Keypair for the mint for the position bundle token.

param positionBundleTokenAccount

The associated token address for the position bundle token in the owners wallet.

param funder

The account that would fund the creation of this account

Type declaration

  • funder: PublicKey
  • owner: PublicKey
  • positionBundleMintKeypair: Keypair
  • positionBundlePda: PDA
  • positionBundleTokenAccount: PublicKey
InitializeRewardParams: { funder: PublicKey; rewardAuthority: PublicKey; rewardIndex: number; rewardMint: PublicKey; rewardVaultKeypair: Keypair; whirlpool: PublicKey }

Parameters to initialize a rewards for a Whirlpool

param whirlpool

PublicKey for the whirlpool config space that the fee-tier will be initialized for.

param rewardIndex

The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).

param rewardMint

PublicKey for the reward mint that we'd use for the reward index.

param rewardVaultKeypair

Keypair of the vault for this reward index.

param rewardAuthority

Assigned authority by the reward_super_authority for the specified reward-index in this Whirlpool

param funder

The account that would fund the creation of this account

Type declaration

  • funder: PublicKey
  • rewardAuthority: PublicKey
  • rewardIndex: number
  • rewardMint: PublicKey
  • rewardVaultKeypair: Keypair
  • whirlpool: PublicKey
OpenBundledPositionParams: { bundleIndex: number; bundledPositionPda: PDA; funder: PublicKey; positionBundle: PublicKey; positionBundleAuthority: PublicKey; positionBundleTokenAccount: PublicKey; tickLowerIndex: number; tickUpperIndex: number; whirlpool: PublicKey }

Parameters to open a bundled position in a Whirlpool.

param whirlpool

PublicKey for the whirlpool that the bundled position will be opened for.

param bundledPositionPda

PDA for the derived bundled position address.

param positionBundle

PublicKey for the position bundle.

param positionBundleTokenAccount

The associated token address for the position bundle token in the owners wallet.

param positionBundleAuthority

authority that owns the token corresponding to this desired bundled position.

param bundleIndex

The bundle index that holds the bundled position.

param tickLowerIndex

The tick specifying the lower end of the bundled position range.

param tickUpperIndex

The tick specifying the upper end of the bundled position range.

param funder

The account that would fund the creation of this account

Type declaration

  • bundleIndex: number
  • bundledPositionPda: PDA
  • funder: PublicKey
  • positionBundle: PublicKey
  • positionBundleAuthority: PublicKey
  • positionBundleTokenAccount: PublicKey
  • tickLowerIndex: number
  • tickUpperIndex: number
  • whirlpool: PublicKey
OpenPositionParams: { funder: PublicKey; owner: PublicKey; positionMintAddress: PublicKey; positionPda: PDA; positionTokenAccount: PublicKey; tickLowerIndex: number; tickUpperIndex: number; whirlpool: PublicKey }

Parameters to open a position in a Whirlpool.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param ownerKey

PublicKey for the wallet that will host the minted position token.

param positionPda

PDA for the derived position address.

param positionMintAddress

PublicKey for the mint token for the Position token.

param positionTokenAccount

The associated token address for the position token in the owners wallet.

param tickLowerIndex

The tick specifying the lower end of the position range.

param tickUpperIndex

The tick specifying the upper end of the position range.

param funder

The account that would fund the creation of this account

Type declaration

  • funder: PublicKey
  • owner: PublicKey
  • positionMintAddress: PublicKey
  • positionPda: PDA
  • positionTokenAccount: PublicKey
  • tickLowerIndex: number
  • tickUpperIndex: number
  • whirlpool: PublicKey
SetCollectProtocolFeesAuthorityParams: { collectProtocolFeesAuthority: PublicKey; newCollectProtocolFeesAuthority: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set the collect fee authority in a WhirlpoolsConfig

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param collectProtocolFeesAuthority

The current collectProtocolFeesAuthority in the WhirlpoolsConfig

param newCollectProtocolFeesAuthority

The new collectProtocolFeesAuthority in the WhirlpoolsConfig

Type declaration

  • collectProtocolFeesAuthority: PublicKey
  • newCollectProtocolFeesAuthority: PublicKey
  • whirlpoolsConfig: PublicKey
SetDefaultFeeRateParams: { defaultFeeRate: number; feeAuthority: PublicKey; tickSpacing: number; whirlpoolsConfig: PublicKey }

Parameters to set the default fee rate for a FeeTier.

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this fee-tier is initialized in

param feeAuthority

Authority authorized in the WhirlpoolsConfig to set default fee rates.

param tickSpacing

The tick spacing of the fee-tier that we would like to update.

param defaultFeeRate

The new default fee rate for this fee-tier. Stored as a hundredths of a basis point.

Type declaration

  • defaultFeeRate: number
  • feeAuthority: PublicKey
  • tickSpacing: number
  • whirlpoolsConfig: PublicKey
SetDefaultProtocolFeeRateParams: { defaultProtocolFeeRate: number; feeAuthority: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set the default fee rate for a FeeTier.

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param feeAuthority

Authority authorized in the WhirlpoolsConfig to set default fee rates.

param defaultProtocolFeeRate

The new default protocol fee rate for this config. Stored as a basis point of the total fees collected by feeRate.

Type declaration

  • defaultProtocolFeeRate: number
  • feeAuthority: PublicKey
  • whirlpoolsConfig: PublicKey
SetFeeAuthorityParams: { feeAuthority: PublicKey; newFeeAuthority: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set the fee authority in a WhirlpoolsConfig

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param feeAuthority

The current feeAuthority in the WhirlpoolsConfig

param newFeeAuthority

The new feeAuthority in the WhirlpoolsConfig

Type declaration

  • feeAuthority: PublicKey
  • newFeeAuthority: PublicKey
  • whirlpoolsConfig: PublicKey
SetFeeRateParams: { feeAuthority: PublicKey; feeRate: number; whirlpool: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set fee rate for a Whirlpool.

param whirlpool

PublicKey for the whirlpool to update. This whirlpool has to be part of the provided WhirlpoolsConfig space.

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param feeAuthority

Authority authorized in the WhirlpoolsConfig to set default fee rates.

param feeRate

The new fee rate for this fee-tier. Stored as a hundredths of a basis point.

Type declaration

  • feeAuthority: PublicKey
  • feeRate: number
  • whirlpool: PublicKey
  • whirlpoolsConfig: PublicKey
SetProtocolFeeRateParams: { feeAuthority: PublicKey; protocolFeeRate: number; whirlpool: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set fee rate for a Whirlpool.

param whirlpool

PublicKey for the whirlpool to update. This whirlpool has to be part of the provided WhirlpoolsConfig space.

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param feeAuthority

Authority authorized in the WhirlpoolsConfig to set default fee rates.

param protocolFeeRate

The new default protocol fee rate for this pool. Stored as a basis point of the total fees collected by feeRate.

Type declaration

  • feeAuthority: PublicKey
  • protocolFeeRate: number
  • whirlpool: PublicKey
  • whirlpoolsConfig: PublicKey
SetRewardAuthorityBySuperAuthorityParams: { newRewardAuthority: PublicKey; rewardEmissionsSuperAuthority: PublicKey; rewardIndex: number; whirlpool: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to update the reward authority at a particular rewardIndex on a Whirlpool.

param whirlpool

PublicKey for the whirlpool to update. This whirlpool has to be part of the provided WhirlpoolsConfig space.

param whirlpoolsConfig

The public key for the WhirlpoolsConfig this pool is initialized in

param rewardIndex

The reward index that we'd like to update. (0 <= index <= NUM_REWARDS).

param rewardEmissionsSuperAuthority

The current rewardEmissionsSuperAuthority in the WhirlpoolsConfig

param newRewardAuthority

The new rewardAuthority in the Whirlpool at the rewardIndex

Type declaration

  • newRewardAuthority: PublicKey
  • rewardEmissionsSuperAuthority: PublicKey
  • rewardIndex: number
  • whirlpool: PublicKey
  • whirlpoolsConfig: PublicKey
SetRewardAuthorityParams: { newRewardAuthority: PublicKey; rewardAuthority: PublicKey; rewardIndex: number; whirlpool: PublicKey }

Parameters to update the reward authority at a particular rewardIndex on a Whirlpool.

param whirlpool

PublicKey for the whirlpool to update.

param rewardIndex

The reward index that we'd like to update. (0 <= index <= NUM_REWARDS).

param rewardAuthority

The current rewardAuthority in the Whirlpool at the rewardIndex

param newRewardAuthority

The new rewardAuthority in the Whirlpool at the rewardIndex

Type declaration

  • newRewardAuthority: PublicKey
  • rewardAuthority: PublicKey
  • rewardIndex: number
  • whirlpool: PublicKey
SetRewardEmissionsParams: { emissionsPerSecondX64: BN; rewardAuthority: PublicKey; rewardIndex: number; rewardVaultKey: PublicKey; whirlpool: PublicKey }

Parameters to set rewards emissions for a reward in a Whirlpool

param whirlpool

PublicKey for the whirlpool which the reward resides in.

param rewardIndex

The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).

param rewardVaultKey

PublicKey of the vault for this reward index.

param rewardAuthority

Assigned authority by the reward_super_authority for the specified reward-index in this Whirlpool

param emissionsPerSecondX64

The new emissions per second to set for this reward.

Type declaration

  • emissionsPerSecondX64: BN
  • rewardAuthority: PublicKey
  • rewardIndex: number
  • rewardVaultKey: PublicKey
  • whirlpool: PublicKey
SetRewardEmissionsSuperAuthorityParams: { newRewardEmissionsSuperAuthority: PublicKey; rewardEmissionsSuperAuthority: PublicKey; whirlpoolsConfig: PublicKey }

Parameters to set rewards emissions for a reward in a Whirlpool

param whirlpoolsConfig

PublicKey for the WhirlpoolsConfig that we want to update.

param rewardEmissionsSuperAuthority

Current reward emission super authority in this WhirlpoolsConfig

param newRewardEmissionsSuperAuthority

New reward emission super authority for this WhirlpoolsConfig

Type declaration

  • newRewardEmissionsSuperAuthority: PublicKey
  • rewardEmissionsSuperAuthority: PublicKey
  • whirlpoolsConfig: PublicKey
SwapInput: { aToB: boolean; amount: BN; amountSpecifiedIsInput: boolean; otherAmountThreshold: BN; sqrtPriceLimit: BN; tickArray0: PublicKey; tickArray1: PublicKey; tickArray2: PublicKey }

Parameters that describe the nature of a swap on a Whirlpool.

param aToB

The direction of the swap. True if swapping from A to B. False if swapping from B to A.

param amountSpecifiedIsInput

Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.

param amount

The amount of input or output token to swap from (depending on amountSpecifiedIsInput).

param otherAmountThreshold

The maximum/minimum of input/output token to swap into (depending on amountSpecifiedIsInput).

param sqrtPriceLimit

The maximum/minimum price the swap will swap to.

param tickArray0

PublicKey of the tick-array where the Whirlpool's currentTickIndex resides in

param tickArray1

The next tick-array in the swap direction. If the swap will not reach the next tick-aray, input the same array as tickArray0.

param tickArray2

The next tick-array in the swap direction after tickArray2. If the swap will not reach the next tick-aray, input the same array as tickArray1.

Type declaration

  • aToB: boolean
  • amount: BN
  • amountSpecifiedIsInput: boolean
  • otherAmountThreshold: BN
  • sqrtPriceLimit: BN
  • tickArray0: PublicKey
  • tickArray1: PublicKey
  • tickArray2: PublicKey
SwapParams: SwapInput & { oracle: PublicKey; tokenAuthority: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey }

Raw parameters and accounts to swap on a Whirlpool

param swapInput

Parameters in SwapInput

param whirlpool

PublicKey for the whirlpool that the swap will occur on

param tokenOwnerAccountA

PublicKey for the associated token account for tokenA in the collection wallet

param tokenOwnerAccountB

PublicKey for the associated token account for tokenB in the collection wallet

param tokenVaultA

PublicKey for the tokenA vault for this whirlpool.

param tokenVaultB

PublicKey for the tokenB vault for this whirlpool.

param oracle

PublicKey for the oracle account for this Whirlpool.

param tokenAuthority

authority to withdraw tokens from the input token account

UpdateFeesAndRewardsParams: { position: PublicKey; tickArrayLower: PublicKey; tickArrayUpper: PublicKey; whirlpool: PublicKey }

Parameters to update fees and reward values for a position.

param whirlpool

PublicKey for the whirlpool that the position will be opened for.

param position

PublicKey for the position will be opened for.

param tickArrayLower

PublicKey for the tick-array account that hosts the tick at the lower tick index.

param tickArrayUpper

PublicKey for the tick-array account that hosts the tick at the upper tick index.

Type declaration

  • position: PublicKey
  • tickArrayLower: PublicKey
  • tickArrayUpper: PublicKey
  • whirlpool: PublicKey

Network

WhirlpoolAccountFetchOptions: SimpleAccountFetchOptions

Type to define fetch options for the WhirlpoolAccountFetcherInterface

WhirlpoolSupportedTypes: WhirlpoolsConfigData | WhirlpoolData | PositionData | TickArrayData | FeeTierData | PositionBundleData | BasicSupportedTypes

Union type of all the {@link ParsableEntity} types that can be cached in the WhirlpoolAccountFetcherInterface

DEFAULT_WHIRLPOOL_RETENTION_POLICY: ReadonlyMap<ParsableEntity<WhirlpoolSupportedTypes>, number> = ...

The default retention periods for each {@link ParsableEntity} type in the WhirlpoolAccountFetcherInterface

IGNORE_CACHE: WhirlpoolAccountFetchOptions = ...

Default fetch option for always fetching when making an account request to the WhirlpoolAccountFetcherInterface

PREFER_CACHE: WhirlpoolAccountFetchOptions = ...

Default fetch option for always using the cached value for an account request to the WhirlpoolAccountFetcherInterface

  • getAllWhirlpoolAccountsForConfig(__namedParameters: { configId: Address; connection: Connection; programId: Address }): Promise<ReadonlyMap<string, WhirlpoolData>>
  • Retrieve a list of whirlpool addresses and accounts filtered by the given params using getProgramAccounts.

    Parameters

    • __namedParameters: { configId: Address; connection: Connection; programId: Address }
      • configId: Address
      • connection: Connection
      • programId: Address

    Returns Promise<ReadonlyMap<string, WhirlpoolData>>

    tuple of whirlpool addresses and accounts

Other

AtaAccountInfo: Pick<Account, "address" | "owner" | "mint">

A type representing a Associated Token Account

param address

The address of the ATA account.

param owner

The owner address of the ATA.

param mint

The mint of the token the ATA represents.

WHIRLPOOL_IDL: Idl = ...
  • Get the size of an account owned by the Whirlpool program in bytes.

    Parameters

    Returns number

    Size in bytes of the account

PoolGraph

Edge: { poolAddress: Address }

A type representing a pool graph edge.

Type declaration

  • poolAddress: Address
Path: { edges: Edge[]; endTokenMint: string; startTokenMint: string }

A path to trade from start token mint to end token mint.

param startMint

The token the path starts with

param endMint

The token the path ends with

param edges

An ordered list of edges (pool addresses) that make up the path

Type declaration

  • edges: Edge[]
  • endTokenMint: string
  • startTokenMint: string
PathSearchEntries: (readonly [string, Path[]])[]

Results for a series of graph search queries between two tokens. The search id for each entry can be obtained from {@link PoolGraphUtils.getSearchRouteId} If a path exist between tokens for that search id, it will be an array of paths. If paths do not exist, it will be an empty array.

PathSearchOptions: { intermediateTokens: Address[] }

Options for finding a path between two tokens

param intermediateTokens

A list of tokens that can be used as intermediate hops

Type declaration

  • intermediateTokens: Address[]
PoolGraph: { getAllPaths: any; getPath: any; getPathsForPairs: any }

A type representing an undirected graph of pools that can be used to find paths between two tokens. In this graph, nodes are token mints, and edges are pools

Type declaration

  • getAllPaths:function
  • getPath:function
    • Get a list of paths between two tokens for this pool graph.

      Notes:

      • Only support paths with up to 2 edges
      • Paths searching between two identical token mints are not supported.

      Parameters

      • startMint: Address

        The token the path starts from

      • endMint: Address

        The token the path ends in

      • Optional options: PathSearchOptions

        Options for finding a path

      Returns Path[]

      A list of path between the two tokens. If no path are found, it will be an empty array.

  • getPathsForPairs:function
    • Get a map of paths from a list of token pairs for this pool graph.

      Notes:

      • Only support paths with up to 2 edges
      • Paths searching between two identical token mints are not supported.

      Parameters

      • searchTokenPairs: [Address, Address][]

        A list of token pairs to find paths for. The first token in the pair is the start token, and the second token is the end token.

      • Optional options: PathSearchOptions

        Options for finding a path

      Returns PathSearchEntries

      An array of search result entires in the same order as the searchTokenPairs.

PriceModule

DecimalsMap: Record<string, number>

A map of token mint addresses against token decimals.

GetPricesConfig: { programId: PublicKey; quoteTokens: PublicKey[]; tickSpacings: number[]; whirlpoolsConfig: PublicKey }

A config object for the PriceModule functions.

param quoteTokens

The group of quote tokens that you want to search Whirlpools for. The first token must be the token that is being priced against the other tokens. The subsequent tokens are alternative tokens that can be used to price the first token.

param tickSpacings

The group of tick spacings that you want to search Whirlpools for.

param programId

The public key of the Whirlpool Program account that you want to search Whirlpools for.

param whirlpoolsConfig

The public key of the WhirlpoolsConfig account that you want to search Whirlpools for.

Type declaration

  • programId: PublicKey
  • quoteTokens: PublicKey[]
  • tickSpacings: number[]
  • whirlpoolsConfig: PublicKey
GetPricesThresholdConfig: { amountOut: BN; priceImpactThreshold: number }

A config object for the PriceModule functions to define thresholds for price calculations. Whirlpools that do not fit the criteria set by the parameters below will be excluded in the price calculation.

param amountOut

The token amount in terms of the first quote token amount to evaluate a Whirlpool's liquidity against.

param priceImpactThreshold

Using amountOut to perform a swap quote on a pool, this value is the maximum price impact that a Whirlpool can have to be included in the price calculation.

Type declaration

  • amountOut: BN
  • priceImpactThreshold: number
PoolMap: Record<string, WhirlpoolData>

A map of whirlpool addresses against WhirlpoolData accounts

PriceCalculationData: { decimalsMap: DecimalsMap; poolMap: PoolMap; tickArrayMap: TickArrayMap }

A set of fetched accounts that are used for price calculations in PriceModule functions.

param poolMap

A map of WhirlpoolData accounts that are used for price calculations.

param tickArrayMap

A map of TickArrayData accounts that are used for price calculations.

param decimalsMap

A map of token decimals that are used for price calculations.

Type declaration

PriceMap: Record<string, Decimal | null>

A map of token mint addresses against price values. If a price is not available, the value will be null.

TickArrayMap: Record<string, TickArrayData>

A map of tick-array addresses against TickArrayData accounts

defaultGetPricesConfig: GetPricesConfig = ...

The default GetPricesConfig config for Orca's mainnet deployment.

defaultGetPricesThresholdConfig: GetPricesThresholdConfig = ...

The default GetPricesThresholdConfig config for Orca's mainnet deployment.

defaultQuoteTokens: PublicKey[] = ...

The default quote tokens used for Orca's mainnet deployment. Supply your own if you are using a different deployment.

Quotes

CollectFeesQuote: { feeOwedA: BN; feeOwedB: BN }

Type declaration

  • feeOwedA: BN
  • feeOwedB: BN
CollectFeesQuoteParam: { position: PositionData; tickLower: TickData; tickUpper: TickData; whirlpool: WhirlpoolData }

Type declaration

CollectRewardsQuote: [BN | undefined, BN | undefined, BN | undefined]

An array of reward amounts that is collectible on a position.

CollectRewardsQuoteParam: { position: PositionData; tickLower: TickData; tickUpper: TickData; timeStampInSeconds?: BN; whirlpool: WhirlpoolData }

Parameters needed to generate a quote on collectible rewards on a position.

param whirlpool

the account data for the whirlpool this position belongs to

param position

the account data for the position

param tickLower

the TickData account for the lower bound of this position

param tickUpper

the TickData account for the upper bound of this position

param timeStampInSeconds

optional parameter to generate this quote to a unix time stamp.

Type declaration

DecreaseLiquidityQuote: DecreaseLiquidityInput & { tokenEstA: BN; tokenEstB: BN }

Return object from decrease liquidity quote functions.

DecreaseLiquidityQuoteParam: { liquidity: BN; slippageTolerance: Percentage; sqrtPrice: BN; tickCurrentIndex: number; tickLowerIndex: number; tickUpperIndex: number }
param liquidity

The desired liquidity to withdraw from the Whirlpool

param tickCurrentIndex

The Whirlpool's current tickIndex

param sqrtPrice

The Whirlpool's current sqrtPrice

param tickLowerIndex

The lower index of the position that we are withdrawing from.

param tickUpperIndex

The upper index of the position that we are withdrawing from.

param slippageTolerance

The maximum slippage allowed when calculating the minimum tokens received.

Type declaration

  • liquidity: BN
  • slippageTolerance: Percentage
  • sqrtPrice: BN
  • tickCurrentIndex: number
  • tickLowerIndex: number
  • tickUpperIndex: number
DevFeeSwapQuote: NormalSwapQuote & { amountSpecifiedIsInput: true; devFeeAmount: BN; estimatedSwapFeeAmount: BN }

A collection of estimated values from quoting a swap that collects a developer-fee.

param estimatedAmountIn

Approximate number of input token swapped in the swap

param estimatedAmountOut

Approximate number of output token swapped in the swap

param estimatedEndTickIndex

Approximate tick-index the Whirlpool will land on after this swap

param estimatedEndSqrtPrice

Approximate sqrtPrice the Whirlpool will land on after this swap

param estimatedFeeAmount

Approximate feeAmount (all fees) charged on this swap

param estimatedSwapFeeAmount

Approximate feeAmount (LP + protocol fees) charged on this swap

param devFeeAmount

FeeAmount (developer fees) charged on this swap

IncreaseLiquidityQuote: IncreaseLiquidityInput & { tokenEstA: BN; tokenEstB: BN }

Return object from increase liquidity quote functions.

IncreaseLiquidityQuoteParam: { inputTokenAmount: BN; inputTokenMint: PublicKey; slippageTolerance: Percentage; sqrtPrice: BN; tickCurrentIndex: number; tickLowerIndex: number; tickUpperIndex: number; tokenMintA: PublicKey; tokenMintB: PublicKey }
param inputTokenAmount

The amount of input tokens to deposit.

param inputTokenMint

The mint of the input token the user would like to deposit.

param tokenMintA

The mint of tokenA in the Whirlpool the user is depositing into.

param tokenMintB

-The mint of tokenB in the Whirlpool the user is depositing into.

param tickCurrentIndex

The Whirlpool's current tickIndex

param sqrtPrice

The Whirlpool's current sqrtPrice

param tickLowerIndex

The lower index of the position that we are withdrawing from.

param tickUpperIndex

The upper index of the position that we are withdrawing from.

param slippageTolerance

The maximum slippage allowed when calculating the minimum tokens received.

Type declaration

  • inputTokenAmount: BN
  • inputTokenMint: PublicKey
  • slippageTolerance: Percentage
  • sqrtPrice: BN
  • tickCurrentIndex: number
  • tickLowerIndex: number
  • tickUpperIndex: number
  • tokenMintA: PublicKey
  • tokenMintB: PublicKey
NormalSwapQuote: SwapInput & SwapEstimates

A collection of estimated values from quoting a swap. Object can be directly used in a swap transaction.

NormalTwoHopSwapQuote: { swapOneEstimates: SwapEstimates; swapTwoEstimates: SwapEstimates } & TwoHopSwapInput

A collection of estimated values from quoting a two-hop-swap.

param swapOneEstimates

Estimates for the first leg of the two-hop-swap

param swapTwoEstimates

Estimates for the second leg of the two-hop-swap

experimental

Not yet ready for use

SwapEstimates: { estimatedAmountIn: BN; estimatedAmountOut: BN; estimatedEndSqrtPrice: BN; estimatedEndTickIndex: number; estimatedFeeAmount: BN }

A collection of estimated values from quoting a swap.

param estimatedAmountIn

Approximate number of input token swapped in the swap

param estimatedAmountOut

Approximate number of output token swapped in the swap

param estimatedEndTickIndex

Approximate tick-index the Whirlpool will land on after this swap

param estimatedEndSqrtPrice

Approximate sqrtPrice the Whirlpool will land on after this swap

param estimatedFeeAmount

Approximate feeAmount (all fees) charged on this swap

Type declaration

  • estimatedAmountIn: BN
  • estimatedAmountOut: BN
  • estimatedEndSqrtPrice: BN
  • estimatedEndTickIndex: number
  • estimatedFeeAmount: BN

A collection of estimated values from quoting a swap.

link

{BaseSwapQuote}

link

{DevFeeSwapQuote}

SwapQuoteParam: { aToB: boolean; amountSpecifiedIsInput: boolean; otherAmountThreshold: BN; sqrtPriceLimit: BN; tickArrays: TickArray[]; tokenAmount: BN; whirlpoolData: WhirlpoolData }
param tokenAmount

The amount of input or output token to swap from (depending on amountSpecifiedIsInput).

param otherAmountThreshold

The maximum/minimum of input/output token to swap into (depending on amountSpecifiedIsInput).

param sqrtPriceLimit

The maximum/minimum price the swap will swap to.

param aToB

The direction of the swap. True if swapping from A to B. False if swapping from B to A.

param amountSpecifiedIsInput

Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.

param tickArrays

An sequential array of tick-array objects in the direction of the trade to swap on

Type declaration

  • aToB: boolean
  • amountSpecifiedIsInput: boolean
  • otherAmountThreshold: BN
  • sqrtPriceLimit: BN
  • tickArrays: TickArray[]
  • tokenAmount: BN
  • whirlpoolData: WhirlpoolData
TwoHopSwapQuote: NormalTwoHopSwapQuote

A collection of estimated values from quoting a swap.

link

{NormalTwoHopSwapQuote}

experimental

Not yet ready for use

  • Get an estimated quote on the minimum tokens receivable based on the desired withdraw liquidity value.

    Parameters

    • liquidity: BN

      The desired liquidity to withdraw from the Whirlpool

    • slippageTolerance: Percentage

      The maximum slippage allowed when calculating the minimum tokens received.

    • position: Position

      A Position helper class to help interact with the Position account.

    • whirlpool: Whirlpool

      A Whirlpool helper class to help interact with the Whirlpool account.

    Returns DecreaseLiquidityQuote

    An DecreaseLiquidityQuote object detailing the tokenMin & liquidity values to use when calling decrease-liquidity-ix.

  • increaseLiquidityQuoteByInputToken(inputTokenMint: Address, inputTokenAmount: Decimal, tickLower: number, tickUpper: number, slippageTolerance: Percentage, whirlpool: Whirlpool): IncreaseLiquidityQuote
  • Get an estimated quote on the maximum tokens required to deposit based on a specified input token amount.

    Parameters

    • inputTokenMint: Address

      The mint of the input token the user would like to deposit.

    • inputTokenAmount: Decimal

      The amount of input tokens to deposit.

    • tickLower: number

      The lower index of the position that we are withdrawing from.

    • tickUpper: number

      The upper index of the position that we are withdrawing from.

    • slippageTolerance: Percentage

      The maximum slippage allowed when calculating the minimum tokens received.

    • whirlpool: Whirlpool

      A Whirlpool helper class to help interact with the Whirlpool account.

    Returns IncreaseLiquidityQuote

    An IncreaseLiquidityInput object detailing the required token amounts & liquidity values to use when calling increase-liquidity-ix.

  • Get an estimated swap quote using input token amount.

    Parameters

    • whirlpool: Whirlpool

      Whirlpool to perform the swap on

    • inputTokenMint: Address

      PublicKey for the input token mint to swap with

    • tokenAmount: BN

      The amount of input token to swap from

    • slippageTolerance: Percentage

      The amount of slippage to account for in this quote

    • programId: Address

      PublicKey for the Whirlpool ProgramId

    • fetcher: WhirlpoolAccountFetcherInterface
    • Optional opts: SimpleAccountFetchOptions

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

    Returns Promise<SwapQuote>

    a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.

  • swapQuoteByInputTokenWithDevFees(whirlpool: Whirlpool, inputTokenMint: Address, tokenAmount: BN, slippageTolerance: Percentage, programId: Address, fetcher: WhirlpoolAccountFetcherInterface, devFeePercentage: Percentage, opts?: SimpleAccountFetchOptions): Promise<DevFeeSwapQuote>
  • Get an estimated swap quote using input token amount while collecting dev fees.

    Parameters

    • whirlpool: Whirlpool

      Whirlpool to perform the swap on

    • inputTokenMint: Address

      PublicKey for the input token mint to swap with

    • tokenAmount: BN

      The amount of input token to swap from

    • slippageTolerance: Percentage

      The amount of slippage to account for in this quote

    • programId: Address

      PublicKey for the Whirlpool ProgramId

    • fetcher: WhirlpoolAccountFetcherInterface
    • devFeePercentage: Percentage

      The percentage amount to send to developer wallet prior to the swap. Percentage num/dem values has to match token decimal.

    • Optional opts: SimpleAccountFetchOptions

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

    Returns Promise<DevFeeSwapQuote>

    a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.

  • Get an estimated swap quote using an output token amount.

    Use this quote to get an estimated amount of input token needed to receive the defined output token amount.

    Parameters

    • whirlpool: Whirlpool

      Whirlpool to perform the swap on

    • outputTokenMint: Address

      PublicKey for the output token mint to swap into

    • tokenAmount: BN

      The maximum amount of output token to receive in this swap.

    • slippageTolerance: Percentage

      The amount of slippage to account for in this quote

    • programId: Address

      PublicKey for the Whirlpool ProgramId

    • fetcher: WhirlpoolAccountFetcherInterface
    • Optional opts: SimpleAccountFetchOptions

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

    Returns Promise<SwapQuote>

    a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.

  • Perform a sync swap quote based on the basic swap instruction parameters.

    Parameters

    • params: SwapQuoteParam

      SwapQuote parameters

    • slippageTolerance: Percentage

      The amount of slippage to account for when generating the final quote.

    Returns SwapQuote

    a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.

Router

ExecutableRoute: readonly [TradeRoute, AddressLookupTableAccount[] | undefined]

A trade route that is ready to execute. Contains the TradeRoute and a possible set of {@link AddressLookupTableAccount} that is needed to successfully execute the trade.

If the lookup table accounts are undefined, then the trade can be executed with a legacy transaction.

RouteSelectOptions: { availableAtaAccounts?: AtaAccountInfo[]; maxSupportedTransactionVersion: "legacy" | number; maxTransactionSize: number; onRouteEvaluation?: any }

Parameters to configure the selection of the best route.

param maxSupportedTransactionVersion

The maximum transaction version that the wallet supports.

param maxTransactionSize

The maximum transaction size that the wallet supports.

param availableAtaAccounts

A list of ATA accounts that are available in this wallet to use for the swap.

param onRouteEvaluation

A callback that is called right before a route is evaluated. Users have a chance to add additional instructions to be added for an accurate txn size measurement. (ex. Adding a priority fee ix to the transaction)

Type declaration

  • Optional availableAtaAccounts?: AtaAccountInfo[]
  • maxSupportedTransactionVersion: "legacy" | number
  • maxTransactionSize: number
  • onRouteEvaluation?:function
    • onRouteEvaluation(route: Readonly<TradeRoute>, tx: TransactionBuilder): void
RoutingOptions: { maxSplits: number; numTopPartialQuotes: number; numTopRoutes: number; percentIncrement: number }

Options to configure the router.

param percentIncrement

The percent increment to use when splitting a trade into multiple trades.

param numTopRoutes

The number of top routes to return from the router.

param numTopPartialQuotes

The number of top partial quotes to return from the router.

param maxSplits

The maximum number of splits to perform on a trade.

Type declaration

  • maxSplits: number
  • numTopPartialQuotes: number
  • numTopRoutes: number
  • percentIncrement: number
SubTradeRoute: { amountIn: BN; amountOut: BN; hopQuotes: TradeHop[]; path: Path; splitPercent: number }

Represents a fragment of a trade that was splitted into multiple trades for more efficient execution.

param path

The path of pool addresses that make up this sub trade.

param splitPercent

The percent of the trade that this sub trade represents.

param amountIn

The amount of token being traded in within this sub-route.

param amountOut

The amount of token being traded out within this sub-routes.

param hopQuotes

The quotes for each hop in the path of this trade.

Type declaration

  • amountIn: BN
  • amountOut: BN
  • hopQuotes: TradeHop[]
  • path: Path
  • splitPercent: number
Trade: { amountSpecifiedIsInput: boolean; tokenIn: Address; tokenOut: Address; tradeAmount: BN }

A Trade type that represents a trade between two tokens

param tokenIn

The token that is being traded in

param tokenOut

The token that is being traded out

param tradeAmount

The amount of token being traded in or out

param amountSpecifiedIsInput

Whether the trade amount is the amount being traded in or out

Type declaration

  • amountSpecifiedIsInput: boolean
  • tokenIn: Address
  • tokenOut: Address
  • tradeAmount: BN
TradeHop: { amountIn: BN; amountOut: BN; inputMint: Address; mintA: Address; mintB: Address; outputMint: Address; quote: SwapQuote; snapshot: TradeHopSnapshot; vaultA: Address; vaultB: Address; whirlpool: Address }

Represents a quote for a single hop in the path of a SubTradeRoute.

param amountIn

The amount of token being traded in for this hop.

param amountOut

The amount of token being traded out for this hop.

param whirlpool

The address of the whirlpool that this hop is trading through.

param inputMint

The address of the input token mint.

param outputMint

The address of the output token mint.

param mintA

The address of the first mint in the pool.

param mintB

The address of the second mint in the pool.

param vaultA

The address of the first vault in the pool.

param vaultB

The address of the second vault in the pool.

param quote

The SwapQuote for this hop.

param snapshot

A snapshot of the whirlpool condition when this hop was made

Type declaration

  • amountIn: BN
  • amountOut: BN
  • inputMint: Address
  • mintA: Address
  • mintB: Address
  • outputMint: Address
  • quote: SwapQuote
  • snapshot: TradeHopSnapshot
  • vaultA: Address
  • vaultB: Address
  • whirlpool: Address
TradeHopSnapshot: { aToB: boolean; feeRate: Percentage; sqrtPrice: BN }

A snapshot of the whirlpool condition when a trade hop was made.

Type declaration

  • aToB: boolean
  • feeRate: Percentage
  • sqrtPrice: BN
TradeRoute: { subRoutes: SubTradeRoute[]; totalAmountIn: BN; totalAmountOut: BN }

A trade route that is ready to execute. A trade can be broken into multiple sub-trades for potentially better trades.

param subRoutes

The sub-routes that make up the trade route. The sum of all splitPercent should equal 100.

param totalAmountIn

The total amount of token being traded in for this trade.

param totalAmountOut

The total amount of token being traded out for this trade.

Type declaration

Solana Accounts

FeeTierData: { defaultFeeRate: number; tickSpacing: number; whirlpoolsConfig: PublicKey }

Type declaration

  • defaultFeeRate: number
  • tickSpacing: number
  • whirlpoolsConfig: PublicKey
OpenPositionBumpsData: { positionBump: number }

Type declaration

  • positionBump: number
OpenPositionWithMetadataBumpsData: { metadataBump: number; positionBump: number }

Type declaration

  • metadataBump: number
  • positionBump: number
PositionBundleData: { positionBitmap: number[]; positionBundleMint: PublicKey }

Type declaration

  • positionBitmap: number[]
  • positionBundleMint: PublicKey
PositionData: { feeGrowthCheckpointA: BN; feeGrowthCheckpointB: BN; feeOwedA: BN; feeOwedB: BN; liquidity: BN; positionMint: PublicKey; rewardInfos: PositionRewardInfoData[]; tickLowerIndex: number; tickUpperIndex: number; whirlpool: PublicKey }

Type declaration

  • feeGrowthCheckpointA: BN
  • feeGrowthCheckpointB: BN
  • feeOwedA: BN
  • feeOwedB: BN
  • liquidity: BN
  • positionMint: PublicKey
  • rewardInfos: PositionRewardInfoData[]
  • tickLowerIndex: number
  • tickUpperIndex: number
  • whirlpool: PublicKey
PositionRewardInfoData: { amountOwed: BN; growthInsideCheckpoint: BN }

Type declaration

  • amountOwed: BN
  • growthInsideCheckpoint: BN
TickArrayData: { startTickIndex: number; ticks: TickData[]; whirlpool: PublicKey }

Type declaration

  • startTickIndex: number
  • ticks: TickData[]
  • whirlpool: PublicKey
TickData: { feeGrowthOutsideA: BN; feeGrowthOutsideB: BN; initialized: boolean; liquidityGross: BN; liquidityNet: BN; rewardGrowthsOutside: BN[] }

Type declaration

  • feeGrowthOutsideA: BN
  • feeGrowthOutsideB: BN
  • initialized: boolean
  • liquidityGross: BN
  • liquidityNet: BN
  • rewardGrowthsOutside: BN[]
WhirlpoolBumpsData: { whirlpoolBump: number }

Type declaration

  • whirlpoolBump: number
WhirlpoolData: { feeGrowthGlobalA: BN; feeGrowthGlobalB: BN; feeRate: number; liquidity: BN; protocolFeeOwedA: BN; protocolFeeOwedB: BN; protocolFeeRate: number; rewardInfos: WhirlpoolRewardInfoData[]; rewardLastUpdatedTimestamp: BN; sqrtPrice: BN; tickCurrentIndex: number; tickSpacing: number; tokenMintA: PublicKey; tokenMintB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpoolBump: number[]; whirlpoolsConfig: PublicKey }

Type declaration

  • feeGrowthGlobalA: BN
  • feeGrowthGlobalB: BN
  • feeRate: number
  • liquidity: BN
  • protocolFeeOwedA: BN
  • protocolFeeOwedB: BN
  • protocolFeeRate: number
  • rewardInfos: WhirlpoolRewardInfoData[]
  • rewardLastUpdatedTimestamp: BN
  • sqrtPrice: BN
  • tickCurrentIndex: number
  • tickSpacing: number
  • tokenMintA: PublicKey
  • tokenMintB: PublicKey
  • tokenVaultA: PublicKey
  • tokenVaultB: PublicKey
  • whirlpoolBump: number[]
  • whirlpoolsConfig: PublicKey
WhirlpoolRewardInfoData: { authority: PublicKey; emissionsPerSecondX64: BN; growthGlobalX64: BN; mint: PublicKey; vault: PublicKey }

Type declaration

  • authority: PublicKey
  • emissionsPerSecondX64: BN
  • growthGlobalX64: BN
  • mint: PublicKey
  • vault: PublicKey
WhirlpoolsConfigData: { collectProtocolFeesAuthority: PublicKey; defaultFeeRate: number; defaultProtocolFeeRate: number; feeAuthority: PublicKey; rewardEmissionsSuperAuthority: PublicKey }

Type declaration

  • collectProtocolFeesAuthority: PublicKey
  • defaultFeeRate: number
  • defaultProtocolFeeRate: number
  • feeAuthority: PublicKey
  • rewardEmissionsSuperAuthority: PublicKey
WHIRLPOOL_ACCOUNT_SIZE: number = ...

Size of the Whirlpool account in bytes.

deprecated

Please use getAccountSize instead.

WHIRLPOOL_CODER: BorshAccountsCoder<string> = ...

The Anchor coder for the Whirlpool program.

Whirlpool Utils

TokenAmounts: { tokenA: BN; tokenB: BN }

Type declaration

  • tokenA: BN
  • tokenB: BN

WhirlpoolClient

TickArray: { address: PublicKey; data: TickArrayData | null }

A wrapper class of a TickArray on a Whirlpool

Type declaration

TokenAccountInfo: Account

Extended (token) Account type to host account info for a Token.

TokenInfo: Mint & { mint: PublicKey }

Extended Mint type to host token info.

WhirlpoolRewardInfo: WhirlpoolRewardInfoData & { initialized: boolean; vaultAmount: BN }

Type to represent a reward for a reward index on a Whirlpool.

  • Construct a WhirlpoolClient instance to help interact with Whirlpools accounts with.

    Parameters

    Returns WhirlpoolClient

    a WhirlpoolClient instance to help with interacting with Whirlpools accounts.

Generated using TypeDoc