Conversation
| uint256 deficitRay = asset.deficitRay; | ||
| uint120 drawnShares = asset.drawnShares; | ||
| uint256 liquidity = asset.liquidity; | ||
| uint256 fees = asset.realizedFees; |
There was a problem hiding this comment.
asset.realizedFees can be packed smaller given it can never be greater than 1 share worth of assets; also it can be removed from storage and unrealisedFees can be maintained in mem/tstore/stack like in https://github.com/aave/aave-v4/pull/927/changes where we are ok loosing rounded fee shares (and be susceptible to treasury grief)
| drawnIndex: drawnIndex | ||
| }); | ||
| uint256 totalAdded = liquidity + swept + aggregatedOwedRay.fromRayUp() - fees; | ||
| feeShares = fees.toSharesDown(totalAdded, asset.addedShares).toUint120(); // donated share price |
There was a problem hiding this comment.
griefing of protocol fee can be done here
There was a problem hiding this comment.
yes ofcourse, that's always there. the point is it's not possible to grief 100% bc of > 0 but rather 50% (or 33% i think) of possible fees like it is on dev rn
There was a problem hiding this comment.
options:
- maintain current approach of using post-action share price, but mint as perfect of shares as possible, and leave behind remainder in realizedFees, NOT zero-ing it out.
ex:
uint256 exactFeeAmount = feeShares.toAssetsDown(totalAdded, asset.addedShares + feeShares);
...
L161: asset.realizedFees = fees - exactFeeAmount;
at least this reduces the donation from being up to <1 share worth of assets to at most 1 wei assets, so adds safety. Now griefing is not profitable
- simpler - mint with initial share price, pre-donation
There was a problem hiding this comment.
either not needed, i had thought about the scenario you're mentioning and it's acceptable imo
There was a problem hiding this comment.
previously we made this restricted to avoid it, so not sure if it's acceptable
There was a problem hiding this comment.
given that we are keeping realizedFees in the storage anyway, i d consider the 1st option of minting "perfect" shares and save the excess
src/hub/Hub.sol
Outdated
| } | ||
|
|
||
| asset.updateDrawnRate(assetId); | ||
| _spokes.updateDrawnRateAndMintFeeShares(asset, assetId); |
There was a problem hiding this comment.
this is ugly, i prefer to use asset and pass _spokes tbf
todo