interlay / interbtc-squid

Subquid GraphQL schema and indexer for the Interlay and Kintsugi networks
Apache License 2.0
4 stars 7 forks source link

feat: circulating supply helper function #113

Closed jtfirek closed 1 year ago

jtfirek commented 1 year ago

I was accidentally working on my master branch in the other pr for #94. So I closed it and opened this one inside with a new branch. Linking the closed pr for reference: https://github.com/interlay/interbtc-squid/pull/108

jtfirek commented 1 year ago

Creating a list of assumptions I made for went this is ready for pr review:

  1. The total issuance is changed I am directly adding the delta to the circulatingSupply. Code here: https://github.com/interlay/interbtc-squid/blob/561197505bcd7833ed9733eaa6291ead57595eee/src/mappings/event/circulating-supply.ts#L32 I am doing it based off this math but I am not sure if an increase in total supply will result in an injection into the circulatingSupply Math: total_issuance - total_locked - total_reserved - system_account_supply https://github.com/interlay/interbtc-squid/pull/108#issuecomment-1503638864
jtfirek commented 1 year ago

Hi @gregdhill and @nud3l,

Thanks for all the helpful info in this thread: #108

I understand how we're using the variables total_issuance, total_locked, total_reserved, and system_account_supply to calculate the circulating supply. This makes sense given the logic we've discussed.

However, I'm not clear on how we should calculate totalVestingTokens and totalEscrowTokens fields that @nud3l would like to see in the cumulativeSupply object. Could you clarify how we should derive these variables? Can the total_locked, total_reserved, and system_account_supply be used directly here?

Also @gregdhill I have a few questions on Token Pallet events:

Do I need to track all four of these for the total_locked, The events seems super redundant. Could I get alway with only tracking 2 of them? https://github.com/open-web3-stack/open-runtime-module-library/blob/0085382cf001704d084ac8e97b7bc3e4e8afb8a7/tokens/src/lib.rs#L333-L357

I have been having trouble trying to listen to this event. Is it possible that we didn't use this event to set the initial supply? https://github.com/open-web3-stack/open-runtime-module-library/blob/0085382cf001704d084ac8e97b7bc3e4e8afb8a7/tokens/src/lib.rs#L310-L313

gregdhill commented 1 year ago

However, I'm not clear on how we should calculate totalVestingTokens and totalEscrowTokens fields that @nud3l would like to see in the cumulativeSupply object. Could you clarify how we should derive these variables?

Take a look at the orml-vesting events to update totalVestingTokens and the escrow pallet events to update totalEscrowTokens - note that would only give the KINT/INTR amount not in vKINT/vINTR.

Do I need to track all four of these for the total_locked, The events seems super redundant. Could I get away with only tracking 2 of them?

I think you just need to use Locked and Unlocked to calculate total_locked.

I have been having trouble trying to listen to this event. Is it possible that we didn't use this event to set the initial supply?

It is possible, for the total supply we can just initialize using some constant value.

jtfirek commented 1 year ago

I think you just need to use Locked and Unlocked to calculate total_locked.

@gregdhill When I try to generate types for these events. I get an error that these events are not included in the chain metadata. So I decided to tracked the lockSet and lockRemoved instead, but the lockRemoved event does not include the amount removed.

I am currently blocked here.

bvotteler commented 1 year ago

Closing PR as it was replaced with #124