From eb7f38b202826fae59dc7005c5892c83454ff82a Mon Sep 17 00:00:00 2001 From: Shuhui Luo <107524008+shuhuiluo@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:53:46 -0500 Subject: [PATCH] feat: add `wrapped_owned` method to `CurrencyAmount` Updated Cargo.toml to version 3.4.0 and upgraded the `bigdecimal` dependency to version 0.4.7. Added a new `wrapped_owned` method in `CurrencyAmount` for better handling of wrapped currencies. --- Cargo.toml | 4 ++-- src/entities/fractions/currency_amount.rs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 803b62c..a79f38b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uniswap-sdk-core" -version = "3.3.0" +version = "3.4.0" edition = "2021" authors = ["malik ", "Shuhui Luo "] description = "The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap decentralized exchange" @@ -8,7 +8,7 @@ license = "MIT" [dependencies] alloy-primitives = { version = ">=0.8.5", features = ["map-fxhash"] } -bigdecimal = "0.4.5" +bigdecimal = "0.4.7" derive_more = { version = "1.0.0", features = ["deref"] } eth_checksum = { version = "0.1.2", optional = true } lazy_static = "1.5" diff --git a/src/entities/fractions/currency_amount.rs b/src/entities/fractions/currency_amount.rs index 06a553c..63b20df 100644 --- a/src/entities/fractions/currency_amount.rs +++ b/src/entities/fractions/currency_amount.rs @@ -150,6 +150,16 @@ impl CurrencyAmount { self.denominator().clone(), ) } + + /// Wrap the currency amount if the currency is not native + #[inline] + pub fn wrapped_owned(&self) -> Result, Error> { + CurrencyAmount::from_fractional_amount( + self.currency.wrapped().clone(), + self.numerator().clone(), + self.denominator().clone(), + ) + } } #[cfg(test)]