diff --git a/markets/perps-market/contracts/interfaces/IAccountModule.sol b/markets/perps-market/contracts/interfaces/IAccountModule.sol index 64e4b1eca4..fe8ae97cff 100644 --- a/markets/perps-market/contracts/interfaces/IAccountModule.sol +++ b/markets/perps-market/contracts/interfaces/IAccountModule.sol @@ -39,4 +39,9 @@ interface IAccountModule { ) external view returns (AsyncOrder.Data memory); function getAvailableMargin(uint128 accountId) external view returns (int); + + function getCollateralAmount( + uint128 accountId, + uint128 synthMarketId + ) external view returns (uint256); } diff --git a/markets/perps-market/contracts/modules/PerpsAccountModule.sol b/markets/perps-market/contracts/modules/PerpsAccountModule.sol index 842aecc8a0..01fec8282e 100644 --- a/markets/perps-market/contracts/modules/PerpsAccountModule.sol +++ b/markets/perps-market/contracts/modules/PerpsAccountModule.sol @@ -104,4 +104,11 @@ contract PerpsAccountModule is IAccountModule { function getAvailableMargin(uint128 accountId) external view override returns (int) { return PerpsAccount.load(accountId).getAvailableMargin(); } + + function getCollateralAmount( + uint128 accountId, + uint128 synthMarketId + ) external view override returns (uint256) { + return PerpsAccount.load(accountId).collateralAmounts[synthMarketId]; + } } diff --git a/markets/perps-market/storage.dump.sol b/markets/perps-market/storage.dump.sol index aaa123dbf5..02a13f1596 100644 --- a/markets/perps-market/storage.dump.sol +++ b/markets/perps-market/storage.dump.sol @@ -350,7 +350,7 @@ library Vault { struct Data { uint256 epoch; bytes32 __slotAvailableForFutureUse; - int128 prevTotalDebtD18; + int128 _unused_prevTotalDebtD18; mapping(uint256 => VaultEpoch.Data) epochData; mapping(bytes32 => RewardDistribution.Data) rewards; SetUtil.Bytes32Set rewardIds; diff --git a/markets/perps-market/test/integration/Account/ModifyCollateral.deposit.test.ts b/markets/perps-market/test/integration/Account/ModifyCollateral.deposit.test.ts index ec3eaeea91..0828a178e3 100644 --- a/markets/perps-market/test/integration/Account/ModifyCollateral.deposit.test.ts +++ b/markets/perps-market/test/integration/Account/ModifyCollateral.deposit.test.ts @@ -109,5 +109,13 @@ describe('ModifyCollateral Deposit', () => { systems().PerpsMarket ); }); + + it('returns the correct amount when calling getCollateralAmount', async () => { + const collateralBalance = await systems().PerpsMarket.getCollateralAmount( + accountIds[0], + synthBTCMarketId + ); + assertBn.equal(collateralBalance, bn(1)); + }); }); });