Almost every week for the past two years I’ve had one-on-one video calls with devs who are trying to upskill in Solidity / smart contract development.
From my experience, here are the top reasons devs, even professional ones, struggle to understand DeFi codebases.
#1 They are weak at math and don’t understand how to translate an algebraic expression to Solidity code.
The code itself is just some expression of an underlying mathematical model of how the devs expect the system to work. Although math may be elegant, Solidity has limited support for fractions and must avoid overflow/underflow, so Solidity formula doesn’t look like the formulas in the whitepaper.
You can’t make sense of code unless you understand what it is trying to do in the first place
#2 They have poor fundamentals in basic finance
If you can’t translate interest-per-year to interest-per-second, some constants just aren’t going to click. Similarly, how are you going to make sense of things, if you don’t even know what “leverage” is in the first place?
#3 They don’t actually use DeFi
This one kind of surprised me, but at least half the devs who have an interest in learning DeFi haven’t used it beyond the absolute basics.
Yes, DeFi is risky. But the best way to get an intuition for it is to actually use it. Lend money. Borrow money. Swap coins. Make some leverage trades.
Do this with money you can afford to lose, don’t try to strike it rich.
When you actually use DeFi, you realize the “surface area” of how state can change is not as big as it originally seems.
#4 They don’t understand how vaults work
Almost every protocol out there uses some kind of notion of “LP shares” or some variation of it. If you don’t grind vault math, you won’t be able to understand the logic behind some of the code you see (such as protection against inflation attacks or how/why the share prices get updated).
How to fix this:
1. If you are scared of algebra, fix this. No need to be a gangster, but if you can’t get a formula from one form to another, you will be too slowed down by this. Solidity devs actually need math, unlike most fullstack devs.
2. Translate algebra to Solidity code and test it over the domain it is supposed to work in. If you get under/overflow or serious rounding issues, figure out why. Your code is not supposed to revert when given a valid value in its domain.
3. Actually use DeFi. Learn by doing, but only use money you can afford to lose. Use an L2 instead of mainnet to save gas.
4. Write a vault from scratch. You can copy the Solmate codebase, delete the vault code (ERC-4626), then write it again and see if your tests pass.
5.56K
116
The content on this page is provided by third parties. Unless otherwise stated, OKX TR is not the author of the cited article(s) and does not claim any copyright in the materials. The content is provided for informational purposes only and does not represent the views of OKX TR. It is not intended to be an endorsement of any kind and should not be considered investment advice or a solicitation to buy or sell digital assets. To the extent generative AI is utilized to provide summaries or other information, such AI generated content may be inaccurate or inconsistent. Please read the linked article for more details and information. OKX TR is not responsible for content hosted on third party sites. Digital asset holdings, including stablecoins and NFTs, involve a high degree of risk and can fluctuate greatly. You should carefully consider whether trading or holding digital assets is suitable for you in light of your financial condition.