-
Notifications
You must be signed in to change notification settings - Fork 4
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 to dust issue on unforced withdrawals under special case #247
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2949,6 +2949,33 @@ describe('Vault', () => { | |
|
||
await vault.connect(admin).exitUnpause(); | ||
}); | ||
|
||
it('leaves no dust on withdraw when force is false', async () => { | ||
const toDeposit = parseUnits('100'); | ||
const prevBal = await underlying.balanceOf(alice.address); | ||
|
||
const params = depositParams.build({ | ||
amount: toDeposit, | ||
inputToken: underlying.address, | ||
claims: [ | ||
claimParams.percent(50).to(alice.address).build(), | ||
claimParams.percent(50).to(bob.address).build(), | ||
], | ||
}); | ||
|
||
await vault.connect(alice).deposit(params); | ||
|
||
await moveForwardTwoWeeks(); | ||
await addYieldToVault('100'); | ||
|
||
await vault | ||
.connect(alice) | ||
.partialWithdraw(alice.address, [2], [parseUnits('1')]); | ||
|
||
const newBal = await underlying.balanceOf(alice.address); | ||
|
||
expect(prevBal.sub(newBal)).to.eq(toDeposit.sub(parseUnits('1'))); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this test failing without your changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test because of the subtraction of 1 done in line 2977 to take the dust into account. Similarly many other tests also had a +1 or -1 in the end to account for the dust. This fix, fixes that issue so now we dont have to account for dust in the tests thus also making the tests more readable and simpler. I have made the changes to the tests and they are passing now. |
||
}); | ||
|
||
describe('claimYield', () => { | ||
|
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.
Just curious to why was there a test for "pps can be manipulated"?
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.
It's a test from the 2nd audit we did. The test proved (at the time) that it could be manipulated. We just kept it as it was