darkforestry / amms-rs

A Rust library to interact with automated market makers across EVM chains.
458 stars 124 forks source link

Feat: Make `amms-rs` compatible with Artemis #76

Closed 0xKitsune closed 5 months ago

0xKitsune commented 1 year ago

It would be useful to have amms-rs be compatible with Artemis so that features like state space tracking could be used by strategies written with artemis. Initially I am thinking that we could update the state-space module to use collectors.

Additionally, it would be nice to implement a strategy or something similar that could be fed into the artemis engine that keeps the state space synced without producing state change updates. This might be useful if someone is using a specific collector to notify their strategy and do not need to listen to state changes, but they still need an up-to date state space.

gakonst commented 1 year ago

Agreed. What would it take to make them compatible? Both are on same version of ethers, right?

We could import artemis-core's traits here e.g. for syncing a strategy, or indeed build collectors.

gakonst commented 1 year ago

Wonder what @frankieislost thinks here / how we could best make progress on this, as it'd open up a bunch of new nice funcitonalities in Artemis.

0xKitsune commented 1 year ago

Agreed. What would it take to make them compatible? Both are on same version of ethers, right?

After a quick look, it seems everything should be compatible as is.

We could import artemis-core's traits here e.g. for syncing a strategy, or indeed build collectors.

I was thinking the same thing, it would be pretty easy to import the artemis-core traits and create collectors.

Currently we have methods to listen_for_state_changes which notifies when a change in the state space occurs, listen_to_new_blocks which keeps the state space updated, notifying when new blocks are received and listen_for_updates which keeps the state space updated without notifying new blocks or state changes.

My initial thinking is to create collectors for all of these but I am interested to hear your thoughts. I'm not sure if having multiple BlockCollector types will be confusing. Additionally, I am not sure if it is best to have listen_for_updates as a collector or a strategy that executes on each block.

0xKitsune commented 1 year ago

Changes are underway! I am shooting to get everything merged in within the next week. Let me know if you have any thoughts on what might be useful for the integration. @FrankieIsLost @gakonst

It would be cool to have this finalized in time for the Rust x Ethereum event in case anyone is hacking with Artemis and wants to utilize this functionality.