> ## 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 Python SDK.

# Overview

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

Included services:

* **evm\_exchange**: Handles exchanges on Ethereum, BSC, Polygon, Arbitrum, Optimism, and Avalanche
* **sol\_exchange**: Handles exchanges on Solana blockchain

> **Note**: All methods return response objects with attributes accessible via dot notation (e.g., `price.expected_output`, `tx.tx_hash`).

***

## EVM Exchange

### Get Price Quote (Native → Token)

```python theme={null}
price = monei.evm_exchange.get_native_to_token_price(
    token_address="0xTokenAddress",
    amount="0.1",
    chain_id=56
)

print(price.expected_output, price.price_impact)
```

### Swap Native → Token

```python theme={null}
tx = monei.evm_exchange.swap_native_to_token(
    token_address="0xTokenAddress",
    amount="0.1",
    chain_id=56,
    slippage=0.5  # 0.5%
)

print(tx.tx_hash)
```

### Get Price Quote (Token → Token)

```python theme={null}
price = monei.evm_exchange.get_token_to_token_price(
    token_in="0xTokenInAddress",
    token_out="0xTokenOutAddress",
    amount="100",
    chain_id=137
)

print(price.expected_output, price.price_impact)
```

### Swap Token → Token

```python theme={null}
tx = monei.evm_exchange.swap_token_to_token(
    token_in="0xTokenInAddress",
    token_out="0xTokenOutAddress",
    amount="100",
    chain_id=137,
    slippage=1
)

print(tx.tx_hash)
```

### Get Price Quote (Token → Native)

```python theme={null}
price = monei.evm_exchange.get_token_to_native_price(
    token_address="0xTokenAddress",
    amount="0.1",
    chain_id=56
)

print(price.expected_output, price.price_impact)
```

### Swap Token → Native

```python theme={null}
tx = monei.evm_exchange.swap_token_to_native(
    token_address="0xTokenAddress",
    amount="100",
    chain_id=56,
    slippage=0.5
)

print(tx.tx_hash)
```

***

## Solana Exchange

### Get SOL → Token Quote

```python theme={null}
quote = monei.sol_exchange.get_sol_to_token_quote(
    output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
    amount="1",
    network="mainnet"
)

print(quote.expected_output, quote.price_impact)
```

### Swap SOL → Token

```python theme={null}
result = monei.sol_exchange.swap_sol_to_token(
    output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    amount="1",
    slippage=1,
    network="mainnet"
)

print(result.signature)
```

### Get Token → Token Quote

```python theme={null}
quote = monei.sol_exchange.get_token_to_token_quote(
    input_mint="TokenAMintAddress",
    output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
    amount="1",
    network="mainnet"
)

print(quote.expected_output, quote.price_impact)
```

### Swap Token → Token (Solana)

```python theme={null}
result = monei.sol_exchange.swap_token_to_token(
    input_mint="TokenAMintAddress",
    output_mint="TokenBMintAddress",
    amount="100",
    slippage=1,
    network="mainnet"
)

print(result.signature)
```

### Get Token → SOL Quote

```python theme={null}
quote = monei.sol_exchange.get_token_to_sol_quote(
    input_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
    amount="1",
    network="mainnet"
)

print(quote.expected_output, quote.price_impact)
```

### Swap Token → SOL

```python theme={null}
result = monei.sol_exchange.swap_token_to_sol(
    input_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    amount="50",
    slippage=1,
    network="mainnet"
)

print(result.signature)
```

***

## Working with Response Objects

All methods return objects with attribute access:

```python theme={null}
# Price quote response
quote = monei.evm_exchange.get_native_to_token_price(...)
print(quote.expected_output)  # Expected output amount
print(quote.price_impact)      # Price impact percentage
print(quote.route)             # Swap route details

# Transaction response
tx = monei.evm_exchange.swap_native_to_token(...)
print(tx.tx_hash)      # Transaction hash
print(tx.status)       # Transaction status
print(tx.explorer_url) # Block explorer URL

# Solana swap response
result = monei.sol_exchange.swap_sol_to_token(...)
print(result.signature)  # Transaction signature
print(result.blockhash)  # Block hash
```

***

## Notes

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

***
