Convex

Convex

Account #131
Account 132 / 14299
FieldValueNotes
Account KeynullEd25519 public key (null for actors)
Balance
        5,002.773352242
Convex coin balance
Account Fields
FieldValueDescription
:sequence0Number of transactions executed by this account to date.
:keynilEd25519 public key of this account. If nil, account cannot execute external transactions (e.g. an actor).
:balance
        5,002.773352242
CVM balance of account. This is used for transaction fees and may be freely transferred.
:allowance0Memory allowance credit on the CVM. If positive, the account may allocated up to this amount of memory before incurring fees for additional memory.
:holdings2 value(s)Storage for holdings data referenced by other accounts.
:controller#66Account controller. If set, the controller can execute code in this account (e.g. change the key). If you don't trust the controller, don't trust the account!
:environment32 value(s)Symbols defined in this account. Typically used to store data or executable code.
:metadata27 value(s)Metadata attached to symbols defined in this account.
:parentnilParent account. This defines fallback values for symbols not defined in this account.
Environment (32)

The Environment contains symbols defined in this account. These may be referenced like: #45/symbol-name

SymbolValueDescription
asset#65nil
token#130nil
fungible#64nil
price(fn [] (let [tok #131/token-balance cvm *balance* ] (cond (cond (> %0 0) (> %1 0) *result*) (/ %1 %0))))nil
buy-cvx-quote(fn [amount] (do (cond (< %0 0) (return nil) (>= %0 *balance*) (return nil)) (let [cvx-balance *balance* pool (* (double #131/token-balance) %1) rate (#131/calc-rate) ] (int (ceil (* (+ 1.0 %3) (- (/ %2 (- %1 %0)) #131/token-balance)))))))nil
decimals(fn [] 0)nil
total-supply(fn [] #131/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] (cond (get-holding %0) *result* 0))nil
calc-rate(fn [] 0.001)nil
direct-transfer(fn [addr amount data] (let [addr (address %0) amount (#131/-qc %1) bal (cond (get-holding *caller*) *result* 0) tbal (cond (get-holding %3) *result* 0) ] nil (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) (set-holding *caller* %7) (set-holding %3 %8))))nil
quantity-subset?(fn [a b] (<= (cond %0 (int %0) 0) (cond %1 (int %1) 0)))nil
sell-cvx(fn [amount] (let [amount (int %0) gained-tokens (cond (#131/sell-cvx-quote %1) *result* (fail :ARGUMENT "Cannot sell negative coin amount")) ] (#131/core/accept %1) (def token-balance (- #131/token-balance %2)) (#131/asset/transfer *caller* (vector #131/token %2)) %2))nil
torus#66nil
offer(fn [receiver quantity] (let [receiver (address %0) quantity (#131/-qc %1) ] (cond (<= %3 0) (cond (lookup-meta *address* offers) (def offers (#8/dissoc-in #131/offers (vector *caller* %2))) (fail :UNDECLARED offers)) (cond (lookup-meta *address* offers) (def offers (assoc-in #131/offers (vector *caller* %2) %3)) (fail :UNDECLARED offers))) %3))nil
sell-tokens(fn [amount] (let [amount (int %0) gained-cvx (cond (#131/sell-tokens-quote %1) *result* (fail :ARGUMENT "Cannot sell this negative token amount")) ] (#131/asset/accept *caller* (vector #131/token %1)) (def token-balance (+ #131/token-balance %1)) (#131/core/transfer *caller* %2) %2))nil
buy-tokens(fn [amount] (let [amount (int %0) _ (cond (< %1 0) (fail :ARGUMENT "Cannot buy negative token quantity")) required-cvx (cond (#131/buy-tokens-quote %1) *result* (fail :LIQUIDITY "Pool cannot supply this amount of tokens")) ] (#131/core/accept %2) (def token-balance (- #131/token-balance %1)) (#131/fungible/transfer #131/token *caller* %1) %2))nil
supply1403034590nil
check-transfer(fn [_sender _receiver _quantity] nil)nil
token-balance393485nil
offers{}nil
sell-cvx-quote(fn [amount] (do (cond (< %0 0) (return nil)) (let [cvx-balance *balance* pool (* (double #131/token-balance) %1) rate (#131/calc-rate) new-cvx-balance (+ %1 %0) ] (int (/ (- #131/token-balance (/ %2 %4)) (+ 1.0 %3))))))nil
get-offer(fn [sender receiver] (get-in #131/offers (vector %0 %1) 0))nil
buy-cvx(fn [amount] (let [amount (int %0) _ (cond (< %1 0) (fail :ARGUMENT "Cannot buy negative coin quantity")) required-tokens (cond (#131/buy-cvx-quote %1) *result* (fail :LIQUIDITY "Pool cannot supply this amount of CVX")) ] (#131/asset/accept *caller* (vector #131/token %2)) (def token-balance (+ #131/token-balance %2)) (#131/core/transfer *caller* %1) %2))nil
add-liquidity(fn [amount] (let [amount (#131/-qc %0) price (#131/price) initial-cvm-balance *balance* liquidity (sqrt (* (double %3) #131/token-balance)) has-liquidity (> %4 0) cvm (#131/core/accept (cond %5 (long (* %2 %1)) *offer*)) _ (#131/asset/accept *caller* #131/token %1) new-token-balance (+ #131/token-balance %1) new-liquidity (sqrt (* (double *balance*) %7)) delta (cond %5 (int (* (- %8 %4) (/ #131/supply %4))) (int %8)) ] (set-holding *caller* (+ %9 (cond (get-holding *caller*) *result* 0))) (cond (lookup-meta *address* supply) (def supply (+ #131/supply %9)) (fail :UNDECLARED supply)) (cond (lookup-meta *address* token-balance) (def token-balance %7) (fail :UNDECLARED token-balance)) %9))nil
-qc(fn [q] (cond (int? %0) %0 (nil? %0) 0 (fail :ARGUMENT "Invalid token quantity")))nil
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
withdraw-liquidity(fn [shares] (let [shares (#131/-qc %0) own-holding (cond (get-holding *caller*) *result* 0) _ (cond (> %1 %2) (fail :FUNDS "Insufficient shares") (< %1 0) (fail :ARGUMENT "Negative withdrawal")) proportion (cond (> #131/supply 0) (/ (double %1) #131/supply) 0.0) coin-refund (int (* %3 *balance*)) token-refund (int (* %3 #131/token-balance)) ] (cond (lookup-meta *address* token-balance) (def token-balance (- #131/token-balance %5)) (fail :UNDECLARED token-balance)) (set-holding *caller* (- %2 %1)) (cond (lookup-meta *address* supply) (def supply (- #131/supply %1)) (fail :UNDECLARED supply)) (transfer *caller* %4) (#131/fungible/transfer #131/token *caller* %5) %1))nil
sell-tokens-quote(fn [amount] (do (cond (< %0 0) (return nil)) (let [cvx-balance *balance* pool (* (double #131/token-balance) %1) rate (#131/calc-rate) new-token-balance (+ #131/token-balance %0) ] (int (/ (- %1 (/ %2 %4)) (+ 1.0 %3))))))nil
core#8nil
accept(fn [sender quantity] (let [sender (address %0) quantity (#131/-qc %1) om (get #131/offers %2) sendbal (cond (get-holding %2) *result* 0) offer (get %4 *caller* 0) ] (cond (< %3 0) (fail "Can't accept a negative quantity of fungible tokens.") (< %6 %3) (fail :STATE "Offer is insufficient") (< %5 %3) (fail :FUNDS "Sender token balance is insufficient") (let [new-offer (- %6 %3) ] (def offers (assoc #131/offers %2 (cond (> %7 0) (assoc %4 *caller* %7) (dissoc %4 *caller*)))) (set-holding %2 (- %5 %3)) (set-holding *caller* (+ (cond (get-holding *caller*) *result* 0) %3)) %3))))nil
buy-tokens-quote(fn [amount] (do (cond (< %0 0) (return nil) (>= %0 #131/token-balance) (return nil)) (let [cvx-balance *balance* pool (* (double #131/token-balance) %1) rate (#131/calc-rate) ] (int (ceil (* (+ 1.0 %3) (- (/ %2 (- #131/token-balance %0)) %1)))))))nil
Holdings (2)

Holdings track token balances and other indexed values by address.

AddressValue
#111403034590
#660