Skip to content

Market Contract#34

Merged
mriynyk merged 17 commits into
masterfrom
market
Feb 5, 2026
Merged

Market Contract#34
mriynyk merged 17 commits into
masterfrom
market

Conversation

@mriynyk

@mriynyk mriynyk commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator

Add Secondary Market Support and Infrastructure Improvements

Overview

This pull request introduces a complete secondary market solution for the Digital Original (DO) protocol, enabling peer-to-peer NFT trading through off-chain order matching. Additionally, it includes significant infrastructure improvements, refactoring, and enhanced error handling across the entire codebase.

Key Features

🏪 New Market Contract

Introduced a comprehensive secondary market system (Market.sol) that facilitates trustless peer-to-peer trading:

  • Dual Order Types: Support for both sell-side (ask) and buy-side (bid) orders
  • Off-chain Order Matching: Gas-efficient trading through EIP-712 signed orders
  • Multi-Currency Support: Configurable payment currencies via CurrencyManager
  • Flexible Fee Structure: Separate maker and taker fees with revenue sharing
  • Order Management: Order invalidation capabilities for both makers and admins
  • Security Features: Time-bound orders, replay protection, and signature verification

📚 New Libraries and Components

  • Order Library (Order.sol): Defines the order structure and EIP-712 hashing
  • ExecutionPermit Library (ExecutionPermit.sol): Handles execution permissions with revenue distribution
  • SafeERC20BulkTransfer (SafeERC20BulkTransfer.sol): Safe bulk transfer utility for distributing funds
  • CurrencyManager (CurrencyManager.sol): Manages supported payment currencies

🔧 Infrastructure Improvements

Refactored Components

  • Renamed Deployer.solCollectionDeployer.sol for clarity
  • Renamed DeployerTest.solAllDeployer.sol
  • Introduced MarketDeployer.sol for market deployment

Enhanced Error Handling

  • Role System: Added RoleSystemUnauthorizedAccount error with detailed role information
  • Distribution: Consolidated DistributionSharesSumTooBig and DistributionSharesSumTooLow into single DistributionSharesSumInvalid error
  • Improved error messages across all contracts for better debugging

Documentation

  • Completely rewritten README.md with:
    • Detailed contract descriptions
    • Repository layout guide
    • Quick start instructions
    • Configuration file explanations
    • Comprehensive NPM scripts documentation
    • Slither static analysis setup guide

🛠️ Development Tools

New Deployment Scripts

  • deploy-market.ts: Deploy market infrastructure
  • deploy-market-impl.ts: Deploy market implementation
  • verify-market.ts: Etherscan verification for market contracts

Configuration

  • Added config.market.yaml for market-specific parameters
  • Updated network configurations for market support

✅ Comprehensive Testing

Added extensive test coverage for:

  • Market contract functionality (Market.ts)
  • Currency manager operations (CurrencyManager.ts)
  • Market utility functions (market-utils.ts)
  • Updated existing tests for new error handling

Technical Changes Summary

Files Added

  • Market contract and interface
  • Order and ExecutionPermit libraries
  • SafeERC20BulkTransfer utility
  • CurrencyManager system
  • MarketDeployer contract
  • Market deployment and verification scripts
  • Market tests and utilities

Files Modified

  • Enhanced error handling in core contracts
  • Refactored deployment infrastructure
  • Updated test suites
  • Improved documentation
  • Configuration updates

Testing

The new market functionality has been thoroughly tested with comprehensive unit tests covering:

  • Order execution (asks and bids)
  • Fee distribution
  • Order invalidation
  • Currency management
  • Edge cases and security scenarios

Security Considerations

  • All market operations require valid EIP-712 signatures
  • Time-bound orders prevent stale order execution
  • Order invalidation provides users control over their orders
  • Comprehensive input validation and error handling
  • Static analysis performed with Slither

Deployment Notes

  1. Deploy market implementation: npx hardhat deploy-market-impl --network <network>
  2. Deploy market proxy: npx hardhat deploy-market --network <network>
  3. Verify on Etherscan: npx hardhat verify-market --network <network>

@mriynyk mriynyk force-pushed the market branch 3 times, most recently from 548241d to a983100 Compare April 15, 2025 22:53
@mriynyk mriynyk changed the base branch from master to upd_token_auction June 23, 2025 13:47
@mriynyk mriynyk changed the base branch from upd_token_auction to master June 23, 2025 13:51
@mriynyk mriynyk changed the base branch from master to upd_token_auction June 23, 2025 13:53
@mriynyk mriynyk changed the title Market contract Market Contract Jul 2, 2025
Base automatically changed from upd_token_auction to master February 5, 2026 11:04
@mriynyk mriynyk merged commit fc0508e into master Feb 5, 2026
1 check passed
@mriynyk mriynyk deleted the market branch February 5, 2026 11:09
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