Conversation

1) When it comes to oracles, you just have to make up your own damn mind
Image
121
1,665
3) Let's say that you have a margin trading protocol which allows cross-margin between a bunch of different assets. Your algorithm is "require 30% initial margin and 20% maintenance margin"--i.e. allow ~3x leverage, and margin call accounts if they get up to 5x leverage.
2
131
4) You have an 'oracle' which reports the price of the assets, and your risk engine--the thing that calculates users' margin--uses prices from that oracle. One asset--say XYZ--has a price of roughly $0.40 according to the oracle. A user--Alice--has $200m XYZ and -$25m USD.
2
99
5) Alice: 500m XYZ ~ $200m -25m USD = -$25m net value ~ $175m margin ~ 87.5% how much should the risk engine allow Alice to withdraw?
12
99
6) A naïve answer would be "well if you require 30% margin then Alice can withdraw up to $115m; at that point her account would be: 500m XYZ ~ $200m -140m USD = -$140m net value ~ $60m margin ~ 30%"
1
64
7) But there's a picture of a mango over The Oracle's face. So, obviously, XYZ is actually MNGO, and MNGO isn't really worth $0.40; it's worth around $0.04. Alice's real account value is, roughly: 500m XYZ ~ $20m -25m USD = -$25m net value ~ -$5m margin < 0 It's already gone.
3
86
8) But for a brief period, someone (almost certainly Alice) bought enough MNGO that it did trade for $0.40, and before people could get in to sell and return it to a more reasonable price, the risk engine had already allowed Alice to withdraw $100m from Mango Markets.
2
102
Replying to
10) What should you really do? Well, let's look at what FTX does, and why *it* didn't have any risk engine issues.
3
99
11) First, FTX has EWMA price bands. What this means is, roughly, that FTX consumes raw price feeds. But, before feeding that into its risk engine, it bounds those price feeds so that they can't move more than ~20% over a 5 minute period.
8
170
12) The reason, basically, is: b) If an asset's price moves 3x in 1 minute, it's decently likely to be bad data, or a temporary wick, or something like that b) If the asset's price stays there for 5 hours, that new price is likely the true economic price
2
110
13) FTX's MNGO index price moved--there should be *some* update--but much less than others because of those EWMA price bands. In particular, while FTX's index topped out at a ~100% increase, on some exchanges the move (temporarily!) hit a +900% increase (!!!).
Image
7
100
14) Second, FTX uses 'IMF Factors'. The larger your position, the greater % margin we charge. For MNGO, the margin we charge is 0.00025 * sqrt(MNGO tokens). If you wanted to have a 500m MNGO position, FTX would have required, uh, 500%. (Bounded at 'fully funded'.)
2
127
16) And some positions -- like the one in question -- are large and illiquid enough that the risk engine forces you to fully collateralize a position.
4
95
17) So even before hitting position limits, the risk engine ensures that the collateral backing a position is sufficient. And what if you try to use something other than dollars as collateral? Well, we haircut it. In some cases, a lot.
4
102
18) (It's worth noting that this is all referring to FTX International. In addition to all of the above protections, our amendment for FTX US Derivative's margin order would only be for BTC and ETH futures using USD margin. No MNGO, and certainly no MNGO collateral.)
6
103
19) There are a bunch of other risk engine protections and sanity checks, too, which would have caught something like this. So -- back to the oracle. It reports: "MNGO: $0.40" Is it wrong?
7
103
20) Well, it depends on what it's promising. But probably it's just promising to tell you, literally, what MNGO is currently trading at. And, for a brief period, on some exchanges, MNGO was in fact trading at $0.40. The real problem here was using the raw oracle price.
7
100
21) The Oracle tells you everything and nothing--the history and current state of markets. It's the risk engine's job to consume that information, and decide what positions are safe. Sometimes it can't just regurgitate The Oracle. Sometimes it has to make up its own damn mind.
11
134
22) Which doesn't mean that the risk engine needs to be manual. You can create a set of rules for it so that it's conservative, and handles apparent large moves gracefully. That, in the end, is probably the most important thing we do at FTX.
16
145
23) And, really, it's why we started FTX in the first place. Tradfi had sophisticated (sometimes!), slow, manual risk models, and--in some FCMs--fast, egregious ones. Crypto had fast, automated, broken risk models. There was an opening for a thoughtfully automated risk engine.
71
354