Skip to content

Commit cc15b59

Browse files
authored
Update Perp artifacts to 1.0.1 (#175)
* Update Perp artifacts to v1.0.2 * Add _getNetQuoteBalance method (to replace removed Perp getter)
1 parent 23ec0c8 commit cc15b59

15 files changed

+162
-368
lines changed

contracts/protocol/modules/PerpV2LeverageModule.sol

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

external/abi/perp/PerpV2AccountBalance.json

Lines changed: 65 additions & 122 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2BaseToken.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2ClearingHouse.json

Lines changed: 35 additions & 17 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2ClearingHouseConfig.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2Exchange.json

Lines changed: 16 additions & 114 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2InsuranceFund.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2MarketRegistry.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2OrderBook.json

Lines changed: 7 additions & 82 deletions
Large diffs are not rendered by default.

external/abi/perp/PerpV2QuoteToken.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)