Markets
Get Max Borrow
Quote the maximum borrowable amount for a collateral size
GET
/
lending-external-securities-v2
/
api
/
markets
/
{marketId}
/
max-borrow
curl "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/max-borrow?collateralAmount=1000" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/max-borrow?collateralAmount=1000`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
if (data.isStale !== false) console.warn('Price is stale or unknown; attach a signed price');
{
"success": true,
"data": {
"collateralAmount": "1000",
"maxBorrow": "78615.0",
"isStale": false,
"priceAge": 1200
}
}
{
"success": false,
"error": {
"code": "INVALID_AMOUNT",
"message": "collateralAmount query param required"
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "collateralAmount", "message": "Amount must be a number with at most 18 decimal places" }
]
}
}
Returns the largest debt the market will allow against a given quantity of collateral, computed by the contract from the stored oracle price and the collateral factor. Use it to drive a borrow slider before calling Open Loan.
The quote is the collateral bound alone. It does not check the pool’s liquidity, the supply caps, the minimum borrow, or whether the price is fresh. Open Loan checks each of those before it returns calldata. On a market that charges an open fee, the borrower receives the loan amount less that fee and owes the full amount.
The response also reports oracle freshness, because the contract refuses a new loan against a stale price.
Path Parameters
string
required
Query Parameters
string
required
Collateral quantity as a decimal string, for example
"1000". Must be greater than zero, and is parsed at the collateral token’s decimals, so it may carry no more decimal places than the token has.Response Fields
object
Show child attributes
Show child attributes
When
isStale is true, opening a loan against the stored price reverts. On a NAV or MARKET market, push a fresh price with Sync Oracle Price. Or attach a signedPrice from Sign Price to the borrow call. An ORACLE market takes neither: its price moves only when the external feed it reads updates. A FIXED market never reports a stale price.curl "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/max-borrow?collateralAmount=1000" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/max-borrow?collateralAmount=1000`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
if (data.isStale !== false) console.warn('Price is stale or unknown; attach a signed price');
{
"success": true,
"data": {
"collateralAmount": "1000",
"maxBorrow": "78615.0",
"isStale": false,
"priceAge": 1200
}
}
{
"success": false,
"error": {
"code": "INVALID_AMOUNT",
"message": "collateralAmount query param required"
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "collateralAmount", "message": "Amount must be a number with at most 18 decimal places" }
]
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
INVALID_AMOUNT | 400 | collateralAmount is missing, not a number, or not greater than zero |
VALIDATION_ERROR | 400 | collateralAmount is not a plain decimal, or carries more decimal places than the collateral token supports |
NO_MARKET_ADDRESS | 400 | The market has no on-chain address recorded |
MISSING_MARKET_ID | 400 | marketId is longer than 100 characters |
MARKET_NOT_FOUND | 404 | No market with this ID on your instance |
⌘I
curl "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/max-borrow?collateralAmount=1000" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/max-borrow?collateralAmount=1000`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
if (data.isStale !== false) console.warn('Price is stale or unknown; attach a signed price');
{
"success": true,
"data": {
"collateralAmount": "1000",
"maxBorrow": "78615.0",
"isStale": false,
"priceAge": 1200
}
}
{
"success": false,
"error": {
"code": "INVALID_AMOUNT",
"message": "collateralAmount query param required"
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "collateralAmount", "message": "Amount must be a number with at most 18 decimal places" }
]
}
}
