-
Notifications
You must be signed in to change notification settings - Fork 0
Add Solana Swap API monetization guide #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
af96544
Add Solana Swap API monetization guide
jlin27 98e9036
Merge branch 'main' into solana-monetization-guide
jlin27 6eeff5a
Clarify per-entry fee cap with an example in Solana monetization guide
jlin27 daebf69
Rename affiliate fees to volume-based fees in Solana monetization guide
jlin27 b3b8152
Remove trade surplus from Solana monetization guide
jlin27 302ddd5
Fix Displaying fees section to reflect request-side values, not inter…
jlin27 de50294
Remove stale trade-plan cross-reference and duplicate alias from Sola…
jlin27 82add78
address PR comments
jlin27 3eaf1ee
address PR comments
jlin27 d08094f
clean up underscores
jlin27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
fern/docs/pages/0x-swap-api/guides/monetize-your-app-using-swap.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
fern/docs/pages/solana-swap-api/guides/monetize-your-app.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| title: Monetize Your App on Solana | ||
| description: This guide covers how you can monetize your app by using the 0x Solana Swap API. | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| Integrate in-app swaps to let users trade seamlessly and at the best prices across Solana's top DEXs. As your app grows, you can monetize those trades with volume-baesd fees (aka affiliate fees, trading fees, or commision) to generate revenue and build a sustainable business. Available on all pricing plans. | ||
|
|
||
| See our [Monetization Report](https://0x.org/reports/monetization-across-defi-report) to learn how top DeFi apps are turning trading activity into millions. | ||
|
|
||
| ## Collect volume-based fees | ||
|
|
||
| The 0x Solana Swap API supports one or more volume-based fees within a single swap request. This lets you route fees to multiple recipients with independently specified amounts and sides — perfect for multi-product apps, partner revenue-share setups, or flexible monetization strategies. | ||
|
|
||
| To apply volume-based fees, include the following fields in the body of your [`/solana/swap-instructions` request](/api-reference/solana-swap-ap-is/swap/instructions): | ||
|
|
||
| - [`swap_fee_ppm`](/api-reference/solana-swap-ap-is/swap/instructions#request.body.swap_fee_ppm) — the fee amount(s) in **parts per million (ppm)**. | ||
| - [`swap_fee_recipient`](/api-reference/solana-swap-ap-is/swap/instructions#request.body.swap_fee_recipient) — the account(s) to receive the fees. | ||
| - [`swap_fee_side`](/api-reference/solana-swap-ap-is/swap/instructions#request.body.swap_fee_side) — _(optional)_ the side each fee is charged on: `buy` (the output token) or `sell` (the input token). | ||
|
|
||
| <Note> | ||
| Fees on Solana are expressed in **parts per million (ppm)**, not basis points. | ||
| `1000000` ppm = 100%, so a 1% fee is `10000` ppm and a 5% fee is `50000` ppm. | ||
| </Note> | ||
|
Comment on lines
+22
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think include underscores here too for number formatting (and elsewhere it isn't already applied) |
||
|
|
||
| ### Multiple fees and recipients | ||
|
|
||
| Each comma-separated position defines one fee entry, so a single request can charge several fees to several recipients across both sides: | ||
|
|
||
| ```json | ||
| { | ||
| "swap_fee_ppm": "50000,25000,10000", | ||
| "swap_fee_recipient": "recipient1,recipient2,recipient3", | ||
| "swap_fee_side": "buy,buy,sell" | ||
| } | ||
| ``` | ||
|
|
||
| In this example, a 5% and a 2.5% fee are collected on the buy token for two different recipients, and a 1% fee is collected on the sell token for a third. | ||
|
|
||
| <Note> | ||
| Fees on the **same side** are applied **sequentially**: each entry is charged | ||
| on the amount remaining after the previous entries on that side have been | ||
| deducted, not on the original amount. For example, two buy-side fees of | ||
| `50000` and `25000` ppm produce an effective fee of 7.375%, not 7.5%. Each fee | ||
| amount is rounded up to the next base unit when needed. | ||
| </Note> | ||
|
|
||
| ### Buy-side vs sell-side fees | ||
|
|
||
| - **`buy`** — the fee is taken from the output token. This reduces the `amount_out` returned in the quote. | ||
| - **`sell`** — the fee is taken from the input token before the swap is routed. This reduces the amount routed into the swap. | ||
|
|
||
| ### Fee recipient accounts | ||
|
|
||
| If a fee recipient is the taker's own token account for that side, the fee is treated as absent (not a self-transfer) and is omitted from the quote and the returned instructions. See [Important Integration Notes](/svm/solana-swap-api/guides/important-integration-notes) for details on fee recipient token accounts, including why 0x does not create them for you. | ||
|
|
||
| ### Displaying fees | ||
|
|
||
| The fee you charge is fully determined by the values you send in the request, so you can display it in your UI directly from those: each `swap_fee_ppm` rate, the token it is charged in (the output token for a `buy` fee, the input token for a `sell` fee), and its `swap_fee_recipient`. | ||
|
|
||
| The quote already reflects any buy-side fees: the returned `amount_out` is net of them, so the value you show the user as the amount received is correct as-is. Sell-side fees reduce the amount routed into the swap before the quote is produced. | ||
|
|
||
| For the complete request and response schema, see the [API Reference](/api-reference/solana-swap-ap-is/swap/instructions). | ||
|
|
||
| ### Pricing considerations | ||
|
|
||
| When deciding how much to charge, set your pricing in a way that strengthens your bottom line while aligning with the value you provide to customers. The volume-based fee impacts the price for the end user, so find the sweet spot where your solution remains competitive. | ||
|
|
||
| Be aware that `swap_fee_ppm` has a default per-app limit of `100000` ppm (10%). The cap is enforced **per fee entry, not on the combined total**: each fee in the list is validated individually against the limit. For example, two sell-side fees of `60000` ppm (6%) each are both accepted under a `100000` ppm cap, even though they sum to 12%, because neither individual entry exceeds the cap. If your application requires a higher per-entry value, [please reach out to us](https://docs.0x.org/docs/introduction/need-help#-contact-developer-support-fastest-direct-help). | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this bit still looks weird to me (I understand I caused it) - what is this section, what is the need for the tip, can it live elsewhere etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's an artifact from the EVM template. let me remove