Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exchanges in the same block as oracle do not respect transaction ordering #9

Open
jjgonecrypto opened this issue Oct 28, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@jjgonecrypto
Copy link
Contributor

jjgonecrypto commented Oct 28, 2019

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.

These can be seen by running the following query against the SNX Exchanges subgraph

 synthExchanges(where:{feesInUSD_lt:0}) {
    id
    account
    from
    fromCurrencyKey
    fromAmountInUSD
    toCurrencyKey
    toAmountInUSD
    feesInUSD
  }
}

We are discussing with members of The Graph engineering team as to how to deal with this issue.

@jjgonecrypto jjgonecrypto added the bug Something isn't working label Oct 28, 2019
@jjgonecrypto
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant