-
Notifications
You must be signed in to change notification settings - Fork 10
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
Pool tokens and relation to Pair is unclear #63
Comments
I've just noticed that the official explorer now shows the pool tokens in balances etc. If I saw it correctly, these appear a bit later than the native tokens when viewing an account balance. That could indicate that they get the info via the Loopring API and not via the graph (as they already do for pending transactions etc.). Will have to look it up on github later |
From what I understand my suspicion was correct, they seem to get the token details via the Loopring API if the token symbol is empty: Loopring/loopring-explorer@9dc43ba Which still surprises me, because it is perfectly possible to create the pool, pair, token relationship with the subgraph, assuming that a pool is only ever used for a single pair. |
I'm almost there: the connection between Pools and Pairs are Swaps! Just fetching any swap for a given pair or pool will be sufficient to make the connection. Tricky part is to find the pool token, but that's doable: the pools balances need to be enumerated and the token without a symbol etc. is most likely the pool token. Additional safe-guard is to check that the balance also contains both tokens of the pair. This can/should be cached without a time-limit (it's not going to change!). The token name can be generated LP-Token0-Token1, luckily the pool token decimals are fixed. So as soon as I have a pool or a pair I can get the token and cache it. But: if I'm only sitting on a regular user page looking at the balances, I have neither the pair nor the pool to find the pool tokens for any of their balances. |
Now that I figured out the last issue as well (just get any Remove transaction with the given pool token id to get the pool and continue with that), I've seen on discord that there are aspects of the Loopring API you can query without the need for API keys or anything else. And lo and behold, here's the link to retrieve a nice JSON will all tokens: https://api3.loopring.io/api/v3/exchange/tokens Docs for that here: https://docs.loopring.io/en/dex_apis/getTokens.html Hm, maybe it's time to consider using the API too? |
I think the caveat with the Loopring API is that you will get rate limited if you reach more than 5 calls per second on an endpoint. I think this may be an issue for us since all calls will be coming from the server unless we use JS Interop to make the call on the client? We could cache the result for that endpoint though like you suggested. |
Well for just getting the tokens (like the official explorer does for a couple of weeks now), the rate limit would be a non-issue, since querying this once the first time it is needed is sufficient (or maybe call once a day). I still tend to rather use the solution using the graph, since I think I'll make a PR once I've got everything ready and then we can all have a look at it. |
If you look at a pool, e.g. https://lexplorer.io/account/118 it has a huge balance of it's token. Here's the query response:
From manually looking at it, it is clear that the token with id = 256 must be the pool token and it should be the USDC/IMX pair, but it seems there is no way to make that connection with the graph? Also, these tokens show up in the account balances, again without a name or anything. Ideally we would be able to display the proper name, have a link to the pair and from the pair have link(s) to the pools, but it seems this isn't possible with the graph queries?
The official explorer seems to actively hide these "empty" tokens!
The text was updated successfully, but these errors were encountered: