ArdanaLabs / dUSD

5 stars 3 forks source link

Price feeder #90

Closed CSVdB closed 2 years ago

CSVdB commented 2 years ago

Implement the price feeder.

Step 1. Implement integration with the 5 chosen CEXes to collect information on the ADA price Step 2. Process the ADA prices into one number Step 3. Integrate with the price module: Update the UTXO after 1h passes by Step 4. Define a systemd service to run the price feeder once every 5 minutes

The 5 CEXes: Coinbase, Binance, Kraken, Huobi, Kucoin

marijanp commented 2 years ago

I'm currently implementing the price feeder and a question/ observation arose. I already implemented Client and APIs in Haskell for Coinbase and Kraken, and made some observations:

Since we will take the median of the prices, we will need a common Price type across the providers, to ensure a correct computation.

The price-module's price dictates when collateral is going to be sold, therefore the most reasonable price type to me is sell, since this is the price we can expect to receive when selling.

I would like to hear your opinions on this. @epiro-ps @CSVdB

Note: this is nothing that blocks me, but it's something we definetly need to decide

epiro-ps commented 2 years ago

@marijanp indeed, we should get this into the design doc to establish a decision.

Some thoughts:

The price module will not only be used for collateral sale during liquidations but also for providing price data to buy actions such as buying dUSD for ADA to stabilize the peg. In this case the buy price would be more useful.

Also our price feeder will eventually be decentralized so we may want to eliminate the complexity of thinking in buy/sell/spot and establish that we're only seeing it as one price, which would inevitably be the spot price.

epiro-ps commented 2 years ago

I dropped a comment in the MakerDAO discord asking them what price their feeders usually provide. Will follow up here when/if they respond.

https://discord.com/channels/893112320329396265/899667556418351194/971010870702387200

CSVdB commented 2 years ago

@marijanp Could you give us some insight into the size of the difference between buying and selling price, and the other price types?

marijanp commented 2 years ago

@CSVdB Well that is difficult to say since the discrepancy depends on the exchange. The discrepancy is called spread and is the comission of the exchange. The spread is regulated for other markets but I couldn't find any information for cryptocurrencies. The problem with the spot price is, that we're not able to compute it using the other price types. Since we are working witch CEXs which are marketplaces we're more likely to get Buy/Sell price information (which we could average) I'll add an overview of the available endpoints of the respective CEX's in a future comment

CSVdB commented 2 years ago

Any order of magnitude estimates? Is the relative difference 1%? 0.1%? 0.01%? What percentage of the spread seems to be due to the exchange's fee, is this 10%, 90%, 99%?

marijanp commented 2 years ago

Overview of the different Price information available at the respective CEXes: