Skip to main content
Call RiskLens and PositionRouter from a contract the same way the app does from viem. The router must be an operator before it can borrow. Your contract, if it holds the stock, must setOperator on Stockline or hold the position itself and call the core.
Addresses: Addresses. Never hardcode production ids from a testnet snippet. Zap and PositionRouter must hold zero balances after a call. If you wrap them, sweep leftovers back in the same transaction. Do not call LiquidationModule.liquidate yourself. It reverts NotCore. Submit through Stockline.liquidate.

What can go wrong

  • Missing operator grant: NotOperator.
  • Weekend: RegimeBlocked.
  • Guardian pause: Paused.
  • Book still closed: BorrowingDisabled.
Next: Open a loan, Zap. A contract integration is a user of the same action table as the app. repay and supplyCollateral stay live in every regime and under guardian pause. borrow and withdrawCollateral require LIVE and not paused. liquidate requires LIVE or DARK and not paused. If your contract holds stock and wants to open a loan in one transaction, either call Stockline directly or setOperator for PositionRouter and then openPosition. Do not leave balances on the router. The invariant is that PositionRouter, Zap, and CreatorFeeRouter hold zero after any call sequence. Permit on the stock token is optional. deadline = 0 skips permit and uses transferFrom. Approve first if you skip permit. Read RiskLens from offchain for UI. Onchain views of maxBorrow are fine for a keeper or a wrapper that must not over-borrow. Never send uiMultiplier into those checks.