⚑Trading

LiquidCore delivers secure trading through the world's first integration of Hyperliquid's HyperEVM read precompiles as price oracles. This pioneering approach provides unprecedented price accuracy and manipulation resistance.

Swap Function

Basic Swap

Execute swaps between USDT0 and WHYPE with slippage protection:

function swap(
    address tokenIn,
    address tokenOut, 
    uint256 amountIn,
    uint256 minAmountOut
) external returns (uint256 amountOut)

Parameters

Parameter
Type
Description

tokenIn

address

Address of token being sold

tokenOut

address

Address of token being bought

amountIn

uint256

Amount of tokenIn to swap

minAmountOut

uint256

Minimum amount of tokenOut expected (slippage protection)

Returns: Actual amount of tokenOut received

Supported Trading Pairs

Direction
Token In
Token Out

USDT0 β†’ WHYPE

0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb

0x5555555555555555555555555555555555555555

WHYPE β†’ USDT0

0x5555555555555555555555555555555555555555

0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb

Revolutionary Price Discovery

HyperEVM Read Precompile Integration

LiquidCore pioneers the use of Hyperliquid's native infrastructure for price discovery:

  1. Pool Spot Price: Real-time pool pricing

  2. Hyperliquid Oracle Price: Spot mid price directly from HyperEVM read precompiles via CoreWriter

  3. First-Ever Implementation: No protocol has ever used Hyperliquid's read precompiles as oracles before

Advanced Price Validation

Before any swap, the protocol validates using Hyperliquid's native pricing:

  • Pool spot price validated against Hyperliquid's spot mid price

  • Direct access to Hyperliquid's tamper-proof price feeds through read precompiles

  • Prevents manipulation attacks using Hyperliquid's own pricing infrastructure

  • Creates unprecedented trading security only possible on Hyperliquid

Getting Current Prices

function getSpotPrices() public view returns (uint64 forwardPrice, uint64 inversePrice)

Returns:

  • forwardPrice: USDT0/WHYPE price from pool

  • inversePrice: WHYPE/USDT0 price from pool

Note: These prices are validated against Hyperliquid's spot mid prices obtained through HyperEVM read precompiles

Dynamic Fee System

Fee Calculation

Fees are calculated dynamically to optimize pool balance:

function getPoolFees() external view returns (uint256 feeToken0In, uint256 feeToken1In)

Returns:

  • feeToken0In: Current fee for USDT0 β†’ WHYPE swaps

  • feeToken1In: Current fee for WHYPE β†’ USDT0 swaps

Fee Structure

Dynamic fees adjust automatically to maintain optimal pool balance and provide the best trading experience.

Fee Distribution

All trading fees from this groundbreaking Hyperliquid-native protocol are split:

  • 90% goes to liquidity providers (distributed proportionally)

  • 10% goes to protocol treasury

Swap Estimation

Preview Swaps

Before executing, estimate swap outcomes:

function estimateSwap(
    address tokenIn,
    address tokenOut, 
    uint256 amountIn
) external view returns (uint256 amountOut)

Best Practices

Slippage Protection

Always set appropriate slippage tolerance based on market conditions and risk tolerance.

Gas Optimization

  1. Estimate First: Always use estimateSwap before executing

  2. Check Fees: Use getPoolFees to understand current fee rates

  3. Batch Operations: Consider batching swaps with other operations

  4. Token Approvals: Set approvals once for multiple swaps

Optimal Trading

  1. Check Pool State: Use getReserves to understand current pool composition

  2. Time Trades: Trade in direction that improves pool balance for lower fees

  3. Size Appropriately: Large trades may hit higher dynamic fees

  4. Monitor Oracle: Leverage Hyperliquid's read precompile prices for optimal timing

Error Handling

Common Errors

error InvalidToken();           // Token not supported by pool
error ZeroAmount();            // Amount input is zero  
error SlippageExceeded();      // Output below minAmountOut
error InsufficientReserve();   // Pool lacks sufficient tokens
error TransferFailed();        // Token transfer failed
error PriceDeviationTooLarge(); // Spot price too far from oracle

Error Resolution

  • InvalidToken: Ensure using correct USDT0/WHYPE addresses

  • ZeroAmount: Check amount input is greater than zero

  • SlippageExceeded: Increase slippage tolerance or reduce trade size

  • InsufficientReserve: Pool lacks liquidity, try smaller amount

  • PriceDeviationTooLarge: Wait for Hyperliquid oracle update or price stabilization

This pioneering trading system combines AMM mechanics with Hyperliquid's native HyperEVM read precompile oracles - a world-first integration that delivers unparalleled security and price accuracy only possible on Hyperliquid.

Last updated