diff --git a/Cargo.lock b/Cargo.lock index 86af6eb7b..529169796 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1420,10 +1420,13 @@ dependencies = [ name = "rain_orderbook_cli" version = "0.0.4" dependencies = [ + "alloy-primitives", + "alloy-sol-types", "anyhow", "clap", "graphql_client", "once_cell", + "rain_orderbook_bindings", "rain_orderbook_subgraph_queries", "reqwest", "rust-bigint", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d606ea051..db2e5aafc 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -10,6 +10,7 @@ homepage = "https://github.com/rainprotocol/rain.orderbook" [dependencies] rain_orderbook_subgraph_queries = { path = "../subgraph" } +rain_orderbook_bindings = { path = "../bindings" } anyhow = "1.0.70" clap = { version = "4.2.5", features = ["cargo", "derive"] } graphql_client = "0.12.0" @@ -21,3 +22,6 @@ serde_bytes = "0.11.9" tokio = { version = "1.28.0", features = ["full"] } tracing = "0.1.37" tracing-subscriber = "0.3.17" +alloy-primitives = "0.5.4" +alloy-sol-types = { version = "0.5.4" } + diff --git a/crates/cli/src/commands/deposit.rs b/crates/cli/src/commands/deposit.rs index ed192bb21..8edc9613c 100644 --- a/crates/cli/src/commands/deposit.rs +++ b/crates/cli/src/commands/deposit.rs @@ -1,6 +1,9 @@ use clap::Parser; use anyhow::Result; use clap::Args; +use alloy_primitives::{U256, Address}; +use rain_orderbook_bindings::IOrderBookV3::depositCall; +use alloy_sol_types::SolCall; #[derive(Parser)] pub struct Deposit { @@ -10,12 +13,8 @@ pub struct Deposit { impl Deposit { pub async fn execute(self) -> Result<()> { - let DepositArgs { - token, - amount, - vault_id, - } = &self.deposit_args; - println!("Token: {}, Amount: {}, Vault ID: {}", token, amount, vault_id); + let deposit_call = self.deposit_args.to_deposit_call()?; + let call_data = deposit_call.abi_encode(); Ok(()) } } @@ -30,4 +29,18 @@ pub struct DepositArgs { #[arg(short, long, help = "The ID of the vault")] vault_id: u64, -} \ No newline at end of file +} + +impl DepositArgs { + pub fn to_deposit_call(&self) -> Result { + let token_address = self.token.parse::
()?; + let amount = U256::from(self.amount); + let vault_id = U256::from(self.vault_id); + + Ok(depositCall { + token: token_address, + amount, + vaultId: vault_id, + }) + } +}