# Stake a liquidity position URL: /docs/api-reference/liquidity-pools/FarmPositionController_stake_v1 Stakes a PancakeSwap V3 position in MasterChefV3 to earn CAKE: the wallet sends the position NFT to the farm. It is a separate user operation, signed after the entry (or after a rebalance), because the NFT id is only known once the position exists. Only pools whose farm is live (allocation points above zero) can be staked. Its network fee is taken out of the position, so the wallet needs no balance: see payGasFeeToken. Collects, removals and top-ups of a staked position keep working through the regular endpoints, and an exit of the whole position takes it out of the farm on its own. The response amounts are the position current amounts, for information; nothing is paid out. ## POST /api/v1/liquidity/stake ```json { "description": "Stakes a PancakeSwap V3 position in MasterChefV3 to earn CAKE: the wallet sends the position NFT to the farm. It is a separate user operation, signed after the entry (or after a rebalance), because the NFT id is only known once the position exists. Only pools whose farm is live (allocation points above zero) can be staked. Its network fee is taken out of the position, so the wallet needs no balance: see payGasFeeToken. Collects, removals and top-ups of a staked position keep working through the regular endpoints, and an exit of the whole position takes it out of the farm on its own. The response amounts are the position current amounts, for information; nothing is paid out.", "operationId": "FarmPositionController_stake_v1", "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FarmPositionDTO" } } } }, "responses": { "200": { "description": "The user operation that stakes the position.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LiquidityOperationResponseDTO" } } } }, "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": "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": [ "PANCAKESWAP_V3 does not support this chain ([object Object])." ] } } }, { "type": "object", "description": "SPONSORED_GAS_BILLING_NOT_CONFIGURED", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "SPONSORED_GAS_BILLING_NOT_CONFIGURED" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "Sponsored gas requires an organization Stripe customer and a default card." ] } } }, { "type": "object", "description": "VALIDATION_FAILED", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "VALIDATION_FAILED" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "liquidityProvider or nftAddress is required" ] } } }, { "type": "object", "description": "LIQUIDITY_PROVIDER_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": [ "LIQUIDITY_PROVIDER_MISMATCH" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The liquidityProvider does not match the provider of the position manager given in nftAddress" ] } } }, { "type": "object", "description": "UNKNOWN_POSITION_MANAGER", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "UNKNOWN_POSITION_MANAGER" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The nftAddress is not a supported liquidity position manager on this chain" ] } } }, { "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 \"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d\" is not one of tokens of the pool 0x55d398326f99059ff775485246999027b3197955,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c." ] } } }, { "type": "object", "description": "INSUFFICIENT_FUNDS", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "INSUFFICIENT_FUNDS" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "Insufficient funds for token 0x55d398326f99059ff775485246999027b3197955\n\tAmount: 1000000000000000\n\tReduce: 43750000000000000" ] } } }, { "type": "object", "description": "UNSUPPORTED_LIQUIDITY_OPERATION", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "UNSUPPORTED_LIQUIDITY_OPERATION" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "This liquidity provider does not support the requested operation" ] } } }, { "type": "object", "description": "POSITION_ALREADY_STAKED", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "POSITION_ALREADY_STAKED" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The liquidity position is already staked in the farm" ] } } }, { "type": "object", "description": "POSITION_HAS_NO_LIQUIDITY", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "POSITION_HAS_NO_LIQUIDITY" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The liquidity position holds no liquidity, so the farm cannot take it" ] } } }, { "type": "object", "description": "FARM_NOT_ACTIVE", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 400 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "FARM_NOT_ACTIVE" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The pool of this position has no active farm, so staking it earns no rewards" ] } } } ] } } } }, "403": { "description": "FORBIDDEN", "content": { "application/json": { "schema": { "oneOf": [ { "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." ] } } }, { "type": "object", "description": "POSITION_NOT_OWNED_BY_WALLET", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 403 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "POSITION_NOT_OWNED_BY_WALLET" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The liquidity position NFT does not belong to the provided wallet address" ] } } } ] } } } }, "404": { "description": "NOT_FOUND", "content": { "application/json": { "schema": { "type": "object", "description": "ACCOUNT_ABSTRACTION_ADDRESS_NOT_REGISTERED_WITH_PROJECT", "required": [ "statusCode", "id", "message" ], "properties": { "statusCode": { "type": "number", "description": "HTTP status code", "examples": [ 404 ] }, "id": { "type": "string", "description": "Our ID of the problem", "examples": [ "ACCOUNT_ABSTRACTION_ADDRESS_NOT_REGISTERED_WITH_PROJECT" ] }, "message": { "type": "string", "description": "A human readable message that explains the problem", "examples": [ "The requested wallet is not registered with the project" ] } } } } } }, "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": "Stake a liquidity position", "tags": [ "Liquidity Pools" ] } ``` ### Schema FarmPositionDTO ```json { "type": "object", "properties": { "liquidityProvider": { "description": "Provider of the position. Only PANCAKESWAP_V3 has a farm. Required unless `nftAddress` is sent; there is no default here.", "type": "string", "enum": [ "UNISWAP_V3", "PANCAKESWAP_V3", "UNISWAP_V4" ], "examples": [ "PANCAKESWAP_V3" ] }, "nftAddress": { "description": "Position manager (NFT contract) of the position: the `nftAddress` returned when the position was created. Required unless `liquidityProvider` is sent; if both are sent they must name the same provider.", "type": [ "string", "null" ], "examples": [ "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364" ] }, "chainId": { "description": "The blockchain network of the position. \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", "type": "number", "examples": [ 42161 ] }, "nftId": { "type": "string", "description": "ID of the NFT that represents the liquidity", "examples": [ "2375619234" ] }, "walletAddress": { "description": "The wallet address (in hexadecimal format) that owns the position.", "type": "string", "examples": [ "0x6e397ddf51d9f15dbe0414538e7529f51f2e5464" ] }, "payGasFeeToken": { "description": "The token address (in hexadecimal format) used to pay the transaction fee: one of the position's two tokens, since the fee is taken out of the position. Its uncollected fees in that token pay first, and only the fee is collected from them; when they fall short, a sliver of liquidity covers the rest and what the sliver frees beyond the fee goes to the wallet. Refused with BAD_DEDUCT_FEE_TOKEN for another token, and INSUFFICIENT_FUNDS when the position holds too little of it (try the other token). Not charged when the project sponsors gas for this operation.", "type": "string", "examples": [ "0x55d398326f99059fF775485246999027B3197955" ] }, "metadata": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Custom metadata. Key-value pairs with string values. Max 1KB size.", "examples": [ { "key": "value" } ] } }, "required": [ "chainId", "nftId", "walletAddress", "payGasFeeToken" ] } ``` ### Schema LiquidityOperationResponseDTO ```json { "type": "object", "properties": { "operation": { "$ref": "#/components/schemas/CreateLiquidityDTO" } }, "required": [ "operation" ] } ``` ### Schema CreateLiquidityDTO ```json { "type": "object", "properties": { "liquidityProvider": { "description": "Optional provider for entering a liquidity pool. If not provided, Uniswap v3 will be used.", "type": "string", "enum": [ "UNISWAP_V3", "PANCAKESWAP_V3", "UNISWAP_V4" ], "examples": [ "UNISWAP_V3" ] }, "walletAddress": { "description": "The wallet address (in hexadecimal format) that will provide the liquidity.", "type": "string", "examples": [ "0x6e397ddf51d9f15dbe0414538e7529f51f2e5464" ] }, "toAddress": { "description": "The address (in hexadecimal format) receiving the token that represents the provided liquidity.", "type": "string", "examples": [ "0x1337133713371337133713371337133713371337" ] }, "chainId": { "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", "type": "number", "examples": [ 42161 ] }, "transactionFeePercent": { "default": 0, "description": "Percentage fee applied to the transaction (e.g., 5 for 5%).", "type": "number", "minimum": 0, "maximum": 99.99, "examples": [ 2.5 ] }, "payGasFeeToken": { "description": "The token address (in hexadecimal format) used to pay the transaction fee.", "type": "string", "examples": [ "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" ] }, "gasFeePaymentMethod": { "type": "string", "enum": [ "ADD_TO_AMOUNT", "DEDUCT_FROM_AMOUNT" ], "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.", "examples": [ "ADD_TO_AMOUNT" ] }, "tokenIn": { "description": "The address (in hexadecimal format) of the token being swapped from.", "type": "string", "examples": [ "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" ] }, "amountIn": { "type": "string", "description": "The amount of token being swapped from, expressed as a decimal string.", "examples": [ "1.2" ] }, "token0": { "description": "The address (in hexadecimal format) of one of the tokens of the pool.", "type": "string", "examples": [ "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f" ] }, "token1": { "description": "The address (in hexadecimal format) of the other token of the pool.", "type": "string", "examples": [ "0xaf88d065e77c8cc2239327c5edb3a432268e5831" ] }, "poolFeePercent": { "type": "number", "exclusiveMinimum": 0, "maximum": 100, "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.", "examples": [ 1 ] }, "tickSpacing": { "type": [ "integer", "null" ], "exclusiveMinimum": 0, "maximum": 9007199254740991, "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.", "examples": [ 60 ] }, "poolId": { "type": [ "string", "null" ], "pattern": "^[0-9]+-0x([0-9a-fA-F]{40}|[0-9a-fA-F]{64})$", "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.", "examples": [ "137-0x5b5bf85e5dc1e76ff90025ac5d8e8595fb575443" ] }, "stake": { "description": "PANCAKESWAP_V3 only: also stake the new position in the pool's MasterChefV3 farm, in the same operation, so it earns CAKE from the start. The wallet approves the staker contract on the position manager once: on the pool's network that approval is part of this operation; coming from another network it is a second, sponsored operation returned as `stakeApprovalUserOperation`. Ignored when the pool has no live farm or `toAddress` is not `walletAddress`. The response's `staked` tells whether the position will be staked.", "type": [ "boolean", "null" ], "examples": [ false ] }, "minPrice": { "type": "number", "minimum": 0, "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`", "examples": [ 83475.12 ] }, "maxPrice": { "type": "number", "minimum": 0, "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`", "examples": [ 102300.5 ] }, "slippage": { "default": 0.5, "description": "Optional parameter controlling the maximum deviation allowed of the expected price of a trade and the actual price at which the trade is executed, with a minimum value of 0.5 and a maximum value of 99, default is 0.5, where 1 unit equals 1%.", "type": "number", "minimum": 0, "maximum": 99, "examples": [ 1.2 ] }, "extraFee": { "description": "Optional extra fee that can be charged in addition to the transaction fee (configured in the dashboard or via `transactionFeePercent`). This extra fee is deducted from the input token and sent to the specified `toAddress`, allowing you to define a custom recipient for this additional charge.", "type": "object", "properties": { "percentage": { "type": "number", "minimum": 0, "maximum": 99.99, "description": "The percentage of the extra fee to be charged", "examples": [ 1.5 ] }, "toAddress": { "description": "The address (in hexadecimal format) receiving the extra fee.", "type": "string", "examples": [ "0x6e397ddf51d9f15dbe0414538e7529f51f2e5464" ] } }, "required": [ "percentage", "toAddress" ] }, "metadata": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Custom metadata. Key-value pairs with string values. Max 1KB size.", "examples": [ { "key": "value" } ] } }, "required": [ "walletAddress", "toAddress", "chainId", "payGasFeeToken", "gasFeePaymentMethod", "tokenIn", "amountIn", "token0", "token1", "poolFeePercent", "minPrice", "maxPrice" ] } ```