Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions contracts/src/internal/HyperdriveShort.sol
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,20 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP {
// accounting updates.
shareReservesDelta -= totalGovernanceFee;

// Ensure that the ending spot price is less than 1.
if (
HyperdriveMath.calculateSpotPrice(
_effectiveShareReserves() + shareCurveDelta,
_marketState.bondReserves - bondReservesDelta,
_initialVaultSharePrice,
_timeStretch
) > ONE
) {
Errors.throwInsufficientLiquidityError(
IHyperdrive.InsufficientLiquidityReason.NegativeInterest
);
}

// Adjust the computed proceeds and delta for negative interest.
// We also compute the share adjustment delta at this step to ensure
// that we don't break our AMM invariant when we account for negative
Expand All @@ -649,19 +663,5 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP {
false
);
}

// Ensure that the ending spot price is less than 1.
if (
HyperdriveMath.calculateSpotPrice(
_effectiveShareReserves() + shareCurveDelta,
_marketState.bondReserves - bondReservesDelta,
_initialVaultSharePrice,
_timeStretch
) > ONE
) {
Errors.throwInsufficientLiquidityError(
IHyperdrive.InsufficientLiquidityReason.NegativeInterest
);
}
}
}