Overview
QuantumPerps implements a virtual AMM-based perpetuals engine on ThiChain L1. Unlike order-book perpetuals, positions are settled against the virtual AMM liquidity pool. All mark prices are sourced from TWAP oracles, making them manipulation-resistant.
- THI/USDC
- QBIT/USDC
- ETH/USDC (cross-chain bridge)
- BTC/USDC (cross-chain bridge)
- Max leverage: 20×
- Min position: 10 USDC
- Max liquidation: 50% per event (Ahimsa)
- Funding interval: 8 hours
Opening a Position
// Long THI with 5× leverage
await perps.openPosition({
pair: 'THI/USDC',
direction: 'LONG',
margin: parseUnits('100', 6), // 100 USDC collateral
leverage: 5, // 5× = 500 USDC notional
slippage: 0.005,
});
When you open a position, the Dharmic Validator gate is invoked. Positions that would harm the protocol (e.g., exceeding global position caps) are rejected at the contract level.
Funding Rate
The funding rate is paid every 8 hours between longs and shorts based on the divergence between perpetuals price and TWAP oracle price. When the perps price is above mark price, longs pay shorts. This mechanism keeps perpetuals prices anchored to the underlying asset.
Liquidations & Ahimsa Protection
Positions are liquidated when their maintenance margin falls below the threshold. QuantumPerps enforces a critical ethical constraint from the Ahimsa principle:
No single liquidation event can seize more than 50% of a position's remaining collateral. This prevents total destruction of counterparty capital and gives traders a chance to recover or close their position.
Liquidation price is calculated as:
// Liquidation triggered when:
// (position_value / notional) < maintenance_margin_ratio
// But maximum seized = min(position_value, 50% of collateral)
Mark Price & TWAP Oracle
Mark price (used for liquidations and PnL) is sourced from IQuantumTWAPOracle.getMarkPrice() — a time-weighted average that smooths out spot price manipulation. The TWAP window is 30 minutes by default.
SDK Example
import { QuantumDEXClient } from '@qubismic/quantumdex-sdk';
const perps = client.perps();
// Get current positions
const positions = await perps.getPositions(userAddress);
// Get mark price for pair
const markPrice = await perps.getMarkPrice('THI/USDC');
// Get funding rate
const fundingRate = await perps.getFundingRate('THI/USDC');
// Close position
await perps.closePosition({
positionId: positions[0].id,
slippage: 0.01,
});