Lending API
Endpoints for lending, borrowing, and managing DeFi lending positions.
Supply & Withdraw
Supply Assets
POST /lending/supply
Deposit assets into a lending protocol to earn interest.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol (aave, compound, euler, morpho, venus) |
tokenAddress | string | Yes | Token to supply |
amount | string | Yes | Amount to supply |
walletAddress | string | Yes | User wallet address |
Withdraw Assets
POST /lending/withdraw
Withdraw supplied assets from a lending protocol.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol |
tokenAddress | string | Yes | Token to withdraw |
amount | string | Yes | Amount to withdraw |
walletAddress | string | Yes | User wallet address |
Borrowing
Borrow Assets
POST /lending/borrow
Borrow assets against supplied collateral.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol |
tokenAddress | string | Yes | Token to borrow |
amount | string | Yes | Amount to borrow |
walletAddress | string | Yes | User wallet address |
Repay Loan
POST /lending/repay
Repay borrowed assets.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol |
tokenAddress | string | Yes | Token to repay |
amount | string | Yes | Amount to repay |
walletAddress | string | Yes | User wallet address |
Position Management
Get User Positions
GET /lending/getUserPositions
Retrieve all lending positions for a user.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
walletAddress | string | Yes | User wallet address |
chainId | number | Yes | Chain ID |
protocol | string | No | Filter by protocol |
Response:
{
"positions": [
{
"protocol": "aave",
"tokenAddress": "0x...",
"symbol": "USDC",
"balance": "1000.00",
"assetsUsd": "1000.00",
"APY": "4.52",
"isCollateral": true,
"collateralFactor": "0.80"
}
]
}
Get Reserve List
GET /lending/getReserveList
Retrieve available lending reserves and their current rates.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol |
Set Collateral
POST /lending/setCollateral
Enable or disable an asset as collateral.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | Lending protocol |
tokenAddress | string | Yes | Token address |
useAsCollateral | boolean | Yes | Enable/disable collateral |
Get Borrowable Assets
GET /lending/getBorrowableAssets
Get a list of assets available for borrowing.
Get Max Borrow Amount
GET /lending/getMaxBorrowAmount
Calculate the maximum amount a user can borrow based on their collateral.
Refresh User Positions
GET /lending/refreshUserPositions
Force a refresh and sync of user lending positions from on-chain data.