Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ Open `localhost:3000` in your browser. The swap is at `localhost:3000/swap`

### API Implementation
The API implementation is at [create-solana-dapp/web/app/swap/page.tsx](https://github.com/AlmostEfficient/jupiter-swap/blob/main/create-solana-dapp/web/app/swap/page.tsx). It's configured to only have 4 assets - USDC, SOL, BONK, WIF. You'll need to add your own token mint addresses, or you can use the [token list API](https://station.jup.ag/docs/token-list/token-list-api) for validated tokens.

### Using custom Swap API endpoints
You can get Swap API urls from [Jupiter Station](https://station.jup.ag/docs/apis/swap-api), [QuickNode](https://marketplace.quicknode.com/add-on/metis-jupiter-v6-swap-api) or [JupiterAPI.com](https://www.jupiterapi.com/). You can easily update the Swap API for the endpoints at [create-solana-dapp/web/app/swap/page.tsx](https://github.com/AlmostEfficient/jupiter-swap/blob/main/create-solana-dapp/web/app/swap/page.tsx) and [create-solana-dapp/web/app/api/swap/route.ts](https://github.com/AlmostEfficient/jupiter-swap/blob/main/create-solana-dapp/web/app/api/swap/route.ts).
2 changes: 1 addition & 1 deletion create-solana-dapp/web/app/api/swap/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function POST(request: Request) {
console.log('Request to swap from', userPublicKey)

try {
const swapTxResponse = await fetch('https://quote-api.jup.ag/v6/swap', {
const swapTxResponse = await fetch('https://public.jupiterapi.com/swap', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
4 changes: 2 additions & 2 deletions create-solana-dapp/web/app/swap/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function Swap() {

const quote = await (
await fetch(
`https://quote-api.jup.ag/v6/quote?inputMint=${fromAsset.mint}&outputMint=${toAsset.mint}&amount=${currentAmount * Math.pow(10, fromAsset.decimals)}&slippage=0.5`
`https://public.jupiterapi.com/quote?inputMint=${fromAsset.mint}&outputMint=${toAsset.mint}&amount=${currentAmount * Math.pow(10, fromAsset.decimals)}&slippage=0.5`
)
).json();

Expand All @@ -100,7 +100,7 @@ export default function Swap() {

// get serialized transactions for the swap
const { swapTransaction } = await (
await fetch('https://quote-api.jup.ag/v6/swap', {
await fetch('https://public.jupiterapi.com/swap', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down