What you can do
| swap | Swap tokens on a whirlpool | Build the swap with the Orca SDK (quote, slippage, tick arrays) or the swap instruction, then sign and send. Route through Jupiter if the best path crosses several pools. |
| open-position | Open a liquidity position in a price range | open_position_with_metadata (or open_position), then increase_liquidity with the chosen liquidity amount and maximum amounts for both tokens. |
| close-position | Remove liquidity and close a position | decrease_liquidity with the full liquidity, then collect_fees and collect_reward for each reward index, then close_position. |
Concentrated positions earn fees only while the pool price is inside their range. Out-of-range positions hold one token and earn nothing until the price returns.
Pools can be created permissionlessly for any token pair, including copycat or scam tokens. Check the mint and the pool's liquidity before providing liquidity.
Use slippage thresholds on every swap and on liquidity changes, since the price can move between quoting and sending.
Orca's program is upgradeable by its program authority and fee authorities, which can change fee rates and reward settings.
Contracts
Read any function, or build a write and sign it. Amounts are in base units (1 USDC = 1000000).Whirlpool programexchange on solanawhirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc
write swap
Exact-in or exact-out swap through one whirlpool. Takes the amount, a threshold (minimum out for exact in, maximum in for exact out), a price limit, and direction flags. Pass the pool's vault, tick array and oracle accounts; the SDK fills these in.
write two_hop_swap
Swap through two whirlpools in one instruction, for token A to token C through token B. Takes the same kind of amount and threshold arguments as swap, per leg.
write open_position
Create an empty position NFT in a tick range. Takes the tick lower and upper bounds. Add liquidity with increase_liquidity afterwards.
write open_position_with_metadata
Same as open_position but also creates the position's metadata account, so wallets show it with a name.
write increase_liquidity
Add liquidity to a position. Arguments: liquidity amount, token A maximum, and token B maximum. Needs the token accounts for both sides, and the tick arrays covering the position range.
write decrease_liquidity
Remove liquidity from a position. Arguments: liquidity amount, token A minimum and token B minimum (slippage guards). Removed tokens go to the owner's token accounts.
write collect_fees
Claim the trading fees a position has earned, sent to the owner's token accounts.
write collect_reward
Claim one reward token's emissions for a position. Takes the reward index (Whirlpools pools have up to three reward slots).
write update_fees_and_rewards
Refresh a position's accrued fees and rewards without claiming. Call before reading owed amounts if you need them up to date.
write close_position
Delete an empty position and return its rent. Remove all liquidity and collect fees and rewards first.
write initialize_pool
Create a new whirlpool for a token pair, tick spacing and starting price. Most agents only need existing pools.