-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Spec ecosystem incentive #225
Merged
taiki1frsh
merged 33 commits into
spec-frontend-incentive
from
spec-ecosystem-incentive
Sep 16, 2022
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
9669ca7
rename files from frontend to nftmarket in according files
1d4e673
rename from frontend_name to incentive_id, frontend_store to incentiv…
eb6ce38
readme: fix desc
a188e0f
adr: fix termlist desc
f4fb9b1
adr: revise basic system desc
accc394
adr: revise basic spec technical desc
6205210
adr: fill checklist
542ee8b
hook: add hook page and desc
9915e9e
msg: fix msgs and query contents
fe1cd92
state: change names
0bb20bc
adr: add service flow desc
32e117d
add desc in hook sections
7cdc645
revise general concept to follow name change
8dfe22c
slight fix
b075751
readme title change
7a6d9b6
rename to ecosystem-incentiven from nftmarket-incentive
15aabe0
slight fixes
b274e3b
modify concept
d181b85
add full data structure concept
a24050a
rename a file
84c62c1
add AfterNftUnlisted hook and description of it
bb83690
add Data structure of the memo field section
49626fc
some modification
596c558
fix module name
48b4b06
modify param structure
624de86
change store name
da8ffdb
change msg name
6613127
describe hook method locations and change hook method name
da1926b
fix error in the json code section
dd15d2d
modify concept
a9bf369
change arg to memo in AfterNftListed method
506cc07
separate sec of data structure of memo to an independent file
23b8c63
modify name
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,155 @@ | ||
# ADR: ecosystem-incentive Module | ||
|
||
## Status | ||
|
||
PROPOSED | ||
|
||
# Term list | ||
|
||
**NOTE: You can maybe remove this file once state page is finalized.** | ||
|
||
The definition of the specific terms which are related to this module. | ||
|
||
`incentive_id` | ||
incentive_id is the unique identifier in the `incentive_store`. Hence, it can't be duplicated. | ||
|
||
`weight` | ||
The ratio of the reward distribution in a `incentive_store` unit. | ||
`incentive_store` can contain several `subject`s and ratio for each. | ||
|
||
`reward_setting` | ||
The setting about `reward_type` and `reward_rate`. | ||
|
||
`incentive_type` | ||
The type of incentive for the subject. | ||
We first have `frontend`. | ||
|
||
`reward_rate` | ||
The rate to determine the percentage for the `ecosystem-incentive` reward out of the total trading fee. | ||
This value is connected to the `incentive_type`. | ||
e.g. | ||
`frontend` - `0.8` | ||
|
||
`denom` | ||
The token ticker like GUU, BTC etc. | ||
In UnUniFi NFT market, some tokens other than GUU (native UnUniFi token) can be used to purchase NFTs. So the rewards are accumuleted in some denoms. | ||
|
||
`reward_payer` | ||
The account to pay the reward for `ecosystem-incentive` protocol. | ||
It's the module account that collect the protocol earned fees from x/nftmarket module. | ||
|
||
# Basic specs | ||
|
||
## Incentive system | ||
|
||
- ecosystem-incentive reward comes from the fee that is made in `nftmarket` module | ||
- Those rewards have some denoms which are used in nftmarket | ||
- Those rewards are accumulated at the timing hooks are called | ||
- Those rewards are determined by the `reward_rate` of the global option of this module in `reward_setting` and the protocol earned NFT trading fee amount | ||
- Those rewards' calculation is `the trading fee * reward_rate` | ||
- Subjects register `incentive_id` and each addresses and its weights (`subject_weight_map`) to receive the reward by sending a message at first | ||
- Subjects have to put registerd `incentive_id` in a target message's memo field to accumulate the nftmarket_reward | ||
- Subjects can send a withdrawal message to actually receive the nftmarket_incentive reward | ||
- Subjects can see how much reward is accumulated for their address | ||
- The reward is distributed from the module account that accumulates the NFT trading fee | ||
|
||
## Service Flow | ||
|
||
1. Subject send a `MsgRegister` message to register `incentive_id` and addresses. | ||
1. At the `AfterNftListed` hooks function, connect that `NftIdentifier` with the `incentive_id` by passing memo filed data through an argument. | ||
1. At the `AfterNftPaid` hooks function, record the reward which the `incentive_id` earned by passing exact `fee_amount` and `fee_denom` in the argument of that hook function. | ||
1. At the `MsgWithdrawResward`, execute bank send method from the module account which accumulate fees internally. | ||
|
||
## Register | ||
|
||
1. Subjects first register the addresses, weights of the proportion of the rewards and `incentive_id` to be used to identify the subject to take rewards in `incentive_store` (e.g. ununifi1a~, 0.5, ununifi1b~, 0.5 registering_name) | ||
1. Weights mush be totaly added to 1.0 (undetermined) | ||
1. The `incentive_id` must be unique for each | ||
1. The object related to one `incentive_id` is static | ||
1. Any address pairs or an address can resister `incentive_store` | ||
|
||
## Accumulate reward | ||
|
||
1. If the `incentive_id` is put into the specified field (currently considering memo field) for the target messages like MsgPayAuctionFee, the `reward_rate` of the consumed trading fee which is made in that transaction (not tx fee) is accumulated to the subjects | ||
1. The reward accumulation is exucuted at the timing hooks are called | ||
1. The reward is stored as just data in the `ecosystem-incentive` module with the subject address as key (not for each `incentive_id`) | ||
|
||
## Withdrawal | ||
|
||
1. Subject account of ecosystem-incentive can withdraw those accumulated rewards | ||
1. Subject account can withdraw all accumulated rewards for all denom at once | ||
1. Subject account can withdraw accumulated reward of the specific denom | ||
1. If the sender module account doesn't have enough funds for the withdrawal, the witthdrawal tx fails with emitting the specific event with the reason. | ||
|
||
## Distribution | ||
|
||
1. The reward is distributed when eligible subject sends withdrawal message | ||
1. The reward comes from the module account that accumulates the consumed trading fee | ||
|
||
### The way to achieve distribution | ||
|
||
1. Actually sending corresponding coin for reward in a process using SendCoinFromModuleAccount | ||
1. (Or possibly in a process, mint corresponding coin for reward for the subject address and just subtract corresponding coin from the subject module account) | ||
|
||
## Query | ||
|
||
1. The accumulated rewards of any account for all denom can be queried by `address` | ||
1. The accumulated reward of any account for the specific denom can be queried by `address` and `denom` | ||
1. The weghts for each subjects in the `incentive_id` can be queried by `incentive_id` | ||
|
||
## Params | ||
|
||
`reward_setting` | ||
This contains `reward_type` and `reward_rate` in array for the incentive configuration. | ||
e.g. | ||
```protobuf | ||
message RewardParams { | ||
repeated RewardRate reward_rate = 1; | ||
} | ||
``` | ||
|
||
`reward_rate` | ||
The factor to multipy the trading fee for the reward of this module. | ||
e.g. If `reward_rate` is 80% and the trading fee that is made in a target message is 100GUU, the actual reward for target `incentive_id` subjects is `100GUU * 0.80 = 80GUU`. | ||
|
||
```protobuf | ||
message RewardRate { | ||
string reward_type = 1; | ||
unsure rate = 2; | ||
} | ||
``` | ||
|
||
## Hooks | ||
|
||
**This logic is not finalized. Needed to be researched.** | ||
|
||
1. Update the reward amount when the according hooks function is called in `nftmarket` module | ||
1. The reward amount is in the hooks function | ||
1. At this moment, what it's needed to do is just update the stored data regarding reward amount for the denom of the subjects address by number | ||
1. Hooks are also called for resistration of the incentive with `incentive_id` and `NftIdentifier`. | ||
1. To pass the `incentive_id` from the memo data of `MsgListNft` requires a method to get memo data in the process of `MsgListNft` in `x/nftmarket` module. | ||
|
||
The interfaces: | ||
|
||
```go | ||
type NftmarketHooks interface { | ||
AfterNftListed(ctx sdk.Context, nft_id types.NftIdentifier, incentive_id string) | ||
AfterNftPaid(ctx sdk.Context, nft_id types.NftIdentifier, fee_amount mathInt, fee_denom string) | ||
} | ||
``` | ||
|
||
# Check List | ||
|
||
**NOTE: You can remove this file once it's done.** | ||
|
||
## Needed to be inspected | ||
|
||
The check list to achieve all requirements of this module. | ||
|
||
- [x] At EndBlock, is it possible to distinguish transactions from message type? | ||
- [x] Is it possible to extract arguments of that message? | ||
- [x] Is it possible to extract memo field data of that message? | ||
- [x] Is possible to distinguish transaction succeeds | ||
- [x] Best way to get subject address and its weight via CLI (json file or map?) | ||
- [x] The way to contain reward information for each addresses and denoms | ||
- [x] Can you use the handler in the transaction tips article |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
# Concepts | ||
|
||
**NOTE: This is early draft.** | ||
|
||
This module aims to provide the incentive for the parties which especially bring value to our ecosystem like frontend service creator. | ||
Fucosing on the case for the frontend service creator, any of them who creates UnUniFi NFT market and NFTFi frontend service are the subjects to recieve Ecosystem Incentive reward from the NFT trading fee in many denoms which are used in NFT market. | ||
|
||
## Joining Ecosystem Incentive | ||
|
||
Any subjects can send a register message `MsgIncentiveRegister` with the `incentive_id` and `subject_weight_map`. | ||
|
||
## Getting Ecosystem Incentive Reward | ||
|
||
This model of distribution reward could be applied to many use-cases. But, we write down only about the case for Nftmarket Frontend model here for better explanation of the sense of this module. | ||
First, the subjects must register to get incentive by sending `MsgIncentiveRegister`. | ||
Once the `incentive_id` is registered, they insert that `incentive_id` in the target message which is `MsgListNft` memo field precisely to get the reward for the Nftmarket Frontend incentive mode. | ||
Once the `NftIdentifer` on the market is connected with `incentive_id`, `AfterNftPaymentWithCommission` hook function triggers methods to reflect the reward amount for according addresses in `incentive_id`. | ||
|
||
## Withdrawing Ecosystem Incentive Reward | ||
|
||
Any registered subjects can withdraw thier reward by sending a withdrawal message if they are there. | ||
They can withdraw all rewards across all denoms by sending `MsgWithdrawAllRewards`. | ||
In other way, they can withdraw specific denom reward by sending `MsgWithdrawSpecificDenomReward`. | ||
|
||
## The Reward Mechanism | ||
|
||
All the reward comes from the fees that UnUniFi protocol earned without gas fee which is defined in protocol as glocal parameter. | ||
There is nothing inflational effect or depletion by rewarding subjects. |
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,86 @@ | ||
# State | ||
|
||
**NOTE: This is early draft.** | ||
|
||
## IncentiveStore | ||
|
||
### incentive_id | ||
|
||
`incentive_id` is the unique identifier in the `incentive_store` for the subjects. Hence, it can't be duplicated. | ||
|
||
### weight | ||
|
||
The ratio of the reward distribution in a `incentive_store` unit. | ||
`incentive_store` can contain several `subject`s and ratio for each. | ||
|
||
```protobuf | ||
message IncentiveStore { | ||
string incentive_id = 1; | ||
repeated string subjects = 2; | ||
repeated undetermined weights = 3; | ||
RewardType reward_type = 4; | ||
} | ||
``` | ||
|
||
- Incentive: `"incentive_id" -> format(IncentiveStore)` | ||
|
||
## NftmarketFrontendIncentiveIdTable | ||
|
||
- nftmarket_frontend_incentive_id_table: `format(nft_id) -> format(incentive_id)` | ||
|
||
This KVStore manages what NFT is connected to which `incentive_id`. | ||
|
||
## RewardTable | ||
|
||
RewardTable is the record of the rewards for the subject of the `ecosystem-incentive`. | ||
|
||
```protobuf | ||
message Reward { | ||
string subject = 1 [ | ||
(gogoproto.moretags) = "yaml:\"sender\"", | ||
(gogoproto.customtype) = "github.com/UnUniFi/chain/types.StringAccAddress", | ||
(gogoproto.nullable) = false | ||
]; | ||
repeated cosmos.base.v1beta1.Coin rewards = 2; | ||
} | ||
``` | ||
|
||
- RewardTable: `format(address) -> format(reward)` | ||
|
||
## Params | ||
|
||
```protobuf | ||
message Params { | ||
repeated RewardParam reward_params = 1 [ | ||
(gogoproto.moretags) = "yaml:\"reward_params\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
repeated RewardType reward_types = 2; | ||
} | ||
|
||
message RewardParams { | ||
string module_name = 1; | ||
repeated RewardRate reward_rate = 2; | ||
} | ||
|
||
message RewardRate { | ||
RewardType reward_type = 1; | ||
unsure rate = 2; | ||
} | ||
|
||
enum RewardType { | ||
NFTMARKET_FRONTEND = 0; // example | ||
} | ||
``` | ||
|
||
`Params` contains `RewardParams` as the configuration of this module parameters. | ||
|
||
### RewardRate | ||
|
||
The factor to multipy the trading fee for the reward of this module. | ||
e.g. If `reward_rate` is 80% and the trading fee that is made in a target message is 100GUU, the actual reward for target `incentive_id` subjects is `100GUU * 0.80 = 80GUU`. | ||
|
||
### RewardType | ||
|
||
The reward type manages the types of the reward for the various subject. | ||
At first, we support frontend creator. But, the reward will be able to distributed for the different type of parties in our ecosystem. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taiki1frsy
I think the data structure is ambiguous.
Can I see a sample data structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkXultra
I added description in 02_state.md for more abundant document of the data structures in this module.
Plz refer.