-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pool-monitor): add initial liquidity monitor
- Loading branch information
1 parent
0a230f9
commit c9e04d3
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "../facets/UbiquityPoolFacet.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract PoolLiquidityMonitor is Ownable { | ||
UbiquityPoolFacet public ubiquityPoolFacet; | ||
address public defenderRelayer; | ||
|
||
event LiquidityChecked(uint256 currentLiquidity); | ||
|
||
constructor(address _ubiquityPoolFacetAddress, address _defenderRelayer) { | ||
ubiquityPoolFacet = UbiquityPoolFacet(_ubiquityPoolFacetAddress); | ||
defenderRelayer = _defenderRelayer; | ||
} | ||
|
||
modifier onlyAuthorized() { | ||
require( | ||
msg.sender == defenderRelayer, | ||
"Not authorized: Only Defender Relayer allowed" | ||
); | ||
_; | ||
} | ||
|
||
function setDefenderRelayer( | ||
address _newDefenderRelayer | ||
) external onlyOwner { | ||
defenderRelayer = _newDefenderRelayer; | ||
} | ||
|
||
function checkLiquidity() external onlyAuthorized { | ||
uint256 currentCollateralLiquidity = ubiquityPoolFacet | ||
.collateralUsdBalance(); | ||
|
||
emit LiquidityChecked(currentCollateralLiquidity); | ||
} | ||
} |