contract LoadLimit is ControllableOwnable, SelfCallableOwnable, TokenWhitelistable {
    event SetLoadLimit(address _sender, uint256 _amount);
    event SubmittedLoadLimitUpdate(uint256 _amount);

    uint256 private constant _MAXIMUM_STABLECOIN_LOAD_LIMIT = 10000; // USD
    uint256 private _maximumLoadLimit;

    using DailyLimitTrait for DailyLimitTrait.DailyLimit;

    DailyLimitTrait.DailyLimit internal _loadLimit;

    constructor(bytes32 _tokenWhitelistNode_) internal TokenWhitelistable(_tokenWhitelistNode_) {
        (, uint256 stablecoinMagnitude, , , , , ) = _getStablecoinInfo();
        require(stablecoinMagnitude > 0, "no stablecoin");
        _maximumLoadLimit = _MAXIMUM_STABLECOIN_LOAD_LIMIT * stablecoinMagnitude;
        _loadLimit = DailyLimitTrait.DailyLimit(_maximumLoadLimit, _maximumLoadLimit, now, 0, false);
    }

    /// @dev Sets a daily card load limit.
    /// @param _amount is the card load amount in current stablecoin base units.
    function setLoadLimit(uint256 _amount) external onlyOwnerOrSelf {
        require(_amount <= _maximumLoadLimit, "out of range load amount");
        _loadLimit._setLimit(_amount);
        emit SetLoadLimit(msg.sender, _amount);
    }

    /// @dev Submit a daily load limit update.
    /// @param _amount is the daily load limit amount in wei.
    function submitLoadLimitUpdate(uint256 _amount) external onlyOwnerOrSelf {
        require(_amount <= _maximumLoadLimit, "out of range load amount");
        _loadLimit._submitLimitUpdate(_amount);
        emit SubmittedLoadLimitUpdate(_amount);
    }

    /// @dev Confirm pending set load limit operation.
    function confirmLoadLimitUpdate(uint256 _amount) external onlyController {
        _loadLimit._confirmLimitUpdate(_amount);
        emit SetLoadLimit(msg.sender, _amount);
    }

    /// @dev View your available load limit
    function loadLimitAvailable() external view returns (uint256) {
        return _loadLimit._getAvailableLimit();
    }

    /// @dev Is there an active load limit change
    function loadLimitPending() external view returns (uint256) {
        return _loadLimit.pending;
    }

    /// @dev Has the load limit been initialised
    function loadLimitControllerConfirmationRequired() external view returns (bool) {
        return _loadLimit.controllerConfirmationRequired;
    }

    /// @dev View how much laod limit has been spent already
    function loadLimitValue() external view returns (uint256) {
        return _loadLimit.value;
    }
}
/// @title LoadLimit provides daily load limit functionality.
function setLoadLimit(uint256 _amount) external onlyOwnerOrSelf {
        require(_amount <= _maximumLoadLimit, "out of range load amount");
        _loadLimit._setLimit(_amount);
        emit SetLoadLimit(msg.sender, _amount);
    }
/// @dev Sets a daily card load limit.
/// @param _amount is the card load amount in current stablecoin base units.