Options
All
  • Public
  • Public/Protected
  • All
Menu

@orca-so/whirlpools-sdk

Index

Constants

Core

Fetcher

Instruction Types

Other

Parsables

Quotes

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_WHIRLPOOLS_CONFIG: PublicKey = ...

Orca's WhirlpoolsConfig PublicKey.

ORCA_WHIRLPOOL_PROGRAM_ID: PublicKey = ...

Program ID hosting Orca's Whirlpool program.

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.

Fetcher

ListWhirlpoolParams: { configId: Address; programId: Address }

Filter params for Whirlpools when invoking getProgramAccounts.

Type declaration

  • configId: Address
  • programId: Address
WhirlpoolAccount: [Address, WhirlpoolData]

Tuple containing Whirlpool address and parsed account data.

Instruction Types

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.

DevFeeSwapInput: SwapInput & { devFeeAmount: u64 }

Parameters to swap on a Whirlpool with developer fees

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.

param devFeeAmount

FeeAmount (developer fees) charged on this swap

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

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: u64
  • tokenMaxB: u64
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
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
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: u64; amountSpecifiedIsInput: boolean; otherAmountThreshold: u64; sqrtPriceLimit: BN; tickArray0: PublicKey; tickArray1: PublicKey; tickArray2: PublicKey }

Parameters to 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: u64
  • amountSpecifiedIsInput: boolean
  • otherAmountThreshold: u64
  • sqrtPriceLimit: BN
  • tickArray0: PublicKey
  • tickArray1: PublicKey
  • tickArray2: PublicKey
SwapParams: SwapInput & { oracle: PublicKey; tokenAuthority: PublicKey; tokenOwnerAccountA: PublicKey; tokenOwnerAccountB: PublicKey; tokenVaultA: PublicKey; tokenVaultB: PublicKey; whirlpool: PublicKey }

Parameters and accounts to 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.

param whirlpool

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

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

Other

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]
CollectRewardsQuoteParam: { position: PositionData; tickLower: TickData; tickUpper: TickData; whirlpool: WhirlpoolData }

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: u64; estimatedSwapFeeAmount: u64 }

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: u64; tokenEstB: u64 }

Return object from increase liquidity quote functions.

IncreaseLiquidityQuoteParam: { inputTokenAmount: u64; 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: u64
  • inputTokenMint: PublicKey
  • slippageTolerance: Percentage
  • sqrtPrice: BN
  • tickCurrentIndex: number
  • tickLowerIndex: number
  • tickUpperIndex: number
  • tokenMintA: PublicKey
  • tokenMintB: PublicKey
NormalSwapQuote: { estimatedAmountIn: u64; estimatedAmountOut: u64; estimatedEndSqrtPrice: BN; estimatedEndTickIndex: number; estimatedFeeAmount: u64 } & SwapInput

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

A collection of estimated values from quoting a swap.

link

{BaseSwapQuote}

link

{DevFeeSwapQuote}

SwapQuoteParam: { aToB: boolean; amountSpecifiedIsInput: boolean; otherAmountThreshold: u64; sqrtPriceLimit: BN; tickArrays: TickArray[]; tokenAmount: u64; 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: u64
  • sqrtPriceLimit: BN
  • tickArrays: TickArray[]
  • tokenAmount: u64
  • whirlpoolData: WhirlpoolData
  • 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.

  • swapQuoteByInputToken(whirlpool: Whirlpool, inputTokenMint: Address, tokenAmount: u64, slippageTolerance: Percentage, programId: Address, fetcher: AccountFetcher, refresh: boolean): Promise<SwapQuote>
  • 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: u64

      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: AccountFetcher

      AccountFetcher object to fetch solana accounts

    • refresh: boolean

      If true, fetcher would default to fetching the latest 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: u64, slippageTolerance: Percentage, programId: Address, fetcher: AccountFetcher, devFeePercentage: Percentage, refresh: boolean): 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: u64

      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: AccountFetcher

      AccountFetcher object to fetch solana accounts

    • devFeePercentage: Percentage

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

    • refresh: boolean

      If true, fetcher would default to fetching the latest accounts

    Returns Promise<DevFeeSwapQuote>

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

  • swapQuoteByOutputToken(whirlpool: Whirlpool, outputTokenMint: Address, tokenAmount: u64, slippageTolerance: Percentage, programId: Address, fetcher: AccountFetcher, refresh: boolean): Promise<SwapQuote>
  • 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: u64

      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: AccountFetcher

      AccountFetcher object to fetch solana accounts

    • refresh: boolean

      If true, fetcher would default to fetching the latest 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.

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

WHIRLPOOL_CODER: BorshAccountsCoder<string> = ...

The Anchor coder for the Whirlpool program.

Whirlpool Utils

TokenAmounts: { tokenA: u64; tokenB: u64 }

Type declaration

  • tokenA: u64
  • tokenB: u64

WhirlpoolClient

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

A wrapper class of a TickArray on a Whirlpool

Type declaration

TokenAccountInfo: AccountInfo

Extended AccountInfo type to host account info for a Token.

TokenInfo: MintInfo & { mint: PublicKey }

Extended MintInfo type to host token info.

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

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