# Get Liquidity Amounts URL: /docs/api-reference/liquidity-pools/GetAmountsController_handle_v1 Get the amounts of tokens needed to provide liquidity to a pool based on the maximum you want to spend in one token. You can pass the max amount for both tokens and receive quotes for the two possible scenarios, this way you can check in a single call what option works based on the amounts your user has. E.g. your user wants to provide liquidity to the ETH-USDC pool, and they have 100 USDC and 100 ETH in their wallet. By passing both as the max amounts in `tokenXMaxAmount` you'll get two quotes. One telling how much ETH you need to provided if you send 100 USDC and another telling how much USDC you need to provide given 100 ETH. Then you can choose which one actually fits the liquidity your user has. **Note**: If only one of them is returned it means the price range is outside the current price, so only one token can be provided to create liquidity, the other will always be zero. ## GET /api/v1/liquidity/amounts Request: `GET https://api.notus.team/api/v1/liquidity/amounts` Authentication: send your project's API key in the `x-api-key` header. ```json { "description": "Get the amounts of tokens needed to provide liquidity to a pool based on the maximum you want to spend in one token. You can pass the max amount for both tokens and receive quotes for the two possible scenarios, this way you can check in a single call what option works based on the amounts your user has. E.g. your user wants to provide liquidity to the ETH-USDC pool, and they have 100 USDC and 100 ETH in their wallet. By passing both as the max amounts in `tokenXMaxAmount` you'll get two quotes. One telling how much ETH you need to provided if you send 100 USDC and another telling how much USDC you need to provide given 100 ETH. Then you can choose which one actually fits the liquidity your user has. **Note**: If only one of them is returned it means the price range is outside the current price, so only one token can be provided to create liquidity, the other will always be zero.", "operationId": "GetAmountsController_handle_v1", "parameters": [ { "name": "liquidityProvider", "required": false, "in": "query", "description": "Optional provider for entering a liquidity pool. If not provided, Uniswap v3 will be used.", "schema": { "type": "string", "enum": [ "UNISWAP_V3", "PANCAKESWAP_V3", "UNISWAP_V4" ], "examples": [ "UNISWAP_V3" ] } }, { "name": "chainId", "required": true, "in": "query", "description": "The blockchain network where the liquidity will be provided. \n Supported EVM chains:\n- Arbitrum One: 42161\n- Avalanche: 43114\n- Base: 8453\n- BNB Smart Chain: 56\n- Ethereum: 1\n- Gnosis: 100\n- OP Mainnet: 10\n- Polygon: 137\n- X Layer Mainnet: 196\n- Robinhood Chain: 4663", "schema": { "type": "number", "examples": [ 42161 ] } }, { "name": "token0", "required": true, "in": "query", "description": "The address (in hexadecimal format) of one of the tokens of the pool. Use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` for the native token (POL, ETH...); the pool is the one holding its wrapped token (WPOL, WETH...).", "schema": { "type": "string", "examples": [ "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f" ] } }, { "name": "token1", "required": true, "in": "query", "description": "The address (in hexadecimal format) of the other token of the pool. Use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` for the native token (POL, ETH...).", "schema": { "type": "string", "examples": [ "0xaf88d065e77c8cc2239327c5edb3a432268e5831" ] } }, { "name": "poolFeePercent", "required": true, "in": "query", "description": "Defines the fee earned by providing liquidity. Lower values are recommended for more stable tokens, while higher values are better suited for volatile assets. The values allowed depend on the provider, so check the provider docs too to know which fee tiers are allowed.", "schema": { "maximum": 100, "exclusiveMinimum": 0, "type": "number", "examples": [ 1 ] } }, { "name": "tickSpacing", "required": false, "in": "query", "description": "Tick spacing of the pool (`tickSpacing` from the pool list). Part of the pool's identity where the fee alone does not fix it: required for UNISWAP_V4, ignored by the providers that read it from the pool.", "schema": { "type": [ "integer", "null" ], "exclusiveMinimum": 0, "maximum": 9007199254740991, "examples": [ 60 ] } }, { "name": "poolId", "required": false, "in": "query", "description": "Optional `id` of the pool from the pool list. When sent, the request fails with POOL_ID_MISMATCH unless the pool it resolves to is this one.", "schema": { "type": [ "string", "null" ], "pattern": "^[0-9]+-0x([0-9a-fA-F]{40}|[0-9a-fA-F]{64})$", "examples": [ "137-0x5b5bf85e5dc1e76ff90025ac5d8e8595fb575443" ] } }, { "name": "token0MaxAmount", "required": false, "in": "query", "description": "The maximum amount of token0 to add to the liquidity pool, expressed as a decimal string.", "schema": { "default": "1", "type": "string", "examples": [ "26.2345" ] } }, { "name": "token1MaxAmount", "required": false, "in": "query", "description": "The maximum amount of token1 to add to the liquidity pool, expressed as a decimal string.", "schema": { "default": "1", "type": "string", "examples": [ "1823.2" ] } }, { "name": "minPrice", "required": true, "in": "query", "description": "Minimum price the liquidity will be active. If the price goes below this, the liquidity won't be active and will generate no revenues. This will allow to concentrate the liquidity to a price range, thus enhancing the gains. Price is always `p = token1 / token0`", "schema": { "minimum": 0, "maximum": 3.4026e+38, "type": "number", "examples": [ 83475.12 ] } }, { "name": "maxPrice", "required": true, "in": "query", "description": "Maximum price the liquidity will be active. If the price goes above this, the liquidity won't be active and will generate no revenues. This will allow to concentrate the liquidity to a price range, thus enhancing the gains. Price is always `p = token1 / token0`", "schema": { "minimum": 0, "maximum": 3.4026e+38, "type": "number", "examples": [ 102300.5 ] } }, { "name": "payGasFeeToken", "required": true, "in": "query", "description": "The token address (in hexadecimal format) used to pay the transaction fee.", "schema": { "type": "string", "examples": [ "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" ] } }, { "name": "gasFeePaymentMethod", "required": true, "in": "query", "description": "Defines how the fee will be paid: \"ADD_TO_AMOUNT\" adds it to the input amount, while \"DEDUCT_FROM_AMOUNT\" subtracts it from the input amount.", "schema": { "type": "string", "enum": [ "ADD_TO_AMOUNT", "DEDUCT_FROM_AMOUNT" ], "examples": [ "ADD_TO_AMOUNT" ] } }, { "name": "type", "required": false, "in": "query", "description": "Optional operation type to align the gas estimate with a future add or change liquidity transaction.", "schema": { "default": "add-liquidity", "type": "string", "enum": [ "add-liquidity", "change-liquidity" ], "examples": [ "change-liquidity" ] } } ], "responses": { "200": { "description": "The amounts of tokens needed to provide liquidity.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GetAmountsPresenterDTO" } } } }, "400": { "description": "BAD_REQUEST", "content": { "application/json": { "schema": { "oneOf": [ { "type": "object", "description": "NOT_AUTHORIZED_TOKENS", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "NOT_AUTHORIZED_TOKENS" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "" ] } } }, { "type": "object", "description": "BAD_DEDUCT_FEE_TOKEN", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "BAD_DEDUCT_FEE_TOKEN" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "You requested to deduct the gas fee from the amounts, but the token given \"0x82af49447d8a07e3bd95bd0d56f35241523fbab1\" is not one of tokens of the pool 0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f,0xaf88d065e77c8cc2239327c5edb3a432268e5831." ] } } }, { "type": "object", "description": "NOT_SUPPORTED_CHAIN", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "NOT_SUPPORTED_CHAIN" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "UNISWAP_V3 does not support this chain ([object Object])." ] } } }, { "type": "object", "description": "BAD_FEE", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "BAD_FEE" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "Wrong fee given." ] } } }, { "type": "object", "description": "TICK_OUT_OF_RANGE", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "TICK_OUT_OF_RANGE" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The provided value in `minPrice` is too high." ] } } }, { "type": "object", "description": "PRICE_RANGE_TOO_NARROW", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "PRICE_RANGE_TOO_NARROW" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The price range between `minPrice` and `maxPrice` does not cover a full tick-spacing step of this pool (10 ticks, about 0.1%); widen it." ] } } }, { "type": "object", "description": "LIQUIDITY_AMOUNT_TOO_SMALL_FOR_FEES", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "LIQUIDITY_AMOUNT_TOO_SMALL_FOR_FEES" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The amount does not cover the fees and the network gas. Increase the amount and try again." ] } } }, { "type": "object", "description": "NOT_SUPPORTED_TOKENS", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "NOT_SUPPORTED_TOKENS" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "Uniswap V3 does not support these tokens (0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)." ] } } }, { "type": "object", "description": "POOL_ID_MISMATCH", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "POOL_ID_MISMATCH" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The poolId does not match the pool the request resolves to" ] } } } ] } } } }, "403": { "description": "FORBIDDEN", "content": { "application/json": { "schema": { "type": "object", "description": "UNAVAILABLE_COMPUTE_UNITS", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 403 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "UNAVAILABLE_COMPUTE_UNITS" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The project doesn't have enough compute units to perform this action. Please upgrade your plan." ] } } } } } }, "404": { "description": "NOT_FOUND", "content": { "application/json": { "schema": { "type": "object", "description": "POOL_NOT_FOUND", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 404 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "POOL_NOT_FOUND" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "This pool was not found in our systems (pool: 42161-0x864abca0a6202dba5b8868772308da953ff125b0f95015adbf89aaf579e903a8). Make sure you are passing the right 'poolId'." ] } } } } } }, "500": { "description": "INTERNAL_SERVER_ERROR", "content": { "application/json": { "schema": { "type": "object", "description": "BLOCKCHAIN_ERROR", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 500 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "BLOCKCHAIN_ERROR" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "We had a problem fetching the data from the blockchain. If the problem persists, contact our support." ] } } } } } } }, "summary": "Get Liquidity Amounts", "tags": [ "Liquidity Pools" ] } ``` ### Schema GetAmountsPresenterDTO ```json { "type": "object", "properties": { "poolPrice": { "type": "string", "description": "Current price of the pool as a string. Price is always `p = token1 / token0`", "examples": [ "18342.234512" ] }, "amounts": { "description": "Amounts you need to provide to the pool. If the amounts for two tokens were provided, this will have two items, otherwise it's a single item.", "allOf": [ { "$ref": "#/components/schemas/AmountsDTO" } ] } }, "required": [ "poolPrice", "amounts" ] } ``` ### Schema AmountsDTO ```json { "type": "object", "properties": { "token0MaxAmount": { "description": "Amount of the tokens you need to provide to the pool if using the token0MaxAmount", "allOf": [ { "$ref": "#/components/schemas/TokenAmountsDTO" } ] }, "token1MaxAmount": { "description": "Amount of the tokens you need to provide to the pool if using the token1MaxAmount", "allOf": [ { "$ref": "#/components/schemas/TokenAmountsDTO" } ] } }, "required": [ "token0MaxAmount", "token1MaxAmount" ] } ``` ### Schema TokenAmountsDTO ```json { "type": "object", "properties": { "token0Amount": { "type": "string", "description": "Amount of token0 as a string", "examples": [ "2345.91" ] }, "token1Amount": { "type": "string", "description": "Amount of token1 as a string", "examples": [ "723.123" ] } }, "required": [ "token0Amount", "token1Amount" ] } ```