Weekend-gap cover for stock and RWA perp LP vaults, priced on chain in Rust



Weekend gaps are a hidden liability for perpetual trading venues.
When SPY, NVDA, gold or EUR/USD opens sharply away from Friday's close, the liquidity vault backing the venue takes the first loss.
On gTrade, that risk sits with the gUSDC vault.
At Arbitrum One block 511,007,816, the vault was carrying:
153,309 USDC long SPY
23,665 USDC short NVDA
10,093 USDC short gold
3,000 USDC short EUR/USD
4,569,046 USDC total assets
On Ostium, a junior buffer absorbs trader PnL before the rest of the system.
The scale of the problem is already significant:
Venue | Arbitrum TVL | Open Interest |
|---|---|---|
gTrade | $7,464,963 | $2,394,444 |
Ostium | $8,589,418 | $10,298,257 |
DefiLlama, read 2026-10-02.
Neither venue has a third party standing behind that weekend risk.
Heracles is that missing layer.
A venue declares its weekend book.
Heracles prices the exposure on-chain.
Investors provide capital to absorb the risk and earn a premium.
If Monday opens beyond the agreed retention, Heracles pays the covered loss up to the purchased limit.
There is no claims committee deciding whether a loss qualifies.
There is no governance vote.
The contract compares two Chainlink prices and settles.
That makes Heracles closer to automated reinsurance for trading infrastructure than traditional insurance.
A buyer calls bind with:
Signed notional for every market
Retention
Coverage limit
Maximum premium they are willing to pay
The binding window ends before Thursday 19:30 UTC, before the Friday reference exists.
This prevents the buyer from seeing the final weekend price and then choosing to insure only the outcomes they already know about.
The Arbitrum Stylus pricer uses each market's own 504-scenario historical weekend gap table.
The quote combines:
Expected loss + 3% of the tail above expected loss + a 4% annualised capital charge on the locked limit
The result is calculated on-chain at the moment of binding.
Writers provide capital through two ERC-4626 pools:
First-loss capital
Takes the first slice of a covered loss and earns the corresponding premium.
Senior capital
Sits above the first-loss layer and earns for taking the remaining risk.
When a layer is bound, the required capacity is locked in both pools.
The reference price is the Chainlink round in effect at the Friday 4:00pm New York close.
The fix is the first fresh Chainlink round after Monday's 9:30am open.
The contract does not rely on a human to submit either price.
The payout is:
declared exposure × Monday gap above the retention
with the payment capped at the purchased limit.
The first-loss vault pays first.
Buyers and writers claim their own balances.
If the required Chainlink round cannot be served, anyone can prove the failure on-chain and the contract cancels the layer with a full premium refund.
The interesting part of Heracles is that the pricing model, risk controls and underwriting all live on-chain.
The Stylus pricer maintains separate weekend-gap tables for:
NVDA
AAPL
SPY
TSLA
EUR/USD
XAU/USD
The tables are adjusted using realised volatility.
A Solidity implementation runs alongside the Rust implementation and serves as the parity reference.
Across one, four and eight markets, the Stylus version uses:
8.00× less L2 execution gas
5.41× less L2 execution gas
4.29× less L2 execution gas
respectively, versus the Solidity implementation.
The six-table implementation produced identical quotes on Arbitrum Sepolia and Robinhood Chain testnet in 10 out of 10 parity checks.
Three separate components consume the on-chain price.
Treaty uses it when coverage is bound.
OIGuard uses it to decide whether a venue can accept additional exposure.
VaultCover uses it to renew a vault's protection each week under a premium ceiling.
The guard is not advisory.
For example, a 2,000,000 NVDA short was rejected because it exceeded the owner's configured premium budget:
PremiumOverBudget(6,684.63, 4,000, 153.42)
That means the insurance price can directly become part of a venue's trading controls.
This is another important distinction.
Heracles pays against the declared Friday-to-Monday gap.
It does not wait for a liquidation event.
A venue can therefore insure the actual market risk sitting in its vault, even when every trader remains solvent and no liquidation ever occurs.
A USDC layer was bound on 2026-10-01 over:
200 USDC of SPY
The premium was:
0.195737 USDC
The bind transaction:
0x770752c7522caf31ce5d493693e48f8bed71726607be0351b835669eb3b85b70
The Friday reference was:
SPY = 770.38
The full weekend can also be replayed directly in the application.
For the weekend of September 25, 2026:
Vault-side loss: 10,910.41
Retention: 3,000
Coverage limit: 20,000
Heracles payout: 7,910.41
Stylus quoted premium: 3,025.37
The replay makes the mechanism visible without requiring the judge to reconstruct the math manually.
The testnet deployment includes four ERC-4626 capacity vaults:
First-loss
0x80b50d73b87BE3ac7Cd0F2DF35bE74033f8E4cF3
Senior
0x05DD502aa5ca21f97c0536e4164D609B38A632Bc
First-loss
0xb293E54AffE056708FCc54D0D1d16A7B7aD1FebB
Senior
0x510e4266C55a58879d3a77eC02e77CCF1602cA39
The USDG book already holds 90 Paxos USDG, deposited through permit:
30 USDG first-loss
60 USDG senior
Component | Address |
|---|---|
Treaty |
|
Stylus Pricer |
|
Six-table Stylus Pricer |
|
OIGuard |
|
VaultCover |
|
The implementation currently has:
196 tests
17 fork tests
18 / 18 pricer mutations killed
10 / 10 VaultCover mutations killed
The fork tests use Chainlink feeds and the L2 Sequencer Uptime feed against an Arbitrum One fork.
The pricing logic also has a Solidity twin, giving the Rust implementation an independent parity target instead of relying on a single code path.
https://heracles-cover.vercel.app
The /replay page lets a judge step through an actual historical weekend and see the insured loss, retention, limit and resulting payout.
Pricing: Arbitrum Stylus, Rust, stylus-sdk
Market data: Chainlink price feeds and L2 Sequencer Uptime feed
Capital: Paxos USDG, USDC, OpenZeppelin ERC-4626
Contracts: Solidity, Foundry
Client: TypeScript, viem
Frontend: React
Perpetual venues can move weekend gap exposure away from their own LP capital.
Risk teams can set a retention and limit instead of leaving the entire tail with the vault.
Underwriters can earn a premium for taking a measurable, bounded slice of venue risk.
Venue operators can use the same pricing engine as a pre-trade risk check.
Heracles is not trying to build another insurance marketplace.
It takes a specific risk that already exists inside on-chain trading venues, turns that risk into a declared book, prices it from historical market behaviour, funds it with external capital and settles it from machine-verifiable prices.
The novel primitive is simple: a perp venue can buy an on-chain, automatically settling weekend reinsurance policy for the exact positions its vault is carrying.
Build from Ground Zero during the Hackathon , took tons of User Interviews to understand their problems before building the platform