Skip to content

Commit

Permalink
✨ lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Dec 16, 2024
1 parent 41883aa commit bf4556e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/Engine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ contract Engine is
USDC.transferFrom(msg.sender, address(this), amountWithExcess);

USDC.approve(address(zap), amountWithExcess);
uint256 usdxAmount = zap.zapIn(amountWithExcess, _zapMinAmountOut, address(this));
uint256 usdxAmount =
zap.zapIn(amountWithExcess, _zapMinAmountOut, address(this));

SUSD.approve(address(zap), usdxAmount);
uint256 remaining = zap.burn(usdxAmount, _accountId);
Expand All @@ -673,7 +674,9 @@ contract Engine is
/// has to be above dust amount to avoid reverting
/// because converting back to USDC will be < 0
SUSD.approve(address(zap), remaining);
if (remaining > USDC_DUST_THRESHOLD) zap.zapOut(remaining, 1, msg.sender);
if (remaining > USDC_DUST_THRESHOLD) {
zap.zapOut(remaining, 1, msg.sender);
}

emit Burned(_accountId, usdxAmount - remaining);
}
Expand Down
23 changes: 17 additions & 6 deletions test/PayDebt.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ contract PayDebtTest is Bootstrap {
170_141_183_460_469_231_731_687_303_715_884_105_747;
uint256 public constant INITIAL_DEBT = 1_415_390_413_007_519_465;
uint256 public constant BASE_BLOCK_NUMBER_WITH_DEBT = 23_779_991;
uint256 public constant USDC_WRAPPER_MAX_AMOUNT = 100_000_000_000_000_000_000_000_000;
uint256 public constant USDC_WRAPPER_MAX_AMOUNT =
100_000_000_000_000_000_000_000_000;

function setUp() public {
vm.rollFork(BASE_BLOCK_NUMBER_WITH_DEBT);
Expand All @@ -38,7 +39,11 @@ contract PayDebtTest is Bootstrap {

vm.expectRevert(abi.encodeWithSelector(IEngine.Unauthorized.selector));

engine.payDebtWithUSDC({_accountId: ACCOUNT_ID, _amount: INITIAL_DEBT, _zapMinAmountOut: 1});
engine.payDebtWithUSDC({
_accountId: ACCOUNT_ID,
_amount: INITIAL_DEBT,
_zapMinAmountOut: 1
});
}

function test_payDebt() public {
Expand All @@ -63,7 +68,7 @@ contract PayDebtTest is Bootstrap {
assertEq(finalSUSD, initialSUSD - INITIAL_DEBT);
}

/// @notice asserts that if amount passed is greater than debt,
/// @notice asserts that if amount passed is greater than debt,
/// @notice excess sUSD is sent back to the user after paying off the debt
function test_payDebt_overpay() public {
/// @dev on this block (BASE_BLOCK_NUMBER_WITH_DEBT)
Expand Down Expand Up @@ -143,7 +148,11 @@ contract PayDebtTest is Bootstrap {
vm.startPrank(DEBT_ACTOR);
/// @dev remember we need to approve the excess amount as well (+1)
USDC.approve(address(engine), INITIAL_DEBT_IN_USDC + 1);
engine.payDebtWithUSDC({_accountId: ACCOUNT_ID, _amount: INITIAL_DEBT_IN_USDC, _zapMinAmountOut: INITIAL_DEBT_IN_USDC});
engine.payDebtWithUSDC({
_accountId: ACCOUNT_ID,
_amount: INITIAL_DEBT_IN_USDC,
_zapMinAmountOut: INITIAL_DEBT_IN_USDC
});
vm.stopPrank();

uint256 finalAccountDebt = perpsMarketProxy.debt(ACCOUNT_ID);
Expand All @@ -158,7 +167,7 @@ contract PayDebtTest is Bootstrap {
assertEq(finalUSDC, initialUSDC - (INITIAL_DEBT_IN_USDC + 1));
}

/// @notice asserts that if amount passed is greater than debt,
/// @notice asserts that if amount passed is greater than debt,
/// @notice excess USDC is sent back to the user after paying off the debt
function test_payDebtWithUSDC_overpay() public {
/// @dev INITIAL_DEBT is in sUSD (18 decimals)
Expand Down Expand Up @@ -241,7 +250,9 @@ contract PayDebtTest is Bootstrap {
assertEq(finalUSDC, initialUSDC - (INITIAL_DEBT_IN_USDC + 1));
} else {
// If amount is less or equal than the initial debt, only part of the debt is paid
assertEq(finalAccountDebt, INITIAL_DEBT - ((amount + 1) * decimalsFactor));
assertEq(
finalAccountDebt, INITIAL_DEBT - ((amount + 1) * decimalsFactor)
);
assertEq(finalUSDC, initialUSDC - (uint256(amount) + 1));
}
/// @dev the sUSD balance should stay the same because
Expand Down

0 comments on commit bf4556e

Please sign in to comment.