Create your own
Lesson illustration

Understanding Key Risks in DeFi Transactions

Hello again. In the last lesson, you traced an Aave-style USDC supply position through approval, supply, pooled lending, repayment, and withdrawal. That trace established what happened on-chain. This lesson asks a more demanding question: what can still go wrong even when the transaction records look correct?

You will learn to distinguish four risk categories in a single DeFi transaction: custody risk, settlement risk, counterparty risk, and smart-contract risk. They can coexist, but they have different sources, different evidence, and different mitigations. Being able to name the primary failure mechanism is essential for sound protocol analysis.

Plan for roughly 35–40 minutes, including two short resource studies.


A risk category is a failure mechanism, not a vague warning

“DeFi is risky” is not a useful conclusion. A useful conclusion states:

  1. What must fail for the loss to happen.
  2. Who or what controls that failure point.
  3. What asset or claim is affected.
  4. Which evidence would reduce, though rarely eliminate, uncertainty.

Use these four diagnostic questions:

RiskThe key questionPrimary failure mechanismTypical loss
Custody riskWho can authorize movement of the asset?A private key, signing device, or custodian’s controls are lost, stolen, or misused.Unauthorized transfer or permanent loss of access
Settlement riskWill the intended transaction become final as expected?Transaction delay, failed inclusion, reorganization, or incomplete delivery between transaction legs.Assets or obligations remain unsettled; time-sensitive position is harmed
Counterparty riskMust another party honor an obligation or refrain from discretionary action?A borrower, issuer, custodian, market maker, or service provider fails, freezes, defaults, or misappropriates assets.Claim cannot be redeemed or obligation is not performed
Smart-contract riskDoes the deployed code correctly enforce the intended rules?A bug, flawed design, bad integration, or unsafe configuration is exploited or behaves unexpectedly.Funds are stolen, locked, mispriced, or incorrectly accounted for

The distinction is easiest to see through a simple contrast:

  • If someone steals your wallet’s signing key and transfers your USDC, that is custody risk.
  • If a transaction is broadcast but cannot be included quickly enough during a market crash, that is settlement risk.
  • If an issuer refuses or cannot honor redemption of a token that represents off-chain reserves, that is counterparty risk.
  • If an Aave-like lending pool contains a flaw that lets an attacker withdraw more than permitted, that is smart-contract risk.

The same visible outcome—for example, “I cannot withdraw”—can arise from any of the four. The cause matters more than the symptom.

EEA DeFi Risk Assessment Guidelines - Version 1

Read the European Ethereum Alliance’s treatment of software, custody, and counterparty risks. It provides a useful baseline vocabulary, particularly its distinction between control of private keys, another party’s obligations, and vulnerabilities in deployed code.

Read Section 3.1.2, “Smart Contract Risk,” from the smart contract discussion. Focus on why public visibility, immutability, fast movement of funds, and upgradeability all change the consequences of ordinary software failures. Then read Section 3.2.2, “Custodial Risk.” Start at the custody distinction and follow the surrounding paragraphs on self-custody and third-party custody. Notice that self-custody removes a custodian but does not remove the risk of key loss. Finally, read the opening of Section 3.6, “Counterparty risk,” beginning with the definition and boundary. Skip the mitigation lists for now; concentrate on identifying the party whose non-performance would create a loss.


Start with the Aave supply trace: one action, several risk layers

Return to Maya’s illustrative action from the previous lesson: she supplies 100 USDC to an Aave V3 market and receives aUSDC. Her confirmed transaction contains several linked operations: USDC leaves her wallet, the reserve custody arrangement receives it, and her aUSDC claim is created.

A confirmed supply transaction is evidence that the requested action executed at that time. It is not evidence that every relevant risk was absent.

Custody risk in the supply

Before Maya even interacts with Aave, she needs a signing authority—usually a wallet private key or hardware signer. Whoever controls that authority can authorize token approvals and transfers.

Custody risk asks: who can move Maya’s USDC, and how securely is that authority managed?

Examples include:

  • Maya’s seed phrase is exposed through phishing or malware.
  • A malicious website induces Maya to approve an attacker-controlled spender.
  • Maya uses an institutional or exchange custodian that controls the wallet keys and can delay or prevent access.
  • A multisignature arrangement is compromised because its required signers or signing infrastructure fail.

The previous lesson’s distinction between Approval and Transfer matters here. A USDC approval does not itself move USDC, but it can create an ongoing custody exposure: the approved address may later use its authority within the allowance amount. A careful analyst checks both the spender and the approval scope.

Once USDC enters a properly functioning lending pool, the funds are controlled by contract rules rather than Maya’s individual key. That is not automatically “third-party custody” in the conventional sense. The important question becomes whether the contract’s rules are correct and whether any privileged party can alter them—questions that move us toward smart-contract and governance analysis.

Settlement risk in the supply

Maya signs a transaction and broadcasts it. At that point, she has requested a supply; she has not necessarily settled one.

Settlement risk asks: does the transaction execute on the intended chain and achieve sufficiently reliable finality before changing conditions make the delay harmful?

For a same-chain Aave supply, the token transfer and the aUSDC accounting change are normally atomic: either both take effect within a successful transaction, or neither takes effect if the transaction reverts. This substantially reduces the risk of one leg completing while the other does not.

Atomic execution is not identical to final settlement, however. A transaction can be:

  1. Broadcast but remain pending because fees are too low or blockspace is scarce.
  2. Included in a block but not yet treated as sufficiently final for the use case.
  3. Affected by a rare chain reorganization, where a block once seen as canonical is replaced.
This schematic depicts a chain reorganization: an alternative block at slot \(N+1\) gains support, and the previously visible Block C becomes orphaned. It illustrates why inclusion in a block and robust final settlement are distinct ideas.

The diagram is not a prediction of routine loss on major networks. Rather, it shows the mechanism behind a settlement-risk question: how much confidence should you place in a transaction before relying on it elsewhere? The appropriate wait time depends on the chain, its consensus design, the value at risk, and what must happen after confirmation.

[PDF] Lessons Learned from Decentralised Finance (DeFi) - Skadden

This short passage connects blockchain finality to settlement and liquidity exposure. Its discussion uses an earlier Ethereum framing, so treat its network-specific wording as historical context; the enduring analytical point is that transaction inclusion, finality, and economic reliance are separate moments.

In the PDF’s “Finality” subsection on the page labeled 14, read the full discussion beginning immediately after the preceding paragraph on smart-contract risk. Pay particular attention to the closing interpretation. Relate it to a time-sensitive DeFi action: a user may know what they want to do, yet still be unable to settle it quickly enough.


Counterparty risk: identify the promise or discretionary power

Counterparty risk requires a party whose behavior matters. The party might be obvious, such as a centralized custodian, or embedded in an apparently on-chain asset, such as a token issuer holding off-chain reserves.

For Maya’s USDC supply, possible counterparties may include:

  • The USDC issuer, if the token’s redemption, reserve management, or administrative controls matter to the value of the USDC deposited.
  • Borrowers in the lending pool, because they must repay debt economically. Aave’s collateral and liquidation rules are designed to reduce this exposure, but a severe crash, poor collateral liquidity, or insufficient liquidators can still produce bad debt.
  • A custodian or issuer of a wrapped asset, if Maya uses a wrapped asset rather than a natively issued on-chain asset.
  • An off-chain market maker or service provider, if the transaction design requires that party to quote, deliver, redeem, or otherwise perform.

Counterparty risk does not mean “there is a contract address on the other side of my transaction.” If code deterministically performs an exchange based solely on its on-chain state, the principal question is whether that code works as intended—that is smart-contract risk. Counterparty risk becomes central when a human organization, a legal entity, or an economically accountable participant must perform.

Wrapped Bitcoin provides a clear example. A holder of WBTC may possess a token in their own Ethereum wallet, so their wallet custody could be entirely self-managed. Yet the token’s value depends on the arrangement through which Bitcoin is held in reserve and WBTC can be minted or redeemed. The holder may therefore have a counterparty exposure to the entities involved in that arrangement.

This Wrapped Bitcoin risk diagram identifies custodial, counterparty, governance, and smart-contract considerations. It shows that holding a wrapped asset can combine several independent risk sources; the diagram’s governance category will be examined in a later module.

A useful boundary test is:

If the code executed perfectly and the blockchain finalized normally, could another party’s insolvency, refusal, fraud, or failed promise still cause the loss?

If yes, counterparty risk is present.

For instance, if USDC’s issuer froze Maya’s address, her wallet key could remain secure and Aave’s contracts could operate exactly as programmed, yet her USDC could still become unusable. That is primarily an issuer and counterparty problem—not a failure of her private-key custody and not necessarily an Aave code defect.


Smart-contract risk: deterministic execution of flawed rules

Smart contracts are programs that hold assets and execute rules on a blockchain. Their value is that the system can follow a rule without asking an intermediary for a discretionary decision. Their danger is equally direct: the system will reliably execute a flawed rule as well as a good one.

CODE IS LAW? Smart Contracts Explained (Ethereum, DeFi)

Watch Finematics’ “CODE IS LAW? Smart Contracts Explained (Ethereum, DeFi).” The selected portions establish both the appeal of deterministic, automated execution and the crucial limitation that code can contain flawed assumptions or vulnerabilities.

Watch the basic model for the idea of a smart contract as a program that can hold and transfer assets under predefined conditions. Then watch the risk section for bugs, audits, upgrades, and the limits of converting real-world conditions into on-chain rules. As you watch, separate “the contract follows its rules” from “the rules are economically and technically safe.”

In a lending protocol, smart-contract risk can arise from several places:

  • A logic error lets users borrow, withdraw, or liquidate under conditions the designers did not intend.
  • An access-control error allows an unauthorized address to pause the protocol, change a parameter, or drain funds.
  • A token-integration error makes the protocol behave incorrectly with a nonstandard ERC-20 token.
  • A flaw in a dependency—such as a library, oracle adapter, or multisignature module—causes losses in a protocol that depends on it.
  • An unsafe upgrade replaces working logic with vulnerable or incompatible logic.

The core insight is that composability expands the attack surface. A protocol is rarely one contract; it is a system of contracts, tokens, interfaces, and dependencies. The contract that fails might not be the one the user interacted with directly.

Audits, formal verification, bug bounties, monitoring, and long operating history are meaningful evidence, but none proves that risk is zero. An audit covers a defined code version and scope. It may exclude external dependencies, future upgrades, economic attacks, or changes after the audit.


Separating the categories when they overlap

The four categories are analytical tools, not watertight compartments. A single event can involve more than one category. Your task is to identify the primary causal mechanism and then record secondary exposures.

Consider four versions of “Maya cannot access her position”:

EventPrimary classificationWhy
Maya signs a malicious approval; the attacker later transfers her USDC.Custody riskHer signing authority was manipulated or misused.
Maya’s urgent transaction remains pending during congestion, and her collateral is liquidated before she can add funds.Settlement riskThe needed action could not settle in time.
A wrapped-asset custodian cannot honor redemptions because reserves are missing.Counterparty riskThe token holder’s claim depends on a party meeting an obligation.
An exploit drains the lending pool despite users following the documented procedure.Smart-contract riskDeployed code or its integration failed to enforce the intended rules.

Now consider a more realistic compound case: an attacker compromises the private key of a protocol’s upgrade administrator, deploys malicious implementation code, and drains user funds.

This has several layers:

  • The key compromise is a custody or operational-security failure.
  • The malicious upgrade authority is an access-control feature of the smart-contract system.
  • The drain occurs through smart-contract execution.
  • If users relied on a team’s promise to safeguard the upgrade keys, there may also be a counterparty dimension.

A strong incident note would not merely say “hack.” It would state the chain of causation and identify where controls failed.


A compact method for classifying any DeFi transaction

When reviewing a transaction, protocol, or incident, write four one-sentence statements:

  1. Custody: “The asset-moving authority is controlled by ___; the relevant key or custodian exposure is ___.”
  2. Settlement: “The transaction settles when ___; the relevant delay, finality, or execution dependency is ___.”
  3. Counterparty: “The claim depends on ___ performing or honoring ___.”
  4. Smart contract: “The code and dependencies that enforce the transaction are ___; a failure could cause ___.”

For the Aave USDC supply, a concise version might read:

Maya self-custodies the wallet key used to authorize the USDC approval and supply, creating private-key and approval-scope risk. The supply is atomic if executed, but remains exposed to network inclusion and finality conditions until settlement is sufficiently reliable. The USDC position retains exposure to the issuer and, through the pooled lending market, residual borrower-default risk. Finally, Maya relies on the correct operation of Aave’s pool, aToken, token-integration, and other connected smart contracts.

Notice the wording. It does not claim that Aave, USDC, or self-custody is “safe” or “unsafe” in the abstract. It identifies dependencies and mechanisms that can later be tested with documentation, explorers, audits, reserve reports, and on-chain data.


Key takeaways

A successful on-chain transaction is evidence of execution, not a blanket guarantee against loss.

  • Custody risk concerns control of private keys and asset-moving authority.
  • Settlement risk concerns whether a transaction executes and achieves reliable finality in time; atomic execution reduces partial-completion risk but does not eliminate finality or congestion concerns.
  • Counterparty risk concerns another party’s ability or willingness to honor a claim or obligation, including issuers, custodians, borrowers, and certain service providers.
  • Smart-contract risk concerns whether the deployed code, integrations, and configurations correctly enforce the intended rules.
  • The categories can overlap. Classify the primary cause, then document the secondary dependencies rather than collapsing everything into “protocol risk.”

Next, you will extend this analysis from transaction-level risks to protocol-level trust assumptions by identifying privileged roles—such as administrators, multisignatures, guardians, and upgrade authorities—and determining what powers they hold.

Can't find a good explanation? Sign up and we'll make it for you

Sign up