top | item 37804493

FTX "insurance fund" calculated by multiplying trading volume by random number

206 points| danso | 2 years ago |twitter.com | reply

169 comments

order
[+] samtho|2 years ago|reply
Isn’t the bigger issue that the fund itself was fake? If they made the decision to set aside some amount of money to be untouchable based on a random number, that is, uh, unconventional to say the least, but they very purposefully chose not to have an insurance fund despite advertising that they did which makes this all the more sinister.
[+] opportune|2 years ago|reply
Yes. This should be an instrumental price of evidence in proving that FTX leadership was not “tragically incompetent” but rather willfully and knowingly defrauded its customers.
[+] doubloon|2 years ago|reply
i think when you are trying to prove a company is lying about having a zillion dollars of insurance, it helps if you can kind of pull the curtain down and show everyone the number 'zillion' was made up by someone throwing a pair of dice, not by someone counting a pile of zillions of dollar bills.
[+] fnordpiglet|2 years ago|reply
Well, yes, the issue is it was fake. But they compounded their fraud by publicly asserting a value of the fund, and the fact they implemented it as a random number shows malicious intent. Sometimes you can wave around incompetence etc as a mitigating factor, but this is clearly intentional deception and this proves it clearly and beyond a doubt.
[+] ngoldbaum|2 years ago|reply
Fun to see an open source project I contribute to (numpy) used to commit some light fraud.
[+] sanderjd|2 years ago|reply
I'd guess numpy has been used for lots of fraudulent accounting! Congratulations, I guess?
[+] wqtz|2 years ago|reply
I guess the dude who wrote that function thought, maybe I shouldn't add a docstring or any comments to that function. What is he/she even supposed to write "function to commit corporate insurance fraud."?

Protip. If you are committing fraud in the future - use a compiled language, do not use offsite version control and UPLOAD ONLY THE BINARY.

[+] EMIRELADERO|2 years ago|reply
> Protip. If you are committing fraud in the future. Use a compiled language, do not use offsite version control and UPLOAD ONLY THE BINARY.

Until you get prosecuted and legally required to turn over the source code, as it happened here.

[+] tedivm|2 years ago|reply
It's always weird when people try to give advice on how to commit crimes here, but it's even weirder when the advice is horrible.
[+] ksd482|2 years ago|reply
The bytecode of the binary could also be used to prove it was a random number generator, right?
[+] twic|2 years ago|reply
Put the fraudy bit in a config file and don't commit your config.
[+] jncfhnb|2 years ago|reply
I’m really disappointed by the lack of comments explaining the logic
[+] rich_sasha|2 years ago|reply
There are, however, some type annotations.
[+] birdyrooster|2 years ago|reply
I am sorry we didn't serve your interests
[+] goosedragons|2 years ago|reply
Can't that go negative occasionally too? Was that intentional?
[+] mxmlnkn|2 years ago|reply
np.random itself with that configuration can go negative with a probability of 0.62% as can be derived with scipy.stats.norm(loc = 7500, scale = 3000).cdf(0) or by looping a million times and counting the negative numbers.

Maybe the f2d function filters negative values but it sounds like a simple float-to-double conversion.

I'm not sure whether it was intentional, but, contrary to the headline, this random value was used to update the fund size daily as shown in the rest of the code. So, a single day for which the fund actually decreases wouldn't matter much. It might even be beneficial to make it look more real.

[+] gruez|2 years ago|reply
The function doesn't calculate the insurance fund amount directly, it only applies a change to the insurance fund (line 28), based on last day's trading volume. Presumably this function gets run every day, so the size of the insurance fund would be the sum of this process repeated multiple times. The chances of that going to negative would be astronomically low.
[+] whbrown|2 years ago|reply
Since it's a normal distribution with a mean of 7500, and a standard deviation of 3000 multiplied by daily volume—it would only cause a negative change less than 1% of the time. This "PublicInsuranceFund" truly embodies their culture of "number go up".
[+] timmytokyo|2 years ago|reply
This is obviously just speculation, but there probably wasn't a whole lot of thought put into it by the coder. The goal was "produce a fluctuating number based on daily trading volume so that it looks like we have a real insurance fund". The randomness is simply there to help make the fraudulent representation less obvious. The fact that the number can (very rarely) go negative is just another example of the fly-by-the-seat-of-your-pants thinking pervasive at FTX.
[+] ilyt|2 years ago|reply
I'd imagine that the person writing it thought the function generates numbers 7500 +/- 3000 and not anything outside this range.
[+] wolverine876|2 years ago|reply
Notice that now prosecutors not only understand code, but feel comfortable showing to judges and juries. Not that long ago, everyone's eyes glazed over at the mention of it.
[+] CraigRo|2 years ago|reply
No they don't. The defense attorneys likely know it better actually (I know one). But if the guy who wrote it actually walks a prosecutor through it, it isn't that complicated
[+] dabeeeenster|2 years ago|reply
This is a proper disgrace to software as a discipline. Who writes this?
[+] pfdietz|2 years ago|reply
One advantage of source code control systems is you know who to send to prison.
[+] joneholland|2 years ago|reply
Not defending FTX here, but I think everyone is jumping to a conclusion that this function is used for display purposes only and not to persist the amount that another process then uses to to transfer the insurance amount.

Using some randomization on the daily trading volume makes some sense for what to actually move each day during an end of day process.

[+] mstudio|2 years ago|reply
Someone needs to run a `git blame` on that line of code!
[+] fishywang|2 years ago|reply
That screenshot is already a diff view, which means this is already from either a commit or a PR.
[+] wmf|2 years ago|reply
They've been discussing who wrote which git commits in the trial.
[+] c0balt|2 years ago|reply
It's nice to see (from a quick lock) SQLAlchemy being used in production software on such a scale. However the purpose is quite disappointing
[+] tester756|2 years ago|reply
I don't know python, but what is the "or" here?

For me it looks like this value is used only when there was no data?

Basically else part of monad

[+] Thorrez|2 years ago|reply
The line wrap on line 27 in that text editor is really confusing.
[+] playingalong|2 years ago|reply
How is the number being random a problem?
[+] teraflop|2 years ago|reply
When you tell your customers that a particular number corresponds to something real (e.g. the amount of money in the insurance fund that protects their assets) but you know the number was actually chosen randomly with no connection to that allegedly real thing, that's called "lying", or in the business world "fraud", and you can go to jail for it.
[+] kgermino|2 years ago|reply
Strictly speaking the problem isn’t that it’s random, the problem is that it’s a lie. The fact it’s random proves that the number isn’t real.

The RNG is used to give some variance to the number without accidentally making a pattern (which humans making up numbers tend to do). Literally using a RNG in code that’s meant to produce a value based on real world data is blatant and hard to defend if true.

[+] Vespasian|2 years ago|reply
If you claim it's a fund to mitigate risk you probably should actually put money into said fund and not just pull some number out of your code.

So technically it's not the randomness that's the issue, and a constant or manually updated fake amount would be as bad, but to me as a layman but it seems like they use a random number to imply a sophisticated risk management system.

[+] svnt|2 years ago|reply
The problem is that the reason it is random is to mislead. If it were a static number then it would be obvious it was faked. The value is designed to look like it is pulled from a fund whose balance is determined by market conditions. But viewing the code, there is no fund to get the balance from, only a call out to random().

It’s like putting pillows under your blanket so someone thinks you’re in bed. Once they find the pillows you aren’t going to get away with “oh I thought I was allowed to be out all night.”

[+] danpalmer|2 years ago|reply
...and this is how this code gets written.

When a software engineer writes code because the code makes sense or solves the problem, without interrogating the problem or how it applies to the real world, there can be real and significant consequences. We trust far too much of our lives to tech to ignore these issues when we're on the side of writing the code.

[+] planetpluta|2 years ago|reply
Agreed — isn’t the problem that nothing was actually being set aside for the insurance fund, not that the amount being set aside was based on a random number?
[+] joeman1000|2 years ago|reply
‘_get_change’ is written so poorly
[+] fhk|2 years ago|reply
Maybe abit weird …

No “import numpy as np” !?

[+] tqi|2 years ago|reply
Is python typically used in production trading systems?
[+] bigyikes|2 years ago|reply
I was ready to reply with an “um actually it is an arbitrary number” but… no… it is literally a random number. How did someone commit that and sleep at night?

It’s amazing that some people still defend SBF. Among his sycophants is Michael Lewis, author of Moneyball, The Big Short, and now “Going Infinite” which somehow manages to gloss over the rampant fraud happening at FTX since inception.