Skip to content

Commit

Permalink
πŸ‘·πŸ»β€β™‚οΈ Refactor _zapOut for early exit
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders committed Jan 12, 2024
1 parent dbc1978 commit afb6cfc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Zap.sol
Expand Up @@ -179,6 +179,19 @@ abstract contract Zap is ZapErrors, ZapEvents {
virtual
returns (uint256 adjustedAmount)
{
/// @notice prior to unwrapping, ensure that there
/// is enough $sUSDC to unwrap
/// @custom:example if $USDC has 6 decimals, and
/// $sUSDC has greater than 6 decimals,
/// then it is possible that the amount of
/// $sUSDC to unwrap is less than 1 $USDC;
/// this contract will prevent such cases
/// @dev if $USDC has 6 decimals, and $sUSDC has 18 decimals,
/// precision may be lost
if (_amount < _DECIMALS_FACTOR) {
revert InsufficientAmount(_amount);
}

// allocate $sUSD allowance to the Spot Market Proxy
if (!_SUSD.approve(address(_SPOT_MARKET_PROXY), _amount)) {
revert ApprovalFailed(
Expand Down Expand Up @@ -209,19 +222,6 @@ abstract contract Zap is ZapErrors, ZapEvents {
);
}

/// @notice prior to unwrapping, ensure that there
/// is enough $sUSDC to unwrap
/// @custom:example if $USDC has 6 decimals, and
/// $sUSDC has greater than 6 decimals,
/// then it is possible that the amount of
/// $sUSDC to unwrap is less than 1 $USDC;
/// this contract will prevent such cases
/// @dev if $USDC has 6 decimals, and $sUSDC has 18 decimals,
/// precision may be lost
if (_amount < _DECIMALS_FACTOR) {
revert InsufficientAmount(_amount);
}

/// @notice $USDC might use non-standard decimals
/// @dev adjustedAmount is the amount of $USDC
/// expected to receive from unwrapping
Expand Down

0 comments on commit afb6cfc

Please sign in to comment.