-
Notifications
You must be signed in to change notification settings - Fork 0
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
All your rebase are belong to me (convert to non-rebasing token) #81
Conversation
0ed7d8d
to
0da1c6f
Compare
cae65d2
to
a261450
Compare
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.
Some comments, nothing blocking.
lido.claimRewards(); | ||
|
||
// assert new exchange rate | ||
assertEq(lido.exchangeRateAVAXToStAVAX(), 982318271119842829); |
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.
Might be worth pulling these out into constants to make it clear, e.g.
assertEq(lido.exchangeRateAVAXToStAVAX(), 982318271119842829); | |
uint256 EXCHANGE_RATE = 982318271119842829; // 10e18 / 1.018 | |
assertEq(lido.exchangeRateAVAXToStAVAX(), EXCHANGE_RATE); |
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.
Are we testing unstaking or are we testing the exchange rate? I think the exchange rate calculations should be tested separately and here it's enough to assert that it's not 1 (if at all).
|
||
// NB: this test fails because the numbers chosen can never match up no matter the precision. | ||
// Known issue of Solidity, floating point numbers & division. This round down behaviour is expected. | ||
// function testCannotClaimMoreAVAXThanDepositedBeforeRewards() public { |
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.
We could assert that the the amount you claim is <=
the the amount deposited?
Or we could assert that it's within the range of our known rounding margin. Something like:
assert( abs (old - new - margin) == 0)
?
) = lido.unstakeRequests(requestId); | ||
|
||
assertEq(requester, USER1_ADDRESS); | ||
assertEq(requestAt, uint64(block.timestamp)); | ||
assertEq(amountRequested, 5 ether); | ||
assertEq(amountFilled, 0 ether); | ||
assertEq(amountClaimed, 0 ether); | ||
assertEq(stAVAXLocked, 5 ether); | ||
|
||
// Second withdrawal. |
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.
Not sure what the second withdrawal is really testing here? Could simplify by having 1 test which tests multiple withdrawals and remove these second withdrawals from these tests?
Feels like we're testing too much in each test.
lido.claimRewards(); | ||
|
||
// assert new exchange rate | ||
assertEq(lido.exchangeRateAVAXToStAVAX(), 982318271119842829); |
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.
Are we testing unstaking or are we testing the exchange rate? I think the exchange rate calculations should be tested separately and here it's enough to assert that it's not 1 (if at all).
cheats.deal(rTreasuryAddress, 0.2 ether); | ||
lido.claimRewards(); |
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.
Could make your life a bit simpler by using an unrealistic amount of rewards such that the value is 1:2. That makes the assertions clearer imo - I'm not sure if 5.09
is the right amount at a glance, but if it's 1:2 I can easily tell 5 -> 10
is correct
assertEq(amountClaimed, 0 ether); | ||
assertEq(stAVAXLocked, 5 ether); | ||
|
||
// Second withdrawal. |
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.
Same here, not sure what this is testing
assertEq(amountRequested3, 0.1 ether); | ||
assertEq(amountFilled3, 0.1 ether); | ||
} | ||
|
||
function testMultipleFillUnstakeRequestsSingleFillAfterRewards() public { |
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.
Not sure what this is really testing
assertEq(lido.protocolControlledAVAX(), 10.09 ether); | ||
assertEq(lido.exchangeRateAVAXToStAVAX(), 991080277502477700); | ||
assertEq(lido.exchangeRateStAVAXToAVAX(), 1.009 ether); |
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.
Again don't think we need to assert this
assertEq(lido.exchangeRateAVAXToStAVAX(), 991080277502477700); | ||
assertEq(lido.exchangeRateStAVAXToAVAX(), 1.009 ether); | ||
|
||
// So we withdraw 1 AVAX and lock 0.99108... stAVAX |
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.
same issue
cheats.deal(rTreasuryAddress, 0.1 ether); | ||
lido.claimRewards(); | ||
|
||
assertEq(lido.protocolControlledAVAX(), 10.09 ether); | ||
assertEq(lido.exchangeRateAVAXToStAVAX(), 991080277502477700); | ||
assertEq(lido.exchangeRateStAVAXToAVAX(), 1.009 ether); | ||
|
||
// So we withdraw 1 AVAX and lock 0.99108... stAVAX | ||
cheats.prank(USER1_ADDRESS); | ||
lido.requestWithdrawal(1 ether); |
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.
same
assertEq(lido.protocolControlledAVAX(), 10.09 ether); | ||
assertEq(lido.exchangeRateAVAXToStAVAX(), 991080277502477700); | ||
assertEq(lido.exchangeRateStAVAXToAVAX(), 1.009 ether); |
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.
Rather than concerning the test with the values, you could do oldRate = lido.exchangeRate...
and then later assert that the currentRate == oldRate
.
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.
Ps that would also make it viable to do a fuzz test where the rewards param is fuzzed
Relates #75
Rebasing is dead, long live rebasing
TODO:
and claim-relatedevents to have both AVAX and stAVAX amountsgetExchangeRate
function