Positions & Queries
Get Loan
Read a loan directly from the market contract
GET
/
lending-external-securities
/
api
/
positions
/
{marketId}
/
loan
/
{loanId}
curl "https://api.trusset.org/lending-external-securities/api/positions/{marketId}/loan/5" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/positions/${marketId}/loan/5`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const liquidatable = data.active && parseFloat(data.healthFactor) < 1;
{
"success": true,
"data": {
"loanId": "5",
"borrower": "0xabc...def",
"collateralAmount": "1000.000000000000000000",
"principal": "50000.000000",
"accruedInterest": "128.750000",
"healthFactor": "1.842000000000000000",
"active": true
}
}
{
"success": false,
"error": {
"code": "LOAN_NOT_FOUND",
"message": "Loan not found"
}
}
{
"success": false,
"error": {
"code": "INVALID_LOAN_ID",
"message": "Valid loan ID required"
}
}
Returns live loan state by numeric loan ID, read from the contract with no database involvement. Use this when you need authoritative figures for a payoff quote, a health check, or a liquidation decision.
Path Parameters
string
required
Market ID.
integer
required
On-chain loan ID. Must be a positive integer.
Response Fields
object
Show child attributes
Show child attributes
string
Loan ID, echoed back.
string
Borrower address.
string
Collateral pledged, in collateral token units.
string
Outstanding principal, in borrow asset units.
string
Interest accrued and unpaid, in borrow asset units.
string
Health factor at 18 decimal places.
1.0 is the liquidation boundary.boolean
Whether the loan is open.
false once it is repaid, closed, or fully liquidated.Total payoff is
principal plus accruedInterest. Interest accrues per block, so add a small margin when quoting a full repayment. The contract caps repayment at the actual debt, so a slight overpayment is not transferred.curl "https://api.trusset.org/lending-external-securities/api/positions/{marketId}/loan/5" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/positions/${marketId}/loan/5`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const liquidatable = data.active && parseFloat(data.healthFactor) < 1;
{
"success": true,
"data": {
"loanId": "5",
"borrower": "0xabc...def",
"collateralAmount": "1000.000000000000000000",
"principal": "50000.000000",
"accruedInterest": "128.750000",
"healthFactor": "1.842000000000000000",
"active": true
}
}
{
"success": false,
"error": {
"code": "LOAN_NOT_FOUND",
"message": "Loan not found"
}
}
{
"success": false,
"error": {
"code": "INVALID_LOAN_ID",
"message": "Valid loan ID required"
}
}
⌘I
curl "https://api.trusset.org/lending-external-securities/api/positions/{marketId}/loan/5" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/positions/${marketId}/loan/5`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const liquidatable = data.active && parseFloat(data.healthFactor) < 1;
{
"success": true,
"data": {
"loanId": "5",
"borrower": "0xabc...def",
"collateralAmount": "1000.000000000000000000",
"principal": "50000.000000",
"accruedInterest": "128.750000",
"healthFactor": "1.842000000000000000",
"active": true
}
}
{
"success": false,
"error": {
"code": "LOAN_NOT_FOUND",
"message": "Loan not found"
}
}
{
"success": false,
"error": {
"code": "INVALID_LOAN_ID",
"message": "Valid loan ID required"
}
}
