Users
Make groups of users and read them. A user is one address across every watched contract. A group is a kind of user: the traders, the LPs, a list of partners. See Users.
Requires contract-dev login. Add --json to any command for its full answer.
contract-dev user create Traders --type traders --who Swap.sender \
--sum "Volume=Swap.amount token 0x… show usd" --rank Volume
contract-dev user list Traders --sort "{Volume}" --limit 20
contract-dev user show 0x1234…user create <Group>
Make a group: its type, who is in it, what is measured of them and what they are ranked by.
contract-dev user create <Group> --type traders|holders|other [--who <Event>.<field>]…
[--on <contract|group:<group>>] [--count <Label>=<Event>]…
[--sum "<Label>=<Event>.<field> [token <token>] [show usd]"]…
[--column "<Label>=<view>(<args>)…"]… [--formula "<Label>=<expr>"]…
[--status "<Label>: …"]… [--rank <Label>] [--when "<rule>"]
[--show "<Label>, <Label>"] [--detail "<Label>, <Label>"]| Flag | Description |
|---|---|
--type | Required. traders, holders or other: how the group’s users are judged. See Group types. |
--who <Event>.<field> | The event field that holds the user: --who Swap.sender. Required unless --when is given. One line per event; several events make one group. <Event>.signer() is the account that sent the transaction. With no --when, a user is in the group once it appears in any of these events. |
--on | Narrows the --who lines given with it, and the group’s counts and sums with them, to one contract or contract group: --on group:Pools, --on 0x…. Without it, an event is every watched contract’s by that name. |
--count <Label>=<Event> | How many of an event name the user: --count Swaps=Swap. One is made for each --who event that has none. |
--sum | An event’s number field added up per user. See Sums. |
--column | A view read with the user as an argument. See Reads. |
--formula | An expression over the other numbers. See Formulas. |
--status | A category. The first option whose rule holds wins; an option with no rule, last, is the rest: --status "Tier: Whale={Volume} > 1000000; Other". |
--rank <Label> | The number the users are ranked by, largest first: one of the group’s, or Transactions, In, Out, Contracts. Required with --type holders, as what each holds. With none, the most recently active come first. |
--when "<rule>" | The rule a user is in the group by, over numbers by label in braces. For a group cut from numbers that already exist: user create Whales --type traders --when "{Volume} > 1000000" --rank Volume. |
--show | The numbers the group’s page shows, in order. With none, the ones made with it. |
--detail | Numbers a user’s page shows for the group that its list does not, in order. |
Read the contract’s source for which field owns the position. It is often not the signer: a deposit can be made for someone else, by a keeper or through a router.
Numbers belong to the workspace, so a group can name one made with another. A workspace holds up to 20 groups, besides imported lists, and 24 numbers.
Sums
--sum "<Label>=<what> <clauses>" adds an amount up per user. <what> is one of:
| What | Adds up |
|---|---|
Swap.amount | An event’s field. |
abs(Swap.amount0) | An event’s field by its size. A signed field nets out when added up; abs() makes it a volume. |
usd from table:Swaps | A field of a table of events: here usd of the Swaps table. |
each Swap; … | A value worked out per event, in the words of metric create. |
After an event’s field:
| Clause | Description |
|---|---|
token <token> | What the amount counts in: a 0x address, self, or a view each contract answers with it, such as asset(). |
show usd | Prices the amount in dollars. A sum from a table takes it too. |
decimals <n> | Scales a plain number. |
contract-dev user update LPs --sum "Deposited=Deposit.assets token asset() show usd"
contract-dev user update Traders --sum "Volume=abs(Swap.amount0) token 0x… show usd"
contract-dev user update Traders --sum "Volume=usd from table:Swaps"A figure worked out per event, such as a swap priced in its own pool’s tokens, takes read, fixed, field and value clauses, separated by ;. field <name>=<expr> names a step the value then uses, so an event with no token amount can still be priced.
contract-dev user update Traders --sum "Volume=each Swap; \
read c0=poolById(bytes32).out0.key.currency0 on 0x159A…3Ef3 with id; \
fixed c0; \
value usd(abs(amount0), c0)"Split a sum
A sum from a table can end in by <field>, and one worked out per event in ; by <field>. It is kept apart by that field of its records, and a user’s page shows each part now against before. by takes one to three fields, separated by commas.
contract-dev user update Traders --sum "Volume=usd from table:Swaps by id"When the field holds a table’s row ids, by <field> in table:<name> names each part for its row and links to it: …; by pool in table:Pools.
Reads
--column "<Label>=<view>(<args>); <clauses>" reads a view with the user as an argument, user(), on each contract in its scope the user has used, and adds the values up. Its clauses are on <contract|group:<group>>, token <token>, show usd and decimals <n>.
contract-dev user update LPs \
--column "Supplied=convertToAssets(balanceOf(user())); on group:Vaults; token asset(); show usd"on one named contract, such as a pool with getUserAccountData, reads every user there.
A holding kept per thing inside a contract, such as a balance per market or token id, is read once for each thing the user’s events name:
contract-dev user update LPs --column "LP now=each Transfer.id; \
read bal=balanceOf(address,uint256) with user(), id(); \
read t=tokenOf(uint256) with id(); \
fixed t; \
value usd(bal, t)"user() is the user and id() is the thing. The event needs a --who line. A read is what the user holds now, however long ago it was built up.
Formulas
--formula "<Label>=<expr>" works out a number from the others, named by label in braces, and the built-in {Transactions}, {In}, {Out}, {First activity}, {Last activity} and {Contracts}. It can end in ; show usd for dollars or ; show pct for a value already in percent, so a change is written (a / b - 1) * 100. See Formulas for the operators and functions.
contract-dev user update LPs --formula "Net={Deposited} - {Withdrawn}; show usd"Numbers over a period
A formula can read a figure over a period, from 1h to 90d: count, sum, usual, hoursSince, daysSince, usualGap, ago and peak. See What a rule can read.
contract-dev user update Traders --formula "Volume 7d=sum(Volume, 7d)" --formula "Swaps 7d=count(Swap, 7d)" \
--show "Volume, Volume 7d, Swaps, Swaps 7d"
contract-dev user update LPs --formula "Vs 30d peak=({LP now} / peak({LP now}, 30d) - 1) * 100; show pct"A number over a period is worked out when users are read:
- The group’s page shows it and sorts by it.
- An alert’s rule names it:
--when "{Volume 7d} < 1000". --rankand--whenon the group cannot use it, anduser listcannot--sortor--totalby it.- It is a dash where the workspace’s history is too short for it.
user update <Group>
Change a group in place: add a number, or change its type, rank, rule, or the numbers it shows. Takes the flags of user create.
contract-dev user update <Group> [the flags of user create] [--remove <Label>]…--remove <Label> takes one of its numbers out of the workspace. --rank none takes its rank off. An imported list changes only through user import.
user delete <name>…
Take out a group or an imported list; a number, by its label; or an event’s --who line, by the event’s name. A group’s alerts and its Overview pins go with it.
contract-dev user delete Whalesuser import
Make a group by hand from a file of addresses in any layout, or the addresses themselves. Each becomes a user and is in the group, whether or not it has used a watched contract. Up to 20,000 addresses in one import.
contract-dev user import <file|0x…>… --as <Group> [--replace]--replace replaces the group’s addresses instead of adding to them.
user list
The users of a group, largest first by its rank, else most recently active first. user with no subcommand lists too.
contract-dev user [list] [<Group>] [--activity <state>] [--kind wallet|contract|exchange]
[--where "<expr>"] [--sort "<expr>" [--asc]] [--by <column> --measure <name>="<fn>(<expr>)"]
[--total "<column>"] [--limit <n>]| Flag | Description |
|---|---|
--activity <state> | Only users in one state: Active, Slowing, Quiet or Returned for traders and other; Holding, Added, Shrinking or Left for holders; or New or Dormant. See How a user is doing. |
--kind | Only wallets, contracts or exchanges. |
--where, --sort, --by with a measure, --total, --limit | As in query, over every user of the group. --total "{Volume}" is the whole group’s. |
<Group> can also be New, Active or Dormant, which every workspace has: first activity in the last 24 hours; last activity in the last 7 days; none for longer.
contract-dev user list LPs --activity Left
contract-dev user list Traders --total "{Volume}"user summary
Each group at once, or the one named: its users, its new ones in the last 24 hours, the number it ranks by added up, the share the ten largest hold, its largest users, and its biggest single actions of the last 7 days.
contract-dev user summary [<Group>]user show
Everything made: who a user is, the numbers, and the groups with how many users each has.
contract-dev user showWith an address, one user: its numbers by contract, what it did here, and its rank in each ranked group.
contract-dev user show <0x address> [--event <Event>] [--order recent|oldest|largest|smallest] [--page <n>]| Flag | Description |
|---|---|
--event <Event> | Lists one event of its actions, fifty per page. |
--order | recent (default) or oldest; with --event, also largest or smallest by the amount each action carried. |
--page <n> | The page of actions. |
contract-dev user show 0x1234… --event Swap --order largestuser refresh
Work the users out again now.
contract-dev user refreshuser pin
Put a group’s top rows on the workspace’s Overview, or the group as one figure. With no group, every user. user unpin takes it off.
contract-dev user pin ["<Group>"] [--rows <n>] [--sort "<column>" [--asc]] [--columns "<A>, <B>…"] [--half | --full]
contract-dev user pin "<Group>" --figure
contract-dev user unpin ["<Group>"] [--figure]See overview for every pin flag.
Alerts and reports on users
Alerts and reports on users are made with the commands every alert and report is made with.
contract-dev alert create "LPs withdrawing" --on users:LPs \
--when "{LP now} <= 0.5 * peak({LP now}, 30d)" --again-after 7d --to "#growth"
contract-dev alert update "LPs withdrawing" --top 100 --again-after none
contract-dev report create "Users weekly" --users Traders --users LPs --day monday --to "#growth"See alert, report and Alerts on users.