Slither and solium together

This commit is contained in:
Andy Tudhope 2019-04-10 02:26:00 +02:00
parent 2347702e45
commit b3a6ad9155
No known key found for this signature in database
GPG Key ID: 02A3DFA93BF26AD2
1 changed files with 42 additions and 42 deletions

View File

@ -9,7 +9,7 @@ import "./utils/BancorFormula.sol";
contract DAppStore is ApproveAndCallFallBack, BancorFormula {
using SafeMath for uint;
// Could be any EIP20/MiniMe token
// Could be any MiniMe token
MiniMeTokenInterface SNT;
// Total SNT in circulation
@ -70,47 +70,6 @@ contract DAppStore is ApproveAndCallFallBack, BancorFormula {
_createDApp(msg.sender, _id, _amount);
}
/**
* @dev Used in UI to display effect on ranking of user's donation
* @param _id bytes32 unique identifier.
* @param _amount of tokens to stake/"donate" to this DApp's ranking.
* @return effect of donation on DApp's effectiveBalance
*/
function upvoteEffect(bytes32 _id, uint _amount) external view returns(uint effect) {
uint dappIdx = id2index[_id];
Data memory d = dapps[dappIdx];
require(d.id == _id, "Error fetching correct data");
require(d.balance + _amount < safeMax, "You cannot upvote by this much, try with a lower amount");
// Special case - no downvotes yet cast
if (d.votesCast == 0) {
return _amount;
}
uint precision;
uint result;
uint mBalance = d.balance + _amount;
uint mRate = decimals - (mBalance * decimals/max);
uint mAvailable = mBalance * mRate;
(result, precision) = BancorFormula.power(
mAvailable,
decimals,
uint32(decimals),
uint32(mRate));
uint mVMinted = result >> precision;
uint temp1 = d.votesCast * mRate * mAvailable;
uint temp2 = mVMinted * decimals * decimals;
uint mEffect = temp1 / temp2;
uint mEBalance = mBalance - mEffect;
return (mEBalance - d.effectiveBalance);
}
/**
* @dev Sends SNT directly to the contract, not the developer. This gets added to the DApp's balance, no curve required.
* @param _id bytes32 unique identifier.
@ -212,6 +171,47 @@ contract DAppStore is ApproveAndCallFallBack, BancorFormula {
}
}
/**
* @dev Used in UI to display effect on ranking of user's donation
* @param _id bytes32 unique identifier.
* @param _amount of tokens to stake/"donate" to this DApp's ranking.
* @return effect of donation on DApp's effectiveBalance
*/
function upvoteEffect(bytes32 _id, uint _amount) external view returns(uint effect) {
uint dappIdx = id2index[_id];
Data memory d = dapps[dappIdx];
require(d.id == _id, "Error fetching correct data");
require(d.balance + _amount < safeMax, "You cannot upvote by this much, try with a lower amount");
// Special case - no downvotes yet cast
if (d.votesCast == 0) {
return _amount;
}
uint precision;
uint result;
uint mBalance = d.balance + _amount;
uint mRate = decimals - (mBalance * decimals/max);
uint mAvailable = mBalance * mRate;
(result, precision) = BancorFormula.power(
mAvailable,
decimals,
uint32(decimals),
uint32(mRate));
uint mVMinted = result >> precision;
uint temp1 = d.votesCast * mRate * mAvailable;
uint temp2 = mVMinted * decimals * decimals;
uint mEffect = temp1 / temp2;
uint mEBalance = mBalance - mEffect;
return (mEBalance - d.effectiveBalance);
}
/**
* @dev Downvotes always remove 1% of the current ranking.
* @param _id bytes32 unique identifier.