Backend and API
The smart contract is administered by a Cardinal-operated backend.
Worker
Worker runs every 12 seconds.
Steps:
- Calculate
carry_tfrom Aave V3 on-chain and sUSDe or wstETH native yield. - Call
settleTick(carry_t, now, all_active_position_ids), batched if needed. - Sync updated position state back to Postgres.
- Deploy spare capital into Aave V3 borrow loops via
deployToAave. - Read LP-Book Pool health.
- Trigger auto-deleverage if health factor falls below threshold or pool NAV drops more than 10% peak-to-trough.
- Update
free_NAVand committed capacity in Postgres after each tick.
The same 12-second worker also calls settleNRH if 1 hour has elapsed since lastNRHSettlement.
settleNRH receives gross carry, not a spot read.
API
The Carry Perp endpoints:
GET /positions/:user
GET /market
GET /pool
GET /positions/:user reads from Postgres.
GET /market returns current carry, pool NAV, and remaining capacity.
GET /pool is LP-facing and returns NAV, free_NAV, withdrawal queue status, and LP-Book Pool health.
The Perpetual Negative Rate Hedge endpoints:
GET /policies/:user
GET /policy/:id/projection
Frontend
Frontend should include the ability to call state-writing methods:
- open and close positions in The Carry Perp
- LP deposit and withdrawal
- open, close, top up, and adjust The Perpetual Negative Rate Hedge positions