Skip to main content
This feature is in private alpha and the details are subject to change!
You can add your own fee to a trade. The fee is paid in the input token to a wallet you choose. Sunrise also marks your trades onchain with a memo, so they count as yours. Both work only on the rfq-fill route, for tokenized stocks against USDC on Solana. See RFQ orders for how that route works. This recipe builds on the swap recipe and the RFQ orders recipe. It uses the same headers, account, stock, and signing code.

How it works

  • Fee. Send integratorFeeBps and integratorFeeRecipientAddress with POST /v1/quotes. The quote comes back with the fee built into its transaction. When the order fills, the fee goes to the recipient wallet.
  • Memo. Sunrise sets a memo on your API key. Every rfq-fill transaction quoted with your key includes it as a Solana Memo instruction. You don’t send the memo yourself.

Step 1: Get your key set up for fees

Contact contact@sunrise.xyz to enable fees on your API key. For each wallet you want to receive fees, send:
  • The Solana wallet address.
  • The highest fee rate you want to charge to it, in basis points. 100 basis points is 1%.
Sunrise approves each wallet and its maximum rate on your key. Your key also needs access to the rfq-fill route. Changes to your key can take up to five minutes to apply. You don’t need any setup to trade without a fee.

Step 2: Get a quote with a fee

Add the two fee fields to the quote request from RFQ orders:
Send both fields for a fee. To trade without a fee, leave both out or send integratorFeeBps: 0. A request with a fee above 0 gets quotes only from rfq-fill. Other routes can’t charge the fee, so they’re skipped and listed in unavailableRoutes with the code integrator_fee_not_supported. If rfq-fill gives no quote, unavailableRoutes says why. The fee wallet needs no setup. Its token accounts are created on its first trade with a fee, with a small one-time SOL rent cost to your user.

Step 3: Check the fee on the quote

Each quote with a fee includes integratorFee:
The fee is charged in the input token: USDC on a buy, the stock token on a sell. It comes out of fromAmount, so toAmount is what your user gets after the fee. Show your user the fee before they sign. The fee applies only to the part of the order that fills. Anything refunded carries no fee.

Step 4: Sign and execute

Sign and execute the quote as in RFQ orders. Nothing changes for a quote with a fee. Sign the unsignedTransaction exactly as returned. It carries the fee and your memo. If the transaction is changed, for example to remove or edit the memo, execute refuses it.

Attribution with a memo

Your memo is a short code, for example sun-Ab12, that Sunrise sets on your API key. It’s included in every rfq-fill transaction quoted with your key, whether or not you charge a fee. Anyone can read it onchain to see which trades came through you.
  • One memo per key. By default, every trade from your key carries the same memo.
  • One memo per wallet. Sunrise can also set a separate memo for each approved fee wallet. A quote that names that wallet in integratorFeeRecipientAddress uses its memo instead.
  • Attribution without a fee. To pick a wallet’s memo without charging a fee, send integratorFeeBps: 0 and that wallet in integratorFeeRecipientAddress. If the wallet has no memo of its own, the key’s memo is used.
Routes other than rfq-fill don’t include the memo. To get a memo set on your key, or one per wallet, contact contact@sunrise.xyz.

Fee errors

See Errors for every other code.