Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add support for Blast chain #64

Merged
merged 21 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniswap-sdk-core"
version = "0.21.0"
version = "0.23.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.22 wasn't used. Again, squash locally and force push.

edition = "2021"
authors = ["malik <[email protected]>", "Shuhui Luo <twitter.com/aureliano_law>"]
description = "The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap decentralized exchange"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Add this to your Cargo.toml

```
[dependencies]
uniswap-sdk-core = "0.22.0";
uniswap-sdk-core = "0.23.0";
```

And this to your code:
Expand Down
32 changes: 32 additions & 0 deletions src/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ lazy_static! {
ChainId::CELO as u64,
address!("79a530c8e2fA8748B7B40dd3629C0520c2cCf03f"),
);
m.insert(
ChainId::BLAST as u64,
address!("5C346464d33F90bABaf70dB6388507CC889C1070"),
);
m
};
}
Expand Down Expand Up @@ -140,6 +144,10 @@ lazy_static! {
ChainId::POLYGON as u64,
address!("edf6066a2b290c185783862c7f4776a2c8077ad1"),
);
m.insert(
ChainId::BLAST as u64,
address!("BB66Eb1c5e875933D44DAe661dbD80e5D9B03035"),
);
m
};
}
Expand Down Expand Up @@ -388,6 +396,20 @@ pub const ROOTSTOCK_ADDRESSES: ChainAddresses = ChainAddresses {
v1_mixed_route_quoter_address: None,
};

/// Blast addresses
pub const BLAST_ADDRESSES: ChainAddresses = ChainAddresses {
v3_core_factory_address: address!("792edAdE80af5fC680d96a2eD80A44247D2Cf6Fd"),
multicall_address: address!("dC7f370de7631cE9e2c2e1DCDA6B3B5744Cf4705"),
quoter_address: address!("6Cdcd65e03c1CEc3730AeeCd45bc140D57A25C77"),
v3_migrator_address: Some(address!("15CA7043CD84C5D21Ae76Ba0A1A967d42c40ecE0")),
nonfungible_position_manager_address: Some(address!(
"B218e4f7cF0533d4696fDfC419A0023D33345F28"
)),
tick_lens_address: Some(address!("2E95185bCdD928a3e984B7e2D6560Ab1b17d7274")),
swap_router02_address: Some(address!("549FEB8c9bd4c12Ad2AB27022dA12492aC452B66")),
v1_mixed_route_quoter_address: None,
};

lazy_static! {
/// A map of chain IDs to their corresponding Uniswap contract addresses.
///
Expand Down Expand Up @@ -418,6 +440,7 @@ lazy_static! {
new_map.insert(ChainId::ZORA as u64, ZORA_ADDRESSES);
new_map.insert(ChainId::ZORASEPOLIA as u64, ZORA_SEPOLIA_ADDRESSES);
new_map.insert(ChainId::ROOTSTOCK as u64, ROOTSTOCK_ADDRESSES);
new_map.insert(ChainId::BLAST as u64, BLAST_ADDRESSES);
new_map
};
}
Expand Down Expand Up @@ -759,4 +782,13 @@ mod tests {
address!("3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E")
);
}

#[test]
fn test_swap_router_02_addresses_blast() {
let address = swap_router02_address(ChainId::BLAST as u64);
assert_eq!(
address,
address!("549FEB8c9bd4c12Ad2AB27022dA12492aC452B66")
);
}
}
7 changes: 6 additions & 1 deletion src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ pub enum ChainId {
ZORASEPOLIA = 999999999,
/// The Rootstock network.
ROOTSTOCK = 30,
/// The Blast network.
BLAST = 81457,
}

/// A list of `ChainId` constants representing the blockchain networks supported by the Uniswap SDK.
///
/// This array includes all the `ChainId` variants that are supported by the SDK, making it easy to
/// iterate over or check for supported chains.
pub const SUPPORTED_CHAINS: [ChainId; 20] = [
pub const SUPPORTED_CHAINS: [ChainId; 21] = [
ChainId::MAINNET,
ChainId::OPTIMISM,
ChainId::OPTIMISMGOERLI,
Expand All @@ -74,6 +76,7 @@ pub const SUPPORTED_CHAINS: [ChainId; 20] = [
ChainId::ZORA,
ChainId::ZORASEPOLIA,
ChainId::ROOTSTOCK,
ChainId::BLAST,
];

/// Represents the names of native currencies supported by the Uniswap SDK.
Expand All @@ -95,4 +98,6 @@ pub enum NativeCurrencyName {
AVAX,
/// Rootstock's native currency.
ROOTSTOCK,
/// Blast native currency.
BLAST,
}
2 changes: 1 addition & 1 deletion src/entities/fractions/fraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait FractionBase<M>: Sized {
/// Accessor method for retrieving metadata
fn meta(&self) -> M;

/// Accessor method for retrieving the numerator
/// Accessor method for retrieving numerator
fn numerator(&self) -> BigInt;

/// Accessor method for retrieving the denominator
Expand Down
4 changes: 4 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

pub mod compute_price_impact;


pub mod sorted_insert;

pub mod sqrt;
#[cfg(feature = "validate_parse_address")]
pub mod validate_and_parse_address;
Loading