fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Liquidity and Liquidation

5 algorithms in Digital Assets and On-Chain Finance.

In this family#

  1. Impermanent-Loss Calculation contract

    Value lost by providing liquidity rather than simply holding the two assets. Called impermanent because it reverses if the price returns — which it frequently does not, and the loss is realised on withdrawal.

    impermanentLoss(data, config)
  2. Liquidity-Provider Fee APR contract

    Annualised fee return for a liquidity position. Meaningful only net of impermanent loss: a headline APR quoted against a divergent pair routinely describes a losing position.

    feeApr(data, config)
  3. Collateral-Health Factor contract

    The ratio of weighted collateral to debt in a lending position. Below 1 the position is liquidatable, which makes it the single number a borrower has to watch.

    healthFactor(data, config)
  4. Liquidation-Price Calculation contract

    The collateral price at which a position becomes liquidatable. The number a borrower actually needs — a health factor is abstract, a price is something you can set an alert on.

    liquidationPrice(data, config)
  5. Liquidation Waterfall contract

    The order in which collateral is seized and debt repaid, including liquidation bonus and any protocol fee. Determines what a borrower recovers, and it is rarely proportional.

    liquidationWaterfall(data, config)

What they share#

Every topic here is a record-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { impermanentLoss } from "fintech-algorithms/digital-assets-and-on-chain-finance/liquidity-and-liquidation/impermanent-loss-calculation";
import { feeApr } from "fintech-algorithms/digital-assets-and-on-chain-finance/liquidity-and-liquidation/liquidity-provider-fee-apr";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Digital Assets and On-Chain Finance collects 10 algorithms across 2 families. For the concept behind this family rather than the call signatures, see the concept guides.