createTradePtInstruction
Builds a raw instruction to execute an exact-in swap between PT and SY tokens. The swap direction determines whether PT is being bought (SY in, PT out) or sold (PT in, SY out). An optional price limit provides anti-sandwich protection by reverting if the spot price moves beyond the specified threshold.Usage
Accounts
| Name | Type | Signer | Writable | Description |
|---|---|---|---|---|
trader | PublicKey | Yes | Yes | Wallet executing the trade |
market | PublicKey | No | Yes | The CLMM market account |
ticks | PublicKey | No | Yes | The market tick array account |
tokenSyTrader | PublicKey | No | Yes | Trader’s SY token account |
tokenPtTrader | PublicKey | No | Yes | Trader’s PT token account |
tokenSyEscrow | PublicKey | No | Yes | Market SY escrow account |
tokenPtEscrow | PublicKey | No | Yes | Market PT escrow account |
addressLookupTable | PublicKey | No | No | Market address lookup table |
tokenProgram | PublicKey | No | No | SPL Token program |
syProgram | PublicKey | No | No | SY program |
tokenFeeTreasurySy | PublicKey | No | Yes | SY fee treasury account |
tokenFeeTreasuryPt | PublicKey | No | Yes | PT fee treasury account |
eventAuthority | PublicKey | No | No | Event authority PDA |
program | PublicKey | No | No | CLMM program ID |
Args
| Name | Type | Description |
|---|---|---|
amountIn | u64 | Exact amount of input tokens |
swapDirection | SwapDirection | Direction of the swap: BuyPt or SellPt |
amountOutConstraint | u64 (optional) | Minimum amount of output tokens to receive |
priceSpotLimit | f64 (optional) | Price limit for anti-sandwich protection |
Returns
TransactionInstruction — a transaction instruction ready to be added to a transaction.