Documentation Index
Fetch the complete documentation index at: https://docs.compasslabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
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 credit product live in days.What It Does
Let users borrow stablecoins and other assets against their crypto holdings through Aave. Build products that offer over-collateralised loans, manage collateral positions, and handle liquidation risk - all through a single API. You call our API, we return a transaction payload. You or your users sign and broadcast. Users access credit, you capture fees. Important: Users must first create a Credit Account before borrowing or managing credit positions. Each wallet address gets one Credit Account per chain.How It Works
The Credit 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.| Protocol | What it does |
|---|---|
| Aave V3 | Lending and borrowing with variable interest rates |
| 1inch | Automatic token swaps when input token differs from collateral |
| Permit2 | Gasless token transfers from EOA to Credit Account |
Getting Started
1. Create a Credit Account
Before using any credit features, create a Credit Account. This deploys an isolated on-chain account controlled by the user’s wallet.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.
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.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.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.| Field | Description |
|---|---|
| account_summary | Health factor, total collateral/debt in USD, LTV, available borrow capacity, E-Mode status |
| collateral_positions | Per-reserve: token, amount, USD value, supply APY, total deposited/withdrawn, interest earned, event history |
| debt_positions | Per-reserve: token, amount, USD value, borrow APY, total borrowed/repaid, interest paid, event history |
| borrowable_tokens | All tokens available to borrow with max borrowable amounts and current APYs |
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
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 credit 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:
| Action Type | Description |
|---|---|
CREDIT_SUPPLY | Supply tokens as collateral to Aave |
CREDIT_WITHDRAW | Withdraw collateral from Aave |
CREDIT_BORROW | Borrow tokens against collateral |
CREDIT_REPAY | Repay outstanding debt |
CREDIT_ENABLE_COLLATERAL | Enable a token as collateral in Aave |
V2_SWAP | Swap tokens within the Credit Account |
V2_TRANSFER_FROM_EOA | Pull tokens from EOA into Credit Account |
V2_TRANSFER_TO_EOA | Send tokens from Credit Account to EOA |
CREDIT_TRANSFER_TO_ADDRESS | Send tokens to any address |
gas_sponsorship: true for gasless execution.
Use Cases
Crypto-Backed Loans: 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 Global Markets: Combine Credit with Global Markets. 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.