Code
You can find the Soroswap library code on the Soroswap GitHub repository. in https://github.com/soroswap/core/tree/main/contracts/libraryUsage as a crate
1.- Add this to your Cargo.toml:Public functions
Every function below ispub in the crate and returns a Result, with
SoroswapLibraryError as the error type. Signatures are from version 2.0.0.
sort_tokens
pair_for
get_reserves_with_factory
get_reserves_with_pair
quote
- Useful for calculating optimal token amounts before calling
deposit.
get_amount_out
- Used in
get_amounts_out.
get_amount_in
- Used in
get_amounts_in.
get_amounts_out
get_reserves_with_factory and then
get_amount_out for each hop, and returns every intermediate amount.
- Useful for calculating optimal token amounts before calling
swap.
get_amounts_in
get_amount_in, returning every preceding minimum
input amount.
- Useful for calculating optimal token amounts before calling
swap.