Skip to main content

Why This Matters

Building a borrowing product from scratch means integrating with lending protocols, managing collateral ratios, handling swaps, tracking positions across chains, and ongoing maintenance. We’ve done that - you get one API that covers everything to get your lending product live in days.

What It Does

Let users borrow stablecoins and other assets against their crypto holdings through Aave V3 or Euler V2. Build products that offer over-collateralised loans, manage collateral positions, and handle liquidation risk - all through a single API. Choose the lending protocol per request with the protocol field (defaults to Aave). You call our API, we return a transaction payload. You or your users sign and broadcast. Users access liquidity, you capture fees. Important: Users must first create a Credit Account before borrowing or managing loan positions. Each wallet address gets one Credit Account per chain.

How It Works

The Crypto-Backed Loans API bundles multiple DeFi actions into single atomic transactions. A borrow operation can include a swap (if the input token differs from the collateral token), a collateral supply, and a borrow - all in one transaction. Repayments work the same way in reverse. We support Ethereum, Base, and Arbitrum. All operations go through the user’s Credit Account (an isolated on-chain account).

Choosing a Lending Protocol

Every /v2/credit/* endpoint accepts an optional protocol field:
  • "AAVE" (default) — markets are identified by token symbol (e.g. USDC, WETH). Existing integrations need no changes.
  • "EULER" — Euler V2 is permissionless, so there is no single market per token. Each market is an EVK vault address instead: pass the vault you borrow from as borrow_vault, and the vault you supply collateral into as collateral_vault.

Discover Euler markets

Use /v2/credit/euler_markets to list the curated Euler markets on a chain (read from Euler’s on-chain Governed Perspective). Each market is a borrow vault plus the collateral vaults it accepts, with live LTVs and APYs - everything you need to assemble an Euler borrow.

Isolate positions with sub-accounts

Euler enforces one borrow market per account, so a single Credit Account can normally hold only one Euler loan. To hold several independent Euler positions, target a sub-account (sub_account_id, 0255) on any Euler transact call (/borrow, /repay, /bundle). Each sub-account is an isolated position with its own collateral, borrow controller, and health factor — moving one never affects another. Sub-account 0 is the default (the Credit Account itself); omit sub_account_id for the original single-position behaviour. sub_account_id is ignored for Aave/Morpho. Read them back from /v2/credit/positions: every Euler collateral/debt position is tagged with its sub_account_id, and euler_account_summaries returns one health summary per active sub-account. Echo a position’s sub_account_id back into your transact calls to act on that specific position.

Borrow on Euler

Borrowing is the same /v2/credit/borrow call as Aave, plus protocol: "EULER" and the vault addresses from the discovery step:
Repaying works the same way: call /v2/credit/repay with protocol: "EULER" and the borrow_vault. Euler is available on Ethereum, Base, and Arbitrum.

Looping, unlooping & rebalancing

Leveraged loops let a user amplify exposure to their collateral against an Aave V3, Morpho, or Euler V2 market — and unwind that leverage — each in one atomic transaction. Both sides carry a hard safety property: every internal swap is executed against a guaranteed on-chain minimum output, so a fill anywhere inside the slippage tolerance can never break a later step. Any positive surplus above the floor is left in the Credit Account as recoverable dust, and the preview reports the worst-case bound as estimated_max_dust. LoopingPOST /v2/credit/loop. Repeatedly supplies collateral, borrows at the requested loan_to_value, and swaps the borrowed token back to collateral, chaining each swap’s guaranteed minimum into the next supply until the position reaches the requested multiplier. The Credit Account must already hold initial_collateral_amount of the collateral token; for protocol: "MORPHO" pass a market_id from /v2/credit/morpho_markets; for protocol: "EULER" pass the collateral_vault and borrow_vault from /v2/credit/euler_markets, optionally targeting an isolated sub_account_id. Inspect open loops with /v2/credit/looped_positions. UnloopingPOST /v2/credit/unloop. The inverse: repeatedly withdraws collateral, swaps it to the borrow token at a guaranteed minimum, and repays. Omit target_multiplier for a full close (the debt is cleared exactly — accrued interest included — and the collateral is returned to the Credit Account); pass 1 to clear the debt but keep the collateral supplied, or a value above 1 to delever to that multiplier. Each withdrawal is sized to keep the position’s health factor ≥ 1.02 at that step, so a position opened very close to the liquidation threshold may need more than one transaction to fully close — set allow_partial: true to take the maximum single-transaction progress (preview.fully_unwound is false), then call unloop again to finish. Euler unwinds the same position identifiers as the loop (collateral_vault, borrow_vault, sub_account_id); a full close also detaches the sub-account’s controller, freeing it for a new market. RebalancingPOST /v2/credit/rebalance. Reshape a whole book of loops toward a set of desired end states in one atomic transaction. Each entry in targets names a position by protocol and pair (Aave) or market_id (Morpho) and a goal — target_equity_usd, target_multiplier, both, or close: true to remove it. The engine derives one of six operations per target from its current vs desired state — open, close, grow (more equity), shrink (less equity), lever_up (more leverage), or lever_down (less) — and reports each as direction in the preview. Positions not listed are left untouched; the request is scoped, not a whole-portfolio wipe. The call is all-or-nothing across targets, and it releases capital before consuming it: it delevers/closes first (Phase A), routes the freed collateral between positions with capital-routing swaps if the tokens differ (Phase B), then grows/opens (Phase C) — so a shrink or close on one position can fund a grow or open on another, including across protocols (an Aave close funding a Morpho open) in the same transaction. Any additional growth beyond the freed and idle capital must come from the Credit Account’s idle balance; if the book grows past what’s available the call returns a 422 asking you to fund the account first via /v2/credit/transfer. Every swap — per-position and capital-routing alike — uses the same guaranteed on-chain minimum output, and preview.estimated_max_dust bounds the recoverable surplus across the whole plan. When every named target is already at its goal within tolerance the plan is a no-op and the response returns transaction: null.

Getting Started

1. Create a Credit Account

Before using any borrowing features, create a Credit Account. This deploys an isolated on-chain account controlled by the user’s wallet.
The account address is deterministic - calling create twice for the same owner and chain returns the same address with transaction: null on the second call.

2. Fund the Credit Account

Transfer tokens from the user’s wallet (EOA) into their Credit Account using the /v2/credit/transfer endpoint.
With gas_sponsorship: true, the response returns EIP-712 typed data (a Permit2 signature) instead of an unsigned transaction - the user signs off-chain and a gas sponsor executes the transfer.

3. Borrow Against Collateral

Supply collateral and borrow in a single atomic transaction. If your input token differs from the collateral token, a swap is performed automatically via 1inch.
Borrow-only mode: Omit token_in, amount_in, and collateral_token to borrow against existing collateral without supplying more.

4. Repay Debt

Repay borrowed assets and optionally withdraw collateral in a single atomic transaction.
Repay-only mode: Omit withdraw_token and withdraw_amount to repay debt without withdrawing collateral. Swap on withdrawal: Set token_out to a different token than withdraw_token to automatically swap the withdrawn collateral via 1inch.

Track Positions

Positions

Get the full state of a Credit Account including collateral, debt, health factor, and borrowable tokens.
The response includes:
Euler positions are returned by the same endpoint. Euler collateral and debt positions appear in collateral_positions / debt_positions (each tagged protocol: "EULER" and its sub_account_id, with per-collateral max_ltv and supply_apy). Like Aave, Euler positions now carry full activity historytotal_deposited / total_withdrawn / interest_earned on collateral, total_borrowed / total_repaid / interest_paid on debt, and an events[] timeline — derived from indexed on-chain events. Alongside the positions you get euler_account_summaries (one health/LTV/available-borrows summary per active sub-account), euler_borrowable_tokens (how much more can be borrowed from the current Euler controllers), and euler_account_summary (deprecated: the sub-account-0 summary, kept for one release — prefer euler_account_summaries). Use /v2/credit/euler_markets to discover a different market to borrow from.

Health Factor

The health factor indicates how close an account is to liquidation:
  • > 1.5 — Healthy position with comfortable buffer
  • 1.0 - 1.5 — Getting risky, consider adding collateral or repaying debt
  • < 1.0 — Eligible for liquidation
If the health factor drops below 1, the position can be liquidated by anyone on-chain. Monitor this value and alert users when it approaches dangerous levels.

Balances

Use /v2/credit/balances to get token balances held in the Credit Account along with transfer history. Takes the same chain and owner query parameters as the positions endpoint.

Advanced: Bundle Actions

Compose multiple lending operations into a single atomic transaction using the /v2/credit/bundle endpoint. This is also how you supply collateral independently — use the CREDIT_SUPPLY action to add collateral without borrowing, or combine it with other actions. Supported action types: To bundle Euler actions, add protocol: "EULER" to each action’s body along with its collateral_vault (for supply) or borrow_vault (for borrow/repay), exactly as in the single-action endpoints above.
All bundle endpoints support gas_sponsorship: true for gasless execution.

Use Cases

Consumer Borrowing: Build a lending product where users deposit ETH or stablecoins as collateral and borrow against it. Show health factor, interest rates, and liquidation warnings in your UI. Example: User deposits 10,000 USDC as collateral and borrows 0.5 WETH at 3.2% APY. You embed a fee on each borrow transaction. Leverage Trading: Let users borrow assets to increase exposure. Deposit collateral, borrow stablecoins, swap to the desired asset - all bundled in a single atomic transaction. Example: User deposits 2 ETH, borrows 5,000 USDC, swaps to more ETH for leveraged long exposure. Margin for Perpetual Trading: Combine Crypto-Backed Loans with Perpetual Trading. Users borrow USDC against crypto collateral, then use it to trade stock perps. Example: User deposits 10,000 USDC as collateral, borrows 5,000 USDC, deposits it to trade AAPL and NVDA perps on Hyperliquid.

Next Steps

Product Accounts

Learn more about how Credit Accounts work.

Earn

Earn yield on idle assets while using them as collateral.

Gas Sponsorship

Sponsor gas for your users so they never need ETH.