-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Aptos Framework][Vesting] Pay out the accumulated rewards relatively to vesting's remaining grant instead of staking contract's principal #6106
Conversation
// Request commission first to make it easier to calculate what's the accumulated rewards that belong to the | ||
// vesting pool. | ||
let operator = vesting_contract.staking.operator; | ||
staking_contract::request_commission(contract_signer, contract_address, operator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this since unlock_stake already does a request_commission internally? isn't the accumulated_rewards = total_active_stake - remaining_grant - commission_amount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion, thanks! Definitely a simpler and less redundant computation. Updated.
a completely orthogonal question, after some period of vesting, isn't it possible that the remaining grant drops below the minimal staking amount? |
5d5d273
to
e6b537b
Compare
Yes this is already a known potential issue in the far future. However, by then, we'll likely have gone through a couple more iterations and add some more features such as adding stake. Another alternative direction is to move the funds to another contract built on top of delegations. |
… to vesting's remaining grant instead of staking contract's principal
let operator = vesting_contract.staking.operator; | ||
let (total_active_stake, _, commission_amount) = | ||
staking_contract::staking_contract_amounts(contract_address, operator); | ||
// Accumulated rewards, excluding unpaid commission, that entirely belongs to the shareholders. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment could be clearer about the difference between this and the accumulated rewards returned from the staking_contract_amounts call
let commission_on_staker_rewards = (with_rewards(staker_rewards) - staker_rewards) / 10; | ||
staker_rewards = with_rewards(staker_rewards) - commission_on_staker_rewards; | ||
commission = with_rewards(commission) + commission_on_staker_rewards; | ||
distribute(contract_address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the expected reward for shareholder here? could we add an assert to make sure the calculation is correct?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
Using the staking contract’s principal is indirect and the vesting contract can use it remaining grant amount as the base to get the actual amount of accumulated rewards so far. Here’s an example to make this clearer:
Test Plan
Unit tests