Lending Protocols¶
All three lending protocols on Gnosis Chain (Agave, Aave V3, Spark) share the same core mechanics derived from the Aave codebase. This page covers the shared concepts; individual protocol pages detail contract addresses, dbt models, and specific features.
How Lending Pools Work¶
- Supply — Users deposit assets into the pool and receive aTokens (interest-bearing ERC-20 tokens whose balance grows over time).
- Borrow — Users borrow against their collateral up to the Loan-to-Value (LTV) ratio. Outstanding borrows are tracked via variableDebtTokens.
- Repay — Borrowers repay debt plus accrued interest.
- Withdraw — Suppliers redeem aTokens for the underlying asset plus earned interest.
- Liquidation — If a borrower's health factor drops below 1, anyone can repay part of their debt and seize collateral at a discount.
Health Factor¶
- HF > 1: Position is safe
- HF < 1: Position is liquidatable
The liquidation threshold is per-asset (e.g., WETH might be 82.5%).
Interest Rate Model¶
All three protocols use a piecewise linear ("kink") model:
If \(U \leq U_{opt}\):
If \(U > U_{opt}\):
Typical parameters: \(U_{opt} = 80\%\), \(\text{slope}_1 = 4\%\), \(\text{slope}_2 = 100\%\), \(\text{baseRate} = 0\text{–}2\%\)
The steep \(\text{slope}_2\) intentionally punishes over-utilization to protect liquidity providers. The reserveFactor is the fraction of interest revenue sent to the protocol treasury.
Units and Conversions¶
| Value | Storage Format | Conversion |
|---|---|---|
Rates (liquidityRate, variableBorrowRate, stableBorrowRate) | RAY = 1e27 | APR = rate / 1e27 |
| RAY APR → APY | — | \((1 + \text{rate} / 1e27 / \text{seconds per year})^{\text{seconds per year}} - 1\) |
Indexes (liquidityIndex, variableBorrowIndex) | RAY = 1e27 | Divide by 1e27 |
| Token amounts | Token wei | Divide by \(10^{\text{decimals}}\) for human-readable |
Key Event Types¶
All three lending protocols emit these core events (Agave uses Deposit, Aave V3/Spark use Supply):
| Event | Description | Key decoded_params Fields |
|---|---|---|
Deposit / Supply | User supplies assets | reserve, user, onBehalfOf, amount |
Withdraw | User redeems supply | reserve, user, to, amount |
Borrow | User opens a borrow | reserve, user, amount, borrowRateMode, borrowRate |
Repay | User repays debt | reserve, user, repayer, amount |
LiquidationCall | Position liquidated | collateralAsset, debtAsset, user, debtToCover, liquidatedCollateralAmount, liquidator |
ReserveDataUpdated | Interest rates updated | reserve, liquidityRate, stableBorrowRate, variableBorrowRate, liquidityIndex, variableBorrowIndex |
Protocol Pages¶
- Agave — Aave V2 fork by 1Hive
- Aave V3 — Aave V3 with E-Mode, Isolation Mode, Siloed Borrowing
- Spark — Aave V3 fork by MakerDAO/Sky