From c9e04d386c65d0443927e0a916197c2323ff0eff Mon Sep 17 00:00:00 2001 From: green Date: Thu, 12 Sep 2024 11:56:08 +0200 Subject: [PATCH] feat(pool-monitor): add initial liquidity monitor --- .../dollar/monitors/PoolLiquidityMonitor.sol | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol diff --git a/packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol b/packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol new file mode 100644 index 000000000..874b06f50 --- /dev/null +++ b/packages/contracts/src/dollar/monitors/PoolLiquidityMonitor.sol @@ -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); + } +}