Open code423n4 opened 1 year ago
Rialto is going to report the correct rewards rate to the DAO from Avalanche. Not sure if its a medium
We felt comfortable with a static setting number because we are (initally) staking minipools for 2 week increments with 2000 AVAX, making the variability in rewards rates minimal.
We will develop a more complex calculation as the protocol starts handling a wider range of funds and durations
The Warden has shown an incorrect implementation of the formula to estimate rewards.
The math would cause the slash value to be incorrect, causing improper yield to be distributed, for this reason I agree with Medium Severity
GalloDaSballo marked the issue as selected for report
GalloDaSballo marked the issue as primary issue
Acknowledged. See comments above!
Lines of code
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/MinipoolManager.sol#L560 https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/MinipoolManager.sol#L676
Vulnerability details
Impact
The validation rewards can be inaccuartedly displayed to user and the slahsed amount can be wrong when slashing happens.
Proof of Concept
note the function below:
As outlined in the comment section, the function is intended to calculate how much AVAX should be earned via validation rewards
Besides display the reward, this function is also used in the function slash.
note the code:
the slashedGGPAmt is calculated based on the AVAX reward amount.
However, the estimation of the validation rewards is not accurate.
According to the doc:
https://docs.avax.network/nodes/build/set-up-an-avalanche-node-with-microsoft-azure
This implies that the staking length affect staking rewards, but this is kind of vague. What is the exact implementation of the reward calculation?
The implementation is linked below:
https://github.com/ava-labs/avalanchego/blob/master/vms/platformvm/reward/calculator.go#L40
note the reward calculation formula:
However, in the current ExpectedRewardAVA, the implementation is just:
AVAX reward rate avax amount duration / 365 days.
Clearly, the implementation of the avalanche side is more sophicated and accurate than the implemented ExpectedRewardAVA.
Tools Used
Manual Review
Recommended Mitigation Steps
We recommend the project make the ExpectedRewardAVA implementation match the implement
https://github.com/ava-labs/avalanchego/blob/master/vms/platformvm/reward/calculator.go#L40