Borrow API
Draw liquidity against treasury holdings on Aave and Morpho without selling them — and monitor the loan's health programmatically.
Requires a key or token scoped to Borrow. Shares Earn's on-chain read infrastructure, but its own order, policy, compliance, and approvals surface.
Markets & borrowing
Browse markets
const { markets } = await client.listBorrowMarkets({
chain: 'ethereum',
protocol: 'aave',
});
// -> [{ id, protocol, protocolId, chain, borrowAsset, collateralAssets, borrowApy,
// maxLtvBps, liquidationThresholdBps, availableLiquidity }, ...]Supply collateral, then borrow
Every step here — supplying collateral, borrowing, repaying, withdrawing collateral — is an
order (create → submit → approvals → signing), with Order.* events on the borrow domain.
const supply = await client.createBorrowOrder({
walletId,
chain: 'ethereum',
protocol: 'aave',
marketId: market.id, // BorrowMarket.id — not its (Morpho-only, optional) .marketId field
action: 'SUPPLY_COLLATERAL',
assetSymbol: 'ETH',
amount: '10',
amountRaw: '10000000000000000000',
});
await client.submitBorrowOrder(supply.id);
const draw = await client.createBorrowOrder({
walletId,
chain: 'ethereum',
protocol: 'aave',
marketId: market.id,
action: 'BORROW',
assetSymbol: 'USDC',
amount: '15000',
amountRaw: '15000000000',
});
await client.submitBorrowOrder(draw.id);Monitor health
Read health factor and LTV whenever you need them.
const { positions } = await client.getBorrowPositions(walletAddress);
// -> [{ protocol, chain, collateral, debt, healthFactor, ltvBps, liquidationThresholdBps }, ...]healthFactor is null when there's no outstanding debt. Below 1.0, the protocol can
liquidate collateral.
Push-based — your on-call channel hears about a position at risk without polling.
Subscribe to Borrow.AlertTriggered (org-wide liquidation alerts attached to the position) and
the shared Order.* lifecycle on the borrow domain. Registration and signature verification
are in the webhooks guide.
Alert early, not at the brink
Health factor 1.0 is liquidation. Alerting at 1.3+ leaves room for a repay or top-up order to clear approvals before the protocol acts. Wire the alert to the same escalation path as your production incidents — a liquidation is one.
The same events, live — for a dashboard that wants push without a receiver.
Same subscription and scoping rules as webhooks — see the WebSockets guide. Live-only: an event published while you're disconnected is missed, so pair this with polling rather than relying on it alone for something as consequential as a liquidation risk.
Repay & withdraw
await client.createBorrowOrder({
walletId,
chain: 'ethereum',
protocol: 'aave',
marketId: market.id,
action: 'REPAY',
assetSymbol: 'USDC',
amount: '15000',
amountRaw: '15000000000',
});
// 'WITHDRAW_COLLATERAL' unwinds supplied collateral the same way, once debt allows it.Recurring schedules
await client.createRecurringBorrowOrder({
walletId,
chain: 'ethereum',
protocol: 'aave',
marketId: market.id,
action: 'REPAY',
assetSymbol: 'USDC',
amount: '2000',
interval: 'MONTHLY',
});The standard way to amortize a draw without a human remembering to do it. Manage schedules with
listRecurringBorrowOrders, toggleRecurringBorrowOrder(id, enabled), and
removeRecurringBorrowOrder(id).