Positions & Queries
Get User Loans
List a borrower active loans in a market
GET
/
lending-external-securities-v2
/
api
/
positions
/
{marketId}
/
user-loans
/
{userAddress}
curl "https://api.trusset.org/lending-external-securities-v2/api/positions/{marketId}/user-loans/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-loans/${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const totalDebt = data.loans.reduce(
(sum, l) => sum + Number(l.principal) + Number(l.accruedInterest),
0
);
const pastGrace = data.loans.filter(l => l.term?.enforceable === true);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"loans": [
{
"loanId": "5",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "1000.0",
"principal": "50000.0",
"accruedInterest": "961.643835",
"healthFactor": "1.842",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1796630400",
"term": {
"dueAt": "1796630400",
"effectiveDueAt": "1796630400",
"graceEnd": "1796889600",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
},
{
"loanId": "9",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "250.0",
"principal": "12000.0",
"accruedInterest": "53.424657",
"healthFactor": "1.204",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1803801600",
"term": {
"dueAt": "1803801600",
"effectiveDueAt": "1803801600",
"graceEnd": "1804060800",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
}
],
"payeeLoans": []
}
}
Returns every open loan held by one address in one market, read from the contract. Closed, repaid, and fully liquidated loans are excluded. An open loan with no debt left is still listed, with
debtFree: true, until it is closed.
A borrower can hold several loans in the same market at once. Each is independent, with its own collateral, debt, health factor and due date, and each is liquidated separately.
Path Parameters
string
required
string
required
Borrower address,
0x followed by 40 hex characters.Response Fields
object
Show child attributes
Show child attributes
string
The address queried, echoed back as sent.
array
Active loans. Each entry has the shape of Get Loan without the
compliance block: loanId, borrower, payee, collateralAmount, principal, accruedInterest, healthFactor, active, debtFree, fixedRateBps, dueAt and term. payee, debtFree, fixedRateBps, dueAt and term come from a batched read and are absent from an entry that had to be read on its own because that read failed.array
Active loans of this market that pay their draws to
userAddress as their payee, while another wallet is the borrower of record. Same shape as loans, with payee set to userAddress in lowercase. Taken from the loans this instance records with that payee, at most the 50 most recently opened, refreshed from the chain first, and read from the contract. Empty when the market predates pay-to, when the address is no loan’s payee, or when the read fails. See Pay the proceeds to another wallet.An empty
loans array means the borrower has no open loans here. It does not distinguish that from a failed chain read, which also returns an empty array. Confirm the market is reachable through Get Market Metrics if an empty result is unexpected.curl "https://api.trusset.org/lending-external-securities-v2/api/positions/{marketId}/user-loans/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-loans/${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const totalDebt = data.loans.reduce(
(sum, l) => sum + Number(l.principal) + Number(l.accruedInterest),
0
);
const pastGrace = data.loans.filter(l => l.term?.enforceable === true);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"loans": [
{
"loanId": "5",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "1000.0",
"principal": "50000.0",
"accruedInterest": "961.643835",
"healthFactor": "1.842",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1796630400",
"term": {
"dueAt": "1796630400",
"effectiveDueAt": "1796630400",
"graceEnd": "1796889600",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
},
{
"loanId": "9",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "250.0",
"principal": "12000.0",
"accruedInterest": "53.424657",
"healthFactor": "1.204",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1803801600",
"term": {
"dueAt": "1803801600",
"effectiveDueAt": "1803801600",
"graceEnd": "1804060800",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
}
],
"payeeLoans": []
}
}
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-loans/0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/positions/${marketId}/user-loans/${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const totalDebt = data.loans.reduce(
(sum, l) => sum + Number(l.principal) + Number(l.accruedInterest),
0
);
const pastGrace = data.loans.filter(l => l.term?.enforceable === true);
{
"success": true,
"data": {
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"loans": [
{
"loanId": "5",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "1000.0",
"principal": "50000.0",
"accruedInterest": "961.643835",
"healthFactor": "1.842",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1796630400",
"term": {
"dueAt": "1796630400",
"effectiveDueAt": "1796630400",
"graceEnd": "1796889600",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
},
{
"loanId": "9",
"borrower": "0xaBc7f1093D5E26B804a1C3f78dE025916B47C0d3",
"payee": null,
"collateralAmount": "250.0",
"principal": "12000.0",
"accruedInterest": "53.424657",
"healthFactor": "1.204",
"active": true,
"debtFree": false,
"fixedRateBps": 650,
"dueAt": "1803801600",
"term": {
"dueAt": "1803801600",
"effectiveDueAt": "1803801600",
"graceEnd": "1804060800",
"enforceable": false,
"termGracePeriod": "259200",
"termPenaltyBps": 300,
"stamped": true,
"termSource": "STAMPED"
}
}
],
"payeeLoans": []
}
}
