How to Query our Contracts
The SYMM Diamond
SYMMIO's core contracts are implemented with EIP-2535, a solution for building modular and upgradeable contracts.
EIP-2535: Diamond Standard Overview
EIP-2535 introduces the Diamond Standard in smart contract development. This standard centralizes around the concept of a "Diamond" contract, which is constructed from multiple "facets," each responsible for different functionalities. This modular design enhances maintainability by allowing facets to be upgraded or modified independently without affecting the entire contract. Key to this architecture are function selectors, which serve as unique identifiers for each function within the facets. These selectors efficiently direct function calls to the correct facet, facilitating organized and conflict-free code execution. For further reading and technical details, refer to the official EIP-2535 documentation.
When a facet, is invoked via a delegatecall
from the Diamond, it operates directly on the Diamondâs storage. The facet uses the slot address computed by the library to access or modify the data in the specific storage slot. This operation is transparent to the Diamond itself.
Finding Facet Contracts
In the SYMM Diamond, the facets()
function of the DiamondLoupeFacet
plays a crucial role in inspecting the contract's structure and behaviour. When this function is called on the Diamond, it returns an array of Facet
structs, each containing the address of a facet along with the specific function selectors associated with that facet.
To examine the facets and call functions on them, we'll use a tool called Louper. This platform displays all facets and functions related to a Diamond contract and allows us to query data directly from them. Since functions cannot be called on through the Diamond contract directly through a blockchain explorer, Louper provides an efficient and user-friendly way to interact with the Diamond.
Using Louper to Read Data
In this example, we'll use Louper to find all the contract symbols available to trade on Thena.
First, paste the address into the tool and select the appropriate chain (BNB):
Then, click the Read tab, and select the View Facet. This shows all the view functions available to query on the Diamond.
Now you can query the symbols available to trade on the Diamond using getSymbols()
with start
and size
as parameters:
For more information on the View Facet's functions, please refer to the ViewFacet documentation (0.8.2).
Using Subgraphs to Query Data
The Graph is a decentralized protocol for indexing and querying blockchain data. You can also query data on the diamond using a subgraph URL provided by SYMM. In this example, we'll query the symbol data using the Apollo Client.
Prerequisites
Basic understanding of GraphQL
A tool for making HTTP requests, such as Postman, cURL, or a GraphQL client like Apollo Client
Endpoint URL
First identify a suitable endpoint:
This endpoint is the analytics endpoint for the SYMMIO Diamond on BNB.
Example Query
To fetch data, send a POST request to the endpoint with the GraphQL query:
Using cURL
Using Apollo Client in React
Install Apollo Client:
Set up Apollo Client and make the query:
Subgraph URLs by Chain
Arbitrum
Main Subgraph
https://api.studio.thegraph.com/query/62454/main_arbitrum_8_2/version/latest
Analytics Subgraph
https://api.studio.thegraph.com/query/62454/analytics_arbitrum_8_2/version/latest
Parties Subgraph
https://api.studio.thegraph.com/query/62454/parties_arbitrum_8_2/version/latest
Funding Rate Subgraph
https://api.studio.thegraph.com/query/62454/fundingrate_arbitrum_8_2/version/latest
Events Subgraph
https://api.studio.thegraph.com/query/62454/events_arbitrum_8_2/version/latest
Mantle
Main Subgraph
https://subgraph-api.mantle.xyz/subgraphs/name/main_mantle_8_2
Analytics Subgraph
https://subgraph-api.mantle.xyz/subgraphs/name/analytics_mantle_8_2/graphql
Parties Subgraph
https://subgraph-api.mantle.xyz/subgraphs/name/parties_mantle_8_2/graphql
Funding Rate Subgraph
https://subgraph-api.mantle.xyz/subgraphs/name/parties_mantle_8_2/graphql
Blast
Main Subgraph
https://api.studio.thegraph.com/query/62454/main_blast_8_2/version/latest
Analytics Subgraph
https://api.studio.thegraph.com/query/62454/analytics_blast_8_2/version/latest
Parties Subgraph
https://api.studio.thegraph.com/query/62454/parties_blast_8_2/version/latest
Funding Rate Subgraph
https://api.studio.thegraph.com/query/62454/fundingrate_blast_8_2/version/latest
Events Subgraph
https://api.studio.thegraph.com/query/62454/events_blast_8_2/version/latest
BNB
Main Subgraph
https://api.studio.thegraph.com/query/62454/main_bnb_8_2/version/latest
Analytics Subgraph
https://api.studio.thegraph.com/query/62454/analytics_bnb_8_2/version/latest
Parties Subgraph
https://api.studio.thegraph.com/query/62454/parties_bnb_8_2/version/latest
Funding Rate Subgraph
https://api.studio.thegraph.com/query/62454/fundingrate_bnb_8_2/version/latest
Events Subgraph
https://api.studio.thegraph.com/query/62454/events_bnb_8_2/version/latest
Base
Main Subgraph
https://api.studio.thegraph.com/query/62454/main_base_8_2/version/latest
Analytics Subgraph
https://api.studio.thegraph.com/query/62454/analytics_base_8_2/version/latest
Parties Subgraph
https://api.studio.thegraph.com/query/62454/parties_base_8_2/version/latest
Funding Rate Subgraph
https://api.studio.thegraph.com/query/62454/fundingrate_base_8_2/version/latest
Events Subgraph
https://api.studio.thegraph.com/query/62454/events_base_8_2/version/latest
Last updated