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(doc): Add comments and derive attributes #60

Merged
merged 33 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
00963c9
fix big-decimal issue
malik672 Mar 17, 2024
78b5e9d
fix big-decimal issue
malik672 Mar 17, 2024
12aab8d
docs and example
malik672 Mar 22, 2024
1f7cff7
resolving conflicts
malik672 Mar 22, 2024
c849dd7
changes
malik672 Mar 24, 2024
30d2626
changes
malik672 Mar 24, 2024
59ed573
fixes
malik672 Apr 12, 2024
d05ac13
change hash table
malik672 Apr 13, 2024
9a8c5ef
change hash table
malik672 Apr 13, 2024
8500a53
changes to doc
malik672 Apr 17, 2024
29dc0cb
fixed documentations and refactored some documentations
malik672 Apr 17, 2024
92f72ad
fixed documentations and refactored some documentations
malik672 Apr 17, 2024
7699f8f
fixed documentations and refactored some documentations
malik672 Apr 17, 2024
754234d
fixed documentations and refactored some documentations
malik672 Apr 17, 2024
06096b8
fixed documentations and refactored some documentations
malik672 Apr 17, 2024
d163b07
Update src/addresses.rs
malik672 Apr 22, 2024
49aa01b
Update src/chains.rs
malik672 Apr 22, 2024
1e3fbc0
Update src/error.rs
malik672 Apr 22, 2024
79fa3b5
Update src/utils/mod.rs
malik672 Apr 27, 2024
8489781
Update src/entities/token.rs
malik672 Apr 27, 2024
31a02ad
Update src/entities/token.rs
malik672 Apr 27, 2024
d82133a
Update src/constants.rs
malik672 Apr 27, 2024
ff29c04
Update src/chains.rs
malik672 Apr 27, 2024
2e89764
Update addresses.rs
malik672 Apr 27, 2024
ade88e8
Update error.rs
malik672 Apr 27, 2024
6c853c1
Update src/entities/token.rs
malik672 Apr 27, 2024
98dd213
Update src/constants.rs
malik672 Apr 27, 2024
cc70c0e
Update src/entities/base_currency.rs
malik672 Apr 27, 2024
858ed40
Update src/entities/fractions/fraction.rs
malik672 Apr 27, 2024
8397c17
Update src/entities/fractions/fraction.rs
malik672 Apr 27, 2024
8b286f1
Update src/entities/fractions/fraction.rs
malik672 Apr 27, 2024
02e56aa
Update src/entities/currency.rs
malik672 Apr 27, 2024
faf864d
Update src/error.rs
malik672 Apr 28, 2024
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 src/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ lazy_static! {
}

lazy_static! {
/// The `MAINNET_ADDRESSES` struct holds the Uniswap contract addresses for the Goerli Testnet.
/// The `GOERLI_ADDRESSES` struct holds the Uniswap contract addresses for the Goerli Testnet.
pub static ref GOERLI_ADDRESSES: ChainAddresses = {
ChainAddresses {
v1_mixed_route_quoter_address: Some(address!(
Expand Down
2 changes: 1 addition & 1 deletion src/chains.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[derive(Debug, Clone, Copy)]
/// Represents the unique identifier for different blockchain networks supported by the Uniswap SDK.
///
/// Each variant corresponds to a specific blockchain network, identified by its unique chain ID.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChainId {
/// The Ethereum Mainnet.
MAINNET = 1,
Expand Down
5 changes: 2 additions & 3 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::prelude::*;
use alloy_primitives::U256;
use num_bigint::Sign;

#[derive(Clone, Copy, Debug, PartialEq)]
/// Represents the various type of trades.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TradeType {
/// Indicates that the trade is based on an exact input amount.
ExactInput,
Expand All @@ -12,9 +12,8 @@ pub enum TradeType {
ExactOutput,
}

#[derive(Clone, Debug, PartialEq, Copy)]

/// Represents three various way to rounds
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Rounding {
/// Rounds down to the nearest whole number.
RoundDown,
Expand Down
3 changes: 1 addition & 2 deletions src/entities/base_currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::ops::Deref;

use alloy_primitives::ChainId;

#[derive(Clone, PartialEq, Debug)]

/// `CurrencyLike` is a generic struct representing a currency with a specific chain ID,
/// decimals, symbol, name, and additional metadata.
#[derive(Clone, PartialEq, Debug)]
pub struct CurrencyLike<M> {
/// The chain ID on which this currency resides
pub chain_id: ChainId,
Expand Down
3 changes: 1 addition & 2 deletions src/entities/currency.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::prelude::*;

#[derive(Clone, PartialEq, Debug)]

/// This enum represnets the two type of currencies i.e native and Token
#[derive(Clone, PartialEq, Debug)]
pub enum Currency {
/// Represents a native currency.
NativeCurrency(Ether),
Expand Down
6 changes: 3 additions & 3 deletions src/entities/fractions/fraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::prelude::*;
use std::ops::{Add, Deref, Mul, Sub};

/// struct to represent a fraction
/// Struct representing a fraction with metadata
#[derive(Clone, Debug)]
pub struct FractionLike<M> {
numerator: BigInt,
Expand Down Expand Up @@ -82,7 +82,7 @@ pub trait FractionBase<M>: Sized {
/// Accessor method for retrieving metadata
fn meta(&self) -> M;

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

/// Accessor method for retrieving the denominator
Expand All @@ -102,7 +102,7 @@ pub trait FractionBase<M>: Sized {
)
}

/// Returns the inverted [`fraction`]
/// Returns the inverted fraction
fn invert(&self) -> Self {
Self::new(self.denominator(), self.numerator(), self.meta())
}
Expand Down
7 changes: 3 additions & 4 deletions src/entities/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::prelude::*;
/// Represents an ERC20 token with a unique address and some metadata.
pub type Token = CurrencyLike<TokenMeta>;

#[derive(Clone, PartialEq, Debug)]

/// Represents the metadata for an ERC20 token, including its address and optional fees.
#[derive(Clone, PartialEq, Debug)]
pub struct TokenMeta {
/// The address of the token.
pub address: Address,
Expand Down Expand Up @@ -45,7 +44,7 @@ impl CurrencyTrait for Token {
}

impl Token {
/// Creates a new `Token` with the given parameters.
/// Creates a new [`Token`] with the given parameters.
///
/// # Arguments
///
Expand All @@ -59,7 +58,7 @@ impl Token {
///
/// # Returns
///
/// A new `Token` instance.
/// A new [`Token`] instance.
///
/// # Panics
///
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod tests {
assert_eq!(error.to_string(), "Addresses are equal");
}

/// Test that `Error::MaxUint` displays the correct error messagit push ge.
/// Test that `Error::MaxUint` displays the correct error messagit.
malik672 marked this conversation as resolved.
Show resolved Hide resolved
#[test]
fn test_max_uint_error() {
let error = Error::MaxUint;
Expand Down
4 changes: 0 additions & 4 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/// Module that contains various methods to comput price
pub mod compute_price_impact;

/// Module that contains various methods to sort
pub mod sorted_insert;
/// Module that contains various methods to compute square root
pub mod sqrt;
#[cfg(feature = "validate_parse_address")]
pub mod validate_and_parse_address;
Loading