Skip to content
kk-vvPublic

About

An open-source, self-custodial HyperLiquid mobile trading client built with React Native, viem, Expo. Supports Perp/Spot trading, local encrypted wallets, portfolio management, transfers, and real-time market data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

XPerp Logo

XPerp

English · 简体中文

A local, self-custodial mobile wallet and trading client for HyperLiquid.

XPerp uses viem to create, restore, and sign with wallets locally on the device. It connects directly to HyperLiquid Core through @nktkas/hyperliquid and does not depend on Privy, a proprietary backend, or a custodial account service.

Risk Notice

XPerp is a self-custodial HyperLiquid client. It does not hold user assets and cannot recover a lost recovery phrase. Digital assets and perpetual contracts involve substantial risk. Users are responsible for verifying order parameters, account addresses, leverage, fees, and liquidation risk.

This project is provided solely for learning and technical reference and does not constitute investment advice. For production use, a professionally security-audited third-party wallet custody solution such as Privy is recommended, together with the compliance and security reviews appropriate for the intended business.

Features

  • Create or import a wallet using an English BIP-39 recovery phrase.
  • Export the recovery phrase, copy the wallet address, or delete the local wallet.
  • View HyperLiquid Perp and Spot markets, order books, and candlestick charts.
  • Place and cancel Perp and Spot orders and view positions, open orders, and history.
  • Send assets from the HyperLiquid account.
  • Transfer assets internally between HyperLiquid Perp and Spot accounts.
  • Display the current HyperLiquid account address as a QR code.
  • Use the interface in Simplified Chinese or English.
  • Switch between light and dark themes.

Screenshots

Perpetual trading and order book HyperLiquid market picker Take profit and stop loss settings

Perp Trading · Market Picker · TP/SL

HyperLiquid candlestick chart HyperLiquid portfolio overview Local wallet settings

Market Chart · Portfolio · Wallet Settings

Wallet Security Model

Wallet keys and signing operations remain on the local device:

  1. @scure/bip39 generates or validates the English recovery phrase.
  2. viem/accounts derives a local HDAccount from the recovery phrase.
  3. AES-256-GCM encrypts the recovery phrase and uses the wallet address as additional authenticated data.
  4. AsyncStorage stores the ciphertext, while iOS Keychain or Android Keystore stores the independent 256-bit encryption key.
  5. When loading a wallet, the derived address is checked against the address stored in the encrypted record.
  6. The local viem account signs every HyperLiquid transaction.

A newly generated wallet is saved only after the user confirms the recovery phrase. Deleting the local wallet removes both the encrypted record and its encryption key from secure device storage.

The recovery phrase is the only way to restore the wallet. Back it up offline and never capture, upload, or share it. If the device is lost, the app is uninstalled, or app data is cleared, the wallet cannot be recovered without this backup.

Assets and Deposits

The app displays the HyperLiquid account address associated with the current local wallet. The deposit QR code is intended only for receiving HyperLiquid Spot or Perp account assets at that address. Always verify the asset type, destination address, and current HyperLiquid rules before transferring assets.

Market Data Strategy

  • Zustand stores cache market metadata and list snapshots.
  • The All Coins modal shows cached data first and makes one API request only when no cache exists. It does not refresh the full list continuously over WebSocket.
  • The active market's order book uses a HyperLiquid WebSocket subscription with UI update coalescing to avoid unnecessary high-frequency renders.
  • Account, position, order, and history data comes directly from HyperLiquid.

Technology Stack

Area Implementation
Mobile Expo 54, React Native 0.81, React 19
Routing Expo Router
Wallet creation and signing viem
HyperLiquid API @nktkas/hyperliquid
Recovery phrase @scure/bip39
Local encryption @noble/ciphers AES-GCM
Secure key storage expo-secure-store
State management Zustand
Large lists FlashList

Development Environment

Prerequisites:

  • The current Node.js LTS release and npm.
  • For iOS: macOS, Xcode, and CocoaPods.
  • For Android: Android Studio, the Android SDK, and an available emulator or device.

Install dependencies:

npm install

Start the Expo development server:

npm run start

Create and run native development builds:

npm run ios
npm run android

Expo hot reload can be used for routine UI development. Native dependencies, Keychain or Keystore behavior, and release configuration should receive final verification in a native development build.

Quality Checks

# Route, wallet encryption, builder configuration, locale, and source reachability checks
npm test

# TypeScript type checking
npx tsc --noEmit

# ESLint and Prettier checks
npm run lint

# Expo dependency and project configuration checks
npx expo-doctor

npm test currently covers:

  • Route validity.
  • Wallet encryption, decryption, tamper detection, and address verification.
  • Optional builder configuration and order parameters.
  • Matching translation keys between English and Simplified Chinese.
  • Unreachable source files.

Project Structure

app/                                  Expo Router screens and navigation
biz/wallet/                           Local wallet, encryption, and wallet state
biz/services/HyperLiquidSDK/          HyperLiquid HTTP, WebSocket, and trading clients
biz/viewmodels/HyperLiquid/           Market, account, and trading state
components/HyperLiquidTrade/          Perp and Spot trading UI
components/AssetsTransfer/            Sending, deposit display, and Perp/Spot transfers
locales/                              English and Simplified Chinese copy
scripts/                              Project constraints and automated checks

Trading Fees

The builder fee is optional and configured in constants/GlobalConfig.ts. When hyperLiquidBuilder.b contains a valid, non-empty address, the app checks and approves the builder fee according to HyperLiquid rules before trading. The current configured maximum rate is 0.055%. When b is empty or omitted, the app neither queries nor approves a builder fee, and no order includes a builder field. This fee is separate from HyperLiquid trading fees, funding, and network costs. Review all order details before submission.

License

This project is released under the MIT License.

About

An open-source, self-custodial HyperLiquid mobile trading client built with React Native, viem, Expo. Supports Perp/Spot trading, local encrypted wallets, portfolio management, transfers, and real-time market data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages