You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
emitMonitorPaused(currentCollateralLiquidity, 32);// 32 represents the percentage difference
324
350
351
+
// Simulate the defender relayer calling checkLiquidityVertex to trigger the liquidity check
325
352
vm.prank(defenderRelayer);
326
353
monitor.checkLiquidityVertex();
327
354
}
328
355
356
+
/**
357
+
* @notice Tests that the `checkLiquidityVertex` function reverts with "Monitor paused" after the monitor is paused due to liquidity dropping below the threshold.
358
+
* @dev Simulates a drop in collateral liquidity by redeeming dollars and ensures that once the liquidity drop exceeds the threshold,
359
+
* the monitor is paused and subsequent calls to `checkLiquidityVertex` revert with the message "Monitor paused".
360
+
*/
329
361
function testMonitorPausedRevertAfterLiquidityDropBelowThreshold() public {
330
362
curveDollarPlainPool.updateMockParams(0.99e18);
331
363
364
+
// Simulate a user redeeming dollars, leading to a decrease in collateral liquidity
332
365
vm.prank(user);
333
366
ubiquityPoolFacet.redeemDollar(0, 1e18, 0, 0);
334
367
368
+
// Simulate the defender relayer calling checkLiquidityVertex to trigger the monitor pause
335
369
vm.prank(defenderRelayer);
336
370
monitor.checkLiquidityVertex();
337
371
372
+
// Expect a revert with "Monitor paused" message when trying to check liquidity again
338
373
vm.expectRevert("Monitor paused");
339
374
vm.prank(defenderRelayer);
340
375
monitor.checkLiquidityVertex();
341
376
}
342
377
378
+
/**
379
+
* @notice Tests that both the monitor and the Ubiquity Dollar are paused after a liquidity drop below the threshold.
380
+
* @dev Simulates a collateral price drop and ensures that:
381
+
* - The monitor is paused after the liquidity drop.
382
+
* - The collateral information is no longer valid and reverts with "Invalid collateral".
383
+
* - The Ubiquity Dollar token is paused after the liquidity drop.
384
+
*/
343
385
function testMonitorAndDollarPauseAfterLiquidityDropBelowThreshold()
344
386
public
345
387
{
346
388
curveDollarPlainPool.updateMockParams(0.99e18);
347
389
390
+
// Simulate a user redeeming dollars, leading to a decrease in collateral liquidity
348
391
vm.prank(user);
349
392
ubiquityPoolFacet.redeemDollar(0, 1e18, 0, 0);
350
393
394
+
// Simulate the defender relayer calling checkLiquidityVertex to trigger the monitor pause
351
395
vm.prank(defenderRelayer);
352
396
monitor.checkLiquidityVertex();
353
397
398
+
// Expect a revert with "Invalid collateral" when trying to retrieve collateral information
// Assert that the monitor is not paused after the liquidity drop
386
441
bool monitorPaused = monitor.monitorPaused();
387
-
388
442
assertFalse(
389
443
monitorPaused,
390
444
"Monitor should Not be paused after liquidity drop"
391
445
);
392
446
}
393
447
394
-
function testLiquidityDropPausesMonitorWhenCollateralToggledAfterThreshold()
395
-
public
396
-
{
448
+
/**
449
+
* @notice Tests that the monitor is paused after a significant liquidity drop, even when collateral was toggled before.
450
+
* @dev Simulates a scenario where collateral liquidity drops below the threshold and collateral is toggled prior to the incident.
451
+
* Ensures that:
452
+
* - The monitor pauses after the liquidity drop.
453
+
* - Any collateral that was toggled prior to the liquidity check does not interfere with the monitor's behavior.
454
+
* - Collateral information becomes inaccessible after the monitor is paused.
455
+
*/
456
+
function testLiquidityDropPausesMonitorWhenCollateralToggled() public {
397
457
curveDollarPlainPool.updateMockParams(0.99e18);
398
458
459
+
// Simulate a user redeeming dollars, causing a significant liquidity drop
399
460
vm.prank(user);
400
461
ubiquityPoolFacet.redeemDollar(0, 1e18, 0, 0);
401
462
463
+
// Simulate the admin toggling the collateral state
402
464
vm.prank(admin);
403
465
ubiquityPoolFacet.toggleCollateral(0);
404
466
467
+
// Simulate the defender relayer calling checkLiquidityVertex to trigger the monitor pause
405
468
vm.prank(defenderRelayer);
406
469
monitor.checkLiquidityVertex();
407
470
471
+
// Assert that the monitor is paused after the liquidity drop
408
472
bool monitorPaused = monitor.monitorPaused();
409
-
410
473
assertTrue(
411
474
monitorPaused,
412
475
"Monitor should be paused after liquidity drop, and any prior manipulation of collateral does not interfere with the ongoing incident management process."
413
476
);
414
477
478
+
// Ensure that collateral information is inaccessible after the monitor is paused
0 commit comments