wallet icon indicating copy to clipboard operation
wallet copied to clipboard

[In-app swaps] Create 0x Api services for price and quote

Open dievazqu opened this issue 2 years ago • 4 comments

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

dievazqu avatar May 05 '22 20:05 dievazqu

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

kathaypacific avatar May 17 '22 15:05 kathaypacific

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

kathaypacific avatar May 17 '22 15:05 kathaypacific

@dievazqu will get Denisse's contact's advice

kathaypacific avatar May 17 '22 15:05 kathaypacific

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)

kathaypacific avatar May 17 '22 15:05 kathaypacific