Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Colin/simple arb detection #230

Merged
merged 16 commits into from
Apr 29, 2023
Merged

Colin/simple arb detection #230

merged 16 commits into from
Apr 29, 2023

Conversation

Autoparallel
Copy link
Collaborator

Closes #144

Quite a big refactor was needed in order to give us the ability to have a struct like SimpleArbitrageur an impl block that we can access from a simulation. That is, working with &dyn Agent can't do this and it would have required a complicated event_monitoring() function to be created.

This is now done by using the AgentType enum which does create an onion type by virtue of items like AgentType::User(User). This is not the most elegant, but we get more control this way.

In order to make the creation of agents easier, we have a trait called AgentStatus that allows for fields of each agent struct to change depending on whether it has been added to the SimulationManager's HashMap as well as the SimulationEnvironment db. This also required a bit of finagling with another trait Identifiable which solely retrieves the name of an agent.

A new test was written in simple_arbitrageur.rs called simple_arbitrage_detection(). Think of this as a basic boilerplate example of detecting price differences. It is rather clunky for now, but going further felt a bit silly until we have other pools to arb with.

@Autoparallel
Copy link
Collaborator Author

Just fixed the conflicts.

Copy link
Collaborator

@0xJepsen 0xJepsen left a comment

Choose a reason for hiding this comment

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

Looks good to me!

thread::spawn(move || {
while let Ok(_logs) = receiver.recv() {
// self.filter_events(logs);
let decoder = |input, filter_num: usize| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

sick move

@@ -151,23 +232,52 @@ pub struct SimulationEventFilter {
pub address: B160,
/// The event names to filter for.
pub topic: H256,
/// A private copy of the [`BaseContract`] for whichever contract is used to generate filters.
base_contract: BaseContract,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does this need to be private?

@0xJepsen 0xJepsen merged commit 4b32d6a into main Apr 29, 2023
@0xJepsen 0xJepsen deleted the colin/simple-arb-detection branch May 15, 2023 05:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent Type: SimpleArbitrageur
2 participants