;; SatGuard Governance Quorum
(define-constant err-owner (err u230))
(define-constant err-nf (err u231))
(define-constant err-amt (err u232))
(define-data-var admin principal tx-sender)
(define-data-var quorum-pct uint u50) ;; 50% default
(define-read-only (get-quorum-pct) (var-get quorum-pct))
(define-public (set-quorum-pct (pct uint))
(begin
(asserts! (is-eq tx-sender (var-get admin)) err-owner)
(asserts! (<= pct u100) err-amt)
(asserts! (> pct u0) err-amt)
(var-set quorum-pct pct)
(print {e: "quorum-updated",pct: pct})
(ok true)))
(define-read-only (check-quorum (pid uint))
(let ((tl (contract-call? .sg-gov-voting get-tally pid))
(pool (contract-call? .insurance-pool get-pool u1)))
(match tl
tally (match pool
p (ok (>= (+ (get vf tally) (get va tally)) (/ (* (get tf p) (var-get quorum-pct)) u100)))
(ok false))
(ok false))))
(define-read-only (get-quorum-status (pid uint))
(let ((tl (contract-call? .sg-gov-voting get-tally pid)))
(match tl
tally (ok {total-votes: (+ (get vf tally) (get va tally)),voter-count: (get tc tally)})
(ok {total-votes: u0,voter-count: u0}))))