# Welcome

Welcome to the COFI Money Documentation!

Here you will find details of COFI Money's core components and operations. We will soon be adding User Guides and technical documentation to integrate COFI Money into your application.

If you have any queries, please feel free to reach out to me at <sam@stoa.money>.


# Introduction

“If you don't find a way to make money while you sleep, you will work until you die.” - Warren Buffet

Much of the money we use today, whether that be fiat or digital assets, sits idly in our accounts and diminishes in purchasing power due to inflationary forces. This is driven from both ends: adverse economic factors and lack of a clear, low maintenance, and scalable solution that spurs network effects.

COFI Money is on a mission to transform idle assets into fully composable, yield-bearing tokens, that actively work for you and accrue rewards. COFI Money provides a seamless, transparent, secure, compliant and non-custodial solution.


# COFI Stablecoins

"Featureful stablecoins that inherit the liquidity of their backing assets and increase in your wallet automagically".

As of launch, COFI Money offers three varieties of stablecoins:

<div><figure><img src="/files/929A3qiFUi0gWwyv9Cy2" alt=""><figcaption><p>COFI Bitcoin</p></figcaption></figure> <figure><img src="/files/yyX6RMt88Ev7KpmTTy9J" alt=""><figcaption><p>COFI Dollar</p></figcaption></figure> <figure><img src="/files/rmDVMnGPtq3L5v4fYiOD" alt=""><figcaption><p>COFI Ethereum</p></figcaption></figure></div>

| COFI Money Stablecoin | Description                                                                      |
| --------------------- | -------------------------------------------------------------------------------- |
| COFI Dollar (COFI)    | A yield-bearing stablecoin that accrues COFI Points and is backed 1:1 with USDC. |
| COFI Ethereum (ETHFI) | A yield-bearing stablecoin that accrues COFI Points and is backed 1:1 with wETH. |
| COFI Bitcoin (BTCFI)  | A yield-bearing stablecoin that accrues COFI Points and is backed 1:1 with wBTC. |

When a user obtains COFI Money Stablecoins, their balance increases every hour automagically. Backing assets are deployed in one of our partner venues, that are continuously monitored to optimise for the highest low-risk yields.

<figure><img src="/files/M47KJU9rwSQf7fcg1vzL" alt=""><figcaption><p>COFI Money Yield Engine</p></figcaption></figure>

Sit back and pour yourself a COFI whilst our Yield Engine does the hard work for you ☕️.

COFI Stablecoins residing in Non-Rebasing Accounts, such as Liquidity Pools and our fee collector contract, does not accrue the yield. As such, this yield is redistributed to COFI sitting in User-owned accounts. This means that, your interest earnings are yielded from a greater amount of backing assets than your COFI holdings.

<figure><img src="/files/dLU8KUDNvJbk7HOoLKfA" alt=""><figcaption></figcaption></figure>


# COFI Points

"Earn yield, get Points!"

In addition to yield, Users earn Points for simply holding COFI Money Stablecoins, as well as other incentives such as referrals. In the near future, Users will be able to spend their Points to receive discounts at selected stores.

<figure><img src="/files/m7dji455HsYd1b32u7u7" alt=""><figcaption><p>Meet Chuck the COFI Cup</p></figcaption></figure>

As of launch, Users earn 100 COFI Points for every 1 COFI ($1) of yield they earn. Users also earn 10 COFI Points for each successful referral.

COFI Points are currently non-transferrable, but have an ERC20 representation so they can be tracked in your wallet in real-time.


# COFI Payments

"Partner with us and provide your Users with discounts".

A not-so-secret benefit of crypto-assets and blockchain networks is their ability to revolutionise the payments space. Merchants have long been plagued with exorbitant acquirer and interchange fees that eat into their margins.

As part of the next iteration of our Roadmap, COFI Money will provide a seamless payments solution that benefits Users and Merchants alike. By signing up, Merchants enable their Users to purchase products using their COFI stablecoins and Points. Any Points spent by the User will be received, in COFI or the underlying asset (e.g., USDC) by the merchant in the equivalent number of said assets.

For example, Alice purchases a $3.50 cappuccino by spending 3 COFI and using 500 of her COFI Points. The Merchant can choose whether to receive this payment in COFI or USDC, which is settled near-instantly due to Arbitrum's impressive sporting of 40,000 TPS.

Therefore, not only can Merchants evade fees of the past, but incorporate incentives to bring Users to their store or platform.

If you represent a Merchant, big or small, please reach out to us at <mike@stoa.money> to arrange a call. ☕️


# Contracts

Where the magic happens 🧠

Please find each of our user-facing contracts listed below.

| Contract Name            | Contract Address                                                                                                                     |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| COFI Money Diamond Proxy | [0x3c9F3b896EC6cC7AF79f5d1E127FD1e84940da4e](https://louper.dev/diamond/0x3c9F3b896EC6cC7AF79f5d1E127FD1e84940da4e?network=optimism) |
| COFI Dollar (coUSD)      | [0x8924ad39beEB4f8B778A1CcA6CB7CE89788eA895](https://optimistic.etherscan.io/token/0x8924ad39beeb4f8b778a1cca6cb7ce89788ea895)       |
| COFI Ethereum (coETH)    | [0xd371a070E505e3d553B8382A7874D177A1EE23A3](https://optimistic.etherscan.io/token/0xd371a070E505e3d553B8382A7874D177A1EE23A3)       |
| COFI Bitcoin (coBTC)     | [0x0395F6F10C8594Cef335E4DfB898bE37F766cBf2](https://optimistic.etherscan.io/token/0x0395F6F10C8594Cef335E4DfB898bE37F766cBf2)       |


# System Architecture

"One smart contract to rule them all... introducing the Diamond Proxy standard💎 👀"

The COFI Money protocol has been developed with a highly modular, upgradeable, and scalable architecture in mind. As such, our smart contracts have been designed in accordance with the EIP-2535 Diamond Standard. This standardisation makes integrations with other tools and software possible, and enables highly granular upgradeability without having to redeploy contracts.

<figure><img src="/files/XrKnZAXwwZJF7lDXLMyB" alt=""><figcaption><p>Smart Contract Architecture</p></figcaption></figure>

The motivations behind opting for the Diamond standard are described as follows:

* **A single address for unlimited contract functionality.** Using a single address makes deployment, testing and integration with other smart contracts, software and user interfaces considerably easier.
* **No maximum contract size.** Therefore no need to deploy and integrate multiple contracts, which adds unnecessary complexity.
* **Effective organisation of contract code and data.** As the Stoa system is complex and contains a lot of functionality, a Diamond pattern provides a systematic way to isolate different functions, connect them together and share data in a gas-efficient way.

## COFI Money Diamond Contract

The COFI Money Diamond is a facade smart contract that performs a `delegatecall` into its facets to execute function calls.

A fallback is a function that is triggered when a smart contract is passed a function signature outside of its immediate vicinity. `delegatecall`, a low-level assembly operation, is used to “borrow” the function from the contract residing at the designated facet address.

Every user interaction made to COFI Money (not including periphery contracts such as ERC20s) will traverse through this fallback function, and routed according to the function-to-facet mapping.

Facets are smart contracts that live on the blockchain, with their own addresses, that house external function calls for a given application, and can share internal functions, libraries and state variables.

## COFI Money Diamond Facets

The Diamond facets specifically relate to operations governing the Diamond Standard itself.

* **DiamondLoupeFacet** - A “loupe” is a tool used for inspecting (real-life) diamonds. As the source code of a Diamond does not include what functions it has (as they are held externally); tools like Etherscan cannot retrieve a Diamond’s supported functions. The DiamondLoupeFacet enables us to access the necessary information. For example, calling `facets()` returns all of the facet addresses and their function selectors.
* **DiamondCutFacet** - This houses the `diamondCut()` function, which updates any number of functions from any number of facets in a single transaction (if carried out in multiple transactions, as is the case with other proxy patterns, this increases the risk of data corruption).
* **OwnershipFacet** - This keeps track of the contract owner(s), so only authorised addresses can perform upgrades.

## COFI Money App Facets

The App facets specifically relate to operations of the Stoa Protocol. Stoa can add or remove functionality by deploying new facets and/or executing a `diamondCut()`.

* **SupplyFacet** - This houses logic relating to interfacing with yield venues and minting, burning and changing the supply of Stoa stablecoins in accordance with the amount of underlying assets held in the venue.
* **RewardsFacet** - This houses logic relating to rewards such as distributing yield earnings and spending Points.
* **PartnerFacet** - This houses custom logic required for integrating with certain partners. For example, obtaining the required USDC-LP tokens prior to depositing.
* **AccessFacet** - This houses administrator functions such as whitelisting users.


