-
Notifications
You must be signed in to change notification settings - Fork 308
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
Tracking issue: DEX state legibility for API consumers #2267
Comments
Comments during a discussion with @zbuc @erwanor:
There are two points here:
We think the best way to implement this would be to have an RPC that takes a trade as input and simulates execution against the current chain state. Because of the way we've built the Penumbra internals (all execution is simulated, we just selectively commit it), this can run the exact same code we would use to execute a trade, so should take essentially no extra development effort on top of the effort needed to implement execution. However, it's possible that this RPC might be expensive to compute, especially after we do routing, so we might want to have
Assuming this means being able to compute the profitability of a specific LP position (identified by
The question is, which of this information should be on-chain, which should be indexed separately, and which should be externally provided?
This is a bit tricky because Penumbra doesn't have "pools" as such, we have (effectively) an orderbook for each pair. We could expose the order book state for each pair in a few different ways. We could provide streams of the raw positions on that pair, ordered by their effective price. Or we could provide summarized depth charts, say in 1bps price increments. This might also not be the most meaningful representation, either, because we don't execute on individual pairs, we execute on the graph. Let's call liquidity on other pairs that can be used to execute a trade on the target pair "synthetic liquidity". It seems useful to provide a synthetic depth chart that shows the order book as if synthetic liquidity were included. How should this be represented? Probably we want the underlying data to include information about the routes (e.g., this section of the synthetic order book runs along path P1, this section along P2, etc).
Penumbra doesn't have pools, but it could be possible to represent aggregates of individual positions for trading pairs. This would be the same as the previous item ("liquidity of the pools") AFAIK. Tracking growth would likely be best handled by using Tendermint events or custom indexing on ZKV's part rather than tracking historical data on-chain.
Similar to checking liquidity.
We have an oblivious API already that returns the known asset listing.
Most popular by which metrics? Transfers, swaps, most liquidity available in positions? This is likely not an API we'd build into the chain, and would be better implemented by ZKV on top of raw data we can provide once we have a better understanding.
|
We should fill in the missing bullet points and do a round-trip with ZKV to get their feedback on our proposed changes |
Thank you for the comments, and first I want to just address some of the terminology around pools, Penumbra liquidity, and goals of our dashboard:
I'll pause there, and separately leave comments on the other aspects from ZKV's perspective, and on ZKV's endpoint and historical data needs in a separate post. But hope that clarifies why we think that visualisation of Penumbra liquidity in a way that is similar to UniswapV3 will still be useful to LPs and traders, despite trades being executed against the full graph and not just individual routes / positions. |
Yes, to clarify, we weren't suggesting that the depth chart on a particular pair doesn't matter to users, it definitely does. The concern was just about how we can convey to users that the liquidity used to execute a trade from asset A to B is not restricted to the liquidity directly between A and B.
Yes, we also think this would be great to display. One idea we'd discussed about how to convey the availability of routing was to display two overlaid charts, one with direct liquidity and the other with synthetic liquidity. This would allow users to see both where liquidity is allocated, and also what liquidity is available for them to trade — and to see the spread between those curves, which will vary by pair. In rendering the dashboard, do you think it would be better to have a liquidity-concentration-style rendering like the Univ3 one in the screenshot, or a more traditional market depth chart?
Yes, we also expect this to be an emergent behavior, and it's why our routing algorithm (#2283) alternates between a graph-traversal "spill phase" whose complexity is independent of the number of positions/orders on each pair and a straight-line "fill phase" that walks up the joint orderbook of a specific route. This way, in the common case where there are only a few relevant routes, we can spend most of our execution time filling along a specific route.
All of the routing and execution is public, so in principle LPs on Penumbra should have exactly the same visibility about how trades were routed. From a visualization standpoint, it seems like a Sankey diagram could be a nice way to display this data. For each block, it should be possible to see the actually-executed route for each batched trade, as well as to see any arbitrage trades performed by the chain. This seems like useful information to display retrospectively. We just need to ensure that as we do that routing and execution on-chain, we produce the data to make it legible to external consumers. So if displaying routes seems useful, it would be helpful to settle on a data structure for recording them.
Yes, we agree, sorry for the confusion. What we were thinking of here was not the frontend visualization, but the backend RPCs we could use to deliver the required data:
Of these two use cases, the second one is probably a lower priority, because it is both less important and also more complicated from a deployment perspective, since it would mean having user-driven queries. The data for the first one can be cached, so it's computed at most once per block for each visualized pair. Hope this clarifies things — I think we are actually much closer aligned with your perspective than we may have appeared! |
We should create a tracking issue from this design issue, so that we can breakdown this effort into action items. |
xref #2576 |
Is your feature request related to a problem? Please describe.
To enable ecosystem participants like ZKV to begin building tooling on top of the Penumbra chain, we need to build out the node APIs (
ObliviousQueryService
andSpecificQueryService
) to provide necessary data.Describe the solution you'd like
It's currently unclear what the specific needs from ZKV will be, but Natalia shared a high-level description with us:
The specifics for ZKV's dashboard need to be re-evaluated as some of the things here don't make much sense for Penumbra (TVL as a metric, "available pools", etc.)
We should: start with high-level use cases and determine the RPCs necessary to make them work and come up with a diff against our currently available RPCs.
Re: depth chart, what does it mean to have a depth chart in the Penumbra context, where you're not restricted to liquidity on a single pair? i.e. there are multiple ways to trade from A -> B through intermediary assets that would not be represented in a traditional depth chart.
Possibly represent the "direct" depth curve as well as one that takes routing into account in the same chart?
The text was updated successfully, but these errors were encountered: