Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

Half withdrawal

jjy edited this page May 6, 2020 · 1 revision

DAO lock is used to lock the NervosDAO cells.

The first intention of this lock script is to allows anyone that holds DCKB to withdraw NervosDAO cells no matter who is the original depositor of the cell.

The second intention is to prevent 'half withdraw' situation:

DCKB owner receives compensation at every block height, which precisely tracks the NervosDAO compensation.

NervosDAO uses two txs to complete withdrawal; the first tx is to generate a cell contains the deposition block number, and the second tx calculate the compensation from the block we deposited in, to the block the first tx get committed.

When an owner tries to withdraw from NervosDAO, after the owner sent the first withdrawal tx, the NervosDAO compensation stopped at the block number of tx committed. But in the DCKB contract, we can't notice the compensation is stopped; the user can stop to send the second withdrawal tx and continuously spend the DCKB. So the NervosDAO compensation is finished, but DCKB compensation increases continually; the DCKB is failed to tracks the NervosDAO compensation!

To prevent this situation, we need a mechanism to force the user to complete the withdrawal.

The dao lock requires a user that in phase 1 withdrawal must custodian X DCKB, which corresponds to the original deposit CKB in the NervosDAO. At phase 2 withdrawal, the user needs to destroy X + Y DCKB which corresponds to the total withdrawal CKB. To prevent a user stop perform phase 2 withdraw, after timeout(42 epochs or ~ 7days), anyone can pay Y DCKB which corresponds to the compensation part to withdraw X + Y CKB. This mechanism incentives users to complete the withdrawal.

Clone this wiki locally