BlockPo / BlockPo-to-Tradelayer

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

Technical Debt Assessment: Settlement + Margin Calc. + Liquidation + Insurance #120

Closed patrickdugan closed 4 years ago

patrickdugan commented 4 years ago

The most likely place where we're going to have edge-cases and related math bugs, which warp consensus and can create sync breaks, is in the intersection of two developer's code in the most complex and risk-sensitive part of a derivatives exchange, how the clearing and liquidation engine meet. To test this we need to run testnet algorithms that simulate large numbers of participants similar to the benchmarking levels, plus a highly capitalized that runs the market in periodic square waves. Then we can test the bankruptcy of a decent % of the addresses participating and if the margin updates take them out properly, insurance fund pays out to compensate, and if the remainder (let's assume the insurance fund gets some ALL from the churning of these algos for N blocks and has not a lot in it) is bailed-in on a pro-rata basis by taxing the unrealized PNL of the winning positions.

Run an algo like this with random intervals for a while to generate some good sample data and increase confidence levels, publish these results. Of course if we find debilitating edge-cases and math bugs we can fix them. Without any incidence we can be more confident that our technical debt is largely paid.

patrickdugan commented 4 years ago

We're basically doing this now QA testing the settlement algo/liquidation with an Oracle contract. Will close when we have assessed the results.

patrickdugan commented 4 years ago

The ticket to build a layered audit/insurance pay-in/bail-in application after the settlement algo returns, is the result of this inquiry so we're finally closing this ticket 6 months later.