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

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

/**
 * @title DeployAaveQuotePushFlashReceiver
 * @notice Deploy the Aave V3 quote-push flash receiver.
 *
 * Env:
 *   PRIVATE_KEY              required
 *   AAVE_POOL_ADDRESS        optional; defaults to Aave V3 mainnet Pool
 *   QUOTE_PUSH_RECEIVER_OWNER optional; defaults to deployer derived from PRIVATE_KEY
 *
 * Usage:
 *   forge script script/deploy/DeployAaveQuotePushFlashReceiver.s.sol:DeployAaveQuotePushFlashReceiver \
 *     --rpc-url $ETHEREUM_MAINNET_RPC --broadcast -vvvv
 */
contract DeployAaveQuotePushFlashReceiver is Script {
    address internal constant DEFAULT_AAVE_POOL_MAINNET = 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2;

    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address pool = vm.envOr("AAVE_POOL_ADDRESS", DEFAULT_AAVE_POOL_MAINNET);
        address deployer = vm.addr(pk);
        address owner = vm.envOr("QUOTE_PUSH_RECEIVER_OWNER", deployer);

        console.log("Deployer:", deployer);
        console.log("Aave Pool:", pool);
        console.log("Receiver owner:", owner);

        vm.startBroadcast(pk);
        AaveQuotePushFlashReceiver receiver = new AaveQuotePushFlashReceiver(pool, owner);
        vm.stopBroadcast();

        console.log("AaveQuotePushFlashReceiver:", address(receiver));
    }
}
