Skip to content

Commit

Permalink
Fix division by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSachinK committed Apr 12, 2022
1 parent 90b0276 commit 56bfe82
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contracts/protocol/modules/v2/PerpV2BasisTradingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,16 @@ contract PerpV2BasisTradingModule is PerpV2LeverageModuleV2 {
override(PerpV2LeverageModuleV2)
returns (int256[] memory, int256[] memory _)
{
uint256 updatedSettledFunding = _getUpdatedSettledFunding(_setToken);
int256 newExternalPositionUnitNetFees = 0;

int256 newExternalPositionUnit = _executePositionTrades(_setToken, _setTokenQuantity, false, true);
if (positions[_setToken].length > 0) {

int256 newExternalPositionUnitNetFees = _calculateNetFeesPositionUnit(_setToken, newExternalPositionUnit, updatedSettledFunding);
uint256 updatedSettledFunding = _getUpdatedSettledFunding(_setToken);

int256 newExternalPositionUnit = _executePositionTrades(_setToken, _setTokenQuantity, false, true);

newExternalPositionUnitNetFees = _calculateNetFeesPositionUnit(_setToken, newExternalPositionUnit, updatedSettledFunding);
}

return _formatAdjustments(_setToken, newExternalPositionUnitNetFees);
}
Expand Down

0 comments on commit 56bfe82

Please sign in to comment.