Skip to content

Files

Latest commit

5df477c · Jun 14, 2024

History

History
This branch is 3 commits ahead of, 885 commits behind DefiLlama/DefiLlama-Adapters:main.

liquidations

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 13, 2024
Dec 22, 2022
Jun 13, 2024
Jun 13, 2024
Jun 13, 2024
Jun 14, 2023
Oct 13, 2022
Sep 29, 2022
Jun 14, 2024
Oct 12, 2023
Sep 29, 2022
Apr 6, 2023
Jun 13, 2024
Jan 25, 2023
Jun 14, 2024
Oct 30, 2022
Nov 28, 2022

Liquidation Level Adapters

How it works

A liquidation level adapter iterates through all open positions on a lending/CDP platform and calculates the liquidation prices of all those positions in regard of their collateral assets.

Each adapter is scoped to a protocol. The shape of the adapter's output LiquidationAdapter is:

interface LiquidationAdapter {
  // chain name
  [chain: string]: {
    liquidations: () => Promise<Liq[]>;
  };
}

interface Liq {
  owner: string; // owner of this liquidatable position
  liqPrice: number; // liquidation price in USD
  collateral: string; // collateral asset address with prefix, eg `ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`
  collateralAmount: string; // native, non-decimal adjusted token amount, eg 1 ETH will be `"1000000000000000000"`
  extra?: {
    displayName?: string; // name of owner to be displayed on positions inspector
    url: string; // link to "spy" inspector provided by the protocol, or blockchain explorer
  };
}

Examples and references

You may refer to the Aave V2 and Angle Protocol adapter for examples of how multi-chain protocols are handled.

For a complete onchain (non-subgraph) adapter, you may refer to the MakerDAO adapter.

For a hybrid approach using both onchain and indexer data, you may refer to the Compound V2 adapter.

Caveat

Since all adapter are run in AWS Lambdas, it is essential to make sure your adapter does not take more than 15min to return the result as it's the hard limit set by AWS.

Test an adapter

Run the following command in the repository root:

npx ts-node ./liquidations/test.ts ./liquidations/<protocol-name>/index.ts

Note

Since the liquidations dashboard is mostly designed to showcase levels where huge liquidations might happen for people to better hedge their leveraged positions, we'd prefer to only list protocols with market moving potentials to reduce the noise on the UI.

We appreciate PRs for protocols of any size, and the liquidation levels data will all be tracked on the backend. However, smaller protocols may get aggregated into a series called Others in the chart on the frontend.