# JustLend Documentation — Full Text Snapshot for LLMs > A condensed, single-document snapshot of the JustLend documentation, intended for LLMs that prefer one-shot ingestion over per-page crawling. Authoritative source is the live site at ; the OpenAPI spec at is the machine-readable contract. ## 0. Snapshot metadata | Field | Value | |-------|-------| | `last_generated` | **2026-11-05** (ISO 8601, UTC date — substituted at build time) | | `docs_commit` | [`0f38b10`](https://github.com/justlend/justlend-docs/commit/0f38b10e7d635b39285a50439c1dab71a0b5515d) (the commit SHA this snapshot was built from — substituted at build time) | | `contracts_json_source` | [`/developers/contracts.json`](https://docs.justlend.org/developers/contracts.json) — see its `_meta.last_generated` for the address-data snapshot date | | `mcp_server_version` | `@justlend/mcp-server-justlend` **v1.1.3** (sync date 2026-08-19) | | `skills_version` | `@justlend/justlend-skills` **v1.1.1** (GitHub distribution; not on npm) | | `cli_version` | `justlend-cli` **v1.0.1** (GitHub source distribution; not on npm) | | `changelog` | [`CHANGELOG.md`](https://github.com/justlend/justlend-docs/blob/main/CHANGELOG.md) | | `regenerate` | This file is updated each time the docs change materially. If you fetched it more than ~30 days ago, refresh it before answering address / market / version questions. | This document covers: protocol overview, core concepts (supply / borrow / withdraw / repay / liquidation / risks / sTRX / energy rental), governance, developer contract reference, deployed addresses (TRON mainnet + Nile), the HTTP API surface, and the AI integration story (Skills + MCP + CLI + V2 Utils). For exhaustive function signatures, field-by-field response schemas, JSON ABIs, and machine-readable address formats, see the individual reference pages and the OpenAPI YAML. **Interface provenance:** The [ABI manifest](https://docs.justlend.org/developers/abis/manifest.json) records targets, verification dates, download hashes and coverage for selected interfaces. [Address verification](https://docs.justlend.org/developers/deployed_contracts/#address-verification) explains the Mainnet pointer getters. These interfaces are not complete deployment artifacts or a guarantee for later upgrades. --- ## 1. Protocol Overview JustLend is the largest lending protocol on TRON, based on the Compound V2 architecture. It is a money market: suppliers deposit TRX or TRC20 assets into per-market liquidity pools and earn interest; borrowers over-collateralize an asset to borrow another asset from the pool. Interest rates float in real time as a function of utilization. ### Roles - **Suppliers** — deposit underlying assets into a market via `mint()`. In return they receive jTokens (TRC20 receipts whose exchange rate to the underlying increases over time as interest accrues). Suppliers can `redeem` jTokens for the underlying at any time, subject to available liquidity and sufficient collateral for outstanding debt. - **Borrowers** — over-collateralize one asset to borrow another. Borrow rates are determined per-block by the interest-rate model and apply uniformly to all borrowers of the same asset in the same block. Borrowers can `repayBorrow` at any time. - **Liquidators** — repay debt of unhealthy positions and seize a discounted portion of the collateral as a reward. ### Integrated sub-protocols - **SBM (Supply and Borrow Market)** — core lending market, launched Dec 2020. - **sTRX (Staked TRX)** — liquid staking. Stake TRX, receive sTRX, earn voting + energy-rental yield. Launched Apr 2023. - **Energy Rental** — rent TRON Energy at a discount instead of burning/staking TRX yourself. Launched Apr 2023. - **Supply Mining** — JST-funded supply-side incentives administered by GrantsDAO. ### Revenue distribution from protocol reserves Risk Fund 40% · DAO Reserve 30% · Supplier/Borrower Incentives 20% · Supply Mining Rewards 10%. --- ## 2. Core Concepts ### 2.1 Supply Deposit an underlying asset → receive jTokens at the current exchange rate → earn interest via the exchange-rate appreciation of those jTokens. - **Supply APY** is driven by the borrow-utilization rate; community governance can adjust collateral factor, reserve factor, etc. - jTokens are TRC20 tokens; they can be transferred (subject to collateral constraints) and used as collateral. ### 2.2 Borrow Borrow against supplied assets, up to a per-asset **Collateral Factor**. - **Borrow APY** rises with utilization (more borrowed → higher rate). - **Borrow Limit** = Σ (supplied amount × collateral factor) across the user's entered markets. - The user must `enterMarkets` on each asset they want counted as collateral. ### 2.3 Withdraw Redeem jTokens for the underlying asset. Subject to (1) market liquidity and (2) maintaining adequate collateralization if there is an outstanding borrow. ### 2.4 Repay Pay back outstanding debt with the same underlying asset (or via `repayBorrowBehalf` to repay on behalf of another address). Reduces total borrow, lowers Risk Value, and increases the amount of collateral that is safe to withdraw. ### 2.5 Liquidation **Risk Value** indicates collateral risk; crossing a displayed threshold does not automatically execute liquidation: $$ \mathrm{Risk\ Value} = \frac{\mathrm{Total\ Borrow}}{\mathrm{Borrow\ Limit}} \times 100 $$ | Range | Risk | |-------|------| | 0–35 | Low | | 35–60 | Medium | | 60–80 | High | | 80–100 | Extremely High | | > 100 | **Liquidatable** | - Observation threshold: Risk Value > 95 (account is listed on the liquidation page). - V1 execution eligibility requires an error-free liquidity read: `error == 0 && shortfall > 0`. The ratio boundary is strictly Risk Value > 100, but a rounded display of 100 is not an execution predicate. Confirm on-chain shortfall and the other transaction guards; see the [pinned Comptroller check](https://github.com/justlend/justlend-protocol/blob/f28f3b462a4f281761e23423554563e15fc9f028/contracts/Comptroller.sol#L451-L467). - A liquidator may repay up to **50%** of a single borrowed asset in one transaction. - **Liquidation reward**: 8% of repaid debt value (paid in the seized jToken collateral). - Process is permissionless; any address may liquidate an eligible position. ### 2.6 Risks (and mitigations) - **Smart-contract risk** — public audits, community review, ongoing bug bounty program. - **Oracle risk** — uses Chainlink decentralized price feeds. - **Collateral risk** — risk service providers, governance-set risk parameters (collateral factor, borrow caps), DAO oversight. ### 2.7 Staked TRX (sTRX) One-click TRX liquid staking under Stake 2.0: - Deposit TRX into the sTRX contract → receive sTRX at the current exchange rate (1 sTRX ≥ 1 TRX, the ratio grows over time as rewards accrue). - sTRX is a standard TRC20 token and can be used in other TRON DeFi. - Yield sources: (1) Super Representative voting rewards, (2) Energy Rental revenue. - **Unstaking on JustLend has a 14-day unbonding period** before the underlying TRX can be claimed. ### 2.8 Energy Rental Rent TRON Energy at ~50–80% below the cost of burning TRX (worked example in [Energy Rental concept page §Cost Estimation](https://docs.justlend.org/getting_started/concepts/energy_rental#cost-estimation) shows 71% savings for a USDT-holding receiver and 84% for a receiver without USDT at one specific past snapshot; actual savings move with the TRON energy unit price and contract usage): - Specify: **Rental Amount** (energy units), **Rental Duration** (hourly or daily, max 30 days), **Receiving Address** (must be a regular account, not a contract). - Estimate prepayment using current rental and stable rates, the duration plus reserve threshold, and `max(minFee, delegated amount × feeRatio)`. Read current parameters rather than assuming a fixed 20 TRX fee. Refunds depend on usage and settlement, not a guaranteed constant. - One USDT transfer: ~64,000 energy if the receiver already holds USDT (warm storage), ~130,000 energy if the receiver is creating a fresh USDT balance (cold storage). 120,000 is a common midpoint estimate but it under-rents in the cold-storage case. - Energy is fully restored after 24h and reusable. - For short rentals (< 3 hours), return immediately after use to avoid early liquidation from price fluctuations. --- ## 3. Governance ### Process (on-chain — verified against `GovernorBravoDelegator` at `TEqiF5JbhDPD77yjEfnEMncGRZNDt2uogD`) 1. Non-whitelisted proposers need available WJST strictly greater than **200,000,000** (`proposalThreshold() = 2e26` raw units, read on 2026-10-14). A current whitelist entry bypasses this balance gate, not other proposal checks. Call `propose()` on `GovernorBravoDelegator`, not the implementation. 2. `startBlock = creationBlock + votingDelay`; Pending includes `block.number <= startBlock`. With the observed `votingDelay() = 1`, creation at B means B+1 is still Pending and B+2 is the earliest Active block. Read `state(proposalId)` before voting. The ~2-day off-chain forum discussion is not protocol-enforced; the on-chain block boundary still applies. 3. Voting runs for `votingPeriod() = 86,400 blocks ≈ 3 days`. 1 JST = 1 Vote after depositing JST into WJST. Votes use the available WJST balance at voting time, not a proposal-block snapshot; voted weight is locked. Once the proposal is no longer Pending or Active, call WJST.withdrawVotes(proposalId) to unlock, then WJST.withdraw(amount) to redeem JST. 4. After voting, a non-canceled proposal passes when For votes > Against votes AND For votes >= **600,000,000** (`quorumVotes() = 6e26`, read on 2026-10-14). Exact quorum passes; a tie with Against fails. See [governance boundaries and pinned source](https://docs.justlend.org/developers/supply_and_borrow_market/governance/#governance-boundaries-and-evidence). 5. A successful proposal must be queued. The Timelock delay is `172,800 sec = 48 hours` from queueing, after which `execute()` can be called before expiry; execution is not automatic. Full on-chain cycle: ~3 days voting + ~48 hours Timelock ≈ **5 days minimum**. Community typically adds ~2 days of forum discussion before `propose()` is called, for a total wall-clock of ~1 week — but again, that pre-propose discussion is not enforced anywhere. Discussion: . ### Tokenomics (JST) JST is the governance and incentive token. Holders use it to vote on JIPs. JST is also used in the buyback-and-burn program (via GrantsDAO) — protocol base income and partner donations are converted to JST liquidity on SunSwap V2, and the resulting LP tokens are burned. This reduces effective supply while maintaining DEX liquidity. --- ## 4. Developer Reference — Core Contracts ### 4.1 SBM (`CToken.sol` / `JToken`) User-facing contract. Methods listed below are on each jToken (e.g., jUSDT, jTRX). #### Query (read-only) ```solidity function exchangeRateCurrent() public nonReentrant returns (uint) // scaled 1e18 function getCash() public view returns (uint) function totalBorrowsCurrent() external nonReentrant returns (uint) function borrowBalanceCurrent(address account) external nonReentrant returns (uint) function borrowRatePerBlock() external view returns (uint) // scaled 1e18 function supplyRatePerBlock() external view returns (uint) // scaled 1e18 function totalSupply() external view returns (uint256) function balanceOfUnderlying(address owner) external returns (uint) function totalReserves() returns (uint) function reserveFactorMantissa() returns (uint) ``` #### Write ```solidity function mint() external payable // jTRX only — supply TRX via msg.value function mint(uint mintAmount) external returns (uint) // jTRC20 — supply TRC20; requires prior approve() function borrow(uint borrowAmount) external returns (uint) function repayBorrow(uint amount) external payable // Mainnet jTRX: amount in sun AND callValue function repayBorrow(uint repayAmount) external returns (uint) // jTRC20: underlying raw units; prior approve function repayBorrowBehalf(address borrower) external payable // jTRX: amount via callValue function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) // jTRC20 function redeem(uint redeemTokens) external returns (uint) function redeemUnderlying(uint redeemAmount) external returns (uint) function transfer(address dst, uint256 amount) external nonReentrant returns (bool) function liquidateBorrow(address borrower, uint repayAmount, address jTokenCollateral) returns (uint) // jTRC20 function liquidateBorrow(address borrower, address jTokenCollateral) payable // jTRX ``` Events emitted: `Mint`, `Borrow`, `RepayBorrow`, `Redeem`, `LiquidateBorrow`. See the SBM reference page for full event signatures. ### 4.2 Comptroller (Unitroller proxy → Comptroller impl) Risk management module. Users must `enterMarkets()` to use a supplied asset as collateral. ```solidity function enterMarkets(address[] memory cTokens) public returns (uint[] memory) function exitMarket(address cTokenAddress) external returns (uint) function getAssetsIn(address account) external view returns (CToken[] memory) function markets(address cTokenAddress) view returns (bool isListed, uint collateralFactorMantissa, bool comped) function getAccountLiquidity(address account) public view returns (uint error, uint liquidity, uint shortfall) function closeFactorMantissa() view returns (uint256) // % of debt that may be liquidated in one call function liquidationIncentiveMantissa() view returns (uint256) // scaled 1e18 ``` After checking `error == 0`, `getAccountLiquidity` reports available `liquidity` or a positive `shortfall`; at most one is non-zero, and both may be zero at the boundary. Positive shortfall is the V1 undercollateralization condition, not a guarantee that every liquidation transaction will succeed. Rounded Risk Value and API health values do not replace it; a no-debt account can return API `health = "0"` without being liquidatable. ### 4.3 Interest Rate Models Two models in use: - **WhitePaperInterestRateModel** — $\mathrm{borrowRate}(u) = a \times u + b$. Used for jTRX historically. - **JumpRateModelV2** — kinked. Below `kink`: $a_1 \times u + b$. Above `kink`: $a_1 \times \mathrm{kink} + a_2 \times (u - \mathrm{kink}) + b$. Used for most TRC20 markets. In both: $$ u = \frac{\mathrm{borrows}}{\mathrm{cash} + \mathrm{borrows} - \mathrm{reserves}} $$ $$ \mathrm{supplyRate}(u) = \mathrm{borrowRate}(u) \times u \times (1 - \mathrm{reserveFactor}) $$ ### 4.4 Price Oracle (`SimplePriceOracle.sol`, via `PriceOracleProxy`) Backed by Chainlink. Prices are denominated in sun (10⁻⁶ TRX), scaled by `10^(tokenDecimal − 6)`. ```solidity function getPrice(address asset) public view returns (uint) function assetPrices(address asset) public view returns (uint) function anchors(address) view returns(uint256 period, uint256 priceMantissa) function poster() view returns(address) function setPrice(address asset, uint requestedPriceMantissa) public returns (uint) // poster-only ``` ### 4.5 Governance — `GovernorBravoDelegate.sol` ```solidity function propose(address[] targets, uint[] values, string[] signatures, bytes[] calldatas, string description) public returns (uint) function queue(uint proposalId) public function execute(uint proposalId) public payable function cancel(uint proposalId) public function getActions(uint proposalId) public view returns (address[], uint[], string[], bytes[]) function getReceipt(uint proposalId, address voter) public view returns (Receipt) // {hasVoted, support, votes} function state(uint proposalId) public view returns (ProposalState) // Pending|Active|Canceled|Defeated|Succeeded|Queued|Expired|Executed // WJST (not Governor): deposit(uint256 amount), withdrawVotes(uint256 proposalId), withdraw(uint256 amount) function castVote(uint proposalId, uint votes, uint8 support) public function castVoteWithReason(uint proposalId, uint votes, uint8 support, string reason) public function castVoteBySig(uint256 proposalId, uint256 votes, uint8 support, uint8 v, bytes32 r, bytes32 s) external ``` ### 4.6 sTRX Contract: `TU3kjFuhtEo42tsCBtfYUAZxoqQ4yuSLQ5` (mainnet). ```solidity function exchangeRate() public view returns (uint256) // sTRX → TRX, scaled 1e18 function totalUnderlying() public view returns (uint256) function viewBalanceOfUnderlying(address _account) public view returns (uint256) function round() view external returns (uint256) // current unfreezing round (starts at 1) function claimable() external returns (uint256) function withdrawal() external returns (uint256) function balanceToUnfreeze() external returns (uint256) function balanceToFreeze() external returns (uint256) function deposit() external payable returns (uint256) // TRX → sTRX function withdraw(uint256 tokenAmount) external returns (uint256) // sTRX → unfreezing queue function withdrawExact(uint256 trxAmount) external returns (uint256) function claim() external returns (uint256) // claim oldest finished round function claimAll() external returns (uint256) ``` ### 4.7 Energy Rental Contract: `TU2MJ5Veik1LRAgjeSzEdvmDYx7mefJZvd` (mainnet). New-rental budget estimate in integer raw units (not an executable quote): ``` feeSun = max(minFeeSun, ceil(amountSun × feeRatioMantissa / 10^18)) prepaySun = ceil(amountSun × max(rentalRateMantissa, stableRateMantissa) × (durationSeconds + 86400 + liquidateThresholdSeconds) / 10^18) + feeSun ``` Read both rates, the time threshold, the proportional fee ratio, and the minimum fee from the current deployment. For a read-only MCP estimate, use `calculate_energy_rental_price` with `energyAmount` and `durationHours` (plus `receiverAddress` for an existing order). Do not invoke the signing/broadcasting `rent_energy` tool merely to quote a price. MCP commit `7d53a6c` can silently substitute fallback defaults on failed parameter/rate reads, without per-field provenance in the structured quote; success does not prove live data. Independently verify current rates, threshold, fees, rental availability and applicable order state. If inputs cannot be verified, stop before signing or broadcasting; otherwise recompute and confirm separately. See the [version-specific fallback warning and source](https://docs.justlend.org/developers/energy_rental/#2-estimate-the-full-new-rental-prepayment-read-only). Refunds and renewal deposits depend on actual order state. Key functions: ```solidity function rentResource(address receiver, uint256 amount, uint256 resourceType) external payable function returnResource(address receiver, uint256 amount, uint256 resourceType) external returns (uint256) function returnResourceByReceiver(address renter, uint256 amount, uint256 resourceType) external returns (uint256) function liquidate(address renter, address receiver, uint256 resourceType) external returns (uint256) function rentals(address renter, address receiver, uint256 resourceType) public view returns (RentalInfo) function getRentInfo(address renter, address receiver, uint256 resourceType) external view returns (uint256, uint256) function _rentalRate(uint256 amount, uint256 resourceType) view external returns (uint256) function _liquidateRate(uint256 resourceType) view external returns (uint256) function badDebt() view external returns (uint256) function badDebtCovered() view external returns (uint256) function badDebtGap() view external returns (uint256) function totalRent() view external returns (uint256) function rentClaimed() external view returns (uint256) ``` `resourceType`: `0 = bandwidth`, `1 = energy`. `rentClaimed()` is the recorded cumulative rental income transferred to sTRX, in sun. It is not the same as `totalRent()`. `claimRental() external returns (uint256)` is a **write restricted to the configured sTRX contract**, not a monitoring read. It returns the actual transfer **in this call**, in sun (`1 TRX = 1,000,000 sun`), or zero if nothing is transferred. A positive transfer emits `RentClaimed(add, totalClaimed)`, where both non-indexed fields are in sun and `totalClaimed` is the counter after the transfer. See [Rental income collection](https://docs.justlend.org/developers/energy_rental/#protocol-income-collection). ### 4.8 SBM Error Codes (selected) | Code | Name | Notes | |------|------|-------| | 0 | NO_ERROR | Success | | 1 | UNAUTHORIZED | | | 2 | BAD_INPUT | | | 3 | COMPTROLLER_REJECTION | Violates risk policy | | 9 | MATH_ERROR | | | 11 | MARKET_NOT_LISTED | | | 12 | TOKEN_INSUFFICIENT_ALLOWANCE | Run `approve()` first | | 13 | TOKEN_INSUFFICIENT_BALANCE | | | 14 | TOKEN_INSUFFICIENT_CASH | Try again later — market is empty | Full error code (17 codes) and failure-info enum (~78 entries) tables are on the SBM reference page. --- ## 5. Deployed Contracts (TRON Mainnet + Nile) The rendered tables below summarize **TRON Mainnet** Base58 addresses. For machine use, fetch `/developers/contracts.json`; it includes Mainnet and Nile addresses in Base58, EVM `0x` hex, TRON-internal `41` hex, and Tronscan URLs. JSON ABI files are available under `/developers/abis/`. To validate `contracts.json` end-to-end, fetch the Draft 2020-12 [`/developers/contracts.schema.json`](https://docs.justlend.org/developers/contracts.schema.json) (`$id` = its own URL); it constrains the TRON Base58 / EVM `0x` / TRON `41`-hex address regexes, the per-network category enum, and the required `_meta` keys (`source_of_truth`, `last_generated`, `schema_version`, `address_formats`). ### 5.1 SBM core - **Unitroller (Comptroller proxy)**: `TGjYzgCyPobsNS9n6WcbdLVR9dH7mWqFx7` - **Comptroller (implementation)**: `TB23wYojvAsSx6gR8ebHiBqwSeABiBMPAr` ### 5.2 jToken delegators (the addresses users interact with) **Protocol-wide market count: 18 active + 6 legacy = 24 jToken markets total** (TRON Mainnet, as of the `last_generated` date in §0 above). Rows tagged `(legacy)` are **closed to new supply and borrow** — existing positions can still be unwound but do not direct new deposits to them. Single source of truth (in order of preference): (1) live `GET https://openapi.just.network/lend/jtoken`, (2) `/developers/contracts.json`, (3) `apis.md §2`. Any other page that quotes a smaller count (e.g. the 9-market "featured" table in `ai_support/justlend_skills.md`) is showing a CLI-convenience subset, not the full protocol roster. Note: the dApp UI has renamed two markets — `jETH` is displayed as "ETH" (formerly "ETHOLD"), and `jETHB` is displayed as "ETHB" (formerly "ETH"). On-chain addresses are unchanged. | Underlying | jToken (CErc20Delegator) | Underlying TRC20 | |------------|--------------------------|------------------| | TRX | `TE2RzoSV3wFK99w6J9UnnZ4vLfXYoxvRwP` | native | | USDT | `TXJgMdjVX5dKiQaUi9QobwNxtSQaFqccvd` | `TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t` | | USDD | `TKFRELGGoRgiayhwJTNNLqCNjFoLBh3Mnf` | `TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz` | | USDCOLD (legacy) | `TNSBA6KvSvMoTqQcEgpVK7VhHT3z7wifxy` | `TLZSucJRjnqBKwvQz6n5hd29gbS4P7u7w8` | | USDJ (legacy) | `TL5x9MtSnDy537FXKx53yAaHRRNdg9TkkA` | `TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT` | | TUSD | `TSXv71Fy5XdL3Rh2QfBoUu3NAaM4sMif8R` | `TUpMhErZL2fhh4sVNULAbNKLokS4GjC1F4` | | USD1 | `TBEKggwqFkrc4KckQVR9BLucAmQugafEZf` | `TPFqcBAaaUMCSVRCqPaQ9QnzKhmuoLR6Rc` | | wstUSDT | `TD5SdLw5scR6mXgyMK2xKrFJpauDjpKqrW` | `TGkxzkDKyMeq2T7edKnyjZoFypyzjkkssq` | | sTRX | `TJQ9rbVe9ei3nNtyGgBL22Fuu2xYjZaLAQ` | `TU3kjFuhtEo42tsCBtfYUAZxoqQ4yuSLQ5` | | SUN | `TPXDpkg9e3eZzxqxAUyke9S4z4pGJBJw9e` | `TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S` | | BTT | `TUaUHU9Dy8x5yNi1pKnFYqHWojot61Jfto` | `TAFjULxiVgT4qWk6UZwjqwZXTSaGaqnVp4` | | NFT | `TFpPyDCKvNFgos3g3WVsAqMrdqhB81JXHE` | `TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq` | | JST | `TWQhCXaWz4eHK4Kd1ErSDHjMFPoPc9czts` | `TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9` | | WIN | `TRg6MnpsFXc82ymUPgf5qbj59ibxiEDWvv` | `TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7` | | HTX | `TDA1mWPyAjTRATMGA55UTswGAHhV2itEXR` | `TUPM7K8REVzD2UdV4R5fe5M8XbnR2DdoJ6` | | BTC | `TLeEu311Cbw63BcmMHDgDLu7fnk9fqGcqT` | `TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9` | | WBTC | `TVyvpmaVmz25z2GaXBDDjzLZi5iR5dBzGd` | `TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi` | | ETHB | `TWBxQMb6RD3qmkXUXpNwVCYbL8SHNreru6` | `TRFe3hT5oYhjSZ6f3ji5FJ7YCfrkWnHRvh` | | ETH | `TR7BUFRQeq1w5jAZf1FKx85SHuX6PfMqsV` | `THb4CqiFdwNHsWsQCs4JhzwjMWys4aqCbF` | | WBTT (legacy) | `TUY54PVeH6WCcYCd6ZXXoBDsHytN9V5PXt` | `TKfjV9RNKJJCqPvBtK8L7Knykh7DNWvnYt` | | USDDOLD (legacy) | `TX7kybeP6UwTBRHLNPYmswFESHfyjm9bAS` | `TPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn` | | BUSDOLD (legacy) | `TLHASseQymmpGQdfAyNjkMXFTJh8nzR2x2` | `TMz2SWatiAtZVVcH2ebpsbVtYwUPT9EdjH` | | SUNOLD (legacy) | `TGBr8uh9jBVHJhhkwSJvQN2ZAKzVkxDmno` | `TKkeiboTkxXKJpbmVFbv4a8ov5rAfRDMf9` | For the full list including each delegator's matching delegate-implementation contract, see . ### 5.3 Price Oracle - **PriceOracle (impl)**: `TMiNCmvD3zdsv6mk7niBU6NPBzVNjYMQTV` - **PriceOracleProxy** (current Comptroller oracle): `TGnYnSn4G9PgWFj7QQemh4YMZKp3fkympJ` ### 5.4 Governance - **GovernorBravoDelegator** (entrypoint): `TEqiF5JbhDPD77yjEfnEMncGRZNDt2uogD` - **GovernorBravoDelegate** (impl): `TUeNh9BsYK44XePmFAuKZWg2rJuU7bSt5u` - **Timelock**: `TRWNvb15NmfNKNLhQpxefFz7cNjrYjEw7x` - **JST** (token): `TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9` ### 5.5 Other - **sTRX**: `TU3kjFuhtEo42tsCBtfYUAZxoqQ4yuSLQ5` - **Energy Rental**: `TU2MJ5Veik1LRAgjeSzEdvmDYx7mefJZvd` Interest-rate models and CErc20Delegate implementations are also listed at . --- ## 6. HTTP API Base URL: `https://openapi.just.network`. Authoritative schema: (OpenAPI 3.1). Importable into Swagger UI, Postman, and any LLM tool. ### Endpoints | Method | Path | Purpose | |--------|------|---------| | GET | `/lend/jtoken` | All SBM V1 markets — supply/borrow APY, TVL, decimals, prices | | GET | `/lend/account?addresses={a,b}` | Per-address SBM V1 positions, health, with pagination & filters | | GET | `/justlend/liquidate/highRiskAccountList` | Accounts with Risk Value > observation threshold, useful for liquidator bots | | GET | `/mining/reward?address={a}` | Per-user mining phase status (keyed by market address → reward-token symbol) | | GET | `/mining/apy` | Per-market USDD mining APY (all markets returned; `"0.00000000"` = inactive) | | GET | `/mining/distributions?addr={a}` | Per-user Merkle claim proofs per phase — ⚠️ parameter is `addr`, not `address` | | GET | `/lend/strx` | sTRX market + Energy Rental dashboard | | GET | `/lend/strxStake/account?addresses={a,b}` | Per-address sTRX staking state | | GET | `/lend/rentResource/account?addresses={a,b}` | Per-address energy rental orders | | GET | `/v2/index/vault/list` | All JustLend V2 (Moolah) vaults — TVL, APY, allocations; user vaults with `address` | | GET | `/v2/index/market/list` | All V2 isolated markets — LLTV, liquidity, borrow rate; user markets with `address` | | GET | `/v2/index/position?address={a}` | Aggregated V2 portfolio for one wallet | | GET | `/v2/vault/position?vaultAddress={v}&address={a}` | User position in one V2 vault | | GET | `/v2/market/position?market={0x…id}&address={a}` | User position in one V2 isolated market | ### Response envelope and error contract V1 endpoints (`/lend/...`, `/mining/...`, `/justlend/...`): ```json { "code": 0, // 0 = success (V1) "message": "SUCCESS", "data": { ... } } ``` V2 endpoints (`/v2/...`): ```json { "code": 200, // 200 = success (V2) "message": "Success", "data": { ... }, "timestamp": 1784101532272 } ``` **Business and validation errors are returned with HTTP `200`** and the same envelope — `code ≠ 0` (V1, `data` absent) or `code ≠ 200` (V2, e.g. `202` invalid parameters, `data: null`). Branch on the body `code`, never on the HTTP status; only transport-level `429` / `5xx` surface as non-200. All decimal quantities (amounts, rates, prices, indexes) are JSON **strings** — parse with big-decimal/BigInt (values like `borrowIndex` and V2 share amounts exceed 2^53). Field types, `required` arrays, and units (`x-unit` / `x-decimals` / `x-format` extensions; jToken units = 8 decimals, APY as annualized decimal, USD values pre-scaled) are spelled out in the OpenAPI components schemas — **prefer the YAML to free-text interpretation**. ### Event-stream / historical-event indexing The HTTP API returns **current state**. For historical events (`Mint`, `Borrow`, `RepayBorrow`, `LiquidateBorrow`, governance `VoteCast`, sTRX `Deposit`, EnergyRental `RentResource`, etc.) there is **no official JustLend subgraph or hosted indexer**. Use one of: 1. **TronGrid event filter** — `GET /v1/contracts/{address}/events?event_name=Mint&...`. Free tier suffices for ad-hoc analytics; ~30-day retention. Best for low-volume agent queries. 2. **Self-hosted indexer** — most robust path is a custom decoder against a `java-tron` archive node (or TronGrid archive plan) + the JSON ABIs at . Generic EVM indexers (DipDup, Subsquid, Substreams, Goldsky, …) have evolving TRON support and should be evaluated case-by-case; do not adopt one based on a "supports TRON" claim without a proof-of-concept run against your specific events first. Best for production analytics, full historical backfills. 3. **Compose MCP server read primitives** — for low-volume agent-driven lookups via `@justlend/mcp-server-justlend`. Not optimized for historical-event sweeps. Interfaces at `/developers/abis/` are subsets, not a universal event registry. `strx.json` now includes all 27 event declarations from the current Mainnet STRXG2 implementation, including `Deposit`, `Withdraw`, and `Claim`; `energy-market.json` includes `RentResource`, `ReturnResource`, `Liquidate`, and `RentClaimed`, with compiler-aligned tuple/bool/refund returns. These additions use bytecode-matched compiler output (excluding compiler metadata), with the four settlement events also checked against real receipts. Check the exact event definition and indexed flags; obtain the matching deployment ABI when absent or decoding a different historical implementation. Derive `topic0` only from a verified signature. See [APIs §8](https://docs.justlend.org/developers/apis#8-event-stream-and-indexing-options) and [ABI provenance](https://docs.justlend.org/developers/abis/#scope-and-provenance). --- ## 7. AI Agent Integration JustLend ships four complementary agent and developer integration surfaces: ### 7.1 JustLend Skills — GitHub distribution Workflow skills package with a bundled read-only runtime, version **v1.1.1**. Repo: . Install by cloning that repository and running `bash install.sh`. The local package identifier `@justlend/justlend-skills` is **not published to npm**; do not use `npm install @justlend/justlend-skills`. An `npm install` run inside the clone only installs the project's dependencies. - Combines structured **skill instructions** (for any Claude-compatible agent — Claude Code, Claude Desktop, Cursor, Codex) with a lightweight built-in **read-only MCP server** exposing **9 query tools**. - Also runs standalone as a **CLI** (`node scripts/justlend_api.mjs markets|dashboard|account ...`). - Requires `TRONGRID_API_KEY` (free at ). Supports `NETWORK=mainnet|nile`. - The bundled MCP server and standalone CLI need no wallet and are strictly read-only. Write skill workflows route to the full MCP server, a signing wallet, and explicit confirmation. - All 9 tools declare a versioned `outputSchema`. Successes expose `{ schemaVersion: "1.0.0", tool, result }` in `structuredContent` while preserving raw JSON text; failures expose `{ schemaVersion, tool, error, errorCode, retryable, hint }`. Auto-retry only `rate_limit` / `transient` errors. - `get_supported_markets` lists only 8 bundled balance/allowance shortcuts. Use `get_all_markets`, the live API, or `contracts.json` for the canonical **24-market (18 active + 6 legacy)** roster. Skill modules: | Skill | Function | Backend | |-------|----------|---------| | `justlend-lending-v1` | V1 queries and lending write workflows | Built-in reads; full MCP writes | | `justlend-lending-v2` | V2 isolated markets and ERC4626 vault guidance | Requires full MCP | | `justlend-trx-staking` | sTRX staking guidance | Requires full MCP (write) | | `justlend-energy-rental` | Energy rental guidance | Requires full MCP (write) | | `justlend-energy-purchase` | Quote-bound direct Energy purchase and recovery | Requires full MCP (write) | | `justlend-governance-v1` | JIP voting guidance | Requires full MCP (write) | Built-in MCP tools (all read-only): `get_all_markets`, `get_dashboard`, `get_supported_markets`, `get_jtoken_details`, `get_account_summary`, `get_account_data_from_api`, `get_trx_balance`, `get_token_balance`, `check_allowance`. ### 7.2 Full MCP Server — `@justlend/mcp-server-justlend` Read + write MCP server, **104 tools**, version **v1.1.3**. Repo: . Covers **JustLend V1 and V2** — including quote-bound energy direct purchase with public payer-history and payer-scoped recovery, plus `moolah_*` / `get_moolah_*` for V2 vaults, isolated markets, liquidation, dashboard/history, and mining. Every tool declares a common success `outputSchema`; successful calls preserve text content and add `{ schemaVersion: "1.0.0", tool, result }` in `structuredContent`. The generated [`mcp-api-list.md`](https://github.com/justlend/mcp-server-justlend/blob/main/mcp-api-list.md) lists input/output contracts and side-effect classes for offline routing. Capability domains: - **Wallet & Network** (10 tools) — supported writes use `agent` mode with an encrypted local wallet under `~/.agent-wallet/`, managed by `@bankofai/agent-wallet`. The legacy loopback browser bridge is disabled because it lacks request-level authentication; `connect_browser_wallet` returns a safety notice and selecting `browser` fails closed. Importing an existing key is intentionally CLI-only (`npx agent-wallet add`) — not exposed as an MCP tool, since MCP arguments can be logged by clients. Tools: `get_wallet_address`, `connect_browser_wallet`, `set_wallet_mode`, `get_wallet_mode`, `list_wallets`, `set_active_wallet`, `get_supported_networks`, `get_supported_markets`, `set_network`, `get_network`. - **Market Data** (3 tools) — contract queries first with API fallback; TTL caching (30–60s). `get_market_data`, `get_all_markets`, `get_protocol_summary`. - **Account & Balances** (5 tools) — Multicall3 batch queries (~2.5s vs ~8s legacy). Multicall3 on TRON Mainnet: `TX56WKxtja91Dybf2FdN4hZbDLyKVxxhAu` (verified on-chain — name = `Multicall3`, `getCurrentBlockTimestamp()` returns valid epoch). `get_account_summary`, `check_allowance`, `get_trx_balance`, `get_token_balance`, `get_wallet_balances`. - **Lending Operations** (10 tools) — `supply`, `withdraw`, `withdraw_all`, `borrow`, `repay`, `enter_market`, `exit_market`, `approve_underlying`, `claim_rewards`, `estimate_lending_energy`. Write tools marked with `destructiveHint: true`. - **Mining & Rewards** (3 tools) — `get_mining_rewards`, `get_usdd_mining_config`, `get_wbtc_mining_config`. - **JST Voting / Governance** (10 tools) — `get_proposal_list`, `get_user_vote_status`, `get_vote_info`, `get_locked_votes`, `check_jst_allowance_for_voting`, `approve_jst_for_voting`, `deposit_jst_for_votes`, `withdraw_votes_to_jst`, `cast_vote`, `withdraw_votes_from_proposal`. - **Energy Rental / Direct Purchase** (15 tools) — nine rental tools plus `get_energy_purchase_config`, `quote_energy_purchase`, `get_energy_purchase_order`, `get_energy_purchase_history`, `get_energy_payment_risk`, and explicitly confirmed `buy_energy_direct`. Mainnet uses `https://tegrow.ablesdxd.link` by default; non-mainnet requires a matching custom service. Direct purchase is quote-bound and, after signing, an ambiguous result may retain the exact signed request in a local mode-`0600` recovery file. The request is redacted from output and removed after public-history reconciliation or deterministic pre-broadcast rejection. The no-argument `get_energy_payment_risk` tool only reports unresolved state for the configured wallet and never replays a payment; a non-empty risk list blocks a second payment. - **sTRX Staking** (7 tools) — dashboard, account, balance, withdrawal-eligibility check, `stake_trx_to_strx`, `unstake_strx`, `claim_strx_rewards`. Staking paths use precision-safe string/BigInt math for TRX Sun conversion and 18-decimal sTRX balances/exchange-rate display. - **Transfers** (2 tools) — `transfer_trx`, `transfer_trc20`. - **General TRON utilities** (via the same tool set) — balances, blocks, transactions, contract read/write, multicall, TRC20/TRC721/TRC1155 metadata, transfers, Stake 2.0 freeze/unfreeze, address conversion, wallet management, message signing. - **JustLend V2 — Vaults** (6 tools) — ERC4626 vaults: `get_moolah_vaults`, `get_moolah_vault`, `approve_moolah_vault`, `moolah_vault_deposit`, `moolah_vault_withdraw`, `moolah_vault_redeem`. - **JustLend V2 — Markets** (8 tools) — isolated markets defined by `(loanToken, collateralToken, oracle, irm, lltv)`: `get_moolah_markets`, `get_moolah_market`, `get_moolah_user_position`, `approve_moolah_proxy`, `moolah_supply_collateral`, `moolah_withdraw_collateral`, `moolah_borrow`, `moolah_repay`. - **JustLend V2 — Liquidation** (5 tools) — public liquidator at the market LLTV: `get_moolah_pending_liquidations`, `get_moolah_liquidation_quote`, `get_moolah_liquidation_records`, `approve_liquidator_token`, `moolah_liquidate`. - **JustLend V2 — Dashboard, History & Mining** (11 tools) — `get_moolah_dashboard`, `get_moolah_history`, `get_moolah_records`, `get_moolah_vault_history`, `get_moolah_market_history`, `estimate_moolah_energy`, `get_moolah_vault_mining_apy`, `get_moolah_mining_resolver`, `get_moolah_mining_accruing`, `get_moolah_pending_mining_periods`, `claim_moolah_mining_period`. - **Historical Records** (7 tools) — V1 + cross-cutting paginated history: `get_lending_records`, `get_strx_records`, `get_vote_records`, `get_energy_rental_records`, `get_liquidation_records`, `get_claimable_rewards`, `claim_v1_mining_period`. Guided prompts ship with the server (14 total): `getting_started`, `supply_assets`, `borrow_assets`, `repay_borrow`, `analyze_portfolio`, `compare_markets`, `rent_energy`, `stake_trx`, `query_proposals`, `cast_vote`, `moolah_supply`, `moolah_borrow`, `moolah_liquidate`, `moolah_portfolio`. **Transport modes**: `stdio` (local clients — Claude Desktop, Codex, Claude Code, Cursor) or `HTTP/SSE` (remote/multi-client). HTTP mode is **fail-closed**: `MCP_API_KEY` is required, binds to `127.0.0.1` by default, CORS disabled unless `MCP_CORS_ORIGIN` is set. **Machine-readable ABIs**: JSON files are available under . The upstream MCP server keeps the source TypeScript definitions in [`src/core/abis.ts`](https://github.com/justlend/mcp-server-justlend/blob/main/src/core/abis.ts); per-network contract addresses are mirrored in `/developers/contracts.json` from [`src/core/chains.ts`](https://github.com/justlend/mcp-server-justlend/blob/main/src/core/chains.ts). ### 7.3 JustLend CLI — deterministic terminal automation Source-installable CLI, version **v1.0.1**. Repo: . It is not currently published to npm: clone the official repository, run `npm ci && npm run build`, then `npm link`. - 30 top-level command groups cover V1/V2 reads and writes, staking, energy rental, governance, rewards, history, portfolio, and simulation. Nested `energy purchase history ` recovers public in-progress and settled direct-purchase orders. - Use `--json` and branch on the process exit code for agents and CI. Success is `{ schemaVersion: "1.0.0", success: true, data }`; failure is `{ schemaVersion, success: false, error, code, retryable, hint? }`, including parser/usage failures. Validate with `schemas/output-v1.schema.json`; never scrape human tables. - Run `--dry-run --dry-run-owner
` before any write; dry-run does not sign or broadcast. - `--no-broadcast` signs without sending for supported write commands. Energy direct purchase rejects it because the configured backend controls broadcast; use a quote or `--dry-run` before the explicitly confirmed purchase. Mainnet broadcasts require explicit user intent; never add `--yes` automatically. - Prefer Nile for integration tests. Full guidance: . ### 7.4 JustLend V2 Utils — embedded browser / Node.js SDK Source-installable utility library, version **v1.0.0**. Repo: . Install with `npm install github:justlend/justlend-utils-v2`; it is not currently published to npm. - Covers V2 vaults, lending markets, liquidations, mining rewards, native TRX/WTRX handling, and energy purchase workflows. - Inject a ready `TronWeb` instance and set the sender explicitly in Node.js. - Preserve amount values as strings or `BigNumber`; never use JavaScript `number` for token quantities. - Many helpers sign or broadcast. Resolve addresses from live/canonical sources, use Nile first, and require human confirmation before Mainnet writes. - Never expose private keys or signed transaction payloads in prompts, logs, or agent output. ### 7.5 Recommended source-of-truth priority for AI agents 1. **OpenAPI spec + the `https://openapi.just.network` HTTP API** — typed, versioned, machine-readable public data. 2. **MCP server tools** — schema-discoverable agent workflows with side effects marked. 3. **JustLend CLI** — deterministic terminal/CI automation through versioned JSON and exit codes. 4. **JustLend V2 Utils** — embedded browser/Node.js integrations owned by the application. 5. **Rendered HTML docs** — concept understanding; cross-check dynamic values and exact machine contracts against sources 1–4. ### 7.6 Precision and units (AI must respect) - **jToken balances**: scaled by `1e8` (8 decimals). - **Underlying TRC20 amounts**: each token's own decimals — TRX = 6, USDT = 6, USDC = 6, USDD = 18, BTC/WBTC = 8, ETH = 18, etc. Always call `decimals()` on the underlying before constructing a `mint` / `borrow` / `repayBorrow` amount. - **Rates** (`borrowRatePerBlock`, `supplyRatePerBlock`): scaled by `1e18`, per-block. To convert to APY, multiply by blocks-per-year and compound; on TRON at the current ~3 s/block this is approximately **10,512,000** (`365 × 86400 / 3`) for a 365-day year or **10,519,200** (`365.25 × 86400 / 3`) when accounting for the leap-year average. Both are approximations — the on-chain block cadence drifts. **Prefer the API's pre-computed `apy` / `supplyRate` / `borrowRate` fields** when you need precision; only do the conversion yourself when the API is unreachable. - **Prices** from the oracle: in sun (10⁻⁶ TRX), scaled by `10^(tokenDecimal − 6)`. - **Collateral factor, reserve factor, exchange rate, liquidation incentive**: all mantissa-scaled by `1e18`. --- ## 8. Resources - **Audit — SBM**: - **Audit — sTRX**: - **Whitepaper**: - **Forum**: - **dApp**: - **GitHub (protocol)**: - **GitHub (Skills)**: - **GitHub (MCP server)**: - **GitHub (CLI)**: - **GitHub (V2 Utils)**: - **Terms of Service**: - **Privacy Policy**: --- ## 9. Notes & Caveats for LLM Consumers - This file is a **snapshot**, regenerated periodically. Treat live endpoints (OpenAPI YAML, sitemap, MCP `list_tools`) as the source of truth when numbers diverge. - Addresses summarized in §5 are rendered for readability. For exact Mainnet and Nile addresses in Base58, EVM `0x` hex, and TRON-internal `41` hex, use . - The public OpenAPI service is unauthenticated and may throttle abusive clients. Keep `pageSize <= 1000`, cache stable market metadata, and retry `429` / transient `5xx` with exponential backoff and jitter. - Where this document gives APYs, TVL, or other dynamic numbers as examples (notably in the Energy Rental cost section), they reflect the moment the underlying example transactions were recorded and are not current. - Liquidation rules summarized here describe the contract-level mechanism. The official liquidation tool also enforces additional UX-level disclaimers — see . - "Read-only" guarantees for the HTTP API and the bundled Skills MCP server are enforced by code paths (no signing keys), not just policy. The full MCP server, CLI, and V2 Utils can submit transactions through their configured wallet/signer paths; inspect side effects, simulate first, and require explicit human intent before signing or broadcasting.