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

# Build a liquidity transaction

> Returns transaction data a caller can show to a wallet for signing when adding, removing, collecting, or burning a liquidity position.

```bash theme={null}
curl -X POST "https://staging-api.struct.to/v1/trading/liquidity/tx/build?fields=short" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"chain_id":8453,"wallet_address":"0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51","protocol":"uniswap_v4","operation":"mint_position","pool_id":"0x1111111111111111111111111111111111111111111111111111111111111111","tick_lower":-180,"tick_upper":60,"amount0_max_raw":"1500000000000000000","amount1_max_raw":"3700000000","slippage_bps":50}'
```

```json Response (Long) theme={null}
{
  "trade_id": "7c4a8d09-ca37-62af-61d5-3583ec55ad30",
  "status": "built",
  "chain_id": "8453",
  "chain_family": "evm",
  "wallet_address": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
  "protocol": "uniswap_v4",
  "operation": "mint_position",
  "warnings": [
    "Execute Permit2 approvals before supplying liquidity."
  ],
  "position": {
    "protocol": "uniswap_v4",
    "pool_id": "0x1111111111111111111111111111111111111111111111111111111111111111",
    "currency0": "0x0000000000000000000000000000000000000000",
    "currency1": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "fee": 3000,
    "tick_spacing": 60,
    "hooks": "0x0000000000000000000000000000000000000000",
    "tick_lower": -180,
    "tick_upper": 60,
    "liquidity_raw": "250000000",
    "amount0_max_raw": "1500000000000000000",
    "amount1_max_raw": "3700000000",
    "current_tick": -120,
    "sqrt_price_x96": "12345678901234567890",
    "active_liquidity_raw": "1000000000"
  },
  "evm": {
    "to": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "from": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
    "data": "0x12aa3caf",
    "value": "0",
    "chain_id": 4663,
    "approval_address": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "approvals": [
      {
        "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "spender": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
        "amount": "100000000"
      }
    ]
  },
  "permit2_approvals": [
    {
      "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
      "spender": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
      "amount": "3700000000",
      "expiration_unix_seconds": 1784265827
    }
  ],
  "expires_at": "2026-09-21T13:10:00Z"
}
```

```jsonc Response (Short) theme={null}
{
  "id": "7c4a8d09-ca37-62af-61d5-3583ec55ad30",
  "st": "built",
  "ci": "8453",
  "cf": "evm",
  "w": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
  "pr": "uniswap_v4",
  "op": "mint_position",
  "wn": [
    "Execute Permit2 approvals before supplying liquidity."
  ],
  "pos": {
    "pr": "uniswap_v4",
    "p": "0x1111111111111111111111111111111111111111111111111111111111111111",
    "c0": "0x0000000000000000000000000000000000000000",
    "c1": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "f": 3000,
    "ts": 60,
    "h": "0x0000000000000000000000000000000000000000",
    "tl": -180,
    "tu": 60,
    "lq": "250000000",
    "a0x": "1500000000000000000",
    "a1x": "3700000000",
    "ctk": -120,
    "sp": "12345678901234567890",
    "al": "1000000000"
  },
  "evm": {
    "to": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "fr": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
    "d": "0x12aa3caf",
    "v": "0",
    "ci": 4663,
    "aa": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "ap": [
      {
        "tk": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "sp": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
        "a": "100000000"
      }
    ]
  },
  "p2": [
    {
      "tk": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "p2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
      "sp": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
      "a": "3700000000",
      "ex": 1784265827
    }
  ],
  "ea": "2026-09-21T13:10:00Z"
}
```


## OpenAPI

````yaml onchain-openapi.json POST /trading/liquidity/tx/build
openapi: 3.1.0
info:
  title: Struct On-chain API
  description: >-
    RESTful API for token market data, discovery, holders, audits, and trader
    analytics across supported chains. Pass `fields=short` or header
    `x-field-names: short` for abbreviated keys. HTTP defaults to `long`. Token
    candlesticks, token trades and wallet batch trades also support
    `fields=array` for typed positional rows.
  version: 1.0.0
servers:
  - url: https://staging-api.struct.to/v1
    description: Staging
security:
  - ApiKey: []
paths:
  /trading/liquidity/tx/build:
    post:
      tags:
        - DEX Trading
      summary: Build a liquidity transaction
      description: >-
        Returns transaction data a caller can show to a wallet for signing when
        adding, removing, collecting, or burning a liquidity position.
      operationId: post_dex_trading_liquidity_tx_build
      parameters:
        - name: x-field-names
          in: header
          required: false
          description: >-
            Select long (full) or short (abbreviated) field names. HTTP defaults
            to `long`. Takes precedence over `fields`. See [Response
            Format](/api-reference/response-format#long-and-short-field-names).
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
        - name: fields
          in: query
          required: false
          description: >-
            Same as `x-field-names`. Use `long` or `short`. HTTP defaults to
            `long`. Ignored when the header is set. `field_names` is accepted as
            an alias.
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LiquidityTransactionBuildRequest'
            example:
              chain_id: 8453
              wallet_address: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
              protocol: uniswap_v4
              operation: mint_position
              pool_id: >-
                0x1111111111111111111111111111111111111111111111111111111111111111
              tick_lower: -180
              tick_upper: 60
              amount0_max_raw: '1500000000000000000'
              amount1_max_raw: '3700000000'
              slippage_bps: 50
        required: true
      responses:
        '200':
          description: Liquidity transaction data to sign
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BuildLiquidityTransactionResponse'
              examples:
                long:
                  summary: Response (Long)
                  value:
                    trade_id: 7c4a8d09-ca37-62af-61d5-3583ec55ad30
                    status: built
                    chain_id: '8453'
                    chain_family: evm
                    wallet_address: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                    protocol: uniswap_v4
                    operation: mint_position
                    warnings:
                      - Execute Permit2 approvals before supplying liquidity.
                    position:
                      protocol: uniswap_v4
                      pool_id: >-
                        0x1111111111111111111111111111111111111111111111111111111111111111
                      currency0: '0x0000000000000000000000000000000000000000'
                      currency1: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                      fee: 3000
                      tick_spacing: 60
                      hooks: '0x0000000000000000000000000000000000000000'
                      tick_lower: -180
                      tick_upper: 60
                      liquidity_raw: '250000000'
                      amount0_max_raw: '1500000000000000000'
                      amount1_max_raw: '3700000000'
                      current_tick: -120
                      sqrt_price_x96: '12345678901234567890'
                      active_liquidity_raw: '1000000000'
                    evm:
                      to: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      from: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                      data: '0x12aa3caf'
                      value: '0'
                      chain_id: 4663
                      approval_address: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      approvals:
                        - token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          spender: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                          amount: '100000000'
                    permit2_approvals:
                      - token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                        permit2: '0x000000000022D473030F116dDEE9F6B43aC78BA3'
                        spender: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                        amount: '3700000000'
                        expiration_unix_seconds: 1784265827
                    expires_at: '2026-09-21T13:10:00Z'
                short:
                  summary: Response (Short)
                  value:
                    id: 7c4a8d09-ca37-62af-61d5-3583ec55ad30
                    st: built
                    ci: '8453'
                    cf: evm
                    w: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                    pr: uniswap_v4
                    op: mint_position
                    wn:
                      - Execute Permit2 approvals before supplying liquidity.
                    pos:
                      pr: uniswap_v4
                      p: >-
                        0x1111111111111111111111111111111111111111111111111111111111111111
                      c0: '0x0000000000000000000000000000000000000000'
                      c1: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                      f: 3000
                      ts: 60
                      h: '0x0000000000000000000000000000000000000000'
                      tl: -180
                      tu: 60
                      lq: '250000000'
                      a0x: '1500000000000000000'
                      a1x: '3700000000'
                      ctk: -120
                      sp: '12345678901234567890'
                      al: '1000000000'
                    evm:
                      to: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      fr: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                      d: '0x12aa3caf'
                      v: '0'
                      ci: 4663
                      aa: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      ap:
                        - tk: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          sp: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                          a: '100000000'
                    p2:
                      - tk: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                        p2: '0x000000000022D473030F116dDEE9F6B43aC78BA3'
                        sp: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                        a: '3700000000'
                        ex: 1784265827
                    ea: '2026-09-21T13:10:00Z'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DexTradingErrorEnvelope'
        '501':
          description: No liquidity route available for the requested operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DexTradingErrorEnvelope'
components:
  schemas:
    LiquidityTransactionBuildRequest:
      type: object
      required:
        - chain_id
        - wallet_address
        - protocol
        - operation
        - pool_id
      properties:
        chain_id:
          $ref: '#/components/schemas/TradingChainId'
          description: Chain id. Use `-1` for Solana or an EVM chain id such as `4663`.
        wallet_address:
          type: string
          description: >-
            Wallet that owns the position or supplies tokens and signs the
            returned transaction.
        recipient_address:
          type:
            - string
            - 'null'
          description: >-
            Wallet that receives position NFTs or collected tokens. Defaults to
            `wallet_address`.
        protocol:
          $ref: '#/components/schemas/LiquidityProtocol'
          description: Liquidity protocol to build for.
        operation:
          $ref: '#/components/schemas/LiquidityOperation'
          description: Liquidity action to build.
        pool_id:
          type: string
          description: Uniswap V4 pool id as a 32-byte hex string.
        tick_lower:
          type:
            - integer
            - 'null'
          format: int32
          description: Lower tick for minting or increasing a position.
        tick_upper:
          type:
            - integer
            - 'null'
          format: int32
          description: Upper tick for minting or increasing a position.
        token_id:
          type:
            - string
            - 'null'
          description: >-
            Position NFT token id for increasing, decreasing, collecting, or
            burning.
        liquidity_raw:
          type:
            - string
            - 'null'
          description: >-
            Position liquidity amount. Required for direct increase/decrease
            unless amount caps are supplied for add operations.
        amount0_max_raw:
          type:
            - string
            - 'null'
          description: Maximum token0 amount the transaction may spend.
        amount1_max_raw:
          type:
            - string
            - 'null'
          description: Maximum token1 amount the transaction may spend.
        amount0_min_raw:
          type:
            - string
            - 'null'
          description: Minimum token0 amount to receive when decreasing or burning.
        amount1_min_raw:
          type:
            - string
            - 'null'
          description: Minimum token1 amount to receive when decreasing or burning.
        liquidity_percentage_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Percentage of current position liquidity to remove, in basis points.
            `10000` means 100%.
          minimum: 0
        slippage_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Slippage tolerance in basis points, included in previews and
            guardrails.
          minimum: 0
        hook_data:
          type:
            - string
            - 'null'
          description: Optional data passed to pool hooks.
        deadline_unix_seconds:
          type:
            - integer
            - 'null'
          format: int64
          description: Optional execution deadline in Unix seconds.
          minimum: 0
        idempotency_key:
          type:
            - string
            - 'null'
          description: Caller-supplied key used to make repeated requests safe.
        metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TradeRequestMetadata'
              description: Caller metadata echoed in tracking records.
    BuildLiquidityTransactionResponse:
      type: object
      required:
        - trade_id
        - status
        - chain_id
        - chain_family
        - wallet_address
        - protocol
        - operation
        - position
        - permit2_approvals
        - expires_at
        - warnings
      properties:
        trade_id:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/TradeStatus'
        chain_id:
          type: string
        chain_family:
          $ref: '#/components/schemas/TradingChainFamily'
        wallet_address:
          type: string
        protocol:
          $ref: '#/components/schemas/LiquidityProtocol'
        operation:
          $ref: '#/components/schemas/LiquidityOperation'
        position:
          $ref: '#/components/schemas/LiquidityPositionPreview'
        evm:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmTransactionRequest'
        solana:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaTransactionRequest'
        permit2_approvals:
          type: array
          items:
            $ref: '#/components/schemas/EvmPermit2AllowanceRequirement'
        expires_at:
          type: string
          format: date-time
        warnings:
          type: array
          items:
            type: string
    DexTradingErrorEnvelope:
      type: object
      required:
        - success
        - message
        - error_code
        - category
        - retryable
        - data
        - info
      properties:
        success:
          type: boolean
        message:
          type: string
        error_code:
          type: string
        category:
          type: string
        retryable:
          type: boolean
        data:
          type: 'null'
          description: Errors have no response data; this field is always null.
        info:
          $ref: '#/components/schemas/DexTradingErrorInfo'
    TradingChainId:
      type: integer
      format: int64
      example: 4663
    LiquidityProtocol:
      type: string
      enum:
        - uniswap_v4
    LiquidityOperation:
      type: string
      enum:
        - mint_position
        - increase_liquidity
        - decrease_liquidity
        - collect_fees
        - burn_position
    TradeRequestMetadata:
      type: object
      properties:
        reference_id:
          type:
            - string
            - 'null'
          description: Caller-side order, quote, or request identifier.
        source:
          type:
            - string
            - 'null'
          description: Client application or integration label.
        user_id:
          type:
            - string
            - 'null'
          description: Caller-side user identifier.
        account_id:
          type:
            - string
            - 'null'
          description: Caller-side wallet or account grouping identifier.
        attributes:
          type:
            - object
            - 'null'
          description: Additional caller-defined string attributes.
          additionalProperties:
            type: string
          propertyNames:
            type: string
    TradeStatus:
      type: string
      enum:
        - built
        - submitted
        - confirmed
        - failed
        - expired
    TradingChainFamily:
      type: string
      enum:
        - evm
        - solana
    LiquidityPositionPreview:
      type: object
      required:
        - protocol
        - pool_id
        - currency0
        - currency1
        - fee
        - tick_spacing
        - hooks
      properties:
        protocol:
          $ref: '#/components/schemas/LiquidityProtocol'
        pool_id:
          type: string
        currency0:
          type: string
        currency1:
          type: string
        fee:
          type: integer
          format: int32
          minimum: 0
        tick_spacing:
          type: integer
          format: int32
        hooks:
          type: string
        tick_lower:
          type:
            - integer
            - 'null'
          format: int32
        tick_upper:
          type:
            - integer
            - 'null'
          format: int32
        token_id:
          type:
            - string
            - 'null'
        liquidity_raw:
          type:
            - string
            - 'null'
        amount0_max_raw:
          type:
            - string
            - 'null'
        amount1_max_raw:
          type:
            - string
            - 'null'
        amount0_min_raw:
          type:
            - string
            - 'null'
        amount1_min_raw:
          type:
            - string
            - 'null'
        current_tick:
          type:
            - integer
            - 'null'
          format: int32
        sqrt_price_x96:
          type:
            - string
            - 'null'
        active_liquidity_raw:
          type:
            - string
            - 'null'
    EvmTransactionRequest:
      type: object
      required:
        - to
        - from
        - data
        - value
        - chain_id
        - approvals
      properties:
        to:
          type: string
        from:
          type: string
        data:
          type: string
        value:
          type: string
        gas_limit:
          type:
            - string
            - 'null'
        gas_price:
          type:
            - string
            - 'null'
        max_fee_per_gas:
          type:
            - string
            - 'null'
        max_priority_fee_per_gas:
          type:
            - string
            - 'null'
        nonce:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        chain_id:
          type: integer
          format: int64
        approval_address:
          type:
            - string
            - 'null'
        approvals:
          type: array
          items:
            $ref: '#/components/schemas/EvmApprovalRequirement'
        approval_transactions:
          type: array
          items:
            $ref: '#/components/schemas/EvmWireTransaction'
          description: >-
            Approval transactions to send before the swap, in this order. May

            include resetting an existing allowance to zero and Permit2
            approvals.

            After they confirm, build the swap again before signing it.
    SolanaTransactionRequest:
      type: object
      properties:
        transaction:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaSerializedTransaction'
        instructions:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaInstructionBundle'
        last_valid_block_height:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        recent_blockhash:
          type:
            - string
            - 'null'
    EvmPermit2AllowanceRequirement:
      type: object
      required:
        - token
        - permit2
        - spender
        - amount
      properties:
        token:
          type: string
        permit2:
          type: string
        spender:
          type: string
        amount:
          type: string
        expiration_unix_seconds:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
    DexTradingErrorInfo:
      type: object
      required:
        - version
        - credits_consumed
        - compute_time_ms
      properties:
        version:
          type: string
        credits_consumed:
          type: integer
          format: int32
          minimum: 0
        compute_time_ms:
          type: number
          format: float
    EvmApprovalRequirement:
      type: object
      required:
        - token
        - spender
      properties:
        token:
          type: string
        spender:
          type: string
        amount:
          type:
            - string
            - 'null'
    EvmWireTransaction:
      type: object
      description: An unsigned EVM transaction. Sign and send it from `from`.
      required:
        - chain_id
        - from
        - to
        - data
        - value
      properties:
        chain_id:
          type: integer
          format: int64
          minimum: 0
        from:
          type: string
        to:
          type: string
        data:
          type: string
        value:
          type: string
    SolanaSerializedTransaction:
      type: object
      required:
        - serialized
        - variant
      properties:
        serialized:
          type: string
        variant:
          $ref: '#/components/schemas/SolanaTransactionVariant'
    SolanaInstructionBundle:
      type: object
      required:
        - compute_budget_instructions
        - setup_instructions
        - swap_instructions
        - cleanup_instructions
        - address_lookup_table_addresses
      properties:
        compute_budget_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        setup_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        swap_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        cleanup_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        address_lookup_table_addresses:
          type: array
          items:
            type: string
    SolanaTransactionVariant:
      type: string
      enum:
        - legacy
        - versioned
        - v1
    SolanaInstruction:
      type: object
      required:
        - program_id
        - accounts
        - data
      properties:
        program_id:
          type: string
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstructionAccount'
        data:
          type: string
    SolanaInstructionAccount:
      type: object
      required:
        - pubkey
        - is_signer
        - is_writable
      properties:
        pubkey:
          type: string
        is_signer:
          type: boolean
        is_writable:
          type: boolean
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Secret API key (`sk_*`) or JWT public key (`pk_jwt_*`).

````

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