Skip to content

Releases: compolabs/spark-envio-indexer

v0.5.1

01 Oct 19:26
Compare
Choose a tag to compare

[v0.5.1] - 2024-10-01

Overview

No serious updates from v0.5.0

Spark Registry: 0xfc3439e66c15c0b8e8e02e0fe4951eecd6001639a6aa8a650885af62ea92540f

Release supports the latest updates of key libraries and tools:

  • fuels-rs v0.66.5
  • forc 0.63.6
  • fuels-ts v0.94.6.

Full Changelog: v0.5.0...v0.5.1

v0.5.0

27 Sep 21:39
Compare
Choose a tag to compare

[v0.5.0] - 2024-09-28

Overview

This release introduces significant changes to support dynamic market contracts, moving from a static market structure to a dynamic, multi-contract approach. The key focus of version 0.5.0 is to handle multiple markets more efficiently by adding market identifiers to events and refactoring the event handler logic. Additionally, there are improvements in schema structure and handler performance. Release supports the latest updates of key libraries and tools:

  • fuels-rs v0.66.5
  • forc 0.63.6
  • fuels-ts v0.94.6.

Added

Market Event Handlers

  • MarketRegisterEvent:
    A new handler for MarketRegisterEvent was added to track the registration of new markets.
    • Schema: The following fields were added to the schema for MarketRegisterEvent:
      • id: The unique identifier for the event.
      • base_asset: The base asset of the market, indexed for querying.
      • quote_asset: The quote asset of the market, indexed for querying.
      • market: The address of the market contract, indexed.
      • timestamp: The time when the event occurred.
      • tx_id: Transaction ID associated with the market registration event.
    • Handler: The MarketRegisterEvent handler records the registration of a market by mapping the base and quote assets to the market contract address.

Market Field in Event Types

  • The market field was added to multiple event types to support handling of balances and orders across different markets:

    • DepositEvent
    • WithdrawEvent
    • TradeOrderEvent
    • OpenOrderEvent
    • CancelOrderEvent
    • ActiveSellOrder
    • ActiveBuyOrder
    • Balance

    This ensures that each event is tied to a specific market, enabling dynamic contract support.


Updated

GraphQL Schema Enhancements

  • Market Field Addition:
    The market field was added to the following GraphQL types:

    • DepositEvent
    • WithdrawEvent
    • TradeOrderEvent
    • CancelOrderEvent
    • OpenOrderEvent
    • ActiveSellOrder
    • ActiveBuyOrder
    • Balance

    This change allows each event or balance to be associated with a specific market contract and supports querying of data by market.

  • Event Schema Changes:

    • The tx_id field was removed from the following event types:
      • TradeOrderEvent
      • DepositEvent
      • WithdrawEvent
      • CancelOrderEvent
      • OpenOrderEvent

    The tx_id was deemed redundant and is now only stored where necessary, improving data efficiency.

Refactor Event Handlers

  • Handler Refactor:

    • Each event handler (DepositEventHandler, WithdrawEventHandler, TradeOrderEventHandler, CancelOrderEventHandler) was refactored to include a market field and to use the new handlerWithLoader pattern. This improves the logic for loading data related to balances and orders, reducing redundant queries.
  • Loader Functions:

    • Deprecation of Loader Functions:
      The explicit loader functions (e.g., depositEventLoader, cancelOrderEventLoader, etc.) were removed in favor of the handlerWithLoader pattern. This provides a more streamlined and efficient way to handle event data without the need for separate loader logic.

Event Handling Improvements

  • HandlerWithLoader:
    • The new handlerWithLoader pattern was introduced to encapsulate both loading and handling logic within a single function, improving performance and reducing the complexity of event processing.

    • Examples:

      • DepositEventHandler now loads the relevant Balance directly before updating it, reducing redundant database queries.
      • TradeOrderEventHandler loads both the buyer’s and seller’s balances and updates them atomically, ensuring that trade data is processed efficiently across dynamic markets.

Removed

Loader Functions

  • Deprecated Loader Functions:
    The following loader functions were removed as part of the migration to the handlerWithLoader model:

    • cancelOrderEventLoader
    • depositEventLoader
    • openOrderEventLoader
    • tradeOrderEventLoader
    • withdrawEventLoader

    By consolidating the loading logic into the event handlers, these functions are no longer necessary.


Key Improvements

  • Dynamic Market Support:
    With the introduction of the market field across events and balances, the indexer now fully supports dynamic market contracts. This is a shift from the previous static market model, allowing for greater flexibility in handling multiple contracts.

  • Optimized Event Handling:
    The handlerWithLoader pattern optimizes the way events are processed, reducing the number of queries and improving overall performance.

  • Simplified Schema:
    The removal of unnecessary fields like tx_id and the addition of indexed fields such as market enhances the clarity and efficiency of the GraphQL schema.

Full Changelog: v0.4.0...v0.5.0

v0.4.0

16 Sep 13:33
Compare
Choose a tag to compare

[v0.4.0] - 2024-08-27

This release enables Envio to process contracts deployed using the latest versions of fuels-rs (v0.66.4) and forc (v0.63.5), with fuels-ts (v0.94.6) being used by the indexer.

  • Optimized Indexing for OrderBook Contracts:
    • The indexer is now capable of efficiently indexing contracts of the OrderBook type, reducing the amount of computation required to track user balances and trade volumes.

Changes in Codebase

  • Version Upgrades:

    • Updated envio package from 1.1.4-fuel to 2.2.4-fuel, enhancing indexing capabilities and compatibility with the Fuel ecosystem.
  • GraphQL Schema Enhancements:

    • Introduced new fields like base_amount and quote_amount in multiple event types (OpenOrderEvent, CancelOrderEvent, TradeOrderEvent, DepositEvent, and WithdrawEvent) for more precise balance tracking and event handling.
  • Refactored Handlers for Efficient Data Processing:

    • OrderBook Event Handling:

      • Updated handlers for OpenOrderEvent, CancelOrderEvent, TradeOrderEvent, DepositEvent, and WithdrawEvent to handle event processing based on user and asset balances.
      • Optimized logic for managing balance updates by removing dependency on marketConfig.ts and directly calculating balances.
    • Active Orders:

      • Improved the handling of active buy and sell orders by tracking their status (Active, Closed, Canceled) and updating corresponding user balances after each order action.
    • Order and Balance Updates:

      • Handlers now process order and balance changes synchronously to ensure real-time updates without requiring additional asset lookup through removed marketConfig.ts.
  • Loader Improvements:

    • Optimized event loaders for CancelOrder, Deposit, OpenOrder, TradeOrder, and Withdraw to streamline balance loading and reduce unnecessary data lookups.
  • Removed Unused Configuration:

    • Removed the unused marketConfig.ts file, which contained predefined constants for base and quote assets, as this is now dynamically handled within the event handlers.

Bug Fixes

  • Balance Calculation Fixes:
    • Corrected balance calculation logic to ensure proper crediting and debiting of base_amount and quote_amount across various event handlers, improving accuracy in tracking users' balances.

Full Changelog: v0.1.0...v0.4.0

v0.1.0

05 Sep 21:51
Compare
Choose a tag to compare

Changelog for Spark Order Book

[v0.1.0] - 2024-09-06

Changes in Configuration for Spark Order Book (config.yaml)

  • Added New Events:
    • The following events were added to the configuration:
      • DepositEvent
      • WithdrawEvent

Changes in GraphQL Schema (schema.graphql)

  • New Event Types:

    • The following event types were added to the schema:
      • DepositEvent: Tracks asset deposits by users.
      • WithdrawEvent: Tracks asset withdrawals by users.
  • Updated Event Types:

    • The CancelOrderEvent type now includes the user field to track which user canceled the order.
    • The TradeOrderEvent type now includes seller and buyer fields to track participants in the trade.
  • Removed Event Type:

    • The MatchOrderEvent type was removed, simplifying the schema by eliminating unused event types.
  • New Balance Type:

    • A Balance type was introduced to track user balances of assets within the system. This type includes fields:
      • id: The unique identifier of the balance.
      • amount: The amount of the asset the user holds.
      • asset: The type of asset (base or quote).
      • user: The user associated with the balance.
      • timestamp: The last updated time of the balance.

Changes in Handlers (OrderBookHandlers.ts)

  • Added Handlers for New Events:

    • DepositEvent and WithdrawEvent handlers were added to handle user deposits and withdrawals, updating the user balances accordingly.
  • Balance Adjustments:

    • Handlers for CancelOrderEvent and TradeOrderEvent now update user balances when orders are canceled or trades are executed.
  • Removed Match Order Logic:

    • The logic and handler for MatchOrderEvent were removed as the event is no longer part of the schema.

These changes bring improvements to the event tracking system and the management of user balances, while simplifying the schema by removing unused elements.

Full Changelog: v0.0.5...v0.1.0

Release v0.0.5

30 Aug 08:32
Compare
Choose a tag to compare

Changelog for BTC-USDC Market

[v0.0.5] - 2024-08-27

Changes in Configuration for BTC-USDC Market (config.yaml)

  • Updated Contract Address:

    • The address for the OrderBook contract in the config.yaml was updated:
      • Old Address: 0x58959d086d8a6ee8cf8eeb572b111edb21661266be4b4885383748d11b72d0aa
      • New Address: 0x9bc5f33c9a1bec6461500cd85b3ba1d8f0094a865b6b9c4367631e4111d0305d - BTC-USDC Market
  • Removed Unused Events:

    • The following events were removed from the configuration:
      • DepositEvent
      • WithdrawEvent

Changes in GraphQL Schema (schema.graphql)

  • Removed AssetType Enum:

    • The AssetType enum was removed from the schema. This change simplifies the data model by removing unnecessary definitions.
  • Removed Event Types:

    • The following event types were removed from the schema:
      • DepositEvent
      • WithdrawEvent

These changes reflect updates to the contract address, removal of unused events, and simplification of the schema by removing unnecessary types and enums.

Full Changelog: v0.0.4...v0.0.5

Release v0.0.4

27 Aug 07:51
Compare
Choose a tag to compare

Changelog

[v0.0.4] - 2024-08-26

Changes in GraphQL Schema (schema.graphql)

  • Removal of asset_type field:

    • The asset_type field has been removed from the following types:
      • OpenOrderEvent
      • Order
      • ActiveSellOrder
      • ActiveBuyOrder

    This change may impact API integrations that use these types, as the asset type (AssetType) data is no longer transmitted.

  • Updated Types:

    • The types Order, ActiveSellOrder, and ActiveBuyOrder now contain only the following fields:
      • id
      • asset
      • amount
      • order_type
      • price
      • user
  • General Improvements:

    • Structural data optimizations have been made to simplify the model and improve query performance.

[v0.0.3] - 2024-08-20

Additions and Fixes

Full Changelog: v0.0.3...v0.0.4

Release v0.0.3

20 Aug 19:28
Compare
Choose a tag to compare

Changelog

[v0.0.3] - 2024-08-27

Changes in Configuration (config.yaml)

  • Updated Hypersync URL:
    • The url for the hypersync_config in the networks section was updated:
      • Old URL: https://fuel-testnet-resync.hypersync.xyz
      • New URL: https://fuel-testnet.hypersync.xyz

This change points the network configuration to the updated Hypersync endpoint for the Fuel testnet.

Full Changelog: v0.0.2...v0.0.3

Release v0.0.2

19 Aug 11:50
Compare
Choose a tag to compare

Changelog

[v0.0.2] - 2024-08-27

Changes in Documentation (README.md)

  • Updated Contract Link:

    • The link to the contract in the README.md file has been updated:
      • Old Link: https://github.com/compolabs/orderbook-contract/blob/cfd0ca883b95f7ebcaf638b2e98fd3c001e6a9b7/src/constants.rs#L3
      • New Link: https://github.com/compolabs/orderbook-contract/tree/master/market-contract
  • Removed Redundant Information:

    • The sentence referring to rebuilding the project with Envio (Rebuild the https://github.com/compolabs/orderbook-indexer with Envio.) was removed.
  • Added Query Examples:

    • Added a section demonstrating how to query the indexer, including examples of GraphQL queries to fetch active orders and filter orders by user:
      • Example query to fetch active orders:
        query MyQuery {
          Order(where: {status: {_eq: "Active"}}) {
            id
            initial_amount
            status
            price
            amount
            order_type
          }
        }
      • Example query to fetch orders filtered by user:
        query MyQuery {
          Order(where: {user: {_eq: ""}}) {
            id
            initial_amount
            status
            price
            amount
            order_type
            asset_type
          }
        }

Full Changelog: v0.0.1...v0.0.2

Release v0.0.1

16 Aug 15:14
Compare
Choose a tag to compare

Changelog

[v0.0.1] - 2024-08-27

Changes in Configuration (config.yaml)

  • Added Hypersync Configuration:
    • Introduced hypersync_config to the network configuration, enabling synchronization with the following URL:
      • https://fuel-testnet-resync.hypersync.xyz

This change adds the necessary configuration to enable Hypersync support for the Fuel testnet in the indexer.

Full Changelog: v0.0.0...v0.0.1

Release v0.0.0

16 Aug 15:52
Compare
Choose a tag to compare

Production version with contract 0x7278edd30be6b982d3196ffb2790321d8546814226e51e82c8136c8f6d3c0c97