Skip to content

Commit d636c4d

Browse files
committed
feat: make ChainAddresses fields public and add support for Soneium
Extended the Uniswap SDK Core with support for the Soneium chain by adding its chain ID, addresses, and relevant configurations. Adjusted `ChainAddresses` structure visibility and incremented the library version to 4.1.0 to reflect the changes. Updated README and Cargo.toml accordingly.
1 parent dc0859a commit d636c4d

File tree

5 files changed

+71
-25
lines changed

5 files changed

+71
-25
lines changed

Cargo.toml

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "uniswap-sdk-core"
3-
version = "4.0.1"
3+
version = "4.1.0"
44
edition = "2021"
55
authors = ["malik <aremumalik05@gmail.com>", "Shuhui Luo <twitter.com/aureliano_law>"]
66
description = "The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap decentralized exchange"
@@ -25,5 +25,14 @@ thiserror = { version = "2", default-features = false }
2525

2626
[features]
2727
default = []
28-
std = ["alloy-primitives/std", "derive_more/std", "fastnum/std", "num-integer/std", "thiserror/std"]
29-
validate_parse_address = ["eth_checksum", "regex"]
28+
std = [
29+
"alloy-primitives/std",
30+
"derive_more/std",
31+
"fastnum/std",
32+
"num-integer/std",
33+
"thiserror/std"
34+
]
35+
validate_parse_address = [
36+
"eth_checksum",
37+
"regex"
38+
]

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Uniswap SDK Core Rust
22

33
[![Rust CI](https://github.com/malik672/uniswap-sdk-core-rust/actions/workflows/rust.yml/badge.svg)](https://github.com/malik672/uniswap-sdk-core-rust/actions/workflows/rust.yml)
4-
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/malik672/uniswap-sdk-core-rust?logo=rust&label=CodeRabbit&color=orange)
54
[![docs.rs](https://img.shields.io/docsrs/uniswap-sdk-core)](https://docs.rs/uniswap-sdk-core/latest)
65
[![crates.io](https://img.shields.io/crates/v/uniswap-sdk-core.svg)](https://crates.io/crates/uniswap-sdk-core)
76

@@ -14,7 +13,7 @@ Add this to your Cargo.toml
1413

1514
```toml
1615
[dependencies]
17-
uniswap-sdk-core = "4.0.0"
16+
uniswap-sdk-core = "4.1.0"
1817
```
1918

2019
And this to your code:
@@ -35,7 +34,7 @@ the `token!` macro.
3534
<details>
3635
<summary>Click to expand</summary>
3736

38-
```rust
37+
```rust,ignore
3938
// Import necessary preludes and token macro
4039
use uniswap_sdk_core::{prelude::*, token};
4140

src/addresses.rs

+45-16
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ pub type AddressMap = HashMap<u64, Address>;
66

77
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
88
pub struct ChainAddresses {
9-
v3_core_factory: Address,
10-
multicall: Address,
11-
quoter: Address,
12-
quoter_v2: Address,
13-
v3_migrator: Option<Address>,
14-
nonfungible_position_manager: Address,
15-
tick_lens: Option<Address>,
16-
swap_router02: Option<Address>,
17-
mixed_route_quoter_v1: Option<Address>,
18-
mixed_route_quoter_v2: Option<Address>,
19-
20-
v4_pool_manager: Option<Address>,
21-
v4_position_manager: Option<Address>,
22-
v4_state_view: Option<Address>,
23-
v4_quoter: Option<Address>,
9+
pub v3_core_factory: Address,
10+
pub multicall: Address,
11+
pub quoter: Address,
12+
pub quoter_v2: Address,
13+
pub v3_migrator: Option<Address>,
14+
pub nonfungible_position_manager: Address,
15+
pub tick_lens: Option<Address>,
16+
pub swap_router02: Option<Address>,
17+
pub mixed_route_quoter_v1: Option<Address>,
18+
pub mixed_route_quoter_v2: Option<Address>,
19+
20+
pub v4_pool_manager: Option<Address>,
21+
pub v4_position_manager: Option<Address>,
22+
pub v4_state_view: Option<Address>,
23+
pub v4_quoter: Option<Address>,
2424
}
2525

2626
pub const DEFAULT_NETWORKS: [ChainId; 3] = [ChainId::MAINNET, ChainId::GOERLI, ChainId::SEPOLIA];
@@ -109,6 +109,10 @@ lazy_static! {
109109
ChainId::MONAD_TESTNET as u64,
110110
address!("0x733e88f248b742db6c14c0b1713af5ad7fdd59d0"),
111111
),
112+
(
113+
ChainId::SONEIUM as u64,
114+
address!("0x97febbc2adbd5644ba22736e962564b23f5828ce"),
115+
),
112116
])
113117
};
114118
}
@@ -168,14 +172,22 @@ lazy_static! {
168172
ChainId::MONAD_TESTNET as u64,
169173
address!("0xfb8e1c3b833f9e67a71c859a132cf783b645e436"),
170174
),
175+
(
176+
ChainId::SONEIUM as u64,
177+
address!("0x273f68c234fa55b550b40e563c4a488e0d334320"),
178+
),
171179
])
172180
};
173181
}
174182

183+
/// Choose not to impl `Default` for `ChainAddresses` to avoid "[E0379]: functions in trait impls
184+
/// cannot be declared const"
175185
impl ChainAddresses {
176186
/// Networks that share most of the same addresses i.e. Mainnet, Goerli, Optimism, Arbitrum,
177187
/// Polygon
178-
const fn default() -> Self {
188+
#[inline]
189+
#[must_use]
190+
pub const fn default() -> Self {
179191
Self {
180192
v3_core_factory: address!("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
181193
multicall: address!("0x1F98415757620B543A52E61c46B32eB19261F984"),
@@ -524,6 +536,22 @@ const MONAD_TESTNET_ADDRESSES: ChainAddresses = ChainAddresses {
524536
..ChainAddresses::default()
525537
};
526538

539+
const SONEIUM_ADDRESSES: ChainAddresses = ChainAddresses {
540+
v3_core_factory: address!("0x42ae7ec7ff020412639d443e245d936429fbe717"),
541+
multicall: address!("0x8ad5ef2f2508288d2de66f04dd883ad5f4ef62b2"),
542+
quoter: address!("0x3e6c707d0125226ff60f291b6bd1404634f00aba"),
543+
v3_migrator: Some(address!("0xa107580f73bd797bd8b87ff24e98346d99f93ddb")),
544+
nonfungible_position_manager: address!("0x56c1205b0244332011c1e866f4ea5384eb6bfa2c"),
545+
tick_lens: Some(address!("0xcd08eefb928c86499e6235ac155906bb7c4dc41a")),
546+
swap_router02: Some(address!("0x7e40db01736f88464e5f4e42394f3d5bbb6705b9")),
547+
548+
v4_pool_manager: Some(address!("0x360e68faccca8ca495c1b759fd9eee466db9fb32")),
549+
v4_position_manager: Some(address!("0x1b35d13a2e2528f192637f14b05f0dc0e7deb566")),
550+
v4_state_view: Some(address!("0x76fd297e2d437cd7f76d50f01afe6160f86e9990")),
551+
v4_quoter: Some(address!("0x3972c00f7ed4885e145823eb7c655375d275a1c5")),
552+
..ChainAddresses::default()
553+
};
554+
527555
lazy_static! {
528556
/// A map of chain IDs to their corresponding Uniswap contract addresses.
529557
///
@@ -559,6 +587,7 @@ lazy_static! {
559587
(ChainId::UNICHAIN_SEPOLIA as u64, UNICHAIN_SEPOLIA_ADDRESSES),
560588
(ChainId::UNICHAIN as u64, UNICHAIN_ADDRESSES),
561589
(ChainId::MONAD_TESTNET as u64, MONAD_TESTNET_ADDRESSES),
590+
(ChainId::SONEIUM as u64, SONEIUM_ADDRESSES),
562591
])
563592
};
564593
}

src/chains.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ pub enum ChainId {
3434
UNICHAIN_SEPOLIA = 1301,
3535
UNICHAIN = 130,
3636
MONAD_TESTNET = 10143,
37+
SONEIUM = 1868,
3738
}
3839

3940
/// A list of `ChainId` constants representing the blockchain networks supported by the Uniswap SDK.
4041
///
4142
/// This array includes all the `ChainId` variants that are supported by the SDK, making it easy to
4243
/// iterate over or check for supported chains.
43-
pub const SUPPORTED_CHAINS: [ChainId; 27] = [
44+
pub const SUPPORTED_CHAINS: [ChainId; 28] = [
4445
ChainId::MAINNET,
4546
ChainId::OPTIMISM,
4647
ChainId::OPTIMISM_GOERLI,
@@ -68,4 +69,5 @@ pub const SUPPORTED_CHAINS: [ChainId; 27] = [
6869
ChainId::UNICHAIN_SEPOLIA,
6970
ChainId::UNICHAIN,
7071
ChainId::MONAD_TESTNET,
72+
ChainId::SONEIUM,
7173
];

src/entities/weth9.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ impl WETH9 {
3131
#[inline]
3232
#[must_use]
3333
pub fn new() -> Self {
34-
const CHAIN_IDS: [u64; 24] = [
34+
const CHAIN_IDS: [u64; 25] = [
3535
1, 11155111, 3, 4, 5, 42, 10, 69, 11155420, 42161, 421611, 421614, 8453, 84532, 56,
36-
137, 43114, 7777777, 81457, 324, 480, 1301, 130, 10143,
36+
137, 43114, 7777777, 81457, 324, 480, 1301, 130, 10143, 1868,
3737
];
3838
let tokens = HashMap::from_iter(
3939
CHAIN_IDS
@@ -222,6 +222,13 @@ impl WETH9 {
222222
"WMON",
223223
"Wrapped Monad"
224224
)),
225+
1868 => Some(token!(
226+
1868,
227+
"0x4200000000000000000000000000000000000006",
228+
18,
229+
"WETH",
230+
"Wrapped Ether"
231+
)),
225232
_ => None,
226233
}
227234
}

0 commit comments

Comments
 (0)