Skip to main content

Developer Reference

The concept sections (Introduction, Borrowing, Holding & Redeeming RD, Earning) explain what the protocol does and why. This section is the call surface: the entry points, parameters, hints, and revert reasons for the common on-chain paths, kept concise for integrators and tooling. It is not an exhaustive contract dump — for the deep mechanics of any subsystem, follow the "Mechanics" links into the Advanced section.

Everything here is per-branch unless noted. There are no admin keys, no proxies, and no privileged callers on any of these functions.

Pages​

  • Borrowing operations — open, adjust, repay, close, claim surplus, toggle shield.
  • Redemption — the multi-branch redeemCollateral call and its per-branch hints; the shutdown path.
  • Earning — Stability Pool deposits, and FEE / FLX / LP staking.
  • Liquidation & cleanup — liquidate, plus the dwarf force-close and mini-dwarf sweep paths.
  • Front-end operators — registration, kickback, and the full integration surface.
  • Reading state — the view functions and hint helpers to read before you send.

Conventions used everywhere​

Sorted-list hints. Borrow ops and redemption take upperHint / lowerHint (or arrays of them) that tell the branch's SortedTroves where to (re)insert a trove. Hints are advisory — wrong hints cost extra gas as the list re-walks, they never change correctness. Compute them off-chain with GlobalHintHelper:

// Approx insert hint for one branch's TroveManager, refine with SortedTroves.findInsertPosition:
GlobalHintHelper.getApproxHint(troveManager, NICR, numTrials, randomSeed)
// Multi-branch redemption hints (no branch index, no price arg):
GlobalHintHelper.getRedemptionHints(RDamount, maxIterations)

The relevant NICR is always the trove's post-operation value — don't reuse pre-op hints. See Reading state.

Par. Redemption, force-close, and liquidation value RD at the protocol's internal par (normally $1.00), read from RateParControl.par().

Gas-compensation reserve. Every trove holds a fixed 200 RD in the branch GasPool for its whole life — refunded on a clean close, paid to the liquidator otherwise. A "Borrow 1,800 RD" open mints 1,800 RD to the user and 200 RD to the pool; surface that in UI.

Contract map​

ContractScopeRole
BorrowerOperationsper branchopen / adjust / close / shield toggle / force-close, and moveCollateralGainToTrove
AggregatorsingletonredeemCollateral, issuance/redemption quotas, cross-branch coordination
StabilityPoolper branchprovideToSP / withdrawFromSP, front-end registration
Liquidationsper branchliquidate / liquidateTroves / batchLiquidate
TroveManagerper branchtrove state, mini-dwarf sweeps, ICR reads
LPStaking / FEEStaking / FLXStakingsingletonstaking entry points
GlobalHintHelpersingletonoff-chain hint construction
RateParControl / MarketOracle / PriceFeedmixedpar, market price, collateral price