This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propose KIP-159 (update of treasury fund rebalancing)
- Loading branch information
1 parent
feed532
commit 5090c6d
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
kip: 159 | ||
title: An Update of Treasury Fund Rebalancing | ||
requires: 103 | ||
--- | ||
|
||
## Simple Summary | ||
An update of treasury fund rebalancing. | ||
|
||
## Abstract | ||
The treasury fund rebalancing is updated, resulting in updates to the treasury rebalance contract v2 and the related core logic. | ||
|
||
## Motivation | ||
According to kip103, the treasury rebalancing refers to the act of burning existing fund balances and minting new funds. This event happens at a reserved time, such as a hard fork block number. Through the TreasuryRebalance contract, the disclosure of the treasury fund activities can be conducted transparently and verifiably. | ||
|
||
But in kip103, the rebalancing only considers the case when the total balance of funds decreases. This proposal expands to the general cases so that we don't have to consider whether the final result is burn or mint. The other improvement is about making rebalanceBlocknumber in the RebalanceContract editable. The rebalanceBlocknumber should be matched with the related hardfork block number. However, it is not updatable even hard fork block number can be updated. | ||
|
||
Other minor improvements would be the changing of the variable names indicating previous/new fund addresses. Currently, it is using ambiguous naming such as Retired,Newbie. To improve the readability, this proposal changes the names to Zeroed and Recipients, so it can clarify the meaning of the burn and mint. Additionally, this proposal updates the core logic not to increase the nonce of 0x0 address unintentionally. | ||
|
||
## Specification | ||
### To update names of previous/new fund addresses | ||
In kip103, the previous/new fund addresses are named as Retired,Newbie. It’s ambiguous enough to degrade the readability and the names don’t make it clear that the previous fund balance became zeroed and the new fund balance is newly minted by blockchain core. For those reasons, this proposal changes the names from `Retired`, `Newbie` to `Zeroed`, `Recipient`. | ||
|
||
| | Previous Fund | New Fund | | ||
|---|---|---| | ||
| Kip103 | Retired,Retiree | Newbie,Newbies | | ||
| This proposal | Zeroed,Zeroeds | Recipient,Recipients | | ||
|
||
### To consider both total burn/total mint cases | ||
In kip103, the rebalancing only considers the total burn case where the total balance decreases. To make it generalized, this proposal removes the condition that the total balance of `Zeroeds` should be more than the total minting amount of `Recipients`. As a result, the checking code is removed from the contract and core code. | ||
|
||
In the `TreasuryRebalanceV2` contract, the finalizeApproval has been revised like below. Originally, this require statement, `require(getTreasuryAmount() < sumOfZeroedBalance())`, was there. However, it is removed to support all the cases. | ||
|
||
```solidity | ||
/** | ||
* @dev finalizeApproval sets the status to Approved, | ||
* After this stage, approvals will be restricted. | ||
*/ | ||
function finalizeApproval() | ||
public | ||
onlyOwner | ||
onlyAtStatus(Status.Registered) | ||
{ | ||
checkZeroedsApproved(); | ||
status = Status.Approved; | ||
emit StatusChanged(status); | ||
} | ||
``` | ||
|
||
The next validation has been removed from the core logic also. It ensured the total balance of `Zeroeds` is bigger than the total balance of `Recipients`, but it is removed to support all the cases. | ||
* totalRetiredAmount >= totalNewbieAmount | ||
|
||
### To make RebalanceBlocknumber defined in TreasuryRebalance contract editable | ||
In the treasury rebalance contract, there's a `RebalanceBlocknumber` storage and it should be matched with the related hard fork block number. However, even though the hard fork block number is updatable, the RebalanceBlocknumber field cannot be edited. To ensure the same behavior with the hard fork block number, the field become editable in this proposal. | ||
|
||
The next method is added to the TreasuryRebalanceV2 contract. | ||
```solidity | ||
/** | ||
* @dev updates rebalance block number | ||
* @param _rebalanceBlockNumber is the updated target block number of the execution the rebalance in Core | ||
*/ | ||
function updateRebalanceBlocknumber( | ||
uint256 _rebalanceBlockNumber | ||
) public onlyOwner { | ||
require( | ||
block.number < rebalanceBlockNumber && | ||
rebalanceBlockNumber < _rebalanceBlockNumber | ||
); | ||
rebalanceBlockNumber = _rebalanceBlockNumber; | ||
} | ||
``` | ||
|
||
### To protect nonce increment of the 0x0000000000000000000000000000000000000000 address | ||
While processing the treasury rebalance core logic, the nonce of a contract was unintentionally increased. It is fixed not to increase the nonce of the zero address. | ||
|
||
## Test cases | ||
TBD | ||
|
||
## Reference | ||
TBD |