DeFi lending risk monitoring
What is DeFi lending risk monitoring?
DeFi lending risk monitoring is watching the collateral, liquidity and bad debt in lending markets and vaults, so supply and borrow caps come down before losses land.
Vault curators and protocol risk teams run it because debt that a liquidation can’t cover falls on the market’s lenders, and the vault’s depositors with them.
Goldsky streams every supply, borrow and liquidation from the markets you cover into your database, with the market’s totals at each block, and flags liquidations that leave bad debt; the stress model, the price and liquidity data behind it and the permission to change caps stay with you.
Who uses DeFi lending risk monitoring?
Vault curators, the risk teams of DeFi lending protocols, and the risk firms that curate vaults or set caps for them.
How DeFi lending risk monitoring works
The diagram follows one lending market from the list of markets you cover, through its loans and liquidations, to the lower limit your team sets after a stress test. Your setup may differ.
List the markets and collateral you cover
Each lending market has its own collateral, price oracle and liquidation threshold, so monitoring starts from the markets your vault lends into.
For each market, record the loan and collateral assets, the oracle that prices the collateral, the liquidation loan-to-value (LLTV, the point at which a loan can be liquidated) and your current cap. A market missing from this list is exposure nobody tests.
Capture every supply, borrow and liquidation
Handled by Goldsky TurboPositions and losses come from the market’s own events, so you need all of them, from the day the market opened.
Each event has to be decoded with the market contract’s interface (its ABI) into the market, the account and the amounts, including events from before you started watching. On some protocols the liquidation event also records any debt the liquidation left unpaid, so a missed event can hide a loss.
With Goldsky, a Turbo Pipelines SQL transform decodes the market contract’s logs with
Decode contract events (opens in a new tab)_gs_log_decodeand its ABI, and a pipeline that starts at theearliestblock replays the market’s history before it follows new blocks.Record each event with the market’s totals
Handled by Goldsky TurboAn event means little without the market around it: how much is supplied, how much is borrowed and how much is left to withdraw.
Read the market’s totals at the same block as each event, so every row shows the state it happened in, then write the rows to a database your model can query. Reading totals later, at the newest block, mixes states from different moments.
In the same pipeline,
Read contract state in SQL (opens in a new tab)_gs_eth_callcalls the market’s view function at the event’s block and adds the result to the row. A database sink keyed on the eventidwrites it and applies reorg corrections to the same rows.Flag liquidations that leave bad debt
Handled by Goldsky TurboBad debt is debt a liquidation couldn’t cover, and it falls on the market’s lenders, so the risk team needs to hear about it at once.
Where the liquidation event records the bad debt it realized, a rule on that one event is enough to raise an alert. Debt that is underwater but not yet liquidated (unrealized bad debt) emits no event, so your stress test has to estimate it.
A SQL filter keeps liquidation rows with a bad-debt amount above zero, and Turbo Pipelines’ webhook sink posts each one to your alerting endpoint. Delivery is at least once and reorgs arrive as correction rows, so key each alert on the event
Set up the webhook sink (opens in a new tab)id.Bring in prices and DEX liquidity
A stress test needs each collateral’s price history and how much of it the market could sell in a liquidation.
Your market-data vendor supplies prices and the depth of DEX liquidity for each collateral asset, with enough history to measure its worst days. Liquidations depend on someone being able to sell the collateral, so thin or stale depth data makes a market look safer than it is.
Stress-test each market
The question is how much debt would go unpaid if the collateral price fell sharply and liquidity dried up on the same day.
One published method takes the 99th-percentile daily drop in the collateral’s price and in its DEX liquidity over the past year, then compares the exposure that drop would make liquidatable with the liquidity there to absorb it. Markets where exposure exceeds that capacity are the ones to cut.
Lower caps or move liquidity
Cutting a vault’s exposure to a risky market before prices move is how a curator keeps losses small.
Your team lowers the market’s supply cap or moves liquidity to a safer market, using the role the protocol grants. On some vaults a lower cap applies at once while a higher one waits out a timelock, so plan increases ahead.
Let the contract apply the new limits
Caps live in the lending contract, so a change counts once it’s onchain.
The contract checks the new cap on every later allocation. Caps limit new allocations and leave existing ones in place, so moving liquidity out of a market is its own step.
What you control
- Your team
- List the markets and collateral you cover
- Stress-test each market
- Lower caps or move liquidity
- Your providers
- Market-data vendor
Security and deployment
- SOC 2 Type IIIndependently audited security controls.
- Dedicated infrastructureSingle-tenant options for production workloads.
- Data residencyCloud, on-premises or co-located.
More use cases that track staking and lending
Use cases built the same way
- Stablecoin freezes and seizuresRecord every freeze, seizure and burn on a lawful order, with the balance it affected.
- Sponsored gas spendTotal the gas you pay for your users per user, paymaster and day, watch the paymaster’s deposit and check the provider’s bill.
- Authorize and capture stablecoin paymentsHold a buyer’s stablecoins in an escrow contract at checkout, capture them to the merchant as orders ship, void what can’t be filled and refund after capture.
- Confirm x402 and agent stablecoin paymentsConfirm stablecoin payments that AI agents make, often per request, and keep each agent within its spending limits.
Monitor DeFi lending risk with Goldsky
We’ll map it to your systems and show you what Goldsky runs, so your team builds the product, not the pipelines underneath it.