A DeFi smart contract is code deployed on a blockchain that holds deposited assets and moves them by rules it reads from on-chain state: collateral balances, governance decisions and price data supplied by an oracle. No operator approves each transfer. If the inputs say a withdrawal is covered, the contract pays it, which is why the documented losses trace back to inputs that were wrong or gameable rather than to a ledger that failed.
How a DeFi smart contract holds funds and executes payouts
Deposits sit at the contract's own address, and every trade, loan or payout is a function call that checks conditions before releasing assets. A lending or derivatives contract asks the same questions on each call: what the user holds, what it is worth, and whether that value covers what they want to take out.
The holdings answer comes from on-chain balances. The value answer comes from outside, because a contract cannot see an exchange order book, so it reads a price feed. The coverage answer is arithmetic on the other two. That makes the price input the point where off-chain markets reach on-chain funds, and governance the point where someone can change the rules themselves.
Where the price comes from: oracle feeds
An oracle is the data feed a contract trusts for prices. Chainlink describes its price feeds as aggregated by independent node operators from many data sources, as of October 2026. The same documentation flags exceptions with single-source or calculated values, so the category of a given feed matters as much as the provider's name.
Mango Markets: an oracle input bought on purpose
Per the CFTC complaint, on October 11, 2022 an attacker took over $110 million from Mango Markets in digital assets. The method was buying MNGO on the oracle's input exchanges, three venues in total. The MNGO price reported by the oracle rose over 13-fold within 30 minutes. The contract then accepted the inflated swap value as collateral and released withdrawals, draining most assets other users deposited.
By its own rules, the contract did what it was written to do: value positions at the oracle price and pay out against that value. The failing component was an input drawn from a small set of venues that one buyer could move.
Of the funds taken, about $67 million came back and about $47 million was retained, per the CFTC. The agency described the matter as its first oracle manipulation case.
Beanstalk: governance as the failing component
Beanstalk's own post reports a theft of about $77M in user assets on April 17, 2022, carried out with a flash loan against the protocol's governance mechanism. The assets came out of the protocol's liquidity pools, and the team burned the Beans left in the exploiter contract. The team attributed the loss to a previously unknown governance issue in the Ethereum mainnet contract.
The component that failed was governance, the process that decides what the contract is allowed to do.
Oracle failure versus governance failure
| Mango Markets | Beanstalk | |
|---|---|---|
| Date | October 11, 2022 | April 17, 2022 |
| Failing input | Oracle price | Governance process |
| Amount taken | Over $110 million | About $77M |
| Funds came from | Assets deposited by other users | Protocol liquidity pools |
| Account | CFTC complaint | Beanstalk team post |
Reading the exposure of DeFi smart contracts
The two cases give a short checklist for any contract that holds deposits:
- Price input: which oracle, which feed category, and how many venues feed it.
- Collateral logic: whether a position valued at that price can withdraw other users' deposits.
- Governance: who can change the contract's rules, and whether that power can be acquired within a single transaction.
- Pooled funds: where deposits sit, since both losses drained shared pools rather than one account.
The same execution path settles wagers on-chain; the polycasino note on how DeFi sports betting settles follows it from deposit to payout.
Sector questions
What is a DeFi smart contract?
It is code on a blockchain that holds deposited assets and releases them when on-chain conditions are met, such as enough collateral at the price its oracle reports. No operator signs off on each withdrawal, so the quality of its inputs decides how safe the deposits are.
How does DeFi lending work?
A lending contract values what a user has posted as collateral and lets them withdraw assets against that value. The Mango Markets case shows the weak point: when the collateral is priced by a manipulable oracle, inflated collateral can withdraw real deposits belonging to other users.
Is DeFi lending risky?
The documented losses say yes, and they say where. Mango Markets lost deposits through a manipulated price feed and Beanstalk lost liquidity pool assets through its governance process. Both are inputs a depositor can check before funding a contract.
Data sources
- U.S. Commodity Futures Trading Commission, CFTC Charges Avraham Eisenberg with Manipulative and Deceptive Scheme to Misappropriate Over $110 million from Mango Markets, 2023-01-09
- Beanstalk Farms, Beanstalk Governance Exploit, 2022-04-19
- Chainlink, Price Feeds | Chainlink Data Feeds, accessed 2026-10-23






