> For the complete documentation index, see [llms.txt](https://justlend.gitbook.io/untitled/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://justlend.gitbook.io/untitled/developers/page-3/smart-contract-api.md).

# Smart Contract API

## Smart Contract Address

<table><thead><tr><th width="162.60507757404795">Name</th><th>Contract Address</th></tr></thead><tbody><tr><td>Unitroller</td><td>TGjYzgCyPobsNS9n6WcbdLVR9dH7mWqFx7</td></tr><tr><td>jTRX</td><td>TE2RzoSV3wFK99w6J9UnnZ4vLfXYoxvRwP</td></tr><tr><td>jUSDD</td><td>TX7kybeP6UwTBRHLNPYmswFESHfyjm9bAS</td></tr><tr><td>jUSDT</td><td>TXJgMdjVX5dKiQaUi9QobwNxtSQaFqccvd</td></tr><tr><td>jUSDJ</td><td>TL5x9MtSnDy537FXKx53yAaHRRNdg9TkkA</td></tr><tr><td>jSUNOLD</td><td>TGBr8uh9jBVHJhhkwSJvQN2ZAKzVkxDmno</td></tr><tr><td>jSUN</td><td>TPXDpkg9e3eZzxqxAUyke9S4z4pGJBJw9e</td></tr><tr><td>jWIN</td><td>TRg6MnpsFXc82ymUPgf5qbj59ibxiEDWvv</td></tr><tr><td>jBTC</td><td>TLeEu311Cbw63BcmMHDgDLu7fnk9fqGcqT</td></tr><tr><td>jETH</td><td>TR7BUFRQeq1w5jAZf1FKx85SHuX6PfMqsV</td></tr><tr><td>jJST</td><td>TWQhCXaWz4eHK4Kd1ErSDHjMFPoPc9czts</td></tr><tr><td>jWBTT</td><td>TUY54PVeH6WCcYCd6ZXXoBDsHytN9V5PXt</td></tr><tr><td>jTUSD</td><td>TSXv71Fy5XdL3Rh2QfBoUu3NAaM4sMif8R</td></tr><tr><td>jUSDC</td><td>TNSBA6KvSvMoTqQcEgpVK7VhHT3z7wifxy</td></tr><tr><td>jNFT</td><td>TFpPyDCKvNFgos3g3WVsAqMrdqhB81JXHE</td></tr><tr><td>jBTT</td><td>TUaUHU9Dy8x5yNi1pKnFYqHWojot61Jfto</td></tr></tbody></table>

### Query interface

#### Liquidation Incentive&#x20;

function liquidationIncentiveMantissa() view returns (uint)&#x20;

**Feature description:** By calling the liquidationIncentiveMantissa function of the Unitroller contract, liquidation incentives can be inquired. Liquidators will be given a proportion of the borrower's collateral as an incentive, which is defined as liquidation incentive. This is to encourage liquidators to perform liquidation of underwater accounts.&#x20;

**Parameter description:** N/A&#x20;

Returns：&#x20;

| uint256 | Liquidation incentive. The rate is 1e18. |
| ------- | ---------------------------------------- |

#### getAccountLiquidity function&#x20;

getAccountLiquidity(address account) view returns (uint, uint, uint)&#x20;

**Feature description:** By calling the getAccountLiquidity function of the Unitroller contract, account information can be accessed through an account's address to determine whether the account should be liquidated or not.&#x20;

**Parameter description**:&#x20;

| Parameter | Type    | Description  |
| --------- | ------- | ------------ |
| account   | address | User address |

**Return value:**

| uint256 | error (error code, 0 means success)                                                                                                                     |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uint256 | liquidity                                                                                                                                               |
| uint256 | shortfall (When the value is bigger than 0, the current account does not meet the market requirement for collateralization and needs to be liquidated.) |

{% hint style="info" %}
Note: There should be at most one non-zero value between liquidity and shortfall.
{% endhint %}

### Modification Interface

#### Liquidate Borrow（jTrc20）

function liquidateBorrow(address borrower, uint repayAmount, address jTokenCollateral) returns (uint)&#x20;

**Feature description:** By calling liquidateBorrow function of the corresponding jTrc20 contract (e.g. jUSDT), accounts whose liquidity does not meet the market requirement for collateralization will be liquidated by other users to restore the account liquidity to a normal level (i.e. higher than the market requirement for collateralization). In the event of liquidation, liquidators may repay part or 50% of the loan for the borrower. Liquidators will be given a proportion of the borrower's collateral as an incentive.

**Parameter description:**

| Parameter        | Type    | Description                                                                               |
| ---------------- | ------- | ----------------------------------------------------------------------------------------- |
| borrower         | address | Address of a liquidated account                                                           |
| repayAmount      | uint256 | Amount of token to be repaid in the event of liquidation (measured in the borrowed asset) |
| jTokenCollateral | address | Address of the jTOKEN contract to set aside the collateralized asset of a borrower        |

**Returns:**

| uint256 | 0 means success.Other value returned represents the corresponding error code |
| ------- | ---------------------------------------------------------------------------- |

#### Liquidate Borrow（jTRX）

function liquidateBorrow(address borrower, address jTokenCollateral) payable

**Function description:** By calling the liquidateBorrow function of the jTRX contract, accounts whose liquidity does not meet the market requirement for collateralization will be liquidated by other users to restore the account liquidity to a normal level (i.e., higher than the market requirement for collateralization). In the event of liquidation, liquidators may repay part or 50% of the loan for the borrower. Liquidators will be given a proportion of the borrower's collateral as an incentive.

**Parameter description:**

| Parameter        | Type    | Description                                                                      |
| ---------------- | ------- | -------------------------------------------------------------------------------- |
| borrower         | address | Address of a liquidated account                                                  |
| msg.value        | uint256 | Amount of TRX to be repaid in the event of liquidation (measured in SUN)         |
| jTokenCollateral | address | Address of the jTRX contract to set aside the collateralized asset of a borrower |

**Returns:**

No return. If any error occurs, the transaction will be reverted.

### Appendix

#### jToken Decimals

All jTokens on JustLend have 8 decimal places.

#### jToken Balance Query

We suggest you use Tronweb to query jToken balance. For example, you can follow the steps below to query jUSDT balance:

```javascript
//Example 1
async function triggercontract(){
  let instance =
awaittronWeb.contract().at('TXJgMdjVX5dKiQaUi9QobwNxtSQaFqccvd');
  let res = await instance.balanceOf().call();
  console.log(res);
}

triggercontract();

//Example 2
async function triggercontract(){
  let instance =
awaittronWeb.contract().at('TXJgMdjVX5dKiQaUi9QobwNxtSQaFqccvd');
  let res = await instance["balanceOf"]().call();
  console.log(res);
}

triggercontract();
```
