Skip to content

Commit

Permalink
test: Adapt tests after new SP scale refactor
Browse files Browse the repository at this point in the history
Now P is always > 1e9 (as opposed to >= 1e19 it was before).
  • Loading branch information
bingen committed Sep 9, 2024
1 parent 922cab5 commit 22a9ea1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions contracts/src/test/stabilityPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ contract SPTest is DevTestSetup {

function testLiquidationWithLowPDoesNotDecreaseP_Cheat_Fuzz(uint256 _cheatP, uint256 _surplus) public {
// Choose a low value of P initially
_cheatP = bound(_cheatP, 1e9, 1e11);
_cheatP = bound(_cheatP, 1e9 + 1, 1e11);

// Cheat 1: manipulate contract state to make value of P low
vm.store(
Expand All @@ -1799,7 +1799,7 @@ contract SPTest is DevTestSetup {

uint256 debtDelta = troveDebt - stabilityPool.getTotalBoldDeposits();

_surplus = bound(_surplus, debtDelta + 1e9, debtDelta + 10e18);
_surplus = bound(_surplus, debtDelta + 1e9 + 1, debtDelta + 10e18);
// B deposits the surplus to SP
makeSPDepositAndClaim(B, _surplus);

Expand All @@ -1811,7 +1811,7 @@ contract SPTest is DevTestSetup {
assertGt(scale2, scale1, "scale didnt change");

// Confirm that P has not fallen below 1e9
assertGe(stabilityPool.P(), 1e9);
assertGt(stabilityPool.P(), 1e9);
}

function testLiquidationsWithLowPAllowFurtherRewardsForAllFreshDepositors_Cheat_Fuzz(
Expand All @@ -1821,7 +1821,7 @@ contract SPTest is DevTestSetup {
PTestVars memory testVars;

// Choose a low value of P initially
_cheatP = bound(_cheatP, 1e9, 1e11);
_cheatP = bound(_cheatP, 1e9 + 1, 1e11);

// Cheat 1: manipulate contract state to make value of P low
vm.store(
Expand All @@ -1846,7 +1846,7 @@ contract SPTest is DevTestSetup {
uint256 troveDebt = troveManager.getTroveEntireDebt(troveIDs.D);
uint256 debtDelta = troveDebt - stabilityPool.getTotalBoldDeposits();

_surplus = bound(_surplus, debtDelta + 1e9, debtDelta + 10e18);
_surplus = bound(_surplus, debtDelta + 1e9 + 1, debtDelta + 10e18);

// B transfers BOLD to A so he can slightly top up the SP
transferBold(B, A, boldToken.balanceOf(B) / 2);
Expand Down Expand Up @@ -1941,7 +1941,7 @@ contract SPTest is DevTestSetup {
PTestVars memory testVars;

// Choose a low value of P initially
_cheatP = bound(_cheatP, 1e9, 1e11);
_cheatP = bound(_cheatP, 1e9 + 1, 1e11);

// Cheat 1: manipulate contract state to make value of P low
vm.store(
Expand Down Expand Up @@ -2058,7 +2058,7 @@ contract SPTest is DevTestSetup {

function testHighFractionLiqWithLowPTriggersTwoScaleChanges_Cheat_Fuzz(uint256 _cheatP, uint256 _surplus) public {
// Choose a low value of P initially
_cheatP = bound(_cheatP, 1e9, 1e11);
_cheatP = bound(_cheatP, 1e9 + 1, 1e11);

// Cheat 1: manipulate contract state to make value of P low
vm.store(
Expand All @@ -2084,7 +2084,7 @@ contract SPTest is DevTestSetup {
uint256 debtDelta = troveDebt - stabilityPool.getTotalBoldDeposits();

// Tiny surplus
_surplus = bound(_surplus, debtDelta + 1e9, debtDelta + 1e10);
_surplus = bound(_surplus, debtDelta + 1e9 + 1, debtDelta + 1e10);
// B deposits the surplus to SP
makeSPDepositAndClaim(B, _surplus);

Expand All @@ -2098,7 +2098,7 @@ contract SPTest is DevTestSetup {

function testHighFractionLiqWithLowPDoesNotDecreasePBelow1e9(uint256 _cheatP, uint256 _surplus) public {
// Choose a low value of P initially
_cheatP = bound(_cheatP, 1e9, 1e11);
_cheatP = bound(_cheatP, 1e9 + 1, 1e11);

// Cheat 1: manipulate contract state to make value of P low
vm.store(
Expand All @@ -2122,7 +2122,7 @@ contract SPTest is DevTestSetup {
uint256 debtDelta = troveDebt - stabilityPool.getTotalBoldDeposits();

// Tiny surplus
_surplus = bound(_surplus, debtDelta + 1e9, debtDelta + 1e10);
_surplus = bound(_surplus, debtDelta + 1e9 + 1, debtDelta + 1e10);
// B deposits the surplus to SP
makeSPDepositAndClaim(B, _surplus);

Expand All @@ -2134,7 +2134,7 @@ contract SPTest is DevTestSetup {
assertGt(scale2, scale1, "scale didnt change");

// Confirm that P has not fallen below 1e9
assertGe(stabilityPool.P(), 1e9);
assertGt(stabilityPool.P(), 1e9);
}
}

Expand Down

0 comments on commit 22a9ea1

Please sign in to comment.