node_wallet/
node_wallet.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use std::{cell::RefCell, rc::Rc};
17
18use nautilus_blockchain::{
19    config::BlockchainExecutionClientConfig, constants::BLOCKCHAIN_VENUE,
20    execution::client::BlockchainExecutionClient,
21};
22use nautilus_common::{
23    cache::Cache,
24    live::{clock::LiveClock, runtime::get_runtime},
25    logging::{init_logging, logger::LoggerConfig, writer::FileWriterConfig},
26};
27use nautilus_core::UUID4;
28use nautilus_execution::client::{ExecutionClient, base::ExecutionClientCore};
29use nautilus_model::{
30    defi::chain::chains,
31    enums::{AccountType, OmsType},
32    identifiers::{AccountId, ClientId, TraderId},
33};
34
35fn main() -> Result<(), Box<dyn std::error::Error>> {
36    dotenvy::dotenv().ok();
37
38    let trader_id = TraderId::default();
39    let account = AccountId::default();
40    let arbitrum = chains::ARBITRUM.clone();
41    let ethereum = chains::ETHEREUM.clone();
42
43    // Init logging
44    let _log_guard = init_logging(
45        trader_id,
46        UUID4::new(),
47        LoggerConfig::default(),
48        FileWriterConfig::default(),
49    )?;
50
51    let arbitrum_rpc_url =
52        std::env::var("ARBITRUM_RPC_HTTP_URL").expect("ARBITRUM_RPC_HTTP_URL must be set");
53    let ethereum_rpc_url =
54        std::env::var("ETHEREUM_RPC_HTTP_URL").expect("ETHEREUM_RPC_HTTP_URL must be set");
55
56    let arbitrum_config = BlockchainExecutionClientConfig::new(
57        trader_id,
58        account,
59        arbitrum,
60        String::from("0x49E96E255bA418d08E66c35b588E2f2F3766E1d0"),
61        Some(vec![
62            "0x912CE59144191C1204E64559FE8253a0e49E6548".to_string(),
63            "0x40BD670A58238e6E230c430BBb5cE6ec0d40df48".to_string(),
64        ]),
65        arbitrum_rpc_url,
66        None,
67    );
68    let ethereum_config = BlockchainExecutionClientConfig::new(
69        trader_id,
70        account,
71        ethereum,
72        String::from("0x49E96E255bA418d08E66c35b588E2f2F3766E1d0"),
73        Some(vec![
74            "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".to_string(),
75            "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa".to_string(),
76            "0xB1D1eae60EEA9525032a6DCb4c1CE336a1dE71BE".to_string(),
77            "0x4fE83213D56308330EC302a8BD641f1d0113A4Cc".to_string(),
78        ]),
79        ethereum_rpc_url,
80        None,
81    );
82    let core_execution_client = ExecutionClientCore::new(
83        trader_id,
84        ClientId::default(),
85        *BLOCKCHAIN_VENUE,
86        OmsType::Netting,
87        account,
88        AccountType::Wallet,
89        None,
90        Rc::new(RefCell::new(LiveClock::new(None))),
91        Rc::new(RefCell::new(Cache::default())),
92    );
93
94    let mut ethereum_execution_client =
95        BlockchainExecutionClient::new(core_execution_client.clone(), ethereum_config)?;
96    let mut arbitrum_execution_client =
97        BlockchainExecutionClient::new(core_execution_client, arbitrum_config)?;
98
99    get_runtime().block_on(async move {
100        ethereum_execution_client.connect().await?;
101        arbitrum_execution_client.connect().await?;
102        Ok::<(), anyhow::Error>(())
103    })?;
104
105    Ok(())
106}