openapi: 3.0.3
info:
  title: API Perp Raydium V1
  version: 1.0.0
  description: >
    Dịch vụ cấu hình và siêu dữ liệu cho Raydium Perpetual Futures. API này cung
    cấp cấu hình giao diện, tính khả dụng tài sản, hạn chế khu vực và các điểm
    cuối RPC. Việc đặt lệnh được ủy thác cho API của Orderly Network.


    Tất cả các điểm cuối trả về một phong bì tiêu chuẩn:

    - **Thành công**: `{ id: string, success: true, data: {...} }`

    - **Lỗi**: `{ id: string, success: false, msg: string }`
  contact:
    name: Raydium
    url: https://raydium.io
servers:
  - url: https://api-perp-v1.raydium.io
    description: Production
tags:
  - name: Main
    description: Thông tin dịch vụ cơ bản (phiên bản, RPC, thống kê, kiểm tra khu vực).
  - name: Pool
    description: Cấu hình bể perp market.
  - name: Campaign
    description: Dữ liệu chiến dịch và bảng xếp hạng.
  - name: Share
    description: Điểm cuối chia sẻ vị trí và P&L.
paths:
  /main/info:
    get:
      summary: Lấy thống kê thị trường perp
      description: Trả về khối lượng giao dịch và lãi suất mở cửa 24h/7d/30d.
      operationId: getMarketInfo
      tags:
        - Main
      responses:
        '200':
          description: Thông tin thị trường đã lấy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarketInfoResponse'
  /pool/default-list:
    get:
      summary: Lấy danh sách bể perp mặc định
      description: >-
        Trả về danh sách các bể giao dịch tương lai mặc định với khối lượng và
        thống kê.
      operationId: getPoolList
      tags:
        - Pool
      responses:
        '200':
          description: Danh sách bể đã lấy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PoolListResponse'
components:
  schemas:
    VersionResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            latest:
              type: string
              description: Phiên bản UI ổn định hiện tại.
              example: 1.2.0
            least:
              type: string
              description: Phiên bản UI tối thiểu được yêu cầu.
              example: 1.0.0
    RpcListResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            rpcs:
              type: array
              description: Danh sách các URL RPC khả dụng.
              items:
                type: string
    MarketInfoResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            volume:
              type: object
              properties:
                24h:
                  type: number
                  description: Khối lượng giao dịch 24 giờ.
                7d:
                  type: number
                  description: Khối lượng giao dịch 7 ngày.
                30d:
                  type: number
                  description: Khối lượng giao dịch 30 ngày.
            openInterest:
              type: object
              properties:
                long:
                  type: number
                  description: Tổng lãi suất mở cửa long.
                short:
                  type: number
                  description: Tổng lãi suất mở cửa short.
                all:
                  type: number
                  description: Lãi suất mở cửa kết hợp.
    AvailabilityResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            available:
              type: boolean
              description: Liệu giao dịch perp có được phép ở khu vực của người dùng.
            country:
              type: string
              description: Mã quốc gia được phát hiện (từ tiêu đề cf-ipcountry).
    TempKeyResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            key:
              type: string
              description: >-
                Khóa công khai Ed25519 ở định dạng
                "ed25519:<base58-encoded-key>".
              example: ed25519:AAAA...
    PoolListResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: array
          items:
            type: object
            properties:
              symbol:
                type: string
                description: 'Ký hiệu bể (ví dụ: BTC/USDC).'
                example: BTC/USDC
              volume24h:
                type: string
                description: Khối lượng giao dịch 24 giờ.
              volume7d:
                type: string
                description: Khối lượng giao dịch 7 ngày.
              volume30d:
                type: string
                description: Khối lượng giao dịch 30 ngày.
    CampaignConfigResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          description: Đối tượng cấu hình chiến dịch với quy tắc và tham số.
    UserCampaignResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            userInfo:
              type: object
              properties:
                index:
                  type: string
                  description: Thứ hạng hoặc vị trí bảng xếp hạng của người dùng.
                walletAddress:
                  type: string
                  description: Địa chỉ ví được che khuất.
                volume:
                  type: number
                  description: Tổng khối lượng giao dịch chiến dịch.
                pnl:
                  type: number
                  description: Lợi nhuận/lỗ nhận được.
                pnlW:
                  type: number
                  description: P&L có trọng số để tính điểm.
                score:
                  type: number
                  description: Điểm chiến dịch.
                rewards:
                  type: array
                  description: Danh sách phần thưởng kiếm được.
                  items:
                    type: object
    LeaderboardResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            updateTime:
              type: integer
              description: Dấu thời gian cập nhật bảng xếp hạng cuối cùng (ms).
            rows:
              type: array
              description: Người dùng hàng đầu trên trang bảng xếp hạng này.
              items:
                type: object
                properties:
                  rank:
                    type: integer
                  wallet:
                    type: string
                  volume:
                    type: number
                  pnl:
                    type: number
                  score:
                    type: number
    SharePositionRequest:
      type: object
      description: Tải trọng để tạo ảnh chụp vị trí hiện tại.
      properties:
        symbol:
          type: string
          example: BTC/USDC
        side:
          type: string
          enum:
            - long
            - short
        size:
          type: string
        entryPrice:
          type: string
        markPrice:
          type: string
        pnl:
          type: string
        leverage:
          type: string
    ShareHistoryPositionRequest:
      type: object
      description: Tải trọng để tạo ảnh chụp vị trí đã đóng.
      properties:
        symbol:
          type: string
          example: BTC/USDC
        side:
          type: string
          enum:
            - long
            - short
        size:
          type: string
        entryPrice:
          type: string
        exitPrice:
          type: string
        realizedPnl:
          type: string
    ShareResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
        data:
          type: object
          properties:
            imgFileName:
              type: string
              description: ID tệp hình ảnh được tạo.
            msg:
              type: string
              description: Thông báo trạng thái.
    ErrorResponse:
      type: object
      properties:
        id:
          type: string
        success:
          type: boolean
          example: false
        msg:
          type: string
          description: Thông báo lỗi hoặc mã lỗi.
