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

# Atomic sell → buy round-trip

> token → SOL → token on the same mint, **both legs in one transaction** —
the mirror of `/swap/sol/buy-sell`. The buy-back leg is chained onto the
sell leg's slippage floor.

Provide exactly one of `percentage` or `tokensAmount` for the sell leg;
sending both, or neither, is an error. Fee accounting is identical to
`/swap/sol/buy-sell` (one off-chain charge on the combined SOL volume).

Errors answer **HTTP 200** with `success:false` and an `error` string.




## OpenAPI

````yaml openapi-spec/trading.yaml post /swap/sol/sell-buy
openapi: 3.0.3
info:
  title: Raze Trading API
  description: >
    Trading endpoints for Solana token swaps — quote, buy, sell, atomic

    round-trips and raw instructions. Perpetuals (Jupiter Perps + Phoenix) live

    here too.


    Quotes can also be **streamed**: `/swap/sol/quote/stream` is a WebSocket
    that

    pushes a fresh quote whenever the pools under your route move. It is not

    describable in OpenAPI — see

    [Streaming quotes](/api-reference/router/quote-stream).


    Write utilities (`/utils/sol/*` — launch, transfer, burn, consolidate, fees)

    moved to the History API on `https://api.raze.bot` (see `history.yaml`).


    Runs on port 8082.


    **Auth methods**: `Authorization: Bearer sk_...` header, `X-API-Key: sk_...`
    header, or `?apiKey=sk_...` query param.
  version: 2.1.0
servers:
  - url: https://router.raze.bot
    description: >-
      Raze global trading router — GeoDNS routes to the nearest region
      automatically
security: []
paths:
  /swap/sol/sell-buy:
    post:
      summary: Atomic sell → buy round-trip
      description: |
        token → SOL → token on the same mint, **both legs in one transaction** —
        the mirror of `/swap/sol/buy-sell`. The buy-back leg is chained onto the
        sell leg's slippage floor.

        Provide exactly one of `percentage` or `tokensAmount` for the sell leg;
        sending both, or neither, is an error. Fee accounting is identical to
        `/swap/sol/buy-sell` (one off-chain charge on the combined SOL volume).

        Errors answer **HTTP 200** with `success:false` and an `error` string.
      operationId: sellBuy
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            API key for authenticated access (alternative to Authorization
            header)
        - name: Authorization
          in: header
          required: false
          schema:
            type: string
          description: Bearer sk_... — alternative to X-API-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SellBuyRequest'
            examples:
              percentage:
                summary: Round-trip 50% of the position
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  percentage: 50
              fixedAmount:
                summary: Fixed token amount, per wallet
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                    - 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  tokensAmount:
                    - 1000000
                    - 2000000
      responses:
        '200':
          description: |
            Transactions generated — or `success:false` with `error` when the
            request is invalid or no route could be built.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SellResponse'
              example:
                success: true
                transactions:
                  - 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWJ...
                amountsOut:
                  - 1043112
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    SellBuyRequest:
      type: object
      description: >
        token → SOL → token atomic round-trip on the SAME mint, both legs in one

        transaction. The buy-back leg is chained onto the sell leg's slippage
        floor.
      properties:
        walletAddresses:
          type: array
          items:
            type: string
          minItems: 1
        tokenAddress:
          type: string
        percentage:
          type: number
          description: >-
            Percentage of holdings to sell on the first leg (0.01–100). Mutually
            exclusive with `tokensAmount` — exactly one is required.
          minimum: 0.01
          maximum: 100
        tokensAmount:
          oneOf:
            - type: number
            - type: array
              items:
                type: number
          description: >-
            Fixed token amount(s) to sell on the first leg. Single number
            applies to all wallets; array is per-wallet. Mutually exclusive with
            `percentage`.
        slippageBps:
          type: integer
          default: 500
          minimum: 0
          maximum: 10000
        transactionsFeeLamports:
          type: number
          description: Priority fee per transaction in lamports.
        feeTipLamports:
          type: number
          description: Tip in lamports. Public — min 0.001 SOL (1000000 lamports) enforced.
          minimum: 1000000
        tipWallet:
          type: string
          description: Custom tip recipient wallet (auth only).
        tipLamports:
          type: number
          description: Custom tip amount in lamports (auth only).
        feeWallet:
          type: string
          description: Custom fee recipient wallet (auth only).
        feeBps:
          type: number
          description: >-
            Custom fee in basis points (auth only). Charged once on the combined
            SOL volume of both legs — see `BuySellRequest`.
        jitoDontFront:
          type: boolean
        maxHops:
          type: integer
          minimum: 1
          maximum: 3
        includeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
        excludeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
        encoding:
          type: string
          enum:
            - base58
            - base64
          default: base64
      required:
        - walletAddresses
        - tokenAddress
    SellResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        transactions:
          type: array
          items:
            type: string
        amountsOut:
          type: array
          items:
            type: integer
            nullable: true
          description: >-
            Per-tx built output amount (raw), index-aligned with `transactions`;
            `null` where no route was found for that wallet. Same semantics as
            on `/swap/sol/buy`.
      required:
        - success
        - transactions
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        details:
          type: string
      required:
        - success
        - error

````