Unstake bfBTC
Currently, we support RedStone Oracle for price feeds. BitFi plans to integrate more underlying asset oracles in the future.
Preview Withdrawal
Description: Preview the amount of underlying asset (BTC/BTCB/hemiBTC) you will receive when withdrawing bfBTC, including fee calculations.
Parameters:
share
: Amount of bfBTC to withdrawnative
:true
= withdraw to Bitcoin network;false
= withdraw to EVM network. This parameter (bool) is currently unused on Bitlayer.
Returns:
underlyingAmount
: Amount of underlying asset you will receivefee
: Total fee to be paid (percentage + fixed)
Notes:
Fees are calculated based on current fee configuration
If total fee exceeds withdrawal amount, returns (0, fee)
Actual received amount may vary due to ratio changes between preview and actual withdrawal
Request Withdrawal
Description: Initiate a withdrawal request by locking specified amount of bfBTC in the contract, awaiting administrator approval.
Parameters:
amount
: Amount of bfBTC to withdraw
Notes:
Amount must exceed
minWithdrawBfbtcAmount
Transaction reverts if calculated fees exceed withdrawal amount
Initial status:
WITHDRAWAL_STATUS_PENDING
bfBTC is transferred to contract but not burned yet
Approve Withdrawal
Description: Administrator function to approve multiple withdrawal requests, updating their status to claimable (or approved in modeP002).
Parameters:
epoch
: Historical epoch number for exchange rate calculation (must be less than current epoch)withdrawIds
: Array of withdrawal request IDs to approve
Notes:
Only callable by multisig manager address
Requests must be in
WITHDRAWAL_STATUS_PENDING
stateMust satisfy cooldown period requirement
In modeP002: Emits
UnboundRequired
event instead of setting status to claimable on Bitlayer only.
Claim Withdrawal
Description: Claim approved withdrawals, receiving underlying assets (BTC, BTCB, hemiBTC) to user's address.
Parameters:
withdrawIds
: Array of withdrawal request IDs to claim
Notes:
Only original requestor can claim
Requests must be in
WITHDRAWAL_STATUS_CLAIMABLE
stateStatus changes to
WITHDRAWAL_STATUS_CLAIMED
after successful claimActual received amount calculated based on withdrawal epoch's ratio
Withdrawal Process Flow
Status Transitions
Standard Flow:
Bitlayer Specific Flow (modeP002 enabled):
Notes:
On Bitlayer, after approval, funds must be transferred via bridge before status changes to Unbound
Withdrawal approval timing varies based on Ceffu's processing speed
Withdrawal Amount Calculation
For WBTC withdrawals on Ethereum, actual amount is calculated using Oracle price:
Where:
Recv
: Amount of WBTC received (8 decimals)WithdrawAmount
: Amount of bfBTC withdrawn (8 decimals)OraclePrice
: WBTC/BTC price from oracleRatio
: Exchange ratio between BTC and bfBTC
Additional Information
Use
claimable(withdrawId)
to check available amount before claimingPreview withdrawal amount using
previewWithdraw()
before initiating requestConsider fee implications when planning withdrawal amount
Monitor ratio changes between request and claim for potential amount variations
Important Notes
Stakes and Unstakes must be made while the contract is not paused.
Unstake require a cooldown period. (1 epoch)
The actual amount of BTC received depends on the current epoch's ratio and price.
The displayed receive amount may differ.
Unstake approval time may vary depending on Ceffu's processing speed. BitFi aims to process unstake request within 5 epochs.
Last updated