The Principle of Maze
For users of Neko Network, when you read the contents below, please consider all MAZE as NEKO. They are identical.

The Cattery Structure

On Maze Protocol, there is an abstract structure consisting of two major pool types, Asset Catteries and Maze Catteries.
    Asset Catteries
      They store and transmit your actual assets on the money market.
      For any actual assets you supply, they mint delegation tokens.
      For any actual assets you withdraw, they recycle the corresponding delegation tokens.
    Maze Catteries
      They store your delegation tokens and take them as the calculation basis of your farming rewards.

Asset Catteries

There are three Asset Catteries designed for different purposes.

Tabby Cattery

    It is designed for supplying stablecoins and MAZE only.
    The stablecoin catteries are different sub-structures such as USDT cattery and BUSD cattery.

Siamese Cattery

    It is designed for supplying unstablecoins permitted by the protocol.
    The unstablecoin catteries are different sub-structures such as BNB cattery and ETH cattery.

Ragdoll Cattery

    It is designed for supplying MAZE-LP tokens only. In fact, it is the LP Pool of the protocol.
    When you supply MAZE-LP tokens to this cattery, an equal amount of pMAZE and lpMAZE will be issued. The lpMAZE token is a farming delegation token. They are paired, so you must repay the same amount of both tokens when you withdraw MAZE from the cattery.
    This cattery is only for LP token asset storage, not involved with the money market.
Every sub-structure in Tabby Cattery and Siamese Cattery is made of a pair of underlying asset pools.

Reserve Pool

    This type of pool is only for safe asset storage, not involved with the money market.
    The supply change in this type of pool will not affect your borrow credit at all.
    When you supply an asset, the pool will issue the same number of rtoken and rmtoken. The rtoken is the asset delegation token of your supplied crypto, and the rmtoken is the farming delegation token.
    When you withdraw an asset, the pool will recycle the same number of rtoken and rmtoken.

Funding Pool

    This type of pool is involved with the money market. It means that your supplied funds in a Funding Pool can be borrowed by users.
    The supply change in this type of pool will affect your borrow credit. It means that your supplied funds in a Funding Pool will be utilized as collaterals.
    When you supply an asset, the pool will issue the same number of ftoken and fmtoken. The rtoken is the asset delegation token of your supplied crypto, and the fmtoken is the farming delegation token.
    When you withdraw an asset, the pool will recycle the same number of ftoken and fmtoken.

Maze Catteries

Different from the other money markets, in Maze you do not earn interest based on your underlying assets. Instead, your income is generated from Maze Catteries by staking delegation tokens.
Your reward is MAZE.
Maze Catteries are series of smart contracts which store your rmtokens, fmtokens and lpMAZE, in order to calculate your rewards in each farming cycle.
Every Asset Cattery has its Maze Cattery as an underlying mining pool(MP).
    A Reserve Pool has an rMP. It stores rmtoken as your reward share in that Reserve Pool.
    A Funding Pool has an fMP. It stores fmtoken as your reward share in that Funding Pool.
    The Ragdoll Cattery has its own lpMP. It stores lpMAZE as your reward share in the LP Pool.
The rewards in Maze Catteries are generated according to cycles, not one single block.
The validity of your shares in Maze Catteries follows two rules:
    Stake: T+1 effectiveness. e.g. when you stake your rmUSDT into its rMP, in the current cycle, your share is not effected and will be in line. Your share will be effected when the next cycle is started. It must endure a complete cycle to get the reward.
    Unstake: T+0 effectiveness. e.g. when you unstake your rmUSDT out of its rMP, in the current cycle, your share is immediately expired, as it does not endure the cycle.
Your rewards of the latest cycle will be issued once a new cycle is started. You need to manually claim the rewards, or let them keep accumulating.

Stratified Harvest Regulators

Global Yield Distribution

Most MAZE are generated from mining in the long term. The mining production in each cycle will be distributed based on the following arrangement.
Ragdoll Cattery will constantly receive 5% of the global yield. The rest 95% will be allocated to the participants in Tabby Cattery and Siamese Cattery. The allocation ratio between Tabby Cattery and Siamese Cattery is determined by governance.
Learn about the parameters here.

Supplied Value Ratio Balancing (SVRB)

Supplied Value Ratio Balancing (SVRB) is designed to maintain a steady proportion of MAZE in Tabby Cattery.
The fundamental purpose of SVRB is to keep the balance of MAZE and stablecoins' value in Tabby Cattery. When the ratio of MAZE value drops to 26%, the maximum harvest ratio comes to MAZE cattery - 80% of reward goes to MAZE suppliers while 20% goes to stablecoin suppliers. This proportion will not last, as the incredible imbalance of harvest rate attracts more MAZE's deposit rather than stablecoins'. Along with the value increase in Tabby Cattery, the harvest ratio for MAZE side starts to drop. The reward ratio comes to the balance when the value proportion is close to 1:1.
Below is the SVRB curve.
Learn more about the equations here.

Simple Value Weighted Distribution (SVWD)

The value in each crypto’s cattery is the distribution share for this cattery structure.
e.g. The USDT cattery has $3m supplied, and the BUSD cattery has $2m supplied. The reward to stablecoins catteries for this cycle is 50 MAZE, then the USDT cattery gets 30 MAZE, and the BUSD cattery gets 20 MAZE.
This mechanism brings all the assets into a flat competition of their supplied value.

Funding Occupation Ratio Balancing (FORB)

Funding Occupation Ratio Balancing (FORB) is designed to encourage more asset supply in Funding when necessary.
In a Funding Pool, the proportion of occupied value decides the harvest distribution ratio between Funding Pool and Reserve Pool. When more assets are occupied, more MAZE yield will be rewarded to Funding suppliers.
It exists in every pair of Funding and Reserve.
Below is the FORB curve.
Learn more about the equations here.

A Posterior Farming System

Implementing Maze's farming system is unlike a simple task composing a MasterChef.sol. Its design has turned it into a highly dynamic revenue distribution protocol which might not be possible to land on a layer-1 blockchain easily. In one word, this is due to the posterior nature of Stratified Harvest Regulators. This chapter will try to give an intuitive explanation.

The Yield Computation Process

Maze is a sensitive ratio-oriented farming system whose status changes in each cycle. Every change of asset prices or supplied amount will affect the yield distribution condition across the entire protocol. Below is a simplified conclusion of the computation process sample to find out one farmer's income in one specific MP (e.g. MAZE-rMP) in one cycle:
    Step 1 Use the global yield distribution parameters to calculate the income to Tabby, Siamese and Ragdoll respectively.
    Step 2 Use the price feeding data to calculate the supplied values of stablecoins and MAZE in Tabby.
    Step 3 Use SVRB functions to calculate the income of MAZE suppliers based on the value results from Step 2.
    Step 4 Find out the occupation rate of MAZE in its Funding.
    Step 5 Use FORB functions to calculate the income of MAZE Reserve suppliers based on the rate result from Step 4.
    Step 6 Find out the farming share of the farmer in MAZE-rMP and then calculate the income of the farmer based on it.
That is the income the farmer makes in THAT ONE circle in that MP. Please do note that all MPs are correlated, so they will affect each other. As you can see, a farmer's unclaimed income is the MAZE reward accrued from passed cycles, but the income for every cycle is different. Stratified Harvest Regulators will keep us from anticipating income or re-validating income if there is not sufficient information.
To learn more about the computation process, see here.

The Paradox

The common way of implementing a farming contract is to validate the revenue when the farmer calls a claim function. The contract will calculate the balance based on the information of the latest block height. However, this solution does not work in Maze's design, because in our case, you apparently should not use the latest ledger status to finalize the income value for all the passed cycles.
The tables below intuitively show the reason:
As we move from one cycle to the next, the parameters will change due to price or amount fluctuation, and thus the reward to each MP is altered. With the latest status, the contract can precisely calculate the income for one cycle, but it will need to keep the data in the memory in order to accumulate the reward for further cycles. If there are a large number of users farming in multiple MPs, the memory will cache a huge balance sheet which is unpractical. Otherwise, the contract must store the income record to the blockchain ledger after each cycle, costing much gas and performance spending in the longterm.
Assuming there are 1,000 users each farming in 10 MPs, generating 10,000 income record tasks in one cycle (10 minutes for Maze), which will be 43,200,000 operations in a month.
So we have a paradox here:
    If the contract only uses the final status of the block height where the user calls the claim, the reward value will be completely incorrect.
    If the contract caches the income value of each cycle in the memory, the network will eventually break.
    If the contract updates the income value of each cycle to the blockchain ledger, the transaction will cause great gas cost and performance waste.
    If we host a back-end service to compute the reward balance and assign a smart contract to execute users' harvest request based on off-chain records, the system will lose its transparency.
To crack the paradox, the team of Maze has developed an innovative technology named Farmbase.

The New Middleware Concept: Farming Computation Service

Farmbase can be concluded into a simple idea: it is a middleware protocol which reads the farm status from a targetchain periodically, and then computes to keep updating a reward balance ledger for the users to accordingly harvest on their targetchain. The users have no awareness on the existence of Farmbase.
This middleware is a new type of blockchain-based system that every project founder can deploy to separate the farming computation missions apart from the business blockchain. It works like the structure below:
Item
Description
Farmbase Thread
A Farmbase blockchain which dedicates to
one farming business
Targetchain
A blockchain where the underlying business lands
RawData Cache
Collects and cleans the data from a targetchain
for the computation mission
Computation Contract
A set of smart contracts which compute reward
distribution based on transparent functions
Shadow Controller
Receives reward distribution updates and accordingly
mints stoken to farmer mapping contracts
Farmer Mapping Contract
Stores stoken as a farmer delegation account
from a targetchain
Targetchain Controller
Acquires the latest reward balance data from
Farmbase to execute a farmer's harvest request
stoken
Shadow token, a mirrored token on Farmbase to
represent the reward asset on targetchain
In the case of Maze, the farm data is collected from Ethereum and Binance Smart Chain ledge every 10 minutes. Then, the oracle feeds prices to form data for the computation contracts to deal with. The functions of Stratified Harvest Regulators are completely public in the contract codes, as well as the computing progress. The Shadow Controller receives the newest reward balance for all farmers and mints sMAZE to their delegation contracts. The procedure above keeps working as a loop according to the cycle.
Finally, once a user on Ethereum or Binance Smart Chain requests a harvest operation, the controller will read the sMAZE balance on Farmbase to permit a claim. The claimed amount as a transaction on Ethereum or Binance Smart Chain will be read by the cache too, and thus causes an sMAZE burn on Farmbase to reduce balance.

The Advantages

The invention of Farmbase can bring outstanding advantages to Maze.
    The decentralized nature of the protocol is preserved.
    All income balance records are now accurate.
    We have reduced performance pressure over Ethereum and Binance Smart Chain.
    There is no need to pay extra gas for updating yield balance or distributing rewards.
    The farming mechanisms are easy to maintain or expand on Farmbase.
    A detailed yield history for each farmer can be generated out of Farmbase ledger.
In fact, we do believe that Farmbase will be the key to Next-Gen DeFi as it is the necessary infrastructure for complicated, cross-chained, privacy-protected farming mechanisms. This leads to the independent project, Farmbase Protocol, which should not be discussed here. All you need to know is that, now we have a way to build Maze.
For more details, please read Maze whitepaper.
Last modified 3mo ago