> ## 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 buy → sell round-trip

> SOL → token → SOL on the same mint, **both legs in one transaction**.

The sell leg is chained onto the buy leg's slippage floor, so it can never
overdraw what the buy actually delivered; the two ATA creations are merged
and the wSOL account is closed once at the end. Either the whole round-trip
lands or nothing does — there is no state where the buy filled and the sell
didn't.

The platform `feeBps` (when set) is charged **once**, off-chain, on
`buy_notional + sell_notional` SOL volume: both CPI legs run at
`fee_bps = 0`, and when tip and fee go to the same wallet they collapse
into a single transfer instruction. Quote mint is SOL.

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




## OpenAPI

````yaml openapi-spec/trading.yaml post /swap/sol/buy-sell
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/buy-sell:
    post:
      summary: Atomic buy → sell round-trip
      description: >
        SOL → token → SOL on the same mint, **both legs in one transaction**.


        The sell leg is chained onto the buy leg's slippage floor, so it can
        never

        overdraw what the buy actually delivered; the two ATA creations are
        merged

        and the wSOL account is closed once at the end. Either the whole
        round-trip

        lands or nothing does — there is no state where the buy filled and the
        sell

        didn't.


        The platform `feeBps` (when set) is charged **once**, off-chain, on

        `buy_notional + sell_notional` SOL volume: both CPI legs run at

        `fee_bps = 0`, and when tip and fee go to the same wallet they collapse

        into a single transfer instruction. Quote mint is SOL.


        Errors answer **HTTP 200** with `success:false` and an `error` string.
      operationId: buySell
      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/BuySellRequest'
            examples:
              uniform:
                summary: Same SOL size for every wallet
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  solAmount: 0.1
                  slippageBps: 500
              perWallet:
                summary: Per-wallet sizes, route pinned to one venue
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                    - 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  amounts:
                    - 0.05
                    - 0.15
                  includeDex: pumpswap
                  maxHops: 1
      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/BuyResponse'
              example:
                success: true
                transactions:
                  - 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWJ...
                amountsOut:
                  - 98342112
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    BuySellRequest:
      type: object
      description: |
        SOL → token → SOL atomic round-trip on the SAME mint, both legs in one
        transaction. The sell leg is chained onto the buy leg's slippage floor,
        so it can never overdraw what the buy actually delivered.
      properties:
        walletAddresses:
          type: array
          items:
            type: string
          minItems: 1
        tokenAddress:
          type: string
          description: The mint bought and sold back.
        solAmount:
          type: number
          description: >-
            Uniform SOL amount per wallet for the buy leg. Required if `amounts`
            not provided.
          example: 0.1
        amounts:
          type: array
          items:
            type: number
          description: >-
            Per-wallet SOL amounts for the buy leg (takes precedence over
            `solAmount`).
        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, off-chain, on
            `buy_notional + sell_notional` SOL volume — both CPI legs run at
            `fee_bps = 0`, and tip + fee to the same wallet collapse into a
            single transfer instruction.
        jitoDontFront:
          type: boolean
          description: >-
            Append the JITO_DONT_FRONT marker. Only safe for a single
            non-bundled tx.
        maxHops:
          type: integer
          minimum: 1
          maximum: 3
        includeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
          description: Only route through these DEXes (array or CSV). Applies to both legs.
        excludeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
          description: Never route through these DEXes. Wins over `includeDex`.
        encoding:
          type: string
          enum:
            - base58
            - base64
          default: base64
      required:
        - walletAddresses
        - tokenAddress
    BuyResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        transactions:
          type: array
          items:
            type: string
          description: Unsigned transactions ready to be signed and submitted
        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. This is what the

            transaction actually delivers (its on-chain `min_return`) — it can
            sit

            below the `amountOut` a prior `/quote` returned when the best-priced

            plan didn't fit the wire and a lower-output alternative was served.
      required:
        - success
        - transactions
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        details:
          type: string
      required:
        - success
        - error

````