Skip to content

Instantly share code, notes, and snippets.

@xlc
Last active April 2, 2021 02:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xlc/674ad33881bf8a7313330ac8b40b9d96 to your computer and use it in GitHub Desktop.
Save xlc/674ad33881bf8a7313330ac8b40b9d96 to your computer and use it in GitHub Desktop.

Parachain 众筹拍卖模块

流程

  • 管理员创建众筹 crowdfund::create
    • 参数
      • orign: Origin
        • 要求 Signed ,任何账号都可以发起众筹
      • cap: Balance
        • 最多可以筹得的硬顶
      • first_slot: T::BlockNumber
        • 竞拍的第一个租赁周期编号
      • last_slot: T::BlockNumber
        • 竞拍的最后一个租赁周期编号
      • end: T::BlockNumber
        • 众筹结束时间。一次众筹可以参与多次拍卖,但如果直到这个时间众筹还未成功,参与者就可以赎回资金
    • 事件
    • 发起众筹需要先预存一定数量的资金
  • 参与者贡献资金 crowdfund::contribute
    • 参数
      • orign: Origin
        • 要求 Signed ,任何账号都可以参与众筹
      • index: FundIndex
        • 参与的众筹编号
      • value: Balance
        • 贡献额度,必须比系统预设的最低额度要多。这部分资金会转移给众筹模块。如果现在在拍卖的结束阶段,会在区块结束时执行竞拍
  • 众筹成功,参与者可以生成参与众筹的证据,在平行链上认取相对应的奖励。
  • 众筹成功,租赁时间到并且没有续约,参与者可以赎回参与资金
  • 众筹失败,参与者可以赎回参与资金

Parachain 拍卖流程介绍

简介

  • 一次拍卖4个周期的插槽租赁权,每个周期6个月。一个parachain最多竞拍4个周期的租赁权,也就是2年。
  • 一个拍卖有几个阶段
    • 拍卖开始
    • 拍卖结束阶段开始
    • 拍卖真正结束
    • 拍卖结束阶段结束
  • 其中 拍卖真正结束 时间是位置的,在 拍卖结束阶段结束 后才知晓。在 拍卖真正结束 之后的所有竞拍视为无效
  • 一个账户可以分别参与多个不同租赁周期的竞拍,但是要求必须是连续的。比如在竞拍周期为6个月(1个周期)的情况下,可以分别竞拍周期0和周期1,但是在暂时获胜周期0的情况下,不能同时竞拍周期3,因为不连续。

相关代码

插槽模块:https://github.com/paritytech/polkadot/blob/master/runtime/src/slots.rs

众筹拍卖模块:https://github.com/paritytech/polkadot/blob/master/runtime/src/crowdfund.rs

Polkadot Wiki: https://wiki.polkadot.network/docs/en/learn-auction

Web3 Wiki: https://research.web3.foundation/en/latest/polkadot/Parachain-Allocation/

流程

  • 系统发起拍卖 slots::new_auction
    • 参数
      • orign: Origin
        • 要求 Root, 也就是说只有治理模块可以发起拍卖
      • duration: BlockNumber
        • 拍卖时长,当这么多块过后,进入 拍卖结束阶段开始
      • lease_period_index: LeasePeriodOf
        • 要拍卖的第一个租赁周期的编号
    • 事件
    • 一次只能有一个拍卖,不支持多个拍卖同时进行
    • 进入 拍卖开始 阶段
  • 用户 / 众筹账号 参与竞拍 slots::bid
    • 参数
      • origin: Origin
        • 要求 Signed,任何用户账号都可以发送交易参与竞拍
      • sub: SubId
        • 竞拍编号。一个同样的用户账号可以发起多个不同的竞拍,不同的竞拍由竞拍编号来决定
      • auction_index: AuctionIndex
        • 拍卖编号
      • first_slot: LeasePeriod
        • 竞拍的第一个租赁周期编号
      • last_slot: LeasePeriod
        • 竞拍的最后一个租赁周期编号
      • amount: Balance
        • 竞拍金额。这部分资金会被锁仓直到竞拍结束,或者有人出更高价
    • 事件
  • 现有 parachain / parathread 参与续拍 slots::bid_rewnew
    • 参数
      • origin: Origin
        • 要求 Signed ParaId。只能由现有的parachain / parathread通过治理模块发起
      • auction_index: AuctionIndex
        • slots::bid
      • first_slot: LeasePeriod
        • slots::bid
      • last_slot: LeasePeriod
        • slots::bid
      • amount: Balance
        • slots::bid
    • 事件
      • slots::bid
  • 拍卖时长后,进入 拍卖结束阶段开始
    • 可以继续竞拍
  • 结束阶段时长后,进入 拍卖结束阶段结束
  • 锁定 parachain runtime slots::fix_deploy_data
    • 由 parachain 管理员账号发送
  • 上传 parachain runtime slots::elaborate_deploy_data
    • 任何人都可以发送,但是 runtime hash 必须符合之前由管理员锁定的 hash
  • 租赁周期开始
    • 把新的平行链锁仓的资金销毁,转换成记账
    • 把退休的平行链记账的资金重新铸币退回给管理员账户
  • 租赁周期期间
    • 可以通过平行链治理模块参与续拍
  • 租赁周期结束
    • 如果没有续拍成功,记账的资金重新铸币退回给管理员账户
@ianhe8x
Copy link

ianhe8x commented Mar 26, 2021

It means crownload and auction are both bid, and complete with each other., right ?

Jaco

Indeed.
The crowdloan has a different bidding address like Shawn mentioned - so they are competing and seen as 2 entities.

shawntabrizi

If you have a crowdloan, you should not make a Bid, but instead contribute to your own crowdloan.
Or you would want to make bids which have different slot selections than your crowdloan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment