Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emerald: track tokens #213

Merged
merged 3 commits into from
Nov 23, 2022
Merged

Emerald: track tokens #213

merged 3 commits into from
Nov 23, 2022

Conversation

pro-wh
Copy link
Collaborator

@pro-wh pro-wh commented Nov 12, 2022

we already have the plumbing to run something on each erc20 Transfer event. this gathers them into a token_balances table.

details:

  • transfers from the zero ethereum address count as mints
  • transfers to the zero ethereum address count as burns
  • addresses in the table are oasis addresses. look up ethereum addresses as needed in the address preimages table

other notes:

  • this doesn't count holders. I'll ask about how to implement this
  • there's no enforcement about starting from genesis-----you can start whenever, and you may have negative "balance" where it only shows the total of all in-minus-out during the time scanned
  • no nothin done about contracts using erc20-compatible Transfer events in any wrong way

Ideas for this:

  1. observe all token transfer events
  2. maintain our own accounting of all-tokens-all-accounts balances
  3. thusly serve list of token balances for account details
  4. delete token,account records when balance hits zero
  5. maintain our own accounting of how many nonzero-balance accounts there are for each token
  6. thusly serve holders count for token details

@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from a98bcb2 to ef244c9 Compare November 15, 2022 00:40
@pro-wh pro-wh marked this pull request as ready for review November 15, 2022 00:46
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

analyzer/emerald/incoming.go Show resolved Hide resolved
analyzer/emerald/incoming.go Outdated Show resolved Hide resolved
storage/migrations/02_oasis_3_emerald.up.sql Outdated Show resolved Hide resolved
analyzer/emerald/incoming.go Show resolved Hide resolved
@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from ef244c9 to 1567ef6 Compare November 15, 2022 20:37
@pro-wh
Copy link
Collaborator Author

pro-wh commented Nov 15, 2022

oh shoot I used "contract address" in the struct but "token address" in the db

@pro-wh
Copy link
Collaborator Author

pro-wh commented Nov 15, 2022

changed struct to call it 'token address'

@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from 1567ef6 to 70c012a Compare November 15, 2022 23:26
@pro-wh pro-wh force-pushed the pro-wh/feature/emeraldapi2 branch from d231428 to cf636d4 Compare November 17, 2022 23:12
@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch 2 times, most recently from 99ed601 to c0d8887 Compare November 21, 2022 22:19
@pro-wh pro-wh force-pushed the pro-wh/feature/emeraldapi2 branch 2 times, most recently from 5cb2f99 to 810bf07 Compare November 22, 2022 19:36
@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from c0d8887 to 548d7ab Compare November 22, 2022 19:36
@pro-wh pro-wh force-pushed the pro-wh/feature/emeraldapi2 branch from e9e94e3 to 03d7232 Compare November 22, 2022 23:49
Base automatically changed from pro-wh/feature/emeraldapi2 to main November 22, 2022 23:55
@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from 548d7ab to 17063b4 Compare November 22, 2022 23:56
@pro-wh pro-wh force-pushed the pro-wh/feature/holders branch from 35e4a23 to c4f4afa Compare November 23, 2022 00:05
@pro-wh pro-wh merged commit 4269f98 into main Nov 23, 2022
@pro-wh pro-wh deleted the pro-wh/feature/holders branch November 23, 2022 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants