
Pick your fee. Or pick your luck. A Uniswap v4 Hook on X Layer. Live on testnet now. Built for @XLayerOfficial × @Uniswap × @flapdotsh hackathon 🎰
Joined April 2022
- Tweets10
- Following67
- Followers26
- Likes4
Pinned Tweet
🎰 Introducing RouletteSwap — a Uniswap v4 Hook where every swap is a coin flip you opt into.
Safe: flat 30 bps
Risky: 5/6 of 5 bps · 1/6 of 155 bps
Expected fee identical. LP economics neutral.
Live on @XLayerOfficial testnet 🧵
#BuildX
1
265
🥉 3rd place @ @XLayerOfficial × @Uniswap × @flapdotsh "Hook the Future" 🙏
Huge thanks to the X Layer team for a well-run hackathon.
What we shipped:
• novel per-swap fee distribution primitive
• 8/8 Foundry tests + 600-trial statistical invariant
• live on X Layer testnet
2
2
74
24 Risky swaps on @RouletteSwap "Beat the House" mode.
bust 2 · survive 22 (RNG was kind today)
paid: 420 bps
if all Safe: 720 bps
→ saved 300 bps
LP economics unchanged. variance is a feature, not a bug.
@XLayerOfficial #BuildX
135
why 5/6 odds, not 9/10 or 99/100?
EV must equal 30 bps → bust fee is forced:
1/6 → 155 bps (5x baseline)
1/10 → 255 bps (8.5x)
1/100 → 2,500+ (degen-only)
5/6 = d6 intuition · cheap to compute · real variance · survivable bust
@XLayerOfficial #BuildX
71
how to prove a "5/6 chance of 5 bps · 1/6 of 155" hook is actually EV-neutral?
let Foundry do it.
600 trials. mean fee within ±20% of 3000 pips. bust frequency within ±35% of 1/6.
if either bound trips, the contract ships broken.
8/8 tests green.
@XLayerOfficial #BuildX
52
every v4 fee hook asks "what's the fee?"
nobody asks "what's the fee DISTRIBUTION?"
RouletteSwap:
uint24 lpFee = roll() == BUST ? 15_500 : 500;
5 bps survive · 155 bust · 1/6 odds · LP-EV-neutral
@XLayerOfficial #BuildX
40
Replying to @RouletteSwap @XLayerOfficial
Built for the @XLayerOfficial × @Uniswap × @flapdotsh "Hook the Future" hackathon.
One contract. ~110 LOC of business logic. No oracles. No admin keys. No token. Just per-swap risk election attached to a real v4 pool.
Code: github.com/gdongxi/roulette-…
1
50
The math:
E[Safe] = 30 bps
E[Risky] = (5/6)·5 + (1/6)·155 = 30 bps
Identical EV — verified by a 600-trial Foundry invariant. LPs see zero EV impact. Strict Pareto improvement on AMM fee design.
Hook: oklink.com/xlayer-test/addre…
39




