> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magicblock.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Jupiter V6 integration

> Integrate Jupiter v6 API in your game

## Jupiter

Jupiter V6 is natively supported in the SDK. Utility methods are provided to easily get swap quotes, build and send the transactions needed to perform swaps.
Jupiter is the key liquidity aggregator for Solana, offering the widest range of tokens and best route discovery between any token pair. For a detailed description refer to the official [Jupiter documentation](https://station.jup.ag/).

***

## Perform a Swap

Create an IDex istance, providing a default account:

```csharp theme={null}
IDexAggregator dex = new JupiterDexAg(Web3.Account);
```

Create an IDex istance:

```csharp theme={null}
TokenData tokenA = await dex.GetTokenBySymbol("SOL");
TokenData tokenB = await dex.GetTokenBySymbol("USDC");
```

Get a swap quote for 1 SOL:

```csharp theme={null}
SwapQuoteAg swapQuote = await dex.GetSwapQuote(
    tokenA.MintAddress,
    tokenB.MintAddress,
    DecimalUtil.ToUlong(1, tokenA.Decimals)
);
```

```csharp theme={null}
var quote = DecimalUtil.FromBigInteger(swapQuote.OutputAmount, tokenB.Decimals);
Debug.Log(quote); // Amount of espected USDC token to receive
```

Display the route path:

```csharp theme={null}
Debug.Log(string.Join(" -> ", swapQuote.RoutePlan.Select(p => p.SwapInfo.Label)));

// Lifinity V2 -> Whirlpool
```

Create the swap transaction:

```csharp theme={null}
Transaction tx = await dex.Swap(swapQuote);
```

Sign and send the swap transaction:

```csharp theme={null}
await Web3.Wallet.SignAndSendTransaction(tx);
```

## Use the Jupiter Payments API

The Jupiter Payments API is also available, enabling you to utilize Jupiter + SolanaPay for facilitating user payments with any SPL token, allowing pricing in USDC or other tokens.

Create an IDex istance, providing a default account:

```csharp theme={null}
IDexAggregator dex = new JupiterDexAg(Web3.Account);
```

Create an IDex istance:

```csharp theme={null}
TokenData tokenA = await dex.GetTokenBySymbol("SOL");
TokenData tokenB = await dex.GetTokenBySymbol("USDC");
```

Get a swap quote for the amount of SOL needed for obtaining 5 UDSC:

```csharp theme={null}
SwapQuoteAg swapQuote = await dex.GetSwapQuote(
    tokenA.MintAddress,
    tokenB.MintAddress,
    DecimalUtil.ToUlong(5, tokenB.Decimals),
    SwapMode.ExactOut
);
```

```csharp theme={null}
var quote = DecimalUtil.FromBigInteger(swapQuote.InputAmount, tokenA.Decimals);
Debug.Log(quote); // Amount of espected SOL token to pay
```

Create the swap transaction:

```csharp theme={null}
Transaction tx = await dex.Swap(swapQuote);
```

Sign and send the swap transaction:

```csharp theme={null}
await Web3.Wallet.SignAndSendTransaction(tx);
```
