Source Code

;; SatGuard Pool Boost - multiplier for stakers
(define-constant err-owner (err u540))
(define-constant err-amt (err u541))
(define-data-var admin principal tx-sender)
(define-map boosts {pid: uint} {mult: uint,sa: uint})
(define-read-only (get-boost (pid uint)) (default-to {mult: u100,sa: u0} (map-get? boosts {pid: pid})))
(define-public (set-boost (pid uint) (mult uint))
  (begin
    (asserts! (is-eq tx-sender (var-get admin)) err-owner)
    (asserts! (>= mult u100) err-amt) ;; min 1x (100 = 1.00x)
    (asserts! (<= mult u500) err-amt) ;; max 5x
    (map-set boosts {pid: pid} {mult: mult,sa: block-height})
    (print {e: "boost-set",pid: pid,mult: mult})
    (ok true)))
(define-read-only (calc-boosted (pid uint) (amt uint))
  (let ((b (get-boost pid)))
    (ok (/ (* amt (get mult b)) u100))))
(define-read-only (get-user-boosted-stake (pid uint) (who principal))
  (let ((s (contract-call? .sg-staking-core get-stake who))
        (sa (get amt s))
        (b (get-boost pid)))
    (ok (/ (* sa (get mult b)) u100))))

Functions (4)

FunctionAccessArgs
get-boostread-onlypid: uint
set-boostpublicpid: uint, mult: uint
calc-boostedread-onlypid: uint, amt: uint
get-user-boosted-stakeread-onlypid: uint, who: principal