Skip to content

Commit d292de9

Browse files
authored
Merge pull request #47 from mattsse/matt/fixes-and-feature-gate
feat: feature gate provider support
2 parents e9fb6f4 + e470620 commit d292de9

12 files changed

+853
-555
lines changed

Cargo.lock

+673-389
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ keywords = ["uniswapV3", "math"]
1212
exclude = ["target/*", ".github/*", ".gitignore", "Uniswap/*"]
1313

1414
[dependencies]
15-
alloy = { version = "0.9", features = ["contract", "providers"] }
15+
alloy = { version = "0.11", features = ["contract", "providers"], optional = true }
16+
alloy-primitives = "0.8"
1617
eyre = "0.6"
1718
thiserror = "2.0"
19+
20+
[features]
21+
contract = ["dep:alloy"]

src/bit_math.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::error::UniswapV3MathError;
2-
use alloy::primitives::U256;
2+
use alloy_primitives::U256;
33

44
pub fn most_significant_bit(x: U256) -> Result<u8, UniswapV3MathError> {
55
if x.is_zero() {
@@ -19,7 +19,7 @@ pub fn least_significant_bit(x: U256) -> Result<u8, UniswapV3MathError> {
1919
mod test {
2020
use super::most_significant_bit;
2121
use crate::{bit_math::least_significant_bit, U256_1};
22-
use alloy::primitives::U256;
22+
use alloy_primitives::U256;
2323
use std::str::FromStr;
2424

2525
#[test]

src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::ruint::ParseError;
1+
use alloy_primitives::ruint::ParseError;
22
use thiserror::Error;
33

44
// TODO: make these errors better, some errors in univ3 libs are just require(condition) without a message.

src/full_math.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::ops::{Add, BitAnd, BitOrAssign, BitXor, Div, Mul, MulAssign};
22

3-
use alloy::primitives::U256;
3+
use alloy_primitives::U256;
44

55
use crate::{error::UniswapV3MathError, U256_1, U256_2, U256_3};
66

@@ -149,11 +149,9 @@ mod tests {
149149

150150
#[cfg(test)]
151151
mod test {
152-
use std::ops::{Div, Mul, Sub};
153-
154-
use alloy::primitives::U256;
155-
156152
use crate::U256_1;
153+
use alloy_primitives::U256;
154+
use std::ops::{Div, Mul, Sub};
157155

158156
use super::mul_div;
159157

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::U256;
1+
use alloy_primitives::U256;
22

33
pub mod bit_math;
44
pub mod error;

src/sqrt_price_math.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::{I256, U256};
1+
use alloy_primitives::{I256, U256};
22

33
use crate::{
44
error::UniswapV3MathError,
@@ -235,7 +235,7 @@ mod test {
235235
str::FromStr,
236236
};
237237

238-
use alloy::primitives::U256;
238+
use alloy_primitives::U256;
239239

240240
use crate::{
241241
sqrt_price_math::{_get_amount_1_delta, get_next_sqrt_price_from_output, MAX_U160},

src/swap_math.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::{I256, U256};
1+
use alloy_primitives::{I256, U256};
22

33
use crate::{
44
error::UniswapV3MathError,
@@ -155,7 +155,7 @@ mod test {
155155
use crate::sqrt_price_math::{get_next_sqrt_price_from_input, get_next_sqrt_price_from_output};
156156
use crate::swap_math::compute_swap_step;
157157
use crate::U256_1;
158-
use alloy::primitives::{I256, U256};
158+
use alloy_primitives::{I256, U256};
159159
use std::str::FromStr;
160160

161161
#[allow(unused)]

src/tick.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::U256;
1+
use alloy_primitives::U256;
22

33
pub struct Tick {
44
pub liquidity_gross: u128,

0 commit comments

Comments
 (0)