feat: mint fee shares with pre-donation share price, perfect shares#1173
Closed
feat: mint fee shares with pre-donation share price, perfect shares#1173
Conversation
yan-man
commented
Feb 3, 2026
| asset.realizedFees += asset.getUnrealizedFees(drawnIndex).toUint120(); | ||
| uint256 feeAmountRay = asset.realizedFeesRay + asset.getUnrealizedFees(drawnIndex).toRay(); | ||
| uint256 feeShares = asset.toAddedSharesDown(feeAmountRay.fromRayDown()); | ||
| uint256 perfectFeeAmountRay = feeShares == 0 ? 0 : asset.toAddedAssetsUp(feeShares.toRay()); |
Contributor
Author
There was a problem hiding this comment.
note: feeShares.toRay() first before converting to assets. Ex. if share price is 1.33333...., and feeShares is 1, then this will yield 1.33333 RAY. If we did toRay() after the conversion instead, it would only give us 2 RAY
also, round up so that the remaining realizedFeesRay is minimized
aave-v4/src/hub/libraries/AssetLogic.sol
Line 183 in c7fbdfc
yan-man
commented
Feb 3, 2026
| FEE_SHARES_SLOT.tstore(0); | ||
| emit IHub.MintFeeShares(assetId, feeReceiver, feeShares, perfectFeeAmountRay.fromRayDown()); | ||
| } | ||
| asset.realizedFeesRay = (feeAmountRay - perfectFeeAmountRay).toUint200(); |
Contributor
Author
There was a problem hiding this comment.
note: whatever remainder exists beyond the perfect shares, cache for the next accrual
maybe needs to be capped bc perfectFeeAmountRay was rounded up, feeAmountRay <= perfectFeeAmountRay ? 0: feeAmountRay - perfectFeeAmountRay
Contributor
Author
|
see #1178 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.