There have been times where Synthetix.exchange() invocations were in the same block yet positioned before ExchangeRate.updateRates() and traded on a price that changed in the latter transaction. When we calculate the effectiveValue of the source and destination via The Graph, it gives us the value as at the end of the block, not at the point when the exchange happens. This has lead to a few instances of reporting negative fees.
As discussed with The Graph engineering members offline, the suggested solution is to track RateUpdate events from synthetix-rates here, and to calculate effectiveValue using the rate entities.
There have been times where
Synthetix.exchange()
invocations were in the same block yet positioned beforeExchangeRate.updateRates()
and traded on a price that changed in the latter transaction. When we calculate theeffectiveValue
of thesource
anddestination
via The Graph, it gives us the value as at the end of the block, not at the point when the exchange happens. This has lead to a few instances of reporting negative fees.These can be seen by running the following query against the SNX Exchanges subgraph
We are discussing with members of The Graph engineering team as to how to deal with this issue.