DeFi Basics and Web3 Payment Infrastructure
DeFi runs lending, trading and earning on smart contracts instead of a bank, which is why it is open around the clock, why you pay a gas fee, and why every risk lands on you.
Gas pays the network's validators for the computation and storage each action needs, and it keeps spammers out. The base fee is set by demand, so it climbs when the chain is busy and everyone bids for the same block space. The same swap that costs $6.00 now would run about $36.60 on a congested chain, though nothing about your transaction changed.
Illustrative figures only, assuming ETH near $2,000. Your wallet works out the real total before you confirm.
Try the gas estimator above. Drag the network from quiet to busy and watch the same transaction get dearer; that changing fee is gas, the price of getting anything done on-chain. In DeFi there is no bank clerk, no help desk, and no undo button. The lending, borrowing and trading all run as code on a public blockchain, and that code does exactly what it says, instantly, for anyone who calls it. That is the appeal: you can put your stablecoins to work at any hour without asking permission from anyone. It is also the risk: the code is effectively the bank, and if it has a flaw or you sign the wrong thing, no one is coming to reverse it. This module walks through what you can actually do with stablecoins on-chain, why you pay a gas fee to do it, and where the real danger sits.
What DeFi actually is
Decentralised finance (DeFi) is a way to lend, borrow, trade and earn on stablecoins through smart contracts, which are self-executing programs on a blockchain, instead of through a bank or broker. No one approves your transaction in the middle and no one holds your money for you. You connect your own wallet, the contract runs its rules automatically, and the result is final.
Being open, permissionless and always on is what makes DeFi powerful. Having no one in charge is also what makes it unforgiving, because a bug in the code can drain funds and there is no manager to call.
What you can do with your stablecoins
A few main things are worth knowing:
- Lend and earn interest. Deposit stablecoins into a lending protocol (Aave and Compound are well-known examples) and earn interest paid by people who borrow against their own collateral.
- Provide liquidity. Supply your stablecoins to a decentralised exchange's pool (an automated market maker such as Uniswap) and collect a share of the trading fees. This carries a subtle risk called impermanent loss, explained in the fold below.
- Yield aggregators. Vaults that move your funds around automatically to chase the best available return.
One warning covers all of them. A high advertised yield is not a free lunch, it is a price tag for hidden risk. If a "stable" return runs well into double digits, assume something risky is paying for it, whether that is protocol insolvency, a token-emission scheme that will collapse, or an outright scam.
A wallet is not a bank account
This distinction sits underneath everything in Web3.
An exchange account behaves like a bank account. The exchange holds your coins and your keys, you log in with a password, and the provider can freeze, reverse or help recover things when they go wrong.
A wallet address is different. You control it with a private key, you alone are responsible for it, and a transfer out is final and irreversible. No one can undo a mistyped address or claw back a payment you were tricked into signing. In DeFi you act from your own wallet, which means you get full control and full responsibility in the same move.
Gas fees: why moving costs money
Every on-chain action (a transfer, a swap, a contract call) makes the network's validators do real computation and storage, so you pay a gas fee to compensate them and to keep spammers out. Gas is priced by demand. When many people want to transact at once, they bid for the limited space in each block and the price rises; when the chain is quiet it falls.
On Ethereum, gas is quoted in gwei (a billionth of one ETH). Since an upgrade called EIP-1559, the fee splits into a base fee that is burned plus an optional tip to the validator. The rough total is gas units multiplied by the gas price, and your wallet works this out for you before you confirm. Different blockchains sit at very different fee levels, which is a big reason some chains are preferred for small, everyday payments.
The risk profile: no safety net
The most important thing to take in before you deposit a cent is that DeFi has no safety net. The main risks:
- Smart-contract bugs. A single flaw or exploit can empty a whole pool in one transaction, and the code is often frozen in place once deployed.
- Governance failures. Token-holder votes or admin keys can change the rules, or be captured by an attacker.
- Oracle and bridge failures. Bad price data or a broken cross-chain transfer can wreck a position.
- No deposit insurance. There is no government scheme, no chargeback, and no support line that can reverse a loss.
If a protocol is hacked, or you approve a malicious contract, the funds are usually gone for good. Treat any DeFi yield as risk-bearing income, size your position accordingly, and never deposit more than you can afford to lose.
Impermanent loss, in plain terms
When you supply two assets to a liquidity pool and their prices move apart, the pool automatically rebalances between them. You can end up with less value than if you had simply held the two assets in your wallet and done nothing. That gap is impermanent loss.
It is called "impermanent" because it shrinks if the prices drift back together, but it becomes very real the moment you withdraw while they are still apart. The trading fees you earn are meant to make up for it, and sometimes they do not. For a stablecoin-to-stablecoin pool the effect is usually small, because both sides are meant to hold the same value, but it is never automatically zero.
How a gas fee is actually calculated
Say you swap stablecoins on Ethereum. The swap uses about 150,000 gas units, the gas price is 20 gwei, and ETH is $2,000.
Fee = 150,000 × 20 gwei = 3,000,000 gwei = 0.003 ETH, which at $2,000 is about $6.
Now the network gets busy and the gas price triples to 60 gwei. The identical swap now costs about $18. Nothing about your swap changed; only the competition for block space did. This is why the same action can feel cheap one hour and expensive the next.
Does a 5% yield actually beat holding?
Suppose you lend 10,000 USDC at 5% APY. The headline interest is $500 a year. Now subtract the real costs. If you paid about $6 in gas to enter and $6 to exit, that is $12 gone before you earn a thing.
More importantly, the protocol carries genuine insolvency and smart-contract risk that a bank deposit does not, and there is no insurance behind it. So the true risk-adjusted return sits meaningfully below the advertised 5%. The lesson is not "never lend", it is "read the headline number as gross, then subtract gas, then subtract risk".
Quick knowledge check
What replaces the bank or broker in DeFi, and why is that both the appeal and the danger? Smart contracts: self-executing code on a blockchain that runs the rules automatically while you transact from your own wallet. The appeal is that it is open, permissionless and always on; the danger is that the code is effectively the bank, so a bug or a bad signature cannot be reversed.
Why do gas fees exist, and what makes them go up? They pay validators for the computation and storage that each on-chain action needs, and they deter spam. They rise when many people want to transact at once and bid for the limited space in each block.
You see a stablecoin vault advertising a 30% "stable" yield. What should you assume? That the high return is paying for hidden risk, not offering free money. A double-digit "stable" yield usually signals protocol insolvency risk, a token-emission scheme that can collapse, or a scam. Treat it as a red flag, not a bargain.
Sources
- Ethereum.org, "Decentralized finance (DeFi)", plain-language overview of smart-contract-based finance without a central intermediary.
- BIS (Bank for International Settlements), "Quarterly Review: Trading in the DeFi era", how liquidity-provider losses (impermanent loss) arise when pooled assets move apart in price.
- Ethereum.org, "Gas and fees", why gas exists, gwei pricing, and the EIP-1559 base-fee-plus-tip model.