2022-03-22 14:55:14 +00:00
|
|
|
//SPDX-License-Identifier: MIT
|
2021-09-29 14:16:30 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
2021-11-14 14:41:05 +00:00
|
|
|
import { DSMath } from "../../../common/math.sol";
|
|
|
|
import { Basic } from "../../../common/basic.sol";
|
2021-09-29 14:16:30 +00:00
|
|
|
import { ComptrollerInterface, BenqiMappingInterface } from "./interface.sol";
|
|
|
|
|
|
|
|
abstract contract Helpers is DSMath, Basic {
|
|
|
|
/**
|
|
|
|
* @dev Benqi Comptroller
|
|
|
|
*/
|
|
|
|
ComptrollerInterface internal constant troller = ComptrollerInterface(0x486Af39519B4Dc9a7fCcd318217352830E8AD9b4);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Benqi Mapping
|
|
|
|
*/
|
2021-10-27 16:50:22 +00:00
|
|
|
BenqiMappingInterface internal constant qiMapping = BenqiMappingInterface(0xe19Fba29ac9BAACc1F584aEcD9C98B4F6fC58ba6);
|
2021-09-29 14:16:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev enter benqi market
|
|
|
|
*/
|
|
|
|
function enterMarket(address qiToken) internal {
|
|
|
|
address[] memory markets = troller.getAssetsIn(address(this));
|
|
|
|
bool isEntered = false;
|
|
|
|
for (uint i = 0; i < markets.length; i++) {
|
|
|
|
if (markets[i] == qiToken) {
|
|
|
|
isEntered = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isEntered) {
|
|
|
|
address[] memory toEnter = new address[](1);
|
|
|
|
toEnter[0] = qiToken;
|
|
|
|
troller.enterMarkets(toEnter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|