diff --git a/contracts/src/HyperdriveLP.sol b/contracts/src/HyperdriveLP.sol index 065579f8c..517b24b96 100644 --- a/contracts/src/HyperdriveLP.sol +++ b/contracts/src/HyperdriveLP.sol @@ -210,7 +210,7 @@ abstract contract HyperdriveLP is HyperdriveTWAP { /// @param _asUnderlying If true the user is paid in underlying if false /// the contract transfers in yield source directly. /// Note - for some paths one choice may be disabled or blocked. - /// @return Returns the base out, the lond withdraw shares out and the short withdraw + /// @return Returns the base out, the long withdraw shares out and the short withdraw /// shares out. function removeLiquidity( uint256 _shares, @@ -317,8 +317,8 @@ abstract contract HyperdriveLP is HyperdriveTWAP { ); // Apply the update to the withdrawal pool. - _withdrawPool.readyToWithdraw -= uint128(_shares); - _withdrawPool.proceeds -= uint128(shareProceeds); + _withdrawPool.readyToWithdraw -= _shares.toUint128(); + _withdrawPool.proceeds -= shareProceeds.toUint128(); // Withdraw for the user uint256 proceeds = _withdraw( @@ -530,8 +530,8 @@ abstract contract HyperdriveLP is HyperdriveTWAP { maxSharesReleased ); } - _withdrawPool.readyToWithdraw += uint128(sharesReleased); - _withdrawPool.proceeds += uint128(withdrawalPoolProceeds); + _withdrawPool.readyToWithdraw += sharesReleased.toUint128(); + _withdrawPool.proceeds += withdrawalPoolProceeds.toUint128(); // Remove the withdrawal pool proceeds from the reserves. _updateLiquidity(-int256(withdrawalPoolProceeds)); diff --git a/contracts/test/MockSafeCast.sol b/contracts/test/MockSafeCast.sol index 5fe824fba..e92d62974 100644 --- a/contracts/test/MockSafeCast.sol +++ b/contracts/test/MockSafeCast.sol @@ -4,8 +4,7 @@ pragma solidity ^0.8.18; import "../src/libraries/SafeCast.sol"; contract MockSafeCast { - function toUint128(uint256 x) external pure returns (uint128) { - uint128 y = SafeCast.toUint128(x); - return y; + function toUint128(uint256 x) external pure returns (uint128 y) { + y = SafeCast.toUint128(x); } }