Closed jtfirek closed 1 year ago
The circulating supply is calculated as total_issuance - total_locked - total_reserved - system_account_supply
(@nud3l please correct me if I am wrong) so we can build this mostly from orml_tokens
events:
Basically I would initialize some total_issuance
variable per currency (perhaps using this event) and track total_locked
and total_reserved
separately. The helper function could then read the balances of any system accounts (such as treasury) and then deduct those from total_issuance
to get the circulating supply.
For total_issuance, it's safe to set this to constant values for KINT and INTR each.
Agree with the orml-token event approach - we can just track the reserved (total_reserved) and frozen (total_locked) via these events and then deduct the system accounts as well.
For system accounts, it might be a bit more involved. The ones that I have in my mind are:
@gregdhill anything else we might need?
For total_issuance, it's safe to set this to constant values for KINT and INTR each.
We should use this to set some initial variable and watch for changes since right now it is possible for the total issuance to increase.
@nud3l here is a list of all primary system accounts on Kintsugi: https://github.com/interlay/interbtc/blob/b2362d4a41c10bee0786cd48b592370cb4124bfb/parachain/runtime/kintsugi/src/lib.rs#L639-L658
There are also sub-accounts we will need to track dynamically for the following pallets:
DexGeneral
DexStable
Farming
Loans
Hey @nud3l, am I on the right track for issue #94? I have created a function that will calculate the circulating supply. How would you like me to expose this function in the graphQL schema? Something like this maybe