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

# Build

> 
Builds an **unsigned XDR** for a quote.

If **Gasless Trustline Swap** is enabled, the XDR must be signed by both the user and the sponsor.

#### ⚡ Gasless Trustline Flow
When enabled, the transaction will include **all the operations required to perform the swap**, plus extra operations to:
- 💰 **Buy 0.5 XLM** — The user purchases 0.5 XLM and sends it to the sponsor wallet.
- 🛡 **Sponsor Trustline Reserve** — The sponsor wallet covers the reserve required to open the user’s trustline.

> **Note:** The `gaslessTrustline` feature only works with a swap on the **Stellar Classic DEX**, and will be applied **only to the first swap for a specific user**.

On mainnet, an EXACT_OUT quote against the Soroswap Aggregator sizes a fixed spend rather than an exact output: `amountIn` and `otherAmountThreshold` both become the amount that will actually be spent, and `amountOut` is the minimum you will receive, with any surplus delivered on top. SDEX quotes and every testnet quote are unaffected — EXACT_OUT there still means an exact output behind a slipped maximum input.




## OpenAPI

````yaml POST /quote/build
openapi: 3.0.0
info:
  title: Soroswap API
  description: >+

    # 🚀 Soroswap API


    **Soroswap.Finance** is both an **Automated Market Maker (AMM)** and a **DEX
    Aggregator** on the Stellar blockchain.


    It aggregates liquidity from Soroban DEXes (**Soroswap, Phoenix, Aqua and
    Comet(TBA)**), and the **Stellar Classic DEX** — giving you **the best trade
    routes, liquidity tools, and real-time market data**.


    ---


    ## 📋 What You Can Do


    - 🔄 **Quote** – Get the best trade route between two assets with
    split-routing logic across AMMs and SDEX.  

    - 🧱 **Build** – Generate and simulate unsigned transactions (XDR) for swaps
    or liquidity actions.  

    - 🚀 **Send** – Submit signed transactions via Soroban RPC or Horizon.

    - ⚡ **Gasless Trustlines** – Use `gaslessTrustline` in `/quote` to open
    trustlines for users without requiring them to hold XLM or deal with
    trustline setup themselves.

    - 💰 **Platform Fees** – Add your own fee to user swaps with
    `platformFee`.  

    - 💧 **Liquidity** – Create LPs, add liquidity, remove liquidity.  

    - 💲 **Price** – Get real-time token prices.  

    - 🧠 **Pools** – View detailed pool information for Soroswap AMM.


    📮 **[Downnload the Postman Collection
    here](https://drive.google.com/drive/folders/1G-LQYE2EojPWP1CSuuS_tDb9vjYbFR6E?usp=drive_link)**

  version: '1.0'
  contact: {}
  x-logo:
    url: https://links.paltalabs.io/soroswap-full.svg
    backgroundColor: '#0e0e0e'
    altText: Soroswap Logo
    href: https://soroswap.finance
servers: []
security: []
tags: []
paths:
  /quote/build:
    post:
      tags:
        - Quote
      summary: Build
      description: >

        Builds an **unsigned XDR** for a quote.


        If **Gasless Trustline Swap** is enabled, the XDR must be signed by both
        the user and the sponsor.


        #### ⚡ Gasless Trustline Flow

        When enabled, the transaction will include **all the operations required
        to perform the swap**, plus extra operations to:

        - 💰 **Buy 0.5 XLM** — The user purchases 0.5 XLM and sends it to the
        sponsor wallet.

        - 🛡 **Sponsor Trustline Reserve** — The sponsor wallet covers the
        reserve required to open the user’s trustline.


        > **Note:** The `gaslessTrustline` feature only works with a swap on the
        **Stellar Classic DEX**, and will be applied **only to the first swap
        for a specific user**.


        On mainnet, an EXACT_OUT quote against the Soroswap Aggregator sizes a
        fixed spend rather than an exact output: `amountIn` and
        `otherAmountThreshold` both become the amount that will actually be
        spent, and `amountOut` is the minimum you will receive, with any surplus
        delivered on top. SDEX quotes and every testnet quote are unaffected —
        EXACT_OUT there still means an exact output behind a slipped maximum
        input.
      operationId: SwapController_buildQuote
      parameters:
        - name: network
          required: false
          in: query
          description: Network on which the operation will be performed
          schema:
            enum:
              - testnet
              - mainnet
            type: string
      requestBody:
        required: true
        description: Data required to build the quote
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuildQuoteDto'
            examples:
              regularExactIn:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10000000'
                    amountOut: '9067253'
                    otherAmountThreshold: '9067253'
                    tradeType: EXACT_IN
                    priceImpactPct: '0.50'
                    platform: aggregator
                    rawTrade:
                      amountIn: '10000000'
                      amountOutMin: '9067253'
                      distribution:
                        - protocol_id: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CD25MNVTZDL4Y3XBCPCJXGXATV5WUHHOWMYFF4YBEGU5FCPGMYTVG5JY
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                          parts: 10
                          is_exact_in: true
                    routePlan:
                      - swapInfo:
                          protocol: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CD25MNVTZDL4Y3XBCPCJXGXATV5WUHHOWMYFF4YBEGU5FCPGMYTVG5JY
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                        percent: '100'
                  to: GCSQJ7TCEVWXK2JZPTTTCJCVZZNMQXEJWVHIOCUAQHWNJSXKHX7OHVUW
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                summary: >-
                  Data required to build the XDR for a regular EXACT_IN
                  aggregator swap
              sdexExactOut:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10500000'
                    amountOut: '10000000'
                    otherAmountThreshold: '10500000'
                    tradeType: EXACT_OUT
                    priceImpactPct: '0.30'
                    platform: sdex
                    rawTrade:
                      source_asset_type: credit_alphanum12
                      source_amount: '10000000'
                      max_source_amount: '10500000'
                      destination_asset_type: credit_alphanum12
                      destination_amount: '10000000'
                      path: []
                    routePlan:
                      - swapInfo:
                          protocol: sdex
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                        percent: '100'
                  to: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                summary: Data required to build the XDR for a SDEX EXACT_OUT swap
              gaslessTrustlineExactIn:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10000000'
                    amountOut: '8567253'
                    otherAmountThreshold: '8467253'
                    tradeType: EXACT_IN
                    priceImpactPct: '0.50'
                    platform: sdex
                    gaslessTrustline: create
                    rawTrade:
                      source_asset_type: credit_alphanum12
                      source_amount: '10000000'
                      destination_asset_type: credit_alphanum12
                      destination_amount: '9067253'
                      min_destination_amount: '9000000'
                      path: []
                      trustlineOperation:
                        source_asset_type: credit_alphanum12
                        source_amount: '0.5000000'
                        max_source_amount: '0.5100000'
                        destination_asset_type: native
                        destination_amount: '0.5000000'
                        path: []
                      netAmount: '8567253'
                      otherNetAmountThreshold: '8467253'
                    trustlineInfo:
                      trustlineCostAssetIn: '0.5000000'
                      trustlineCostAssetOut: '0.5000000'
                    routePlan:
                      - swapInfo:
                          protocol: sdex
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                        percent: '100'
                  to: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  sponsor: GDFRQKZH2F6QPZDW7YNWCV3H6FGUQZ3XAJS7XEZQVYZSQYB4SVPQXVYB
                summary: >-
                  Data required to build the XDR for a gasless trustline
                  EXACT_IN swap - sponsor lends 0.5 XLM for the trustline and
                  user repays via output asset
              gaslessTrustlineExactOut:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10500000'
                    amountOut: '10000000'
                    otherAmountThreshold: '10700000'
                    tradeType: EXACT_OUT
                    priceImpactPct: '0.50'
                    platform: sdex
                    gaslessTrustline: create
                    rawTrade:
                      source_asset_type: credit_alphanum12
                      source_amount: '10000000'
                      max_source_amount: '10200000'
                      destination_asset_type: credit_alphanum12
                      destination_amount: '10000000'
                      path: []
                      trustlineOperation:
                        source_asset_type: credit_alphanum12
                        source_amount: '0.5000000'
                        max_source_amount: '0.5100000'
                        destination_asset_type: native
                        destination_amount: '0.5000000'
                        path: []
                      netAmount: '10500000'
                      otherNetAmountThreshold: '10700000'
                    trustlineInfo:
                      trustlineCostAssetIn: '0.5000000'
                      trustlineCostAssetOut: '0.0500000'
                    routePlan:
                      - swapInfo:
                          protocol: sdex
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                        percent: '100'
                  to: GCSQJ7TCEVWXK2JZPTTTCJCVZZNMQXEJWVHIOCUAQHWNJSXKHX7OHVUW
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  sponsor: GDFRQKZH2F6QPZDW7YNWCV3H6FGUQZ3XAJS7XEZQVYZSQYB4SVPQXVYB
                summary: >-
                  Data required to build the XDR for a gasless trustline
                  EXACT_OUT swap - total input includes trustline setup cost
              sorobanSponsoredStep1:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10000000'
                    amountOut: '9067253'
                    otherAmountThreshold: '9067253'
                    tradeType: EXACT_IN
                    priceImpactPct: '0.50'
                    platform: aggregator
                    rawTrade:
                      amountIn: '10000000'
                      amountOutMin: '9067253'
                      distribution:
                        - protocol_id: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                          parts: 10
                          is_exact_in: true
                  to: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  sponsor: GDFRQKZH2F6QPZDW7YNWCV3H6FGUQZ3XAJS7XEZQVYZSQYB4SVPQXVYB
                summary: >-
                  Step 1: Soroban sponsored transaction - API returns unsigned
                  XDR for user to sign
              sorobanSponsoredStep2:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10000000'
                    amountOut: '9067253'
                    otherAmountThreshold: '9067253'
                    tradeType: EXACT_IN
                    priceImpactPct: '0.50'
                    platform: aggregator
                    rawTrade:
                      amountIn: '10000000'
                      amountOutMin: '9067253'
                      distribution:
                        - protocol_id: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                          parts: 10
                          is_exact_in: true
                  to: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                  sponsor: GDFRQKZH2F6QPZDW7YNWCV3H6FGUQZ3XAJS7XEZQVYZSQYB4SVPQXVYB
                  signedUserXdr: AAAAAgAAAABiSu3MsKtQvDuQO5i2b...
                summary: >-
                  Step 2: Soroban sponsored transaction - Send user-signed XDR,
                  API returns fee bump XDR for sponsor to sign
              withPlatformFee:
                value:
                  quote:
                    assetIn: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                    assetOut: CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                    amountIn: '10000000'
                    amountOut: '9067253'
                    otherAmountThreshold: '9067253'
                    tradeType: EXACT_IN
                    priceImpactPct: '0.50'
                    platform: aggregator
                    platformFee:
                      feeBps: 50
                      feeAmount: 50000
                    rawTrade:
                      amountIn: '10000000'
                      amountOutMin: '9067253'
                      distribution:
                        - protocol_id: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                          parts: 10
                          is_exact_in: true
                    routePlan:
                      - swapInfo:
                          protocol: soroswap
                          path:
                            - >-
                              CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
                            - >-
                              CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV
                        percent: '100'
                  to: GCSQJ7TCEVWXK2JZPTTTCJCVZZNMQXEJWVHIOCUAQHWNJSXKHX7OHVUW
                  from: GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK
                summary: >-
                  Data required to build the XDR for a quote whose platform fee
                  came from the partner rate
      responses:
        '200':
          description: XDR built successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  xdr:
                    type: string
                    example: >-
                      AAAAAgAAAAB8shYDi1JO9x2/3jMeVzK2IGtrsFVWLCL4uHRJf+YPyAAAA+gCzi7HAAAApgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAABc12cL...
                    description: Transaction XDR ready for signing and execution
        '400':
          description: Invalid quote data or missing required fields
        '409':
          description: The fee rate changed since the quote was issued; request a new quote
        '428':
          description: Precondition Required - Multi-step action needed
          content:
            application/json:
              schema:
                oneOf:
                  - title: 'Step 1: User Signature Required'
                    type: object
                    properties:
                      message:
                        type: string
                        example: User signature required for sponsored transaction
                      action:
                        type: string
                        example: SIGN_USER_TRANSACTION
                      actionData:
                        type: object
                        properties:
                          xdr:
                            type: string
                            example: AAAAAgAAAAB8shYDi1JO9x2...
                          step:
                            type: number
                            example: 1
                          totalSteps:
                            type: number
                            example: 2
                          description:
                            type: string
                            example: >-
                              Sign the transaction with the user wallet and send
                              back the signed XDR
                  - title: 'Step 2: Sponsor Signature Required'
                    type: object
                    properties:
                      message:
                        type: string
                        example: Sponsor signature required for fee bump transaction
                      action:
                        type: string
                        example: SIGN_SPONSOR_TRANSACTION
                      actionData:
                        type: object
                        properties:
                          xdr:
                            type: string
                            example: AAAABQAAAABiSu3MsKtQvDuQO5i2b...
                          step:
                            type: number
                            example: 2
                          totalSteps:
                            type: number
                            example: 2
                          description:
                            type: string
                            example: >-
                              Sign the fee bump transaction with the sponsor
                              wallet
components:
  schemas:
    BuildQuoteDto:
      type: object
      properties:
        quote:
          type: object
          description: The quote to build the XDR for
        from:
          type: string
          description: The wallet address that will send the funds
        to:
          type: string
          description: >-
            The wallet address that will receive the funds. If Gasless Trustline
            Swap is enabled, this is the wallet address must be the same as the
            from address (hence, don't provide this parameter)
        referralId:
          type: string
          description: >-
            Ignored. Fee destinations are no longer caller-supplied; the value
            you send is recorded so Soroswap can propose your payout address.
        sponsor:
          type: string
          description: >-
            The wallet address that will sponsor the transaction. Only required
            for Gasless Trustline Swap and Soroban sponsored transactions
        signedUserXdr:
          type: string
          description: >-
            The signed transaction XDR from Step 1 of Soroban sponsored
            transactions. Required for Step 2 when sponsor is provided for
            non-SDEX platforms.
      required:
        - quote

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.