INFOAs of January 2025, when integrating the Legacy Swap API, you no longer need to use the Referral Program to set up a
referralAccount and referralTokenAccount to collect fees from the swaps you provide to the end users.Simply, just pass in any valid token account as the feeAccount parameter in the Legacy Swap API.However, do note that it is still applicable to the Trigger API.NOTEYou can still find information about the Referral Program.The Referral Program is an open source program by Jupiter to provide referral fees for integrators who are integrating Jupiter Swap and Jupiter Limit Order. You can check out the code here to gain a better understanding of how it works.
Overview
By default, there are zero protocol fees on Jupiter Swap. Integrators have the option to introduce a platform fee denoted in basis points, e.g. 20 bps for 0.2% of the token input or output.Important Notes
- For ExactIn swaps, the
feeAccount’s mint can be either the input mint or output mint of the swap pair, and not any other mints. - For ExactOut swaps, the
feeAccount’s mint can only be the input mint of the swap pair. - Example, if you swap JUP to USDC, you cannot take fees in SOL, it has to be part of the swap pair.
- It supports SPL and Token2022 tokens.
- Referral Program is no longer required for Legacy Swap API.
1. Set up
You will need to complete the prerequisites and understanding of Environment Setup and Get Quote and Swap guide as this is reliant on the Legacy Swap API.2. Set your fee in Quote
Setting your fee is simple, just addplatformFeeBps parameter to the /quote endpoint.
In this example, we set platformFeeBps to 20 which equates to 0.2%.
3. Set your feeAccount in Swap
In the/swap endpoint, you will need to pass in the feeAccount parameter.
- The
feeAccountis a token account that will receive the fees from the swap - the mint of the token account has to be part of the swap pair. - Do ensure that the token account needs to be initialized beforehand and is the correct mint to receive the fees in.
- For ExactIn swaps, the
feeAccount’s mint can be either the input mint or output mint of the swap pair, and not any other mints. - For ExactOut swaps, the
feeAccount’s mint can only be the input mint of the swap pair. - Example, if you swap JUP to USDC, you cannot take fees in SOL, it has to be part of the swap pair.
- Refer to the Create Token Account section to create a token account.
4. Sign and send transaction
Finally, the user can sign the transaction and it can be submitted to the network to be executed. You can refer to the Send Swap Transaction guide to complete this step.Create Token Account
To create a token account, you can use the following code or refer to Solana Cookbook.- The code creates the transaction to create the token account and handles the transaction siging and sending.
- If the token account already exists, it will not create and might throw an error such as
Provided owner is not allowed.
For Trigger API Integrator Fee
Important Notes-
The Jupiter Swap project account for the Referral Program is
45ruCyfdRkWpRNGEqWzjCiXRHkZs8WXCLQ67Pnpye7Hp. -
The
referralTokenAccountcan either be:- Input mint or the output mint on the swap for ExactIn.
- Input mint ONLY on the swap for ExactOut.
-
You can use the Dashboard, SDK or API to set up the
referralAccountandreferralTokenAccountin this guide.
referralAccount and referralTokenAccount
There are 2 ways you can set up a referral account.
- Use our referral dashboard to create them. After creating, remember to find your
Referral Keyon the page and the associated token accounts. - Use our SDK to create them. You can use the example scripts to create.
mintAccount
As for the mint account, assuming you have an interface where a user swaps, you will know up front what are the input or output mints. For the sake of example, we will use a hardcoded mint public key.
feeAccount
In order to refer and receive fees from all types of tokens, you will need to have already initialize referralTokenAccounts (owned by your referralAccount) for the mint in the order.
In this code block, we will be using the SDK to try to find the referralTokenAccount based on our previously defined referralAccount and mintAccount. If the token account is not found, it will send a transaction to the network to attempt to initialize one for the mint.
referralTokenAccount for specific mints have been created, you can use this method to get it. Do note that, even if the token account is not intialized, it will still return a pubkey as it is a Program Derived Address and is deterministic. Read more here.
feeAccount and params.feeBps
Setting your referral fee is simple, just add feeAccount and params.feeBps parameters to the /createOrder endpoint.
In this example, we set params.feeBps to 20 which equates to 0.2%.
