Skip to content

Commit

Permalink
✨ lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Dec 17, 2024
1 parent 1941cff commit 48cd8d3
Showing 1 changed file with 22 additions and 98 deletions.
120 changes: 22 additions & 98 deletions src/utils/zap/Zap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {SafeERC20} from "./utils/SafeTransferERC20.sol";
/// @author @barrasso
/// @author @moss-eth
contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @custom:circle
address public immutable USDC;

Expand Down Expand Up @@ -99,11 +98,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
/// @param _minAmountOut acceptable slippage for wrapping and selling
/// @param _receiver address to receive USDx
/// @return zapped amount of USDx received
function zapIn(
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
function zapIn(uint256 _amount, uint256 _minAmountOut, address _receiver)
external
returns (uint256 zapped)
{
Expand All @@ -114,10 +109,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @dev allowance is assumed
/// @dev following execution, this contract will hold the zapped USDx
function _zapIn(
uint256 _amount,
uint256 _minAmountOut
)
function _zapIn(uint256 _amount, uint256 _minAmountOut)
internal
returns (uint256 zapped)
{
Expand All @@ -131,11 +123,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
/// @param _minAmountOut acceptable slippage for buying and unwrapping
/// @param _receiver address to receive USDC
/// @return zapped amount of USDC received
function zapOut(
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
function zapOut(uint256 _amount, uint256 _minAmountOut, address _receiver)
external
returns (uint256 zapped)
{
Expand All @@ -146,10 +134,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @dev allowance is assumed
/// @dev following execution, this contract will hold the zapped USDC
function _zapOut(
uint256 _amount,
uint256 _minAmountOut
)
function _zapOut(uint256 _amount, uint256 _minAmountOut)
internal
returns (uint256 zapped)
{
Expand Down Expand Up @@ -177,10 +162,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
external
returns (uint256 wrapped)
{
) external returns (uint256 wrapped) {
_pull(_token, msg.sender, _amount);
wrapped = _wrap(_token, _synthId, _amount, _minAmountOut);
_push(ISpotMarket(SPOT_MARKET).getSynth(_synthId), _receiver, wrapped);
Expand All @@ -193,10 +175,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint128 _synthId,
uint256 _amount,
uint256 _minAmountOut
)
internal
returns (uint256 wrapped)
{
) internal returns (uint256 wrapped) {
IERC20(_token).approve(SPOT_MARKET, _amount);
(wrapped,) = ISpotMarket(SPOT_MARKET).wrap({
marketId: _synthId,
Expand All @@ -221,10 +200,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
external
returns (uint256 unwrapped)
{
) external returns (uint256 unwrapped) {
address synth = ISpotMarket(SPOT_MARKET).getSynth(_synthId);
_pull(synth, msg.sender, _amount);
unwrapped = _unwrap(_synthId, _amount, _minAmountOut);
Expand All @@ -233,11 +209,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @dev allowance is assumed
/// @dev following execution, this contract will hold the unwrapped token
function _unwrap(
uint128 _synthId,
uint256 _amount,
uint256 _minAmountOut
)
function _unwrap(uint128 _synthId, uint256 _amount, uint256 _minAmountOut)
private
returns (uint256 unwrapped)
{
Expand Down Expand Up @@ -266,10 +238,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
external
returns (uint256 received, address synth)
{
) external returns (uint256 received, address synth) {
synth = ISpotMarket(SPOT_MARKET).getSynth(_synthId);
_pull(USDX, msg.sender, _amount);
received = _buy(_synthId, _amount, _minAmountOut);
Expand All @@ -278,11 +247,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @dev allowance is assumed
/// @dev following execution, this contract will hold the bought synth
function _buy(
uint128 _synthId,
uint256 _amount,
uint256 _minAmountOut
)
function _buy(uint128 _synthId, uint256 _amount, uint256 _minAmountOut)
internal
returns (uint256 received)
{
Expand All @@ -307,10 +272,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _amount,
uint256 _minAmountOut,
address _receiver
)
external
returns (uint256 received)
{
) external returns (uint256 received) {
address synth = ISpotMarket(SPOT_MARKET).getSynth(_synthId);
_pull(synth, msg.sender, _amount);
received = _sell(_synthId, _amount, _minAmountOut);
Expand All @@ -319,11 +281,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

/// @dev allowance is assumed
/// @dev following execution, this contract will hold the sold USDX
function _sell(
uint128 _synthId,
uint256 _amount,
uint256 _minAmountOut
)
function _sell(uint128 _synthId, uint256 _amount, uint256 _minAmountOut)
internal
returns (uint256 received)
{
Expand Down Expand Up @@ -362,11 +320,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _unwrapMinAmountOut,
uint256 _swapAmountIn,
address _receiver
)
external
isAuthorized(_accountId)
requireStage(Stage.UNSET)
{
) external isAuthorized(_accountId) requireStage(Stage.UNSET) {
stage = Stage.LEVEL1;

bytes memory params = abi.encode(
Expand Down Expand Up @@ -408,12 +362,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _premium,
address,
bytes calldata _params
)
external
onlyAave
requireStage(Stage.LEVEL1)
returns (bool)
{
) external onlyAave requireStage(Stage.LEVEL1) returns (bool) {
stage = Stage.LEVEL2;

(,,, address _collateral,,,,, address _receiver) = abi.decode(
Expand Down Expand Up @@ -447,11 +396,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _flashloan,
uint256 _premium,
bytes calldata _params
)
internal
requireStage(Stage.LEVEL2)
returns (uint256 unwound)
{
) internal requireStage(Stage.LEVEL2) returns (uint256 unwound) {
(
uint128 _accountId,
uint128 _collateralId,
Expand Down Expand Up @@ -566,10 +511,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
/// @param _amount amount of USDx to burn
/// @param _accountId synthetix perp market account id
/// @return excess amount of USDx returned to the caller
function burn(
uint256 _amount,
uint128 _accountId
)
function burn(uint256 _amount, uint128 _accountId)
external
returns (uint256 excess)
{
Expand Down Expand Up @@ -607,10 +549,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
uint256 _amount,
uint128 _accountId,
address _receiver
)
external
isAuthorized(_accountId)
{
) external isAuthorized(_accountId) {
_withdraw(_synthId, _amount, _accountId);
address synth = _synthId == USDX_ID
? USDX
Expand All @@ -621,11 +560,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
/// @custom:synthetix RBAC permission required: "PERPS_MODIFY_COLLATERAL"
/// @dev following execution, this contract will hold the withdrawn
/// collateral
function _withdraw(
uint128 _synthId,
uint256 _amount,
uint128 _accountId
)
function _withdraw(uint128 _synthId, uint256 _amount, uint128 _accountId)
internal
{
IPerpsMarket market = IPerpsMarket(PERPS_MARKET);
Expand Down Expand Up @@ -655,10 +590,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
bytes memory _path,
uint256 _amountIn,
address _receiver
)
external
returns (uint256 amountOut)
{
) external returns (uint256 amountOut) {
_pull(_from, msg.sender, _amountIn);
amountOut = odosSwap(_from, _amountIn, _path);
_push(USDC, _receiver, amountOut);
Expand All @@ -677,10 +609,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
address _tokenFrom,
uint256 _amountIn,
bytes memory _swapPath
)
internal
returns (uint256 amountOut)
{
) internal returns (uint256 amountOut) {
IERC20(_tokenFrom).approve(ROUTER, _amountIn);

(bool success, bytes memory result) = ROUTER.call{value: 0}(_swapPath);
Expand Down Expand Up @@ -709,11 +638,7 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {
/// @param _token address of token to push
/// @param _receiver address of receiver
/// @param _amount amount of token to push
function _push(
address _token,
address _receiver,
uint256 _amount
)
function _push(address _token, address _receiver, uint256 _amount)
internal
{
require(_receiver != address(0), PushFailed("Zero Address"));
Expand All @@ -722,5 +647,4 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) {

SafeERC20.safeTransfer(token, _receiver, _amount);
}

}
}

0 comments on commit 48cd8d3

Please sign in to comment.