HyperSolid is a cryptocurrency trading application developed with Flutter, providing spot and perpetual contract trading capabilities. This WebView JSSDK project enables third-party Web applications to interact with the HyperSolid App, achieving seamless Web-to-Native communication.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HyperSolid App (Flutter) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β UI Layer β β Business Logic β β Data Layer β β
β β β β β β β β
β β β’ Home Page β β β’ Trade Service β β β’ API Service β β
β β β’ Trade Page β β β’ Wallet Serviceβ β β’ Local Storage β β
β β β’ Portfolio β β β’ Order Service β β β’ WebSocket β β
β β β’ Account β β β’ Price Service β β β’ Database β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β WebView Bridge Layer β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Bridge Manager β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββ β β
β β β Wallet β β Navigation β β Order β β System β β β
β β β Handler β β Handler β β Handler β βHandler β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββ β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββ β β
β β β Position β β Price β β Asset β β Fill β β β
β β β Handler β β Handler β β Handler β βHandler β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β WebView Container β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Web Application β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β HyperSolid JSSDK β β β
β β β β β β
β β β β’ wallet API β’ position API β’ order API β β β
β β β β’ trading API β’ price API β’ navigation API β β β
β β β β’ asset API β’ fill API β’ system API β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β β
β β HTML + CSS + JavaScript β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Provides wallet connection status query, address retrieval, and balance inquiry functions.
Main Features:
- Get wallet connection information
- Query wallet address
- Get account balance
- Check connection status
Usage Examples:
// Get wallet information
const { data: walletInfo } = await HyperSolidSDK.wallet.getInfo();
console.log("Wallet address:", walletInfo.address);
// Get balance
const { data: balance } = await HyperSolidSDK.wallet.getWalletPerpBalance();
console.log("Account balance:", balance);This is the core functionality of the SDK, providing complete trading order capabilities, supporting both spot and perpetual contract trading.
Main Features:
- Limit Order Trading: Specify price for buy/sell orders
- Market Order Trading: Execute immediately at current market price
- Percentage-based Orders: Automatically calculate order size based on available funds percentage
- Position Management: Support reduce-only mode
- Dual Market Support: Spot trading and perpetual contract trading
API Detailed Description:
// Limit Buy (Long)
await HyperSolidSDK.trading.limitBuy({
symbol: "BTC", // Trading pair symbol
price: 50000, // Limit price
size: 0.001, // Trading quantity
isSpot: false, // false=perpetual contract, true=spot
reduceOnly: false, // Reduce-only mode
});
// Limit Sell (Short)
await HyperSolidSDK.trading.limitSell({
symbol: "BTC",
price: 52000,
size: 0.001,
isSpot: false,
reduceOnly: false,
});// Market Buy (automatically get current price)
await HyperSolidSDK.trading.marketBuy({
symbol: "BTC",
size: 0.001,
isSpot: false,
reduceOnly: false,
});
// Market Sell
await HyperSolidSDK.trading.marketSell({
symbol: "BTC",
size: 0.001,
isSpot: false,
reduceOnly: false,
});// Use 25% of available funds for limit buy
await HyperSolidSDK.trading.limitBuyByPercentage({
symbol: "BTC",
price: 50000,
percentage: 0.25, // 25% of available funds
isSpot: false,
reduceOnly: false,
});
// Use 50% of position for market sell
await HyperSolidSDK.trading.marketSellByPercentage({
symbol: "BTC",
percentage: 0.5, // 50% of position
isSpot: false,
reduceOnly: true,
});Technical Advantages of Trading API:
- Smart Price Retrieval: Market orders automatically get latest price from server
- Fund Management: Percentage orders automatically calculate maximum tradable amount
- Risk Control: Support reduce-only mode to prevent over-leverage
- Dual Market Support: Unified interface for both spot and contract trading
- Error Handling: Comprehensive exception handling and user feedback
Provides real-time position query and management functions.
Main Features:
- Get all position list
- Query specific coin position
- Long/short position filtering
- Position summary statistics
Usage Examples:
// Get all positions
const { data: positions } = await HyperSolidSDK.position.getPositions();
// Get BTC position
const { data: btcPosition } = await HyperSolidSDK.position.getPosition("BTC");
// Get long positions
const longPositions = await HyperSolidSDK.position.getLongPositions();Provides query and management functions for open orders.
Main Features:
- Get all open orders
- Query orders by coin
- Classify buy/sell orders
- Order statistics
Provides query functions for trade execution records.
Main Features:
- Get all fill history
- Query fills by coin
- Fill history summary
Provides real-time price data query functions.
Main Features:
- Get current price
- Get trade details
- Support spot and contract prices
Provides user asset data query functions.
Main Features:
- Get user asset data
- Query maximum trade size limits
Provides page navigation and routing control functions.
Main Features:
- Basic page navigation (Home, Trade, Portfolio, Account)
- Trade page navigation (with parameters)
- Custom route navigation
- Back operations
Provides system-level function calls.
Main Features:
- Page refresh
- Version information query
- System information retrieval
- Connectivity testing
- Asynchronous Communication: Promise-based asynchronous API design
- Type Safety: Provides TypeScript type definitions
- Error Handling: Unified error handling mechanism
- Timeout Control: 10 second request timeout protection
- State Management: SDK ready state detection
- Compatibility: Supports modern browsers and WebView environments
<script src="./jssdk/hypersolid-sdk.js"></script>if (HyperSolidSDK.utils.isReady()) {
console.log("SDK is ready");
} else {
HyperSolidSDK.utils.onReady(() => {
console.log("SDK initialization completed");
});
}try {
const result = await HyperSolidSDK.wallet.getInfo();
console.log("Call successful:", result);
} catch (error) {
console.error("Call failed:", error.message);
}- All API calls are verified through Flutter side
- Support wallet connection status checking
- Provide comprehensive error handling mechanism
- Timeout protection prevents long waiting times
- Current Version: 1.0.0
- Compatibility: Supports Flutter WebView
- Update Date: 2025
This document is the technical specification for HyperSolid WebView JSSDK. For detailed API reference, please check the test examples in index.html.