dsa-connectors-old/contracts/connectors/chi.sol

51 lines
1.3 KiB
Solidity
Raw Normal View History

2020-08-03 07:49:23 +00:00
pragma solidity ^0.6.0;
interface CHIInterface {
function mint(uint256 value) external;
function free(uint256 value) external returns (uint256);
function balanceOf(address) external view returns (uint);
2020-08-09 15:27:21 +00:00
function approve(address, uint256) external;
2020-08-03 07:49:23 +00:00
}
2020-08-04 10:10:04 +00:00
contract ChiHelpers {
2020-08-03 07:49:23 +00:00
/**
* @dev CHI token Address
*/
function getCHIAddress() internal pure returns (address) {
return 0x0000000000004946c0e9F43F4Dee607b0eF1fA1c;
}
2020-08-09 15:27:21 +00:00
/**
* @dev Connector Details.
*/
function connectorID() public view returns(uint model, uint id) {
(model, id) = (1, 36);
}
2020-08-03 07:49:23 +00:00
}
contract ChiResolver is ChiHelpers {
/**
* @dev Mint CHI token.
* @param amt token amount to mint.
*/
function mint(uint amt) public payable {
uint _amt = amt == uint(-1) ? 140 : amt;
2020-08-03 07:49:23 +00:00
require(_amt <= 140, "Max minting is 140 chi");
CHIInterface(getCHIAddress()).mint(_amt);
}
/**
* @dev burn CHI token.
* @param amt token amount to burn.
*/
function burn(uint amt) public payable {
2020-08-03 07:49:23 +00:00
CHIInterface chiToken = CHIInterface(getCHIAddress());
uint _amt = amt == uint(-1) ? chiToken.balanceOf(address(this)) : amt;
2020-08-09 15:27:21 +00:00
chiToken.approve(address(chiToken), _amt);
2020-08-03 07:49:23 +00:00
chiToken.free(_amt);
}
}
contract ConnectCHI is ChiResolver {
string public name = "CHI-v1";
}