BlockPo / BlockPo-to-Tradelayer

Incubation Repo for the TradeLayer protocol, 0.2.0
http://www.tradelayer.org
Other
8 stars 8 forks source link

Mark Price Calculation, Component 1: Turnover-filtered Volume #480

Open patrickdugan opened 2 years ago

patrickdugan commented 2 years ago

By default anyone can wash trade a large ALL positions while having enough LTC to transfer at a lower price, and it's an equal weight "vote" on what the next block's mark price should be. This is very bad. One way to fix this is to filter out volume that is turning over each block, or each N blocks or less. N can increase based on volatility (sampled in another ticket).

We need to write a function that looks at every trade from trade channels in a block, and then looks at the addresses, returns data from the historical trades RPC (we need to double check that this RPC includes trade channel activity and not just on-chain orderbook xTrade matches) and then uses that data to return true or false about the trade. It returns true if the has traded recently within N blocks and false if not. If it's false we can include the trade channel transaction into our VWAP sample.

Let's focus on commit one or two constituent functions to get this filtering done.

To make this transparent we should also add an RPC call to return this filtered data for a native contracts VWAP. If not a native contract then it will return an err message stating that the contract must be a native contract with a VWAP sample to return this data.