Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement commission: every time we withdraw from the global pool, we directly transfer the commission to the operator. The remaining goes into the vault's staking pool. That also means that there's no technical reason to place restrictions on when the commission can be modified, although there could be other reasons to add such restrictions in the future.
One drawback of this approach, though, is that it is less clear for the operator to see how much they have earned.
I also added a randomized test to test the reward distribution, which compares the actual rewards with one calculated by a very simple (and therefore less error-prone) brute-force implementation. I am aware that fee distribution is going to change in the future but the test should be easy enough to update when that happens.
Also note the fix in the vault-registry that prevents incorrect reward distribution after vault collateral changes.
A final thing to note is that the commission is stored and set in the fee pallet rather than the nomination pallet. There is an argument to be made to place it in the nomination pallet, but that'd slightly complicate the implementation (we'd require a config item trait that allows the fee pallet to make calls to the nomination pallet. But in the end the commission is directly related to the fees so it's not a terrible spot for it either.