interlay / interbtc-squid

Subquid GraphQL schema and indexer for the Interlay and Kintsugi networks
Apache License 2.0
4 stars 7 forks source link

Store all swaps #106

Closed nud3l closed 1 year ago

nud3l commented 1 year ago

We want to track historical swap data including:

bvotteler commented 1 year ago
  • Fees paid

@nud3l : This information is not available on the events (DexGeneral.AssetSwap and DexStable.CurrencyExchange). Should we create an issue in interbtc to add that info to the events?

Naturally, squid can query the chain, but we need to be very careful of the processing cost. If possible I'd like to avoid making squid processing slower due to additional lookups.

nud3l commented 1 year ago

Good point. Just for me to check: the vector of amounts in the pallet is just the in and out the amount and does not contain the fee? @gregdhill maybe you know more as well. This is was I was looking at: https://github.com/interlay/interbtc/blob/master/crates/dex-general/src/swap/mod.rs#L266

bvotteler commented 1 year ago
  • From asset
  • To asset
  • From amount
  • To amount

One more point to clarify: For multi-path swaps (e.g. KBTC -> KSM -> KINT), do we want to ignore the intermediate swaps and only track the first input / last output (KBTC in, KINT out, ignore KSM values)?

nud3l commented 1 year ago

I thought that multi-hop would fire multiple events, so if it's multi-hop we would see:

For now, we would not need any aggregation/special handling of this as right now we are just interested in the fees that we collect in the AMM.

bvotteler commented 1 year ago

I thought that multi-hop would fire multiple events

For DexStable.CurrencyExchange events we only have in/out amounts in an event as far as I recall.

For DexGeneral.AssetSwap the entire path is included as far as I understood. In fact, I split the path into "pairwise swaps" for cumulative values inside squid. See code sample here.

gregdhill commented 1 year ago

DexGeneral.AssetSwap

DexStable.CurrencyExchange

DexStable.CurrencyExchangeUnderlying

bvotteler commented 1 year ago

PR: #114

Sample query and result shown in this comment