Positions & Queries
Get User Collateral
Read a borrower total collateral in a market
GET
/
lending-external-securities-v2
/
api
/
positions
/
{marketId}
/
user-collateral
/
{userAddress}
curl "https://api.trusset.org/lending-external-securities-v2/api/positions/{marketId}/user-collateral/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const headers = { 'X-API-Key': 'trusset_your_key_here' };
const [collateralRes, capsRes] = await Promise.all([
fetch(`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-collateral/${address}`, { headers }),
fetch(`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/supply-caps`, { headers })
]);
const { data: c } = await collateralRes.json();
const { data: caps } = await capsRes.json();
const cap = caps ? Number(caps.maxUserCollateral) : null;
const headroom = cap === null ? null : cap === 0 ? Infinity : cap - Number(c.collateral);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"collateral": "1250.0"
}
}
Returns the total collateral one address has locked across all of its open loans in a market, read from the contract. This is the figure the market’s
The example below reads the cap from Get Supply Caps alongside the total and works out how much more collateral the borrower may post.
maxUserCollateral cap is checked against when the address opens a loan or adds collateral. A cap of 0 means the market sets no per-borrower limit.
Path Parameters
string
required
string
required
Borrower address,
0x followed by 40 hex characters.Response Fields
object
This is an aggregate across every open loan the address holds in this market, not a per-loan figure. Collateral leaves it when it is withdrawn, returned on close, or seized in a liquidation. For the breakdown, use Get User Loans.
curl "https://api.trusset.org/lending-external-securities-v2/api/positions/{marketId}/user-collateral/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const headers = { 'X-API-Key': 'trusset_your_key_here' };
const [collateralRes, capsRes] = await Promise.all([
fetch(`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-collateral/${address}`, { headers }),
fetch(`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/supply-caps`, { headers })
]);
const { data: c } = await collateralRes.json();
const { data: caps } = await capsRes.json();
const cap = caps ? Number(caps.maxUserCollateral) : null;
const headroom = cap === null ? null : cap === 0 ? Infinity : cap - Number(c.collateral);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"collateral": "1250.0"
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | userAddress is not 0x followed by 40 hex characters |
NO_MARKET_ADDRESS | 400 | The market has no on-chain address recorded |
MISSING_MARKET_ID | 400 | The market ID 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/positions/{marketId}/user-collateral/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const headers = { 'X-API-Key': 'trusset_your_key_here' };
const [collateralRes, capsRes] = await Promise.all([
fetch(`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-collateral/${address}`, { headers }),
fetch(`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/supply-caps`, { headers })
]);
const { data: c } = await collateralRes.json();
const { data: caps } = await capsRes.json();
const cap = caps ? Number(caps.maxUserCollateral) : null;
const headroom = cap === null ? null : cap === 0 ? Infinity : cap - Number(c.collateral);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"collateral": "1250.0"
}
}
