Lending / Yield·EVM
Gearbox
Composable on-chain credit / leverage protocol. Lenders deposit into ERC-4626 passive `Pool`s; borrowers open isolated `CreditAccount`s and trade leveraged on whitelisted DeFi protocols (Uniswap, Curve, Convex, Balancer, etc.) via vetted adapters.
- 01leveraged DeFi farming
- 02isolated credit accounts
- 03passive lending into 4626 pools
- 04leveraged LST / LRT loops
- 05delta-neutral strategies
- pnpm add @gearbox-protocol/sdk @gearbox-protocol/sdk-gov viem
| Variable | Scope | Description |
|---|---|---|
| NEXT_PUBLIC_GEARBOX_ADDRESS_PROVIDER | Client | AddressProvider v3 for the chain — resolves all CreditFacade / CreditManager / Pool addresses. |
Integrate Gearbox v3. Lenders deposit into a `Pool` (ERC-4626) via `Pool.deposit(assets, receiver)` to mint dTokens (e.g. dUSDC). Borrowers interact through `CreditFacade` (one per `CreditManager`, one CM per asset/leverage tier). Open a leveraged position: `CreditFacade.openCreditAccount(onBehalfOf, MultiCall[] calls, referralCode)` where `calls` is a `MultiCall[] = { target, callData }` batch encoding `addCollateral`, `increaseDebt`, then adapter calls (`UniV3Adapter.exactInputSingle`, `CurveAdapter.exchange`, `ConvexAdapter.deposit`, etc.). Manage with `CreditFacade.multicall(creditAccount, calls)`. Close with `closeCreditAccount` (full repay) or `liquidateCreditAccount` (any liquidator past the health-factor threshold). Resolve all addresses through the v3 `AddressProvider` and the SDK's `GearboxSDK.attach(...)`.
- ⚑Leverage cascades risk — at 10x leverage a 10% adverse move zeroes the account. Health factor is checked AFTER the multicall, so a temporarily underwater state inside the batch is fine but final HF must be ≥ 1.
- ⚑Adapters are a strict whitelist — calling a non-adapter target through `multicall` reverts. Trying to call an unsupported pool/protocol will fail; check `creditConfigurator.contractToAdapter`.
- ⚑Each CreditManager has its own debt token, leverage cap, and collateral list — opening a USDC account on the WETH manager will revert. Match the user's collateral to the right CM.
- ⚑Liquidations are permissionless and incentivized — once HF < 1, anyone can liquidate; partial liquidations are not supported on v3, so the entire account closes at a discount to the liquidator.
- ⚑Oracle dependency: account valuation relies on the `PriceOracleV3` (mostly Chainlink + Redstone with hard-coded staleness checks). A stale or paused feed pauses borrowing and can DoS withdrawals.
- ⚑`CreditAccount` is an isolated smart contract holding funds — sending tokens to it directly works for collateral, but unsupported tokens get stuck unless the configurator whitelists them.
- ⚑Gas cost for opening / closing is high (multicall + multiple adapter calls + price oracle reads); estimate generously and prefer L2 deployments for retail UX.