We are pleased to share that we are releasing Jupiter SDK v1.0-beta, the most comprehensive yet easy-to-use liquidity SDK available on Solana.
With more than 3B in swaps performed since we launched Jupiter 2 months ago, Jupiter is Solana’s most proven swap aggregation engine. This SDK will allow any wallet or UI to replicate precisely the functionality on Jupiter.
We are incredibly grateful to our early partners Mango, MeanDAO, Sonar, Tulip, Defiland, and many other individual developers from our discord for their commitment and patience in helping us work through the many issues and kinks to get here.
A great example is Mango, which is an awesome one-stop site for both spot and perp trades!
The Swap SDK For Solana
Swap is a critical use case for the vast majority of use cases in DeFi, including wallets, games, marketplaces, lending, liquidation bots, etc. - and having access to the most comprehensive list of tokens, markets, and routes is critical.
The SDK allows developers to access over 10 Dexes with more than 6bn in liquidity, allowing developers to find the best route with a simple API call.
These features include:
- Fetching all the available tokens across DEXes
- Find the best routes based on input token and amount
- Perform the swap by calling the function directly or using the transaction objects
- Add platform fee if you are a wallet or UI
- Caching options for performance
Basic Usage
We designed the SDK to be as easy to use as possible. The basic usage simply comprises of getting the routes for a given token pair and executing the transaction!
const jupiter = await Jupiter.load({
connection,
cluster: ENV,
user: USER_KEYPAIR,
});
const routes = await jupiter.computeRoutes(
new PublicKey(inputToken.address), // Mint address of the input token
new PublicKey(outputToken.address), // Mint address of the output token
inputAmount,
slippagePercentage,
true // cached=true => will use cache if not older than routeCacheDuration
)
const { execute } = await jupiter.exchange({ route: routes[0] });
const swapResult: any = await execute();
The basic guide can be found here, while a comprehensive example with everything you need to set up a fully functioning swap UI can be found here.
Platform Fees
If you are a wallet or UI that needs to set platform fees, you can do so with this:
// define platform fee and owner account
const platformFeeAndAccounts = {
feeBps: 50,
feeAccounts: await getPlatformFeeAccounts(
new PublicKey('9VjEE6cne5rNzrV9UPPZupab57bDGx3R9ZDG9YMNAht') // The platform fee account owner
)
}
// Pass
const jupiter = Jupiter.load({
... // rest of Jupiter parameters
platformFeeAndAccounts
})
The guide for adding platform fees can be found here.
Links
Next Steps
This SDK is a critical first step in our overall goal to make liquidity as easily accessible and transparent to the entire ecosystem as possible, including our open source plans in early 2022, which will allow any developer to contribute to Jupiter.
Although we don’t expect significant issues in the SDK’s beta phase, there might still be occasions when things break due to the changes we need to implement, either due to partner feedback or improvements. With that said, we do expect a stable version of the SDK to be released by Jan 2022.
Like how we strive to make our UX as easy and seamless as possible to users, our goal is to deliver an SDK that enables developers to achieve all their goals in the simplest way possible. We are not there yet, so any help/feedback/request will be great!
If you have any needs, requirements, or future requests, please post a reply here or let us know in our developer community Jupiter Aggregator.