You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The dashboard calculates how many rewards are going to be received when a staker pushes the "Claim" button.
Currently, this calculation is made by checking the last updated Merkle Distribution file (rewards.json) and subtracting the number of rewards that have been claimed already.
To get the rewards already claimed, the dashboard checks the claimed events emitted by the contract to the Ethereum network.
But checking these past events is not a reliable way to check this, since:
It is quite inefficient and it is getting more inefficient over time: as new blocks are generated in the blockchain, the earlier events are left behind.
Some providers can restrict the oldest events: maybe the provider returns only the events that happened in the last x Ethereum blocks.
The fix
Instead of querying for events, the claimed rewards of a stake can be queried directly to CumulativeClaimed in the Merkle distribution contract:
Rewards are cumulative, so anything that has already been claimed needs
to be subtracted to get the current available amount. This commit gets
the claimed amount by calling `cumulativeClaimed` on the merkle
contract. This is more reliable than scanning for claimed events.
Fixes#765
The issue
The dashboard calculates how many rewards are going to be received when a staker pushes the "Claim" button.
Currently, this calculation is made by checking the last updated Merkle Distribution file (rewards.json) and subtracting the number of rewards that have been claimed already.
To get the rewards already claimed, the dashboard checks the
claimed
events emitted by the contract to the Ethereum network.token-dashboard/src/hooks/useFetchStakingRewards.ts
Line 38 in fccb16f
But checking these past events is not a reliable way to check this, since:
The fix
Instead of querying for events, the claimed rewards of a stake can be queried directly to
CumulativeClaimed
in the Merkle distribution contract:https://github.com/threshold-network/merkle-distribution/blob/252dabcbf6a252104218512ffd62d5e2272cb777/contracts/CumulativeMerkleDrop.sol#L20
The text was updated successfully, but these errors were encountered: