First, we state definitions from the official Goo Paper followed by some insights:
- goo balance
$g(t, m, \textrm{goo}) = 0.25 t^2 m + t \sqrt{m \cdot \textrm{goo}} + \textrm{goo}$ - instantaneous goo production:
$g'(m, \textrm{goo} = g(t)) = \sqrt{m \cdot \textrm{goo}}$ - goo production
$\Delta g(t, m, \textrm{goo}) = g(t, m, \textrm{goo}) - \textrm{goo} = 0.25 t^2 m + t \sqrt{m \cdot \textrm{goo}}$ - goo auto-compounds:
$g(t_0 + t_1, m, \textrm{goo}) = g(t_1, m, g(t_0, m, \textrm{goo}))$ - optimally distributed goo among several gobblers is equal to the total goo distributed to a single gobbler with the sum of their multiples:
$g(t, M, \textrm{GOO}) = \sum_i g(t, m_i, \frac{m_i}{M} * \textrm{GOO})$ with$M = \sum_i m_i$ ,$\textrm{GOO} = \sum_i \textrm{goo}_i$
Users can deposit an arbitrary amount (including 0) of gobblers and/or goo. As the ArtGobblers
contract already balances goo optimally for individual users and because of equation (5) we can model a multi-gobbler deposit by a user as a single-gobbler deposit
Note Equation (5) is also the reason why the GooStew protocol leads to better goo production. In practice, the gobbler & goo pots of different users don't distribute the total goo optimally:
$g(t, M, \textrm{GOO}) \geq \sum_i g(t, m_i, \textrm{goo}_i)$ .
When gobblers are deposited, the protocol mints an NFT to the user which identifies the IDs of the gobblers.
When depositing goo, the protocol mints goo share tokens at a goo share price of totalGoo
at any time. The NFT can be redeemed for its gobblers and a fair share
Whenever a deposit
or redeem
happens, we first claim the new goo inflation
- the goo amount
$r_\textrm{gobbler}$ goes to all gobbler depositors - the goo amount
$r_\textrm{goo} = \Delta g(\textrm{timeElapsed}, M, \textrm{totalGoo}) - r_\textrm{gobbler}$ goes to all goo shares holders
For the protocol to be fair to gobbler depositors with regards to the compounding nature of an update step, the goo amount totalGoo
is increased by the new goo inflation ArtGobblers
to produce more goo.
Choosing correct testNoLoss
to satisfy the no-loss property.
The inflation is received as goo amounts but it needs to be distributed to two different non-comparable elements, goo and gobblers. Efficiently computing the inflation distribution in the smart contract is done by:
- inflation for goo depositors: issuing shares tokens on goo deposits which are a proportional claim on the total goo amount. The goo inflation
$r_\textrm{goo}$ can directly be attributed to the total goo amount. - inflation for gobbler depositors: The gobbler goo inflation
$r_\textrm{gobbler}$ is issued as goo shares (at the new price after attributing$r_\textrm{goo}$ to the shares holders) and we use aMasterChef
-style reward index (_gobblerSharesPerMultipleIndex
) for each staking NFT to keep track of how many shares the NFT can be redeemed for. This way we only need to "mint" the total shares amount on each update but can postpone minting each individual depositor's shares until redemption.
The full implementation is available as GooStew.sol.
- To incentivize developers building this and other projects in the ArtGobblers ecosystem, the protocol could take a performance fee on the additional goo production. Using philogy's math, we can compute the sum of individual goo balances and therefore the additional goo production in the smart contract:
$g(t, M, \textrm{GOO}) - \sum_i g(t, m_i, \textrm{goo}_i)$ .
We want to show that for a user depositing
By letting
This equation is true for all non-negative numbers
This shows that it's a no-loss for a single update step but as