Skip to content

Commit

Permalink
Fixed intermittent test failuires (#532)
Browse files Browse the repository at this point in the history
* fixed intermittent test failuires

* remove console
  • Loading branch information
ControlCplusControlV authored Jul 26, 2023
1 parent 76fc785 commit 2324420
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/src/HyperdriveLong.sol
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ abstract contract HyperdriveLong is HyperdriveLP {
// reserves and the bond reserves decreased, we must ensure that the
// base reserves are greater than the longsOutstanding.
if (
_sharePrice.mulDown(_marketState.shareReserves) <
_marketState.shareReserves <
uint256(longsOutstanding_).divDown(_sharePrice) +
_minimumShareReserves
) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/HyperdriveShort.sol
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ abstract contract HyperdriveShort is HyperdriveLP {
// Since the share reserves are reduced, we need to verify that the base
// reserves are greater than or equal to the amount of longs outstanding.
if (
_sharePrice.mulDown(shareReserves_) <
shareReserves_ <
uint256(_marketState.longsOutstanding).divDown(_sharePrice) +
_minimumShareReserves
) {
Expand Down
12 changes: 7 additions & 5 deletions test/integrations/ERC4626Validation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -440,18 +440,20 @@ abstract contract ERC4626ValidationTest is HyperdriveTest {
vm.startPrank(alice);
shortAmount = shortAmount.normalizeToRange(
0.00001e18,
Lib.min(
HyperdriveUtils.calculateMaxShort(hyperdrive),
underlyingToken.balanceOf(alice)
)
Lib
.min(
HyperdriveUtils.calculateMaxShort(hyperdrive),
underlyingToken.balanceOf(alice)
)
.mulDown(0.95e18)
);

// Deposit into the actual ERC4626
underlyingToken.approve(address(token), type(uint256).max);
token.deposit(shortAmount, alice);

// Open the short
(uint256 maturityTime, ) = openShortERC4626(alice, shortAmount, true);
(uint256 maturityTime, ) = openShortERC4626(alice, shortAmount, false);

// The term passes and interest accrues.
variableRate = variableRate.normalizeToRange(0, 2.5e18);
Expand Down

0 comments on commit 2324420

Please sign in to comment.