Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Jul 1, 2024
1 parent 8d69d6d commit 0b0c8ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions contracts/src/libraries/LPMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ library LPMath {
_vaultSharePrice,
_initialVaultSharePrice
);

uint256 maxBondProceeds;
(maxBondProceeds, success) = YieldSpaceMath.calculateMaxBuyBondsOutSafe(
effectiveShareReserves,
Expand All @@ -219,15 +218,18 @@ library LPMath {
}

// Calculate the pool's solvency after opening the max long. This
// doesn't account for fees, which is fine since this will be more
// conservative.
// doesn't account for fees, which is fine since this check is more
// conservative without fees.
uint256 shareReserves = _shareReserves + maxSharePayment;
uint256 longExposure = calculateLongExposure(
_longExposure,
_checkpointExposure,
_checkpointExposure + maxBondProceeds.toInt256()
);

// FIXME: This comment is confusing, and I don't completely understand
// this code. What fails if I remove it?
//
// If the pool isn't solvent after opening the max long, then we
// prevent the liquidity from being added since it will cause issues
// with price discovery. We know that when: cz <= e_l + c * z_min
Expand All @@ -245,7 +247,7 @@ library LPMath {
);
if (
shareReserves.mulDown(_vaultSharePrice) <=
longExposure + 2 * minimumShareReserves.mulUp(vaultSharePrice)
longExposure + minimumShareReserves.mulUp(vaultSharePrice)
) {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion test/integrations/hyperdrive/PriceDiscovery.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ contract PriceDiscoveryTest is HyperdriveTest {
hyperdrive.checkpoint(hyperdrive.latestCheckpoint(), 0);

// Add liquidity.
console.log("solvency = %s", hyperdrive.solvency().toString(18));
addLiquidity(alice, 100e18);
}

Expand Down

0 comments on commit 0b0c8ba

Please sign in to comment.