2021-02-08 17:20:48 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
|
|
|
import { DSMath } from "../../common/math.sol";
|
|
|
|
import { Basic } from "../../common/basic.sol";
|
2021-03-16 16:25:39 +00:00
|
|
|
import { ComptrollerInterface, CompoundMappingInterface } from "./interface.sol";
|
2021-02-08 17:20:48 +00:00
|
|
|
|
|
|
|
abstract contract Helpers is DSMath, Basic {
|
|
|
|
/**
|
|
|
|
* @dev Compound Comptroller
|
|
|
|
*/
|
|
|
|
ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
|
|
|
|
|
2021-03-16 16:25:39 +00:00
|
|
|
/**
|
|
|
|
* @dev Compound Mapping
|
|
|
|
*/
|
2021-03-27 16:58:28 +00:00
|
|
|
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xA8F9D4aA7319C54C04404765117ddBf9448E2082);
|
2021-03-16 16:25:39 +00:00
|
|
|
|
2021-02-08 17:20:48 +00:00
|
|
|
/**
|
|
|
|
* @dev enter compound market
|
|
|
|
*/
|
|
|
|
function enterMarket(address cToken) internal {
|
|
|
|
address[] memory markets = troller.getAssetsIn(address(this));
|
|
|
|
bool isEntered = false;
|
|
|
|
for (uint i = 0; i < markets.length; i++) {
|
|
|
|
if (markets[i] == cToken) {
|
|
|
|
isEntered = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isEntered) {
|
|
|
|
address[] memory toEnter = new address[](1);
|
|
|
|
toEnter[0] = cToken;
|
|
|
|
troller.enterMarkets(toEnter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|