library P1IndexMath {

    // ============ Constants ============

    uint256 private constant FLAG_IS_POSITIVE = 1 << (8 * 16);

    // ============ Functions ============

    /**
     * @dev Returns a compressed bytes32 representation of the index for logging.
     */
    function toBytes32(
        P1Types.Index memory index
    )
        internal
        pure
        returns (bytes32)
    {
        uint256 result =
            index.value
            | (index.isPositive ? FLAG_IS_POSITIVE : 0)
            | (uint256(index.timestamp) << 136);
        return bytes32(result);
    }
}
/**
 * @title P1IndexMath
 * @author dYdX
 *
 * @dev Library for manipulating P1Types.Index structs.
 */
function toBytes32(
    P1Types.Index memory index
)
    internal
    pure
    returns (bytes32)
{
    uint256 result =
        index.value
        | (index.isPositive ? FLAG_IS_POSITIVE : 0)
        | (uint256(index.timestamp) << 136);
    return bytes32(result);
}

/**
 * @dev Returns a compressed bytes32 representation of the index for logging.
 */