On Hyperliquid, dYdX, and every other perp DEX, your positions are visible to everyone. Hunters track your liquidation price. Parasites copy your trades. Competitors analyze your strategy.
Complete trading privacy. Zero information leakage. Impossible to track.
struct Order {
price: u64, // 8 bytes
quantity: u64, // 8 bytes
trader: [u8; 32], // 32 bytes
nonce: u64, // 8 bytes
flags: u32, // 4 bytes
padding: [u8; 4] // 4 bytes
} // 64 bytes ร 30,000 = 1.92MB base
struct Position {
entry: u64, // 8 bytes
size: i64, // 8 bytes
margin: u64, // 8 bytes
realized: i64, // 8 bytes
funding: i64, // 8 bytes
timestamp: u64 // 8 bytes
} // 48 bytes ร 30,000 = 1.44MB
struct Fragment {
order_id: u32, // 4 bytes
fill_qty: u64, // 8 bytes
fill_price: u64, // 8 bytes
counter: u32, // 4 bytes
timestamp: u64 // 8 bytes
} // 32 bytes ร 16,000 = 512KB
#[repr(C, packed)]
pub struct Slab {
magic: [u8; 8], // b"PERPALTR"
version: u32,
flags: u32,
orders: [Order; 30_000],
positions: [Position; 30_000],
fragments: [Fragment; 16_000],
// Memory-mapped file backed
_phantom: PhantomData<*const u8>,
}
impl Slab {
pub unsafe fn from_mmap(mmap: &Mmap) -> &Self {
assert_eq!(mmap.len(), std::mem::size_of::<Slab>());
&*(mmap.as_ptr() as *const Slab)
}
pub fn process_order(&self, order: Order) -> Result<(), Error> {
// Direct memory operations, no heap allocations
let slot = self.find_slot();
self.orders[slot].store(order, Ordering::Release);
Ok(())
}
}
pub struct EncryptedOrder {
// Homomorphic encryption allows operations on ciphertext
encrypted_price: PaillierCiphertext,
encrypted_size: PaillierCiphertext,
// Zero-knowledge proof of valid range
range_proof: BulletProof,
// Commitment to prevent double-spending
commitment: PedersenCommitment,
}
impl EncryptedOrder {
pub fn match_orders(
&self,
other: &EncryptedOrder
) -> EncryptedFill {
// Matching without decryption
let encrypted_exec_price = self.encrypted_price
.homomorphic_add(&other.encrypted_price)
.homomorphic_div(2);
EncryptedFill {
price: encrypted_exec_price,
proof: self.generate_execution_proof(),
}
}
}
// Benchmarks from production environment
#[bench]
fn bench_order_processing(b: &mut Bencher) {
b.iter(|| {
slab.process_order(order)
});
}
// Result: 98ns per order (10.2M orders/sec)
#[bench]
fn bench_liquidation_check(b: &mut Bencher) {
b.iter(|| {
slab.check_liquidations()
});
}
// Result: 1.2ยตs for 30k positions (833k checks/sec)
#[bench]
fn bench_settlement(b: &mut Bencher) {
b.iter(|| {
slab.settle_batch(fills)
});
}
// Result: 450ns per fill (2.2M settlements/sec)
plaintext: {price: 47823, size: 1000}
encrypted: {p: 0x7f3a9b2c..., s: 0x9e8d7c6b...}
obfuscated: origin unknown
match without decryption
proof: valid, details: hidden
On public DEXs, your large position is immediately visible to all participants. Hunters calculate your exact liquidation price.
Multiple actors coordinate to push price toward your liquidation level. They profit from the liquidation cascade.
Your liquidation triggers other liquidations, creating a waterfall effect. Hunters close their shorts at the bottom.
Hunters made millions. You lost everything. This happens every day on public perpetual exchanges.
Implements Pedersen commitments with range proofs to hide position sizes while maintaining verifiable solvency. Utilizes recursive zkSNARKs for proof aggregation.
Maintenance margin levels are encrypted using threshold cryptography. Liquidation triggers are computed inside a trusted execution environment (TEE) preventing targeted attacks on known liquidation prices.
Order flow is anonymized through mix networks with decoy orders injected via commitment-reveal schemes, preventing pattern recognition and statistical arbitrage.
Zero-knowledge perpetual trading protocol. Built on Percolator's sharded architecture.