-set-balance | (fn [addr bal] (let [orec (get-holding %0) rec (cond %2 (assoc %2 0 %1) (vector %1 nil)) ] (set-holding %0 %3))) | nil |
unwrap | (fn ([] (recur (call* #72 0 balance))) ([amount] (call* #72 %0 -unwrap %0))) | nil |
wrap | (fn [amount] (call* #72 %0 wrap-offer)) | nil |
decimals | (fn [] 9) | nil |
total-supply | (fn [] #72/supply) | nil |
quantity-add | (fn [a b] (let [a (cond %0 (int %0) 0) b (cond %1 (int %1) 0) ] (+ %2 %3))) | nil |
balance | (fn ([addr] (let [rec (get-holding %0) ] (cond (get %1 0) *result* 0)))) | nil |
direct-transfer | (fn [addr amount data] (let [addr (address %0) amount (#72/-qc %1) bal (#72/-get-balance *caller*) tbal (#72/-get-balance %3) ] (cond (< %4 0) (fail :ARGUMENT "negative transfer")) (cond (> %4 %5) (fail :FUNDS "insufficent token balance")) (cond (= *caller* %3) (do (log "TR" *caller* %3 %4 %5 %5 %2) (return %4)) nil) (let [nsb (- %5 %4) nrb (+ %6 %4) ] (log "TR" *caller* %3 %4 %7 %8 %2) (#72/-set-balance *caller* (- %5 %4)) (#72/-set-balance %3 (+ %6 %4))))) | nil |
-unwrap | (fn [amt] (let [new-bal (- (#72/-get-balance *caller*) %0) ] (cond (>= %1 0) *result* (fail "Insufficient balance for unwrap")) (#72/-set-balance *caller* %1) (def supply (- #72/supply %0)) (transfer *caller* %0) %0)) | nil |
quantity-subset? | (fn [a b] (let [a (cond %0 (int %0) 0) b (cond %1 (int %1) 0) ] (<= %2 %3))) | nil |
offer | (fn [receiver quantity] (let [quantity (#72/-qc %1) receiver (address %0) rec (get-holding *caller*) ] (cond %4 (let [os (nth %4 1) nrec (cond (<= %2 0) (assoc %4 1 (dissoc %5 %3)) (assoc %4 1 (assoc %5 %3 %2))) ] (set-holding *caller* %6)) (set-holding *caller* (vector 0 (hash-map %3 %2)))) %2)) | nil |
-get-balance | (fn [addr] (let [h (get-holding %0) bal (get %1 0 0) ] %2)) | nil |
supply | 0 | nil |
get-offer | (fn [sender receiver] (let [offs (get (get-holding %0) 1) ] (cond (get %2 %1) *result* 0))) | nil |
wrap-offer | (fn [] (let [amt *offer* new-bal (+ (#72/-get-balance *caller*) %0) ] (accept %0) (#72/-set-balance *caller* %1) (def supply (+ #72/supply %0)) %0)) | nil |
-qc | (fn [q] (cond (int? %0) %0 (nil? %0) 0 (fail :ARGUMENT "Invalid token quantity"))) | "Quantity check." |
quantity-sub | (fn [a b] (let [a (cond %0 (int %0) 0) b (cond %1 (int %1) 0) ] (cond (>= %2 %3) (- %2 %3) 0))) | nil |
accept | (fn [sender quantity] (let [quantity (#72/-qc %1) _ (cond (zero? %2) (return 0) (< %2 0) (fail :ARGUMENT "Negative accept amount")) receiver *caller* rec (get-holding %0) ] (cond %4 (let [os (nth %4 1) off (cond (get %5 %3) *result* (fail :STATE "No offer to receiver")) _ (cond (< %6 %2) (fail :STATE "insufficient offer")) bal (nth %4 0) nbal (- %7 %2) _ (cond (< %8 0) (fail :FUNDS "Insufficent balance to accept")) noff (- %6 %2) nos (cond (<= %9 0) (dissoc %5 %3) (assoc %5 %3 %9)) nrec (vector %8 %10) ] (set-holding %0 %11) (#72/-set-balance %3 (+ (#72/-get-balance %3) %2)) %2) (fail "No offers from sender")))) | nil |