fn swap_without_fees(
        &self,
        source_amount: u128,
        _swap_source_amount: u128,
        _swap_destination_amount: u128,
        trade_direction: TradeDirection,
    ) -> Option<SwapWithoutFeesResult> {
        let token_b_price = self.token_b_price as u128;

        let (source_amount_swapped, destination_amount_swapped) = match trade_direction {
            TradeDirection::BtoA => (source_amount, source_amount.checked_mul(token_b_price)?),
            TradeDirection::AtoB => {
                let destination_amount_swapped = source_amount.checked_div(token_b_price)?;
                let mut source_amount_swapped = source_amount;

                // if there is a remainder from buying token B, floor
                // token_a_amount provided to avoid taking too many tokens, but
                // don't recalculate the fees
                let remainder = source_amount_swapped.checked_rem(token_b_price)?;
                if remainder > 0 {
                    source_amount_swapped = source_amount.checked_sub(remainder)?;
                }

                (source_amount_swapped, destination_amount_swapped)
            }
        };
        let source_amount_swapped = map_zero_to_none(source_amount_swapped)?;
        let destination_amount_swapped = map_zero_to_none(destination_amount_swapped)?;
        Some(SwapWithoutFeesResult {
            source_amount_swapped,
            destination_amount_swapped,
        })
    }
/// Constant price curve always returns 1:1
Constant price curve always returns 1:1
Constant price curve always returns 1 : 1
fn swap_without_fees(
        &self,
        source_amount: u128,
        _swap_source_amount: u128,
        _swap_destination_amount: u128,
        trade_direction: TradeDirection,
    ) -> Option<SwapWithoutFeesResult> {
        let token_b_price = self.token_b_price as u128;
        let (source_amount_swapped, destination_amount_swapped) = match trade_direction {
            TradeDirection::BtoA => (source_amount, source_amount.checked_mul(token_b_price)?),
            TradeDirection::AtoB => {
                let destination_amount_swapped = source_amount.checked_div(token_b_price)?;
                let mut source_amount_swapped = source_amount;
                // if there is a remainder from buying token B, floor
                // token_a_amount provided to avoid taking too many tokens, but
                // don't recalculate the fees
                let remainder = source_amount_swapped.checked_rem(token_b_price)?;
                if remainder > 0 {
                    source_amount_swapped = source_amount.checked_sub(remainder)?;
                }
                (source_amount_swapped, destination_amount_swapped)
            }
        };
        let source_amount_swapped = map_zero_to_none(source_amount_swapped)?;
        let destination_amount_swapped = map_zero_to_none(destination_amount_swapped)?;
        Some(SwapWithoutFeesResult {
            source_amount_swapped,
            destination_amount_swapped,
        })
    }
fn swap_without_fees ( & self , source_amount : u128 , _swap_source_amount : u128 , _swap_destination_amount : u128 , trade_direction : TradeDirection , ) -> Option < SwapWithoutFeesResult > { let token_b_price = self . token_b_price as u128 ; let ( source_amount_swapped , destination_amount_swapped ) = match trade_direction { TradeDirection :: BtoA => ( source_amount , source_amount . checked_mul ( token_b_price ) ? ) , TradeDirection :: AtoB => { let destination_amount_swapped = source_amount . checked_div ( token_b_price ) ? ; let mut source_amount_swapped = source_amount ; // if there is a remainder from buying token B, floor // token_a_amount provided to avoid taking too many tokens, but // don't recalculate the fees let remainder = source_amount_swapped . checked_rem ( token_b_price ) ? ; if remainder > 0 { source_amount_swapped = source_amount . checked_sub ( remainder ) ? ; } ( source_amount_swapped , destination_amount_swapped ) } } ; let source_amount_swapped = map_zero_to_none ( source_amount_swapped ) ? ; let destination_amount_swapped = map_zero_to_none ( destination_amount_swapped ) ? ; Some ( SwapWithoutFeesResult { source_amount_swapped , destination_amount_swapped , } ) }
Constant price curve always returns 1:1
Constant price curve always returns 1 : 1
&self
source_amount
u128
_swap_source_amount
u128
_swap_destination_amount
u128
trade_direction
TradeDirection
&self
source_amount
u128
_swap_source_amount
u128
_swap_destination_amount
u128
trade_direction
TradeDirection