# LoanTermsConsensus Contracts

Teller utilizes nodes in order to sign borrower and lender requests before they can be accepted on-chain. The consensus contracts for Teller validate responses from the nodes in congruence with the borrower's request, this allows them to then facilitate or disburse the loan.&#x20;

The main external function for both of these contracts is the `processRequest()` method that processes the loan request, or the request for accrued interest, to ensure it is in line with current protocol settings and response variability.

{% hint style="info" %}
Internally, the contract calls the `_getConsensus()` method that checks if all the node values are within the tolerance set on the platform in order to retrieve the average of those values and set them on-chain.
{% endhint %}

The loan terms consensus contracts handle all borrower requests for loans and the related responses from the nodes handling `Loan Terms`

### processLoanTerms()

`function(`\
&#x20; `TellerCommon.LoanRequest calldata request,`\
&#x20; `TellerCommon.LoanResponse[] calldata responses,`\
`)`

`TellerCommon.LoanRequest` is a request struct/object that is sent to the Teller Nodes and subsequently on-chain, with all the required entries such as:

| Variable           | Type              | Description                                                                           |
| ------------------ | ----------------- | ------------------------------------------------------------------------------------- |
| `borrower`         | `address payable` | The wallet address of the borrower                                                    |
| `recipient`        | `address`         | The address where funds will be sent, only applicable in over collateralized loans    |
| `consensusAddress` | `address`         | The address of the Teller loan consensus contract to which the request should be sent |
| `requestNonce`     | `uint256`         | The nonce of the borrower wallet address required for authentication                  |
| `amount`           | `uint256`         | The number of tokens requested by the borrower for the loan                           |
| `duration`         | `uint256`         | The length of time in seconds that the loan has been requested for                    |
| `requestTime`      | `uint256`         | The timestamp at which the loan was requested                                         |

`TellerCommon.LoanResponse[]` is an array of signed response structs/objects that are returned from registered Teller nodes. These signed response structs/objects need to be passed on-chain in order to register the loan terms on-chain.

| Variable           | Type        | Description                                                                                          |
| ------------------ | ----------- | ---------------------------------------------------------------------------------------------------- |
| `signer`           | `address`   | The wallet address of the signer validating the interest request of the lender                       |
| `consensusAddress` | `address`   | The address of the Teller loan consensus contract to which the request should be sent                |
| `responseTime`     | `uint256`   | The timestamp at which the response was sent                                                         |
| `interestRate`     | `uint256`   | The signed interest rate generated by the signer's Credit Risk Algorithm (CRA)                       |
| `collateralRatio`  | `uint256`   | The ratio of collateral to loan amount that is generated by the signer's Credit Risk Algorithm (CRA) |
| `maxLoanAmount`    | `uint256`   | The largest amount of tokens that can be taken out in the loan by the borrower                       |
| `signature`        | `Signature` | The signature generated by the signer in the format of the below Signature struct                    |
