openapi: 3.1.0
x-schema-version: '1.0.0'
x-compatibility:
    policy: Backward-compatible optional fields may be added without notice. Field removals, type changes, or semantic changes require a documentation version update and deprecation note.
    sourceOfTruth: https://docs.justlend.org/developers/apis/justlend_apis.yaml
x-rate-limit:
    authentication: none
    pageSizeMax: 1000
    policy: Public unauthenticated traffic may be throttled. Cache stable metadata and retry 429 or transient 5xx responses with exponential backoff and jitter.
info:
    title: JustLend DAO API
    version: '1.0.0'
    summary: Public read‑only API for JustLend DAO protocol data.
    termsOfService: https://justlend.org/docs/JustLend_Terms_of_Use_en.pdf
    contact:
        name: JustLend DAO
        url: https://support.justlend.org/
    license:
        name: Documentation license and terms
        url: https://justlend.org/docs/JustLend_Terms_of_Use_en.pdf
    description: |
        Public REST endpoints for querying JustLend DAO protocol state:
        lending markets, user positions, liquidation risk, USDD supply‑mining
        rewards, sTRX staking, and Energy Rental.

        ## Conventions

        * **Envelope** — every successful response is `{ code: 0, message: "SUCCESS", data: { ... } }`.
        * **Addresses** — TRON Base58 (`T...`, 34 chars).
        * **Numbers** — already de‑scaled to human‑readable units unless explicitly noted.
            * `*Rate` and `apy` fields are **annualized decimals** (`0.0917` = 9.17 %).
            * `*Factor` fields are decimals in `[0, 1]` (`0.75` = 75 %).
            * Amounts in `cash` / `reserves` / `totalBorrows` / `supplyBalanceUnderlying` etc. are already in underlying units.
            * jToken amounts (`totalSupply` of `/lend/jtoken`, `supplyBalanceJtoken`) are in jToken units (8 decimals).
        * **Hex numbers** — `amount`, `index`, `merkleIndex`, `merkleRoot`, `proof` returned by `/mining/distributions` are bare `0x…` hex `uint256`. Pass directly to the on‑chain claim contract; decode the amount with `parseInt(hex, 16) / 1e6` for USDD.
        * **Mining APY** — paid on top of `supplyRate`. Effective supply APY = `supplyRate + apy`.
        * **Pagination** — `pageNo` is 1‑based, default `1`. `pageSize` default `10`, max `1000`.
        * **Rate limits** — public unauthenticated traffic may be throttled. Cache stable metadata and retry `429` / transient `5xx` with exponential backoff and jitter.
        * **Errors** — non‑zero `code` plus an RFC 7807 body. See the `Error` schema.
        * **Compatibility** — clients should ignore unknown fields. Field removals,
          type changes, or semantic changes require a documentation version update
          and deprecation note.

        See [`/developers/apis`](https://docs.justlend.org/developers/apis) for the
        human‑readable version with tables, worked examples, and the jToken
        address reference.

servers:
    - url: https://openapi.just.network
      description: Production

tags:
    - name: Supply and Borrow Market
      description: |
          Core lending protocol. Query market parameters, per‑user positions,
          and liquidatable accounts.
    - name: Mining
      description: |
          USDD supply‑mining rewards. Suppliers of jUSDD
          (`TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf`) earn additional USDD distributed
          in time‑bounded **phases**. Use these endpoints to query the active
          APY, per‑user phase status, and Merkle claim proofs.
    - name: Staked TRX and Energy Rental
      description: |
          sTRX liquid‑staking pool and the Energy Rental market.

paths:
    /lend/jtoken:
        get:
            tags: [Supply and Borrow Market]
            operationId: listMarkets
            summary: List all SBM markets
            description: |
                Returns the on‑chain state of every Supply & Borrow market:
                rates, total supply/borrow, exchange rate, oracle price, and
                collateral factor.
            responses:
                '200':
                    description: Market list.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/MarketListResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /lend/account:
        get:
            tags: [Supply and Borrow Market]
            operationId: getAccount
            summary: Get a user's SBM positions
            description: |
                Returns each queried wallet's supply / borrow positions, health
                factor, and totals.
            parameters:
                - $ref: '#/components/parameters/addresses'
                - $ref: '#/components/parameters/minBorrowValueInTrx'
                - $ref: '#/components/parameters/maxHealth'
                - $ref: '#/components/parameters/pageNo'
                - $ref: '#/components/parameters/pageSize'
            responses:
                '200':
                    description: User account list.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/AccountListResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /justlend/liquidate/highRiskAccountList:
        get:
            tags: [Supply and Borrow Market]
            operationId: listHighRiskAccounts
            summary: List high‑risk / liquidatable accounts
            description: |
                Returns accounts whose health factor is at or near the
                liquidation threshold. `risk > 1` means the account is
                liquidatable now.
            responses:
                '200':
                    description: High‑risk account list.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/HighRiskAccountListResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /mining/apy:
        get:
            tags: [Mining]
            operationId: getMiningApy
            summary: Get USDD mining APY per market
            description: |
                Returns the current USDD supply‑mining APY for every market
                that has mining enabled. The response is keyed by jToken
                address (currently only `TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf` —
                jUSDD).

                The value is an **annualized decimal**: `0.09175706` = 9.18 %.
                It is paid on top of `supplyRate` returned by `/lend/jtoken`.

                A user's effective supply APY in this market is
                `supplyRate + apy`.
            responses:
                '200':
                    description: Mining APY per market.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/MiningApyResponse'
                            example:
                                code: 0
                                message: SUCCESS
                                data:
                                    TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf:
                                        USDD: 0.09175706
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /mining/reward:
        get:
            tags: [Mining]
            operationId: getMiningReward
            summary: Get current/last phase status for a user
            description: |
                Returns the user's status in the current and previous USDD
                mining phase for each market with mining enabled.

                Each phase has a `start` time, `end` time, accrued reward, and
                a status enum:

                | `*RewardStatus` | Meaning                             |
                |-----------------|-------------------------------------|
                | `0`             | Phase not started                   |
                | `1`             | Phase in progress                   |
                | `2`             | Phase ended (finalized / claimable) |
                | `3`             | Phase paused                        |

                Once a phase reaches status `2`, call `/mining/distributions`
                to fetch the Merkle proof needed to claim on‑chain.
            parameters:
                - $ref: '#/components/parameters/addressQuery'
            responses:
                '200':
                    description: User's mining phase status per market.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/MiningRewardResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /mining/distributions:
        get:
            tags: [Mining]
            operationId: getMiningDistributions
            summary: Get Merkle claim proofs for all phases
            description: |
                Returns every mining phase the user has ever been entitled to,
                claimed or unclaimed. Each entry carries the data needed to
                claim on‑chain: `merkleIndex`, `index`, `amount` (hex
                `uint256`), `merkleRoot`, and `proof`.

                **Decoding amount** — `parseInt(amount, 16) / 1e6` ⇒ USDD.

                **Claim flow** — filter `claimed == false`, then call the
                distribution contract with `(merkleIndex, index, amount, proof)`
                per phase.
            parameters:
                - $ref: '#/components/parameters/addressQuery'
            responses:
                '200':
                    description: Per‑phase reward and Merkle proof list.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/MiningDistributionsResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /lend/strx:
        get:
            tags: [Staked TRX and Energy Rental]
            operationId: getStrxAndRentalSnapshot
            summary: Get sTRX market and Energy Rental snapshot
            description: |
                Returns global state for both the sTRX liquid‑staking pool
                (`stakeInfo`) and the Energy Rental market (`rentInfo`).
            responses:
                '200':
                    description: Global sTRX/Energy Rental state.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/StrxSnapshotResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /lend/strxStake/account:
        get:
            tags: [Staked TRX and Energy Rental]
            operationId: getStrxStakeAccount
            summary: Get user's sTRX staking positions
            description: |
                Returns each queried wallet's sTRX balance, in‑cooldown amount,
                and amount ready to withdraw.
            parameters:
                - $ref: '#/components/parameters/addresses'
                - $ref: '#/components/parameters/pageNo'
                - $ref: '#/components/parameters/pageSize'
                - $ref: '#/components/parameters/minStrxBalance'
            responses:
                '200':
                    description: User sTRX positions.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/StrxStakeAccountResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

    /lend/rentResource/account:
        get:
            tags: [Staked TRX and Energy Rental]
            operationId: getRentResourceAccount
            summary: Get user's Energy Rental orders
            description: |
                Returns each queried wallet's Energy Rental orders.
                Bandwidth rentals are not yet exposed.
            parameters:
                - $ref: '#/components/parameters/addresses'
                - $ref: '#/components/parameters/pageNo'
                - $ref: '#/components/parameters/pageSize'
                - $ref: '#/components/parameters/minStrxBalance'
                - $ref: '#/components/parameters/maxRemainingRentAmount'
            responses:
                '200':
                    description: User Energy Rental orders.
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/RentAccountResponse'
                '400':
                    $ref: '#/components/responses/BadRequest'
                '429':
                    $ref: '#/components/responses/TooManyRequests'

components:
    parameters:
        addresses:
            name: addresses
            in: query
            description: |
                One or more TRON Base58 addresses, **comma‑separated** (no
                spaces). Example: `T9yD14...,TXJgM...`.
            required: true
            schema:
                type: string
                example: T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
        addressQuery:
            name: address
            in: query
            description: A single TRON Base58 address.
            required: true
            schema:
                type: string
                example: T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
        minBorrowValueInTrx:
            name: minBorrowValueInTrx
            in: query
            description: Only return accounts whose total borrow value (TRX) is ≥ this threshold.
            required: false
            schema: { type: number, format: double }
        maxHealth:
            name: maxHealth
            in: query
            description: Only return accounts whose health factor is ≤ this threshold (useful to find risky borrowers).
            required: false
            schema: { type: number, format: double }
        pageNo:
            name: pageNo
            in: query
            description: 1‑based page number. Default `1`.
            required: false
            schema: { type: integer, format: int64, minimum: 1, default: 1 }
        pageSize:
            name: pageSize
            in: query
            description: Page size. Default `10`, max `1000`.
            required: false
            schema: { type: integer, format: int64, minimum: 1, maximum: 1000, default: 10 }
        minStrxBalance:
            name: minStrxBalance
            in: query
            description: Minimum sTRX balance an account must hold to be included.
            required: false
            schema: { type: number, format: double }
        maxRemainingRentAmount:
            name: maxRemainingRentAmount
            in: query
            description: Only include rental orders whose remaining rent is ≤ this threshold.
            required: false
            schema: { type: number, format: double }

    responses:
        BadRequest:
            description: Bad Request — missing or malformed parameters.
            content:
                application/json:
                    schema:
                        $ref: '#/components/schemas/Error'
        TooManyRequests:
            description: Too Many Requests — slow down and retry with exponential backoff and jitter.
            headers:
                Retry-After:
                    description: Optional server-provided delay, in seconds, before retrying.
                    schema:
                        type: integer
                        minimum: 1
            content:
                application/json:
                    schema:
                        $ref: '#/components/schemas/Error'

    schemas:
        # ------------------------------------------------------------------
        # Common envelope pieces
        # ------------------------------------------------------------------
        EnvelopeOk:
            type: object
            description: Shared shape of every successful response.
            required: [code, message, data]
            properties:
                code:
                    type: integer
                    description: '`0` means success. Non‑zero values indicate an error; see `message` and the HTTP status code.'
                    example: 0
                message:
                    type: string
                    description: Status string. `"SUCCESS"` on success.
                    example: SUCCESS
                data:
                    description: Endpoint‑specific payload. Shape documented per endpoint.

        Pagination:
            type: object
            description: Pagination metadata.
            properties:
                totalCount: { type: integer, format: int64, description: Total number of records across all pages. }
                totalPage:  { type: integer, format: int64, description: Total number of pages. }

        Error:
            type: object
            description: RFC 7807 problem document.
            properties:
                type:   { type: string, example: 'https://docs.justlend.org/errors/bad-request' }
                title:  { type: string, example: 'Bad Request' }
                status: { type: integer, format: int32, example: 400 }
                detail: { type: string, example: 'Parameter `addresses` is required.' }

        # ------------------------------------------------------------------
        # /lend/jtoken
        # ------------------------------------------------------------------
        Market:
            type: object
            description: One Supply & Borrow market.
            properties:
                address:
                    type: string
                    description: jToken contract address (the market).
                    example: TE2RzoSV3wFK99w6J9UnnZ4vLfXYoxvRwP
                symbol:
                    type: string
                    description: jToken symbol, e.g. `jTRX`, `jUSDD`.
                    example: jTRX
                underlyingAddress:
                    type: string
                    description: Underlying asset contract address.
                    example: T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
                underlyingSymbol:
                    type: string
                    description: Underlying asset symbol.
                    example: TRX
                underlyingDecimal:
                    type: integer
                    format: int32
                    description: Decimals of the underlying asset.
                    example: 6
                underlyingPriceInTrx:
                    type: number
                    format: double
                    description: Oracle price of 1 unit of underlying, denominated in TRX.
                    example: 1.0
                borrowIndex:
                    type: integer
                    format: int64
                    description: Cumulative borrow interest index (scaled `1e18`).
                    example: 1224530412174750380
                borrowRate:
                    type: number
                    format: double
                    description: Borrow APY as annualized decimal. `0.0647` = 6.47 %.
                    example: 0.06467371
                supplyRate:
                    type: number
                    format: double
                    description: Supply APY as annualized decimal (does **not** include mining rewards).
                    example: 0.00904450
                cash:
                    type: number
                    format: double
                    description: Available underlying liquidity in the market.
                    example: 349909392.537020
                reserves:
                    type: number
                    format: double
                    description: Protocol reserves in the market (underlying units).
                    example: 2300647.881336
                totalBorrows:
                    type: number
                    format: double
                    description: Total outstanding debt (underlying units).
                    example: 63951044.565948
                totalSupply:
                    type: number
                    format: double
                    description: Total minted jTokens (jToken units, 8 decimals).
                    example: 39391010299.49149122
                exchangeRate:
                    type: number
                    format: double
                    description: Current jToken → underlying conversion ratio.
                    example: 0.010448063811832339
                collateralFactor:
                    type: number
                    format: double
                    description: Loan‑to‑value cap when used as collateral. `0.75` = 75 %.
                    example: 0.75
                reserveFactor:
                    type: number
                    format: double
                    description: Share of borrow interest taken as protocol reserve.
                    example: 0.10

        MarketListResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          required: [tokenList]
                          properties:
                              tokenList:
                                  type: array
                                  items: { $ref: '#/components/schemas/Market' }

        # ------------------------------------------------------------------
        # /lend/account
        # ------------------------------------------------------------------
        UserTokenPosition:
            type: object
            description: One jToken position for one user.
            properties:
                address:
                    type: string
                    description: jToken contract address.
                    example: TNSBA6KvSvMoTqQcEgpVK7VhHT3z7wifxy
                underlyingSymbol:
                    type: string
                    description: Underlying asset symbol.
                    example: USDD
                entered:
                    type: integer
                    format: int32
                    description: '`1` if the user has entered this market as collateral, `0` otherwise.'
                    enum: [0, 1]
                    example: 1
                supplyBalanceJtoken:
                    type: number
                    format: double
                    description: Supplied balance in jTokens (8 decimals).
                    example: 1.09062037
                supplyBalanceUnderlying:
                    type: number
                    format: double
                    description: Supplied balance in underlying units.
                    example: 0.01148891329334797
                borrowBalanceUnderlying:
                    type: number
                    format: double
                    description: Outstanding borrow in underlying units.
                    example: 0.704372293431166

        UserAccount:
            type: object
            description: One wallet's aggregated SBM position.
            properties:
                addresses:
                    type: string
                    description: User wallet address.
                    example: T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
                health:
                    type: number
                    format: double
                    description: Health factor. `> 1` healthy, `≤ 1` liquidatable.
                    example: 5.88
                totalCollateralValueInTrx:
                    type: number
                    format: double
                    description: Sum of collateral value in TRX (after `collateralFactor`).
                    example: 24.126681
                totalBorrowValueInTrx:
                    type: number
                    format: double
                    description: Sum of outstanding borrow value in TRX.
                    example: 11.277370
                liquidateStatusStartTime:
                    type: string
                    format: date-time
                    nullable: true
                    description: When the account first entered a liquidatable state, or `null` if currently safe.
                tokens:
                    type: array
                    items: { $ref: '#/components/schemas/UserTokenPosition' }

        AccountListResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          allOf:
                              - $ref: '#/components/schemas/Pagination'
                              - type: object
                                properties:
                                    list:
                                        type: array
                                        items: { $ref: '#/components/schemas/UserAccount' }

        # ------------------------------------------------------------------
        # /justlend/liquidate/highRiskAccountList
        # ------------------------------------------------------------------
        CollateralToken:
            type: object
            description: Collateral position of a high‑risk account.
            properties:
                jtokenAddress:    { type: string, description: jToken contract address., example: TR7BUFRQeq1w5jAZf1FKx85SHuX6PfMqsV }
                symbol:           { type: string, description: jToken symbol., example: jETH }
                amount:           { type: string, description: Collateral held, in jToken units (8 decimals)., example: '11.03049909' }
                price:            { type: string, description: jToken price in USD (already multiplied by `exchangeRate`)., example: '21.090028146702653201' }
                valueUsd:         { type: string, description: '`amount × price`.', example: '232.633536' }
                exchangeRate:     { type: string, description: jToken → underlying conversion ratio., example: '0.010021847796289808' }
                collateralFactor: { type: string, description: Collateral factor applied for risk calculation., example: '0.750000000000000000' }

        BorrowToken:
            type: object
            description: Borrow position of a high‑risk account.
            properties:
                tokenAddress:     { type: string, description: '**Underlying** asset address (note — keyed by underlying, not jToken).', example: TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9 }
                symbol:           { type: string, description: Underlying asset symbol., example: JST }
                amount:           { type: string, description: Outstanding borrowed amount in underlying units., example: '19.357667866419444238' }
                price:            { type: string, description: Underlying asset price in USD., example: '0.040802750477000000' }
                valueUsd:         { type: string, description: '`amount × price`.', example: '0.789846' }
                exchangeRate:     { type: string, description: jToken → underlying conversion ratio for this market., example: '0.010481635809265784' }
                collateralFactor: { type: string, description: Collateral factor of the corresponding jToken market., example: '0.600000000000000000' }

        HighRiskAccount:
            type: object
            description: One liquidatable / near‑liquidatable account.
            properties:
                borrower:                 { type: string, description: Borrower wallet., example: TLc34aTvy1vBFzLvM9oz36ihhb7sVpQmgQ }
                risk:                     { type: string, description: 'Risk coefficient. `> 1` ⇒ liquidatable now. Higher = riskier.', example: '1.105684' }
                totalCollateralUsd:       { type: string, description: Total collateral value in USD., example: '234.063780' }
                totalBorrowUsd:           { type: string, description: Total borrow value in USD., example: '193.705172' }
                liquidateStatusStartTime: { type: integer, format: int64, description: Epoch ms when the account first became liquidatable., example: 1770089973150 }
                collateralTokenList:
                    type: array
                    items: { $ref: '#/components/schemas/CollateralToken' }
                borrowTokenList:
                    type: array
                    items: { $ref: '#/components/schemas/BorrowToken' }

        JTokenAddressMap:
            type: object
            description: jToken symbol → contract address lookup.
            additionalProperties:
                type: string
            example:
                jTRX:  TE2RzoSV3wFK99w6J9UnnZ4vLfXYoxvRwP
                jUSDD: TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf
                jUSDT: TXJgMdjVX5dKiQaUi9QobwNxtSQaFqccvd

        HighRiskAccountListResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          properties:
                              updateTime:
                                  type: integer
                                  format: int64
                                  description: Snapshot timestamp (epoch ms).
                                  example: 1770275708508
                              jtokens:
                                  type: array
                                  items: { $ref: '#/components/schemas/JTokenAddressMap' }
                              accounts:
                                  type: array
                                  items: { $ref: '#/components/schemas/HighRiskAccount' }

        # ------------------------------------------------------------------
        # /mining/apy
        # ------------------------------------------------------------------
        MiningApy:
            type: object
            description: |
                Mining APY for one market, keyed by reward token symbol.
                Currently only `USDD` is paid out.
            properties:
                USDD:
                    type: number
                    format: double
                    description: |
                        USDD mining APY as annualized decimal. `0.09175706` =
                        9.18 %. Paid on top of the market's `supplyRate`.
                    example: 0.09175706

        MiningApyResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          description: |
                              Keyed by **jToken address**. Currently only
                              `TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf` (jUSDD)
                              receives mining rewards. A market that does not
                              appear has no mining.
                          additionalProperties:
                              $ref: '#/components/schemas/MiningApy'

        # ------------------------------------------------------------------
        # /mining/reward
        # ------------------------------------------------------------------
        PhaseStatus:
            type: integer
            format: int32
            description: |
                Phase status:
                * `0` — not started
                * `1` — in progress
                * `2` — ended (finalized / claimable)
                * `3` — paused
            enum: [0, 1, 2, 3]
            example: 1

        MarketMiningPhase:
            type: object
            description: |
                User's status in the current and previous USDD mining phase
                for one market.
            properties:
                currPhase:
                    type: integer
                    format: int64
                    description: Sequential phase number that is **in progress** now.
                    example: 64
                currStartTime: { type: string, format: date-time, description: Start of current phase (UTC). }
                currEndTime:   { type: string, format: date-time, description: End of current phase (UTC). }
                currReward:
                    type: number
                    format: double
                    description: User's accrued reward in the current phase (USDD). Updates over time.
                    example: 0.0
                currRewardStatus: { $ref: '#/components/schemas/PhaseStatus' }
                lastStartTime: { type: string, format: date-time, description: Start of the previous (most recently finalized) phase. }
                lastEndTime:   { type: string, format: date-time, description: End of the previous phase. }
                lastReward:
                    type: number
                    format: double
                    description: User's finalized reward in the previous phase (USDD). Use `/mining/distributions` for the on‑chain claim proof.
                    example: 0.0
                lastRewardStatus: { $ref: '#/components/schemas/PhaseStatus' }
                price:
                    type: number
                    format: double
                    description: Current price of the reward token in USD (USDD ≈ 1).
                    example: 1.0

        MiningRewardResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          description: Keyed by **jToken address** of the rewarded market.
                          additionalProperties:
                              $ref: '#/components/schemas/MarketMiningPhase'

        # ------------------------------------------------------------------
        # /mining/distributions
        # ------------------------------------------------------------------
        PhaseDistribution:
            type: object
            description: |
                Per‑phase claim data. All hex strings are bare `0x…` values.
            properties:
                tokenAddress:
                    type: string
                    description: Distribution contract address for this phase.
                    example: TPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn
                claimed:
                    type: boolean
                    description: '`true` if the user has already claimed this phase.'
                    example: false
                merkleIndex:
                    type: string
                    pattern: '^0x[0-9a-fA-F]+$'
                    description: Index of the Merkle tree this phase belongs to.
                    example: '0x00'
                index:
                    type: string
                    pattern: '^0x[0-9a-fA-F]+$'
                    description: Leaf index of the user inside the Merkle tree.
                    example: '0x0659'
                amount:
                    type: string
                    pattern: '^0x[0-9a-fA-F]+$'
                    description: 'Claimable reward in **underlying smallest units** (USDD: 6 decimals). Decode: `parseInt(amount, 16) / 1e6`.'
                    example: '0x6933158b3c05'
                merkleRoot:
                    type: string
                    pattern: '^0x[0-9a-fA-F]{64}$'
                    description: Merkle root of this phase.
                    example: '0x3fdc21ab4fed9e13714fa852ff2e659f9e32af553f4426810ff75e38ccf17a97'
                proof:
                    type: array
                    description: Merkle proof from the user's leaf to `merkleRoot`.
                    items:
                        type: string
                        pattern: '^0x[0-9a-fA-F]{64}$'
                        example: '0x6b734d20b9ca2a0dda57b184789dbb6df2d2993049a9365b6eafe932cd435255'

        MiningDistributionsResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          description: Keyed by phase label, e.g. `"Phase 22"`.
                          additionalProperties:
                              $ref: '#/components/schemas/PhaseDistribution'

        # ------------------------------------------------------------------
        # /lend/strx
        # ------------------------------------------------------------------
        StakeInfo:
            type: object
            description: sTRX liquid‑staking pool snapshot.
            properties:
                strxAddress:         { type: string, description: sTRX token contract address., example: TU3kjFuhtEo42tsCBtfYUAZxoqQ4yuSLQ5 }
                symbol:              { type: string, description: Token symbol., example: sTRX }
                decimal:             { type: integer, format: int32, description: sTRX decimals., example: 18 }
                underlyingDecimal:   { type: integer, format: int32, description: TRX decimals., example: 6 }
                exchangeRate:        { type: number, format: double, description: 'TRX per sTRX. `1.18` means 1 sTRX = 1.18 TRX.', example: 1.181813870419231 }
                supplyRate:          { type: number, format: double, description: sTRX staking APY as annualized decimal., example: 0.03937302 }
                totalSupply:         { type: number, format: double, description: Total sTRX issued., example: 6553955254.250488 }
                totalUnderlying:     { type: number, format: double, description: Total TRX held by the pool., example: 7745555225.580224 }
                totalSupplyUsd:      { type: number, format: double, description: TVL in USD., example: 1729932328.7582867 }
                trxPrice:            { type: number, format: double, description: Current TRX price in USD., example: 0.22334516743810272 }
                reserse:             { type: number, format: double, description: Protocol reserves in TRX. (Field name is a legacy typo — read as `reserves`.), example: 71933070.32142 }
                rentReserveFactor:   { type: number, format: double, description: Share of rental revenue taken as reserve., example: 0.20 }
                rewardReserveFactor: { type: number, format: double, description: Share of staking reward taken as reserve., example: 0.20 }

        RentInfo:
            type: object
            description: Energy Rental market snapshot.
            properties:
                rentMarketAddress:        { type: string, description: Energy Rental contract address., example: TU2MJ5Veik1LRAgjeSzEdvmDYx7mefJZvd }
                priceFor10KEnergByRent:   { type: number, format: double, description: TRX cost to obtain 10 000 Energy via **rental**., example: 0.65530713 }
                priceFor10KEnergByStake:  { type: number, format: double, description: TRX **stake** needed to produce 10 000 Energy yourself., example: 885.28697646 }
                priceFor10KEnergByBurn:   { type: number, format: double, description: TRX cost to obtain 10 000 Energy by **burning** TRX in a transaction., example: 4.20 }
                totalDelegatedEnergyTrx:  { type: number, format: double, description: Total TRX delegated through the rental market., example: 162748507.90893 }
                totalDelegatedEnergyRate: { type: number, format: double, description: Utilization rate of the rental pool., example: 0.0325497 }

        StrxSnapshotResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          type: object
                          properties:
                              stakeInfo: { $ref: '#/components/schemas/StakeInfo' }
                              rentInfo:  { $ref: '#/components/schemas/RentInfo' }

        # ------------------------------------------------------------------
        # /lend/strxStake/account
        # ------------------------------------------------------------------
        StrxStakePosition:
            type: object
            description: One wallet's sTRX position.
            properties:
                addresses:               { type: string, description: User wallet., example: TU3kjFuhtEo42tsCBtfYUAZxoqQ4yuSLQ5 }
                sTRXBalance:             { type: number, format: double, description: Current sTRX balance., example: 1.0 }
                unstakingAmount:         { type: number, format: double, description: TRX currently in the un‑staking cooldown., example: 24120999.583032 }
                availableWithdrawAmount: { type: number, format: double, description: TRX past cooldown and ready to withdraw., example: 150865439.643028 }

        StrxStakeAccountResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          allOf:
                              - $ref: '#/components/schemas/Pagination'
                              - type: object
                                properties:
                                    list:
                                        type: array
                                        items: { $ref: '#/components/schemas/StrxStakePosition' }

        # ------------------------------------------------------------------
        # /lend/rentResource/account
        # ------------------------------------------------------------------
        RentOrder:
            type: object
            description: One Energy Rental order.
            properties:
                rentType:         { type: string, description: 'Resource type. Only `"Energy"` is exposed for now.', enum: ['Energy'], example: Energy }
                renter:           { type: string, description: Account paying the rent., example: TWdWEHRLPBVGsXhwjSUv45XwnsfUHXydJa }
                receiver:         { type: string, description: Account receiving the delegated Energy., example: TWdWEHRLPBVGsXhwjSUv45XwnsfUHXydJa }
                delegatedAmount:  { type: number, format: double, description: TRX equivalent of the energy currently delegated., example: 10000.0 }
                rentRemainAmount: { type: number, format: double, description: TRX prepayment still remaining for this order., example: 8500.0 }
                rentAmountPerDay: { type: number, format: double, description: Daily TRX cost of the rental order., example: 1500.0 }

        RentAccountResponse:
            allOf:
                - $ref: '#/components/schemas/EnvelopeOk'
                - type: object
                  properties:
                      data:
                          allOf:
                              - $ref: '#/components/schemas/Pagination'
                              - type: object
                                properties:
                                    list:
                                        type: array
                                        items: { $ref: '#/components/schemas/RentOrder' }
