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

import {Script, console} from "forge-std/Script.sol";
import {DODOPMMProvider} from "../../contracts/liquidity/providers/DODOPMMProvider.sol";

/**
 * @title DeployDODOPMMProvider
 * @notice Deploy DODOPMMProvider for Chain 138 (or any chain with DODOPMMIntegration).
 * @dev Set DODO_PMM_INTEGRATION or DODO_PMM_INTEGRATION_ADDRESS in .env. After deploy,
 *      call registerPool(tokenIn, tokenOut, pool) for each pool created via DODOPMMIntegration.
 */
contract DeployDODOPMMProvider is Script {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address integrationAddr = vm.envAddress("DODO_PMM_INTEGRATION");
        if (integrationAddr == address(0)) {
            integrationAddr = vm.envAddress("DODO_PMM_INTEGRATION_ADDRESS");
        }
        require(integrationAddr != address(0), "DODO_PMM_INTEGRATION not set");

        address deployer = vm.addr(pk);

        vm.startBroadcast(pk);
        DODOPMMProvider provider = new DODOPMMProvider(integrationAddr, deployer);
        console.log("DODOPMMProvider deployed at:", address(provider));
        vm.stopBroadcast();

        console.log("\nNext: register pools with registerPool(tokenIn, tokenOut, pool)");
        console.log("export DODO_PMM_PROVIDER_ADDRESS=", vm.toString(address(provider)));
    }
}
