BitFi Docs
Home
  • Welcome to BitFi
    • CeDeFi Innovation
    • Addressing Market Challenges
  • FAQ
  • Background
    • Bitcoin-Fi: Current Challenges
    • The BitFi Solution: A CeDeFi Hybrid Approach
  • BitFi‘s CEDEFI
    • Integration with CeFi and DeFi
    • Implementation of CeFi
      • Ceffu MirrorX
      • BitFi Strategies
      • Risk Management
    • Implementation of DeFi
      • bfBTC
      • bfUSD
  • How To
    • Introduction
    • Stake BTC on an EVM-Compatible Chain
    • Stake BTC on Bitcoin Network
    • Unstake bfBTC to EVM-Compatibale Chain
    • Unstake bfBTC to Bitcoin Network
  • Developer
    • bfBTC Overview
    • Using Contract
      • Stake bfBTC
      • Unstake bfBTC
      • bfBTC Fees
      • bfBTC Price Oracle
    • Epoch and Ratio
      • Epoch Updates
      • Underlying Asset Price Variation
    • Deployed Contracts
    • Audit Report
  • Resource
    • Communities
    • Brand Kit
    • BitFi Home Page
Powered by GitBook
On this page
  • Preview Stake
  • Stake on EVM
  • Stake on BTC
  1. Developer
  2. Using Contract

Stake bfBTC

Currently, we support RedStone Oracle for price feeds. BitFi plans to integrate more underlying asset oracles in the future.

Preview Stake

function previewDeposit(uint256 amount) public view returns (uint256)

Description: Preview the amount of bfBTC tokens you will receive for a specified deposit amount.

Parameters:

  • amount: The expected amount of underlying asset to deposit

Return Value:

  • The estimated amount of bfBTC to be received

Notes:

  • underlyingDecimals = 8 or 18 (BTCB & BTC on Bitlayer are 18; hemiBTC is 8)

  • minAmount acts as slippage protection

  • Recommended to set a 1% buffer to prevent deposit failures due to epoch updates

  • Helps estimate bfBTC amount before actual deposit

Stake on EVM

function deposit(uint256 amount, uint256 minAmount) external

Description: Deposit underlying assets to receive bfBTC tokens on EVM-compatible chains.

Parameters:

  • amount: The deposit amount of underlying asset

  • minAmount: Minimum acceptable amount of bfBTC to be minted (recommended: 1% buffer)

Chain-Specific Requirements:

  • Ethereum: Requires WBTC approval

  • BSC: Requires BTCB approval

  • Bitlayer: Uses native token (value sent in transaction)

  • Hemi: Uses hemiBTC

Calculation Formula (Ethereum WBTC):

Recv=DepositAmount∗min⁡(1,OraclePrice1e6)∗Ratio1e8Recv = \text{DepositAmount} * \min\left(1, \frac{\text{OraclePrice}}{1e6}\right) * \frac{\text{Ratio}}{1e8}Recv=DepositAmount∗min(1,1e6OraclePrice​)∗1e8Ratio​

Where:

  • Recv: Amount of bfBTC received (8 decimals)

  • DepositAmount: Amount of WBTC deposited (8 decimals)

  • OraclePrice: WBTC/BTC price from oracle

  • Ratio: Exchange ratio between BTC and bfBTC

Special Cases:

  • Hemi & BSC: Oracle Price fixed at 1 BTC equivalent for BTCB & hemiBTC deposits

  • Bitlayer: No amount parameter required; value sent in transaction

Notes:

  • Requires prior approval for contract to use underlying tokens

  • Transaction reverts if received amount < minAmount

  • Underlying assets transferred to underlyingWallet

  • Emits Deposit event with transaction details

Stake on BTC

function depositNative(
    address[] calldata users,
    uint256[] calldata amounts,
    bytes32[] calldata nativeTxs
) external

Description: Process native BTC deposits from Bitcoin network.

Parameters:

  • users: Array of user addresses receiving bfBTC

  • amounts: Array of BTC deposit amounts

  • nativeTxs: Array of Bitcoin transaction hashes

Process Flow:

  1. User deposits BTC on Bitcoin network

  2. Multisig manager confirms deposit

  3. Multisig manager calls depositNative to mint bfBTC

  4. Users receive bfBTC tokens

Notes:

  • Only callable by multisig manager address

  • Each native transaction can only be processed once

  • Uses current ratio for bfBTC calculation

  • Emits DepositNative event for each successful deposit

  • Requires contract to be unpaused

Additional Information

  • Native deposits require administrator processing

  • Each native transaction hash must be unique

  • Batch processing supported for efficiency

  • Security measures prevent double-processing

  • Pausable functionality available for emergencies

PreviousUsing ContractNextUnstake bfBTC

Last updated 3 months ago