Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Update co2ken.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
0xEther authored Mar 12, 2020
1 parent 753e2dc commit eccee56
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Contracts/co2ken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ contract CO2ken is Ownable {
event CarbonOffsetted(address indexed from, uint256 value);
event Minted(string ipfsHash, uint256 dollarValue, uint256 tokensMinted);
event Withdrawal(uint256 value);

// --- Math ---
function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = mul(x, y) / ONE;
}

constructor(address storageTarget, address daiTarget, string memory name, string memory symbol, uint8 decimals) public {
// set our token detail
Expand Down Expand Up @@ -69,6 +74,16 @@ contract CO2ken is Ownable {
emit CarbonOffsetted(_msgSender(), tokensToBurn);
}

// tons [27 precision]
function offsetCarbonTons(uint256 tons) public {
// calculate burn amount using current token price
uint256 payment = rmul(tons, storageData.co2kenPrice()); // [wad]
daiToken.transferFrom(_msgSender(), address(this), payment);
// burn CO2
balance = balance.sub(tons);
emit CarbonOffsetted(_msgSender(), tons);
}

function transferOwnership(address newOwner) public virtual override onlyOwner {
_transferOwnership(newOwner);
}
Expand Down

0 comments on commit eccee56

Please sign in to comment.