From 788c5b1cc89d8fe96a611b734d6457414c0dd55d Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 2 Jan 2024 18:57:53 +0000 Subject: [PATCH] Refactor _reduceOIAndOIShares to include additional parameters --- contracts/OverlayV1Market.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contracts/OverlayV1Market.sol b/contracts/OverlayV1Market.sol index f76f0afa..7ec073f0 100644 --- a/contracts/OverlayV1Market.sol +++ b/contracts/OverlayV1Market.sol @@ -342,7 +342,7 @@ contract OverlayV1Market is IOverlayV1Market { // subtract unwound open interest from the side's aggregate oi value // and decrease number of oi shares issued - _reduceOIAndOIShares(pos, fraction); + _reduceOIAndOIShares(pos, fraction, oiTotalOnSide, oiTotalSharesOnSide); // register the amount to be minted/burned // capPayoff prevents overflow reverts with int256 cast @@ -433,7 +433,7 @@ contract OverlayV1Market is IOverlayV1Market { // subtract liquidated open interest from the side's aggregate oi value // and decrease number of oi shares issued - _reduceOIAndOIShares(pos, fraction); + _reduceOIAndOIShares(pos, fraction, oiTotalOnSide, oiTotalSharesOnSide); // register the amount to be burned _registerMintOrBurn(int256(value) - int256(cost) - int256(marginToBurn)); @@ -728,7 +728,12 @@ contract OverlayV1Market is IOverlayV1Market { /// @notice subtract open interest from the side's aggregate oi value /// @notice and decrease number of oi shares issued - function _reduceOIAndOIShares(Position.Info memory pos, uint256 fraction) internal { + function _reduceOIAndOIShares( + Position.Info memory pos, + uint256 fraction, + uint256 oiTotalOnSide, + uint256 oiTotalSharesOnSide + ) internal { // NOTE: use subFloor to avoid reverts with oi rounding issues if (pos.isLong) { oiLong = oiLong.subFloor(