DeFi Deep Dive
Decentralised finance replaces the intermediary with a program: trading, lending and market-making run as public code that anyone can call.
Decentralised finance replaces the intermediary with a program: trading, lending and market-making run as public code that anyone can call. The benefits are real and so are the failure modes, and the failure modes are unusual enough to deserve most of this course.
AMM Protocols
An automated market maker replaces the order book with a pool and a formula. Liquidity providers deposit two assets, and the formula quotes a price that moves as the pool's balance changes; you trade against the pool instead of against another trader.
The consequence is price impact by design: every trade moves the pool, so a large order in a small pool gets a materially worse price. Bicoince's own DEX path routes through venues and aggregators rather than running a pool, but the same arithmetic decides what a swap costs you.
Liquidity Provision
Providing liquidity means depositing assets so others can trade against them, in exchange for a share of the fees. It is not interest and it is not a deposit: it is taking the other side of whatever flow arrives, continuously.
You end up holding more of whichever asset is falling and less of whichever is rising, because the pool sells the winner to buyers as it climbs. Fees earned have to exceed that drift for the position to beat simply holding the two assets, which is the calculation the next section is about.
Yield Farming Strategies
Yield farming is chasing the highest available return on deposited assets, usually paid in a protocol's own token on top of trading fees. The headline number is an annualised rate computed from a snapshot, and it assumes the reward token holds its value.
Both assumptions break routinely: emissions dilute, rewards are sold by everyone earning them, and a rate that was 200% when you read it can be single digits by the time the transaction confirms. Work in what you would actually keep after selling the reward, not the advertised percentage.
Impermanent Loss
Impermanent loss is the gap between holding two assets and depositing them into a pool. When their prices diverge, the pool rebalances against you, and the wider the divergence the larger the gap.
The name is generous. It is only "impermanent" if prices return to where they started; if you withdraw after a divergence, the loss is exactly as permanent as any other. Compare a pool position against the honest baseline — what the same two assets would have been worth untouched.
Flash Loans
A flash loan borrows without collateral on the condition that it is repaid inside the same transaction. If the repayment does not happen, the whole transaction reverts as though nothing occurred, which is why no collateral is required.
They make arbitrage possible without capital, and they also make attacks cheap: an attacker can briefly command enormous size to move a thin market that some other protocol reads as a price. Most famous DeFi exploits are not a flash-loan bug but a price-source bug that a flash loan made affordable to exploit.
Protocol Security
The code is the counterparty. An audit is one team's review at one point in time, not a guarantee, and audited protocols have been drained. Upgradeable contracts mean today's code is not necessarily tomorrow's, and an admin key is a person who can change the rules.
Before depositing, look for what would go wrong rather than what should go right: who can upgrade or pause it, where its prices come from, how long it has run with real money in it, and what happens to your position if the front end disappears.
MEV & Arbitrage
Because pending transactions are public and block producers choose the order, there is value in deciding what executes first. Arbitrage between venues is the benign version; sandwiching — trading ahead of your swap and behind it — is the version that costs you directly.
This is what slippage settings are actually for. A generous slippage tolerance is an invitation, and a large swap announced to a public mempool at a loose tolerance is the most expensive way to trade on-chain.
Risk Assessment
Put the risks in layers and price each one. The asset can fall. The protocol can be exploited. The chain can congest so you cannot exit when you want. The reward token can fall faster than it accrues. A stablecoin in the pair can stop being stable.
None of these is exotic and all of them have happened. The practical test is simple: if you cannot say where the yield comes from and who is paying it, you are the one paying it.
After this course you can
- Explain why a large swap in a small pool fills badly.
- Compare a liquidity position against simply holding the two assets.
- Say what a flash loan actually makes cheap.
- List what you would check before depositing into a protocol.