Skip to content

Commit

Permalink
Merge 75e5475 into f664691
Browse files Browse the repository at this point in the history
  • Loading branch information
Franklin Richards committed Jun 24, 2021
2 parents f664691 + 75e5475 commit ac35c1f
Show file tree
Hide file tree
Showing 86 changed files with 50,809 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
mocha: true, // for test files
"truffle/globals": true, // same as "truffle/truffle": true
},
extends: "prettier",
parserOptions: {
ecmaVersion: 2020,
},
rules: {},
plugins: ["truffle"],
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
36 changes: 36 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Installing Packages
run: npm ci
- name: Checking Formatting
run: npm run lint && npm run prettier-check
- name: Test Coverage
run: npm run test
# - name: Code Coverage
# run: npm run coverage
# - name: Coveralls GitHub Action
# uses: coverallsapp/github-action@v1.1.2
# with:
# github-token: ${{ secrets.COVERALLS }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,12 @@ dist

# TernJS port file
.tern-port

# Custom
cache
build
artifacts
.vscode
coverage
coverage.json
.DS_Store
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
__pycache__
.DS_Store
.history
.hypothesis/
artifacts/
build/
reports/
node_modules/
!.solhint.json
package-lock.json
coverage
coverage.json
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"overrides": [
{
"files": ["*.sol", "*.js"],
"options": {
"printWidth": 140,
"tabWidth": 4,
"useTabs": true,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
}
}
]
}
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
skipFiles: ['Sovryn', 'Openzeppelin', 'Interfaces']
};
8 changes: 8 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "solhint:default",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"max-line-length": ["warn",140]
}
}
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: node_js
os: linux
dist: xenial
node_js:
- "10"

cache:
directories:
- node_modules

before_install:
- export NODE_OPTIONS=--max_old_space_size=6144

install:
- npm ci

script:
- npm run coverage

after_script:
- cat coverage/lcov.info | coveralls
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,97 @@
# origins
# Origins [![Node.js CI](https://github.com/DistributedCollective/origins/actions/workflows/node.js.yml/badge.svg)](https://github.com/DistributedCollective/origins/actions/workflows/node.js.yml) [![Build Status](https://travis-ci.org/DistributedCollective/origins.svg?branch=main)](https://travis-ci.org/DistributedCollective/origins) [![Coverage Status](https://coveralls.io/repos/github/DistributedCollective/origins/badge.svg?branch=initial)](https://coveralls.io/github/DistributedCollective/origins?branch=initial)

The Origins Platform Smart Contracts

## Main Contracts

- OriginsAdmin
- OriginsStorage
- OriginsEvents
- OriginsBase
- LockedFund

### OriginsAdmin

A basic contract with currently two main roles:
- Owner
- Verifier

An owner has the right on major decision making functions. The owner has too many rights, including the withdrawal of proceedings, thus it is recommended to use a multisig for the same.

A Verifier currently has the right to add any address as verified.

### OriginsStorage

A contract with all the storage of `OriginsBase`. Basically acts as the harddisk of the system.

### OriginsEvents

A contract with all the events of `OriginsBase` listed in it.

### OriginsBase

This is the main contract which does all the major works. Each sale is a Tier. And a single contract will be enough to do multiple sales of a unique Token.

The proceedings of the raised amount could be taken by the owner or a pre-set deposit address.

Tier creation could be done with a single function call, or can be done by multiple calls. Individual Tier parameters can be edited as well based on Tier ID.

Verification of participants at the moment can be done by address. And any verifier can add address and tiers for which the address is approved. Verification Type also gives freedom to pass anyone, thus allowing a public sale.

Sale time is also dependent on two different methods mainly, one is duration (calculated from the start time) or the end timestamp itself. Another method is until supply last as well.

Deposit asset can be either RBTC or any other ERC20 Compliant Token as well, and it can be unique for each tier also.

Transfer Type can be None, Unlocked Immediately, Waited Unlock, which means the unlock will happen after a certain period, Locked, which means the tokens will be a linear vesting, and finally Vested, which is tokens vested linearly, but the difference being the voting power in Governance. The current version only support None, Unlocked and Vested for now.

The contract also keeps track of participating wallets per tier, the number of tokens sold per tier, etc.

### LockedFund

Currently it's functionality is limited to vest tokens and withdraw tokens after a certain time period. In the future, it will allow for further features like locked tokens and unlocked tokens, etc.

For Vesting, it uses the contracts of `Sovryn-smart-contract` repo. The registry used in this case with be `VestingRegistry3`.

## Call Graph

![Call Graph](callGraph.svg)

P.S. It is a simple project, isn't it?

## Call Graph

![UML Diagram](UML.png)

## Explanation

TODO

## Deployment

- TODO
- TODO: Setting `waitedTS` in LockedFund.
- TODO: Setting `OriginsBase` as an admin of LockedFund for calling deposit function.

### Deployment Parameters

TODO

## Assumptions

- Admin has a lot of power, and is assumed to be the right, fair and just person/party. It is highly advised to have a multisig as admin, rather than just a EOA.

## Limitations

- If the deposit asset price is lower than the token which is sold, currently that is not possible with this system. A simple solution is to have a divisor constant or a numerator & denominator system instead of the rate system.
- LockedFund can only have a single cliff and duration per person. Tier based system would be much better when the vesting registry is updated (waiting for a PR to be merged in Sovryn).
- Address can only be validated, and cannot be invalidated. Adding a simple function should suffice. To be done in the next update.

## Improvements

- NFT Based Sale.
- Decoupling Tier for lesser gas usage and minimize the stack too deep error.
- Fee for use of Origins platform (Contracts, UI and Setup).
- Divide the contract based on Verification Type, Vesting/Locked Type, Deposit by Token or RBTC, etc to make the contract size and interaction gas cost to the minimum without losing the Origins Granularity. This will be a new contract which will be inheriting from OriginsBase, with OriginsBase itself inheriting a unique OriginsStorage based on the granularity.
- Maybe a single contract can act as the platform if instead of different tiers based on ID, the tiers are based on token address (which is to be sold), thus having multiple tiers based on that. So, a single contract can handle multiple sales at once with multiple tiers. This can only be done after struct decoupling and gas profiling of each function and possible gas saving methods added.
- Total unique wallets participated in all tiers. Currently only unique wallets participated in a each tier is counted, which is not the same as unique wallets participated in all tiers combined. New storage structure will be required.
- Tests related to other type of sales to be added.
Binary file added UML.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Brownie configuration file
# https://eth-brownie.readthedocs.io/en/stable/config.html

project_structure:
build: build
contracts: contracts
interfaces: contracts/Interfaces
reports: reports
scripts: scripts
tests: tests

networks:
default: development
development:
gas_limit: 6800000
gas_price: 65000000
reverting_tx_gas_limit: 8000000
default_contract_owner: true
cmd_settings:
port: 8545
gas_limit: 6800000
accounts: 10
evm_version: istanbul
mnemonic: brownie
block_time: 0
default_balance: 1000000
# time: 2020-05-08T14:54:08+0000
live:
cmd_settings:
port: 443
gas_limit: 6800000
gas_price: 65100000 # 8000000000
reverting_tx_gas_limit: false
default_contract_owner: false

compiler:
evm_version: null
solc:
version: null
optimizer:
enabled: true
runs: 200
remappings: null

console:
show_colors: true
color_style: monokai
auto_suggest: true
completions: true

reports:
exclude_paths:
- contracts/Openzeppelin/*.*
- contracts/Testhelpers/*.*
exclude_contracts:
- MultiSigWallet

hypothesis:
deadline: null
max_examples: 50
report_multiple_bugs: False
stateful_step_count: 10

autofetch_sources: false
dependencies: null
dev_deployment_artifacts: false

0 comments on commit ac35c1f

Please sign in to comment.