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

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

/**
 * @title DeployDODOToUniswapV3MultiHopExternalUnwinder
 * @notice Deploy mixed 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...`
 *
 * Usage:
 *   forge script script/deploy/DeployDODOToUniswapV3MultiHopExternalUnwinder.s.sol:DeployDODOToUniswapV3MultiHopExternalUnwinder \
 *     --rpc-url $ETHEREUM_MAINNET_RPC --broadcast -vvvv
 */
contract DeployDODOToUniswapV3MultiHopExternalUnwinder 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);
        DODOToUniswapV3MultiHopExternalUnwinder unwinder =
            new DODOToUniswapV3MultiHopExternalUnwinder(integration, router);
        vm.stopBroadcast();

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