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

# Exchange Services

> Convert digital assets, retrieve exchange rates, and initiate asset swaps using the Monei Node.js / TypeScript SDK.

# Overview

The `Exchange Services` provides a unified interface for cross-chain cryptocurrency exchange operations, supporting both EVM-compatible and Solana blockchains.

Included services:

* **evmExchange**: Handles exchanges on Ethereum, BSC, Polygon, Arbitrum, Optimism, and Avalanche
* **solExchange**: Handles exchanges on Solana blockchain

***

## EVM Exchange

### Get Price Quote (Native → Token)

```typescript theme={null}
const price = await monei.evmExchange.getNativeToTokenPrice({
  tokenAddress: '0xTokenAddress',
  amount: '0.1',
  chainId: 56,
});

console.log(price.expectedOutput, price.priceImpact);
```

### Swap Native → Token

```typescript theme={null}
const tx = await monei.evmExchange.swapNativeToToken({
  tokenAddress: '0xTokenAddress',
  amount: '0.1',
  chainId: 56,
  slippage: 0.5, // 0.5%
});

console.log(tx.txHash);
```

### Get Price Quote (Token → Token)

```typescript theme={null}
const price = await monei.evmExchange.getTokenToTokenPrice({
  tokenIn: '0xTokenInAddress',
  tokenOut: '0xTokenOutAddress',
  amount: '100',
  chainId: 137,
});

console.log(price.expectedOutput, price.priceImpact);
```

### Swap Token → Token

```typescript theme={null}
const tx = await monei.evmExchange.swapTokenToToken({
  tokenIn: '0xTokenInAddress',
  tokenOut: '0xTokenOutAddress',
  amount: '100',
  chainId: 137,
  slippage: 1,
});

console.log(tx.txHash);
```

### Get Price Quote (Token → Native)

```typescript theme={null}
const price = await monei.evmExchange.getTokenToNativePrice({
  tokenAddress: '0xTokenAddress',
  amount: '0.1',
  chainId: 56,
});

console.log(price.expectedOutput, price.priceImpact);
```

### Swap Token → Native

```typescript theme={null}
const tx = await monei.evmExchange.swapTokenToNative({
  tokenAddress: '0xTokenAddress',
  amount: '100',
  chainId: 56,
  slippage: 0.5,
});

console.log(tx.txHash);
```

***

## Solana Exchange

### Get SOL → Token Quote

```typescript theme={null}
const quote = await monei.solExchange.getSolToTokenQuote({
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: '1',
  network: SolanaNetwork.MAINNET,
});

console.log(quote.expectedOutput, quote.priceImpact);
```

### Swap SOL → Token

```typescript theme={null}
const result = await monei.solExchange.swapSolToToken({
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '1',
  slippage: 1,
  network: SolanaNetwork.MAINNET,
});

console.log(result.signature);
```

### Get Token → Token Quote

```typescript theme={null}
const quote = await monei.solExchange.getTokenToTokenQuote({
  inputMint: 'TokenAMintAddress',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: '1',
  network: SolanaNetwork.MAINNET,
});

console.log(quote.expectedOutput, quote.priceImpact);
```

### Swap Token → Token (Solana)

```typescript theme={null}
const result = await monei.solExchange.swapTokenToToken({
  inputMint: 'TokenAMintAddress',
  outputMint: 'TokenBMintAddress',
  amount: '100',
  slippage: 1,
  network: SolanaNetwork.MAINNET,
});

console.log(result.signature);
```

### Get Token → SOL Quote

```typescript theme={null}
const quote = await monei.solExchange.getTokenToSolQuote({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: '1',
  network: SolanaNetwork.MAINNET,
});

console.log(quote.expectedOutput, quote.priceImpact);
```

### Swap Token → SOL

```typescript theme={null}
const result = await monei.solExchange.swapTokenToSol({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '50',
  slippage: 1,
  network: SolanaNetwork.MAINNET,
});

console.log(result.signature);
```

***

## Working with Response Objects

All methods return objects with property access:

```typescript theme={null}
// Price quote response
const quote = await monei.evmExchange.getNativeToTokenPrice({...});
console.log(quote.expectedOutput);  // Expected output amount
console.log(quote.priceImpact);      // Price impact percentage
console.log(quote.route);            // Swap route details

// Transaction response
const tx = await monei.evmExchange.swapNativeToToken({...});
console.log(tx.txHash);      // Transaction hash
console.log(tx.status);       // Transaction status
console.log(tx.explorerUrl);  // Block explorer URL

// Solana swap response
const result = await monei.solExchange.swapSolToToken({...});
console.log(result.signature);  // Transaction signature
console.log(result.blockhash);  // Block hash
```

***

## Notes

* All methods require a properly configured `MoneiClient` instance with authentication
* EVM methods require `chainId` parameter (e.g., 56 for BSC, 137 for Polygon)
* Solana methods require `network` parameter (`SolanaNetwork.MAINNET` or `SolanaNetwork.DEVNET`)
* `slippage` is optional (defaults to 0.5% for EVM, 1% for Solana)
* All responses are strongly typed objects with property access

***
