wallet
wallet copied to clipboard
[In-app swaps] Create 0x Api services for price and quote
Description
Create a service/wrapper over the 0x api in valora-rest-api, that the swap screen can use. It must provide:
- a method to fetch the swap rate between 2 tokens: https://docs.0x.org/0x-api-swap/api-references/get-swap-v1-price
- a method that executes the swap: https://docs.0x.org/0x-api-swap/api-references/get-swap-v1-quote (it would be nice if this method receives the expected price for the swap, so we can avoid sending the transaction if the price changed too much).
- use signed message as authentication for both endpoints
Acceptance Criteria
- [ ] Method for fetching exchange rates
- [ ] Method for executing the swap
There is a rate limit of 3 requests/second for the 0x API - do we want to wrap this api (more flexibility) or call directly from the app (less rate limit issues)? @silasbw curious for your opinion
https://docs.0x.org/developer-resources/api-faqs#is-there-a-fee-to-use-the-0x-api - seems like you can pay to use the 0x api but pricing isn't clear
@dievazqu will get Denisse's contact's advice
another point for wrapping 0x ourselves is being able to price compare with mento (since 0x does not use Mento and Mento could have a better swap price for small swaps between native celo assets)