Skip to main content

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.

Your business, step 1: List the markets you coverCollateral, oracle and cap for each
Blockchains: Borrowers take loansSupply, borrow, repay and liquidate
Goldsky, step 2: TurboStream market eventsDecoded, from the market’s first block
Goldsky, step 3: TurboLand them in your databaseWith market totals at each block
Goldsky, step 4: TurboFlag bad debtLiquidations that leave debt unpaid
Your business, step 5: Market-data vendorBring in prices and depthPrice and DEX liquidity per collateral
Your business, step 6: Run the stress testPrice and liquidity shocks per market
Your business, step 7: Cut exposureLower caps or move liquidity
Blockchains, step 8: New limits applyThe lending contract enforces them
  • Goldsky
  • Your provider

How to monitor DeFi lending risk

A pipeline decodes every supply, borrow and liquidation in the markets you cover, adds each market’s totals at that block and writes the rows to your database, and posts liquidations that leave bad debt to your risk team. Your stress test runs on those rows, with prices and DEX depth from a market-data vendor.

What you’ll need

  • Goldsky Turbo
  • The addresses and ABIs of the lending markets and vaults you cover
  • A database for the decoded events
  • A webhook endpoint or alerting tool for your risk team
  • Price and DEX liquidity data for each collateral asset
  • Your stress model
  • The protocol role that lets you change caps or move liquidity
  1. 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.

  2. Capture every supply, borrow and liquidation

    Handled by Goldsky Turbo

    Positions 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 _gs_log_decode and its ABI, and a pipeline that starts at the earliest block replays the market’s history before it follows new blocks.

    Decode contract events (opens in a new tab)
  3. Record each event with the market’s totals

    Handled by Goldsky Turbo

    An 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, _gs_eth_call calls the market’s view function at the event’s block and adds the result to the row. A database sink keyed on the event id writes it and applies reorg corrections to the same rows.

    Read contract state in SQL (opens in a new tab)
  4. Flag liquidations that leave bad debt

    Handled by Goldsky Turbo

    Bad 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 id.

    Set up the webhook sink (opens in a new tab)
  5. 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.

  6. 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.

  7. 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.

  8. 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.

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.

© Endless Sky Inc. All rights reserved.

PrivacyTermsSecurity

System status