Metacenter

Gate a vault on headroom

Pause an action when headroom or coverage gets thin, or the feed goes stale.

The pattern in coverage-guard, adapted to headroom:

(define-constant MIN_HEADROOM_BPS u5000) ;; pause when the pool could fall less than 50%

(define-public (deposit (feed <risk-feed>) (amount uint))
  (let ((s (try! (contract-call? feed get-coverage-summary))))
    (asserts! (is-eq (contract-of feed) TRUSTED_FEED) ERR_UNTRUSTED_FEED)
    (asserts! (match (get headroom-bps s) h (>= h MIN_HEADROOM_BPS) true) ERR_PAUSED)
    ;; ... your deposit logic
    (ok amount)))

Choosing thresholds

  • Headroom is currently 94.0% onchain (block 967,806); coverage is 16.68× onchain (block 967,806).
  • 2.0× coverage equals 50% headroom.
  • Always check staleness with updated-at. Mirrored feeds post once per distribution (about weekly).
  • Pin the trusted feed (contract-of), so a caller cannot pass in a contract that returns whatever it likes.
Edit on GitHub

On this page