Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add smooth staking hip #782

Merged
merged 7 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion HIP/hip-406.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ last-call-date-time: 2022-06-02T07:00:00Z
release: v0.27.0
created: 2022-03-27
discussions-to: https://github.com/hashgraph/hedera-improvement-proposal/discussions/408
updated: 2022-04-20, 2022-05-25, 2022-06-02, 2022-11-14, 2023-03-27
superseded-by: 782
updated: 2023-08-09
---

## Abstract
Expand Down
66 changes: 66 additions & 0 deletions HIP/hip-782.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
hip: 782
title: Smoothing Staking Rewards
author: Leemon Baird <[email protected]>
type: Standards Track
category: Core
needs-council-approval: Yes
status: Accepted
last-call-date-time: 2023-08-09T07:00:00Z"
release: v0.40.0
created: 2023-08-01
discussions-to: https://github.com/hashgraph/hedera-improvement-proposal/pull/782
replaces: 406
updated: 2023-08-09
---

Note: This hip does not replace all of hip-406 Staking. It replaces only replaces a small part. Otherwise, hip-406 still stands.

## Abstract

This HIP describes a change to the staking reward system for proof of stake described in HIP-406. HIP-406 gives rewards at a constant reward rate until the unreserved balance of account `0.0.800` is empty, then suddenly drops to a near zero reward rate. This HIP defines a change so that as `0.0.800` approaches being empty, the reward rate decreases smoothly rather than with an abrupt drop.

## Motivation

## Rationale

## User Stories

## Specification

In the original HIP, there is a setting `stakingRewardRate`, and rewards are given at that rate until the unreserved balance of account `0.0.800` is empty, at which point it abruptly drops to simply distributing each day whatever came in to that account the previous day, such as through transaction fees. And there was originally a setting for the max reward emission per day.

The change is to remove both of those settings, and have `stakingRewardRate` automatically change each day, based on the balance of `0.0.800` and three settings: `maxRewardRate`, `rewardBalanceThreshold`, and `maxStakeRewarded`. The `maxRewardRate` (in tinybars earned per hbar staked per day) is the rate to pay normally (i.e., when `0.0.800` has a large balance, and not too many hbars are staked for reward). When the balance of `0.0.800` drops below `rewardBalanceThreshold` (in tinybars), then the `stakingRewardRate` drops smoothly as the balance drops. If the hbars staked for reward exceed `maxStakeRewarded` (in tinybars), then there is a further decrease (which replaces the original absolute limit on hbars emitted per day).


Let `unreservedBalance` (in tinybars) be the balance of account `0.0.800` minus the amount of rewards that have been earned but not yet distributed. Let `stakedForReward` (in tinybars) be the total number of hbars on Hedera that have been staked for reward (so it ignores accounts that stake but decline a reward). Then each day, just before the HIP-406 reward calculations are performed using `stakingRewardRate`, recalculate `stakingRewardRate` as follows (implemented with equivalent results, but using integer calculations, rather than the real-number calculations shown):

```
//A real number proportional to the unreserved balance, from 0 for empty, up to 1 at the threshold.
balanceRatio = min(unreservedBalance, rewardBalanceThreshold) / rewardBalanceThreshold;

stakingRewardRate = maxRewardRate
* balanceRatio * (2 – balanceRatio)
* min(1, maxStakeRewarded / stakedForReward)

```

## Backwards Compatibility

This has no effect on HAPI or on transactions. It just affects the amount of daily staking rewards received by accounts that stake for reward, when `0.0.800` has a low balance.

## Security Implications

None.

## How to Teach This

## Reference Implementation

## Rejected Ideas

## Open Issues / FAQ

## Copyright/license

This document is licensed under the Apache License, Version 2.0 -- see [LICENSE](../LICENSE) or (https://www.apache.org/licenses/LICENSE-2.0)
Loading