contract AESCollateralMultisig is MultiSigWallet {
    event DepositCollateral(
        uint256 amount,
        address indexed sender,
        address indexed token,
        string indexed aeAddress
    );

    event WithdrawCollateral(
        uint256 amount,
        address indexed receiver,
        address indexed token,
        string indexed burnTxHash
    );

    using SafeERC20 for IERC20;

    mapping(address => bool) public collateral;

    /// @dev Allows to deposit collateral token. Transaction can to be sent by everyone.
    /// To the given AE Address, the same amount of tokens will be minted.
    function deposit(uint256 amount, address token, string calldata aeAddress) external {
        require(collateral[token], "INVALID_COLLATERAL");

        require(amount > 0, "INVALID_AMOUNT");

        address sender = msg.sender;

        IERC20(token).safeTransferFrom(sender, address(this), amount);

        emit DepositCollateral(amount, sender, token, aeAddress);
    }
    
    
    constructor(address[] memory _owners, uint256 _required) MultiSigWallet(_owners, _required) public {
        collateral[address(0x6B175474E89094C44Da98b954EedeAC495271d0F)] = true;
    }

    /// @dev Allows to withdraw collateral token. Transaction has to be sent by wallet.
    /// Burn transaction hash must be provided i.e. Aeternity TX hash proving the burn.
    function withdraw(
        uint256 amount,
        address token,
        address receiver,
        string calldata burnTxHash
    ) external onlyWallet {
        IERC20(token).safeTransfer(receiver, amount);
        emit WithdrawCollateral(amount, receiver, token, burnTxHash);
    }

    /// @dev Allows to add a new token collateral. Transaction has to be sent by wallet.
    /// @param token Address of token e.g. DAI, USDC...
    function addCollateralToken(address token) external onlyWallet {
        collateral[token] = true;
    }

    /// @dev Allows to remove token collateral. Transaction has to be sent by wallet.
    /// @param token Address of token e.g. DAI, USDC...
    function removeCollateralToken(address token) external onlyWallet {
        collateral[token] = false;
    }

    function collateralBalance(address token) public view returns(uint256) {
        return IERC20(token).balanceOf(address(this));
    }
}
function addCollateralToken(address token) external onlyWallet {
    collateral[token] = true;
}

/// @dev Allows to add a new token collateral. Transaction has to be sent by wallet.
/// @param token Address of token e.g. DAI, USDC...