-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add spec files and small nits
- Loading branch information
1 parent
0e0bfc5
commit 8d340d2
Showing
24 changed files
with
552 additions
and
85 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
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
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
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
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
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
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
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
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
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
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
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
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,39 @@ | ||
<!-- | ||
order: 1 | ||
--> | ||
|
||
# Concepts | ||
|
||
For policy reasons not everybody can or is allowed to receive, hold and | ||
control other tokens. Therefore, users need to opt-in for multi-coin rewards. | ||
Because users could miss the opt-in, there is a grace-period in which multi-coin | ||
rewards can still be retrieved after a claim. If a user does not enable | ||
multi-coin rewards and does not enable it within the grace-period after a claim, | ||
the multi-coin rewards get re-distributed to the existing pools according to | ||
a distribution policy which can be modified by an admin-address which is set | ||
by the governance. | ||
|
||
## (Re-)distribution policy | ||
|
||
The redistribution policy defines which multi-coin denom gets re-distributed | ||
to which pool depending on a certain weight. To allow quick updates an | ||
admin address (other than the governance) can be specified which can update | ||
the policy. The address can not drain any rewards, but only modify to which | ||
pools the coins get re-distributed to. Therefore, the governance might | ||
set the admin address to a trusted (multi-sig) address. | ||
|
||
## Token Flow | ||
Within the withdraw-rewards function inside the CosmosSDK distribution module | ||
the multi-coin-rewards module is called. | ||
1. User has opted in: All tokens are directly paid out to the user | ||
2. User has not opted in: Only the native token is paid out, the other tokens are | ||
transferred to the `multi_coin_rewards` module account. A queue entry is | ||
created and a user has a certain amount of time to enable multi-coin-rewards. | ||
certain amount of time to enable | ||
1. User enables rewards within time: All pending rewards are transferred to the user | ||
2. User does not enable rewards within time: The rewards are transferred to | ||
the `multi_coin_rewards_distribution` module account. | ||
|
||
Every 50 blocks all coins in `multi_coin_rewards_distribution` are | ||
redistributed according to the distribution policy. If tokens are not | ||
covered by the policy they remain inside the module account. |
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,47 @@ | ||
<!-- | ||
order: 2 | ||
--> | ||
|
||
# State | ||
|
||
The module is mainly responsible for holding the policy itself and keeping | ||
track of who has opted in for multi-coin rewards. | ||
|
||
## MultiCoinRewardsEnabled | ||
|
||
The users who have opted in for multi-coin rewards are stored as a key in | ||
the IAVL tree. There is no value associated with it. If the key exists, | ||
the users has opted in. | ||
|
||
- MultiCoinRewardsEnabled: `0x01 | AccAddress -> {}` | ||
|
||
## MultiCoinDistributionPolicy | ||
|
||
The MultiCoinDistributionPolicy stores for every denom a list of pools and | ||
weights. The weights determine on how the rewards of a given denom are | ||
re-distributed under the pools. | ||
|
||
```protobuf | ||
syntax = "proto3"; | ||
// MultiCoinDistributionPolicy ... | ||
message MultiCoinDistributionPolicy { | ||
repeated MultiCoinDistributionDenomEntry entries = 1; | ||
} | ||
// MultiCoinDistributionDenomEntry ... | ||
message MultiCoinDistributionDenomEntry { | ||
string denom = 1; | ||
repeated MultiCoinDistributionPoolWeightEntry pool_weights = 2; | ||
} | ||
// MultiCoinDistributionPoolWeightEntry ... | ||
message MultiCoinDistributionPoolWeightEntry { | ||
uint64 pool_id = 1; | ||
string weight = 2 [ | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
``` |
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,16 @@ | ||
<!-- | ||
order: 4 | ||
--> | ||
|
||
# Messages | ||
|
||
## ToggleMultiCoinRewards | ||
|
||
User can enable or disable the retrieval of multi-coin-rewards. If they | ||
enable multi-coin rewards all current pending rewards will be claimed. | ||
|
||
## SetMultiCoinRewardDistributionPolicy | ||
|
||
Sets the multi coin rewards distribution policy. This can only be done by | ||
the admin address. This can either be the address of the governance itself | ||
or a trusted entity. |
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,9 @@ | ||
<!-- | ||
order: 4 | ||
--> | ||
|
||
# BeginBlock | ||
|
||
Every 50 blocks all coins in the `multi_coin_rewards_distribution` module account | ||
are re-distributed according to the current policy. If a coin is not covered | ||
by the policy, it remains in the account. |
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,12 @@ | ||
<!-- | ||
order: 5 | ||
--> | ||
|
||
# Parameters | ||
|
||
The multi-coin-rewards module contains the following parameters: | ||
|
||
| Key | Type | Example | | ||
|----------------------------------------------|--------|---------------------------------------------| | ||
| multi_coin_distribution_policy_admin_address | string | kyve10d07y265gmmuvt4z0w9aw880jnsr700jdv7nah | | ||
| multi_coin_distribution_pending_time | uint64 | 1,209,600 | |
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,31 @@ | ||
<!-- | ||
order: 6 | ||
--> | ||
|
||
# Events | ||
|
||
The multi-coin-rewards module contains the following events: | ||
|
||
## EventToggleMultiCoinRewards | ||
|
||
EventToggleMultiCoinRewards indicates that someone has changed their | ||
multi-coin-settings. | ||
|
||
```protobuf | ||
syntax = "proto3"; | ||
message EventToggleMultiCoinRewards { | ||
// address ... | ||
string address = 1; | ||
// enabled ... | ||
bool enabled = 2; | ||
// pending_rewards_claimed ... | ||
string pending_rewards_claimed = 3; | ||
} | ||
``` | ||
|
||
It gets emitted by the following actions: | ||
|
||
- SetMultiCoinRewardDistributionPolicy |
Oops, something went wrong.