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

import {Script, console} from "forge-std/Script.sol";
import "../../../contracts/bridge/trustless/EnhancedSwapRouterV2.sol";
import "../../../contracts/bridge/trustless/RouteTypesV2.sol";

contract ConfigureEnhancedSwapRouterV2DodoOnly is Script {
    address constant LIVE_ROUTER_V2 = 0xF1c93F54A5C2fc0d7766Ccb0Ad8f157DFB4C99Ce;

    function run() external {
        require(block.chainid == 138, "ConfigureEnhancedSwapRouterV2DodoOnly: Chain 138 only");

        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        address routerAddress = vm.envOr("ENHANCED_SWAP_ROUTER_V2_ADDRESS", LIVE_ROUTER_V2);

        EnhancedSwapRouterV2 router = EnhancedSwapRouterV2(payable(routerAddress));
        RouteTypesV2.Provider[] memory providers = new RouteTypesV2.Provider[](1);
        providers[0] = RouteTypesV2.Provider.Dodo;

        vm.startBroadcast(deployerPrivateKey);
        router.setRoutingConfig(0, providers);
        router.setRoutingConfig(1, providers);
        router.setRoutingConfig(2, providers);
        router.setProviderEnabled(RouteTypesV2.Provider.UniswapV3, false);
        router.setProviderEnabled(RouteTypesV2.Provider.Balancer, false);
        router.setProviderEnabled(RouteTypesV2.Provider.Curve, false);
        router.setProviderEnabled(RouteTypesV2.Provider.OneInch, false);
        router.setProviderEnabled(RouteTypesV2.Provider.Partner, false);
        vm.stopBroadcast();

        console.log("EnhancedSwapRouterV2 DODO-only routing configured:", routerAddress);
        console.log("sizeCategory 0 provider:", uint8(providers[0]));
        console.log("sizeCategory 1 provider:", uint8(providers[0]));
        console.log("sizeCategory 2 provider:", uint8(providers[0]));
        console.log("disabled provider:", uint8(RouteTypesV2.Provider.UniswapV3));
        console.log("disabled provider:", uint8(RouteTypesV2.Provider.Balancer));
        console.log("disabled provider:", uint8(RouteTypesV2.Provider.Curve));
        console.log("disabled provider:", uint8(RouteTypesV2.Provider.OneInch));
        console.log("disabled provider:", uint8(RouteTypesV2.Provider.Partner));
    }
}
