DEFI: Build the DeFi protocol that holds real money and does not get drained, and be the team whose pool survived the attack.

$ 150.922,00

This book teaches you to build decentralized finance the way the teams who run protocols with real total value locked build it: assuming every price can be moved, every deposit can be withdrawn at the worst moment, and every integration is a contract that will call you back mid-transaction. It starts from the idea of money legos and composability, then builds an automated market maker from the constant-product formula up, so you understand slippage and impermanent loss as things you can compute rather than words. From there it builds a lending market: collateral, the health factor that decides who is safe, the liquidation that keeps the system solvent, and the interest-rate model that prices borrowing. It covers yield aggregators and vaults, staking and reward accounting, and the two things that quietly decide whether a protocol survives: where your prices come from and what a flash loan lets an attacker do with them for one transaction. It closes on the discipline that separates a demo from a deployment, testing your protocol against real liquidity with a mainnet fork, and shipping and upgrading it without handing yourself a backdoor. The running example is one small protocol, built and attacked across the chapters. For engineers who are going to put a protocol on chain and want to be the team whose pool did not get emptied.

SKU: DEFI-EN Category: Tags: , , ,

Description

A DeFi protocol is not one contract, it is a set of contracts that trust each other with money and quote prices to each other in real time, and that is exactly what an attacker buys a flash loan to exploit. The math looks simple until you meet the reader who deposited into your pool and the arbitrageur who noticed your price came from a spot reserve he can move in the same transaction. Your lending market is solvent until one liquidation reverts and leaves a position underwater. Your vault earns yield until the strategy it forwards funds to gets drained and your share price is suddenly a fraction of what your users think they hold. Building DeFi is composability turned against you: every integration you add is another contract that can call you back, another price you did not compute, another assumption someone will pay to break.

This book teaches you to build decentralized finance the way the teams who run protocols with real total value locked build it: assuming every price can be moved, every deposit can be withdrawn at the worst moment, and every integration is a contract that will call you back mid-transaction. It starts from the idea of money legos and composability, then builds an automated market maker from the constant-product formula up, so you understand slippage and impermanent loss as things you can compute rather than words. From there it builds a lending market: collateral, the health factor that decides who is safe, the liquidation that keeps the system solvent, and the interest-rate model that prices borrowing. It covers yield aggregators and vaults, staking and reward accounting, and the two things that quietly decide whether a protocol survives: where your prices come from and what a flash loan lets an attacker do with them for one transaction. It closes on the discipline that separates a demo from a deployment, testing your protocol against real liquidity with a mainnet fork, and shipping and upgrading it without handing yourself a backdoor. The running example is one small protocol, built and attacked across the chapters. For engineers who are going to put a protocol on chain and want to be the team whose pool did not get emptied.

Who this is written for

This book is for: engineers who can already write a smart contract and now have to build a protocol that holds other people’s deposits, quotes its own prices, and lets strangers borrow against collateral, where a single mispriced swap or a stale oracle is not a bug report but a drained pool.

What you’ll get inside

  • Chapter 1: The night my ten-line contract inherited someone else’s bug
  • Chapter 2: The exchange that sets its own price with one multiplication
  • Chapter 3: The receipt for your deposit, and how the first depositor can rob the rest
  • Chapter 4: The number that decides whether you keep your house or lose it
  • Chapter 5: The stranger who gets paid to seize your collateral
  • Chapter 6: Why your debt grows while you sleep, and who decides how fast
  • Chapter 7: The vault that farms while you sleep, and the one that farms your users
  • Chapter 8: How to pay a million users their exact share without a single loop
  • Chapter 9: Where your protocol gets its prices, and why the cheap way gets you drained
  • Chapter 10: Free money for one transaction, and the attacks it makes possible
  • Chapter 11: Testing a protocol by forking the real world and attacking it
  • Chapter 12: The day I deployed, and what I wish I had done before I did