> For the complete documentation index, see [llms.txt](https://docs.tydro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tydro.com/vii.-developers/credit-delegation.md).

# Credit Delegation

Credit delegation allows a supplier to contribute liquidity to Tydro to earn interest, and delegate their borrowing power (i.e. their credit) to another address.\
The enforcement of the borrow position and its terms are agreed upon between the supplier (delegator) and the borrower (delegatee), which can happen either off-chain (via legal agreements) or on-chain (via smart contracts).

This enables:

* The delegator to earn extra yield on top of their base lending yield
* The delegatee to access uncollateralized liquidity

Borrowing by a delegatee must be consistent with the delegator’s eMode category. For example, if a delegator is in the STABLECOINS eMode:

* Delegatee can only borrow assets within the STABLECOINS category
* If a delegatee attempts to borrow a non-STABLECOIN asset (e.g. WETH), the transaction will revert

Additionally, the delegatee cannot cause liquidation of the delegator. If a delegated borrow causes the delegator’s Health Factor to drop below the liquidation threshold, the transaction will fail.

### Approving the delegation

The approveDelegation or delegationWithSig function on the [VariableDebtToken](https://docs.tydro.com/vii.-developers/developer-overview/smart-contracts/tokenization.md#variabledebttoken) contract must be called by the supplier (delegator), approving the borrower (delegatee) a certain amount.

This is done for each debt token that needs to be delegated.

The delegator does not need to already have supplied funds in the protocol to approveDelegation. However, **before** the delegatee executes borrow, there must be sufficient collateral supplied by delegator in the protocol.

### Borrowing the credit

The borrower (delegatee) calls the borrow function on the [Pool](https://docs.tydro.com/vii.-developers/developer-overview/smart-contracts/pool.md), using the supplier's (delegator's) address in final parameter onBehalfOf.

The borrower's available credit is reduced by the borrowed amount.

### Repaying the credit

Anyone can repay the borrow position *OnBehalf* of the user, by calling one of the following [Pool](https://docs.tydro.com/vii.-developers/developer-overview/smart-contracts/pool.md) functions - repay or repayWithPermit. The supplier (aka creditor) can also use the repayWithATokens function to repay a borrow position with their *aTokens* of the underlying asset in the same pool.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tydro.com/vii.-developers/credit-delegation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
