tangle-network / dapp

Monorepo for the Tangle ecosystem.
https://app.tangle.tools
Apache License 2.0
29 stars 15 forks source link

[TASK] Obtain Restaking Role Earnings Chart Data #2133

Closed AtelyPham closed 5 months ago

AtelyPham commented 6 months ago

Presently, we can utilize the api.query.roles.erasRestakeRewardPoints API to retrieve reward data (also referred to as earnings data) for each era.

To obtain the user's reward for each era, we can iterate through all eras and filter by the user's address. The pending task involves converting the era number to a timestamp.

Screenshot

image

drewstone commented 6 months ago

@AtelyPham the points are not the earnings exactly, CC @1xstj can you describe to @AtelyPham how to get the earnings from the points? Maybe there's an easier way here.

AtelyPham commented 6 months ago

We determined the staking reward of a validator using the following formula:

Validator's reward = (Era's total reward * Validator's points) / Era's total points

Therefore, we'll apply the same methodology to compute the restaking reward for a restaker.