Open hats-bug-reporter[bot] opened 6 months ago
The original shares accrue some fees and staking rewards, I think this is the correct behavior
@coreggon11 But the second user just stake to the protocol and he shouldn't subject to the fees and staking rewards right
Thank you for your submission. It is working as intended. Virtual shares are just like normal shares and must be considered. In other DAPPs, they are minted in the update function, but I think here, for gas purposes, they are minted in the withdraw-fee function.
the values of shares is important, see the process, if i miss something let me know: the value of each share decreases in each update fee.
user A 100 share :user A Owns 100 azero
owner get 1 share :user A Owns 99 azero (give some fee)
user B 100*101/100 = 101 share :user A owns 99 azero, user B ownes 100 azero(doesn't give fee yet)
owner get 2 shares :user A owns 98 azero (give some fee again), user B ownes 99 azero(give some fee)
Remember, earlier users pay higher fees but receive greater rewards. (staking APY is more than fee APY)
so the share values is inflationary? Not sure if staking APY is less than fee APY scenario is possible because if many users stake into the protocol and resulting in earlier stakers losing money as the share they are holding is less valuable than the time when they first staked.
so the share values is inflationary? Not sure if staking APY is less than fee APY scenario is possible because if many users stake into the protocol and resulting in earlier stakers losing money as the share they are holding is less valuable than the time when they first staked.
The fee is about 2 percent for a whole year, and the APY is more than that, besides that, there is a compounding mechanism that increases revenue even more.
So early stakers will earn more than later stakers.
Github username: @erictee2802 Twitter username: 0xEricTee Submission hash (on-chain): 0x864b14e70109f0c9c64fb2a5cdf323b42326abfff70720934ba4b19e491d7f0d Severity: high
Description: Description\
When staking with
Vault/lib.rs:stake()
function, the following function will calculate how much shares to mint to stakers:Vault/lib.rs:get_shares_from_azero
:Vault/lib.rs:get_total_shares()
:Users who stakes at a later stages will receive more shares than users who stake earlier. As a result, this is an unfair distribution of shares issue that cause users to lose rewards.
Attack Scenario\
Unfair shares distribution causes early stakers to lose rewards.
Attachments
NA
Add the following ink! test to
drink_tests/lib.rs
:Result:
The virtual shares which will increase overtime will cause late stakers to receive more shares.