Skip to content

Commit

Permalink
feat: add wrapped_owned method to CurrencyAmount (#105)
Browse files Browse the repository at this point in the history
Introduced `wrapped_owned` to wrap non-native currency amounts into `CurrencyAmount<Token>`. Also updated `Cargo.toml` to version `4.0.0-rc3` to reflect the new changes.
  • Loading branch information
shuhuiluo authored Jan 28, 2025
1 parent c8a074b commit 72c240c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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 = "4.0.0-rc2"
version = "4.0.0-rc3"
edition = "2021"
authors = ["malik <aremumalik05@gmail.com>", "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
10 changes: 10 additions & 0 deletions src/entities/fractions/currency_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ impl<T: BaseCurrency> CurrencyAmount<T> {
self.denominator(),
)
}

/// Wrap the currency amount if the currency is not native
#[inline]
pub fn wrapped_owned(&self) -> Result<CurrencyAmount<Token>, Error> {
CurrencyAmount::from_fractional_amount(
self.currency.wrapped().clone(),
self.numerator(),
self.denominator(),
)
}
}

#[cfg(test)]
Expand Down

0 comments on commit 72c240c

Please sign in to comment.