Releases: compolabs/spark-envio-indexer
v0.5.1
[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.5forc 0.63.6fuels-ts v0.94.6.
Full Changelog: v0.5.0...v0.5.1
v0.5.0
[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.5forc 0.63.6fuels-ts v0.94.6.
Added
Market Event Handlers
- MarketRegisterEvent:
A new handler forMarketRegisterEventwas 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
MarketRegisterEventhandler records the registration of a market by mapping the base and quote assets to the market contract address.
- Schema: The following fields were added to the schema for
Market Field in Event Types
-
The
marketfield 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:
Themarketfield 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_idfield was removed from the following event types:TradeOrderEventDepositEventWithdrawEventCancelOrderEventOpenOrderEvent
The
tx_idwas deemed redundant and is now only stored where necessary, improving data efficiency. - The
Refactor Event Handlers
-
Handler Refactor:
- Each event handler (
DepositEventHandler,WithdrawEventHandler,TradeOrderEventHandler,CancelOrderEventHandler) was refactored to include amarketfield and to use the newhandlerWithLoaderpattern. This improves the logic for loading data related to balances and orders, reducing redundant queries.
- Each event handler (
-
Loader Functions:
- Deprecation of Loader Functions:
The explicit loader functions (e.g.,depositEventLoader,cancelOrderEventLoader, etc.) were removed in favor of thehandlerWithLoaderpattern. This provides a more streamlined and efficient way to handle event data without the need for separate loader logic.
- Deprecation of Loader Functions:
Event Handling Improvements
- HandlerWithLoader:
-
The new
handlerWithLoaderpattern was introduced to encapsulate both loading and handling logic within a single function, improving performance and reducing the complexity of event processing. -
Examples:
DepositEventHandlernow loads the relevantBalancedirectly before updating it, reducing redundant database queries.TradeOrderEventHandlerloads 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 thehandlerWithLoadermodel:cancelOrderEventLoaderdepositEventLoaderopenOrderEventLoadertradeOrderEventLoaderwithdrawEventLoader
By consolidating the loading logic into the event handlers, these functions are no longer necessary.
Key Improvements
-
Dynamic Market Support:
With the introduction of themarketfield 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:
ThehandlerWithLoaderpattern optimizes the way events are processed, reducing the number of queries and improving overall performance. -
Simplified Schema:
The removal of unnecessary fields liketx_idand the addition of indexed fields such asmarketenhances the clarity and efficiency of the GraphQL schema.
Full Changelog: v0.4.0...v0.5.0
v0.4.0
[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
OrderBooktype, reducing the amount of computation required to track user balances and trade volumes.
- The indexer is now capable of efficiently indexing contracts of the
Changes in Codebase
-
Version Upgrades:
- Updated
enviopackage from1.1.4-fuelto2.2.4-fuel, enhancing indexing capabilities and compatibility with the Fuel ecosystem.
- Updated
-
GraphQL Schema Enhancements:
- Introduced new fields like
base_amountandquote_amountin multiple event types (OpenOrderEvent,CancelOrderEvent,TradeOrderEvent,DepositEvent, andWithdrawEvent) for more precise balance tracking and event handling.
- Introduced new fields like
-
Refactored Handlers for Efficient Data Processing:
-
OrderBook Event Handling:
- Updated handlers for
OpenOrderEvent,CancelOrderEvent,TradeOrderEvent,DepositEvent, andWithdrawEventto handle event processing based on user and asset balances. - Optimized logic for managing balance updates by removing dependency on
marketConfig.tsand directly calculating balances.
- Updated handlers for
-
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.
- Improved the handling of active buy and sell orders by tracking their status (
-
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.
- Handlers now process order and balance changes synchronously to ensure real-time updates without requiring additional asset lookup through removed
-
-
Loader Improvements:
- Optimized event loaders for
CancelOrder,Deposit,OpenOrder,TradeOrder, andWithdrawto streamline balance loading and reduce unnecessary data lookups.
- Optimized event loaders for
-
Removed Unused Configuration:
- Removed the unused
marketConfig.tsfile, which contained predefined constants for base and quote assets, as this is now dynamically handled within the event handlers.
- Removed the unused
Bug Fixes
- Balance Calculation Fixes:
- Corrected balance calculation logic to ensure proper crediting and debiting of
base_amountandquote_amountacross various event handlers, improving accuracy in tracking users' balances.
- Corrected balance calculation logic to ensure proper crediting and debiting of
Full Changelog: v0.1.0...v0.4.0
v0.1.0
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:
DepositEventWithdrawEvent
- The following events were added to the configuration:
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.
- The following event types were added to the schema:
-
Updated Event Types:
- The
CancelOrderEventtype now includes theuserfield to track which user canceled the order. - The
TradeOrderEventtype now includessellerandbuyerfields to track participants in the trade.
- The
-
Removed Event Type:
- The
MatchOrderEventtype was removed, simplifying the schema by eliminating unused event types.
- The
-
New Balance Type:
- A
Balancetype 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.
- A
Changes in Handlers (OrderBookHandlers.ts)
-
Added Handlers for New Events:
DepositEventandWithdrawEventhandlers were added to handle user deposits and withdrawals, updating the user balances accordingly.
-
Balance Adjustments:
- Handlers for
CancelOrderEventandTradeOrderEventnow update user balances when orders are canceled or trades are executed.
- Handlers for
-
Removed Match Order Logic:
- The logic and handler for
MatchOrderEventwere removed as the event is no longer part of the schema.
- The logic and handler for
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
Changelog for BTC-USDC Market
[v0.0.5] - 2024-08-27
Changes in Configuration for BTC-USDC Market (config.yaml)
-
Updated Contract Address:
- The
addressfor theOrderBookcontract in theconfig.yamlwas updated:- Old Address:
0x58959d086d8a6ee8cf8eeb572b111edb21661266be4b4885383748d11b72d0aa - New Address:
0x9bc5f33c9a1bec6461500cd85b3ba1d8f0094a865b6b9c4367631e4111d0305d- BTC-USDC Market
- Old Address:
- The
-
Removed Unused Events:
- The following events were removed from the configuration:
DepositEventWithdrawEvent
- The following events were removed from the configuration:
Changes in GraphQL Schema (schema.graphql)
-
Removed
AssetTypeEnum:- The
AssetTypeenum was removed from the schema. This change simplifies the data model by removing unnecessary definitions.
- The
-
Removed Event Types:
- The following event types were removed from the schema:
DepositEventWithdrawEvent
- The following event types were removed from the schema:
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
Changelog
[v0.0.4] - 2024-08-26
Changes in GraphQL Schema (schema.graphql)
-
Removal of
asset_typefield:- The
asset_typefield has been removed from the following types:OpenOrderEventOrderActiveSellOrderActiveBuyOrder
This change may impact API integrations that use these types, as the asset type (
AssetType) data is no longer transmitted. - The
-
Updated Types:
- The types
Order,ActiveSellOrder, andActiveBuyOrdernow contain only the following fields:idassetamountorder_typepriceuser
- The types
-
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
Changelog
[v0.0.3] - 2024-08-27
Changes in Configuration (config.yaml)
- Updated Hypersync URL:
- The
urlfor thehypersync_configin thenetworkssection was updated:- Old URL:
https://fuel-testnet-resync.hypersync.xyz - New URL:
https://fuel-testnet.hypersync.xyz
- Old URL:
- The
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
Changelog
[v0.0.2] - 2024-08-27
Changes in Documentation (README.md)
-
Updated Contract Link:
- The link to the contract in the
README.mdfile 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
- Old Link:
- The link to the contract in the
-
Removed Redundant Information:
- The sentence referring to rebuilding the project with Envio (
Rebuild the https://github.com/compolabs/orderbook-indexer with Envio.) was removed.
- The sentence referring to rebuilding the project with Envio (
-
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 } }
- Example query to fetch active orders:
- Added a section demonstrating how to query the indexer, including examples of GraphQL queries to fetch active orders and filter orders by user:
Full Changelog: v0.0.1...v0.0.2
Release v0.0.1
Changelog
[v0.0.1] - 2024-08-27
Changes in Configuration (config.yaml)
- Added Hypersync Configuration:
- Introduced
hypersync_configto the network configuration, enabling synchronization with the following URL:https://fuel-testnet-resync.hypersync.xyz
- Introduced
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
Production version with contract 0x7278edd30be6b982d3196ffb2790321d8546814226e51e82c8136c8f6d3c0c97