Source Code

(impl-trait .proposal-trait.proposal-trait)
(define-constant ERR-NOT-AUTHORIZED (err u1000))
(define-constant ERR-ALREADY-PROCESSED (err u1409))
(define-constant ONE_8 (pow u10 u8))
(define-map approved-operators principal bool)
(define-map processed-batches { cycle: uint, batch: uint } bool)
(define-read-only (is-dao-or-extension)
    (ok (asserts! (or (is-eq tx-sender .executor-dao) (contract-call? .executor-dao is-extension contract-caller)) ERR-NOT-AUTHORIZED)))
(define-read-only (is-cycle-batch-processed (cycle uint) (batch uint))
  (default-to false (map-get? processed-batches { cycle: cycle, batch: batch })))
(define-public (set-approved-operator (new-approved-operator principal) (approved bool))
  (begin
    (try! (is-dao-or-extension))
    (ok (map-set approved-operators new-approved-operator approved))))
(define-public (execute (sender principal))
	(begin
		(try! (contract-call? 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-apower add-approved-contract .auto-alex-apower-helper-v3))
		(try! (set-approved-operator 'SP1A6F9ABHQMVP92GH7T9ZBF029T1WG3SHPNMKT0D true))
		(ok true)))
(define-public (mint-and-burn-apower (cycle uint) (batch uint) (recipients (list 200 {recipient: principal, amount: uint})))
	(let (
      (minted (try! (fold mint-apower-iter recipients (ok u0)))))
		(asserts! (or (is-ok (is-dao-or-extension)) (is-ok (check-is-approved))) ERR-NOT-AUTHORIZED)
    (asserts! (is-eq (is-cycle-batch-processed cycle batch) false) ERR-ALREADY-PROCESSED)
    (map-set processed-batches { cycle: cycle, batch: batch } true)
    (as-contract (contract-call? 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-apower burn-fixed minted 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.auto-alex-v3))))
(define-private (mint-apower-iter (recipient {recipient: principal, amount: uint}) (prior (response uint uint)))
  (begin
    (as-contract (try! (contract-call? 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-apower mint-fixed (get amount recipient) (get recipient recipient))))
    (ok (+ (try! prior) (get amount recipient)))))
(define-private (check-is-approved)
  (ok (asserts! (default-to false (map-get? approved-operators tx-sender)) ERR-NOT-AUTHORIZED)))

Functions (7)

FunctionAccessArgs
is-dao-or-extensionread-only
is-cycle-batch-processedread-onlycycle: uint, batch: uint
set-approved-operatorpublicnew-approved-operator: principal, approved: bool
executepublicsender: principal
mint-and-burn-apowerpubliccycle: uint, batch: uint, recipients: (list 200 {recipient: principal, amount: uint}
mint-apower-iterprivaterecipient: {recipient: principal, amount: uint}, prior: (response uint uint
check-is-approvedprivate