Before you start
- An API key. See the Quick Start.
- A Credit Account for the user on the chain you want, holding the collateral token. See Create an Account and Fund an Account.
1. Pick a market
Every request names the lending protocol withprotocol. It defaults to AAVE.
For example, list the Aave markets on Base:
2. Borrow
Supply 1,000 USDC as collateral and borrow 0.2 WETH on Aave, in one transaction:
The user signs
transaction and sends it. To pay the loan out to the user’s wallet, call transfer with action: "WITHDRAW". This works while the loan is open. See Withdraw Funds.
3. Track the loan
4. Repay
Repay 0.2 WETH and withdraw the 1,000 USDC collateral in one transaction:repay_token. Interest accrues on the debt every block, so read amount_borrowed from debt_positions right before you build the repayment. Leave out withdraw_token and withdraw_amount to repay without withdrawing. Set token_out to have the withdrawn collateral swapped into another token. Afterwards, send the collateral to the user’s wallet with transfer. See Withdraw Funds.
Good to know
- Morpho and Euler. Send
protocol: "MORPHO"with themarket_id, orprotocol: "EULER"withcollateral_vaultandborrow_vault, onborrowandrepayalike. On Morpho,collateral_tokenandborrow_tokenmust be the market’s own pair. An identifier that doesn’t match the protocol, such as amarket_idon Aave, returns422. - On HyperEVM,
AAVEandMORPHOselect the chain’s equivalent lending venues. Nothing else changes. - Several Euler loans in one account. Euler allows one borrow market per account, so give each extra loan its own
sub_account_id(1to255) and pass the same id when you repay. Positions report the id they live in. - Supply collateral without borrowing. Use
bundlewith aCREDIT_SUPPLYaction. Bundles also combine supply, borrow, repay, withdraw, swap and transfer actions into one transaction. - Leverage. To multiply a position by supplying, borrowing and swapping in a loop, see Leveraged Looping.
- Errors. Credit endpoints return
400 Credit Account not deployeduntil the account exists on that chain. Calling a protocol on a chain that doesn’t have it returns422with the chains that do.
Endpoints
Next
Leveraged Looping
Open and unwind leveraged positions in one transaction.
Embedded Fees
Earn a fee on every loan.
Gas Sponsorship
Pay gas for your users so they never need ETH.