# APIs

### Blockchain

HECO

### Contract Address

comptroller: 0xeA5D4714d2a30E23c678177c3C2Bdabddf47f4f1

dmUSDT: 0x8d8fD8139CEaf0034A021E6eb039bB6f70C83d9c

dmHUSD: 0xe2CE3BDe9f94C41E839287af95feE7c07807Cf71

dmHBTC: 0x62Ac818EcaF5A351d48CB7f95A07E2dA7E97ABca

dmETH: 0x59a626a783A9C071fDcEFC95B3664a34d0592e24

dmWHT: 0xDA77B5663a0baFa56080Ae5D0a1F462848465b14

dmHDOT: 0x63fB23F78923320DE2816562401a2658321fFB11

dmHFIL: 0xe867f648957Fa769E43E30b99Faa008C1A39808f

dmHBCH: 0x31f7C57AA9ecC0Da99105F2d7ad2c30c9DF1c1Dc

dmLINK: 0xF677108CB45e702DF16B42F7B37a1305239FC75A

dmUNI: 0x103fC41D79C4AdA572B158b39De4d5b30d45ddf6

dmMDX: 0xc790FF20B8479e1FEdF73f78dC07C40DB79D8474

dusdUnitroller: 0x6113fdB9177dfEFb7A09c47f06FDb59b63B9143A

### APIs

```
pragma solidity ^0.5.16;

contract IComptroller {
    /**
     * @notice Calculate the remaining available credit limit for the specified user. At most one of the remaining credit limit and the owed credit limit is greater than 0. When the owed credit limit is greater than 0, the user can be liquidated.
     * @return error，0= success,
                Remaining credit limit
     *          Overflow credit limit
     */
    function getAccountLiquidity(address account) public view returns (uint, uint, uint);
    
    
    /**
     * @notice Obtain user collateral funds pool
     * @param account
     * @param index
     * @return Fund pool address
     */
    function accountAssets(adress account, uint index) public vew returns(address);
}
```

```
pragma solidity ^0.5.16;

contract IDmToken {
    /**
     * @notice Liquidation of debts of current assets
     * @param borrower
     * @param repayAmount
     * @param dmTokenCollateral
     * @return 0 = success
     */
    function liquidateBorrow(address borrower, uint repayAmount, address dmTokenCollateral) external returns (uint);
    
    /**
     * @notice Get the deposit of the specified user in the current fund pool
     * @param owner
     * @return Deposit amount
     */
    function balanceOfUnderlying(address owner) external returns (uint);
}
```

```
pragma solidity ^0.5.16;

contract IDUSDUnitroller {
    /**
     * @notice Liquidation of stable currency debt
     * @param borrower
     * @param repayAmount
     * @param dmTokenCollateral
     * @return 0 = success, The liquidator actually repays the amount of stablecoins
     */
    function liquidateDUSD(address borrower, uint repayAmount, address dmTokenCollateral) external returns (uint, uint);
}
```

### Notes

1. Scan the chain, collect the user list
2. IComptroller.getAccountLiquidity: Check whether the specified user can be liquidated
3. IComptroller.accountAssets: Get user pledged asset pool
4. IDmToken.balanceOfUnderlying: Get the user's deposit in the designated fund pool
5. IDmToken.liquidateBorrow: Liquidation (repayment of borrowings)
6. IDUSDUnitroller.liquidateDUSD: Liquidation (repayment of stablecoins)
