jupiter swap referral fees wif api

  • posted on 12-20-2024 in crypto

k so, while you are on jup.ag swappin solami coins, scroll down a bit to the bottom of the page.
on pc, you should see a button that says 'referral'.

Thats the key to opening the door to earning referral fees from jup swaps api.
for example, dis my link here

The other day i randomly starting clicking buttons and said hmmm, maybe add a swap page on this site. Then i went down the tism tunnel of sdk/api/docs/nodes that make the code/fees thingy work on your dapp or site.
team jup did a great job with the docs and demo builder. just a read and take your time depending on what your goals are. i'll add the concise links to pages and the important bits to get you going quickly.
For your referral account you'll want to pay the rent per token account to earn fees. Similar to how your personal wallet functions on solana, pay the rent fee on the account to interact with the token meta data. in this case to earn fees.
Quick link to the jup tutorial wif pics -> here for the ref account initial setup.
Your jup ref dashboard is located here. simple dash wif an api tab and easy claim buttons. depending on what you are building the api tab comes in handy for quick endpoint access to your ref account.

since my site is vanilla html/php/js i went wif the simple page integration snippet. on the terminal builder link you have a few options to review and how the form is called is like the backbone if you will. You can go with a modal, widget or integrated on page. choosing integrated may require some additional styling to function correctly, even though its the simple route of install. Depending on your site/setup you may find it easier to use the widget snippet. for integrated i had to inject some style as there was a height conflict with tailwind and bootstrap.
if you are using modal be careful wif data-attribute tags and running a current version of bootstrap 5 to prevent injection/xss.
Most important tidbit is your rpc thingy, you can't copy pasta the one in the docs. you have to use your own provider. i went with quicknode as they have pre-rolled solana wrapper endpoint thingy perfect for this purpose. pretty sure jup recs them in the docs too.
Aside from that you may want to separate your fee const from the calling snippet, for reference the code below is working @ stonerfore.net/go/swap in the footer. don't forget to call the jup script file in your header.



const FEE_thingy = {
  referralAccount: 'youraccountfromjupherehomie',
  feeBps: 10,
};


window.Jupiter.init({
  endpoint: "youllneedaprivateoneforratelimitingandwutnot",
  displayMode: "integrated",
  integratedTargetId: "integrated-terminal",
  refetchIntervalForTokenAccounts: 10000,
  strictTokenList: false,
  defaultExplorer: "Solscan",

  platformFeeAndAccounts: FEE_thingy,
  formProps: {
    initialAmount: "420000000",
    initialOutputMint: "UwU8RVXB69Y6Dcju6cN2Qef6fykkq6UUNpB15rZku6Z",
  },
});

my initial mint is $uwu, tehe. fee is set to 10, which is 0.1%. initial amount is $420. and thats it for html integration really. your main set backs are styling and mobile connectivity [i tink]; me need to test via mobile wallet not reg browser. For framework integration you can install via the npm/scaffold method -> here. i may play around with that after installing a testnet subdomain for framework based stuff later on. but for now we have a working jup swap on the vanilla stonerforge site.

stonerforge unicornio solana nft pfp
  • written by stoner
  • art supplies or coffee $$$ to stonerforge.sol or .eth
  • ily make art
  • ▄︻デ══‐一💜
weeeeeee