-
Notifications
You must be signed in to change notification settings - Fork 320
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
feat: locked profit on deposit #273
Conversation
contracts/Vault.vy
Outdated
shares = precisionFactor * amount * totalSupply / self._totalAssets() / precisionFactor | ||
|
||
freeFunds: uint256 = self._totalAssets() - self._calculateLockedProfit() | ||
shares = precisionFactor * amount * totalSupply / freeFunds / precisionFactor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What testing do we have to make sure this change doesn't introduce a vulnerability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we modify the deposit and withdraw test in brownie for the same block to assert we got the exact amount of want tokens on both operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tought in tests every blockchain call mines a block, I haven't seen an option to batch transactions.
Will look for how that's done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shut off auto-mining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, can we add or edit a test to check that deposit and withdraw in same block cannot make more want than possible?
Disregard failing CI job, was testing something |
Change looks good, needs further testing to merge |
I am missing something I couldn't find how to include multiple transactions within the same block.
|
Suggestion from audit: losses should take away from locked profits |
rebase on |
c8d1f36
to
fdf4bd8
Compare
Rebased added losses on lockedProfit and force pushed |
Found a workaround to mine two transactions within the same block using
found the solution UMAprotocol/protocol#1151 |
7ac332e
to
d162d65
Compare
d162d65
to
041e731
Compare
Co-authored-by: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com>
041e731
to
e8a18ea
Compare
Merged 🎉🎉🎉 |
* feat: locked profit on deposit * fix: refactor unused code * fix: audit changes * refactor: use cached value * fix: rebase mistakes * feat: remove loss from lockedProfit * test: deposit and withdrawal within same block * docs: error if division fail Co-authored-by: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com> * docs: ganache minning workaround Co-authored-by: Sam Priestley <sfpriestley@hotmail.co.uk> Co-authored-by: Just some guy <3859395+fubuloubu@users.noreply.github.com> Co-authored-by: steffel <2143646+steffenix@users.noreply.github.com>
* feat: locked profit on deposit * fix: refactor unused code * fix: audit changes * refactor: use cached value * fix: rebase mistakes * feat: remove loss from lockedProfit * test: deposit and withdrawal within same block * docs: error if division fail Co-authored-by: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com> * docs: ganache minning workaround Co-authored-by: Sam Priestley <sfpriestley@hotmail.co.uk> Co-authored-by: Just some guy <3859395+fubuloubu@users.noreply.github.com> Co-authored-by: steffel <2143646+steffenix@users.noreply.github.com>
1 - Make sure that we deposit and withdraw at same share price
2 - Add onreleased profit to next lockedprofit