mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
31 lines
924 B
Solidity
31 lines
924 B
Solidity
![]() |
pragma solidity ^0.7.0;
|
||
|
|
||
|
import { DSMath } from "../../common/math.sol";
|
||
|
import { Basic } from "../../common/basic.sol";
|
||
|
import { ComptrollerInterface } from "./interface.sol";
|
||
|
|
||
|
abstract contract Helpers is DSMath, Basic {
|
||
|
/**
|
||
|
* @dev Compound Comptroller
|
||
|
*/
|
||
|
ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
|
||
|
|
||
|
/**
|
||
|
* @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);
|
||
|
}
|
||
|
}
|
||
|
}
|