Skip to content
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

Introduce crowdfunding MVP #142

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
681c666
feat: introduce basic CrowdfundingContract and CrowdfundingContractRe…
chrismin Jul 10, 2018
ebdf1ac
feat: make createCrowdfundingContract external
chrismin Jul 11, 2018
318f6a6
feat: implement 721 and add basic create and withdrawPayment
chrismin Jul 11, 2018
becad7d
feat: implement basic functionality with for-loops
chrismin Jul 13, 2018
a6c8974
build: add minimetoken
chrismin Jul 16, 2018
44c42df
WIP
chrismin Jul 16, 2018
3435d91
feat: implement CrowdfundingContract
chrismin Jul 16, 2018
ecb4062
feat: introduce Controlled contract
chrismin Jul 16, 2018
061712e
feat: remove TokenController logic from CrowdfundingContract
chrismin Jul 16, 2018
fd36554
feat: update CrowdfundingContractRegistry
chrismin Jul 16, 2018
217435f
fix: fix compiler errors and typos
chrismin Jul 16, 2018
38d3e6d
refactor: rename CrowdfundingContract to CrowdfundingToken
chrismin Jul 16, 2018
674557f
refactor: rename CrowdfundingContractRegistry to CrowdfundingTokenReg…
chrismin Jul 16, 2018
6a18a3e
feat: create CrowdfundingToken on receipt of ERC-721
chrismin Jul 17, 2018
e736da1
wip: tests
chrismin Jul 17, 2018
51dca82
refactor: use ContractRegistry and repaymentTokenIndex with TokenRegi…
chrismin Jul 17, 2018
9809289
refactor: update CrowdfundingTokenRegistry to use new CrowfundingToke…
chrismin Jul 17, 2018
43aa702
refactor: move CrowdfundingTokenRegistry tests to integration folder
chrismin Jul 17, 2018
6f3232a
refactor: move CrowdfundingContractRegistry test into own dir
chrismin Jul 17, 2018
7fc8f65
feat: copy over SimpleInterestTermsContract runners and scenarios
chrismin Jul 17, 2018
d3707d2
refactor: rename to CrowdfundingRunner
chrismin Jul 17, 2018
a270b3b
fix: add TODO in CrowdfundingTokenRegistry
chrismin Jul 17, 2018
b310cdf
feat: introduce CreateCrowdfundingTokenScenario
chrismin Jul 17, 2018
a43fe11
refactor: update CrowdfundingRunner and remove unnecessary scenarios
chrismin Jul 17, 2018
afa5ec1
feat: add method to send DebtToken to CrowdfundingTokenRegistry in tests
chrismin Jul 17, 2018
6354438
feat: introduce unit test for CrowdfundingTokenRegistry
chrismin Jul 17, 2018
1ab4172
fix: clean up Crowdfunding runners
chrismin Jul 17, 2018
b6f82c2
feat: make CrowfundingToken an ERC721Receiver
chrismin Jul 18, 2018
84aa8d0
refactor: remove unnecessary scenarios
chrismin Jul 18, 2018
f7fa9fd
refactor: update sendTransactions test util
chrismin Jul 18, 2018
ed0008f
feat: introduce CreateCrowdfundingToken runner
chrismin Jul 18, 2018
1e01c26
feat: update CrowdfundingTokenRegistry integration test to use runner
chrismin Jul 18, 2018
9cfb993
feat: update CrowdfundingTokenRegistry
chrismin Jul 18, 2018
9934410
feat: make crowdfundingTokens mapping public
chrismin Jul 18, 2018
236b940
feat: introduce CreateCrowdfundingToken runner integration tests
chrismin Jul 18, 2018
c0afc49
fix: reintroduce SimpleInterestTermsContract unit test that was comme…
chrismin Jul 18, 2018
cb073ec
fix: update copy
chrismin Jul 18, 2018
139f7bb
feat: introduce WithdrawOnCrowdfundingToken scenarios
chrismin Jul 18, 2018
4d33601
fix: fix CrowdfundingContractRegistry test filename
chrismin Jul 18, 2018
3dd3e7f
fix: fix bytes to uint conversion
chrismin Jul 19, 2018
b6711b6
fix: handle edge case in CrowdfundingToken
chrismin Jul 19, 2018
2d87578
feat: set unlimited token transfer proxy in base Crowdfunding runner
chrismin Jul 19, 2018
bfbe69c
fix: make default scenario arguments more flexible
chrismin Jul 19, 2018
59da42f
feat: introduce WithdrawOnCrowdfundingToken runner
chrismin Jul 19, 2018
1365109
feat: introduce CrowdfundingToken integration test
chrismin Jul 19, 2018
94cedaf
feat: add safeguards to CrowdfundingTokenRegistry
chrismin Jul 19, 2018
54582f1
feat: reject repayment in CrowdfundingToken if no tokens have been mi…
chrismin Jul 19, 2018
c828547
feat: update withdrawOnCrowdfundingToken scenario to allow for multip…
chrismin Jul 19, 2018
a317581
feat: add multple token holder addresses to runners
chrismin Jul 19, 2018
5d3a31d
fix: use SafeMath in CrowdfundingToken
chrismin Jul 19, 2018
da3944f
feat: remove fees from default debt order
chrismin Jul 19, 2018
1746aca
fix: store repayments instead of per token withdrawal allowance to pr…
chrismin Jul 19, 2018
e67fdf2
feat: introduce more withdrawOnCrowdfungingToken scenarios
chrismin Jul 19, 2018
fb48007
feat: generalize the base withdrawOnCrowdfundingToken runner tests
chrismin Jul 19, 2018
eddfa21
fix: simplify tracking of withdrawals in CrowdfundingToken
chrismin Jul 20, 2018
a31982f
feat: add tests for additional withdrawals, transfers of tokens
chrismin Jul 20, 2018
6d59ca1
fix: remove unnecessary property
chrismin Jul 20, 2018
31cdc8e
fix: clean up test
chrismin Jul 20, 2018
9e287d9
feat: add Crowdfunding info to README
chrismin Jul 20, 2018
ee9905f
feat: update README
chrismin Jul 20, 2018
64a6b51
feat: make contractRegistryAddress public in CrowdfundingTokenRegistry
chrismin Jul 20, 2018
ce60e00
feat: add migration for CrowdfundingTokenRegistry
chrismin Jul 20, 2018
06e53e0
refactor: clean up CrowdfundingToken
chrismin Jul 20, 2018
bac29d7
refactor: clean up CrowdfundingTokenRegistry
chrismin Jul 20, 2018
8b4555f
fix: credit MinimeToken for Controlled contract
chrismin Jul 20, 2018
7c56c0d
fix: remove MinimeToken dependency
chrismin Jul 20, 2018
552996b
feat: update README
chrismin Jul 21, 2018
e675339
[F]
chrismin Jul 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@

> 'Charta' is the latin word for 'letter or document'. We loosely appropriate this term as a codename for the smart contracts comprising the business logic of Dharma protocol.

# Dharma Crowdfunding MVP
Send repayments to arbitrarily many recipients. Crowdfund debt. Issue bonds.

This overview assumes the reader has working knowledge of the Dharma Protocol. For a primer on the protocol, check out our [docs]().

### CrowdfundingToken
#### contracts/crowdfunding/CrowdfundingToken.sol
The Dharma `CrowdfundingToken` enables a single debtor to make repayments to multiple creditors. It takes much inspiration from the [`MinimeToken`](https://github.com/Giveth/minime).

- The `CrowdfundingToken` is an ERC-20 token.
- The `CrowdfundingToken` itself owns a Dharma `DebtToken`.
- The repayments made on the debt represented by the `DebtToken` are thus sent to the `CrowdfundingToken` contract.
- Owners of the `CrowdfundingToken` are entitled to a withdraw a portion of each repayment made to the contract.
- Each withdrawal amount is proportionate to the number of tokens owned by a given address divided by the total supply of tokens at the time of the repayment
- withdrawalAllowance = repaymentAmount * (tokensOwned / totalSupply)

### CrowdfundingTokenRegistry
#### contracts/crowdfunding/CrowdfundingTokenRegistry.sol
The `CrowdfundingTokenRegistry` is a smart contract that deploys and keeps track of `CrowdfundingToken`s.

### How to Crowdfund on Dharma Protocol
1. The issuer wanting to crowdfund creates a `DebtToken` with no principal and sets itself as both the creditor and debtor.
2. The issuer transfers the `DebtToken` to the `CrowdfundingTokenRegistry`.
3. On receipt of the `DebtToken`, the `CrowdfundingTokenRegistry` deploys a new `CrowdfundingToken` and passes the `DebtToken` on to the `CrowdfundingToken`.
- The original owner of the `DebtToken`--in this case the issuer--is the owner of the new `CrowdfundingToken` contract.
- The `CrowdfundingTokenRegistry` keeps track of the `CrowdfundingToken `based on the `agreementId` of the `DebtToken` it owns.
4. The issuer mints, distributes, and/or sells tokens of the `CrowdfundingToken` as they see fit.
5. The issuer makes repayments on their debt and registers the repayment with the `CrowdfundingToken`
- The repayment is routed to the `CrowdfundingToken`.
6. The token holders make withdrawals--proportionate to their ownership of the `CrowdfundingToken` at the time the repayment--from the `CrowdfundingToken`.

### Future Work
- A custom TermsContract to meet the needs of a specific crowdfunding use case
- Defining custom terms, repayment schedule, etc.
- Combining repayment and registering repayment into a single transaction
- Simplifying the process of distributing/purchasing `CrowdfundingToken`s

------------

[Dharma](https://dharma.io) is a protocol for generic tokenized debt issuance and fundraising on blockchains supporting requisite smart contract functionality (i.e. EVM blockchains). For a full description of the protocol's mechanics, a thorough overview can be found in the [Dharma Protocol Whitepaper](https://whitepaper.dharma.io/). This repository contains the core contracts that compromise the business logic for issuing and administering debt crypto-assets on-chain.

Expand Down
108 changes: 54 additions & 54 deletions artifacts/json/AddressUtils.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"abi": [],
"bytecode": "0x60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a723058201a94a5c7a3f497e8cf56df37432c210e41d7bb26c8b2dfc0b33d74a7b36b64720029",
"deployedBytecode": "0x6060604052600080fd00a165627a7a723058201a94a5c7a3f497e8cf56df37432c210e41d7bb26c8b2dfc0b33d74a7b36b64720029",
"sourceMap": "86:518:29:-;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "86:518:29:-;;;;;",
"sourceMap": "86:518:32:-;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "86:518:32:-;;;;;",
"source": "pragma solidity ^0.4.18;\n\n/**\n * Utility library of inline functions on addresses\n */\nlibrary AddressUtils {\n\n /**\n * Returns whether there is code in the target address\n * @dev This function will return false if invoked during the constructor of a contract,\n * as the code is not actually created until after the constructor finishes.\n * @param addr address address to check\n * @return whether there is code in the target address\n */\n function isContract(address addr) internal view returns (bool) {\n uint256 size;\n assembly { size := extcodesize(addr) }\n return size > 0;\n }\n\n}\n",
"sourcePath": "zeppelin-solidity/contracts/AddressUtils.sol",
"ast": {
"attributes": {
"absolutePath": "zeppelin-solidity/contracts/AddressUtils.sol",
"exportedSymbols": {
"AddressUtils": [
8604
9911
]
}
},
Expand All @@ -26,9 +26,9 @@
".18"
]
},
"id": 8587,
"id": 9894,
"name": "PragmaDirective",
"src": "0:24:29"
"src": "0:24:32"
},
{
"attributes": {
Expand All @@ -42,10 +42,10 @@
"documentation": "Utility library of inline functions on addresses",
"fullyImplemented": true,
"linearizedBaseContracts": [
8604
9911
],
"name": "AddressUtils",
"scope": 8605
"scope": 9912
},
"children": [
{
Expand All @@ -58,7 +58,7 @@
],
"name": "isContract",
"payable": false,
"scope": 8604,
"scope": 9911,
"stateMutability": "view",
"superFunction": null,
"visibility": "internal"
Expand All @@ -70,7 +70,7 @@
"attributes": {
"constant": false,
"name": "addr",
"scope": 8603,
"scope": 9910,
"stateVariable": false,
"storageLocation": "default",
"type": "address",
Expand All @@ -83,27 +83,27 @@
"name": "address",
"type": "address"
},
"id": 8588,
"id": 9895,
"name": "ElementaryTypeName",
"src": "471:7:29"
"src": "471:7:32"
}
],
"id": 8589,
"id": 9896,
"name": "VariableDeclaration",
"src": "471:12:29"
"src": "471:12:32"
}
],
"id": 8590,
"id": 9897,
"name": "ParameterList",
"src": "470:14:29"
"src": "470:14:32"
},
{
"children": [
{
"attributes": {
"constant": false,
"name": "",
"scope": 8603,
"scope": 9910,
"stateVariable": false,
"storageLocation": "default",
"type": "bool",
Expand All @@ -116,19 +116,19 @@
"name": "bool",
"type": "bool"
},
"id": 8591,
"id": 9898,
"name": "ElementaryTypeName",
"src": "508:4:29"
"src": "508:4:32"
}
],
"id": 8592,
"id": 9899,
"name": "VariableDeclaration",
"src": "508:4:29"
"src": "508:4:32"
}
],
"id": 8593,
"id": 9900,
"name": "ParameterList",
"src": "507:6:29"
"src": "507:6:32"
},
{
"children": [
Expand All @@ -144,7 +144,7 @@
"attributes": {
"constant": false,
"name": "size",
"scope": 8603,
"scope": 9910,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
Expand All @@ -157,52 +157,52 @@
"name": "uint256",
"type": "uint256"
},
"id": 8594,
"id": 9901,
"name": "ElementaryTypeName",
"src": "520:7:29"
"src": "520:7:32"
}
],
"id": 8595,
"id": 9902,
"name": "VariableDeclaration",
"src": "520:12:29"
"src": "520:12:32"
}
],
"id": 8596,
"id": 9903,
"name": "VariableDeclarationStatement",
"src": "520:12:29"
"src": "520:12:32"
},
{
"attributes": {
"externalReferences": [
{
"size": {
"declaration": 8595,
"declaration": 9902,
"isOffset": false,
"isSlot": false,
"src": "549:4:29",
"src": "549:4:32",
"valueSize": 1
}
},
{
"addr": {
"declaration": 8589,
"declaration": 9896,
"isOffset": false,
"isSlot": false,
"src": "569:4:29",
"src": "569:4:32",
"valueSize": 1
}
}
],
"operations": "{\n size := extcodesize(addr)\n}"
},
"children": [],
"id": 8597,
"id": 9904,
"name": "InlineAssembly",
"src": "538:49:29"
"src": "538:49:32"
},
{
"attributes": {
"functionReturnParameters": 8593
"functionReturnParameters": 9900
},
"children": [
{
Expand All @@ -226,13 +226,13 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 8595,
"referencedDeclaration": 9902,
"type": "uint256",
"value": "size"
},
"id": 8598,
"id": 9905,
"name": "Identifier",
"src": "588:4:29"
"src": "588:4:32"
},
{
"attributes": {
Expand All @@ -247,45 +247,45 @@
"type": "int_const 0",
"value": "0"
},
"id": 8599,
"id": 9906,
"name": "Literal",
"src": "595:1:29"
"src": "595:1:32"
}
],
"id": 8600,
"id": 9907,
"name": "BinaryOperation",
"src": "588:8:29"
"src": "588:8:32"
}
],
"id": 8601,
"id": 9908,
"name": "Return",
"src": "581:15:29"
"src": "581:15:32"
}
],
"id": 8602,
"id": 9909,
"name": "Block",
"src": "514:87:29"
"src": "514:87:32"
}
],
"id": 8603,
"id": 9910,
"name": "FunctionDefinition",
"src": "451:150:29"
"src": "451:150:32"
}
],
"id": 8604,
"id": 9911,
"name": "ContractDefinition",
"src": "86:518:29"
"src": "86:518:32"
}
],
"id": 8605,
"id": 9912,
"name": "SourceUnit",
"src": "0:605:29"
"src": "0:605:32"
},
"compiler": {
"name": "solc",
"version": "0.4.18+commit.9cf6e910.Emscripten.clang"
},
"networks": {},
"schemaVersion": "1.0.1",
"updatedAt": "2018-07-02T23:10:02.088Z"
"updatedAt": "2018-07-24T01:55:45.041Z"
}
14,903 changes: 14,903 additions & 0 deletions artifacts/json/ApproveAndCallFallBack.json

Large diffs are not rendered by default.

Loading