Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cargo test --all
In order to run the opensea sudoswap arbitrage strategy, you can run the following command:

```sh
cargo run -- --wss <INFURA_OR_ALCHEMY_KEY> --opensea-api-key <OPENSEA_API_KEY> --private-key <PRIVATE_KEY> --arb-contract-address <ARB_CONTRACT_ADDRESS> --bid-percentage <BID_PERCENTAGE>
cargo run --bin artemis -- --wss <INFURA_OR_ALCHEMY_KEY> --opensea-api-key <OPENSEA_API_KEY> --private-key <PRIVATE_KEY> --arb-contract-address <ARB_CONTRACT_ADDRESS> --bid-percentage <BID_PERCENTAGE>
```

where `ARB_CONTRACT_ADDRESS` is the address to which you deploy the [arb contract](/crates/strategies/opensea-sudo-arb/contracts/src/SudoOpenseaArb.sol).
Expand Down
50 changes: 29 additions & 21 deletions crates/generator/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Error, Result};
use clap::{Parser, ValueHint};
use convert_case::{Case, Casing};
use quote::__private::TokenStream;
use std::fs::{create_dir, File};
use std::fs::{create_dir, metadata, File};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand All @@ -28,32 +28,46 @@ pub struct StrategyParser {

impl StrategyParser {
pub fn generate(&self) -> Result<(), Error> {
let snake = self.strategy_name.to_case(Case::Snake);
let kebab = self.strategy_name.to_case(Case::Kebab);
let pascal = self.strategy_name.to_case(Case::Pascal);

let strategy_data = generate_strategy(&pascal);
let constants_data = generate_constants();
let type_data = generate_types();
let lib_data = generate_lib();

let crate_name = snake;

generate_crate(
&crate_name,
&self.root,
strategy_data,
constants_data,
type_data,
lib_data,
)?;

let crate_name = kebab;

let path: PathBuf = {
let mut p: PathBuf = self.root.to_path_buf();
p.push(&crate_name);
p
};

if !metadata(&path).is_ok() {
generate_crate(
&crate_name,
path,
strategy_data,
constants_data,
type_data,
lib_data,
)?;
return Ok(());
}

run_strategy();
Ok(())
}
}

fn generate_crate<P: AsRef<Path>>(
fn run_strategy() {
//TODO run strategy code
}

fn generate_crate(
crate_name: &str,
root: P,
path: PathBuf,
strategy: TokenStream,
constants: TokenStream,
types: TokenStream,
Expand All @@ -66,12 +80,6 @@ fn generate_crate<P: AsRef<Path>>(
("async-trait", "0.1.64"),
];

let path: PathBuf = {
let mut p: PathBuf = root.as_ref().to_path_buf();
p.push(crate_name);
p
};

// Create crate directory
create_dir(&path)?;

Expand Down