# 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

```graphql
{
  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.&#x20;

```json
{
    "data": {
        "user": {
            "borrowers": [
                {
                    "loans": {
                        "all": [
                            {
                                "acceptedTimestamp": "1729976725",
                                "apr": "2500",
                                "bidId": "4295",
                                "borrowerAddress": "0x359e8a8ab1061ec972d9b8f807577563432b8994",
                                "collateral": [
                                    {
                                        "amount": "5000000000000000000",
                                        "collateralAddress": "0x692ac1e363ae34b6b489148152b12e2785a3d8d6",
                                        "status": "Deposited",
                                        "token": {
                                            "decimals": "18",
                                            "name": "Polytrade (PoS)",
                                            "symbol": "TRADE"
                                        },
                                        "tokenId": "0",
                                        "type": "ERC20"
                                    }
                                ],
                                "expiresAt": "1730581525",
                                "lastRepaidTimestamp": "0",
                                "lenderAddress": "0x0854d0c201fd3f9e0ae2341c92b28d289234549c",
                                "lendingTokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
                                "loanDuration": "604800",
                                "marketplace": {
                                    "paymentType": "EMI"
                                },
                                "marketplaceId": "33",
                                "metadataURI": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
                                "nextDueDate": "1730581525",
                                "paymentCycle": "604800",
                                "paymentCycleAmount": "607360",
                                "paymentDefaultDuration": "0",
                                "principal": "604395",
                                "status": "Accepted",
                                "totalRepaidPrincipal": "0"
                            }
                        ]
                    },
                    "marketplaceId": "33",
                    "tokenVolumes": [
                        {
                            "aprActiveAverage": "2500",
                            "aprAverage": "2500",
                            "lendingTokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"
                        }
                    ]
                }
            ]
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.teller.org/teller-lite/dev-guide/repay/getting-repay-details.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
