Skip to content

聊天質押

此模塊負責DaoDst相關的質押,銷毀,獎勵部分

chat/
├── client
│   └── rest
│        ├── error.go          # 介面錯誤集
│        ├── grpc.go           # grpc査詢方法
│        ├── handle_pledge.go # pledge模塊消息前置處理
│        ├── query.go          # 介面査詢函數
│        ├── rest.go           # 消息與査詢路由的注册
│        └── tx.go             # tx相關方法,包括廣播等
├── keeper
│   ├── genesis.go        # 模塊的狀態化和匯出
│   ├── keeper.go         # 存儲管理器,處理模塊的業務邏輯,並有許可權訪問狀態樹的特定子樹
│   ├── msg_server.go     # 提供上鏈消息的服務處理邏輯
│   ├── params.go         # 模塊參數的設定和獲取
│   ├── query.go          # 狀態査詢函數
│   ├── medal.go          # hash币质押计算相关逻辑算法
│   └── mingkeeper.go     # 铸造增发相关逻辑算法
├── types
│   ├── codec.go          # 編碼注册類型
│   ├── errors.go         # 模塊特定的錯誤
│   ├── events.go         # 向Tendermint PubSub/Websocket暴露的事件
│   ├── genesis.go        # 模塊的創世狀態
│   ├── interface.go      # 模塊的介面集合
│   ├── keys.go           # 模塊存儲key以及一些其他的常數
│   ├── msg.go            # 聊天模塊交易消息
│   ├── params.go         # 模塊可以通過治理模塊修改的自定義參數
│   ├── interface.go      # 引入的外部模块实现的方法
│   └── types.go          # 模塊的類型集合
├── genesis.go            # ABCI的創世狀態初始化和匯出功能
├── handler.go            # 消息路由
└── module.go             # 模塊管理器的模塊設定

目錄

Pledge

pledge模塊負責DaoDST的質押與銷毀的部分

DST & HASH

用戶可以通過銷毀dst的管道獲取hash代幣,同時質押hash來持續獲取並隨時選取dst獎勵,
到達一定等級後,hash可以贖回並交易

HASH

在注册聊天時,需要銷毀一定量的dst,按照算灋兌換成hash,獲得的hash將會被自動質押,按照規則,每次出塊都將獲得獎勵(dst)
hash的贖回和交易需要到達一定自由石匠等級

自由石匠等级

提高自由石匠等級有一些權益,比如解鎖hash的贖回和交易,提升銷毀dst獲得hash的比例,解鎖更多聊天房間數量,提高聊天線上存儲空間等。
自由石匠等級和hash質押量掛鉤,hash質押量與等級之間的關係可以通過投票更改

HASH轉帳

hash的轉帳將會收取更多的gas,大概是普通轉帳的10000倍

銷毀DST

銷毀DST時,將會根據銷毀量,給注册閘道和當前閘道增發一些獎勵(dst),同時增發一些獎勵給礦工

銷毀DST兌換HASH的算灋如下

銷毀金額/(當日DST獎勵增發量/全網HASH累計獲得量)=獲得的HASH數量

質押HASH

質押HASH可以持續獲得DST獎勵

DST每次出塊都會增發,用戶按照hash質押占比獲得其中的dst獎勵

dst每次出塊增發數量的算灋如下

塊通脹=((0.35-最近100天銷毀數量)/ 0.35 *(最大通脹率3.65 -最小通脹率1.21)+最小通脹率1.21)/每年出塊數5259600

功能

质押模塊' Keeper '授予對聊天模塊狀態的存取權限 並實現' statedb。 介面,以支持' StateDB '實現。 Keeper包含一個允許資料庫的存儲鍵 寫入只能由Chat模塊訪問的多庫的具體子樹。 而不是使用樹和資料庫進行査詢和持久化(' StateDB '實現), DaoDst使用Cosmos的“KVStore”(鍵值存儲)和Cosmos SDK的“Keeper”來促進狀態轉換。

為了支持介面功能,它導入了4個模塊Keepers:

  • auth: 帳號的增删改查
  • bank: 供應量和餘額的增删改查
  • comm: 閘道相關資料的管理
  • chat: 聊天相关数据的管理
type Keeper struct {
    storeKey   sdk.StoreKey
    cdc        codec.BinaryCodec
    paramstore paramtypes.Subspace

    hooks            types.PledgeHooks
    AccountKeeper    types.AccountKeeper
    BankKeeper       types.BankKeeper
    CommKeeper       types.CommKeeper
    ChatKeeper       types.ChatKeeper
    FeeCollectorName string
}

消息

MsgPledge

通過此消息,發起dst的銷毀
    type MsgPledge struct {
        FromAddress      string     `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"`
        DelegatorAddress string     `protobuf:"bytes,2,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"`
        ValidatorAddress string     `protobuf:"bytes,3,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"`
        Amount           types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"`
    }

MsgWithdrawDelegatorReward

通過此消息,選取質押hash的dst獎勵
    type MsgWithdrawDelegatorReward struct {
        DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"`
    }

MsgUnpledge

通過此消息,贖回質押的hash
    type MsgUnpledge struct {
        DelegatorAddress string     `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"`
        Amount           types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"`
    }

MsgBurnGetMedal

銷毀dst獲得Hash
    type MsgBurnGetMedal struct {
        FromAddress string     `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"`
        ToAddress   string     `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"`
        Gateway     string     `protobuf:"bytes,3,opt,name=gateway,proto3" json:"gateway,omitempty" yaml:"gateway"`
        BurnCoin    types.Coin `protobuf:"bytes,4,opt,name=burn_coin,json=burnCoin,proto3" json:"burn_coin" yaml:"burn_coin"`
    }

參數

pledge模塊包含如下模塊參數

參數

Key Type Default Value
KeyInflationDays int64 100
InflationMax github_com_cosmos_cosmos_sdk_types.Dec 3.65
InflationMin github_com_cosmos_cosmos_sdk_types.Dec 1.21
GoalBonded github_com_cosmos_cosmos_sdk_types.Dec 0.35
BlocksPerYear uint64 5259600
UnbondingHeight int64 302400
MinBurnCoin github_com_cosmos_cosmos_sdk_types.Coin 100000000000000000000dst
BurnCurrentGatePercent github_com_cosmos_cosmos_sdk_types.Dec 0.1
BurnRegisterGatePercent github_com_cosmos_cosmos_sdk_types.Dec 0.1
BurnDposPercent github_com_cosmos_cosmos_sdk_types.Dec 0.1
BurnReturnDays int64 120
BurnLevels []BurnLevel

銷毀等級

BurnLevels 定義了自由石匠等級可享受的相關權益,其中包括三種權益

1.銷毀dst兌換hash的比例
2.聊天存儲空間
3.聊天解鎖房間數
Level MedalAmount AddPercent RoomAmount
1 100 1 0
2 200 2 0
3 400 3 0
4 800 4 0
5 1600 5 1
6 3200 6 2
7 6400 7 3
8 12800 8 4
9 25600 9 5
10 51200 12 6
11 102400 15 7
12 204800 18 8
13 409600 21 9
14 819200 24 10
15 1638400 27 11
16 3276800 30 12
17 6553600 33 13
18 13107200 36 14
19 26214400 39 15
20 52428800 43 16
21 104857600 47 17
22 209715200 51 18
23 419430400 55 19
24 838860800 59 20
25 1677721600 63 21
26 3355443200 67 22
27 6710886400 71 23
28 13421772800 75 24
29 26843545600 79 25
30 53687091200 84 26
31 107374182400 89 27
32 214748364800 94 28
33 429496729600 100 29