Skip to main content

DeFi Explained: Decentralised Exchanges, Lending and Liquidity Pools

Decentralised finance (DeFi) refers to financial applications built primarily from smart contracts on blockchain networks, allowing users to exchange tokens, provide liquidity or borrow against collateral under programmed rules. The absence of a conventional central exchange or bank in some transaction steps does not make these activities risk-free or entirely decentralised. Smart contracts, oracles, bridges, governance keys and market liquidity remain important dependencies.

Understanding DeFi requires studying how each mechanism handles pricing, collateral, fees and settlement. A displayed annual percentage yield may be funded by token incentives and can change or disappear. Liquidity providers can lose money relative to holding their tokens, and borrowers can be liquidated rapidly when collateral prices fall.

Two simple blue liquidity pools with arrows showing decentralised token exchange
DeFi protocols use smart contracts to connect token swaps, liquidity provision and collateralised borrowing, with significant additional risks.

What is DeFi?

DeFi is an umbrella term for blockchain-based applications that automate financial functions such as swaps, lending, collateral management and some forms of derivatives through code. Users often interact with contracts using a wallet and pay network transaction fees. Economic outcomes depend on contract parameters and the external market value of assets used.

A protocol may be accessible through a decentralised smart contract while its website, front-end hosting or governance is controlled by a team. Some designs permit administrators to pause functions or upgrade code. The word “decentralised” therefore describes a spectrum of control and operational dependencies, not an unconditional security guarantee.

What is a decentralised exchange?

A decentralised exchange (DEX) enables trades under blockchain-based rules without requiring the same internal ledger or custody arrangement as a conventional centralised exchange. Some DEXs match orders, while others trade against pooled token reserves through automated market makers (AMMs).

Because transactions are signed by wallets, users typically retain certain key-management responsibilities. But signing an interaction with a malicious contract can still transfer assets or create persistent permissions. A DEX also does not guarantee the accuracy or legitimacy of every token listed or displayed by its interface.

What is an automated market maker?

An AMM is a pricing mechanism in which users trade against a liquidity pool under a mathematical or algorithmic rule. In a simple constant-product pool with two assets, reserves are linked through an invariant commonly written as x × y = k before considering fees and protocol design variations.

As a trader buys one token from the pool, that token becomes scarcer in the reserves and the implied exchange price adjusts. The larger the trade relative to pool depth, the more the effective price may diverge from the starting marginal price. This is a form of price impact distinct from conventional order-book execution.

Worked AMM price-impact example

Consider a hypothetical constant-product pool containing 100 units of Asset A and 10,000 units of Asset B, giving k = 1,000,000. The initial marginal price is approximately 100 B per A. A trader adds 1,000 B to the pool to receive A. Ignoring swap fees, the pool must end with 11,000 B and approximately 90.909 A.

The trader receives 100 − 90.909 = 9.091 A. The average price paid is 1,000 ÷ 9.091 ≈ 110 B per A, above the initial marginal price of 100. This is about 10% average price impact before any protocol fee. The example illustrates why a pool with a large nominal value can still deliver poor execution for a large trade.

Illustrative constant-product poolBefore swapAfter 1,000 B input
Asset A reserves100.00090.909
Asset B reserves10,00011,000
Constant-product k1,000,000Approximately 1,000,000
Marginal B per A100Approximately 121
A received by trader—Approximately 9.091

No-fee constant-product arithmetic; real pools have fees, routing, other contracts and changing liquidity.

What is a liquidity pool?

A liquidity pool holds assets available for protocol-defined trades or other financial activities. Liquidity providers may deposit assets in exchange for a contractual or tokenised claim on the pool. They can earn trading fees or incentives, but their final asset composition and value change as other users trade.

Pool claims are not equivalent to bank deposits. They are subject to smart-contract risk, token-price movements, liquidity conditions, potentially malicious assets and governance decisions. The practical ability to withdraw depends on contract rules and available pool assets.

What is impermanent loss?

Impermanent loss is a term used to describe the difference between the value of a liquidity-provider position and the value of simply holding the same initial assets, under specified pool assumptions. It arises because an AMM rebalances the pool’s token quantities as relative prices change. The “impermanent” label is misleading if the difference persists or is crystallised on withdrawal.

For a balanced two-asset constant-product pool under idealised conditions, the relative-value effect can be described with a formula. But the result depends on pool design, asset prices, trade fees, incentives and rebalancing. Different concentrated-liquidity AMMs have other exposures and can magnify price-range risk.

Worked liquidity-provider comparison

Suppose a person initially holds $1,000 of each of two tokens and contributes both to a balanced pool. One token’s price doubles while the other is stable. If held outside the pool, the original tokens would be worth $3,000. Under a simplified no-fee constant-product pool, the claim value would be approximately $2,828.43. The relative shortfall is about $171.57, or 5.72% relative to holding.

This does not automatically mean the liquidity provider lost dollars overall: the pooled position still increased from $2,000 to $2,828.43 in the example. It means the pool underperformed the hypothetical buy-and-hold alternative. Fees, reward tokens and protocol costs could change the comparison in either direction.

DeFi lending and overcollateralisation

Many DeFi lending protocols allow users to supply assets and borrow against deposited collateral. Collateral ratios and interest rates are set by smart-contract and governance rules. Overcollateralisation can provide a buffer against borrower default, but falling collateral prices can trigger automatic liquidations to protect protocol solvency.

Borrowing against volatile collateral introduces leverage. A loan’s real economic risk depends on its debt denomination, collateral token, liquidation thresholds, oracle, interest-rate changes and available liquidity for selling collateral.

Worked collateral liquidation example

Imagine a user deposits $10,000 of crypto collateral and borrows $5,000 in a stablecoin, giving an initial 50% loan-to-value (LTV) ratio. If collateral falls 30% to $7,000 while debt remains $5,000, the LTV rises to approximately 71.4%. If the protocol’s applicable liquidation threshold is 70%, the position may become eligible for liquidation, depending on rules and oracle updates.

Liquidation can incur penalties and may happen quickly. The borrowed stablecoin can also depeg, changing the borrower’s real obligations. Collateral volatility, interest, funding and liquidity should be analysed together rather than treating the initial LTV as permanent.

What are oracles?

Smart contracts often need prices or other information originating outside the blockchain. An oracle provides or helps verify such data. Oracle design may use several market sources and validation processes, but errors or manipulation can still cause incorrect valuations, swaps and liquidations.

For example, if a protocol relies on a thinly traded token price, an attacker may attempt to influence the reference through temporary trading activity. A robust oracle design tries to account for data quality and market manipulation, but no data feed is intrinsically infallible.

Smart-contract vulnerabilities

Smart contracts can contain logic errors, unsafe permissions, oracle dependencies or interactions with external contracts that produce unintended outcomes. Audits can identify some weaknesses but do not guarantee that code is free of exploitable defects. A protocol may also be upgraded after a review, altering risk.

Composable applications can inherit vulnerabilities from other services: if one protocol depends on a bridge, stablecoin or collateral oracle that fails, losses may propagate. Ethereum’s smart contract documentation describes programmability and the limitations of external data access.

Governance tokens and administrative control

Some protocols issue governance tokens that allow holders to propose or vote on changes to parameters. Actual control may be concentrated among insiders, delegates or treasury addresses. Governance rights do not necessarily create ownership of protocol assets or an enforceable right to distributions.

Upgradeability and pause controls can be useful security features but also create dependence on whoever holds administrative keys. Governance attacks, compromised signers or poorly structured proposals can alter the protocol’s risk profile abruptly.

What does total value locked mean?

Total value locked (TVL) typically estimates the market value of assets deposited in selected DeFi contracts. It is a useful scale indicator but not a measure of protocol profit, unique customers, revenue or safety. Reported TVL can be inflated by rising token prices, duplicate counting, recursive borrowing or synthetic exposures.

If a protocol has 1 million tokens deposited and their price doubles, reported TVL may double even if no additional tokens enter. A rise in TVL therefore should be decomposed into token quantities, prices and changes in deposit composition.

DeFi yield and the sources of reward

Displayed yields can result from borrower interest, trading fees, newly issued incentive tokens or subsidies. Incentives paid in volatile tokens may lose value rapidly or dilute existing holders. Some yields are quoted as APY, assuming periodic compounding, while others are simple APR figures that cannot be compared directly without conventions.

An apparent 20% token-denominated reward is not a guaranteed 20% fiat return. Smart-contract failure, falling token prices, collateral liquidation, fees and withdrawal restrictions can dominate the nominal yield.

Bridge and Layer 2 risk

DeFi users may move assets across networks through bridges. Bridge contracts, custodians, message verifiers and sequencers can have security weaknesses or operational restrictions. A token representation on a different chain may have distinct redemption or custody assumptions from the original asset.

Before analysing any opportunity, identify the network and actual contract addresses, and determine how withdrawals depend on bridges or settlement mechanisms. See Ethereum Explained and Crypto Wallets Explained.

How to evaluate a DeFi protocol

  1. Identify the protocol contracts, chain, developer governance and upgrade keys.
  2. Understand exactly where the deposited assets reside and which rights the user receives.
  3. Inspect collateral, liquidation, oracle, redemption and withdrawal conditions.
  4. Quantify AMM price impact and liquidity-provider exposure relative to simply holding.
  5. Separate sustainable fee income from token-emission subsidies.
  6. Assess bridges, stablecoins and any other dependencies.
  7. Consider exploit, depeg, liquidity-crisis and total-loss scenarios.
  8. Verify applicable regulation and avoid interpreting displayed APY as a guaranteed return.

Why AMM price impact depends on trade size

In a constant-product AMM, the marginal price changes continuously as pool reserves move. A small transaction relative to pool liquidity may face modest price impact, while a larger transaction shifts reserve ratios materially. The average executed price can therefore be substantially worse than the price displayed before the swap, even when the protocol itself operates exactly as programmed.

Consider the earlier illustrative pool with 100 Asset A and 10,000 Asset B. Buying approximately 9.091 A by contributing 1,000 B changes the marginal reserve price from 100 B per A to about 121 B per A. The trader’s average price was about 110 B per A, between the starting and ending marginal prices. Fees would generally make the effective result worse for the trader under a fee-charging pool.

Concentrated liquidity adds range-dependent risk

Some AMM designs allow liquidity providers to concentrate assets within chosen price ranges rather than supply liquidity across all possible prices. This can improve capital efficiency under suitable conditions, but can also cause the position to become heavily or entirely composed of one token after a large price change. Fee income depends on actual trading through the relevant range.

A provider who expects a price to stay within a narrow range may face unexpected asset concentration if the market trends sharply. A displayed attractive fee yield during a busy period does not prove future fees will compensate for relative price loss, rebalancing costs or the risk of an illiquid asset.

Recursive borrowing can exaggerate collateral activity

A DeFi user may deposit tokens, borrow a stablecoin, exchange it for more tokens and deposit the newly acquired assets again. This can increase measured deposits and borrowing without creating an equivalent amount of independent new outside capital. The process also increases leverage and the possibility of liquidation when prices move against the strategy.

If the same underlying economic value is represented by deposits across several connected protocols, aggregate TVL can count related claims more than once. Analysts should distinguish gross assets reported by contracts from net outside funding. The BIS’s research on crypto and DeFi measurement illustrates how architectural complexity can mislead headline activity metrics.

Oracle updates and liquidation gaps

A lending system may rely on oracle updates rather than every individual exchange trade. During rapid price moves, a collateral value can change before a protocol’s price reference updates. When the oracle catches up, multiple accounts may become liquidatable at once, putting pressure on the same assets and increasing slippage.

A strong risk assessment examines price-source diversification, update frequency, emergency controls, liquidation incentives and available market depth. A collateral buffer that appears adequate in calm markets may be insufficient when prices gap or network gas costs spike.

Protocol fees and tokenholder value are not interchangeable

A DeFi application may generate meaningful trading fees while distributing most of them to liquidity providers or other participants. A separate governance token might receive no contractual share of those amounts. Therefore comparing the token’s FDV with gross protocol fees can create a misleading valuation multiple unless the actual value-capture mechanism is known.

Incentive tokens used to encourage liquidity can also create dilution. High displayed activity during a subsidy programme may disappear when rewards are reduced. Analyse usage net of subsidies, token emissions, protocol operating costs and whether governance can alter distributions.

Decentralisation and protocol governance are not guarantees

A protocol may settle swaps on a public blockchain while its interface, administrative upgrade keys or oracle services remain under concentrated control. This creates the possibility of contract changes, compromised administration or interrupted access. Analysts should distinguish open-source code from independent operation and consider who could alter the system’s economic parameters.

Permissionless access also does not guarantee that a user can exit at an acceptable price. A liquidity pool with few active counterparties may be unable to absorb a large trade without substantial loss of value. Governance and actual market depth must therefore be assessed independently of claims about decentralisation.

Frequently asked questions

Is DeFi completely decentralised?

Not necessarily. Contracts can operate on a public chain while upgrades, frontends, oracles and governance remain concentrated.

Can liquidity providers lose money when a token price rises?

Yes. Their pool claim may underperform simply holding tokens, and price changes or contract failure can cause absolute losses.

Does high TVL prove a protocol is safe?

No. TVL depends on token prices, deposits and methodology, and does not guarantee security or solvency.

Are DeFi lending rates guaranteed?

No. They can vary with utilisation, governance, market demand and incentive programmes, while losses may exceed any rewards.

Can smart-contract audits eliminate risk?

No. An audit is a bounded examination, not a guarantee against future vulnerabilities or changing code.

Key takeaways

DeFi combines programmable financial contracts with real market liquidity and collateral risks. AMMs, lending protocols and governance arrangements must be evaluated through their actual economics, not advertised yields or decentralisation labels. Code security, price oracles, liquidation mechanics and connected services can produce substantial or total losses.

Related Cryptocurrency Education

Research the dependencies of DeFi through Ethereum smart contracts, stablecoin redemption and depegging, tokenomics and protocol incentives, and six-pillar crypto analysis.

Sources and further reading

Important notice: General educational information only, not an offer or recommendation for any DeFi protocol. Smart-contract defects, liquidations, oracle failures, depegging and volatility can cause severe or total loss. Examples are hypothetical.