@@ -697,7 +697,6 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
697
697
*/
698
698
function getAccountInfo (ISetToken _setToken ) public view returns (AccountInfo memory accountInfo ) {
699
699
(int256 owedRealizedPnl ,, ) = perpAccountBalance.getPnlAndPendingFee (address (_setToken));
700
- (int256 netQuoteBalance , ) = perpAccountBalance.getNetQuoteBalanceAndPendingFee (address (_setToken));
701
700
702
701
// NOTE: pendingFundingPayments are represented as in the Perp system as "funding owed"
703
702
// e.g a positive number is a debt which gets subtracted from owedRealizedPnl on settlement.
@@ -706,7 +705,7 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
706
705
collateralBalance: _getCollateralBalance (_setToken),
707
706
owedRealizedPnl: owedRealizedPnl,
708
707
pendingFundingPayments: perpExchange.getAllPendingFundingPayment (address (_setToken)).mul (- 1 ),
709
- netQuoteBalance: netQuoteBalance
708
+ netQuoteBalance: _getNetQuoteBalance (_setToken)
710
709
});
711
710
}
712
711
@@ -1204,6 +1203,15 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
1204
1203
return _toPreciseUnitsFromDecimals (balance, collateralDecimals);
1205
1204
}
1206
1205
1206
+ // @dev Retrieves net quote balance of all open positions
1207
+ function _getNetQuoteBalance (ISetToken _setToken ) internal view returns (int256 netQuoteBalance ) {
1208
+ for (uint256 i = 0 ; i < positions[_setToken].length ; i++ ) {
1209
+ netQuoteBalance = netQuoteBalance.add (
1210
+ perpAccountBalance.getQuote (address (_setToken), positions[_setToken][i])
1211
+ );
1212
+ }
1213
+ }
1214
+
1207
1215
/**
1208
1216
* @dev Returns issuance or redemption adjustments in the format expected by `SlippageIssuanceModule`.
1209
1217
* The last recorded externalPositionUnit (current) is subtracted from a dynamically generated
@@ -1290,4 +1298,4 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
1290
1298
function _abs (int x ) internal pure returns (int ) {
1291
1299
return x >= 0 ? x : x.mul (- 1 );
1292
1300
}
1293
- }
1301
+ }
0 commit comments