UNPKG

@orca-so/whirlpools-sdk

Version:

Typescript SDK to interact with Orca's Whirlpool program.

1,501 lines 259 kB
{ "address": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc", "metadata": { "name": "whirlpool", "version": "0.9.0", "spec": "0.1.0" }, "instructions": [ { "name": "close_bundled_position", "docs": [ "Close a bundled position in a Whirlpool.", "", "### Authority", "- `position_bundle_authority` - authority that owns the token corresponding to this desired position bundle.", "", "### Parameters", "- `bundle_index` - The bundle index that we'd like to close.", "", "#### Special Errors", "- `InvalidBundleIndex` - If the provided bundle index is out of bounds.", "- `ClosePositionNotEmpty` - The provided position account is not empty." ], "discriminator": [ 41, 36, 216, 245, 27, 85, 103, 67 ], "accounts": [ { "name": "bundled_position", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 98, 117, 110, 100, 108, 101, 100, 95, 112, 111, 115, 105, 116, 105, 111, 110 ] }, { "kind": "account", "path": "position_bundle.position_bundle_mint", "account": "PositionBundle" }, { "kind": "arg", "path": "bundle_index" } ] } }, { "name": "position_bundle", "writable": true }, { "name": "position_bundle_token_account" }, { "name": "position_bundle_authority", "signer": true }, { "name": "receiver", "writable": true } ], "args": [ { "name": "bundle_index", "type": "u16" } ] }, { "name": "close_position", "docs": [ "Close a position in a Whirlpool. Burns the position token in the owner's wallet.", "", "### Authority", "- \"position_authority\" - The authority that owns the position token.", "", "#### Special Errors", "- `ClosePositionNotEmpty` - The provided position account is not empty." ], "discriminator": [ 123, 134, 81, 0, 49, 68, 98, 98 ], "accounts": [ { "name": "position_authority", "signer": true }, { "name": "receiver", "writable": true }, { "name": "position", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 112, 111, 115, 105, 116, 105, 111, 110 ] }, { "kind": "account", "path": "position_mint" } ] } }, { "name": "position_mint", "writable": true }, { "name": "position_token_account", "writable": true }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" } ], "args": [] }, { "name": "close_position_with_token_extensions", "docs": [ "Close a position in a Whirlpool. Burns the position token in the owner's wallet.", "Mint and TokenAccount are based on Token-2022. And Mint accout will be also closed.", "", "### Authority", "- \"position_authority\" - The authority that owns the position token.", "", "#### Special Errors", "- `ClosePositionNotEmpty` - The provided position account is not empty." ], "discriminator": [ 1, 182, 135, 59, 155, 25, 99, 223 ], "accounts": [ { "name": "position_authority", "signer": true }, { "name": "receiver", "writable": true }, { "name": "position", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 112, 111, 115, 105, 116, 105, 111, 110 ] }, { "kind": "account", "path": "position_mint" } ] } }, { "name": "position_mint", "writable": true }, { "name": "position_token_account", "writable": true }, { "name": "token_2022_program", "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" } ], "args": [] }, { "name": "collect_fees", "docs": [ "Collect fees accrued for this position.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position." ], "discriminator": [ 164, 152, 207, 99, 30, 186, 19, 182 ], "accounts": [ { "name": "whirlpool", "relations": [ "position" ] }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" } ], "args": [] }, { "name": "collect_fees_v2", "docs": [ "Collect fees accrued for this position.", "This instruction works with both Token and Token-2022.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position." ], "discriminator": [ 207, 117, 95, 191, 229, 180, 226, 15 ], "accounts": [ { "name": "whirlpool", "relations": [ "position" ] }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_mint_a" }, { "name": "token_mint_b" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "token_program_a" }, { "name": "token_program_b" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" } ], "args": [ { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "collect_protocol_fees", "docs": [ "Collect the protocol fees accrued in this Whirlpool", "", "### Authority", "- `collect_protocol_fees_authority` - assigned authority in the WhirlpoolConfig that can collect protocol fees" ], "discriminator": [ 22, 67, 23, 98, 150, 178, 70, 220 ], "accounts": [ { "name": "whirlpools_config", "relations": [ "whirlpool" ] }, { "name": "whirlpool", "writable": true }, { "name": "collect_protocol_fees_authority", "signer": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "token_destination_a", "writable": true }, { "name": "token_destination_b", "writable": true }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" } ], "args": [] }, { "name": "collect_protocol_fees_v2", "docs": [ "Collect the protocol fees accrued in this Whirlpool", "This instruction works with both Token and Token-2022.", "", "### Authority", "- `collect_protocol_fees_authority` - assigned authority in the WhirlpoolConfig that can collect protocol fees" ], "discriminator": [ 103, 128, 222, 134, 114, 200, 22, 200 ], "accounts": [ { "name": "whirlpools_config", "relations": [ "whirlpool" ] }, { "name": "whirlpool", "writable": true }, { "name": "collect_protocol_fees_authority", "signer": true }, { "name": "token_mint_a" }, { "name": "token_mint_b" }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "token_destination_a", "writable": true }, { "name": "token_destination_b", "writable": true }, { "name": "token_program_a" }, { "name": "token_program_b" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" } ], "args": [ { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "collect_reward", "docs": [ "Collect rewards accrued for this position.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position." ], "discriminator": [ 70, 5, 132, 87, 86, 235, 177, 34 ], "accounts": [ { "name": "whirlpool", "relations": [ "position" ] }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "reward_owner_account", "writable": true }, { "name": "reward_vault", "writable": true }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" } ], "args": [ { "name": "reward_index", "type": "u8" } ] }, { "name": "collect_reward_v2", "docs": [ "Collect rewards accrued for this position.", "This instruction works with both Token and Token-2022.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position." ], "discriminator": [ 177, 107, 37, 180, 160, 19, 49, 209 ], "accounts": [ { "name": "whirlpool", "relations": [ "position" ] }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "reward_owner_account", "writable": true }, { "name": "reward_mint" }, { "name": "reward_vault", "writable": true }, { "name": "reward_token_program" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" } ], "args": [ { "name": "reward_index", "type": "u8" }, { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "decrease_liquidity", "docs": [ "Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position.", "", "### Parameters", "- `liquidity_amount` - The total amount of Liquidity the user desires to withdraw.", "- `token_min_a` - The minimum amount of tokenA the user is willing to withdraw.", "- `token_min_b` - The minimum amount of tokenB the user is willing to withdraw.", "", "#### Special Errors", "- `LiquidityZero` - Provided liquidity amount is zero.", "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", "- `TokenMinSubceeded` - The required token to perform this operation subceeds the user defined amount." ], "discriminator": [ 160, 38, 208, 111, 104, 91, 44, 1 ], "accounts": [ { "name": "whirlpool", "writable": true, "relations": [ "position" ] }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "tick_array_lower", "writable": true }, { "name": "tick_array_upper", "writable": true } ], "args": [ { "name": "liquidity_amount", "type": "u128" }, { "name": "token_min_a", "type": "u64" }, { "name": "token_min_b", "type": "u64" } ] }, { "name": "decrease_liquidity_v2", "docs": [ "Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", "This instruction works with both Token and Token-2022.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position.", "", "### Parameters", "- `liquidity_amount` - The total amount of Liquidity the user desires to withdraw.", "- `token_min_a` - The minimum amount of tokenA the user is willing to withdraw.", "- `token_min_b` - The minimum amount of tokenB the user is willing to withdraw.", "", "#### Special Errors", "- `LiquidityZero` - Provided liquidity amount is zero.", "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", "- `TokenMinSubceeded` - The required token to perform this operation subceeds the user defined amount." ], "discriminator": [ 58, 127, 188, 62, 79, 82, 196, 96 ], "accounts": [ { "name": "whirlpool", "writable": true, "relations": [ "position" ] }, { "name": "token_program_a" }, { "name": "token_program_b" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_mint_a" }, { "name": "token_mint_b" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "tick_array_lower", "writable": true }, { "name": "tick_array_upper", "writable": true } ], "args": [ { "name": "liquidity_amount", "type": "u128" }, { "name": "token_min_a", "type": "u64" }, { "name": "token_min_b", "type": "u64" }, { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "delete_position_bundle", "docs": [ "Delete a PositionBundle account. Burns the position bundle token in the owner's wallet.", "", "### Authority", "- `position_bundle_owner` - The owner that owns the position bundle token.", "", "### Special Errors", "- `PositionBundleNotDeletable` - The provided position bundle has open positions." ], "discriminator": [ 100, 25, 99, 2, 217, 239, 124, 173 ], "accounts": [ { "name": "position_bundle", "writable": true }, { "name": "position_bundle_mint", "writable": true }, { "name": "position_bundle_token_account", "writable": true }, { "name": "position_bundle_owner", "signer": true }, { "name": "receiver", "writable": true }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" } ], "args": [] }, { "name": "delete_token_badge", "docs": [ "Delete a TokenBadge account.", "", "### Authority", "- \"token_badge_authority\" - Set authority in the WhirlpoolConfigExtension", "", "### Special Errors", "- `FeatureIsNotEnabled` - If the feature flag for token badges is not enabled." ], "discriminator": [ 53, 146, 68, 8, 18, 117, 17, 185 ], "accounts": [ { "name": "whirlpools_config", "relations": [ "whirlpools_config_extension", "token_badge" ] }, { "name": "whirlpools_config_extension" }, { "name": "token_badge_authority", "signer": true }, { "name": "token_mint" }, { "name": "token_badge", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 116, 111, 107, 101, 110, 95, 98, 97, 100, 103, 101 ] }, { "kind": "account", "path": "whirlpools_config" }, { "kind": "account", "path": "token_mint" } ] } }, { "name": "receiver", "writable": true } ], "args": [] }, { "name": "idl_include", "discriminator": [ 223, 253, 121, 121, 60, 193, 129, 31 ], "accounts": [ { "name": "tick_array" }, { "name": "system_program", "address": "11111111111111111111111111111111" } ], "args": [] }, { "name": "increase_liquidity", "docs": [ "Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position.", "", "### Parameters", "- `liquidity_amount` - The total amount of Liquidity the user is willing to deposit.", "- `token_max_a` - The maximum amount of tokenA the user is willing to deposit.", "- `token_max_b` - The maximum amount of tokenB the user is willing to deposit.", "", "#### Special Errors", "- `LiquidityZero` - Provided liquidity amount is zero.", "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", "- `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount." ], "discriminator": [ 46, 156, 243, 118, 13, 205, 251, 178 ], "accounts": [ { "name": "whirlpool", "writable": true, "relations": [ "position" ] }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "tick_array_lower", "writable": true }, { "name": "tick_array_upper", "writable": true } ], "args": [ { "name": "liquidity_amount", "type": "u128" }, { "name": "token_max_a", "type": "u64" }, { "name": "token_max_b", "type": "u64" } ] }, { "name": "increase_liquidity_by_token_amounts_v2", "docs": [ "Add liquidity to a position by specifying token maxima, not liquidity.", "This instruction works with both Token and Token-2022.", "", "NOTE: This instruction is only implemented in Pinocchio, not Anchor.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position.", "", "### Parameters", "- `token_max_a` - The maximum amount of tokenA the user is willing to deposit.", "- `token_max_b` - The maximum amount of tokenB the user is willing to deposit.", "- `min_sqrt_price` - The minimum sqrt price allowed.", "- `max_sqrt_price` - The maximum sqrt price allowed.", "", "", "#### Special Errors", "- `LiquidityZero` - Computed liquidity amount is zero.", "- `LiquidityTooHigh` - Computed liquidity exceeds u128::max.", "- `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount." ], "discriminator": [ 239, 251, 9, 124, 210, 198, 53, 43 ], "accounts": [ { "name": "whirlpool", "writable": true, "relations": [ "position" ] }, { "name": "token_program_a" }, { "name": "token_program_b" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_mint_a" }, { "name": "token_mint_b" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "tick_array_lower", "writable": true }, { "name": "tick_array_upper", "writable": true } ], "args": [ { "name": "method", "type": { "defined": { "name": "IncreaseLiquidityMethod" } } }, { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "increase_liquidity_v2", "docs": [ "Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", "This instruction works with both Token and Token-2022.", "", "### Authority", "- `position_authority` - authority that owns the token corresponding to this desired position.", "", "### Parameters", "- `liquidity_amount` - The total amount of Liquidity the user is willing to deposit.", "- `token_max_a` - The maximum amount of tokenA the user is willing to deposit.", "- `token_max_b` - The maximum amount of tokenB the user is willing to deposit.", "", "#### Special Errors", "- `LiquidityZero` - Provided liquidity amount is zero.", "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", "- `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount." ], "discriminator": [ 133, 29, 89, 223, 69, 238, 176, 10 ], "accounts": [ { "name": "whirlpool", "writable": true, "relations": [ "position" ] }, { "name": "token_program_a" }, { "name": "token_program_b" }, { "name": "memo_program", "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" }, { "name": "position_authority", "signer": true }, { "name": "position", "writable": true }, { "name": "position_token_account" }, { "name": "token_mint_a" }, { "name": "token_mint_b" }, { "name": "token_owner_account_a", "writable": true }, { "name": "token_owner_account_b", "writable": true }, { "name": "token_vault_a", "writable": true }, { "name": "token_vault_b", "writable": true }, { "name": "tick_array_lower", "writable": true }, { "name": "tick_array_upper", "writable": true } ], "args": [ { "name": "liquidity_amount", "type": "u128" }, { "name": "token_max_a", "type": "u64" }, { "name": "token_max_b", "type": "u64" }, { "name": "remaining_accounts_info", "type": { "option": { "defined": { "name": "RemainingAccountsInfo" } } } } ] }, { "name": "initialize_adaptive_fee_tier", "docs": [ "Initializes an adaptive_fee_tier account usable by Whirlpools in a WhirlpoolConfig space.", "", "### Authority", "- \"fee_authority\" - Set authority in the WhirlpoolConfig", "", "### Parameters", "- `fee_tier_index` - The index of the fee-tier that this adaptive fee tier will be initialized.", "- `tick_spacing` - The tick-spacing that this fee-tier suggests the default_fee_rate for.", "- `initialize_pool_authority` - The authority that can initialize pools with this adaptive fee-tier.", "- `delegated_fee_authority` - The authority that can set the base fee rate for pools using this adaptive fee-tier.", "- `default_fee_rate` - The default fee rate that a pool will use if the pool uses this", "fee tier during initialization.", "- `filter_period` - Period determine high frequency trading time window. (seconds)", "- `decay_period` - Period determine when the adaptive fee start decrease. (seconds)", "- `reduction_factor` - Adaptive fee rate decrement rate.", "- `adaptive_fee_control_factor` - Adaptive fee control factor.", "- `max_volatility_accumulator` - Max volatility accumulator.", "- `tick_group_size` - Tick group size to define tick group index.", "- `major_swap_threshold_ticks` - Major swap threshold ticks to define major swap.", "", "#### Special Errors", "- `InvalidTickSpacing` - If the provided tick_spacing is 0.", "- `InvalidFeeTierIndex` - If the provided fee_tier_index is same to tick_spacing.", "- `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE.", "- `InvalidAdaptiveFeeConstants` - If the provided adaptive fee constants are invalid." ], "discriminator": [ 77, 99, 208, 200, 141, 123, 117, 48 ], "accounts": [ { "name": "whirlpools_config" }, { "name": "adaptive_fee_tier", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 102, 101, 101, 95, 116, 105, 101, 114 ] }, { "kind": "account", "path": "whirlpools_config" }, { "kind": "arg", "path": "fee_tier_index" } ] } }, { "name": "funder", "writable": true, "signer": true }, { "name": "fee_authority", "signer": true }, { "name": "system_program", "address": "11111111111111111111111111111111" } ], "args": [ { "name": "fee_tier_index", "type": "u16" }, { "name": "tick_spacing", "type": "u16" }, { "name": "initialize_pool_authority", "type": "pubkey" }, { "name": "delegated_fee_authority", "type": "pubkey" }, { "name": "default_base_fee_rate", "type": "u16" }, { "name": "filter_period", "type": "u16" }, { "name": "decay_period", "type": "u16" }, { "name": "reduction_factor", "type": "u16" }, { "name": "adaptive_fee_control_factor", "type": "u32" }, { "name": "max_volatility_accumulator", "type": "u32" }, { "name": "tick_group_size", "type": "u16" }, { "name": "major_swap_threshold_ticks", "type": "u16" } ] }, { "name": "initialize_config", "docs": [ "Initializes a WhirlpoolsConfig account that hosts info & authorities", "required to govern a set of Whirlpools.", "", "### Authority", "- \"authority\" - Set authority that is one of ADMINS.", "", "### Parameters", "- `fee_authority` - Authority authorized to initialize fee-tiers and set customs fees.", "- `collect_protocol_fees_authority` - Authority authorized to collect protocol fees.", "- `reward_emissions_super_authority` - Authority authorized to set reward authorities in pools." ], "discriminator": [ 208, 127, 21, 1, 194, 190, 196, 70 ], "accounts": [ { "name": "config", "writable": true, "signer": true }, { "name": "funder", "writable": true, "signer": true }, { "name": "system_program", "address": "11111111111111111111111111111111" } ], "args": [ { "name": "fee_authority", "type": "pubkey" }, { "