Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Compute Circulating Supply and expose via backend #489

Closed
3 tasks done
frol opened this issue Nov 25, 2020 · 1 comment
Closed
3 tasks done

Compute Circulating Supply and expose via backend #489

frol opened this issue Nov 25, 2020 · 1 comment
Assignees

Comments

@frol
Copy link
Collaborator

frol commented Nov 25, 2020

This is only applicable to mainnet

This issue is blocked on #478

Circulating Supply = Total Supply - Tokens locked in the Lockup contracts

Implementation Notes

Here is how to compute the value:

  1. Total Supply is available though RPC block method (see header->total_supply)
  2. Tokens locked in the lockup contracts needs to be queried individually:
    2.1. Query Indexer for Explorer database for all the lockup accounts: SELECT account_id FROM accounts WHERE account_id LIKE '%.lockup.near'
    2.2. Use account-lookup code to query the still locked balance
  3. Sum up all the locked balances and subtract it from the Total Supply

NOTE: Make sure you pin a specific block height when you query the Total Supply and every individual contract state (through the account-lookup)

Compute the value every 2 hours on the backend and store the value in memory (if the computation takes too long, consider storing it in SQLite). Expose the precomputed value via WAMP get-circulating-supply method.

Acceptance Criteria

  • The value is computed correctly (compare with the projection)
  • Non-mainnet networks return undefined
  • The value is re-computed every 2 hours (note: adjust the number if necessary)
@shelegdmitriy
Copy link
Contributor

@telezhnaya is this issue still relevant?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants