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

# Compute optimal allocation

> Given an amount of IKA tokens, computes the optimal stake distribution across validators to maximize risk-adjusted APY.



## OpenAPI

````yaml /openapi/leviathan.yaml post /api/v1/ika/agent/allocate
openapi: 3.1.0
info:
  title: Inkwell Agent API
  version: 0.1.0
  description: >
    REST API for AI agents to interact with IKA staking infrastructure and
    Leviathan protocol services.


    ## Authentication


    Most endpoints require an API key passed via the `X-API-Key` header.

    Register at `POST /api/v1/agents/self-register` to obtain a free-tier key.


    ## Rate Limits


    | Tier     | RPM | RPD    |

    |----------|-----|--------|

    | free     | 10  | 100    |

    | builder  | 100 | 1,000  |

    | pro      | custom | custom |


    Rate limit headers (`X-RateLimit-Remaining-RPM`,
    `X-RateLimit-Remaining-RPD`) are included on every authenticated response.
  contact:
    name: Inkwell Finance
    email: support@inkwell.finance
    url: https://inkwell.finance
  license:
    name: MIT
servers:
  - url: https://backend.inkwell.finance
    description: Production
  - url: http://localhost:3000
    description: Local development
security:
  - ApiKeyAuth: []
tags:
  - name: IKA Staking (Agent)
    description: >-
      Authenticated endpoints for staking allocation, transaction building, and
      rebalancing. Requires API key.
  - name: IKA Staking (Public)
    description: >-
      Public read-only endpoints for validator data, pricing, and APY history.
      No auth required.
  - name: Agent Identity
    description: Register API keys, manage agents, rotate credentials.
paths:
  /api/v1/ika/agent/allocate:
    post:
      tags:
        - IKA Staking (Agent)
      summary: Compute optimal allocation
      description: >-
        Given an amount of IKA tokens, computes the optimal stake distribution
        across validators to maximize risk-adjusted APY.
      operationId: ikaAgentAllocate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AllocateRequest'
      responses:
        '200':
          description: Optimal allocation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    AllocateRequest:
      type: object
      required:
        - amount
      properties:
        amount:
          type: string
          description: Amount of IKA in MIST to allocate
          example: '10000000000'
        maxValidators:
          type: integer
          minimum: 1
          maximum: 10
          default: 5
    AllocationResponse:
      type: object
      properties:
        allocations:
          type: array
          items:
            type: object
            properties:
              validatorId:
                type: string
              amount:
                type: string
              weight:
                type: number
        totalProjectedApy:
          type: number
  responses:
    ValidationError:
      description: Invalid input
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              message:
                type: string
              status:
                type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Agent API key obtained via self-registration or admin registration

````