Skip to content
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

MASP Rewards Distribution Algorithm Mints (Slightly) Too Much NAM #4372

Open
murisi opened this issue Feb 12, 2025 · 0 comments
Open

MASP Rewards Distribution Algorithm Mints (Slightly) Too Much NAM #4372

murisi opened this issue Feb 12, 2025 · 0 comments
Labels

Comments

@murisi
Copy link
Collaborator

murisi commented Feb 12, 2025

The current MASP rewards distribution algorithm mints NAM in order to be able to service claims for shielded rewards. The problem is that it mints too much NAM for a few reasons including users choosing to unshield without claiming their rewards and the token being distributed across shielded accounts in such a way that the majority of token owners never meet the conversion threshold.

The specific case this issue is concerned with is overminting due to rounding errors occurring in the execution of the rewards distribution algorithm. This overminting can be observed at

assert!(captured.contains("nam: 0.003216"));
where the MASP address' NAM balance is slightly more than zero even though all assets have been unshielded. This amount though it is probably unclaimable still counts as "locked" and will impact future inflation/rewards computations.

The cause of this problem is that for non-native tokens NAM is currently minted based on the inflated reward instead of the deflated reward. (See:

.u128_eucl_div_rem((reward, precision))
). This is problematic because the AllowedConversions that are actually put into the conversion Merkle tree use the deflated reward. A potential solution to this is to first compute the total deflated reward in NAM[0] and then inflate that amount to the current epoch using a NAM conversion. This approach is attempted in #4369 .

But even #4369 (which mints NAM based on deflated rewards) still overmints NAM. See:

assert!(captured.contains("nam: 0.000012"));
. The reason is that in order to have sufficient NAM for the case where users first combine their pre-existing NAM[0] with NAM[0] rewards from their non-native tokens before converting to the current epoch, this algorithm avoids rounding down amounts to the nearest conversion threshold too early.

The PR #4285 manages to avoid overminting of NAM, but this comes at the cost of removing compounding rewards. See:

assert!(captured.contains("nam: 0"));
. In this PR overminting does not happen because (1) rewards for non-native tokens are no longer deflated into NAM[0] terms meaning that the same value that's put into the conversion tree also determines minting and (2) rounding down to the nearest conversion threshold happens early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant