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

feat(contracts): Add EntanglementManager #72

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

lukmaan-ferrum
Copy link
Contributor

@lukmaan-ferrum lukmaan-ferrum commented Oct 31, 2024

This logic needs double checking:

Start

  • Initially mint some qpBTC to get the system going
  • Distribute this to some chosen initial stakers

Stakers staking

  • Stakers call stakeQpBtc() to become stakers
  • Their capacity is updated

Users bridging from L1 to ferrumnet (entangling)

  • A random staker with enough capacity is chosen. A deposit address on L1 which corresponds to that staker is given to the user
  • User sends BTC to this address
  • Indexer pick this up and makes the tx available on ferrumnet, together with an encoded call to QP
  • EntanglementManager reduces staker's capacity by the amount given to their BTC address
  • EntanglementManager makes the QP call
  • QP mints qpBTC to the user

Users bridging from ferrumnet to L1 (settling)
1/ Withdrawal request

  • Request withdrawal
  • EntanglementManager takes the QpBTC and stores in contract for now
  • Random staker chosen to fulfill this withdrawal
  • WithdrawalRequest event emitted
  • Staker needs to listen for this event and fulfill withdrawal

2/ Verify withdrawal

  • Once withdrawal is carried out on L1, call verifyWithdrawal(requestId, txHash)
  • Check outputs address match that of user
  • Increase staker capacity
  • Burn QP

Stakers unstaking

  • Can unstake up to their current capacity
    • Makes sure that staked qpBtc can only be withdrawn if it is not currently being use as collateral for minted qpBtc to some user

Known issues

  • Small number of stakers can mean same staker chosen multiple times in same block, possible exceeding capacity
  • Withdrawal request assumed staker can fullfil any amount of BTC during withdrawal

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

Successfully merging this pull request may close these issues.

2 participants