CO-PIP-5: Upgrade Staking Program in Mainnet to add Staking for data integrity
Abstract
In response to the proposal and the design by CMS of a community integrity staking program that aims at making the Pyth Network the most robust and secure oracle network to its DeFi users, Douro Labs has now completed the implementation of the staking program and proposes its deployment to mainnet. The new staking program for oracle integrity is independent of the current staking program for Governance, enabling Pyth DAO members to stake in both programs.
The audited implementation is inline with the original design proposed. The proposed deployment includes a number of parameters that are suggested given simulations that Douro Labs team has performed and that anyone in the community can replicate.
The success of the new staking program is dependent on a reward pool being funded and adoption by the Pyth community.
Rationale
- Staking for the integrity of data and its accuracy bolsters protections for quality data production for consumers
- Douro Labs has been the biggest code contributor to the Pyth Network to date. We deeply care about making DeFi safer for everyone through the Pyth Network
- This staking program will establish the Pyth Network as the first secured oracle for its users
Description
The implementation of the staking program follows the original design proposed by the community.
1. Design Principles
The program’s economic design is focused on encouraging data accuracy. The implementation assumes an open-ended reward pool that distributes rewards for helping to secure the quality of the data produced, and slashes stake to penalise failure to maintain data accuracy.
As a recap, the core design principles behind the program proposed include the following:
- All current and future price feeds produced currently by the Pyth Network are secured by Integrity Staking
- Data publishers and stakers facilitate data accuracy
- Rewards and penalties are proportionate to the stake assigned to each publisher
- A higher number of publishers for each price feed contributes positively to the security of such feed
- Staking for integrity is complementary to staking for governance and such eligible PYTH tokens can be used for both purposes
- The ability to slash stake requires unlocked PYTH tokens, whereas staking for governance can use both locked and unlocked PYTH tokens
- All parameters related to the protocol are subject to the governance of the Pyth DAO
- Slashing rules and procedures are also subject to the governance of the Pyth DAO. Their implementation is delegated to the Pythian Council
2. Proposed Implementation
The proposed implementation follows the structure described below:
- The same 7-day epoch for governance voting applies to staking for oracle integrity. All parameters used in the protocol are captured at each start of the epoch on Thursdays 0:00 UTC and remain constant until the end of the epoch. Staking is subject to warmup and cooldown period prior and post epoch respectively
- Each publisher is programmatically assigned a staking pool where they can self-stake and to which other stakers can delegate
- The staking pool assigned to each publisher covers all price feeds that the publisher contributes data to
- Each staking pool has at a soft cap. Such cap dynamically expand and shrink given number of symbols published by the assigned publisher
- Adding coverage for a price feed with a low number of publishers contribute more to the cap’s expansion
- Staking into the pool can exceed the soft cap, however no rewards are distributed for the excess stake
- Self-stake attributed to a publisher is prioritised when rewards are distributed to the publisher’s pool
- All staking pools charge the same delegation fee for stakers who are delegating stake to one or many pools
- The rate of rewards paid each epoch to each pool, exclusive of any excessive stake, has a hard cap
- The total amount of rewards paid to all pools is bound by the same cap relative to the amount of rewards available to the protocol
- Slashing of stake has a maximum rate and only impacts pools that assigned to publishers responsible for the poor data quality. Both self-stakers and delegators are also slashed proportionally to their staked amount in the impacted pools
3. Mathematical Representation
- Let
Publishers
be the set of data publishers in the Pyth Network - Let
P
be the number of data publishers in the Pyth Network, equal to the number of publisher pools in the system, orP = |Publishers|
- Let
$S_p$
be the stake assigned to the pool assigned to publisherp
, made of self-staked amount$S^{p}_{p}$
and delegated stake$S^{d}_{p}$
, or$S_{p} = S^{p}_{p} + S^{d}_{p}$
- Let
$C_p$
be the stake cap for the pool assigned to publisherp
- Let
$R_{p}$
be the reward paid to the pool assigned to publisherp
, while$R^{d}_{p}$
is the reward allocated to delegated stake, or$R^{d}_{p} = R_{p} - R^{p}_{p}$
- Let
$SL_p$
be the amount slashed from the pool assigned to publisherp
- Let
y
be the yearly cap to the rate of rewards for any pool - Let
w
be the cap to the slashing percentage from any pool - Let
Symbols_p
be the set of price feeds produced by the Pyth Network wherep
is a publisher (each of them identified by symbols
) - Let
$n_s$
be the number of publishers for symbols
- Let
f
be the delegation fee charged to delegated stake, as a percentage of the pool’s rewards from delegation, making the delegation fee amount equal to$f \cdot R^d_p$
- Let
$\Pi^p_p$
and$\Pi^d_p$
be the rewards net of slashing distributed by the pool to the publisher and its delegators respectively
The stake cap $C_p$
for each pool explained in 2.2.b is represented by the following:
C_p = M \cdot \sum_{s \in \text{Symbols\_p}} \frac{1}{\max(n_s, Z)}
where
M
is a constant parameter representing the target stake per symbolZ
is a constant parameter to control cap contribution from symbols with a low number of publishers
The reward $R_p$
paid to each pool in 2.2.c follows the formula below:
R_p = y \cdot \min(S_p, C_p)
while the total amount of such rewards is bounded per 2.2.d:
\sum_{p \in \text{Publishers}} R_p \leq y \cdot \min(NumSymbols \cdot M, \sum_{p=1}^{P} S_p)
The reward component relative the amount self-staked by the publisher p
is:
R^{p}_{p} = y \cdot \min(S^p_p, C_p) = R_p - R^d_p
The slashed amount $SL_p$
from each pool in 2.2.e follows the formula below
SL_p = w \cdot S_p = w \cdot (S^{p}_{p} + S^{d}_{p})
and is uniformly allocated to both the self-staking publisher and delegators in the pool, pro-rata to their respective stake.
Subsequently, the rewards received by a publisher and delegators into a pool, net of any slashed amounts can be expressed as below
\Pi^p_p = ( R^p_p + f \cdot R^d_p ) - w \cdot S^p_p
\Pi^d_p = R^d_p - ( f \cdot R^d_p + w \cdot S^d_p )
4. Suggested Parameters and Simulation Results
Douro Labs suggests that the Pyth DAO sets the program parameters to the following:
M = 1800000
as the target stake per symbolZ = 10
as the parameter to control cap contribution from symbols with a low number of publishersy = 1000bps
as the yearly cap to the rate of rewards for any pool, or 19.24bps for each epochf = 2000bps
as the delegation fee charged by the pool for delegated stakew = 500bps
as the maximum slashing percentage from any pool
Given the program parameters above and assuming
- a total reward pool of 100M tokens,
- a 100% growth in the number symbols supported by the Pyth Network,
- a 30% growth in the number of publishers on the Network,
- a normal distribution of amounts staked per pool ranging from 500k to 30M tokens, and
- no slashing event
the P95 rate of return for one year relative to the total amount staked is simulated as shown in the figure below:
If we assume the reward pool is halved at 50M, the results change as below:
Implementation Plan
- DAO constitution changes to add Staking for data integrity: link
- Security Audit report: link
- Technical deployment:
- Deploy integrity pool program (pyti8TM4zRVBjmarcgAPmTNNAXYKJv7WVHrkrm6woLN) to Solana mainnet
- Deploy publisher caps program (pytcD8uUjPxSLMsNqoVnm9dXQw9tKJJf3CQnGwa8oL7) to Solana mainnet
- Configure integrity pool program with the initial parameters (BE8Xq1iHSQYKG8CZorZsrTnxyeHKQLzCWm4dYKdFkVEL)
- y: 19.24 bps (per epoch)
- Pyth Token Mint: HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3
- Slash Custody: AYBdhJU8Wao48SEDyKVRXgDRbo9SU8Thnytakof4HDDH , this is a DAO wallet.
- Configure pool data (poo1zPoi5xrNzi4yk4i23oWcJrNNkDYAniBCewJY8kb)
- Delegation fee: 2000bps
- Deploy stake caps parameters program (ujSFv8q8woXW5PUnby52PQyxYGUudxkrvgN6A631Qmm) to Pythnet
- Configure stake caps parameters
- M: 1,800,000,000,000 (1.8M with 6 decimals)
- Z: 10
- Transfer all authorities to the DAO
- program upgrade authority:
- integrity pool program to the DAO
- publisher caps program to the DAO
- stake caps parameters program to the Pythian council
- configuration authorities
- stake caps parameters authority to the Pythian council
- program upgrade authority:
- Upgrade staking contract
- Enable integrity pool staking by updating the pool authority
Proposal ID - 7WRmpgAno6hYFeGkmub5N6XkhneAsfsAhycMoFMXgpNZ