Skip to content

Implement Core BitLock Contract with NFT Marketplace and Staking Functionality#1

Open
timileyin-create wants to merge 5 commits into
mainfrom
feat/bitlock-core
Open

Implement Core BitLock Contract with NFT Marketplace and Staking Functionality#1
timileyin-create wants to merge 5 commits into
mainfrom
feat/bitlock-core

Conversation

@timileyin-create

Copy link
Copy Markdown
Owner

Overview

This PR introduces the foundational components for BitLock – a Bitcoin-backed NFT exchange protocol on Stacks L2. It enables:
Collateralized NFT Minting
Decentralized Marketplace
Fractional Ownership
Yield-Generating Staking


Key Changes

1. Core Contract Architecture (feat: Initialize BitLock contract)

  • Data Structures
    (define-map tokens {token-id: uint} {
      owner: principal,
      uri: (string-ascii 256),
      collateral: uint,
      is-staked: bool,
      stake-timestamp: uint,
      fractional-shares: uint
    })
  • Protocol Constants
    • min-collateral-ratio: 150%
    • protocol-fee: 2.5%
    • yield-rate: 5% APY

2. NFT Lifecycle Management (feat: Add mint-nft)

  • Collateral Verification
    (asserts! (>= (stx-get-balance tx-sender) collateral-requirement) 
  • Metadata Validation
    • URI length/format checks
    • Atomic BTC-STX collateral transfers

3. Marketplace Engine (feat: Implement NFT transfer...)

  • Atomic Swaps
    • Seller/Buyer STX transfers with fee deduction
    (try! (stx-transfer? (/ (* price protocol-fee) 1000) tx-sender contract-owner))
  • Fractionalization
    • Share tracking with proportional ownership rights

4. Staking Module (feat: Implement staking...)

  • Time-Based Yield
    (let ((blocks-staked (- block-height stake-timestamp)))
      (* blocks-staked (/ yield-rate 52560))) ;; Annual blocks estimate
  • Auto-Claim Mechanism
    • Rewards distributed atomically during unstaking

Compliance Alignment

  1. Bitcoin Standards
    • BRC-20 compatible metadata structure
    • sBTC collateral tracking
  2. Financial Safeguards
    • Time-locked staking withdrawals
    • Anti-frontrunning listing logic

Reviewer Notes

  • Critical Path: Verify collateral ratio enforcement in mint-nft
  • QA Focus: Staking reward calculation edge cases
  • Compliance Check: Validate fee distribution addresses

…ants

- Define protocol parameters including minimum collateral ratio, protocol fee, total staked, yield rate, and total supply.
- Establish main token storage map with fields for owner, URI, collateral, staking status, stake timestamp, and fractional shares.
- Add error codes for various contract operations to ensure robust error handling.
- Include comprehensive contract metadata detailing the purpose, summary, and features of BitLock.

This commit sets up the foundational elements required for the BitLock Bitcoin-backed NFT exchange with staking and fractional ownership capabilities.
- Implement mint-nft function to mint new NFTs with collateral backing.
- Validate URI format and length.
- Ensure sufficient collateral is provided by the sender.
- Transfer collateral to the contract and update the token storage map.
- Increment total supply of tokens upon successful minting.

This commit introduces the core functionality for minting NFTs within the BitLock contract, ensuring proper validation and collateralization.
… transfer

- Added `transfer-nft` function to handle NFT ownership transfer.
- Added `list-nft` function to list NFTs for sale.
- Added `purchase-nft` function to handle NFT purchases and update ownership.
- Added `transfer-shares` function to transfer fractional shares between users.
- Added `stake-nft` function to enable NFT staking for yield generation.
- Added `unstake-nft` function to allow unstaking of NFTs and claiming rewards.
- Implemented read-only functions to retrieve token, listing, fractional shares, and staking rewards information.
- Added `calculate-rewards` read-only function to compute current staking rewards.

This commit enhances the BitLock contract with staking capabilities and essential read-only queries for data retrieval.
… claiming

- Implement `stake-nft` function to enable NFT staking for yield generation.
- Implement `unstake-nft` function to allow unstaking of NFTs and claiming rewards.
- Add read-only functions to retrieve token, listing, fractional shares, and staking rewards information.
- Implement `calculate-rewards` read-only function to compute current staking rewards.
- Add private `claim-staking-rewards` function to handle reward distribution during unstaking.

This commit enhances the BitLock contract with staking capabilities, reward calculation, and essential read-only queries for data retrieval.
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.

1 participant