-
Notifications
You must be signed in to change notification settings - Fork 3
Develop #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #5
Changes from all commits
736fbc1
8aa6193
9156100
68635e3
cf3a6e4
07ad532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| node_modules | ||
|
|
||
| .idea/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import './DebtToken.sol'; | ||
| pragma solidity ^0.4.15; | ||
| contract DeployDebtToken is Ownable{ | ||
|
|
||
| address public owner; | ||
| address public dayTokenAddress; | ||
| uint public dayTokenFees; //DAY tokens to be paid for deploying custom DAY contract | ||
| ERC20 dayToken; | ||
|
|
||
| event FeeUpdated(uint _fee, uint _time); | ||
| event DebtTokenCreated(address _creator, address _debtTokenAddress, uint256 _time); | ||
|
|
||
| function DeployDebtToken(address _dayTokenAddress, uint _dayTokenFees){ | ||
| dayTokenAddress = _dayTokenAddress; | ||
| dayTokenFees = _dayTokenFees; | ||
| owner = msg.sender; | ||
| dayToken = ERC20(dayTokenAddress); | ||
| } | ||
|
|
||
| function updateDayTokenFees(uint _dayTokenFees) onlyOwner public { | ||
| dayTokenFees = _dayTokenFees; | ||
| FeeUpdated(dayTokenFees, now); | ||
| } | ||
|
|
||
| function createDebtToken(string _tokenName, | ||
| string _tokenSymbol, | ||
| uint256 _initialAmount, | ||
| uint256 _exchangeRate, | ||
| uint256 _decimalUnits, | ||
| uint256 _dayLength, | ||
| uint256 _loanTerm, | ||
| uint256 _loanCycle, | ||
| uint256 _interestRate, | ||
| address _debtOwner){ | ||
|
|
||
| address user = msg.sender; | ||
|
|
||
| if(dayToken.transferFrom(user, this, dayTokenFees)){ | ||
| DebtToken newDebtToken = new DebtToken(_tokenName, _tokenSymbol, _initialAmount, _exchangeRate, | ||
| _decimalUnits, _dayLength, _loanTerm, _loanCycle, | ||
| _interestRate, _debtOwner); | ||
| DebtTokenCreated(user, address(newDebtToken), now); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // to collect all fees paid till now | ||
| function fetchDayTokens() onlyOwner public { | ||
| dayToken.transfer(owner, dayToken.balanceOf(this)); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add the fallback function, just to ensure that ether are not transferred to the address?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by default fallback is not payable so TX with ETH will be reverted
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add tests for deployment code. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When calling new DebtToken from DeployDebtToken the msg.sender seen by DebtToken will be the address of DeployDebtToken contract.
To fix this we shall modify the contract so it accepts 'borrower' as an input.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Observation, we would create a different
DeployableDebtTokenwith that feature, so we can separate development process of the two.Following the pattern used in the
DayTokenThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the way
DayTokenhas resolved it. In case of debt contract, I think it has too much of overhead. If we "rename" owner to "borrower" there is no need for 3rd party like owner.My proposal is to
borrowerownervariable and semantics and replace withborrower(remove ownable inheritance)