abstract contract Aggregator is Ownable {
    using Address for address;

    AggregatorV3Interface private _aggregator;
    int256 private _price = 0;
    bool private _isTrandUp = true;

    /**
     * @dev Emitted when agregator changes to `newAggregator`.
     */
    event UpdateAggregator(address indexed newAggregator);

    /**
     * @dev Updates the oracle used to receive market data.
     *
     * Can be called by the contract owner.
     */
    function updateAggregator(address newAggregator) public virtual onlyOwner {
        require(newAggregator.isContract(), "Address: call to non-contract");

        _aggregator = AggregatorV3Interface(newAggregator);
        updateTrand();

        emit UpdateAggregator(newAggregator);
    }

    /**
     * @dev Checks if the market trend is upward (bullish).
     */
    function isTrandUp() public view virtual returns (bool) {
        return _isTrandUp;
    }

    /**
     * @dev Updates the trend information.
     */
    function updateTrand() public virtual {
        (, int256 price, , , ) = _aggregator.latestRoundData();

        if (price != _price) {
            _isTrandUp = price > _price;
            _price = price;
        }
    }
}
/**
 * @dev Wrapper for chainlink oracle (AggregatorV3Interface)
 */
function updateTrand() public virtual {
    (, int256 price, , , ) = _aggregator.latestRoundData();

    if (price != _price) {
        _isTrandUp = price > _price;
        _price = price;
    }
}

/**
 * @dev Updates the trend information.
 */