Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Dexterity Command Line Interface #5

Open
41 tasks
r0zar opened this issue Dec 20, 2024 · 0 comments
Open
41 tasks

Implement Dexterity Command Line Interface #5

r0zar opened this issue Dec 20, 2024 · 0 comments

Comments

@r0zar
Copy link
Owner

r0zar commented Dec 20, 2024

Title: Implement Dexterity Command Line Interface

Description

Create a command-line interface for Dexterity that enables developers to interact with pools, execute trades, manage liquidity, and deploy contracts directly from the terminal. This will improve developer experience and enable automation workflows.

Technical Overview

Build a CLI tool using Commander.js that wraps the Dexterity SDK and provides command-line access to all core functionality. The CLI should support configuration files, environment variables, and both interactive and scripted modes.

Implementation Details

Core CLI Structure

// cli.ts
import { Command } from 'commander';
import { DexteritySDK } from 'dexterity-sdk';

const program = new Command();

program
  .name('dexterity')
  .description('CLI for Dexterity Protocol')
  .version('0.1.0');

Command Categories

Pool Commands
  • List pools
    dexterity pools list [--network] [--token <token-id>]
  • Show pool details
    dexterity pool info <pool-id>
  • Deploy pool
    dexterity pool deploy --config <config-file>
Trading Commands
  • Get quote
    dexterity quote <amount> <token-in> <token-out> [--slippage] [--max-hops]
  • Execute swap
    dexterity swap <amount> <token-in> <token-out> [--slippage] [--max-hops]
  • Show routes
    dexterity routes <token-in> <token-out> [--max-hops]
Liquidity Commands
  • Add liquidity
    dexterity liquidity add <pool-id> <amount> [--slippage]
  • Remove liquidity
    dexterity liquidity remove <pool-id> <amount> [--slippage]
  • Show positions
    dexterity positions list [--address]
Token Commands
  • List tokens
    dexterity tokens list [--network]
  • Show token info
    dexterity token info <token-id>
  • Deploy token
    dexterity token deploy --config <config-file>

Configuration Management

  • Add config file support:
    interface CLIConfig {
      network: string;
      address: string;
      privateKey?: string;
      apiKey?: string;
      defaultSlippage: number;
    }
  • Support environment variables:
    DEXTERITY_NETWORK=mainnet
    DEXTERITY_ADDRESS=ST...
    DEXTERITY_PRIVATE_KEY=...
    DEXTERITY_API_KEY=...

Interactive Mode

  • Add interactive prompts:
    import inquirer from 'inquirer';
    
    async function promptSwapDetails() {
      const answers = await inquirer.prompt([
        {
          type: 'input',
          name: 'amount',
          message: 'Enter amount to swap:',
        },
        // ... other prompts
      ]);
      return answers;
    }

Output Formatting

  • Implement output formats:
    • JSON
    • Table
    • YAML
    interface OutputOptions {
      format: 'json' | 'table' | 'yaml';
      color: boolean;
      verbose: boolean;
    }

Installation

  • Add npm global installation:
    {
      "bin": {
        "dexterity": "./dist/cli.js"
      }
    }
  • Add installation command:
    npm install -g dexterity-cli

Testing Requirements

  • Unit tests for each command
  • Integration tests with SDK
  • End-to-end tests with testnet
  • Test configuration loading
  • Test error scenarios

Documentation Requirements

  • CLI documentation:
    • Installation guide
    • Command reference
    • Configuration guide
    • Examples
  • Generate help text:
    dexterity --help
    dexterity <command> --help
  • Add README examples
  • Add automation guides

Error Handling

  • Implement error messages:
    interface CLIError {
      code: string;
      message: string;
      details?: any;
      suggestions?: string[];
    }
  • Add error recovery suggestions
  • Add debugging mode

Acceptance Criteria

  • All commands work as specified
  • Configuration system works reliably
  • Interactive mode functions correctly
  • Error messages are clear and helpful
  • Documentation is complete
  • Tests pass
  • Installation works via npm

Performance Requirements

  • Command execution < 2s
  • Interactive mode responsive
  • Low memory footprint

Security Considerations

  • Secure handling of private keys
  • API key protection
  • Network validation
  • Input sanitization

Example Usage

# Initialize configuration
dexterity config init

# Get a quote
dexterity quote 100 token-a token-b --slippage 0.5

# Execute a swap
dexterity swap 100 token-a token-b --slippage 0.5

# Deploy a pool
dexterity pool deploy --config pool-config.json

# Show pool details
dexterity pool info SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.pool-token

# Interactive mode
dexterity swap --interactive

Related Issues

  • Depends on: SDK implementation
  • Blocked by: None
  • Related to: Developer tools

Notes

  • Consider adding shell completion
  • Plan for plugin system
  • Consider adding batch operations
  • Think about CI/CD integration
  • Consider adding config validation
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

No branches or pull requests

1 participant