nautilus_blockchain/exchanges/ethereum/
uniswap_v3.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::sync::LazyLock;
17
18use nautilus_model::defi::{
19    chain::chains,
20    dex::{AmmType, Dex, DexType},
21};
22
23use crate::exchanges::{
24    extended::DexExtended,
25    parsing::uniswap_v3::{
26        burn::parse_burn_event, collect::parse_collect_event, mint::parse_mint_event,
27        pool_created::parse_pool_created_event, swap::parse_swap_event,
28        trade_data::convert_to_trade_data,
29    },
30};
31
32/// Uniswap V3 DEX on Ethereum.
33pub static UNISWAP_V3: LazyLock<DexExtended> = LazyLock::new(|| {
34    let mut dex = Dex::new(
35        chains::ETHEREUM.clone(),
36        DexType::UniswapV3,
37        "0x1F98431c8aD98523631AE4a59f267346ea31F984",
38        12369621,
39        AmmType::CLAMM,
40        "PoolCreated(address,address,uint24,int24,address)",
41        "Swap(address,address,int256,int256,uint160,uint128,int24)",
42        "Mint(address,address,int24,int24,uint128,uint256,uint256)",
43        "Burn(address,int24,int24,uint128,uint256,uint256)",
44        "Collect(address,address,int24,int24,uint128,uint128)",
45    );
46    dex.set_initialize_event("Initialize(uint160,int24)");
47    let mut dex_extended = DexExtended::new(dex);
48
49    dex_extended.set_pool_created_event_parsing(parse_pool_created_event);
50    dex_extended.set_swap_event_parsing(parse_swap_event);
51    dex_extended.set_convert_trade_data(convert_to_trade_data);
52    dex_extended.set_mint_event_parsing(parse_mint_event);
53    dex_extended.set_burn_event_parsing(parse_burn_event);
54    dex_extended.set_collect_event_parsing(parse_collect_event);
55
56    dex_extended
57});