Key Concepts

⚠️ Important: Quotes simulation

πŸ”’ Connect your wallet to get real, pre-simulated pricing from the Ooga Booga backend.

Without wallet connection, quotes may be spoofed or manipulated by aggregators. Connected wallets receive verified quotes that reflect actual execution prices.

🌐 Quote Stream API

The application connects to a streaming API for real-time swap quotes:

const AGGREGATOR_BASE_URL = 'https://hyperevm.api.oogabooga.io/meta/stream/swap'

Supported Parameters

Parameter
Type
Description

tokenIn

string

Input token address

tokenOut

string

Output token address

amount

string

Amount to swap (in token units)

maxSlippage

string

Maximum acceptable slippage (default: 0.01)

to

string

Recipient address

aggregators

string[]

Specific aggregators to query

πŸ“‘ Event Types

The SSE stream emits the following events:

  • connected - Initial connection established

  • quote - New quote data received

  • error - Error occurred during streaming

  • heartbeat - Keep-alive signal

πŸ“Š Quote Data Structure

Each quote contains comprehensive swap information:

interface QuoteResponse {
  aggregator: string;
  quote: {
    status: string;
    amountIn: string;
    amountOut: string;
    fee: string;
    value: string;
    aggregator: string;
    routerAddr: string;
    calldata: string;
    gas: string;
    simulationAmountOut: string;
    priceImpact: number;
  };
  timestamp: number;
}

πŸ”§ Usage Examples

Basic Quote Stream Implementation

import { useQuoteStream } from '@/hooks/use-quote-stream'

const QuoteStreamComponent = () => {
  const { isConnected, latestQuote, error } = useQuoteStream({
    chainId: 999, // HyperEVM chain ID
    params: {
      tokenIn: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb', // USDT
      tokenOut: '0x0000000000000000000000000000000000000000', // HYPE
      amount: '10000000', // 10 USDT
      maxSlippage: '0.5',
    },
    enabled: true
  })

  if (!isConnected) {
    return <div>πŸ”„ Connecting to quote stream...</div>
  }
  
  if (error) {
    return <div>❌ Error: {error.message}</div>
  }
  
  return (
    <div>
      <h3>πŸ“Š Latest Quote</h3>
      <pre>{JSON.stringify(latestQuote, null, 2)}</pre>
    </div>
  )
}

Last updated