Works with the AI Agents you already use
Perp Protocol Design Review
by BanditXBT
Solvency-focused review of perp/margin protocols: margin, funding, liquidation, insurance fund, ADL.
$4.20
About this skill
A perp venue is a solvency machine: every unit of unrealized profit is someone's loss or the pool's liability. Review whether that books always balance under stress.
- Orderbook / matching engine (on- or off-chain): counterparties are traders; protocol bears only bad debt.
- Oracle-priced pool (LP/vault is counterparty): LPs are short trader PnL; price manipulation and skew become LP losses.
- vAMM / virtual curve: price impact from curve; funding anchors mark to index. State who is the counterparty to each trade and who absorbs shortfall.
- Conservation: total collateral + insurance ≈ Σ(user equity) + protocol liabilities; zero-sum PnL across longs/shorts net of fees.
- No free money: open then immediately close at the same price returns ≤ initial collateral minus fees.
- Margin:
equity ≥ initial marginto open or increase;equity < maintenance margin⇒ liquidatable; liquidation must move account to a safer state. - OI & risk caps: per-market OI, per-account size, skew/imbalance limits are enforced on every path (including partial close, collateral withdrawal, and order execution by keepers).
- Funding: payments net to ~zero between longs and shorts (or are accounted for if pool is counterparty); accrual is time-weighted and cannot be skipped or double-counted.
- Mark vs. index vs. last price: liquidation and PnL should use a manipulation-resistant mark (index with premium/TWAP clamp), not last trade. Check price-source switching and fallback behavior.
- Funding rate: formula (premium/skew-based), clamp, interval, sign convention, max rate; behavior at extreme skew; precision and rounding; funding applied before margin checks.
- Margin model: isolated vs. cross; per-asset haircuts on collateral; collateral that correlates with the position (wrong-way risk: ETH collateral long ETH); unrealized-PnL counted as collateral?
- Liquidation: trigger, close factor (partial vs. full), penalty/fee split (liquidator vs. insurance), minimum position size so liquidations remain profitable under gas, keeper incentive vs. gas on each chain, behavior when liquidation is unprofitable (bad debt accrues). Self-liquidation to capture the fee; liquidation of positions at the same oracle tick used to open.
- Insurance fund & socialization: order of loss absorption (liquidation penalty → insurance → LP/vault → ADL or socialized loss). ADL rules should be deterministic and ranked by profit×leverage. Attack: drain insurance fund via coordinated bad-debt creation.
- Order lifecycle: keeper-executed orders (two-step request/execute) with price-at-execution vs. price-at-request; stale-order replay; cancellation griefing; front-running of oracle updates (latency arbitrage against pull oracles such as Pyth: attacker picks which signed price to submit within the allowed window).
- Fees & rebates: exploitable with wash trading, self-referral, negative-fee maker rebates.
- Admin/risk params: who can change leverage, caps, oracle, fee? Timelock? Can an update instantly make healthy accounts liquidatable?
- Chain specifics: sequencer downtime (grace period before liquidations resume), block time/latency vs. funding interval, gas auction dynamics on congested chains.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
Requires
Nothing to install.
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
New in Security
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.