FV-SOL-8-C4 Unexpected Gas Increase

TLDR

Occurs when dynamic transaction fees or gas fees increase unexpectedly, eating into the user's transaction value and causing unintended slippage.

Game

During the transaction, the user expects a predictable gas cost. Would you say he can calm down and go eat a sandwich?

// SPDX-License-Identifier: MIT
// Open me in VSCode and really think before opening the hints!
// Add @audit tags wherever suspicious
// Go to the solidity docs to complete missing knowledge of what's happening here
// Solve by drafting a fix!
pragma solidity ^0.8.0;

interface IDEX {
    function swap(address tokenIn, address tokenOut, uint256 amountIn) external returns (uint256);
}

contract GasIncreaseGame {
    IDEX public dex;
    address public tokenOut;

    constructor(address _dex, address _tokenOut) {
        dex = IDEX(_dex);
        tokenOut = _tokenOut;
    }
    
    function executeSwap(address tokenIn, uint256 amountIn) public {
        dex.swap(tokenIn, tokenOut, amountIn);
    }
}

Last updated