# Hello Space

By [sharkonaut](https://paragraph.com/@sharkonaut) · 2023-04-17

---

I am testing out the mirror editor.

[https://opensea.io/assets/ethereum/0x439cac149B935AE1D726569800972E1669d17094/9999](https://opensea.io/assets/ethereum/0x439cac149B935AE1D726569800972E1669d17094/9999)

    contract IdolMain is ERC721Enumerable, IERC2981, Ownable, ReentrancyGuard {
      /
      constructor(
        address _mintContractAddress,
        address _stethAddr,
        address _teamWalletAddress
      )
        ERC721("Idol", "IDOL")
      {
        mintContractAddress = _mintContractAddress;
        marketplaceAddress = address(0x0);
        teamWalletAddress = _teamWalletAddress;
        steth = IERC20(_stethAddr);
        stethPrincipalBalance = 0;
        allocatedStethRewards = 0;
        rewardPerGod = 0;
        allowAllContracts = true;
        // set caller reward to 1%
        updateCallerReward = 100;
        teamRewards = 0;
        deployTime = block.timestamp;
      }
      
      function updateRewardPerGod()
          public
          nonReentrant
      {
        uint256 stethBal = steth.balanceOf(address(this));
        // This should only occur if steth has experienced slashing.
        // Reduce stethPrincipalBalance to stethBal minus previously allocated rewards.
        if (stethBal < (stethPrincipalBalance + allocatedStethRewards)) {
          emit RewardPerGodUpdated(rewardPerGod, stethPrincipalBalance + allocatedStethRewards - stethBal, msg.sender);
          stethPrincipalBalance = stethBal - allocatedStethRewards;
          return;
        }
        // Nothing to do if the balances are equal.
        else if (stethBal == (stethPrincipalBalance + allocatedStethRewards)) {
          return;
        }
        // If we have extra stETH, update rewardPerGod, add newRewards to allocatedStethRewards.
        else if (stethBal > (stethPrincipalBalance + allocatedStethRewards)) {
          uint newRewards = stethBal - (stethPrincipalBalance + allocatedStethRewards);
          uint callerReward = newRewards * updateCallerReward / 10000;
          newRewards = newRewards - callerReward;
          rewardPerGod = rewardPerGod + newRewards / totalSupply();
          allocatedStethRewards = allocatedStethRewards + newRewards;
          emit RewardPerGodUpdated(rewardPerGod, 0, msg.sender);
          if(callerReward > 0){
            require(steth.transfer(msg.sender, callerReward));
          }
        }
      }

---

*Originally published on [sharkonaut](https://paragraph.com/@sharkonaut/hello-space)*
