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

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

/// @notice M1 vault basket for ALL Mainnet (651940): AUSDC, AUSDT, WALL.
contract DeployAcVdcSdcVaults651940 is Script {
    uint8 constant DECIMALS = 6;
    bool constant DEBT_TRANSFERABLE = true;
    uint8 constant GRU_TIER_M1 = 2;

    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address deployer = vm.addr(pk);
        address owner = vm.envOr("OWNER", deployer);
        address entity = vm.envOr("ENTITY", vm.envOr("GRU_OMNL_ENTITY_ADDRESS", deployer));
        address factoryAddr = vm.envAddress("VAULT_FACTORY_ADDRESS");
        VaultFactory factory = VaultFactory(factoryAddr);

        bytes32 ibanHash = vm.envBytes32("GRU_IBAN_HASH");
        bytes32 policyProfileKey = vm.envOr("GRU_POLICY_PROFILE_KEY", bytes32(0));

        address[] memory bases = new address[](3);
        string[] memory labels = new string[](3);
        bases[0] = vm.envAddress("CUSDC_ADDRESS_651940");
        labels[0] = "AUSDC";
        bases[1] = vm.envAddress("AUSDT_ADDRESS_651940");
        labels[1] = "AUSDT";
        bases[2] = vm.envAddress("WALL_ADDRESS_651940");
        labels[2] = "WALL";

        uint256 startIdx = vm.envOr("GRU_VAULT_START_INDEX", uint256(0));
        uint256 endIdx = vm.envOr("GRU_VAULT_END_INDEX", bases.length);

        vm.startBroadcast(pk);
        for (uint256 i = startIdx; i < endIdx && i < bases.length; i++) {
            (address vault, address depositToken, address debtToken) = factory.createVaultWithDecimalsGRU(
                owner,
                entity,
                bases[i],
                bases[i],
                DECIMALS,
                DECIMALS,
                DEBT_TRANSFERABLE,
                GRU_TIER_M1,
                ibanHash,
                policyProfileKey
            );
            console.log(string.concat(labels[i], " vault:"), vault);
            console.log(string.concat("ac", labels[i], ":"), depositToken);
            console.log(string.concat("vdc", labels[i], ":"), debtToken);
        }
        vm.stopBroadcast();
    }
}
