FEAT: Add Trade Accounts

FEAT: Add Trade Assets

Summary

This MR introduces a comprehensive Trade Assets feature to MayaChain, enabling specialized accounts for trading and arbitrage opportunities. The feature allows users to deposit assets into dedicated Trade Accounts and perform swaps with those assets, facilitating more complex trading strategies.

Key Components

Core Trade Account Functionality

  • Added TradeAccountManager interface for handling trade account operations
  • Implemented handlers for trade account deposits and withdrawals
  • Added constants and configuration for trade account operations
  • Created proto definitions for trade account messages

Standardized Terminology

  • Renamed TradeTarget to SwapTarget throughout the codebase for terminology consistency
  • Updated all related methods, handlers, and tests to use the new naming
  • Modified proto files to align with the naming convention

Testing Infrastructure

  • Added unit tests covering trade account deposit/withdrawal and arbitrage scenarios
  • Added regression tests verifying trade account functionality in various network conditions
  • Added simulation tests to validate trade account arbitrage operations

Technical Implementation Notes

  • Trade accounts work similarly to Savers accounts but are optimized for active trading
  • The architecture maintains compatibility with existing swap functionality
  • Current implementation lays groundwork for future advanced trading features
  • All code follows MayaChain's established patterns and security practices

Required Actions Before Merge

  • Run scripts/protocgen.sh to regenerate protobuf files from the updated proto definitions
  • Verify all unit tests pass
  • Run all regression tests to ensure stability
  • Execute simulation tests to validate arbitrage functionality

Impact Analysis

This feature enables the following new user workflows:

  • Users can deposit assets into specialized accounts dedicated to trading
  • Trade accounts can perform automated swaps for more efficient asset management
  • Creates foundation for more advanced trading strategies in future releases

Security Considerations

  • All trade account operations maintain the security model of existing accounts
  • Access controls ensure only account owners can withdraw funds
  • Standard transaction validation protects against manipulation

Migration Notes

  • No migration needed as this is a new feature
  • Existing swap functionality is preserved with improved naming consistency
  • API changes are backward compatible

Summary by CodeRabbit

  • New Features

    • Introduced trade accounts enabling deposits, withdrawals, and balance management for trade assets.
    • Added dedicated transaction types and handlers for trade account deposits and withdrawals.
    • Implemented trade account management interfaces and keeper methods for querying and updating trade accounts and trade units.
    • Added feature flags to control trade account functionality and deposit operations.
    • Provided simulation actors and test suites to validate trade account arbitrage and swap scenarios.
  • Improvements

    • Enhanced asset handling to explicitly support trade assets with new parsing, equality, and string representation logic.
    • Updated swap validation to restrict direct swaps between trade and non-trade assets without proper memos.
    • Renamed swap and orderbook fields from TradeTarget to SwapTarget for consistency.
  • Bug Fixes

    • Fixed field naming inconsistencies in swap, orderbook, and streaming swap logic.
  • Documentation

    • Added comprehensive trade assets implementation guide detailing architecture, integration, and feature flags.
  • Tests

    • Added extensive unit tests for trade account deposit and withdrawal handlers.
    • Introduced regression and simulation test suites covering trade account operations and arbitrage.
  • Chores

    • Downgraded specific Docker images for ethereum and arbitrum services.
    • Removed deprecated logging wrapper and obsolete generated protobuf Python modules.
Edited by Ghost User

Merge request reports

Loading
Loading