HwalDOCS

Quickstart

Clone, deploy to devnet, register a Pyth Lazer feed, delegate a position to MagicBlock ER, fire a 1ms-cadence trigger. Windows native or WSL.

Korean / non-ASCII paths
Solana's test validator and Turbopack panic on non-ASCII paths on Windows. If your project directory has non-ASCII characters, build via WSL or junction-link to an ASCII path before running anchor test or npm run dev.

Prerequisites

  • Rust via rustup
  • Solana CLI
  • Anchor
  • Node 20+ and npm
  • A Solana devnet wallet with ~5 SOL (web faucet if rate-limited)

1. Clone & build

terminal
bash
git clone https://github.com/Hwaldev/hwal.git
cd hwal
anchor build

First build syncs the program ID. The artifact lands attarget/deploy/hwal.so (~322 KB) and the IDL at target/idl/hwal.json.

2. Deploy to devnet

terminal
bash
solana config set --url https://api.devnet.solana.com
solana airdrop 5
anchor deploy --provider.cluster devnet

Burns ~2.24 SOL of rent for the program account. The deploy signature prints when it lands.

3. Bootstrap config + Lazer feed

This creates the Config PDA and registers a Pyth Lazer feed for SOL/USD on the chosen channel (1ms / 50ms / 200ms). The Lazer feed id is verified at everytick_position call via attestation.

terminal
bash
npm install
$env:ANCHOR_PROVIDER_URL = "https://api.devnet.solana.com"
$env:ANCHOR_WALLET = "C:\Users\baayo\.config\solana\id.json"
npx ts-node scripts/setup-devnet.ts --lazer-channel 50ms --feed sol-usd

4. Delegate position to MagicBlock ER

Opening a position automatically delegates the PDA to the MagicBlock ephemeral rollup. The position state lives in the ER, ticks at 50ms cadence, and commits back to L1 on trigger fire or cancel.

terminal
bash
npx ts-node scripts/smoke-test.ts --delegate-er

Expected output

output
text
==> position delegated to MagicBlock ER (slot cadence: 50ms)
==> lazer attestation @ 150.000000  → tick (no trigger, tick_count = 1)
==> lazer attestation @ 160.000000  → tick (take-profit fires inside ER)
==> ER state committed to L1 atomically
==> status = 1 (TRIGGERED), trigger_reason = 2 (take-profit)
==> settlement:
    trader: +0.049625 SOL  (collateral - 0.5% fee - 0.25% keeper)
    keeper: +0.000125 SOL  (0.05 * 0.25%)
    fee_rx: +0.00024  SOL  (0.05 * 0.5%, net of tx fee)
==> smoke test PASSED on devnet + ER.

5. Run the keeper bot inside ER

terminal
bash
npx ts-node scripts/keeper-bot.ts --er --channel 50ms

Subscribes to the Lazer feed at the chosen channel and submits tick_positioninside the MagicBlock ER for every open position. On a trigger fire, earns 0.25% of the collateral plus the L1 commit reward.

What next