// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// Mock V2-style AMM router that captures the amountOutMin passed in.
/// Used to verify AereSink's oracle-floor computation logic.
contract MockSinkRouter {
    uint256 public lastAmountOutMin;
    address public outTokenOverride;

    function setOutToken(address t) external { outTokenOverride = t; }

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256
    ) external returns (uint256[] memory amounts) {
        lastAmountOutMin = amountOutMin;
        IERC20(path[0]).transferFrom(msg.sender, address(this), amountIn);
        // Always return at least amountOutMin (success path) so we can verify
        // the floor without triggering the try/catch fallback in AereSink.
        address outT = outTokenOverride == address(0) ? path[path.length - 1] : outTokenOverride;
        IERC20(outT).transfer(to, amountOutMin);
        amounts = new uint256[](2);
        amounts[0] = amountIn;
        amounts[1] = amountOutMin;
    }
}
