Skip to content

Commit

Permalink
fixes for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
enkogu committed Jul 17, 2018
1 parent 32f2736 commit 0478ccf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 45 deletions.
2 changes: 1 addition & 1 deletion contracts/moneyflow/ether/WeiExpense.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract WeiExpense is IWeiReceiver, IDestination, Ownable {
owner.transfer(address(this).balance);
}

function flushTo(address _to) external onlyOwner {
function flushTo(address _to) public onlyOwner {
emit WeiExpense_Flush(_to, address(this).balance);
_to.transfer(address(this).balance);
}
Expand Down
64 changes: 26 additions & 38 deletions contracts/moneyflow/ether/WeiFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,11 @@ contract WeiFund is IWeiReceiver, IDestination, Ownable {//
momentCreated = now;
}

function getTotalFundNeededAmount()external view returns(uint){
function getTotalFundNeededAmount()public view returns(uint){
return neededWei;
}

function _getTotalWeiNeeded(uint _inputWei)internal view returns(uint){
uint need;
if(_getDebtMultiplier()*neededWei > totalWeiReceived){
need = _getDebtMultiplier()*neededWei - totalWeiReceived;
}else{
need = 0;
}

if(need<=_inputWei){
return need;
}else{
return _inputWei;
}
}

function getDebtMultiplier()external view returns(uint){
return _getDebtMultiplier();
}

function _getDebtMultiplier()internal view returns(uint){

function getDebtMultiplier()public view returns(uint){
if((isPeriodic)&&(!isAccumulateDebt)&&( (now - momentReceived) / (periodHours * 3600 * 1000) >=1)){
return (balanceOnMomentReceived/neededWei) + 1;
} else if((isPeriodic)&&(isAccumulateDebt)){
Expand All @@ -76,51 +56,59 @@ contract WeiFund is IWeiReceiver, IDestination, Ownable {//

// -------------- IWeiReceiver

function processFunds(uint _currentFlow) external payable{
function processFunds(uint _currentFlow) public payable{
// emit consoleUint('_getDebtMultiplier', _getDebtMultiplier());
require(_isNeedsMoney());
require(isNeedsMoney());

require(totalWeiReceived+msg.value<=_getDebtMultiplier()*neededWei); // protect from extra money
require(totalWeiReceived+msg.value<=getDebtMultiplier()*neededWei); // protect from extra money
// require(msg.value==_currentFlow);
totalWeiReceived += msg.value;
if(_getTotalWeiNeeded(msg.value)==0){
if(getTotalWeiNeeded(msg.value)==0){
momentReceived = now;
balanceOnMomentReceived = totalWeiReceived;
}
}

function getTotalWeiNeeded(uint _inputWei)external view returns(uint){
return _getTotalWeiNeeded(_inputWei);
function getTotalWeiNeeded(uint _inputWei)public view returns(uint){
uint need;
if(getDebtMultiplier()*neededWei > totalWeiReceived){
need = getDebtMultiplier()*neededWei - totalWeiReceived;
}else{
need = 0;
}

if(need<=_inputWei){
return need;
}else{
return _inputWei;
}
}

function getMinWeiNeeded()external view returns(uint){
function getMinWeiNeeded()public view returns(uint){
return 0;
}

function getPercentsMul100() view external returns(uint){
function getPercentsMul100() view public returns(uint){
return 0;
}

function isNeedsMoney()external view returns(bool){
return _isNeedsMoney();
}
function _isNeedsMoney()internal view returns(bool){
return _getDebtMultiplier()*neededWei > totalWeiReceived;
function isNeedsMoney()public view returns(bool){
return getDebtMultiplier()*neededWei > totalWeiReceived;
}

// -------------- IDestination

function flushTo(address _to) external onlyOwner {
function flushTo(address _to) public onlyOwner {
emit WeiFund_FlushTo(_to, this.balance);
_to.transfer(this.balance);
}

function flush() external onlyOwner {
function flush() public onlyOwner {
emit WeiFund_FlushTo(owner, this.balance);
owner.transfer(this.balance);
}

function() external{
function() public{

}
}
8 changes: 2 additions & 6 deletions contracts/moneyflow/ether/WeiSplitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ contract WeiTopDownSplitter is SplitterBase, IWeiReceiver {
// IWeiReceiver:
// calculate only absolute outputs, but do not take into account the Percents

function getMinWeiNeeded()external view returns(uint){
return _getMinWeiNeeded();
}

function _getMinWeiNeeded()internal view returns(uint){
if(!_isOpen()){
function getMinWeiNeeded()public view returns(uint){
if(!isOpen()){
return 0;
}
uint out = 0;
Expand Down

0 comments on commit 0478ccf

Please sign in to comment.