Closed freak12techno closed 8 months ago
coefficient
can be calculated by a formula: coefficient = latest.value[k] / bondedToken
Once we use this, we don't need config any more.
@liangping where to get bondedToken from?
Every validator's bonded token
@liangping you mean, from /validators endpoint response?
@liangping okay I did it the better way probably, can you check?
One concern I have for sure is that it's unclear which code style there is, as there's sometimes semicolons and sometimes no semicolons, which one is preferred?
semicolons is preferred.
@liangping if semicolon is preferred, what do you think of enforcing it (and probably other things) via eslint + required pr check?
Sure. It is needed
---Original--- From: @.> Date: Sun, Feb 4, 2024 20:52 PM To: @.>; Cc: @.**@.>; Subject: Re: [ping-pub/explorer] Add tendermint voting power coefficient (PR#541)
@freak12techno commented on this pull request.
In src/modules/[chain]/staking/index.vue:
> // const n: number = latest.value[txt]; // const o: number = yesterday.value[txt]; // // console.log( txt, n, o) // return n > 0 && o > 0 ? n - o : 0; - return changes.value[txt]; + + const latestValue = latest.value[txt]; + if (!latestValue) { + return; + } + + const displayTokens = format.tokenAmountNumber({ + amount: parseInt(entry.tokens, 10).toString(), + denom: staking.params.bond_denom, + }); + const coefficient = displayTokens / latestValue;
Likely yes, as in practice I've seen coefficient being not 1 but something like 1.000033 or so, not sure what causes it (maybe token value rounding?), but I doubt this coefficient might ever be a float instead of int.
I can fix it in a separate PR if needed, let me know if it is needed.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Question is, what to round it to. I am now testing it on Nomic, which has this coefficient as 1m, and this is the coefficient per each validator (the last value in each line):
Issue is, I can't do Math.round() as rounding 0.000001 (as for Nomic) would result in 0, and if doing it vice versa (e.g. 1000000), rounding it won't make any sense.
Also, at this point it seems more like it's a floating math issue like this one: https://0.30000000000000004.com/, does it make sense fixing it this way, given that the offset isn't really noticeable?
@liangping if semicolon is preferred, what do you think of enforcing it (and probably other things) via eslint + required pr check?
I am ok if you want to add it.
Fixes #539.
One concern I have for sure: it's highly unlikely that this is going to be used everywhere, so does it make sense putting this thing in docs in chains/README.md?