GEN-1630: increase test coverage#12
Conversation
6990830 to
4e5a87b
Compare
Codecov Report
@@ Coverage Diff @@
## main #12 +/- ##
===========================================
+ Coverage 69.87% 82.79% +12.91%
===========================================
Files 9 8 -1
Lines 405 372 -33
Branches 66 66
===========================================
+ Hits 283 308 +25
+ Misses 98 44 -54
+ Partials 24 20 -4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
0aa5c0b to
6ced5fd
Compare
6ced5fd to
a31f1d4
Compare
jparklev
left a comment
There was a problem hiding this comment.
Coverage is awesome – will check back in again tomorrow in case there's any new discussion 👍
|
|
||
| * `RollerPeriphery` - the slippage protected LP management interface to all AutoRollers. | ||
| * `OwnableAdapter` - Sense adapter owned by a unique auto-roller. Through the auto-roller, series rollers can sponsor new series via `AutoRoller.roll` and settle series via `AutoRoller.settle`. | ||
| * `OwnableAdapter` - Sense adapter owned by a unique auto-roller. Through the auto-roller, series rollers can sponsor new series via `AutoRoller.roll` and settle series via `AutoRoller.settle`. This adapter must **override** `getMaturityBounds` so only the roller can sponsor preventing a potential DoS attack. |
There was a problem hiding this comment.
| * `OwnableAdapter` - Sense adapter owned by a unique auto-roller. Through the auto-roller, series rollers can sponsor new series via `AutoRoller.roll` and settle series via `AutoRoller.settle`. This adapter must **override** `getMaturityBounds` so only the roller can sponsor preventing a potential DoS attack. | |
| * `OwnableAdapter` - Sense adapter owned by a unique auto-roller. Through the auto-roller, series rollers can sponsor new series via `AutoRoller.roll` and settle series via `AutoRoller.settle`. This adapter must **override** `getMaturityBounds` so only the roller can sponsor, preventing a potential DoS attack. | |
| balances[1 - _pti] = targetToJoin; | ||
|
|
||
| if (assets - targetToJoin > 0) { // Assumption: this is false if Space has only Target liquidity. | ||
| if (assets - targetToJoin > 0) { // Assumption: this is false if Space has only Target liquidity. TODO: can this ever happen? |
There was a problem hiding this comment.
Perhaps not if we don't allow the pool to be initialized at 0%!
There was a problem hiding this comment.
But is this something we should keep just in case?
There was a problem hiding this comment.
I think so, not much harm in being safe here besides bloat, but i'll think about it as I continue audit resolutions
| vm.stopPrank(); | ||
|
|
||
| (, bytes32[] memory writes) = vm.accesses(address(autoRoller)); | ||
| // Check that no storage slots were written to |
There was a problem hiding this comment.
| // Check that no storage slots were written to | |
| // Check that the expected number of storage slots were written to |
|
|
||
| function testAfterDepositWithOnlyTargetLiquidity() public { | ||
| // The idea is making a test that covers line case on the `afterDeposit` function | ||
| // where `if (assets - targetToJoin > 0)` is false. |
There was a problem hiding this comment.
This is true, because even if we have someone try to buy all of the PTs out of the pool, I don't think it's possible to get it down to true 0 after initialization
There was a problem hiding this comment.
perfect, I'll remove all this
| autoRoller.deposit(0.2e18, address(this)); | ||
| assertEq(autoRoller.balanceOf(address(this)), 0.2e18); | ||
|
|
||
| // 3. Roll the Target into the first Series. |
There was a problem hiding this comment.
| // 3. Roll the Target into the first Series. | |
| // 2. Roll the Target into the first Series. |
|
|
||
| // 5. Redeem all shares while still in the active phase. | ||
| uint256 targetBalPre = target.balanceOf(address(this)); | ||
| vm.expectCall(address(periphery), abi.encodeWithSelector(periphery.swapYTsForTarget.selector)); |
| vm.expectCall(address(periphery), abi.encodeWithSelector(periphery.swapYTsForTarget.selector)); | ||
| autoRoller.redeem(autoRoller.balanceOf(address(this)), address(this), address(this)); | ||
| uint256 targetBalPost = target.balanceOf(address(this)); | ||
| // assertRelApproxEq(targetBalPost - targetBalPre, 0.5e18, 0.0001e18 /* 0.01% */); // TODO: what should it be the expected value? |
There was a problem hiding this comment.
I think we should expect it to be pretty close to "total deposited amount - firstDeposit" (since firstDeposit is kept locked in the contract forever, similar to the min bpt for our space pool). What were you seeing here for this val?
There was a problem hiding this comment.
hmm yeah, i was seeing something similar (I forgot to consider the firstDeposit) but now, considering the firstDeposit:
- I have deposited in total
0.5e18and I'm asserting that0.5e18 - 0.01e18(total deposited -firstDeposit) should almost equal to the target I received back which is499642339889372330, shouldn't that be lower? Or how do I establish which is a good delta in this case?
There was a problem hiding this comment.
Ahh yea, after you roll the math starts to get a little more complicated I think. You can always do a previewRedeem here to see what it should be out, or you can walk through the trace to see what it's doing. I might do the latter today or tomorrow just out of curiosity
|
|
||
| vm.warp(autoRoller.maturity()); | ||
|
|
||
| // 4. Increase scale and settle the first Series. |
There was a problem hiding this comment.
Did we want to manually increase scale somewhere here?
There was a problem hiding this comment.
no no, it's not needed
|
|
||
| // 6. Assert max redeem is same as TODO. | ||
| sharesOut = autoRoller.maxRedeem(address(this)); | ||
| // assertEq(sharesOut, TODO); |
There was a problem hiding this comment.
think we could do assertEq(autoRoller.maxRedeem(address(this)), sharesOut); again here perhaps?
There was a problem hiding this comment.
oh, it works :), i would have sworn i tried that and was not working 🤔 and that;s why i was confused
| kind: BalancerVault.SwapKind.GIVEN_IN, | ||
| assetIn: address(pt), | ||
| assetOut: address(autoRoller.asset()), | ||
| amount: 0.01e18, // TODO: how do I calculate a number such that it would make the maxPTSale >= diff? This number works though |
There was a problem hiding this comment.
So, the only case where this isn't true IIRC is if order we'd have to swap here such that the pool becomes very close to the maxRate value (time shifted) so that the user can't safely make the PT in swap needed to withdraw their position without exceeding the max rate
Note that you can check the rate "(pt reserves + total supply / (target reserve * scale))"
1313180 to
aa29a35
Compare
getMaturityBounds