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

SIP-0002: Stake #4

Open
codefather-filestar opened this issue Mar 31, 2021 · 2 comments
Open

SIP-0002: Stake #4

codefather-filestar opened this issue Mar 31, 2021 · 2 comments

Comments

@codefather-filestar
Copy link

codefather-filestar commented Mar 31, 2021

FileStar Stake 方案

基本逻辑

  1. 用户调用 Stake 合约的充值函数进行锁仓
  2. 经过成熟期后算力生效
  3. 在每一轮奖励发放周期通过 Stake 算力占全网总 Stake 算力的比例发放奖励,奖励按180天线性释放
  4. 已解锁的奖励可以调用合约取回,本金可在锁定期后赎回

规则

  • 充值:有最小充值金额限制,100 STAR,管理员可调整
  • 本金锁定期:90天,管理员可调整
  • 成熟期:12小时,管理员可调整
  • 奖励发放周期(即一轮):1天,管理员可调整
  • 算力生效规则:充值块高距离当前块高大于成熟期的视为有效算力
  • 每轮总奖励上限:3万 STAR,管理员可调整
  • 每轮实际总奖励:min(每轮总奖励上限, 全网Stake算力 * 通胀系数 / 10000 ) // 通胀系数暂定为100, 相当于日化1%,管理员可调整
  • 奖励公式:所占Stake算力比例 * 每轮实际总奖励
  • Stake激活后,原存储挖矿的奖励减少30%,总流通量不变
  • 分叉高度:584460(北京时间2021年5月18日10:30左右)

伪代码实现

  • StakeState
{
    RootKey                 // 管理员地址
    TotalStakePower         // 全网总算力

    MaturePeriod            // 成熟期
    RoundPeriod             // 奖励发放周期
    PrincipalUnlockDuration // 本金锁定期
    MinDepositAmount        // 最小充值金额 
    MaxRewardsPerRound      // 每轮最大总奖励
    InflationFactor         // 通胀系数
    LastRoundReward         // 上一轮实际总奖励
    NextRoundEpoch          // 下一轮奖励发放高度

    // 在锁定状态的本金
    LockedPrincipalMap {
        Address => []{Id, Amount, ChainEpoch},
    }

    // 已解锁的本金
    AvailablePrincipalMap {
        Address => Amount
    }

    // 各地址的算力情况
    StakePowerMap {
        Address => StakePower (=AvailablePrincipal + LockedPrincipal中已成熟部分)
    }

    // 待释放的奖励
    VestingRewardMap {
        Address => []VestingFund
    }
    
    // 可提取的奖励金额
    AvailableRewardMap {
        Address => Amount
    }
}
  • StakeActor
{   
    // 充值
    func Deposit()

    // 提取本金
    func WithdrawPrincipal(amount)

    // 提取奖励
    func WithdrawReward(amount)

    // 修改成熟期,需鉴权
    func ChangeMaturePeriod()

    // 修改轮长,需鉴权
    func ChangeRoundPeriod()

    // 修改锁定期,需鉴权
    func ChangePrincipalUnlockDuration()

    // 修改最小充值金额,需鉴权
    func ChangeMinDepositAmount()

    // 修改每轮总奖励上限,需鉴权
    func ChangeMaxRewardsPerRound()

    // 修改通胀系数,需鉴权
    func ChangeInflationFactor()

    // 修改管理员,需鉴权    
    func ChangeRootKey()

    // 定时器
    func OnEpochTickEnd()
}

新增命令

  • 充值:lotus stake deposit [amount]
  • 查看信息:lotus stake info
  • 查看被锁定的本金:lotus stake list-locked-principal
  • 查看未释放的奖励:lotus stake list-vesting
  • 提取本金:lotus stake withdraw principal [amount]
  • 提取奖励:lotus stake withdraw reward [amount]
@bird512
Copy link

bird512 commented Apr 12, 2021

管理员可调整!!!这个还是去中心化的项目吗?

@codefather-filestar
Copy link
Author

管理员可调整!!!这个还是去中心化的项目吗?

你好,管理员账号 t080 是 filecoin 就有的机制,https://github.com/filecoin-project/lotus/blob/b54b1303f9f6bcc3b57ae25cfc1174b59f44b943/chain/actors/builtin/builtin.go#L31 它是一个多签地址,需要多位管理员同意才能调用,filestar也打算沿用这套管理方案。

参数可调整的好处在于更新规则不需要额外发布代码进行硬分叉,同时如果发现bug也可以在不更新代码的情况下及时停止stake。

管理员账号在stake中的作用仅限于参数的调整,不能因此获利。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants