Skip to main content
You can take a cut of every trade your integration executes by sending a partnerFeeBps field with a buy or a sell. The fee is paid to a wallet you register with Trench, as a plain SOL transfer included in the same transaction as the trade. Because the transfer rides in the trade transaction, the two settle together. A trade that fails moves no fee.
Charging a fee requires the Partner tier. Apps on the free Basic tier cannot charge one, and a non-zero partnerFeeBps from such an app is rejected outright. See Tiers.

Setting the Rate

The rate is expressed in basis points, so 100 is 1% and 50 is 0.5%. It is sent per request, and Trench never stores it.
Omitting the field, or sending 0, charges nothing. Trench never applies a rate you did not send. The upper bound of 9999 is arithmetic rather than a policy ceiling, since a rate of 10000 basis points would leave nothing to spend on the trade.
Because the rate travels with each request, per-user tiering is entirely yours to design. Store each user’s rate in your own database and pass it with their trades.

What the Fee Is Charged On

The basis differs between buys and sells, and rounding is always down so you never over-collect.
On a sell, the fee is calculated from minSolOut rather than from the actual proceeds, which means a minSolOut of "0" earns you nothing. This is worth checking if you are computing sell bounds loosely.

Fees and Slippage

On a buy, the fee is deducted before the remainder reaches the trading venue. In slippage mode this is handled for you. Trench takes the quote after deducting the fee, so the derived bound already accounts for it. If you charge a fee, this is the main practical reason to prefer that mode. In explicit mode the deduction is yours to account for, which means minTokensOut has to be quoted against the post-fee amount rather than against maxSolIn.
In explicit mode, quoting against maxSolIn while a fee is set will cause a correctly priced trade to trip your own slippage guard and fail with slippage_exceeded.

Registering Fee Wallets

Fee wallets are granted with the Partner tier. Send the Trench team one or more addresses to register against your app, each of which has to meet three conditions.
  1. It must already exist on-chain.
  2. It must be a plain system account rather than a program-owned one.
  3. It must already be rent-exempt.
A transfer into an unfunded or program-owned account fails, and because the fee rides in the trade transaction, that failure takes the whole trade with it. If you register several wallets, one is chosen at random for each trade, so you can spread volume across wallets without coordinating with Trench. Sending a non-zero partnerFeeBps without an eligible tier or a registered wallet returns partner_fee_not_configured. The message field distinguishes the two cases.

Disclosure

Trench imposes no ceiling on partnerFeeBps and does not tell your users what you charge. The consent screen indicates only that your app charges a fee, not the rate.
Telling your users what they are being charged, and complying with whatever rules apply to you for doing so, is your responsibility.

Errors