Cross-Chain Aggregation DEX

Agg-DEX Demo

Quote cross-chain swaps on RHEA, optionally execute when the source chain is Zcash and Noir Wallet is connected.

← Wallet DemoLendingPerpsAgg-DEX cross-chain Quote / Swap

Loading token list…

From (source chain)

To (destination chain)

Usage example
// Quote-only — works for any supported source chain
import { SwapClient } from '@rhea-finance/zcash-wallet-adapter/aggregation';

const quoteClient = new SwapClient({
  baseUrl: 'https://api.rhea.finance',
  getAccessToken: () => process.env.SWAP_API_KEY!,
});

// Zcash Swap — requires a connected Noir wallet
import { NoirZcashWalletAdapter } from '@rhea-finance/zcash-wallet-adapter';
import { createNoirSwapClient } from '@rhea-finance/zcash-wallet-adapter/aggregation';

const noir = new NoirZcashWalletAdapter({ network: 'mainnet' });
await noir.connect();

const swapClient = createNoirSwapClient({
  baseUrl: 'https://api.rhea.finance',
  getAccessToken: () => process.env.SWAP_API_KEY!,
  wallet: noir,
  zcash: { fundingSource: 'shielded' },
});

Zcash Swap requires Noir Wallet. Quote works with a manually entered sender address.

quote

Usage example
const quote = await quoteClient.quote({
  fromChain: 'zcash',
  toChain: '1', // Ethereum
  tokenIn: {
    chain: 'zcash',
    address: '0x0000000000000000000000000000000000000000',
    symbol: 'ZEC',
    decimals: 8,
    isNative: true,
  },
  tokenOut: {
    chain: '1',
    address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
    symbol: 'USDT',
    decimals: 6,
    isNative: false,
  },
  amountIn: 1_000_000n, // 0.01 ZEC
  slippageBps: 50, // 0.5%
  sender: 'u1...', // source chain address
  recipient: '0x...', // destination chain address
});

swap

Zcash source chain only; requires connected Noir wallet.

Usage example
const result = await swapClient.swap({
  quote,
  waitFor: 'submitted',
});
// result.txHash

Executable source chains: zcash, zec. Configure NEXT_PUBLIC_SWAP_API_KEY to call the RHEA Quote/Swap API.