# Technical Overview of the Yield Source Contract

### Yield Source

We have introduced the IYieldSource interface as a standardized approach to managing yield sources. The interface acts as a conduit between the SIV and the actual yield source. Typically, the IYieldSource operates on behalf of the SIV; hence, **it's crucial for the SIV to hold ownership of the IYieldSource implementation.**

One critical feature of the IYieldSource implementation is the ability to convert the generated yield into a payment token and transfer it back to the SIV. Our goal is to give developers **flexibility** in managing this implementation. They can choose suitable yield aggregators and determine the allocation of yield for insurance purchases.

| yieldToken                                                  | address of reward token                                                                                                              |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| sourceToken                                                 | address of yield-bearing asset                                                                                                       |
| function pendingYield()                                     | returns the pending yield, which is the amount of `yieldToken` currently available to be claimed by the contract.                    |
| function pendingYieldInToken(address outToken)              | estimates the amount of outToken that can be obtained by harvesting the yield.                                                       |
| function totalDeposit()                                     | retrieves the total amount of `sourceToken` currently deposited.                                                                     |
| function deposit(uint256 amount)                            | is used to transfer `sourceToken` from the SIV to the Yield Source contract, where yield strategy can be implemented like `staking`. |
| function withdraw(uint256 amount, bool claim, address to)   | can only be called by `owner` (SIV), used to withdraw `sourceToken`.                                                                 |
| function claimAndConvert( address outToken, uint256 amount) | is used to claim yield and execute yield harvesting strategy and then transferred to the SIV.                                        |

Example implementation: \
[Stargate LP staking rewards ](https://github.com/Y2K-Finance/SelfInsuredVault/blob/master/src/sources/StargateLPYieldSource.sol)


---

# 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://y2k-finance.gitbook.io/y2k-finance/products/earthquake-builder-program/builder-info/technical-overview-of-the-yield-source-contract.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.
