@@ -697,7 +697,6 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
697697 */
698698 function getAccountInfo (ISetToken _setToken ) public view returns (AccountInfo memory accountInfo ) {
699699 (int256 owedRealizedPnl ,, ) = perpAccountBalance.getPnlAndPendingFee (address (_setToken));
700- (int256 netQuoteBalance , ) = perpAccountBalance.getNetQuoteBalanceAndPendingFee (address (_setToken));
701700
702701 // NOTE: pendingFundingPayments are represented as in the Perp system as "funding owed"
703702 // 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
706705 collateralBalance: _getCollateralBalance (_setToken),
707706 owedRealizedPnl: owedRealizedPnl,
708707 pendingFundingPayments: perpExchange.getAllPendingFundingPayment (address (_setToken)).mul (- 1 ),
709- netQuoteBalance: netQuoteBalance
708+ netQuoteBalance: _getNetQuoteBalance (_setToken)
710709 });
711710 }
712711
@@ -1204,6 +1203,15 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
12041203 return _toPreciseUnitsFromDecimals (balance, collateralDecimals);
12051204 }
12061205
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+
12071215 /**
12081216 * @dev Returns issuance or redemption adjustments in the format expected by `SlippageIssuanceModule`.
12091217 * The last recorded externalPositionUnit (current) is subtracted from a dynamically generated
@@ -1290,4 +1298,4 @@ contract PerpV2LeverageModule is ModuleBase, ReentrancyGuard, Ownable, IModuleIs
12901298 function _abs (int x ) internal pure returns (int ) {
12911299 return x >= 0 ? x : x.mul (- 1 );
12921300 }
1293- }
1301+ }
0 commit comments