# Repay

* In order to repay the loan, User has to have some assets borrowed.
* User can make a request to the Repay method with the SRWA User Badge and the bucket of assets that the User wants repaid.
* Protocol will calculate how much of the loan is repaid, if the amount that the User sent is less then it's owed, borrow balance will be decreased for that amount, if it's more than it's owed, loan will be paid in full and the rest will be transferred back to the Users wallet.
* Protocol will then calculate the price of the SB Token, Users accrued interest if there's any, total borrow balance of SB Token and the asset and Users balance in SB Token. After that, Protocol will update Protocol borrow balance and Users deposit balance in SRWA User Badge and transfer repaid assets to the Pool and the change if any, to the Users wallet.

Repayment is the simplest operation in terms that it can be done at any time, by sending any amount of assets. It only takes into account the current borrow balance of the user and the amount that is sent. When the protocol the gets repayment request, it checks how much the user owes, and if the repay amount is bigger then the debt, it erases it and returns the change to the users wallet, if it's smaller, it subtracts the  said amount from the debt.


---

# 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://srwa.gitbook.io/srwa-docs/getting-started/how-it-works/repay.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.
