I have an odd use case, in that I would like to get the price of a token at or before a certain block. This is working fine if there have been previous trades (as per below query). But it runs into issued if there have been no previous trades. Is there a way I can expand the query to look for price action events outside the scope of trades, such as an addLiquidity event, which will produce a price based on the initial reserves in the LP? Can this be tied into the query below or would it need to be a new query altogether for this specific case?
Hi @stcroix your GraphQL query filters the blocks in the descending order of their height which means that the particular height: {lteq: 9939407} might not have got rendered. I tried the same query with a different height parameter and it worked.
Yes there is way you can expand the scope of the query outside dexTrades by using aliasing. An example of the same is shown below. However, you can read more about aliasing in Bitquery from here: How to use GraphQL Alias and Aggregation?
If you using “aliasing” just like in the above query in the GraphQL IDE you need to use the dropdown provided in the IDE in order to switch between the aliased queries as shown in the image below.
Thanks again @sayon - The aliasing is very interesting! Can you please explain more about why my initial query didn’t work because of the block height filtering? As thats the actual block I want to start searching backwards from.
My use of the term “price action” may be incorrect. Essentially what i’m wanting the query to do is: "get the last spot price of the token as of block 9939407, even if there have been no trades (using other events to determine the price if that’s the case)