mycelium-ethereum / pools-client

Client interface for Perpetual Pools
pools-client.vercel.app
9 stars 18 forks source link

Create TradingView charts #358

Open KittyLomas opened 2 years ago

KittyLomas commented 2 years ago

Note: The token prices are significantly less than the spot price of the market (e.g., SPOT of BTC is around AU$80,000 and the token prices of the pools tracking BTC are around AU$1). So we're going to have to show 2 axis -- SPOT and SMA on one, and token prices on the other.

The chart will be added to the new 'Pools' page in a later iteration. The rough wireframes are below, to give you an idea of the direction that this feature is headed

image

KittyLomas commented 2 years ago

@ScaredIbis can you please review this ticket, and let me know if you have capacity to pick it up?

chrdevmar commented 2 years ago

@KittyLomas just so you know it is not realistic for me to implement this functionality this sprint. I have put some of my initial thoughts down below:

Create a chart for each market (BTC/USD and ETH/USD).

  • Ideally, we'll want the options of charts to be dynamic (would likely be driven by a list of known pools/markets from the SDK)
  • We currently capture both the pool token prices and the oracle prices at each upkeep event, this would probably be the easiest and most accurate source of data since it will provide us both data series (both the underlying price and the pool token price at the same points in time, however, these will be only approximately hourly data points) Display the SMA price for this market
  • We would need to source the SMA parameters from somewhere, this could also live in the pools list in the SDK So we're going to have to show 2 axis -- SPOT and SMA on one, and token prices on the other.
  • I'm struggling a little bit to picture how it would look, my thought was that we could just normalize to percentage movements for both the underlying and the pool tokens, then they would overlay nicely If the user has an investment in this market, give them the option to display their profit and loss
  • where would this show?

I don't know if this is the case, but I imagine the main problem we are trying to solve with this is to visualize movements of the pool token price compared to the underlying price. We could probably satisfy this by using a simpler charting library (basically just showing a few lines overlayed on a chart with some way of seeing both the underlying price and token price at each datapoint) and using the historic upkeep data as the single data source. The drawback to this is that it would only contain underlying price data starting from when the pool was deployed. If users have specifically requested tradingview charts/technical analysis tools then we can go with trading view, but will likely incur extra dev time

KittyLomas commented 2 years ago

@ScaredIbis that's okay. This doesn't need to be done this sprint, but I would like us to start to begin implementing this soon. We can break the work down into smaller deliverables: E.g.,

  1. Chart hourly oracle price of the underlying
  2. Chart the hourly pool token prices, etc.

The hourly price of the underyling (from the oracle) and hourly token prices are great, but we are also going to need the price of the underlying in real-time, through TradingView or something else.

I will speak to Webby about the SMA pricing. This is something that we will need down the track (for V2 launch). We could retrive and display the other 3 prices first (hourly oracle, hourly token price, real-time underlying).

This is what I meant by having 2 axis btw: image

We are going to move towards a TradingView charting library at some stage, so I think it makes sense to do it now, rather than using a simple graphing library now, and upgrading later. Do you have any major hesitations to TradingView? @dospore has set it up for Swaps in the past so I might speak to him about it. It'd be good to understand the technical requirements on your end, so I can figure out the EFFORT vs IMPACT and understand if it's worth it.