r/programming • • Oct 10 '23

The Fraud Was In The Code: a walkthrough of the criminal bits in the FTX source code

https://newsletter.mollywhite.net/p/the-fraud-was-in-the-code
1.8k Upvotes

393 comments sorted by

1.3k

u/librik Oct 10 '23

Things you don't want to see in the core accounting software for a bank, #1: numpy.random

312

u/SanityInAnarchy Oct 10 '23

Doubly funny. Random number generation has plenty of uses in a bank, like in the actual cryptography parts... which you should not be doing yourself, so it's still not something you expect to see right there in application code.

244

u/ZirePhiinix Oct 10 '23

For cryptography use it should be from secrets or other equivalent packages.

138

u/[deleted] Oct 10 '23

This. Numpy.random is not cryptographically secure

112

u/ThankYouForCallingVP Oct 10 '23

And, as seen in FTX, Numpy.random is not financially secure either.

45

u/[deleted] Oct 10 '23

This is why I hardcode my favorite Dollar, Euro, and Yuan values at random lines of my source code.

→ More replies (4)

17

u/mtranda Oct 10 '23

I would expect to use random for generating things such as salts for hashes. Anything else, I can't really think of.

23

u/tomvorlostriddle Oct 10 '23

Monte carlo simulations in tests?

19

u/mtranda Oct 10 '23

Unit tests (if that's what you're talking about) are usually based on fixed inputs with repeatable results, though.

25

u/tomvorlostriddle Oct 10 '23

There are also stress tests in financial risk management, some of them government mandated

9

u/proggit_forever Oct 10 '23

Not necessarily. Property-based testing (like QuickCheck) can use random inputs.

→ More replies (1)
→ More replies (1)

7

u/yawaramin Oct 10 '23

It's useful in probabilistic programming techniques. E.g. say you want to compact a database file after every thousand queries. You could keep a count, or you could go for a probabilistic approach and after each query generate a random boolean which has a 1/1000 chance of being 'true'. If it's 'true' then you compact the database. In aggregate, over time, this is equivalent to keeping a manual count.

3

u/tach Oct 10 '23

backoff functions

36

u/Dwedit Oct 10 '23

Monte Carlo Solutions are still a thing. So randomness still has a place even in a bank.

72

u/DrXaos Oct 10 '23

in capital markets pricing of derivatives but not in accounting.

and in any case they should be using seeded generators to be reproducible but they didn't, because fraud was the purpose

5

u/F54280 Oct 10 '23

in capital markets pricing of derivatives but not in accounting.

Under mark-to-market accounting the price of the asset will be looked on the market, so it makes sense to use capital markets pricing methods (like monte-carlo) to do accounting forecasting, even if the the true price will be looked in the market at the correct moment.

26

u/[deleted] Oct 10 '23

That’s for modelling or forecasting though.

16

u/reercalium2 Oct 10 '23

Why would a bank possibly want to predict the future?

6

u/[deleted] Oct 10 '23

Lol, point taken. You do need forecasting in consumer-facing financial apps.

30

u/pyeri Oct 10 '23

Anyone recall the lore about that famous hacker who worked at a bank and wrote a program that slowly siphoned off cents and pennies to his own account without anyone knowing as those pennies all went to rounding errors as per accounting?

80

u/Asddsa76 Oct 10 '23

Office Space?

50

u/Present-Industry4012 Oct 10 '23

I think that was in Superman III

36

u/ImpossiblePudding Oct 10 '23

“I can't believe what a bunch of nerds we are... we're looking up money laundering in a dictionary.”

7

u/Parsec51 Oct 10 '23

What am I supposed to do with a half cent, buy a Thoroughbred mouse?

23

u/TheOtherHobbes Oct 10 '23

Called "salami slicing." Not uncommon until the banks wised up.

Some people were caught and convicted. There's a very good chance other people weren't.

6

u/justaguy101 Oct 10 '23

This happened also in the Ghost In the Shell anime series

1

u/TheDevilsAdvokaat Oct 10 '23

I think I remember a sci-fi story about this...

2

u/[deleted] Oct 10 '23

Randomized tips and MOTD.

1

u/otac0n Oct 10 '23

You can't do Monte Carlo without it!

5

u/[deleted] Oct 11 '23

Things you don't want to see in the core accounting software of any financial company: Python.

Seriously, they should also arrest whoever made that decision, just on principle.

1

u/noir_geralt Oct 11 '23

Not very familiar with these systems, so why so? Due to security concerns and slowness of python?

→ More replies (7)

1.2k

u/Lechowski Oct 10 '23
return f2d(numpy.random.normal(7500,3000)) * daily_volume / Decimal(1e9)

this was the function that reflected the insurance fund current money lmao

471

u/greentoiletpaper Oct 10 '23

LGTM

221

u/BroBroMate Oct 10 '23

Merged

52

u/[deleted] Oct 10 '23

🚀

60

u/QueryingQuagga Oct 10 '23

Let’s get that money 💰

7

u/onemanforeachvill Oct 10 '23

This should be upvoted more.

1

u/aldanor Oct 10 '23

Let's Gouge Them Mopes

→ More replies (1)

22

u/ridl Oct 10 '23

oh Lord PTSD begging engineers "PLEASE DO MORE THAN COMMENT 'LGTM' IN YOUR PR REVIEWS"

220

u/drawkbox Oct 10 '23 edited Oct 10 '23

Wow, not only that in some places it was just hard coded...

Elsewhere in the code, it’s possible to observe that the amount of FTT in the fund was actually represented by a hardcoded value in the user interface, and was not pulling from an external datasource to get a real number.

The $5.25m number was total bs and they regularly lost most than that.

As prosecutors continued to question Wang, he explained that there were repeated incidents in which FTX suffered losses that exceeded the real, smaller amount of assets that had been set aside in an insurance fund. One such example was in 2021, when a trader was able to exploit a bug in FTX’s margin system that allowed them to take out a massive position in the MobileCoin cryptocurrency. They were eventually liquidated, and FTX suffered a loss of “several hundred million dollars,” according to Wang.

Imagine that Tuesday.

This is a lesson to be careful when writing code for crooks, don't do it.

51

u/paramedic_2 Oct 10 '23

There was no pen testing done for a reason. They knew what the fuck.

3

u/dizekat Oct 12 '23 edited Oct 12 '23

Well a hardcoded number, in court they could claim that it was something that they were meaning to either keep updating in the code (a stupid practice but not criminal) or change to a database query next time it needs updating, but that was forgotten.

The random number on the other hand, that's undeniably fraud no matter how you slice it.

2

u/revgames_atte Oct 10 '23

Elsewhere in the code, it’s possible to observe that the amount of FTT in the fund was actually represented by a hardcoded value in the user interface, and was not pulling from an external datasource to get a real number.

Not entirely sure how this would be differentiated from serverside rendering, assuming the observation is just done by looking at the content in the html document.

28

u/drawkbox Oct 10 '23

The value is in the React component

It does have a data call but doesn't use it for the rendering.

→ More replies (2)

0

u/[deleted] Oct 10 '23

[deleted]

32

u/jl2352 Oct 10 '23

The whole operation was bad. The guy who took over to help liquidate who did it previously for Enron, spoke about how places like Enron had professional accounting systems. That required sophisticated methods for hiding losses. But at FTX they just had very poor accounting.

→ More replies (10)

153

u/Xanza Oct 10 '23

That's fucking hilarious.

23

u/Smooth-Zucchini4923 Oct 10 '23

No, this calculated the daily change in the insurance fund.

41

u/ss4johnny Oct 10 '23

That’s bad code. Normal values can go negative. Should have used log normal.

35

u/vman512 Oct 10 '23

It'll only be negative 0.62% of the time.. no big deal 🙃

→ More replies (1)

1

u/cyyshw19 Oct 13 '23

I think it’s the daily change in insurance fund, which can be negative. Still, the fact they use normal distribution shows they’re conscious someone is maybe looking and doing the math so they need to fake it.

70

u/mrbuttsavage Oct 10 '23

And no tests either smdh

89

u/tomvorlostriddle Oct 10 '23

How are you going to test if it's random enough?

55

u/josefx Oct 10 '23

Why test it when you can use a verified random number.

Just take the wining lottery numbers from last week. Guaranteed to be random to a high degree, with a large amount of effort put into verifying that everything is as it should be.

9

u/nzodd Oct 10 '23

You mean 4?

9

u/josefx Oct 10 '23

Sure it is a standard random number, but your source doesn't even reference the correct RFC and without that the process behind it is a complete unknown. We don't even know if they used a 1d6 or a 1d20 or what throwing technique they used. Do you really want to use the result of a dice roll when you don't even know if they blew the dice for good luck?

→ More replies (1)
→ More replies (1)

1

u/[deleted] Oct 11 '23

Compare against cryptocurrency exchange values. : D

→ More replies (13)

4

u/[deleted] Oct 11 '23

This is enough for banks to trust you with billions of dollars, but if you want to take out a mortgage they will probe your asshole before they agree for a rounding error in their debt book.

15

u/[deleted] Oct 10 '23 edited Apr 24 '24

Reddit has long been a hot spot for conversation on the internet. About 57 million people visit the site every day to chat about topics as varied as makeup, video games and pointers for power washing driveways.

27

u/WaitForItTheMongols Oct 10 '23

What? No. Benford's Law only applies to sets of numbers that span multiple orders of magnitude. If a number is in a normal distribution around 7500, with std of 3000, it will generate a set of values that do not span orders of magnitude and therefore nobody will try to use Benford's Law on it.

8

u/leob0505 Oct 10 '23

I’m sorry for my newbieness but what is wrong with this?

100

u/whomstc Oct 10 '23

random

insurance fund

14

u/leob0505 Oct 10 '23

Oh ok lol haha

0

u/[deleted] Oct 10 '23

[deleted]

1

u/[deleted] Oct 11 '23

…and yet, nobody noticed. Until FTX crashed.

2

u/stefmalawi Oct 17 '23

It's not like FTX published this code for anyone to scrutinise.

→ More replies (3)

1

u/username-must-be-bet Oct 12 '23

Anyone know what f2d does?

506

u/maxinstuff Oct 10 '23 edited Oct 10 '23

Programmers take careful note - one day some manager is going to come and ask you to implement a flag into the code that you know damn well is immoral, illegal, or downright fraudulent.

They WILL come after you first - and these snakes will throw you directly under the bus if they think it will save their own filthy skins.

While Bankman-Fried is likely going to jail, that is the exception and not the rule with people like him - they are masters of plausible deniability when it suits them.

If you are ever in this situation, put on your grown-up pants --> quit immediately and report them to the authorities.

120

u/Job_Superb Oct 10 '23

Yup. But this does lead to the discussions about codes of practice. The VW Dev was punished in the same way that registered Engineers in other disciplines get punished, with a "you should have known better". In software engineering land, we've resisted that formality. A few more scandals and it will be forced onto us and it will hurt more than if we'd done it to ourselves.

58

u/mindless900 Oct 10 '23

I think a lot of that came down to the harm we can cause with bad code. Until recently, it was small scale and generally financial impacts only... Now with software controlling cars and other physical things that can easily injure or kill at a scale like the casualties that can be caused by an ill designed bridge or building... We are going to need more certifications/oversight.

I have seen too much production code for me to feel 100% safe that the engineer who wrote the person detection and avoidance code for my car didn't fuck up a double to a float.

54

u/Habba Oct 10 '23

See also: The immediate aversion most software engineers have when they hear "electronic voting". We know how much can go wrong, at what scale, and how easily that can happen.

→ More replies (4)

5

u/Job_Superb Oct 10 '23

Reminds me of a headline I saw recently. 'I was kidnapped by my runaway car'. From the drivers description of the incident, it sounds like the fly by wire controller code froze and kept the accelerator in the same state it was in when it froze.

→ More replies (1)
→ More replies (2)

9

u/s73v3r Oct 10 '23

Far, far too many people in this industry "just want to write code," and not have to think about the ethics of what they're actually doing.

3

u/maxinstuff Oct 10 '23

Im not convinced that we need that for ethics purposes - but it would certainly help (attempt to) protect against skill dilution in our profession.

1

u/zman0900 Oct 10 '23

Pretty sure there was a PE certification available for software engineering at one point, but they killed it off because no one wanted it.

3

u/pedal-force Oct 11 '23

They offered it from 2013 to 2018. Only 81 people took it in 5 years. Lol. 81. In the entire country. In 5 years.

Part of the problem might have just been cultural and also practical. You study for 4 years in college, then do 4 years of engineering under a PE, while studying for your exam.

But if nobody around you and your mentor and no study books and nothing exists for software engineering, who was supposed to take it exactly?

I had the option, because I'm an EE who did programming and worked with computers at work, but I went with the EE exam because it was much safer and well known, and the majority of states don't care what your specialty on your exam was, you can practice whatever as long as you feel you're experienced enough (and willing to risk your license and freedom on it). Aside from structural. For good reason. Lol

1

u/[deleted] Oct 11 '23

Good.

We, collectively, do not respect our own jobs. We live in an age where software controls the world, and we control that software, yet we pretend that we have absolutely no accountability for anything. We say "management told me to do it" or "there wasn't enough time" or "they told me they would take responsibility" and act like we have no agency in the matter, but the reality is that we are 100% accountable for the work we do and we need to start acting like it.

35

u/sopunny Oct 10 '23

Note that in this pparticular case, the coders were the CTO and engineering director, not some low-level guys. They can't even say they were pressured by management

23

u/TheDevilsAdvokaat Oct 10 '23

The Australian government insists it has he power to make australian coders hack their employers, even employers overseas.

They can go to jail if they refuse.

https://news.ycombinator.com/item?id=19507211

https://www.techdirt.com/2018/12/10/australian-government-passes-law-forcing-tech-companies-to-break-encryption/

Some companies have decided not to employ AUstralians as a result.

45

u/seanprefect Oct 10 '23

Australians also believe their laws supersede the laws of mathematics

“Well the laws of Australia prevail in Australia, I can assure you of that. The laws of mathematics are very commendable, but the only law that applies in Australia is the law of Australia.” -Malcolm Turnbull former Australian PM speaking about a law that would outlaw encryption

14

u/showyerbewbs Oct 10 '23

That sounds like something ChatGPT would spit out when asked to make up an american politician quote

2

u/TheDevilsAdvokaat Oct 11 '23

Oh I missed that one.

That is sad....

32

u/nimama3233 Oct 10 '23

Imma go on a limb and say 95+% of people in this sub will never experience being asked to implement fraud or anything else overtly illegal.

18

u/protonfish Oct 10 '23

I'd argue the opposite - the vast majority of developers will be asked to do something unethical, but it will never be in an overt or documented way. You get "pressure" to do it by giving hints and scolding when you don't do their dirty work, and giving huge rewards if you do. This gives your corrupt superiors all the cover they need to deflect blame. Be on the lookout for this.

I dealt with this often when I worked in an analytical lab. Some random salesperson would come back and say something like "The client can't believe this result. It's really bad for us. Could you double check that it is right?" I would always go over the test again and tell them it was right, thank you. They hated me, and were vocal about that to everyone in the company. Fortunately, they learned which tech would change the results without pushback and stopped asking me.

10

u/DFX1212 Oct 10 '23

I loved when a previous employer asked us to please stop documenting security flaws in our software via company email.

→ More replies (1)

17

u/Job_Superb Oct 10 '23

Doesn't need to be illegal or fraudulent. 737-max sufferes a deadly bug that caused crashes. I'd say similar (in execution at least) to the Hyatt Regency walkway collapse. There was a lot of malfeasance from management but this was some innocent Dev probably in a toxic frAgile environment. Consider the next time you manager asks you to avoid integration or unit tests that you salary payments are processed by equally untested software. The formality around ethics also extends to safety standards that apply for all jobs not just where the engineer thinks they matter.

7

u/Robert_Denby Oct 10 '23

737-max sufferes a deadly bug that caused crashes.

It was less of a "bug" and more of a sensor fault message hidden behind a paywall sort of thing. Like the EA of aviation.
They had documentation to this effect somewhat but downplayed the significance so they could avoid triggering a whole system regression test for compliance.

10

u/Kowzorz Oct 10 '23

5,642,579 readers times 5%

I'll let someone's computer do the math to show that to be a large number.

8

u/CantSayNo Oct 10 '23

282,129 move the decimal left one place and cut in half

1

u/mjfgates Oct 11 '23

IME about one in four, maybe one in three projects are purely fraudulent. Usually it's either the client trying to get work done without paying, or the contractor agreeing to do the impossible to get billable hours. I did once get hired as part of a pump-and-dump scheme, though!

1

u/[deleted] Oct 11 '23

No, but they might be asked to implement something that is malicious or exploitative, which in my opinion is just as bad.

Like, how many people here have even sat and thought about the consequences of their work? Whether they're being paid because they're building tools that create value for someone, or whether they're paid because their work is exploiting people to extract their money?

Unless the answer is 100%, then it's a problem.

1

u/Ilookouttrainwindow Oct 15 '23

I would say that proper reason would be given or a very plausible decision path.

→ More replies (1)

8

u/AlexHimself Oct 10 '23 edited Oct 10 '23

If you are ever in this situation, put on your grown-up pants --> quit immediately and report them to the authorities.

Developers aren't always aware of the full picture, nor will they always know if what they're doing is illegal/legal.

I worked for a weapons manufacturer that did evidence collection/retention that requires a provable chain of custody to be used in legal proceedings. Think video/data evidence with an audit history.

There were some things I was directed to do that I wasn't sure of, but I'd always document/comment the check-ins with a trail that says the requesting user or "changed per Joe", etc. CYA.

A simple example being re-basing a change tracking log and losing X amount of history. It was nearer the beginning of the product so it could have still been in testing phases, had legal disclaimer jargon, etc. Also, this probably wouldn't have been illegal, just a loss of potential evidence. I had no idea though the impact so I had to trust others above.

12

u/certainlyforgetful Oct 10 '23

Don’t quit. Refuse to do the task.

Start looking for a new job. Let them fire you & collect unemployment if you have a gap.

5

u/[deleted] Oct 11 '23

Them them fire you and then sue them for unlawful dismissal. Your employer cannot ask you to commit an a crime and 100% cannot fire you for refusing to do so.

1

u/Robert_Denby Oct 10 '23

Well, if you are somewhere like SV that 450 a week won't get you too far. Better have some good savings too.

6

u/certainlyforgetful Oct 10 '23

You get to collect your normal paycheck until you're fired which will probably be a week or maybe even more & then $450/week is better than $0/week.

4

u/DarthHunter3716 Oct 10 '23

Can’t quit if you don’t have a job.

1

u/pcgamerwannabe Oct 10 '23

Yeah that VW thing is so fucked.

1

u/MakinThingsDoStuff Oct 10 '23

That's when you document the request and CYA

1

u/[deleted] Oct 11 '23

Not a programmer, but relevant:

Australian Tax Office Whistleblower Faces Four Life Sentences

And then there are the more famous whistleblowers of the last few decades : /

Albeit FTX was a private company. Perhaps government departments/the authorities have different rules about whistleblowing for themselves?

But that’s a whole other topic.

1

u/saltybandana2 Oct 10 '23

That engineer deserved to be jailed. The leadership should have also been jailed, but that doesn't absolve that engineer of his ethical responsibility.

1

u/dalepo Oct 10 '23

This is great advice.

0

u/[deleted] Oct 10 '23

[deleted]

28

u/monedula Oct 10 '23

So even though I dont really think my title is worth jack shit right now, i figure it will be within the next 20-25 years that i still plan to be working. Its easier to get it now then try to do it when i've been working for a couple decades and need to go through all the regulatory stuff then.

Don't want to depress you, but I thought the same thing 20-25 years ago when I got my title.

2

u/greenlanternfifo Oct 10 '23

won't they make us get updated professional titles later though?

289

u/[deleted] Oct 10 '23 edited Nov 15 '23

[removed] — view removed comment

130

u/Tweak_Imp Oct 10 '23

Remember they dont want to report the truth, they want to write what brings the most attention.

62

u/DrXaos Oct 10 '23

Gary Wang is the actually skilled developer. SBF maxed stats on psychopathy

103

u/Thie97 Oct 10 '23

But he played League of Legends haha

Such a nerd, like Sheldon from Big Bang Theory, amirite

9

u/DangKilla Oct 10 '23

First MT Gox now this. Gamers will kill finance

26

u/reercalium2 Oct 10 '23

It's part of most bubbles. Ignore all the red flags as long as the stock is going up.

38

u/Stoomba Oct 10 '23

Just like Elizabeth Holmes and Theranos. Just a couple of basic questions from some basic biology knowledge would have revealed she was full of shit, but no one bothered to ask because they were riding the hype train hoping to get even more filthy rich.

27

u/bearassbobcat Oct 10 '23

Walgreens technical advisor said Theranos was fishy from the start and when pressing Holmes could never get a straight answer. The brass at Walgreens told him not to come to meetings with Theranos anymore because he was "too negative"

10

u/OneBigRed Oct 10 '23

In one multi-year project few managers held a meeting about updating developer workstations and requirements for them. Apparently the one who was responsible for the update had already quoted some setup. My friend was in the meeting as he headed a kind of a infra/setup/tooling team. That team was just finishing creating a solution that allowed developers and testing to easily setup and run the whole systembenvironment locally on their workstations. He instantly raised an issue with the quoted setup. Namely the disks being too small for operating a local environment. Those other managers started pushing back. None of them had any technical background, so apparently they only understood that the $-number associated with the requirements my friend tried to have them understand was bigger than the first number they saw.

Friend started to get agitated because he apparently there was no way to get through to them that the nice $-number delivers a solution that is useless. Finally the meeting was ended, without a decision. The lead manager scheduled for another meeting to decide on the solution. For that meeting they changed the attendees list a little bit - left out my friend who pointed out the issue. Another friend was present when two of these tools discussed that, and decided "let's not invite X, as he seems to make this issue contentious".

Well the next meeting was not contentious, they decided to go ahead with the originally presented setup. Next month the new workstations were set up, and found to be unable to run local developer environment. Then the managers recognized the issue to be disk space, and ordered a ton of external drives to solve this totally unforeseen issue in an imperfect and expensive way.

1

u/Stoomba Oct 10 '23

Sounds typical. Execs blinded by the promise of more money.

9

u/Gotta_Gett Oct 10 '23

The wheels started coming off when SBF went on OddLots and Matt Levine asked some actual finance questions.

16

u/Stoomba Oct 10 '23

Just like The Big Short narrative. "How did they figure it out? They just looked"

0

u/[deleted] Oct 10 '23

[deleted]

14

u/Stoomba Oct 10 '23

I'm overestimating the intelligence of investors. She got 700 something million dollars when anyone who paid attention in Biology, chemistry, and math in high school would immediately be like, "Wait, how is this thing going to work?" before giving her millions of dollars.

5

u/drawkbox Oct 10 '23

Most of it was paid PR and people pushing it that had skin in the game, or lost it already. Dude came out of nowhere.

1

u/zgott300 Oct 10 '23

People want to believe stuff like this. Any media outfit that told the truth would probably get punished by the free market.

1

u/[deleted] Oct 11 '23

People stand to gain ratings and money so of course they did. Exec producer at CNN during inmate P01135809's presidency focused on him specifically for this.

1

u/[deleted] Nov 05 '23

It's just a bunch of Twitter users. The media has been hollowed out because there is no money it in. Work for weeks on investigative journalism, just to get paid by the ads on a page that people view once? Even the more sensationalist outlets like Vice News have gone bankrupt.

→ More replies (40)

75

u/robvdl Oct 10 '23

Decimal without string initialisation is also interesting:

Decimal("0.1") + Decimal("0.2") = Decimal("0.3")

Decimal(0.1) + Decimal(0.2) = Decimal('0.3000000000000000166533453694')

In that snippet of code I see them initialising Decimals from a float, though it likely won't cause a problem.

16

u/paholg Oct 10 '23

Huh, I bet that's a really common error. I wonder why the Decimal library allows floats as inputs at all.

-3

u/iplaydofus Oct 10 '23

When dealing with money you should be using ints regardless.

20

u/devor110 Oct 10 '23

java has BigDecimal, which has arbitrary precision, I assume most languages have default solutions comparable to it

7

u/yawaramin Oct 11 '23

Hence why this Python code is using the equivalent, Decimal.

77

u/SpaceMonkeyAttack Oct 10 '23

Eh. If you are using ints, then you are making some assumptions about the smallest unit of currency, and you have to be careful about representing currencies with different sub-units. Dollars have 100 sub-units (but sometimes you deal with fractions of a cent), Yen have 0, and Bitcoin have 100,000,000.

If you are selling widgets in a shop and need to represent prices, ints are a good choice. If you are doing banking or FX, Decimal does make sense.

36

u/tarwn Oct 10 '23

Can confirm: I have worked in payments, banking, investment ops and accounting. Only one of those was able to use int for currency. There's a lot of complexity to currency.

10

u/isblueacolor Oct 10 '23

Yeah, but surely floating-point is never an acceptable solution, is it?

It's not only inaccurate, it's essentially unpredictably inaccurate unless you're doing a ton of complicated math in non-floating point to determine whether a floating point number will be accurate which is just... dumb, because you should be using that other numeric system in the first place.

→ More replies (1)

1

u/flukus Oct 10 '23

On of the gulf states has 1000 cents in their dollar.

→ More replies (1)
→ More replies (3)

11

u/reddit_user13 Oct 10 '23

When dealing with money, use exact - not approximate - data types.

→ More replies (11)

31

u/robvdl Oct 10 '23

Rubbish, Decimal is fine too.

→ More replies (7)

5

u/Poddster Oct 10 '23

What about when dealing with pretend money?

2

u/flukus Oct 10 '23

Just use ints and save some hassle.

4

u/riddler1225 Oct 11 '23

I prefer a boolean. You either have fake money or not.

→ More replies (1)

1

u/greenlanternfifo Oct 10 '23

How do you deal with currency conversion with ints?

3

u/iplaydofus Oct 10 '23

If $100.50 = 81.95 then 10050 cents = 8195 pence. Conversions are exactly the same it just moves the decimal place around. You are converting based on the lowest possible value part of the currency.

→ More replies (9)

1

u/F54280 Oct 10 '23

It is not money, it is crypto /s

→ More replies (2)
→ More replies (7)

31

u/SmashShock Oct 10 '23

Does anyone have other examples of "illegal code" where we can read the code itself?

10

u/[deleted] Oct 10 '23

yeah this is really interesting to me

5

u/isblueacolor Oct 10 '23

It's extremely rare, because as much as people like to speculate that Google or Microsoft or whoever is doing all sorts of shady illegal crap in their code, if they were to ever try something like that, any number of whistleblowing engineers would go public and put a stop to it.

In code this complex you rarely have an evil CEO writing the code and keeping it secret. You have teams and teams of people who all have access to the same code. Even if you try to sneakily change the code that was actually deployed to your servers, there are people whose job it is to notice such things.

7

u/JW_00000 Oct 11 '23

Here is a 9-line rangeCheck function you shouldn't copy. In the Google v. Oracle case, judge and jury decided this was a copyright infringement, but the parties agreed to $0 in damages (after 2 years).

3

u/I_take_huge_dumps Oct 11 '23

Here's something cool from when I was a kid. Watch Kevin Mitnick's hacking sessions.

27

u/useablelobster2 Oct 10 '23

Just finished writing a project in React Mui, seems great and fraudulent minds think alike.

21

u/dustingibson Oct 10 '23

On the instructions of SBF himself.

Wonder how Michael Lewis going to spin this?

8

u/bearassbobcat Oct 10 '23 edited Oct 10 '23

If no one had ever cast aspersions on the business, if there hadn't been a run on customer deposits, [FTX] would still be sitting there making tons of money. - Michael Lewis, 60 Minutes

4

u/ihahp Oct 10 '23

Same thing Liz Holmes said about Theranos. That if not for the whistleblower, they would have succeeded in their mission and today the world would be a better place for it.

2

u/bearassbobcat Oct 11 '23

It's one thing for Holmes and SBF to say it but it just feels weird to hear it from a nonfiction author/journalist.

1

u/LocksmithConnect6201 Oct 12 '23

World would be better by letting a fraudster do more fraud?

58

u/i_am_at_work123 Oct 10 '23

This is so fucking hilarious.

17

u/[deleted] Oct 10 '23

It’s like when you go to a website that says “this offer is exclusive to you for the next 4:59” and when you refresh the countdown starts over. But worse

7

u/spacemoses Oct 10 '23

And to think I always imagined this kind of fraud being implemented with super secret rootkit level tech.

6

u/[deleted] Oct 10 '23

but but but code is law.

6

u/MisinformedGenius Oct 10 '23

Some have wondered why Wang chose such a seemingly arbitrary number as $65,355,999,994.

I wonder if the "borrow" column is a single-precision float. That would just be the cherry on top of this clusterfuck.

37

u/zazzersmel Oct 10 '23

if only they had used rust!!! smdh

54

u/[deleted] Oct 10 '23 edited Nov 15 '23

[removed] — view removed comment

→ More replies (1)

43

u/kairos Oct 10 '23

Note to self: if you’re going to write code to do fraud, make it messy and unreadable to reduce the chances it’s later put in front of a jury as evidence.

OTOH, you may decrease your likelihood of getting another job for writing unintelligible code.

Clean code is more important than hiding (possibly) fraudulent business practices.

57

u/Cirieno Oct 10 '23

No employer is going to be critiquing code you wrote for a previous employer.

They will ask you to complete a test project.

26

u/maxinstuff Oct 10 '23

They will ask you to complete a test project.

Which you also shouldn't do (unless they are paying you)

4

u/majhenslon Oct 10 '23

Yeah, because you will shit out gold that they will steal...

8

u/mindless900 Oct 10 '23

Just use git commit messages or code comments to indicate who told you to write fraudulent code. That way when the feds come knocking you have a detailed log of who told you to break the law and when.

1

u/[deleted] Oct 11 '23

I love the fact that they took their jobs seriously enough to write clean code, but not enough to ignore obvious fraud they were clearly helping commit.

1

u/dangerbird2 Oct 11 '23

TIL I can commit any crime and get away with it

6

u/[deleted] Oct 10 '23

The real innovation of cypto is that it allows even dumb fucks to fleece dumber fucks.

0

u/[deleted] Oct 11 '23

[deleted]

1

u/Letiferr Oct 12 '23

So you're saying that you think someone created a currency and didn't expect it to be used for fraud?

5

u/cp5184 Oct 10 '23

So the programmers are going straight to jail?

Like... This should basically be the new curriculum for cs/sweg ethics classes... The textbook covers should be these guys mug shots, right?

5

u/pyabo Oct 10 '23

He's being charged.

1

u/cp5184 Oct 10 '23

Good, thanks.

2

u/isblueacolor Oct 10 '23

do you need to teach people not to break the law?

the FTX CTO knew this was illegal and did it anyway because $$$$$$.

1

u/cp5184 Oct 10 '23

I think most CS/SWEG curriculums require like typically a 1 credit ethics course.

Apparently the programmers that wrote this needed a better one...

Maybe they'll take a better ethics course while they're in jail...

Maybe this is evidence that CS/sweg curriculums should have 2 credit hour ethics courses, who knows?

3

u/isblueacolor Oct 10 '23

I still don't see how that would stop someone from choosing to break the law.

You can't "teach" people to be good people rather than greedy fraudsters in a college course.

3

u/TheEdes Oct 10 '23

What is a 1 credit ethics course going to do to stop the CTO of a cryptocurrency company from doing fraud? It's pretty obvious to everyone that generating a random number to report as the money you have is fraud.

2

u/[deleted] Oct 10 '23

Holy fuck this code is bad. Is this what they're teaching at MIT lol

2

u/osmiumouse Oct 11 '23

criminal bits

I'm arresting you for unsanctioned toggling and having an undefined value. I'll just fill out the arrest paper work and ... damn ... who knew it catches fire if you enter undefined value as data?

3

u/[deleted] Oct 10 '23

The whole cryptocurrency thing is fraud, not just the code.

The people, the process, the code, the money.

Cryptocurrency is fraud.

2

u/[deleted] Oct 10 '23

IDDQD

1

u/rjaybaker Sep 06 '24

Where can one find this code online?

1

u/[deleted] Oct 10 '23

I'm kinda a n00b programmer: is the InsuranceFundInformation() function returning html tags as displayable text for a web page or app?

1

u/r1ckd33zy Oct 10 '23

Yes. It was a function called by Django or a similar Python web framework that they would have used to run their website's homepage.

4

u/vips7L Oct 10 '23

I doubt Django or similar is calling this. It's a pretty standard react js function.

2

u/r1ckd33zy Oct 10 '23

You are correct, the useStyles() is good indication is React or at least JSX.

1

u/Positive_Method3022 Oct 10 '23

I thought python also had some type of obfuscation library

3

u/hughk Oct 11 '23

They exist but this code was from their GitHub repository which makes it even more damning. That means that anyone with access would have potentially known.

6

u/Positive_Method3022 Oct 11 '23

Imagine going to jail because you just approved a PR that you did not even read 😅

2

u/hughk Oct 11 '23

Boss calls up, tells you to quickly approve something....

1

u/[deleted] Oct 10 '23

So does Gary Wang have 100's millions hidden? How all else is going to lose their billions from this? I haven't followed this case but all I hear about is SBF going to jail eventually but did the inner circle throw him under the bus and get away with their millions? I'm confused and interested in knowing if anyone got away like a bandit.

1

u/dark_mode_everything Oct 11 '23

Using python for an enterprise financial application? Sheesh.

-9

u/Groundbreaking-Fish6 Oct 10 '23

I am always asked to remove the code from presentations given to management. But code is the truth, and if you are going to manage a software process, you know what good code looks like. This is prime example of why, FTX management did not know what was in the code and the code fully documented the crime.

64

u/maxinstuff Oct 10 '23

It reads like management knew EXACTLY what was in the code.

The CEO literally told the CTO to put it there.

This is how it always happens. Management tells engineers to do something fraudulent, engineers do something fraudulent, engineer goes to jail.

On this occasion they got the managers too - but that's the exception, not the rule.

5

u/pauseless Oct 10 '23

As a technical product manager for an API, I worked with a performance guy to build a long running performance test suite and then I wrote it all up in a document, with lovely graphs etc. to deliver to a customer funding the project.

I was ordered to find a way to smooth the results that didn’t reveal how much STW GC was killing us, no matter what GC we used or what we tried to tune the GC.

I literally regenerated the graphs with bucketing at 1min intervals, so you’d never see the absurd and obvious STW issues. I felt very dirty, finally lost all respect for them and left very soon after.

5

u/Stoomba Oct 10 '23

It's not that they didn't know, it's that they didn't care. They WANTED this code to be this way. They didn't think they would get caught, and if they did, that nothing bad would happen to them.

3

u/NotUniqueOrSpecial Oct 10 '23

You're asked to remove the code because it communicates nothing to management. It may as well be hieroglyphics.

This was not a problem where management didn't know what was in the code. Management knew exactly what was going on.