Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion building-financial-products-in-solana/lending.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Because every division rounds this way, the market never loses a minor unit to r
- **Skipping the refresh** would let positions be judged on old values; `ReserveStale`, `ObligationStale`, and `borrow_without_obligation_refresh_is_rejected` close the path.
- **Cross-market smuggling**: an obligation in one market pledging reserves from another is refused (`MarketMismatch`, `cross_market_reserve_is_rejected`).
- **Dangerous configurations are rejected at write time**: LTV above threshold, zero close factor, misordered rate curves, a rate above 300% a year, a confidence limit of zero or above the price (`rejects_ltv_above_liquidation_threshold`, `rejects_misordered_interest_rate_curve`, `rejects_borrow_rate_above_ceiling_on_update`, `rejects_zero_confidence_limit`, `rejects_confidence_limit_wider_than_the_price`). `update_reserve_config()` also refuses a lower liquidation threshold with `RiskLimitLowered`, so an update cannot pull the liquidation threshold down under an open borrow (`rejects_lowering_liquidation_threshold`). It accepts a lower loan-to-value, down to zero to stop new borrowing (`accepts_lowering_loan_to_value`).
- **Share inflation through the reserve's own borrowing.** Total liquidity counts interest owed on borrows, and a supplier may borrow from the reserve they supply. The attacker is the only supplier of an empty reserve, holding a single minor unit of its shares, and borrows one minor unit from it against collateral in another reserve. Debt rounds up, so a second of interest makes that debt two minor units, and the attacker's unit of shares is worth two without anything being minted. From there, deposits and redemptions push the share price higher, because both round in the pool's favor and the attacker owns the whole pool. Once that unit is worth about 690 USDC, a 1,000 USDC deposit mints one unit of shares, and the attacker's unit redeems half the pool. `inflating_shares_through_own_borrow_does_not_pay` runs this on the default rate curve, and the attacker repays the loan and leaves no bad debt. Without the withheld shares the attacker would keep about 155 USDC of the victim's deposit. With them, the attacker's unit is one of 1,001, and nearly everything the rounding leaves behind goes to shares nobody can redeem. The test asserts that the attacker ends with no more than they started with and the victim gets back at least 99.9% of the deposit. A reserve whose suppliers have all left keeps the 1,000 minor units behind the withheld shares, and the next deposit is priced against them instead of starting the reserve over (`sole_supplier_leaves_the_minimum_behind`).
- **Share inflation through the reserve's own borrowing.** Total liquidity counts interest owed on borrows, and a supplier may borrow from the reserve they supply. The attacker is the only supplier of an empty reserve, holding a single minor unit of its shares, and borrows one minor unit from it against collateral in another reserve. Debt rounds up, so a second of interest makes that debt two minor units. A reserve factor rounds its fee up and would take that whole unit, but in a reserve with no reserve factor the unit goes to suppliers, and the attacker's unit of shares is worth two without anything being minted. From there, deposits and redemptions push the share price higher, because both round in the pool's favor and the attacker owns the whole pool. Once that unit is worth about 690 USDC, a 1,000 USDC deposit mints one unit of shares, and the attacker's unit redeems half the pool. `inflating_shares_through_own_borrow_does_not_pay` runs this on the default rate curve with no reserve factor, and the attacker repays the loan and leaves no bad debt. Without the withheld shares the attacker would keep about 155 USDC of the victim's deposit. With them, the attacker's unit is one of 1,001, and nearly everything the rounding leaves behind goes to shares nobody can redeem. The test asserts that the share price rises after the borrow and again after the round trips, that the attacker ends with no more than they started with, and that the victim gets back at least 99.9% of the deposit. A reserve whose suppliers have all left keeps the 1,000 minor units behind the withheld shares, and the next deposit is priced against them instead of starting the reserve over (`sole_supplier_leaves_the_minimum_behind`).
- **Self-liquidation** is allowed (`owner_can_liquidate_their_own_obligation`): it is only possible while unhealthy and is economically pointless.

## Testing Considerations
Expand Down
Loading