Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Hackathon graph #534

Merged
merged 22 commits into from
Jun 28, 2023
Merged

Hackathon graph #534

merged 22 commits into from
Jun 28, 2023

Conversation

alfetopito
Copy link
Collaborator

@alfetopito alfetopito commented Jun 21, 2023

Summary

Hackathon project introducing a new graph visualization: Trade based view

It's possible to toggle between current (transfer based) to the new (trade based)
image

Also introducing 2 new graph layouts: circle and concentric
image

Example of concentric layout for batch 0x992cbc5f40755ee858726662a28425dc3aa389c8b53a9b104049d4ae2249dc7f

Current (transfer based view) New (trade based view)
image image

Details

In the new view, transferred tokens (and some AMMs) are the nodes, trades (denoted in green) and transfers (denoted in red) are the edges.

Wrapping/unwrapping is abstracted away. Any native token interaction is replaced by the corresponding wrapped token.

Nodes

Like the previous visualization, click on nodes links to Etherscan.

Token nodes will display a tooltip with token balance on hover
image

Token images will be displayed when available (for now mostly for Mainnet)

Hyper nodes do not have a tooltip.
They are displayed for intermediate transfers on AMM interactions
image

Edges

Trade edges are colored green.
The label is the abbreviated order id.
The tooltip shows the full order id and the trade amounts
image

Transfer edges are colored red.
The label is either the name of the contract that performed the transfer or an abbreviation of its address when there's no name.
The tooltip shows the transfer amounts
image

Hypernode edges are a special case of transfer edges, where the tooltip will only have a single amount. Either bought or sold, depending on the transfer direction
image

Testing

Basically, verify different batches with both visualizations.
There was a lot of refactoring, but in essence the original graph should have the same behaviour as before.

Some use cases checked during development:

  • Single trade, 1 hop 0xc444e3c90846adec2058296a6b4958c4e153361f5d3eda55b4f9c71efcb63697
  • Single trade, goes through intermediate token 0x48817a64fc831ed6f20b90ad634f79dc07052cd7158279a618eccbe039541c16
  • Multiple trades, multiple hyper nodes 0x4033bb83a68605b863066acc744a9a971da27b237a83d2898fa39448916e0f86
  • Single trade, buying ETH, internal buffers 0x3a4d9e2bfc30c201ff12e197080f5552d7fe9598944ae24fec455f87360936a4
  • Single trade, multiple hops (filtered out) 0x34a01445b89389e7ec795fafcb0cc2a03042cd274246a0c91f06c9aa4747099c
  • Maaaany trades, (fee dump) 0x54450bc55a83276344a4e27b951a82d0d5e1927af0126aaac64b1417eb369868
  • 2 trades, 1 is an eth flow order 0x3e55e2219400b5c229463d0f02cd70c779d4b2a21017cb9d3ca997baa533d8ed
  • Multiple trades, contains a CoW 0x992cbc5f40755ee858726662a28425dc3aa389c8b53a9b104049d4ae2249dc7f
  • 2 trades, disconnected transfers 0x7fe80b725910de1c47e6ac0b4ba56049c84d753e63e45db09d56426ba18ec1e8
  • Multiple trades 0x3dd00931be9dffae244218c119469cb5c5233e79f627c54c92785a959ce9b75e

alfetopito and others added 4 commits June 19, 2023 06:05
* chore: add getTransactionTrace and getTransactionContracts tenderly api fns

* chore: add hook to fetch unfiltered tx data
* refactor: rename `traceToTransfersAndTrades`

* chore: export all types from tenderly from index

* feat: add getContractTrades

* feat: add getNotesAndEdges
* refactor: a tiny bit of clean up on useTxBatchTrades

* chore: update graph

WIP

Messy commit, lots to describe and update still

* fix: edge colors now match user/amm interactions

* chore: pass down transfers to Node objs

* chore: use different node types for dex vs token nodes

* chore: use a different icon for token nodes

* chore: capture eth sell transfers

* refactor: remove repeated variable

* chore: add map of wrapped native token addresses

* chore: add link to hyper nodes

* chore: show address and link when token has no symbol

* chore: actually, always show link for all nodes

* chore: improve edge labels

* chore: add tooltip to edges

* chore: replace native token node with wrapped

* ore: add node type hyper

* chore: add dynamic stylesheet for token images

* chore: add token images to graph

* filter contract trades which only route tokens (#533)

---------

Co-authored-by: Felix Henneke <[email protected]>
@vercel
Copy link

vercel bot commented Jun 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback

📖 Storybook ↗︎

@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Pull Request Test Coverage Report for Build 5358427449

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 61.669%

Totals Coverage Status
Change from base Build 5257074225: 0.04%
Covered Lines: 876
Relevant Lines: 1235

💛 - Coveralls

* refactor: rename const to all caps

* chore: wire up everything -- still WIP

* chore: more a ton of refactorings, still not working

* fix: enum comparison of same type was failing because one was a string the other a number

* chore: update layout once visualization changes

* fix: use proper type

* chore: remove debug statements

* refactor: remove unused hooks

* refactor: move buildContractBasedSettlement to TransactionBatchGraph

* refactor: move buildTokenBasedSettlement into settlementBuilder

* refactor: move node builder fns into nodesBuilder file

* refactor: move types to types file

* refactor: move hooks to hooks file

* chore: cache tenderly fetched data

* refactor: rename contract->transfer token->trades
* added tooltip for nodes showing balance of token

* show dangeling edges

* merge transfers for hyper nodes

* use order information to filter for non-user trades

* clean up

address comments
- made isInternal in Transfer optional
- better sign for 0 in tool tip
- tooltip can be undefined. does still render stuff though.
@alfetopito alfetopito self-assigned this Jun 23, 2023
@alfetopito alfetopito marked this pull request as ready for review June 23, 2023 08:56
@alfetopito alfetopito requested review from a team June 23, 2023 08:56
@elena-zh
Copy link

Hey @alfetopito , that's great! Awesome!
I have taken a brief look and noticed that balances (actually, where are they taken?) may be negative:
neg
negative balance
negative

Then, as a proposal, if there is no a token icon, maybe we should use a funny cow icon instead of a grey circle (not for now, just for the future)?

Also I noticed some overlapping between elements in the graph area
some overlapping
And for this TX
image

@alfetopito
Copy link
Collaborator Author

Hey @alfetopito , that's great! Awesome! I have taken a brief look and noticed that balances (actually, where are they taken?) may be negative

Expected, as the number refers to changes to CoW protocol internal buffers usage

Then, as a proposal, if there is no a token icon, maybe we should use a funny cow icon instead of a grey circle (not for now, just for the future)?

I tried to do that at first but it broke the images for the other tokens.
We'll need a different approach for loading the images for this to work.
I'll see if I can come up with something today.

Also I noticed some overlapping between elements in the graph area some overlapping

True, I'll try to fix it

And for this TX

This case is a won't fix, as it's just a matter of the default visualization not looking great for this graph and the view size.
In a shorter window width for example it does not overlap
image

@elena-zh
Copy link

elena-zh commented Jun 23, 2023

Hey @alfetopito , also noticed that it would be great to enhance a bit mobile views
image
image

Also, impossible on a mobile view to see a token's balance as it opens a token's address on explorer on click

@elena-zh
Copy link

Hey @alfetopito , also noticed that it would be great to enhance a bit mobile views

Also, impossible on a mobile view to see a token's balance as it opens a token's address on explorer on click

Created cowprotocol/cowswap#3717 issue for this

@alfetopito
Copy link
Collaborator Author

Hey @alfetopito , also noticed that it would be great to enhance a bit mobile views
Also, impossible on a mobile view to see a token's balance as it opens a token's address on explorer on click

Created cowprotocol/cowswap#3717 issue for this

Thank you!

@elena-zh one more thing I didn't have time to fix is the deep link to the new graph.
Even though it's set in the URL, it's not possible to load the page straight into the new view.
Can you also create an issue for that?

@elena-zh
Copy link

@alfetopito ,

@elena-zh one more thing I didn't have time to fix is the deep link to the new graph. Even though it's set in the URL, it's not possible to load the page straight into the new view. Can you also create an issue for that?

Created #541 :)

@alfetopito alfetopito merged commit 54c2aac into develop Jun 28, 2023
@alfetopito alfetopito deleted the hackaton-graph branch June 28, 2023 15:14
@alfetopito
Copy link
Collaborator Author

Please post merge review

@alfetopito alfetopito mentioned this pull request Jun 28, 2023
@nenadV91 nenadV91 mentioned this pull request Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants