Skip to main content
Fix missing definition.
Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

I'd do something like this. I don't think there's "a correct way" to achieve this.

function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
    uint256 rate;
    if (weiAmount <= 13*10**18) { 
        rate = 66666;  
    } else if(weiAmount > 13*10**18 && weiAmount <= 25*10**18) {
        rate = 100000; 
    } else {
        rate = 400000;
    }
 
    return weiAmount.mul(rate);
}

I'd do something like this. I don't think there's "a correct way" to achieve this.

function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
    if (weiAmount <= 13*10**18) { 
        rate = 66666;  
    } else if(weiAmount > 13*10**18 && weiAmount <= 25*10**18) {
        rate = 100000; 
    } else {
        rate = 400000;
    }
 
    return weiAmount.mul(rate);
}

I'd do something like this. I don't think there's "a correct way" to achieve this.

function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
    uint256 rate;
    if (weiAmount <= 13*10**18) { 
        rate = 66666;  
    } else if(weiAmount > 13*10**18 && weiAmount <= 25*10**18) {
        rate = 100000; 
    } else {
        rate = 400000;
    }
 
    return weiAmount.mul(rate);
}
Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

I'd do something like this. I don't think there's "a correct way" to achieve this.

function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
    if (weiAmount <= 13*10**18) { 
        rate = 66666;  
    } else if(weiAmount > 13*10**18 && weiAmount <= 25*10**18) {
        rate = 100000; 
    } else {
        rate = 400000;
    }
 
    return weiAmount.mul(rate);
}