Skip to content

Commit

Permalink
feat(ubiquity-pool-security-monitor): modularize contract
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandr-masl committed Sep 20, 2024
1 parent 428fb6d commit 2ddd382
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions packages/contracts/src/dollar/core/UbiquityPoolSecurityMonitor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,38 @@ contract UbiquityPoolSecurityMonitor is Initializable, UUPSUpgradeable {
require(!monitorPaused, "Monitor paused");

if (currentCollateralLiquidity > liquidityVertex) {
liquidityVertex = currentCollateralLiquidity;
emit LiquidityVertexUpdated(liquidityVertex);
_updateLiquidityVertex(currentCollateralLiquidity);
} else {
uint256 liquidityDiffPercentage = liquidityVertex
.sub(currentCollateralLiquidity)
.mul(100)
.div(liquidityVertex);
_checkThresholdPercentage(currentCollateralLiquidity);
}
}

function _updateLiquidityVertex(uint256 _newLiquidityVertex) internal {
liquidityVertex = _newLiquidityVertex;
emit LiquidityVertexUpdated(liquidityVertex);
}

if (liquidityDiffPercentage >= thresholdPercentage) {
monitorPaused = true;
function _checkThresholdPercentage(
uint256 _currentCollateralLiquidity
) internal {
uint256 liquidityDiffPercentage = liquidityVertex
.sub(_currentCollateralLiquidity)
.mul(100)
.div(liquidityVertex);

// Pause the UbiquityDollarToken
_pauseUbiquityDollarToken();
if (liquidityDiffPercentage >= thresholdPercentage) {
monitorPaused = true;

// Pause LibUbiquityPool by disabling collateral
_pauseLibUbiquityPool();
// Pause the UbiquityDollarToken
_pauseUbiquityDollarToken();

emit MonitorPaused(
currentCollateralLiquidity,
liquidityDiffPercentage
);
}
// Pause LibUbiquityPool by disabling collateral
_pauseLibUbiquityPool();

emit MonitorPaused(
_currentCollateralLiquidity,
liquidityDiffPercentage
);
}
}

Expand Down

0 comments on commit 2ddd382

Please sign in to comment.