> ## 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.

# Get Allowance

> In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users must set
a token allowance to authorize the protocol to spend a specified amount of their
tokens on their behalf.

This is a crucial step before engaging in any transactions or operations within
these protocols, ensuring that the protocol has the necessary permissions to manage
the user's tokens securely and efficiently.



## OpenAPI

````yaml /v1/combined_spec.json get /v1/generic/allowance
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:
  /v1/generic/allowance:
    get:
      tags:
        - Universal
      summary: Get Allowance
      description: >-
        In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users
        must set

        a token allowance to authorize the protocol to spend a specified amount
        of their

        tokens on their behalf.


        This is a crucial step before engaging in any transactions or operations
        within

        these protocols, ensuring that the protocol has the necessary
        permissions to manage

        the user's tokens securely and efficiently.
      operationId: v1_generic_allowance
      parameters:
        - name: chain
          in: query
          required: true
          schema:
            type: string
            enum:
              - arbitrum
              - base
              - ethereum
            title: Chain
            default: arbitrum
        - name: user
          in: query
          required: false
          schema:
            type: string
            default: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
            title: User
          description: The user to get the ERC20 allowance of.
        - name: token
          in: query
          required: true
          schema:
            type: string
            title: Token
            description: >-
              A token identifier - either a supported symbol (e.g., USDC, WETH)
              or a valid Ethereum address (0x...)
            examples:
              - USDC
              - WETH
              - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
            default: USDC
          description: >-
            The symbol or address of the token for which the allowance is
            checked.
        - name: contract
          in: query
          required: true
          schema:
            anyOf:
              - type: string
                enum:
                  - AaveV3Pool
                  - AerodromeBasicRouter
                  - AerodromeSlipstreamRouter
                  - AerodromeSlipstreamNonfungiblePositionManager
                  - UniswapV3Router
                  - UniswapV3NFTPositionManager
                  - MorphoMarket
                  - SkyDaiUsdsConverter
                  - SkyUsdcUsdsConverter
                  - SkyUsdsVault
                  - PendleRouter
                  - OdosRouter
                  - EthenaVault
              - type: string
            title: Contract
            default: AaveV3Pool
          description: The name or address of the contract to check allowance for.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllowanceInfoResponse'
        '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.universal.generic_allowance(chain=models.V1GenericAllowanceChain.ARBITRUM, token="USDC", contract=models.V1GenericAllowanceContractEnum.AAVE_V3_POOL, user="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B")

                # 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.universal.genericAllowance({
                chain: "arbitrum",
                user: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
                token: "USDC",
                contract: "AaveV3Pool",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    AllowanceInfoResponse:
      properties:
        amount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Amount
          description: Amount of tokens allowed to be spent by spender
          examples:
            - 1.5
        decimals:
          type: integer
          title: Decimals
          description: Number of decimals of the token
          examples:
            - 18
        token_symbol:
          type: string
          title: Token Symbol
          description: Symbol of the token.
          examples:
            - WETH
        token_address:
          type: string
          title: Token Address
          description: Address of the token
          examples:
            - '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
        contract_address:
          type: string
          title: Contract Address
          description: Address of the contract
          examples:
            - '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
      type: object
      required:
        - amount
        - decimals
        - token_symbol
        - token_address
        - contract_address
      title: AllowanceInfoResponse
      description: Response model for token allowance information.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````