Skip to content

Commit

Permalink
Refactor _reduceOIAndOIShares to include additional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetto90 committed Jan 2, 2024
1 parent 169d5c4 commit 788c5b1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contracts/OverlayV1Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 788c5b1

Please sign in to comment.