Rename Compound -> Cream and change addresses

This commit is contained in:
0xyolo 2021-04-12 11:35:41 +08:00
parent ab66ac7403
commit 8708dce8f0
4 changed files with 37 additions and 36 deletions

View File

@ -2,21 +2,22 @@ pragma solidity ^0.7.0;
import { DSMath } from "../../common/math.sol";
import { Basic } from "../../common/basic.sol";
import { ComptrollerInterface, CompoundMappingInterface } from "./interface.sol";
import { ComptrollerInterface, CreamMappingInterface } from "./interface.sol";
abstract contract Helpers is DSMath, Basic {
/**
* @dev Compound Comptroller
* @dev Cream Comptroller
*/
ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d5BC3c8d13dcB8bF317092d84783c2697AE9258);
/**
* @dev Compound Mapping
* @dev Cream Mapping
*/
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xA8F9D4aA7319C54C04404765117ddBf9448E2082);
// TODO: wait for the cream mapping contract address
CreamMappingInterface internal constant creamMapping = CreamMappingInterface();
/**
* @dev enter compound market
* @dev enter cream market
*/
function enterMarket(address cToken) internal {
address[] memory markets = troller.getAssetsIn(address(this));

View File

@ -30,7 +30,7 @@ interface ComptrollerInterface {
function claimComp(address) external;
}
interface CompoundMappingInterface {
interface CreamMappingInterface {
function cTokenMapping(string calldata tokenId) external view returns (address);
function getMapping(string calldata tokenId) external view returns (address, address);
}

View File

@ -7,10 +7,10 @@ import { Helpers } from "./helpers.sol";
import { Events } from "./events.sol";
import { CETHInterface, CTokenInterface } from "./interface.sol";
abstract contract CompoundResolver is Events, Helpers {
abstract contract CreamResolver is Events, Helpers {
/**
* @dev Deposit ETH/ERC20_Token.
* @notice Deposit a token to Compound for lending / collaterization.
* @notice Deposit a token to Cream for lending / collaterization.
* @param token The address of the token to deposit. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param cToken The address of the corresponding cToken.
* @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
@ -46,7 +46,7 @@ abstract contract CompoundResolver is Events, Helpers {
/**
* @dev Deposit ETH/ERC20_Token using the Mapping.
* @notice Deposit a token to Compound for lending / collaterization.
* @notice Deposit a token to Cream for lending / collaterization.
* @param tokenId The token id of the token to deposit.(For eg: ETH-A)
* @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
* @param getId ID to retrieve amt.
@ -58,13 +58,13 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = depositRaw(token, cToken, amt, getId, setId);
}
/**
* @dev Withdraw ETH/ERC20_Token.
* @notice Withdraw deposited token from Compound
* @notice Withdraw deposited token from Cream
* @param token The address of the token to withdraw. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param cToken The address of the corresponding cToken.
* @param amt The amount of the token to withdraw. (For max: `uint256(-1)`)
@ -100,7 +100,7 @@ abstract contract CompoundResolver is Events, Helpers {
/**
* @dev Withdraw ETH/ERC20_Token using the Mapping.
* @notice Withdraw deposited token from Compound
* @notice Withdraw deposited token from Cream
* @param tokenId The token id of the token to withdraw.(For eg: ETH-A)
* @param amt The amount of the token to withdraw. (For max: `uint256(-1)`)
* @param getId ID to retrieve amt.
@ -112,13 +112,13 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = withdrawRaw(token, cToken, amt, getId, setId);
}
/**
* @dev Borrow ETH/ERC20_Token.
* @notice Borrow a token using Compound
* @notice Borrow a token using Cream
* @param token The address of the token to borrow. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param cToken The address of the corresponding cToken.
* @param amt The amount of the token to borrow.
@ -146,7 +146,7 @@ abstract contract CompoundResolver is Events, Helpers {
/**
* @dev Borrow ETH/ERC20_Token using the Mapping.
* @notice Borrow a token using Compound
* @notice Borrow a token using Cream
* @param tokenId The token id of the token to borrow.(For eg: DAI-A)
* @param amt The amount of the token to borrow.
* @param getId ID to retrieve amt.
@ -158,7 +158,7 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = borrowRaw(token, cToken, amt, getId, setId);
}
@ -214,7 +214,7 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = paybackRaw(token, cToken, amt, getId, setId);
}
@ -279,7 +279,7 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = depositCTokenRaw(token, cToken, amt, getId, setId);
}
@ -335,7 +335,7 @@ abstract contract CompoundResolver is Events, Helpers {
uint getId,
uint setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address token, address cToken) = compMapping.getMapping(tokenId);
(address token, address cToken) = creamMapping.getMapping(tokenId);
(_eventName, _eventParam) = withdrawCTokenRaw(token, cToken, cTokenAmt, getId, setId);
}
@ -368,13 +368,13 @@ abstract contract CompoundResolver is Events, Helpers {
CTokenInterface cTokenContract = CTokenInterface(cTokenPay);
{
(,, uint shortfal) = troller.getAccountLiquidity(borrower);
require(shortfal != 0, "account-cannot-be-liquidated");
(,, uint shortfall) = troller.getAccountLiquidity(borrower);
require(shortfall != 0, "account-cannot-be-liquidated");
_amt = _amt == uint(-1) ? cTokenContract.borrowBalanceCurrent(borrower) : _amt;
}
if (tokenToPay == ethAddr) {
require(address(this).balance >= _amt, "not-enought-eth");
require(address(this).balance >= _amt, "not-enough-eth");
CETHInterface(cTokenPay).liquidateBorrow{value: _amt}(borrower, cTokenColl);
} else {
TokenInterface tokenContract = TokenInterface(tokenToPay);
@ -414,8 +414,8 @@ abstract contract CompoundResolver is Events, Helpers {
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
(address tokenToPay, address cTokenToPay) = compMapping.getMapping(tokenIdToPay);
(address tokenInReturn, address cTokenColl) = compMapping.getMapping(tokenIdInReturn);
(address tokenToPay, address cTokenToPay) = creamMapping.getMapping(tokenIdToPay);
(address tokenInReturn, address cTokenColl) = creamMapping.getMapping(tokenIdInReturn);
(_eventName, _eventParam) = liquidateRaw(
borrower,
@ -430,6 +430,6 @@ abstract contract CompoundResolver is Events, Helpers {
}
}
contract ConnectV2Compound is CompoundResolver {
string public name = "Compound-v1";
contract ConnectV2Cream is CreamResolver {
string public name = "Cream-v1";
}

View File

@ -123,8 +123,8 @@ abstract contract Helpers {
}
contract InstaCompoundMapping is Helpers {
string constant public name = "Compound-Mapping-v1.1";
contract InstaCreamMapping is Helpers {
string constant public name = "Cream-Mapping-v1.1";
constructor(
address _connectors,