Darwin-Coin / darwin-token-contracts

Darwin Protocol Smart Contracts
https://darwinprotocol.io
0 stars 0 forks source link

DarwinPresale: calculateDarwinAmount seems off #42

Closed kingofclubstroyDev closed 1 year ago

kingofclubstroyDev commented 1 year ago
      ~line 332:

      uint256 stage = _getCurrentStage();
      uint256 darwinAmount;
      uint256 rate;
      uint256 stageAmount;
      uint256 stageCap;
      while (bnbAmount > 0) {
          (rate, stageAmount, stageCap) = _getStageDetails(stage);
          if (bnbAmount <= stageAmount) {
              darwinAmount += (bnbAmount * rate);
              bnbAmount = 0;
              break;
          } else {
              darwinAmount += (stageAmount * rate);
              bnbAmount -= stageAmount;
          }
          ++stage;
      }
      return darwinAmount;
  }

It seems like the stage amount is being compared with the deposited bnb amount, but i think it could be the stageCap - amountRaised, or something along those lines, as i think this doesn't include intermediate deposits within the stage

kingofclubstroyDev commented 1 year ago

resolved in pull request