Skip to main content

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:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol (aave, compound, euler, morpho, venus)
tokenAddressstringYesToken to supply
amountstringYesAmount to supply
walletAddressstringYesUser wallet address

Withdraw Assets

POST /lending/withdraw

Withdraw supplied assets from a lending protocol.

Request Body:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol
tokenAddressstringYesToken to withdraw
amountstringYesAmount to withdraw
walletAddressstringYesUser wallet address

Borrowing

Borrow Assets

POST /lending/borrow

Borrow assets against supplied collateral.

Request Body:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol
tokenAddressstringYesToken to borrow
amountstringYesAmount to borrow
walletAddressstringYesUser wallet address

Repay Loan

POST /lending/repay

Repay borrowed assets.

Request Body:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol
tokenAddressstringYesToken to repay
amountstringYesAmount to repay
walletAddressstringYesUser wallet address

Position Management

Get User Positions

GET /lending/getUserPositions

Retrieve all lending positions for a user.

Query Parameters:

ParameterTypeRequiredDescription
walletAddressstringYesUser wallet address
chainIdnumberYesChain ID
protocolstringNoFilter 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:

ParameterTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol

Set Collateral

POST /lending/setCollateral

Enable or disable an asset as collateral.

Request Body:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesLending protocol
tokenAddressstringYesToken address
useAsCollateralbooleanYesEnable/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.