Skip to content

Comments

feat: mint after every action#1170

Draft
DhairyaSethi wants to merge 5 commits intodevfrom
feat/mint-fee
Draft

feat: mint after every action#1170
DhairyaSethi wants to merge 5 commits intodevfrom
feat/mint-fee

Conversation

@DhairyaSethi
Copy link
Member

@DhairyaSethi DhairyaSethi commented Feb 2, 2026

todo

  • fix update asset config dup mint fee shares
  • event likely needs unmintedFees in asset terms as well

@DhairyaSethi DhairyaSethi marked this pull request as draft February 2, 2026 18:33
uint256 deficitRay = asset.deficitRay;
uint120 drawnShares = asset.drawnShares;
uint256 liquidity = asset.liquidity;
uint256 fees = asset.realizedFees;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@aave aave deleted a comment from DhairyaSethi Feb 2, 2026
drawnIndex: drawnIndex
});
uint256 totalAdded = liquidity + swept + aggregatedOwedRay.fromRayUp() - fees;
feeShares = fees.toSharesDown(totalAdded, asset.addedShares).toUint120(); // donated share price
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

griefing of protocol fee can be done here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options:

  1. 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

  1. simpler - mint with initial share price, pre-donation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either not needed, i had thought about the scenario you're mentioning and it's acceptable imo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously we made this restricted to avoid it, so not sure if it's acceptable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ugly, i prefer to use asset and pass _spokes tbf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants