Opportunity Market Life Cycle

How an Opportunity Market progresses through different stages in its life-cycle.

Creating the Market

The decision maker creates and configures the market account by calling the create_market instruction.

The creator can configure which token is used for staking and rewards and how long the staking period lasts.

Adding initial Options

Options can be added at this stage by the creator with the instruction add_market_option

Funding the Reward Pool

Anyone can fund the market via the instruction add_reward. Rewards can be either locked in permanently or made withdrawable later. Withdrawable rewards are only withdrawable before the staking period ends via withdraw_reward.

Opening the Opportunity Market for Staking

The market creator opens the market to staking by calling the open_market instruction.

Staking

Once the market is open, users can stake on options. The market is open for a certain period of time, the length of which is configured upon market creation. During this time, more options can still be added.

Staking is done with the stake instruction. This requires the user to transfer at least the minimum stake amount to the Token Vault account. The user encrypts their option choice, which is then stored in their StakeAccount.

The user can claim back their stake amount with a delay by calling the unstake_early instruction (the delay can be set to zero, we have this mechanism just to allow flexibility for future design). After the delay has passed that, the stake can be claimed via do_unstake_early. The latter instruction is permissionless, and can be moved to a "cranker" process to improve UX. Users are incentivized to keep their stake in the market as long as possible. More about that in later section Distributing the Reward.

Selecting the Winning Options

The market creator can choose up to 10 winning options and choose how the reward pool is split between them. This is done via the select_winning_option instruction. If the market is configured to allow closing early, this instruction can be called while the staking is still active, ending the staking period immediately.

Unstaking

Now that the winning options have been selected, users can withdraw their stake with no penalty via reclaim_stake.

Distributing the Reward

Once the winning options have been selected, those who staked on them are entitled to a slice of the reward pool.

Before the reward can be claimed however, the option choice of the eligible users must be revealed. Revealing must be done for each eligible StakeAccount via the instruction reveal_stake. After that, the total option stake tally must be incremented via increment_option_tally. This increments the user's stake amount in the OpportunityMarketOptionAccount, the total sum of which is used for reward calculation. Both of these operations are permissionless, and can be done by a background "cranker" process.

After all the winning stakes have been revealed and the tallies incremented, eligible users can claim their rewards via the close_stake_account instruction.

We use a score system for determining how much of the total reward goes to each eligible StakeAccount. The score takes three things into account:

  1. Stake amount: how much the user staked.

  2. Time in market: how long the stake was active relative to the total market duration. Unstaking early lowers your score.

  3. Earliness: staking sooner after the market opens gives a bonus by a configurable max multiplier. This bonus decays over time linearly and eventually disappears (also configurable what point in time this is).

A user's reward is then their share of the total score for that winning option, multiplied by the portion of the reward pool assigned to that option by the market creator.

Last updated