# Treasury

{% hint style="warning" %}
As of April 2023, those contracts have not been deployed, and there is no front-end for this module.
{% endhint %}

* **Module Name:** Treasury Module
* **Contract Sources:**&#x20;
  * [Treasury.sol](https://github.com/Kolektivo/kolektivo-monetary-contracts/blob/development/src/Treasury.sol)
  * [ElasticReceiptToken.sol](https://github.com/Kolektivo/kolektivo-monetary-contracts/blob/development/src/ElasticReceiptToken.sol)
  * Oracles

<details>

<summary>Table of Contents</summary>

[Summary](#summary)

[Module Details](#module-details)

[Treasury](#treasury)

[Treasury Token](#treasury-token)

[Failure Modes](#failure-modes)

</details>

## Summary

This module is a custom creation made of two smart contracts: The first one, the Kolektivo Treasury, holds the natural capital assets (or their indexes) and creates the Kolektivo Treasury Token (KTT) which directly represents the treasury’s value. KTT is a rebase token, influenced by [Ampleforth](https://docs.ampleforth.org/). Through its elastic supply and the rebasing mechanics, the aim is to keep the token value close to a certain ratio. The treasury is comprised of the various LP index tokens as well as other currencies.&#x20;

## Module Details

The Treasury Module has 2 core components consisting of the `Treasury.sol`, and `ElasticReceiptToken.sol` contracts.

{% embed url="<https://github.com/Kolektivo>" %}

## Treasury

The `Treasury.sol` contract allows to:

* Hold multiple tokens: ERC20, Index/Liquidity Tokens from Balancer, Stable Coins such as cUSD or cEUR, ERC721, and GeoNFTs.
* Withdraw certain tokens up to a certain amount (limited to certain addresses and revokable). For example: A mapping of address => `address` => `uint256`, where we can define “Address X can withdraw Token Y up to a limit of 123”.
* Send treasury assets to arbitrary addresses. For example, the Treasury has stables and wants to fund a Kolektivo community economy.&#x20;
* Sell and buy assets (bond and redeem) by minting/burning the Kolektivo Treasury Token (KTT). This implies that the treasury allows to:
  * List certain tokens as bondable/redeemable
  * List certain tokens to be unbonded/unredeemed
  * Dynamically set the price of the bonds based on the value of assets to un-/bond. Note that the pricing should depend on the average value for some time to prevent flash loan attacks.
* Perform negative and positive rebases
* Modify the rebase impact by applying a damping factor to the supply delta (e.g. 1/5)

{% hint style="info" %}
***What are supply delta and dampening factor?***

The supply delta is the input of the rebasing function (i.e. by how much the rebase should be). A dampening factor decreases the supply delta parameter to stretch the rebasing out over multiple epoches (soft) vs. doing it at once (hard).
{% endhint %}

* Create an elastic supply token (KTT).
* Modify the deviation threshold defining supply boundaries in which no rebase should occur (e.g. 5%)

{% embed url="<https://github.com/Kolektivo/kolektivo-monetary-contracts/blob/main/src/Treasury.sol>" %}

### Error Messages

| Code                                                                                     | Description                                                     |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `Treasury__ERC20IsNotBondable(address erc20)`                                            | Function is only callable for bondable erc20's                  |
| `Treasury__ERC721IdIsNotBondable(address erc721, uint id)`                               | Function is only callable for bondable erc721Id's               |
| `Treasury__ERC20IsNotRedeemable(address erc20)`                                          | Function is only callable for redeemable erc20's                |
| `Treasury__ERC721IdIsNotRedeemable(address erc721, uint id)`                             | Function is only callable for redeemable erc721Id's             |
| `Treasury__ERC20IsNotRegistered(address erc20)`                                          | Function is only callable for registered erc20's                |
| `Treasury__ERC721IdIsNotRegistered(address erc721, uint id)`                             | Function is only callable for registered erc721Id's             |
| `Treasury__StaleERC20PriceDeliveredByOracle(address erc20, address oracle)`              | Functionality is limited due to stale price delivered by oracle |
| `Treasury__StaleERC721IdPriceDeliveredByOracle(address erc721, uint id, address oracle)` | Functionality is limited due to stale price delivered by oracle |

## Treasury Token

The [Treasury Token](/kolektivo-docs/tools/framework-tokens/treasury-token.md) is a vanilla ERC-20 token backed by the Treasury's assets. It is called the Kolektivo Treasury Token (KTT), and it is an elastic / rebasing token, which means that 1 KTT is always worth 1$ worth of treasury assets. The KTT contract is inspired by the well-tested [Ampleforth](https://www.ampleforth.org/). Here are some of the token's characteristics:

* The maximum supply is one billion.
* Each rebase happens at an epoch.&#x20;
* Each time someone interacts with a token, e.g. token transfer, rebase is triggered a rebase.
* Rebase can also be called manually.&#x20;

{% embed url="<https://github.com/Kolektivo/kolektivo-monetary-contracts/blob/main/src/ElasticReceiptToken.sol>" %}

### Error Messages

| Code               | Description             |
| ------------------ | ----------------------- |
| `InvalidRecipient` | Invalid token recipient |
| `InvalidAmount`    | Invalid token amount    |
| `MaxSupplyReached` | Maximum supply reached  |

&#x20;

## Failure Modes

{% hint style="danger" %}
Please note that this experimental MVP software is provided on an "as is" and "as available" basis. As this module is an first attempt, be aware that different failures may occur. We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.
{% endhint %}


---

# 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://kolektivo.gitbook.io/kolektivo-docs/advanced/smart-contracts/monetary-system/treasury.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.
