Share
Embed
Transcript
27 slides
-
⽬录 • ParallelFI 介绍 • XCM v0的回顾 • XCM v1,
v2的新特性 • What is & why Liquid Staking • Liquid Staking⽅案探索 • Liquid Staking验证⼈选举 • 基于Transact和衍⽣账户的Liquid Staking实现 • 平⾏链开发经验及⼯具分享 • 引⽤ -
ParallelFI 介绍 • 春季 Substrate Hackathon 时建⽴的团队 • 4⽉份成⽴Parallel Finance,总部位于美国
• 团队成员主要位于中国,美国,欧洲,印度,俄罗斯 • 2200万美元A轮融资,波卡⽣态中最⼤的⼀轮融资 Parallel Finance = Lending + Liquid Staking + AMM + Auction Loan + Cross chain wallet -
XCM v0 的回顾 XCM v0 XCM v1 XCM v2 xcm-executor
xcm- builder pallet-xcm XCMP / UMP / DMP QUEUE -
XCM v1, v2 的新特性 • 类型结构简化 (v1) • 版本⾃动协商 (v1添加类型,v2添加实现)
• Extrinsics回调 (v2) • VM (v2) -
XCM v1, v2 的新特性 类型结构简化 • MultiAsset -> AssetId +
Fungibility + WildMultiAsset (v1) • MultiLocation X1…X8 -> MultiLocation { parents: u8, interior: Junctions } (v1) • Xcm, Order -> Instruction (v2) • BuyExecution weight + debt -> WeightLimit::Limited(weight) (v2) 例⼦:在 Parachain(2000) 上表示 Parachain(1001) 上的 30 个同质化 Token V0 V1, V2 -
XCM v1, v2 的新特性 版本⾃动协商 pallet-xcm xcm wrap version Version
Discovery Queue note unknown version on_initialize 1. check and notify xcm version change, migrate storage 2. request version notify pallet-xcm SubscribeVersion QueryResponse { .., response: v1 } Version Notify Targets Add new target Supported Versions XCM_VERSION.MultiLocation <-> XcmVersion Version Notify Targets ParaA ParaB -
XCM v1, v2 的新特性 Extrinsics回调 pallet-xcm xcm wrapper (xcm) report_outcome_notify
Router Queries query_id <—> Option<[pallet_index, call_index]> ParaB query_id, weight query_id, weight, error_index query_id, weight, error_index new_query Some(call info) on_response [ SetAppendix(ReportError), … ] ParaA dispatch -
XCM v1, v2 的新特性 VM xcm new vm process instruction
set / fire error handler set appendix ….. execute appendix -
What is & why Liquid Staking • 波卡使⽤ NPOS 保证⽹络安全
• ⽤户可以质押⾃⼰的 Token 提名验证者来获得奖励 • Token 质押期间不具有流动性,⽆法获得可流动的 “票据” • 只有波卡⽹络知道这笔锁住的 Token 问题:为什么不提供票据释放流动性呢?让⽤户能⾃由的在各个平台交易“票据” 流动性释放的类似案例: Bifrost SALP 协议释放 Crowdloan 期间锁住 Token 的流动性 -
Liquid Staking ⽅案探索 链下多签 + 代理的 v1 版本 pallet-liquid-staking offchain
stake-client Relay Chain Alice xcm upward transfer + bond / bond_extra Bob Charlie stake amount reached threshold anonymous bond duration arrived multi-sig start redeem allocation unstake Proxy::A Proxy::B xcm downward transfer offchain nominate-client validators nominate -
Liquid Staking ⽅案探索 基于 Transact 和衍⽣账户的 v2 版本 stake unstake
(charge 3/1000) Governance pallet-liquid-staking offchain nominate-client validators Relay Chain upward transfer derive_bond / derive_bond_extra derive_unbond derive_rebond nominate / payout_stakers summary(bonding_amount, unbonding_amount) Ledger Unstake Queue total_stake total_unstake peek front push back Withdrawing derive_withdraw_unbonded downward transfer rewards / slashes update amount insert -
Liquid Staking 验证⼈选举 Score = R ⋅ (crf ⋅ (1
− CR) + nf ⋅ 1 N + epf ⋅ EEP EEPA ) ⋅ SR R: Reputation, 0 or 1 CR: Commission Rate N: Nomination of one validator EEP: Average Era Points of one validator in the past 28 eras. EEPA: Average Era Points of All validators in the past 28 eras. crf: A constant shows how much influence of the Commission Rate of a validator. The default value is 100. nf: A constant shows how much influence of the Nomination of a validator. The default value is 1000. epf: A constant shows how much influence of the Era Points of a validator. The default value is 10. SR: Slash Record, default 1, set to 0 if ever slashed in the past month -
基于 Transact 和衍⽣账户的 Liquid Staking 实现 中继链⽅法定义 pallet_staking pallet_utility pallet_balances
注意:参数的 #[codec(compact)] 需与中继链保持⼀致,否则会报 WeightNotComputable 错误 -
基于 Transact 和衍⽣账户的 Liquid Staking 实现 XCM消息格式 Heiko Kusama Holding
staking.bond Derivative pallet staking upward transfer balance transfer derivative call -
基于 Transact 和衍⽣账户的 Liquid Staking 实现 on_idle 尝试对 unstake 队列
peek_front 并⽀付 Staking Currency remaining weight > required_weight ? transfer(queue.peek_front()) queue.pop_front -
引⽤ • [XCM part II: Versioning and compatibility] https://medium.com/polkadot-network/ xcm-part-ii-versioning-and-compatibility-b313fc257b83
• [XCM: The Cross-Chain Message Format] https://medium.com/polkadot-network/ xcm-the-cross-consensus-message-format-3b77b1373392 • [XCM v1] https://github.com/paritytech/polkadot/pull/2815 • [XCM v1 version notificatio stub] https://github.com/paritytech/polkadot/pull/3766 • [Automatic version negociation] https://github.com/paritytech/polkadot/pull/3736 • [XCM v2: Scripting, Query Responses, Exception handling and error reporting] https://github.com/paritytech/polkadot/pull/3629