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    clock::LiveClock,
25    logging::{init_logging, logger::LoggerConfig, writer::FileWriterConfig},
26    runtime::get_runtime,
27};
28use nautilus_core::UUID4;
29use nautilus_execution::client::base::ExecutionClientCore;
30use nautilus_live::execution::client::LiveExecutionClient;
31use nautilus_model::{
32    defi::chain::chains,
33    enums::{AccountType, OmsType},
34    identifiers::{AccountId, ClientId, TraderId},
35};
36
37fn main() -> Result<(), Box<dyn std::error::Error>> {
38    dotenvy::dotenv().ok();
39
40    let trader_id = TraderId::default();
41    let account = AccountId::default();
42    let arbitrum = chains::ARBITRUM.clone();
43    let ethereum = chains::ETHEREUM.clone();
44
45    // Init logging
46    let _log_guard = init_logging(
47        trader_id,
48        UUID4::new(),
49        LoggerConfig::default(),
50        FileWriterConfig::default(),
51    )?;
52
53    let arbitrum_rpc_url =
54        std::env::var("ARBITRUM_RPC_HTTP_URL").expect("ARBITRUM_RPC_HTTP_URL must be set");
55    let ethereum_rpc_url =
56        std::env::var("ETHEREUM_RPC_HTTP_URL").expect("ETHEREUM_RPC_HTTP_URL must be set");
57
58    let arbitrum_config = BlockchainExecutionClientConfig::new(
59        trader_id,
60        account,
61        arbitrum,
62        String::from("0x49E96E255bA418d08E66c35b588E2f2F3766E1d0"),
63        arbitrum_rpc_url,
64        None,
65    );
66    let ethereum_config = BlockchainExecutionClientConfig::new(
67        trader_id,
68        account,
69        ethereum,
70        String::from("0x49E96E255bA418d08E66c35b588E2f2F3766E1d0"),
71        ethereum_rpc_url,
72        None,
73    );
74    let core_execution_client = ExecutionClientCore::new(
75        trader_id,
76        ClientId::default(),
77        *BLOCKCHAIN_VENUE,
78        OmsType::Netting,
79        account,
80        AccountType::Wallet,
81        None,
82        Rc::new(RefCell::new(LiveClock::new(None))),
83        Rc::new(RefCell::new(Cache::default())),
84    );
85
86    let mut ethereum_execution_client =
87        BlockchainExecutionClient::new(core_execution_client.clone(), ethereum_config);
88    let mut arbitrum_execution_client =
89        BlockchainExecutionClient::new(core_execution_client, arbitrum_config);
90
91    get_runtime().block_on(async move {
92        ethereum_execution_client.connect().await?;
93        arbitrum_execution_client.connect().await?;
94        Ok::<(), anyhow::Error>(())
95    })?;
96
97    Ok(())
98}