Skip to content

Commit

Permalink
Merge branch 'main' into indexed-events
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzschoff authored Jun 28, 2023
2 parents 920bc83 + 8863153 commit 66591ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions markets/perps-market/contracts/interfaces/IAccountModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
7 changes: 7 additions & 0 deletions markets/perps-market/contracts/modules/PerpsAccountModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
2 changes: 1 addition & 1 deletion markets/perps-market/storage.dump.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});
});

0 comments on commit 66591ec

Please sign in to comment.