Tristero Margin API

Margin position management

Operations 4

POST /quotes/margin Get a margin quote #
GET /wallets/margin-positions/{position_id} Get margin position #
GET /wallets/{wallet}/margin-positions List margin positions #
POST /orders/close-margin-position Close a margin position #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/tristero-margin-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

tristero-margin-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Tristero Assets Margin API
  description: Tristero is a cross-chain trading protocol supporting spot swaps, margin positions, and feather (UTXO-based) swaps. This API provides endpoints for requesting quotes, submitting orders, managing margin positions, and real-time updates via WebSocket.
  version: 2.0.0
  contact:
    name: Tristero Support
    url: https://tristero.com
servers:
- url: https://api.tristero.com/v2
  description: Production
- url: https://staging-api.tristero.com/v2
  description: Staging
- url: http://localhost:8060
  description: Local (Quoter)
- url: http://localhost:8070
  description: Local (Filler)
security:
- ApiKeyAuth: []
tags:
- name: Margin
  description: Margin position management
paths:
  /quotes/margin:
    post:
      tags:
      - Margin
      summary: Get a margin quote
      description: Request a quote for opening a leveraged margin position. Any token can be used as collateral.
      operationId: getMarginQuote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MarginQuoteRequest'
            examples:
              2x-long-weth:
                summary: 2x Long WETH with USDC collateral
                value:
                  chain_id: '42161'
                  wallet_address: 0x...
                  collateral_token: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
                  base_token: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
                  leverage_ratio: 2
                  collateral_amount: '1000000'
      responses:
        '200':
          description: Margin quote response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarginQuoteResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /wallets/margin-positions/{position_id}:
    get:
      tags:
      - Margin
      summary: Get margin position
      description: Get details of a specific margin position by ID.
      operationId: getMarginPosition
      parameters:
      - name: position_id
        in: path
        required: true
        schema:
          type: string
        description: Position ID
      responses:
        '200':
          description: Margin position details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarginPosition'
  /wallets/{wallet}/margin-positions:
    get:
      tags:
      - Margin
      summary: List margin positions
      description: Get all margin positions for a wallet address.
      operationId: getMarginPositions
      parameters:
      - name: wallet
        in: path
        required: true
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: Wallet address (checksum)
      responses:
        '200':
          description: List of margin positions
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/MarginPosition'
  /orders/close-margin-position:
    post:
      tags:
      - Margin
      summary: Close a margin position
      description: Submit a signed request to close a margin position. Can close partially or fully, with cash settlement or swap settlement.
      operationId: closeMarginPosition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClosePositionSubmission'
      responses:
        '200':
          description: Close position order submitted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClosePositionResponse'
components:
  schemas:
    MarginPosition:
      type: object
      properties:
        id:
          type: string
          description: Position ID
        status:
          type: string
          enum:
          - open
          - closing
          - closed
          description: Position status
        escrow_address:
          type: string
          description: Escrow contract address holding the position
        filler_address:
          type: string
          description: Authorized filler address
        taker_token_id:
          type: integer
          description: NFT token ID representing the position
        wallet_address:
          type: string
          description: Owner wallet address
        collateral_token:
          type: string
          description: Collateral token address
        base_token:
          type: string
          description: Base token address
        loan_token:
          type: string
          description: Loan token address
        collateral_amount:
          type: string
          description: Collateral amount in raw units
        loan_amount:
          type: string
          description: Outstanding loan amount
        leverage_ratio:
          type: integer
          description: Position leverage
        interest_rate_bps:
          type: integer
          description: Annual interest rate in basis points
        opened_at:
          type: string
          format: date-time
          description: Position open timestamp
    ClosePositionSubmission:
      type: object
      required:
      - signature
      - domain
      - message
      - chainId
      - typed_data
      properties:
        signature:
          type: string
          description: EIP-712 signature for CloseWithSwap
        domain:
          $ref: '#/components/schemas/EIP712Domain'
        message:
          type: object
          description: CloseWithSwap message data
          properties:
            positionId:
              type: integer
              description: Position NFT token ID
            cashSettle:
              type: boolean
              description: True for cash settlement, false for swap settlement
            fractionBps:
              type: integer
              description: Fraction to close in basis points (10000 = 100%)
            authorized:
              type: string
              description: Authorized filler address
            nonce:
              type: integer
              description: Unique nonce for the signature
            deadline:
              type: integer
              description: Unix timestamp deadline
        chainId:
          type: string
          description: Chain ID
        typed_data:
          type: object
          description: Complete typed data for verification
    OrderParameters:
      type: object
      properties:
        src_asset:
          type: string
          description: Source token address
        dst_asset:
          type: string
          description: Destination token address
        src_quantity:
          type: string
          description: Source amount
        dst_quantity:
          type: string
          description: Expected destination amount
        min_quantity:
          type: string
          description: Minimum acceptable output (slippage protection)
        dark_salt:
          type: string
          description: Random salt for order uniqueness
    ClosePositionResponse:
      type: object
      properties:
        close_order:
          type: object
          properties:
            id:
              type: string
              description: Close order ID
        id:
          type: string
        order_id:
          type: string
    OrderData:
      type: object
      properties:
        parameters:
          $ref: '#/components/schemas/OrderParameters'
        deadline:
          type: integer
          description: Unix timestamp deadline
        router_address:
          type: string
          description: Router contract address
        filler_wallet_address:
          type: string
          description: Filler wallet address
        order_type:
          type: string
          enum:
          - FEATHER
          - PERMIT2
          - MARGIN
        custom_data:
          type: array
          items:
            type: string
            format: binary
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
        detail:
          type: object
          description: Additional error details
    MarginQuoteRequest:
      type: object
      required:
      - chain_id
      - wallet_address
      - collateral_token
      - base_token
      - leverage_ratio
      - collateral_amount
      properties:
        chain_id:
          type: string
          description: Chain ID where position will be opened
          example: '42161'
        wallet_address:
          type: string
          description: User's wallet address
          example: 0x...
        collateral_token:
          type: string
          description: Collateral token address (any ERC20, e.g., USDC, USDT0, WETH)
          example: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
        base_token:
          type: string
          description: Base token address for the position (e.g., WETH for long ETH)
          example: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
        leverage_ratio:
          type: integer
          description: Leverage multiplier (e.g., 2 for 2x)
          minimum: 1
          example: 2
        collateral_amount:
          type: string
          description: Collateral amount in raw units
          example: '1000000'
    EIP712Domain:
      type: object
      properties:
        name:
          type: string
          example: Permit2
        version:
          type: string
          example: '1'
        chainId:
          type: integer
          description: Chain ID where the contract is deployed
        verifyingContract:
          type: string
          description: Contract address that verifies the signature
          example: '0x000000000022D473030F116dDEE9F6B43aC78BA3'
    TokenMetadata:
      type: object
      properties:
        address:
          type: string
        symbol:
          type: string
        name:
          type: string
        decimals:
          type: integer
    MarginQuoteResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
        chain_id:
          type: string
          description: Chain ID
        collateral_token:
          $ref: '#/components/schemas/TokenMetadata'
        base_token:
          $ref: '#/components/schemas/TokenMetadata'
        loan_token:
          $ref: '#/components/schemas/TokenMetadata'
        interest_rate_bps:
          type: integer
          description: Annual interest rate in basis points
        order_data:
          $ref: '#/components/schemas/OrderData'
        position_size:
          type: string
          description: Total position size in base token units
        loan_amount:
          type: string
          description: Amount being borrowed
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication (if required by deployment)
externalDocs:
  description: Tristero Python SDK Documentation
  url: https://pypi.org/project/tristero/