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

Fix deposit fee #38

Merged
merged 6 commits into from
Sep 12, 2023
Merged

Fix deposit fee #38

merged 6 commits into from
Sep 12, 2023

Conversation

Rubilmax
Copy link
Contributor

All tests break because they are incomplete: in order for the fee recipient to accrue fee, the vault must realize a performance (it should actually not accrue fee from deposits/withdrawals)

@Rubilmax Rubilmax force-pushed the fix/deposit-fee branch 3 times, most recently from 3ae1742 to 09bf26a Compare September 12, 2023 09:38
@Rubilmax Rubilmax marked this pull request as ready for review September 12, 2023 09:38
@Rubilmax Rubilmax linked an issue Sep 12, 2023 that may be closed by this pull request
@Rubilmax Rubilmax mentioned this pull request Sep 12, 2023
contracts/SupplyVault.sol Outdated Show resolved Hide resolved
modifier syncLastTotalAssets() {
_;

lastTotalAssets = totalAssets();
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we trigger 2 times totalAssets for each tx. It will cost a lot...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, it is the only viable solution. Using a timestamp-based solution creates a bug: if 2 users deposit within the same block, lastTotalAssets is not updated with the last user's deposit, which gets counted as interest in the next fee accrual...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just pushed an alternative version that saves 2 calls to totalAssets. This should be a huge gas cost improvement

@MerlinEgalite MerlinEgalite merged commit 46bea01 into test/fees Sep 12, 2023
14 checks passed
@Rubilmax Rubilmax deleted the fix/deposit-fee branch September 12, 2023 14:34
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.

Instant revenue for the fee recipient
2 participants