Skip to content

Commit 9195ba6

Browse files
author
Sachin
authored
Refactor require to check for position unit during engage (#29)
1 parent a98789a commit 9195ba6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

contracts/extensions/DeltaNeutralBasisTradingStrategyExtension.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,11 @@ contract DeltaNeutralBasisTradingStrategyExtension is BaseExtension {
11521152
function _getAndValidateEngageInfo() internal view returns(LeverageInfo memory) {
11531153
ActionInfo memory engageInfo = _createActionInfo();
11541154

1155-
require(engageInfo.accountInfo.collateralBalance == 0, "PerpV2 collateral balance must be 0");
1155+
// Check that there is zero position unit of USDC of collateral value. Allows to neglect dust amounts.
1156+
require(
1157+
engageInfo.accountInfo.collateralBalance.preciseDiv(engageInfo.setTotalSupply.toInt256()) == 0,
1158+
"PerpV2 collateral balance must be 0"
1159+
);
11561160

11571161
return LeverageInfo({
11581162
action: engageInfo,

0 commit comments

Comments
 (0)