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

# Sell

> Sell a Based or Cringe position in the specified market

<Note>
  This is a smart contract write function. The curl example shown is for illustration. To call this function, use web3 libraries (ethers.js, viem, web3.py) or JSON-RPC directly.
</Note>


## OpenAPI

````yaml POST /market/{marketAddress}/sell
openapi: 3.0.3
info:
  title: Based Protocol Smart Contracts API
  description: >-
    OpenAPI specification for the Based Protocol - a bidirectional perpetual
    markets platform built for EVM blockchains. The protocol allows users to
    create binary markets where participants can take "Based" (positive) or
    "Cringe" (negative) positions using the Based Market mechanism.
  version: 1.0.0
  license:
    name: LicenseRef-Proprietary
servers:
  - url: https://mainnet.base.org
    description: Base Mainnet (default RPC endpoint)
security: []
tags:
  - name: BasedProtocol
    description: Operations related to the main protocol contract
  - name: BasedMarket
    description: Operations for individual markets
  - name: BasedMarketRouter
    description: Router operations with safety checks and deadline protection
paths:
  /market/{marketAddress}/sell:
    post:
      tags:
        - BasedMarket
      summary: Sell position in market
      description: Sell a Based or Cringe position in the specified market
      operationId: sellPosition
      parameters:
        - name: marketAddress
          in: path
          required: true
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: Address of the market contract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SellPositionRequest'
      responses:
        '200':
          description: Position sold successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionResponse'
        '400':
          description: >-
            Invalid request parameters, insufficient holdings, or slippage
            exceeded
        '403':
          description: Unauthorized - only token holder or authorized router can sell
components:
  schemas:
    SellPositionRequest:
      type: object
      required:
        - user
        - amount
        - isBased
        - minAmountReceived
      properties:
        user:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
          description: Address whose position will be sold
        amount:
          type: integer
          format: uint64
          minimum: 1
          description: Size of the position to sell
        isBased:
          type: boolean
          description: Whether selling Based (true) or Cringe (false) position
        minAmountReceived:
          type: integer
          format: uint64
          minimum: 0
          description: Minimum amount of USD to receive (slippage protection)
    TransactionResponse:
      type: object
      properties:
        transactionHash:
          type: string
          pattern: ^0x[a-fA-F0-9]{64}$
          description: Transaction hash
        blockNumber:
          type: integer
          format: uint256
          description: Block number where transaction was mined
        gasUsed:
          type: integer
          format: uint256
          description: Amount of gas used
        success:
          type: boolean
          description: Whether transaction was successful

````