Prerequisites
Before starting, make sure you have:- An access token carrying the
trade:executescope. - A user with 1-click trading enabled.
- Amounts prepared as integer strings in base units.
Endpoints Used
Before You Trade
ChecktradingEnabled on GET /partner/v1/me. A user can revoke wallet delegation after connecting, and once they do, every trade will fail with 403 delegation_missing.
Setting Slippage
Every trade needs a bound on how far the price may move between quoting and execution, and there are two ways to give one. Which one you get is decided by whether the body containsslippageBps.
Slippage Mode
SendslippageBps and Trench quotes the trade at execution time and derives the bound for you. This is the simpler option, and it is the one to reach for unless you are running your own pricing.
100 is 1%, and the accepted range is 0 to 5000.
Explicit Mode
OmitslippageBps and you supply the bound yourself as minTokensOut on a buy or minSolOut on a sell. Both are then required.
slippage_exceeded rather than filling at a worse price. That is true in both modes.
Buy
A standard buy spends up to a fixed amount of SOL.Buy Exact Out
An exact-out buy purchases a specific token amount while capping what you spend. This is the right endpoint when the user picks a quantity rather than a SOL budget.maxSolIn becomes optional here, since the quote produces one. You may still send it as a hard ceiling, in which case whichever value is lower applies.
Sell
Migrated Tokens
A Trench token starts on the bonding curve and later migrates to a Raydium pool. All three endpoints handle both, so you send the same request either way and Trench routes it to whichever venue the token currently trades on. There is a brief window between the curve completing and the pool being ready, and trades during it fail with a retryable409.
Both clear on their own, so retrying after a short delay is the right response to either.
The Response
All three endpoints respond identically.Confirming
Whether a transaction succeeded is public on-chain state, so you read it from your own RPC using the signature Trench returned rather than asking Trench for it.Node.js
err is a real economic outcome rather than a transport problem, since the user paid fees and the trade did not execute. Treat it as a failed trade and surface it as one.
To report what the trade actually filled at, read the token balance changes recorded on the transaction.
Node.js
Retries
A429 is the one case where retrying is safe, because the request was rejected before reaching the transaction builder and nothing was submitted.
Network Fees
Both fee fields are required on every trade.
Raising the priority fee helps during periods of congestion. Both fees are spent whether or not the trade succeeds.
Charging Your Own Fee
AddingpartnerFeeBps to any of the three endpoints pays you a cut of the trade, transferred to a wallet you register with Trench in the same transaction.
Volume Caps
Neither tier sets a cap by default, but Trench can configure them per app. When set, they apply tomaxSolIn on buys only, and sells are never capped.
The daily figure is tracked per user and resets at 00:00 UTC. See Registration.
Common Failures
The full list is on the Error Handling page.