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.5
forc 0.63.6
fuels-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.5
forc 0.63.6
fuels-ts v0.94.6
.
Added
Market Event Handlers
- MarketRegisterEvent:
A new handler forMarketRegisterEvent
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.
- Schema: The following fields were added to the schema for
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:
Themarket
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. - The
Refactor Event Handlers
-
Handler Refactor:
- Each event handler (
DepositEventHandler
,WithdrawEventHandler
,TradeOrderEventHandler
,CancelOrderEventHandler
) was refactored to include amarket
field and to use the newhandlerWithLoader
pattern. 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 thehandlerWithLoader
pattern. 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
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 relevantBalance
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 thehandlerWithLoader
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 themarket
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:
ThehandlerWithLoader
pattern optimizes the way events are processed, reducing the number of queries and improving overall performance. -
Simplified Schema:
The removal of unnecessary fields liketx_id
and the addition of indexed fields such asmarket
enhances 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
OrderBook
type, 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
envio
package from1.1.4-fuel
to2.2.4-fuel
, enhancing indexing capabilities and compatibility with the Fuel ecosystem.
- Updated
-
GraphQL Schema Enhancements:
- Introduced new fields like
base_amount
andquote_amount
in 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
, andWithdrawEvent
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.
- 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
, andWithdraw
to streamline balance loading and reduce unnecessary data lookups.
- Optimized event loaders for
-
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.
- Removed the unused
Bug Fixes
- Balance Calculation Fixes:
- Corrected balance calculation logic to ensure proper crediting and debiting of
base_amount
andquote_amount
across 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:
DepositEvent
WithdrawEvent
- 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
CancelOrderEvent
type now includes theuser
field to track which user canceled the order. - The
TradeOrderEvent
type now includesseller
andbuyer
fields to track participants in the trade.
- The
-
Removed Event Type:
- The
MatchOrderEvent
type was removed, simplifying the schema by eliminating unused event types.
- The
-
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.
- A
Changes in Handlers (OrderBookHandlers.ts)
-
Added Handlers for New Events:
DepositEvent
andWithdrawEvent
handlers were added to handle user deposits and withdrawals, updating the user balances accordingly.
-
Balance Adjustments:
- Handlers for
CancelOrderEvent
andTradeOrderEvent
now update user balances when orders are canceled or trades are executed.
- Handlers for
-
Removed Match Order Logic:
- The logic and handler for
MatchOrderEvent
were 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
address
for theOrderBook
contract in theconfig.yaml
was updated:- Old Address:
0x58959d086d8a6ee8cf8eeb572b111edb21661266be4b4885383748d11b72d0aa
- New Address:
0x9bc5f33c9a1bec6461500cd85b3ba1d8f0094a865b6b9c4367631e4111d0305d
- BTC-USDC Market
- Old Address:
- The
-
Removed Unused Events:
- The following events were removed from the configuration:
DepositEvent
WithdrawEvent
- The following events were removed from the configuration:
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.
- The
-
Removed Event Types:
- The following event types were removed from the schema:
DepositEvent
WithdrawEvent
- 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_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. - The
-
Updated Types:
- The types
Order
,ActiveSellOrder
, andActiveBuyOrder
now contain only the following fields:id
asset
amount
order_type
price
user
- 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
url
for thehypersync_config
in thenetworks
section 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.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
- 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_config
to 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