Mars Protocol Code Review Breakdown — Session #5, Staking Incentives Module
In the last two code review sessions, Mars contributor @larry0x went over the Safety Fund and Governance modules for the Mars Hub app-chain, focusing on the CosmosSDK side of development. In this session, @larry0x covers the Staking Incentives module, the third and final custom module for the initial deployment of Mars Hub.
This article will serve as a brief introduction to the Staking Incentives module. For a more detailed analysis of the code, check out the recording:
Introduction to the Staking Incentives Module
There are two types of incentives that Mars deals with: incentives for MARS stakers and incentives for lending/borrowing activities. The Incentive module exclusively manages incentivization for MARS stakers. Incentives for lending/borrowing activities are managed by a wasm contract deployed at each Outpost and are not covered in this session.
So what’s the reasoning behind the incentives module or incentives for MARS stakers?
Mars Hub is opting out of interchain security in favor of having its own infrastructure and network of validators. While there are many long-term advantages to this, there are some short-term issues to consider. For example, it is expected that as the MARS token is launched, especially in what could be a “bear market”, the token will initially have a low market cap. Furthermore, the network could have a low percentage of stakers.
As a result, network security may be weak at certain times, especially during the initial launch. In order to incentivize users to stake MARS tokens and secure the network, a percentage of MARS from the community pool will slowly be released as staking rewards. This is the core function of the incentives module.
The release of incentives is defined by
Schedules. Each incentives schedule consists of three (3) parameters:
Between the timespan defined by
EndTime, coins specified by
TotalAmount will be released as staking rewards linearly, in the
BeginBlocker of each block.
BeginBlocker and (
EndBlocker) are powerful tools for developers to add automatic execution of logic to their module. These special functions execute automatically at the beginning or end of each block. In this case, staking rewards are released linearly at the beginning of each block. Each validator who has signed the previous block gets a portion of the block reward pro-rata according to their voting power.
A new schedule can be created upon a successful
CreateIncentivesScheduleProposal. The incentives module will withdraw the coins corresponding to
TotalAmount from the community pool to its module account. Conversely, an active schedule can be canceled upon a successful
TerminateIncentivesScheduleProposal. All coins yet to be distributed will be returned to the community pool.
There can be multiple schedules active at the same time, each identified by a
uint64. Each schedule can release multiple coins, not limited to the MARS token.
Finally, putting the module together is relatively simple: there are no
tx functions since most of the work is executed automatically in the
BeginBlocker, and there are only a few queries to help us return information about
If you’re ready to dive into the code, check out the recording.
The next/sixth session will shift back to CosmWasm smart contract development and cover the Lending Market contracts on Osmosis. Listen, ask questions & help spot bugs in this live video transmission. Event details:
- August 13, 2022
- 11 AM EST | 3 PM UTC
Please be advised all of the above reflects Mission Control’s current thinking, but is not guaranteed or promised. No contract is implied or duties assumed hereby. Do not make any financial decisions based on this announcement.
- Mission Control
This article does not constitute investment advice and is subject to and qualified in its entirety by the Mars disclaimers here.