Placing Taker Orders
Fill limit orders as a searcher — instruction layout, accounts, WSOL edge cases, and full execution code.
Searchers fill orders by invoking the TakeOrder instruction (discriminator 2). Orders can be partially or fully fulfilled — in both cases the taker receives their tokens immediately.
Fill behavior
Full fill
When an order is fully filled, the program automatically:
Creates the maker's ATA for the output tokens (if needed).
Refunds the original rent used in the Limit Order back to the maker.
Reimburses any lamports back to the taker if they had to pay for any ATA creation.
For WSOL output — returns funds back to the maker as SOL instead of WSOL.
Partial fill
For partial fills, the taker receives their tokens immediately. The remaining input tokens stay in the program vault. The maker can withdraw filled output tokens at any time.
Example: 100 USDC → 1 SOL with 5 BPS fee
User creates a limit order paying the rent and depositing 100 USDC into the vault. Price is set to
0.01.Adjusting for fees — when it is favourable to trade 1.0005 SOL → 100 USDC, the taker comes in and takes the full order.
Under the hood, taker deposits 1.0005 SOL into the vault. 100 USDC is moved from the vault to the taker's ATA, 0.0005 WSOL fee is moved to the fee receiver's wallet.
Contract determines the limit order is fulfilled. Since the output is SOL, the special WSOL edge case is handled:
The contract expects a taker-owned WSOL (non-ATA) token account is passed into the call.
The WSOL vault sends 1 SOL to this token account and closes it out to the maker, crediting their wallet balance with the 1 SOL.
The limit order is closed and rent is sent to the taker.
The taker sends the rent funds to the maker subtracting any rent they paid for the WSOL token account.
WSOL handling
When the output mint is WSOL and the order will close:
The taker must pass a seeded (non-ATA) WSOL token account as the maker's output account.
The program sends SOL to this account and closes it to the maker, crediting their wallet balance directly.
The taker wraps SOL into their ATA before the take, and closes the ATA after.
TakeOrder accounts
0—taker— Taker wallet. Writable, signer.1—maker— Maker wallet (receives output tokens on full fill). Writable.2—inputMint— Input token mint. Read-only.3—outputMint— Output token mint. Read-only.4—limitOrder— Limit order PDA. Writable.5—takerInputMintTokenAccount— Taker's input token account (receives input tokens). Writable.6—takerOutputMintTokenAccount— Taker's output token account (sends output tokens + fees). Writable.7—makerOutputMintTokenAccount— Maker's output token account (or seeded account for WSOL). Writable.8—makerInputMintTokenAccount— Maker's input token account (for remaining balance on close). Writable.9—feeReceiverTokenAccount— Fee receiver's output token account. Writable.10—vaultManager— Vault manager PDA (["vault_manager"]). Read-only.11—inputMintVault— Vault's input token account. Writable.12—outputMintVault— Vault's output token account. Writable.13—systemProgram— System program. Read-only.14—inputMintProgram— Token program for input mint (SPL or SPL-2022). Read-only.15—outputMintProgram— Token program for output mint (SPL or SPL-2022). Read-only.16—associatedTokenProgram— Associated Token Program. Read-only.17—instructionsSysvar— Instructions sysvar. Read-only.
Instruction data
Byte 0 —
discriminator(u8) — Always2(TakeOrder).Bytes 1–8 —
amount(u64, little-endian) — Input token amount to take.Bytes 9–16 —
max_cost_amount(u64, little-endian) — Maximum output tokens the taker will pay. Useu64::MAXfor no limit.Byte 17 —
output_mint_token_account_bump(u8) — PDA bump for maker's output token account.Byte 18 —
input_mint_token_account_bump(u8) — PDA bump for maker's input token account.Byte 19 —
fee_receiver_output_mint_bump(u8) — PDA bump for fee receiver's output token account.
Full execution code
The following code shows how to create a complete set of instructions to execute a TakeOrder, including setup (ATA creation, WSOL wrapping) and cleanup (WSOL unwrapping).
Related pages
Limit Orders Overview — Order structure, price calculation, time-in-force, fees
Limit Order Events — Event structure and parsing from program logs
Error Codes — Program error codes
Last updated

