// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Script, console} from "forge-std/Script.sol";
import {TwoHopDodoToUniswapV3MultiHopExternalUnwinder} from "../../contracts/flash/TwoHopDodoToUniswapV3MultiHopExternalUnwinder.sol";

/**
 * @title DeployTwoHopDodoToUniswapV3MultiHopExternalUnwinder
 * @notice Deploy three-hop DODO -> DODO -> Uniswap V3 unwinder for quote-push workflows.
 *
 * Env:
 *   PRIVATE_KEY                    required
 *   DODO_PMM_INTEGRATION_MAINNET   required
 *   UNISWAP_V3_SWAP_ROUTER_MAINNET optional; defaults to legacy SwapRouter `0xE592...`
 */
contract DeployTwoHopDodoToUniswapV3MultiHopExternalUnwinder is Script {
    address internal constant DEFAULT_UNISWAP_V3_ROUTER_MAINNET = 0xE592427A0AEce92De3Edee1F18E0157C05861564;

    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address integration = vm.envAddress("DODO_PMM_INTEGRATION_MAINNET");
        address router = vm.envOr("UNISWAP_V3_SWAP_ROUTER_MAINNET", DEFAULT_UNISWAP_V3_ROUTER_MAINNET);
        address deployer = vm.addr(pk);

        console.log("Deployer:", deployer);
        console.log("DODO PMM integration:", integration);
        console.log("Uniswap V3 router:", router);

        vm.startBroadcast(pk);
        TwoHopDodoToUniswapV3MultiHopExternalUnwinder unwinder =
            new TwoHopDodoToUniswapV3MultiHopExternalUnwinder(integration, router);
        vm.stopBroadcast();

        console.log("TwoHopDodoToUniswapV3MultiHopExternalUnwinder:", address(unwinder));
    }
}
