Skip to content

Commit

Permalink
feat(pool-monitor): add initial liquidity monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandr-masl committed Sep 12, 2024
1 parent 0a230f9 commit c9e04d3
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol
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);
}
}

0 comments on commit c9e04d3

Please sign in to comment.