// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

interface IUnipilotStaking {
    function stake(address _to, uint256 _amount) external;

    function setGovernance(address _newGovernance) external;

    function updateRewards(uint256 _reward, uint256 _rewardDurationInBlocks) external;
}

interface IPilot {
    function approve(address spender, uint256 amount) external returns (bool);
}

contract UnipilotStakingSetup {
    IUnipilotStaking public unipilotStaking;
    IPilot public pilotToken;

    constructor(IPilot _pilotToken) {
        pilotToken = _pilotToken;
    }

    function setStakingAddress(IUnipilotStaking _unipilotStaking) external {
        unipilotStaking = _unipilotStaking;
    }

    function doSetup(
        address _stakeAddr,
        address _governance,
        uint256 _amount,
        uint256 _rewardToDistribute,
        uint256 _rewardDuration
    ) external {
        // approve pilot
        pilotToken.approve(address(unipilotStaking), type(uint256).max);

        // update rewards
        unipilotStaking.updateRewards(_rewardToDistribute, _rewardDuration);

        // stake pilot
        unipilotStaking.stake(_stakeAddr, _amount);

        // set governance
        unipilotStaking.setGovernance(_governance);
    }
}
[{"inputs":[{"internalType":"contract IPilot","name":"_pilotToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_stakeAddr","type":"address"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_rewardToDistribute","type":"uint256"},{"internalType":"uint256","name":"_rewardDuration","type":"uint256"}],"name":"doSetup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pilotToken","outputs":[{"internalType":"contract IPilot","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IUnipilotStaking","name":"_unipilotStaking","type":"address"}],"name":"setStakingAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unipilotStaking","outputs":[{"internalType":"contract IUnipilotStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"}]