Skip to content

feat(api): support quotes to amount #265

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cruzdanilo
Copy link

this pr adds support for fetching quotes by specifying the desired toAmount instead of fromAmount.

this is achieved by:

  • introducing a new union type for QuoteRequest that allows either fromAmount or toAmount (but not both).
  • updating the getQuote method in src/services/api.ts to:
    • validate that either fromAmount or toAmount is provided, and not both.
    • construct the api url to hit the /quote/toAmount endpoint when toAmount is specified, or the existing /quote endpoint when fromAmount is used.
  • updating the unit tests in src/services/api.unit.spec.ts to cover the new validation logic for toAmount and the case where both fromAmount and toAmount are erroneously provided.

this aligns the sdk with the v1/quote/toAmount api endpoint (docs: https://apidocs.li.fi/reference/get_v1-quote-toamount), providing users with more flexibility when requesting quotes.

this is my first contribution. any feedback is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant