Skip to main content
A Long buys option contracts from an OptionPool and can sell them back to the pool before expiration. All Long trade builders require a fresh shard-0 Pyth price feed account as priceUpdateAccount. See Pricing and Oracles for how to resolve it.

Opening a Long

1

Check Pool Liquidity

Call preflightBuyFromPoolMarketOrder before building the transaction. It checks that both OptionPool.totalAvailable and active Writers’ Unsold Size can fill your quantity.
2

Build and Send the Market Order

Use buildBuyFromPoolMarketOrderTransactionWithDerivation to derive all accounts, attach active Writer remaining accounts, and enforce your quotedPremiumTotal plus slippage buffer. Send the result as a version 1 transaction.

Multi-Leg Long Buy

Use buildBuyFromPoolMultiFromIdentities to open up to 4 Long legs in one instruction when all legs share the same underlyingAsset and payment mint:

Closing a Long

Check preflightCloseLongToPool before closing to verify that active Writers’ sold quantity matches the pool.
buildCloseLongToPoolTransactionWithDerivation appends a CloseAccount instruction by default to reclaim the buyer’s LONG token account rent. On a partial close, always pass closeLongTokenAccount: false so the account stays open for the remaining contracts.