-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,164 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20AbsoluteExpense is ERC20Expense { | ||
constructor(address _tokenAddress, uint _minERC20Amount, uint _totalERC20Need) public | ||
ERC20Expense(_tokenAddress, _minERC20Amount, _totalERC20Need, 0, 0, false, false) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20AbsoluteExpenseWithPeriod is ERC20Expense { | ||
constructor(address _tokenAddress, uint _minERC20Amount, uint _totalERC20Need, uint _periodHours) public | ||
ERC20Expense(_tokenAddress, _minERC20Amount, _totalERC20Need, 0, _periodHours, false, true) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20AbsoluteExpenseWithPeriodSliding is ERC20Expense { | ||
constructor(address _tokenAddress, uint _minERC20Amount, uint _totalERC20Need, uint _periodHours) public | ||
ERC20Expense(_tokenAddress, _minERC20Amount, _totalERC20Need, 0, _periodHours, true, true) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20RelativeExpense is ERC20Expense { | ||
constructor(address _tokenAddress, uint _partsPerMillion) public | ||
ERC20Expense(_tokenAddress, 0, 0, _partsPerMillion, 0, false, false) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20RelativeExpenseWithPeriod is ERC20Expense { | ||
constructor(address _tokenAddress, uint _partsPerMillion, uint _periodHours) public | ||
ERC20Expense(_tokenAddress, 0, 0, _partsPerMillion, _periodHours, false, true) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./ERC20Expense.sol"; | ||
|
||
|
||
contract ERC20RelativeExpenseWithPeriodSliding is ERC20Expense { | ||
constructor(address _tokenAddress, uint _partsPerMillion, uint _periodHours) public | ||
ERC20Expense(_tokenAddress, 0, 0, _partsPerMillion, _periodHours, true, true) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol"; | ||
|
||
contract ERC20Token is MintableToken { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,52 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../bases/ExpenseBase.sol"; | ||
|
||
import "../interfaces/IDestination.sol"; | ||
import "../interfaces/IReceiver.sol"; | ||
import "../interfaces/ITokenReceiver.sol"; | ||
|
||
import "zeppelin-solidity/contracts/math/SafeMath.sol"; | ||
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
|
||
/** | ||
* @title ERC20Expense | ||
* @dev Something that needs money (task, salary, bonus, etc) | ||
* Should be used in the Moneyflow so will automatically receive ERC20. | ||
*/ | ||
contract ERC20Expense is ITokenReceiver, IDestination, ExpenseBase { | ||
ERC20 public token; | ||
|
||
constructor( | ||
address _tokenAddress, | ||
uint _totalNeeded, | ||
uint _minAmount, | ||
uint _partsPerMillion, | ||
uint _periodHours, | ||
bool _isSlidingAmount, | ||
bool _isPeriodic) public | ||
{ | ||
token = ERC20(_tokenAddress); | ||
expense = _constructExpense(uint128(_totalNeeded), uint128(_minAmount), uint32(_partsPerMillion), uint32(_periodHours), _isSlidingAmount, _isPeriodic); | ||
} | ||
|
||
event ProcessTokensExpense(address sender, address target, uint _value); | ||
function processTokens(uint _currentFlow, uint _value) public { | ||
require(_value <= token.allowance(msg.sender, address(this))); | ||
token.transferFrom(msg.sender, address(this), _value); | ||
emit ProcessTokensExpense(msg.sender, address(this), _value); | ||
expense = _processAmount(expense, _currentFlow, _value); | ||
} | ||
|
||
contract Erc20Expense { | ||
function flush() public onlyOwner { | ||
token.transfer(owner, expense.balance); | ||
expense = _processFlushTo(expense, owner); | ||
} | ||
|
||
} | ||
function flushTo(address _to) public onlyOwner { | ||
token.transfer(_to, expense.balance); | ||
expense = _processFlushTo(expense, _to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "zeppelin-solidity/contracts/math/SafeMath.sol"; | ||
import "../bases/SplitterBase.sol"; | ||
|
||
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
import "../interfaces/ISplitter.sol"; | ||
import "../interfaces/ITokenReceiver.sol"; | ||
import "../interfaces/IReceiver.sol"; | ||
|
||
|
||
/** | ||
* @title Splitter | ||
* @dev Will split money from top to down (order matters!). It is possible for some children to not receive money | ||
* if they have ended. | ||
*/ | ||
contract ERC20Splitter is ITokenReceiver, SplitterBase { | ||
ERC20 public token; | ||
|
||
constructor(address _tokenAddress) public { | ||
token = ERC20(_tokenAddress); | ||
splitter = _constructSplitter(false); | ||
} | ||
|
||
contract Erc20Splitter { | ||
function _elementProcessing(address _target, uint _currentFlow, uint _value) internal { | ||
token.approve(_target, _value); | ||
ITokenReceiver(_target).processTokens(_currentFlow, _value); | ||
} | ||
|
||
function processTokens(uint _currentFlow, uint _value) public { | ||
require(_value <= token.allowance(msg.sender, address(this))); | ||
token.transferFrom(msg.sender, address(this), _value); | ||
_processAmount(splitter, _currentFlow, _value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "zeppelin-solidity/contracts/math/SafeMath.sol"; | ||
import "../bases/TableBase.sol"; | ||
import "../bases/ExpenseBase.sol"; | ||
import "../bases/SplitterBase.sol"; | ||
|
||
import "../interfaces/IReceiver.sol"; | ||
import "../interfaces/ITokenReceiver.sol"; | ||
|
||
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
|
||
contract ERC20Table is ITable, IReceiver, ITokenReceiver, TableBase { | ||
ERC20 public token; | ||
|
||
constructor(address _tokenAddress) public { | ||
token = ERC20(_tokenAddress); | ||
} | ||
|
||
function processTokens(uint _currentFlow, uint _value) public { | ||
require(_value <= token.allowance(msg.sender, address(this))); | ||
_processAmountAt(0, _currentFlow, _value); | ||
token.transferFrom(msg.sender, address(this), _value); | ||
} | ||
|
||
contract Erc20Table { | ||
function flushAt(uint _eId) public onlyOwner isCorrectId(_eId) { | ||
token.transfer(owner, expenses[_eId].balance); | ||
_processFlushToAt(_eId, owner); | ||
} | ||
|
||
function flushToAt(uint _eId, address _to) public onlyOwner isCorrectId(_eId) { | ||
token.transfer(_to, expenses[_eId].balance); | ||
_processFlushToAt(_eId, _to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pragma solidity ^0.4.23; | ||
pragma solidity ^0.4.24; | ||
|
||
import "./WeiExpense.sol"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pragma solidity ^0.4.23; | ||
pragma solidity ^0.4.24; | ||
|
||
import "./WeiExpense.sol"; | ||
|
||
|
Oops, something went wrong.