-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
mod cli; | ||
use clap::Parser; | ||
use anyhow::Result; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
cli::main().await | ||
mod orderbook; | ||
|
||
#[derive(Parser)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Cli { | ||
#[command(subcommand)] | ||
orderbook: orderbook::Orderbook, | ||
} | ||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
tracing::subscriber::set_global_default(tracing_subscriber::fmt::Subscriber::new())?; | ||
|
||
let cli = Cli::parse(); | ||
orderbook::dispatch(cli.orderbook).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use clap::Args; | ||
use anyhow::Result; | ||
|
||
#[derive(Args)] | ||
pub struct DepositArgs { | ||
#[arg(help = "The token address in hex format")] | ||
token: String, | ||
|
||
#[arg(help = "The amount to deposit")] | ||
amount: u64, | ||
|
||
#[arg(help = "The ID of the vault")] | ||
vault_id: u64, | ||
} | ||
|
||
pub async fn deposit(args: DepositArgs) -> Result<()> { | ||
println!("Token: {}, Amount: {}, Vault ID: {}", args.token, args.amount, args.vault_id); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use anyhow::Result; | ||
use clap::Subcommand; | ||
|
||
mod order; | ||
mod deposit; | ||
|
||
#[derive(Subcommand)] | ||
pub enum Orderbook { | ||
#[command(subcommand)] | ||
Order(order::Order), | ||
#[command(about = "Deposit funds into a vault.")] | ||
Deposit(deposit::DepositArgs) | ||
} | ||
|
||
pub async fn dispatch(orderbook: Orderbook) -> Result<()> { | ||
match orderbook { | ||
Orderbook::Order(order) => order::dispatch(order).await, | ||
Orderbook::Deposit(args) => deposit::deposit(args).await, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters