Skip to content

Commit

Permalink
fix: add getter for _exposureCap
Browse files Browse the repository at this point in the history
  • Loading branch information
parth-15 committed Jan 17, 2024
1 parent f368bef commit 08f2fbb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/contracts/facilitators/gsm/Gsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ contract Gsm is AccessControl, VersionedInitializable, EIP712, IGsm {
return _exposureCap > _currentExposure ? _exposureCap - _currentExposure : 0;
}

/// @inheritdoc IGsm
function getExposureCap() external view returns (uint128) {
return _exposureCap;
}

/// @inheritdoc IGsm
function getAvailableLiquidity() external view returns (uint256) {
return _currentExposure;
Expand Down
6 changes: 6 additions & 0 deletions src/contracts/facilitators/gsm/interfaces/IGsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ interface IGsm is IAccessControl, IGhoFacilitator {
*/
function getAvailableUnderlyingExposure() external view returns (uint256);

/**
* @notice Returns the GSM exposure capacity
* @return The maximum amount of underlying asset that can be sold to the GSM
*/
function getExposureCap() external view returns (uint128);

/**
* @notice Returns the actual underlying asset balance immediately available in the GSM
* @return The amount of underlying asset that can be bought from the GSM
Expand Down
2 changes: 2 additions & 0 deletions src/test/TestGsm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ contract TestGsm is TestGhoBase {
vm.expectEmit(true, true, false, true);
emit ExposureCapUpdated(0, DEFAULT_GSM_USDC_EXPOSURE);
gsm.initialize(address(this), TREASURY, DEFAULT_GSM_USDC_EXPOSURE);
assertEq(gsm.getExposureCap(), DEFAULT_GSM_USDC_EXPOSURE, 'Unexpected exposure capacity');
}

function testRevertInitializeZeroAdmin() public {
Expand Down Expand Up @@ -1054,6 +1055,7 @@ contract TestGsm is TestGhoBase {
vm.expectEmit(true, true, false, true, address(GHO_GSM));
emit ExposureCapUpdated(DEFAULT_GSM_USDC_EXPOSURE, 0);
GHO_GSM.updateExposureCap(0);
assertEq(GHO_GSM.getExposureCap(), 0, 'Unexpected exposure capacity');

vm.stopPrank();
}
Expand Down

0 comments on commit 08f2fbb

Please sign in to comment.