Skip to content

Commit d3f602a

Browse files
authored
Spearbit #89: Addressed review feedback from @Saw-mon-and-Natalie (#827)
* Use safe functions more consistently in `calculateNetCurveTradeSafe` * Fail if `calculateSharesOutGivenBondsInDownSafe` underflows * Fixed the rust tests * Improved the system's liveness when the present value can't be computed * Improved the liveness properties of `removeLiquidity` * Ignore `calculateLPSharePrice` failures in `removeLiquidity` * Ensure that the ending indexes are valid in `HyperdriveFactory` getters * Used unchecked arithmetic in several places * Made the `LPMath` safer and used unchecked arithmetic * Use unchecked arithmetic in the rest of the contracts * Consolidated the derivative functions in the `LPMath` library * Addressed review feedback from @jrhea * Simplified the main loop of `calculateDistributeExcessIdle` * Addressed review feedback from @Saw-mon-and-Natalie * Addressed review feedback from @Saw-mon-and-Natalie
1 parent c56d094 commit d3f602a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contracts/src/libraries/LPMath.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,11 @@ library LPMath {
749749
return 0;
750750
}
751751

752-
// If the max bond amount is greater than or equal to the
753-
// net curve trade, then Newton's method has terminated since
752+
// If the max bond amount is less than or equal to the net
753+
// curve trade, then Newton's method has terminated since
754754
// proceeding to the next step would result in reaching the
755755
// same point.
756-
if (maxBondAmount >= uint256(_params.netCurveTrade)) {
756+
if (maxBondAmount <= uint256(_params.netCurveTrade)) {
757757
return shareProceeds;
758758
}
759759
// Otherwise, we continue to the next iteration of Newton's
@@ -840,15 +840,15 @@ library LPMath {
840840
///
841841
/// (1) zeta > 0:
842842
///
843-
/// y_max_out(dz) = (z - dz) - zeta * ((z - dz) / z) - z_min
843+
/// z_max_out(dz) = ((z - dz) / z) * (z - zeta) - z_min
844844
///
845845
/// =>
846846
///
847847
/// PV(dz) = zeta * ((z - dz) / z) + net_f
848848
///
849849
/// (2) zeta <= 0:
850850
///
851-
/// y_max_out(dz) = (z - dz) - z_min
851+
/// z_max_out(dz) = (z - dz) - z_min
852852
///
853853
/// =>
854854
///

0 commit comments

Comments
 (0)