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

Store all swaps #106

Closed
7 tasks
nud3l opened this issue Apr 3, 2023 · 7 comments · Fixed by #114
Closed
7 tasks

Store all swaps #106

nud3l opened this issue Apr 3, 2023 · 7 comments · Fixed by #114
Assignees
Labels
enhancement New feature or request prio:critical

Comments

@nud3l
Copy link
Member

nud3l commented Apr 3, 2023

We want to track historical swap data including:

  • From asset
  • To asset
  • From amount
  • To amount
  • Fees paid
  • Account
  • Timestamp
@nud3l nud3l added enhancement New feature or request prio:critical labels Apr 3, 2023
@nud3l nud3l added this to Backlog Apr 3, 2023
@github-project-automation github-project-automation bot moved this to New 🆕 in Backlog Apr 3, 2023
@nud3l nud3l moved this from New 🆕 to Todo ⏳ in Backlog Apr 3, 2023
@bvotteler
Copy link
Contributor

bvotteler commented Apr 3, 2023

  • 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
Copy link
Member Author

nud3l commented Apr 3, 2023

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
Copy link
Contributor

  • 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
Copy link
Member Author

nud3l commented Apr 3, 2023

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

  • Swap event 1
  • Swap event 2

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
Copy link
Contributor

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
Copy link
Member

DexGeneral.AssetSwap

  • May include multiple hops in a single event
  • The amounts vector includes the fee
  • Swap fee and protocol fee customizable (protocol taken from swap)
  • No events emitted for fee rate updates and not included in PairCreated

DexStable.CurrencyExchange

  • Fired per swap (includes pool and currency indices)
  • Input amount includes fee
  • Swap fee and admin fee customizable (admin taken from swap)
  • NewSwapFee and NewAdminFee update fee rates, not included in CreatePool

DexStable.CurrencyExchangeUnderlying

  • Same as above but currency index over two pools

@bvotteler bvotteler self-assigned this Apr 17, 2023
@bvotteler bvotteler moved this from Todo ⏳ to Development 🏗️ in Backlog Apr 17, 2023
@bvotteler bvotteler mentioned this issue Apr 20, 2023
2 tasks
@bvotteler
Copy link
Contributor

bvotteler commented Apr 20, 2023

PR: #114

Sample query and result shown in this comment

@github-project-automation github-project-automation bot moved this from Development 🏗️ to Done ✅ in Backlog Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request prio:critical
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants