Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Add JIT Liquidity Classifier #292

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

elicbarbieri
Copy link

Adding Just in time liquidity classification

Tests are based on block 13601096
Added necessary classification, schemas and models

@mikemcdonald
Copy link

@elicbarbieri a couple interesting fields to add to the schema alongside tx details:

  • Fee earned by JIT LP
  • % of tick range liquidity owned by LP during the sandwich

@elicbarbieri
Copy link
Author

@mikemcdonald calculating these metrics would require a minimum of 2 calls to the RPC, and probably decoding the logs from the liquidity burn and mint. All the data from mev-inspect is derived from the transaction traces, and there is no accurate way to get the fees and liquidity across ticks from the traces. The rest of the codebase minimizes calls to the RPC and it doesn't make sense to change that now. I will probably pull the raw JIT data into a CSV and calculate these metrics later, and will make sure to post that.

@elicbarbieri elicbarbieri marked this pull request as ready for review April 29, 2022 22:19
trace.from_address,
]

else: # trace.function_signature == "transferFrom(address,address,uint256)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the else case is implying a new case that we're aware of, use elif, and change the else case for the scenario where the function signature is an unexpected transfer function. Make assumptions explicit in the code (not in the comments)

classified_traces: List[ClassifiedTrace],
) -> List[Transfer]:
"""
Super Jank...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up this docstring

if sorted(net_search_info) in found_transfers:
for index, transfer in enumerate(return_transfers):
if (
transfer.token_address != net_search_info[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unclear what comparisons are being made against net_search_info due to the list, i would use a dictionary with appropriate key names, that way these are legible

None,
)

# This would be cleaner with bisect(), but creates 3.10 dependency
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, can remove now

return "0x0000000000000000000000000000000000000000"

# This case is here because from_address is optional in ClassifiedTrace
if type(mint_trace.from_address) == str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an attribute (from_address) is Optional in the schema, the object can be created without passing a value and the key will not exist in the dictionary. This will then throw a KeyError. I believe a better check would be
if 'from_address' in mint_trace.keys()

@elicbarbieri
Copy link
Author

image

@elicbarbieri elicbarbieri changed the title Initial JIT Liquidity Classifier Commit Adding JIT Liquidity Classifier May 9, 2022
@elicbarbieri elicbarbieri changed the title Adding JIT Liquidity Classifier Add JIT Liquidity Classifier May 9, 2022
… I created join table migration before main table
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants