contract ButtSwap {
   mapping(address => uint256) public butts;

   using SafeMath
   for uint;
   uint private totalButts = 3355443199999981;
   uint private availableKrakints = 10000000000000000000000;
   ButtCoin private buttcoin;
   Krakint private krakint;
   address public contractAddress;
   address public owner;
   uint public krkInContract = 1000000000000000000000000; //to be reduced from 
   bool public isLive = true;

   address buttcoinAddress = address(0x5556d6a283fD18d71FD0c8b50D1211C5F842dBBc); //change before deployment
   address krakintAddress = address(0x7C131Ab459b874b82f19cdc1254fB66840D021B6); //change before deployment

   constructor() {
     contractAddress = address(this);
     owner = msg.sender;
     buttcoin = ButtCoin(buttcoinAddress);
     krakint = Krakint(krakintAddress);
   }

   function Step2(uint buttcoinAmount) public virtual returns(string memory message) {
     require(isLive, "Swap contract is stopped");

     require(buttcoin.balanceOf(msg.sender) >= buttcoinAmount, "Not enough allocated buttcoins");
     buttcoin.transferFrom(msg.sender, contractAddress, buttcoinAmount);
     butts[msg.sender] = butts[msg.sender].add(buttcoinAmount);

     uint amt2 = calculateKrakints(buttcoinAmount);
     require(krkInContract >= amt2, "Not enough krakints");

     krakint.transfer(msg.sender, amt2);

     krkInContract = krkInContract.sub(amt2);

     string memory mssg = "Done! Please wait for the Krakin't transfer to complete.";
     return mssg;
   }

   function calculateKrakints(uint buttcoins) private view returns(uint amount) {
     buttcoins = buttcoins.mul(10000000000000); //adds decimals
     uint ret = (buttcoins.mul(totalButts)).div(availableKrakints);
     return ret;
   }

   //we do not count the losses, so it can happen that some accounts will get butted!
   function recoverButtcoins() public virtual returns(bool success) {
     require(!isLive, "Contract must be stopped to get your butts back");
     require(butts[msg.sender] > 0, "You cannot recover zero buttcoins");
     buttcoin.transfer(msg.sender, butts[msg.sender]);
     butts[msg.sender] = 0;
     return true;
   }

   function stopSwap() public virtual {
     require(msg.sender == owner);
     require(isLive);
     isLive = false;
   }

 }
function recoverButtcoins() public virtual returns(bool success) {
  require(!isLive, "Contract must be stopped to get your butts back");
  require(butts[msg.sender] > 0, "You cannot recover zero buttcoins");
  buttcoin.transfer(msg.sender, butts[msg.sender]);
  butts[msg.sender] = 0;
  return true;
}

//we do not count the losses, so it can happen that some accounts will get butted!