Getting Repay Details
Getting user loans
The first step in repaying is to get the user loans. To do this, first query the subgraph using the user's wallet address
{
user(id: "0x359e8a8ab1061ec972d9b8f807577563432b8994") { # replace this by the user id
borrowers {
marketplaceId
tokenVolumes {
aprAverage
aprActiveAverage
lendingTokenAddress
}
loans {
all(where: { status_not: "Repaid" }) {
totalRepaidPrincipal
principal
borrowerAddress
lenderAddress
apr
marketplaceId
lendingTokenAddress
loanDuration
paymentCycle
paymentCycleAmount
metadataURI
bidId
acceptedTimestamp
lastRepaidTimestamp
nextDueDate
paymentDefaultDuration
status
expiresAt
collateral {
type
collateralAddress
token {
name
symbol
decimals
}
amount
tokenId
status
}
marketplace {
paymentType
}
}
}
}
}
}The important element to note here is querying the loans by status that has not been Repaid
This returns a list of all the loans for a specific user wallet, and with the most important information to display in the front end.
Last updated