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

Address returnsGenerated being incorrect & add tests #119

Merged
merged 12 commits into from
Nov 29, 2021

Conversation

bsamuels453
Copy link

@bsamuels453 bsamuels453 commented Nov 29, 2021

This PR fixes the issue reported here, and validates the fix using the new test suite. I can split the fix and tests into multiple PRs if needed.

The commit for the fix can be viewed here
This fix works by adding a balanceTokens field to VaultUpdate. This field reports on the balance of tokens managed by the Vault at the time of the update and is populated by vault.totalAssets();

The returnsGenerated field of VaultUpdate is now populated by comparing the balanceTokens of the previous update to the new balanceTokens. When taking token deposits and withdrawls into account, the difference between the balanceTokens of each update is a reliable proxy for recognized profit the vault has earned.

In addition, the logic for setting vault.latestUpdate, vault.balanceTokens, and vault.balanceTokensIdle has been moved to the createVaultUpdate function (previously this logic was duplicated in two separate spots).

@rareweasel rareweasel self-requested a review November 29, 2021 15:35
Copy link

@rareweasel rareweasel left a comment

Choose a reason for hiding this comment

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

@bsamuels453 Great job!!! Ben! Thank you very much for your contribution. I left some comments/questions.

@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:fix && git add -A

Choose a reason for hiding this comment

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

Why did we remove it?

Copy link
Author

Choose a reason for hiding this comment

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

yarn lint:fix is still there; I removed git add -A because it kept including files in each commit that I did not want to commit yet. I kept running into issues where I would stage 1 or 2 files for commit, git commit them, then the commit includes every change that was in my working directory.

Copy link

@rareweasel rareweasel left a comment

Choose a reason for hiding this comment

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

Great job @bsamuels453 !!! Thanks for your contribution.

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.

2 participants