Skip to content

Mechanics

Gregory Magarshak edited this page Jan 23, 2022 · 2 revisions

I think algorithm is like this

Pool receives deposits of LP from staker, adds weekly minimums buckets for unstake() later

When stake started, pool tells factory to mint walletTokens to staker

Pool has mappings:

address => Minimums[]
address => balance
address => unstakeable

And scalar variables:
totalRedeemable
totalUnstakeable
(Actually, totalUnstakeable + totalRedeemable = totalStaked)

When start new stake:
unstakeable[address] += amount
totalUnstakeable += amount

When transfer T from address:

Require balance >= T
if (balance – T < unstakeable) {
r = unstakeable – (balance – T);
unstakeable -= r;
totalUnstakeable -= r;
totalRedeemable += r;
}
balance -= T;

Recipient just has balance of wallet tokens increased. That’s it !

When redeem:

A = totalRedeemable across all pools
B = totalSupply – A – totalUnstakeable
C = A / (A + B * discount)

The discount is a fraction between 0 and 1 (in logical space), it determines by how much minting from factory will reduce price of tokens. If it is 1, then all tokens can always be redeemed. But if it is less than 1, then someone redeeming may have to wait until totalRedeemable increass (because all redeemable LP tokens have been taken) and in the meantime the walletTokens will have to recirculate.

When unstaking

For unstake, just look at unstakeable[balance], and revert if too low. Otherwise check if minimums violated.

Only can unstake in same pool where staked.

Note: discount doesn’t apply to unstake, it is always original ratio (ie 1-1). Thus, assuming minimums have been cleared, there are always enough LP tokens to unstake for unstakeable wallet tokens because only redeemable tokens can be redeemed for LP by others!

The overall idea is that people are “investing into” an ecosystem and getting utility tokens which they hope to use in the next few years, or have to sell to someone else. The factory may give promotions, here are some examples:

1. if you stake large amount, or stake for a long time, you get bonus walletTokens

2. if you promote the community services, or bring more buyers, community will mint you free utility tokens, but add a minimum on you, so you can’t withdraw them for a year

Often the stakers are community organizations prebuying large amount of utility tokens, and over the years, utility tokens may be deducted from stakers eg for time based subscriptions per month, and also for their own community members using some services in ecosystem. So they might prebuy many months x members x services in advance, and still it can be a huge legitimate purchase for UTILITY.

The unused tokens can eventually be unstaked, and possibly be given some external rewards by some contract, for participating.

Clone this wiki locally