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

# Collect fees

> Sweep the fees a position has earned into your account.



## OpenAPI

````yaml /v2/combined_spec.json post /v2/risk_yield/collect
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/risk_yield/collect:
    post:
      tags:
        - Risk Yield
      summary: Collect fees
      description: Sweep the fees a position has earned into your account.
      operationId: v2_risk_yield_collect
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RiskYieldCollectRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RiskYieldLiquidityResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI, models


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.risk_yield.risk_yield_collect(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", position_id=1076416, chain=models.RiskYieldCollectRequestChain.ROBINHOOD, gas_sponsorship=False, preview=False, slippage_pct="0.5", deadline_seconds=300)

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.riskYield.riskYieldCollect({
                owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
                chain: "robinhood",
                positionId: 1076416,
              });

              console.log(result);
            }

            run();
components:
  schemas:
    RiskYieldCollectRequest:
      properties:
        owner:
          type: string
          title: Owner
          description: The wallet that owns the Risk Yield Account.
          default: '0x06A9aF046187895AcFc7258450B15397CAc67400'
          examples:
            - '0x06A9aF046187895AcFc7258450B15397CAc67400'
        chain:
          type: string
          enum:
            - robinhood
          title: Chain
          description: Risk Yield is available on Robinhood Chain only.
          default: robinhood
          examples:
            - robinhood
        gas_sponsorship:
          type: boolean
          title: Gas Sponsorship
          description: >-
            Return EIP-712 typed data for the owner to sign instead of a
            transaction, so a sponsor can broadcast it.
          default: false
        preview:
          type: boolean
          title: Preview
          description: >-
            Return the plan and its simulation without building a transaction.
            Nothing is signed and nothing can be broadcast.
          default: false
        slippage_pct:
          anyOf:
            - type: number
              maximum: 10
              exclusiveMinimum: 0
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Slippage Pct
          description: >-
            How far the executed amounts may fall short of the quote before the
            transaction reverts. Memecoin pools move between the quote and the
            block that includes the transaction.
          default: '0.5'
        deadline_seconds:
          type: integer
          maximum: 3600
          minimum: 30
          title: Deadline Seconds
          description: How long the transaction stays valid once built.
          default: 300
        position_id:
          type: integer
          title: Position Id
          default: 1076416
          examples:
            - 1076416
        dex_version:
          $ref: '#/components/schemas/DexVersion'
          default: V3
        recipient:
          anyOf:
            - type: string
            - type: 'null'
          title: Recipient
      type: object
      required:
        - owner
        - position_id
      title: RiskYieldCollectRequest
      description: Sweep the fees a position has earned.
      default:
        owner: '0x06A9aF046187895AcFc7258450B15397CAc67400'
        chain: robinhood
        position_id: 1076416
    RiskYieldLiquidityResponse:
      properties:
        transaction:
          anyOf:
            - $ref: '#/components/schemas/UnsignedTransaction'
            - type: 'null'
        position_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Position Id
        range:
          anyOf:
            - $ref: '#/components/schemas/ResolvedRange'
            - type: 'null'
        plan:
          anyOf:
            - $ref: '#/components/schemas/DepositPlan'
            - type: 'null'
        expected_liquidity:
          anyOf:
            - type: string
            - type: 'null'
          title: Expected Liquidity
        liquidity_removed:
          anyOf:
            - type: string
            - type: 'null'
          title: Liquidity Removed
        amount0_min:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount0 Min
        amount1_min:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount1 Min
        steps:
          items:
            $ref: '#/components/schemas/PlanStep'
          type: array
          title: Steps
        simulation:
          anyOf:
            - $ref: '#/components/schemas/Simulation'
            - type: 'null'
        warnings:
          items:
            type: string
          type: array
          title: Warnings
      type: object
      title: RiskYieldLiquidityResponse
      description: The shape every liquidity-changing endpoint returns.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DexVersion:
      type: string
      enum:
        - V3
        - V4
      title: DexVersion
      description: >-
        Which Uniswap deployment a pool belongs to.


        v3 pools hold their own tokens and pay LPs the fee tier. v4 pools live
        in a

        shared PoolManager and may route the fee through a hook, which is where
        the

        launchpad pools' zero LP yield comes from.
    UnsignedTransaction:
      properties:
        chainId:
          type: string
          title: Chainid
          description: The chain id of the transaction
        data:
          type: string
          title: Data
          description: The data of the transaction
        from:
          type: string
          title: From
          description: The sender of the transaction
        gas:
          anyOf:
            - type: string
            - type: 'null'
          title: Gas
          description: The gas of the transaction
        to:
          type: string
          title: To
          description: The recipient of the transaction
        value:
          type: string
          title: Value
          description: The value of the transaction
        nonce:
          type: string
          title: Nonce
          description: The nonce of the address
        maxFeePerGas:
          type: string
          title: Maxfeepergas
          description: The max fee per gas of the transaction
        maxPriorityFeePerGas:
          type: string
          title: Maxpriorityfeepergas
          description: The max priority fee per gas of the transaction
      type: object
      required:
        - chainId
        - data
        - from
        - gas
        - to
        - value
        - nonce
        - maxFeePerGas
        - maxPriorityFeePerGas
      title: UnsignedTransaction
      example:
        chainId: '0x2105'
        data: >-
          0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d
        from: '0x4A83b4413CF41C3244027e1590E35a0F48403F0c'
        gas: '0x7a120'
        maxFeePerGas: '0x59682f00'
        maxPriorityFeePerGas: '0x3b9aca00'
        nonce: '0x5'
        to: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67'
        value: '0x0'
    ResolvedRange:
      properties:
        tick_lower:
          type: integer
          title: Tick Lower
        tick_upper:
          type: integer
          title: Tick Upper
        price_lower:
          type: string
          title: Price Lower
        price_upper:
          type: string
          title: Price Upper
        width_lower_pct:
          type: string
          title: Width Lower Pct
          description: How far below the current price the lower bound sits.
        width_upper_pct:
          type: string
          title: Width Upper Pct
        is_full_range:
          type: boolean
          title: Is Full Range
      type: object
      required:
        - tick_lower
        - tick_upper
        - price_lower
        - price_upper
        - width_lower_pct
        - width_upper_pct
        - is_full_range
      title: ResolvedRange
      description: >-
        A range after the API has snapped it to the pool's tick spacing.


        Returned because the range you asked for is rarely the range you get:
        ticks

        are discrete, and a 30% band becomes whichever usable ticks bracket it.
    DepositPlan:
      properties:
        amount0_desired:
          type: string
          title: Amount0 Desired
        amount1_desired:
          type: string
          title: Amount1 Desired
        amount0_min:
          type: string
          title: Amount0 Min
          description: The floor the transaction enforces after slippage.
        amount1_min:
          type: string
          title: Amount1 Min
        leftover0:
          type: string
          title: Leftover0
          default: '0'
        leftover1:
          type: string
          title: Leftover1
          default: '0'
        swap:
          anyOf:
            - $ref: '#/components/schemas/SwapPlan'
            - type: 'null'
          description: Present when one asset had to be traded for the other.
      type: object
      required:
        - amount0_desired
        - amount1_desired
        - amount0_min
        - amount1_min
      title: DepositPlan
      description: >-
        What will actually be deposited, and what is left over.


        A range fixes the ratio of the two assets, so a deposit rarely uses all
        of

        both. The leftovers are reported rather than silently swept: they stay
        in

        the account, and a caller who expected them to be used should know.
    PlanStep:
      properties:
        kind:
          $ref: '#/components/schemas/PlanStepKind'
        description:
          type: string
          title: Description
        contract:
          anyOf:
            - type: string
            - type: 'null'
          title: Contract
        token:
          anyOf:
            - type: string
            - type: 'null'
          title: Token
        amount:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount
      type: object
      required:
        - kind
        - description
      title: PlanStep
      description: >-
        One leg of a bundled transaction, in the order it executes.


        Every transact endpoint returns a single transaction; this is what is
        inside

        it, so a caller can show a person what they are about to sign.
    Simulation:
      properties:
        ok:
          type: boolean
          title: Ok
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        gas_used:
          anyOf:
            - type: integer
            - type: 'null'
          title: Gas Used
      type: object
      required:
        - ok
      title: Simulation
      description: >-
        The result of executing the transaction against current state.


        Meme tokens on this chain carry transfer taxes, blacklists and pause

        switches, none of which are visible from a pool's parameters. Simulating
        is

        the only way to find out before the owner signs.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    SwapPlan:
      properties:
        token_in:
          type: string
          title: Token In
        token_out:
          type: string
          title: Token Out
        amount_in:
          type: string
          title: Amount In
        amount_out_quoted:
          type: string
          title: Amount Out Quoted
        amount_out_min:
          type: string
          title: Amount Out Min
          description: The floor the transaction enforces, after slippage.
        price_impact_pct:
          anyOf:
            - type: string
            - type: 'null'
          title: Price Impact Pct
        pool_fee_ppm:
          anyOf:
            - type: integer
            - type: 'null'
          title: Pool Fee Ppm
      type: object
      required:
        - token_in
        - token_out
        - amount_in
        - amount_out_quoted
        - amount_out_min
      title: SwapPlan
      description: The swap leg of an entry or a rebalance.
    PlanStepKind:
      type: string
      enum:
        - APPROVE
        - PERMIT2_APPROVE
        - SWAP
        - MINT
        - INCREASE
        - DECREASE
        - COLLECT
        - BURN
        - TRANSFER
      title: PlanStepKind
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````