SoroswapLibrary
Last updated
Last updated
The SoroswapLibrary is a rust crate that anyone can implement in their smart contracts. Check all the documentation here:
You can find the Soroswap library code on the . in
1.- Add this to your Cargo.toml:
[dependencies] soroswap-library = ""
2.- Import it:
3.- Use it:
Sorts token addresses.
Calculates the address for a pair without making any external calls.
Fetches and sorts the reserves for a pair.
Given some asset amount and reserves, returns an amount of the other asset representing an equivalent value.
Useful for calculating optimal token amounts before calling deposit
.
Given an input asset amount, returns the maximum output amount of the other asset (accounting for fees) given reserves.
Used in get_amounts_out
.
Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
Used in get_amounts_in
.
Given an input asset amount and an array of token addresses, calculates all subsequent maximum output token amounts by calling get_reserves
for each pair of token addresses in the path in turn and using these to call get_amount_out
.
Useful for calculating optimal token amounts before calling swap
.
Given an output asset amount and an array of token addresses, calculates all preceding minimum input token amounts by calling get_reserves
for each pair of token addresses in the path in turn and using these to call get_amount_in
.
Useful for calculating optimal token amounts before calling swap
.
This Soroswap library is designed to facilitate efficient and precise token swapping and handling in the Soroswap.Finance ecosystem. It includes a range of functions to support various aspects of token management, from sorting token addresses to calculating reserves and performing chained calculations for different pairs. These functions are crucial for the optimal functioning of Soroswap in the Stellar network.