dsa-connectors/contracts/avalanche/connectors/benqi/v2/helpers.sol

37 lines
1.1 KiB
Solidity
Raw Normal View History

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;
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
*/
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);
}
}
}