> ## Documentation Index
> Fetch the complete documentation index at: https://docs.systems-echo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# spot trade (buy/sell)



## OpenAPI

````yaml /openapi.json post /api/v1/extension/token/trade
openapi: 3.0.1
info:
  title: echo/extension/v1/extension.proto
  version: version not set
servers:
  - url: /
security: []
tags:
  - name: ExtensionService
paths:
  /api/v1/extension/token/trade:
    post:
      tags:
        - ExtensionService
      summary: spot trade (buy/sell)
      operationId: ExtensionService_TradeTokenExtension
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v1TradeTokenExtensionRequest'
        required: true
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1TradeTokenExtensionResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/rpcStatus'
components:
  schemas:
    v1TradeTokenExtensionRequest:
      type: object
      properties:
        token:
          title: token is the extension token (auth token)
          type: string
        chain:
          $ref: '#/components/schemas/v1CHAIN'
        direction:
          $ref: '#/components/schemas/v1TradeDirection'
        input:
          title: input is the token address or pool address
          type: string
        amount:
          title: |-
            amount is the amount to trade
            can be specific amount (for buy)
            or percentage of the balance (for sell)
          type: string
        settings:
          $ref: '#/components/schemas/v1UserSettings'
        strategies:
          title: |-
            optional trade strategies applied after successful trade
            (e.g. take profit, stop loss)
          type: array
          items:
            $ref: '#/components/schemas/v1TradeStrategy'
        walletId:
          title: |-
            optional wallet_id to use for the trade
            if not set, primary wallet will be used
          type: string
    v1TradeTokenExtensionResponse:
      type: object
      properties:
        result:
          $ref: '#/components/schemas/v1ExecuteTaskSpotTradeResult'
        errors:
          title: possible errors from the strategies
          type: array
          items:
            $ref: '#/components/schemas/v1StrategyError'
    rpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
    v1CHAIN:
      type: string
      default: CHAIN_UNSPECIFIED
      enum:
        - CHAIN_UNSPECIFIED
        - CHAIN_SOL
        - CHAIN_ETH
        - CHAIN_BSC
        - CHAIN_BASE
        - CHAIN_ROBINHOOD
    v1TradeDirection:
      type: string
      default: TRADE_DIRECTION_UNSPECIFIED
      enum:
        - TRADE_DIRECTION_UNSPECIFIED
        - TRADE_DIRECTION_BUY
        - TRADE_DIRECTION_SELL
    v1UserSettings:
      title: User settings
      type: object
      properties:
        buyFee:
          type: number
          format: double
        sellFee:
          type: number
          format: double
        buyTip:
          type: number
          format: double
        sellTip:
          type: number
          format: double
        buySlippage:
          type: number
          format: double
        sellSlippage:
          type: number
          format: double
    v1TradeStrategy:
      type: object
      properties:
        takeProfit:
          $ref: '#/components/schemas/v1Strategy'
        stopLoss:
          $ref: '#/components/schemas/v1Strategy'
    v1ExecuteTaskSpotTradeResult:
      type: object
      properties:
        transactionId:
          title: transaction_id is the ID of the transaction that was executed
          type: string
        poolAddress:
          title: pool_address is the address of the pool where the trade was executed
          type: string
        poolPlatform:
          $ref: '#/components/schemas/v1PLATFORM'
        tokenInInfo:
          $ref: '#/components/schemas/v1TokenInfo'
        tokenOutInfo:
          $ref: '#/components/schemas/v1TokenInfo'
        tokenInAmount:
          title: >-
            token_in_amount and token_out_amount are the raw amounts of the
            tokens that were traded
          type: string
        tokenOutAmount:
          type: string
        poolMcapUsd:
          title: pool_mcap_usd is the formatted market cap of the pool in USD
          type: string
    v1StrategyError:
      type: object
      properties:
        strategyIdx:
          title: index of the strategy that failed
          type: integer
          format: int64
        error:
          title: error message from the strategy
          type: string
    protobufAny:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties:
        type: object
    v1Strategy:
      type: object
      properties:
        target:
          title: |-
            target is the target % for the strategy
            the format is "+10" for +10% or "-5" for -5%
          type: string
        amount:
          title: amount is the amount of tokens you want to sell at the target
          type: string
    v1PLATFORM:
      type: string
      default: PLATFORM_UNSPECIFIED
      enum:
        - PLATFORM_UNSPECIFIED
        - PLATFORM_RAYDIUM
        - PLATFORM_RAYDIUM_CP
        - PLATFORM_RAYDIUM_CLMM
        - PLATFORM_PUMPFUN
        - PLATFORM_MOONSHOT
        - PLATFORM_METEORA_DYN
        - PLATFORM_METEORA_DLMM
        - PLATFORM_PAMM
        - PLATFORM_RAYDIUM_LAUNCHPAD
        - PLATFORM_METEORA_DBC
        - PLATFORM_METEORA_DAMM_V2
        - PLATFORM_HEAVEN
        - PLATFORM_UNISWAP_V2
        - PLATFORM_UNISWAP_V3
        - PLATFORM_UNISWAP_V4
    v1TokenInfo:
      type: object
      properties:
        address:
          type: string
        name:
          type: string
        symbol:
          type: string
        decimals:
          type: integer
          format: int64
        isStable:
          type: boolean

````