Util Helpers
The SDK provides a few helper functions to use with the SDK. These are useful for formatting and sorting the quotes received from the SDK.
Helper functions
quoteToRoute
Converts a ProviderQuoteOption
object to a Route
object that can be executed.
This is useful for executing a quote that has been selected by the user.
sortProviderQuotes
Sorts an array of provider quotes by arranging the payment methods of each provider
in descending order based on the amountFiat
value in the receive
property.
sortByHighestReturn
Sorts a list of provider quotes by the highest return value in fiat currency among
all the providers.
This function takes an array of ProviderQuoteOption
objects, where each provider
may have multiple payment methods. It flattens the array by creating a new object
for each payment method, retaining the provider's other properties. The resulting
array is then sorted in ascending order based on the amountFiat
value of the
first payment method in each provider's payment methods array.
sortByFees
Sorts provider quotes by fee amount either within each provider or across all providers.
filterByPaymentMethod
Filters provider quotes based on payment method types. Can either include only specified payment methods or exclude specified payment methods. Removes any provider quotes that end up with no payment methods after filtering.