Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 1b722a9

Browse files
authored
Merge pull request #13 from SetProtocol/v0.2.0
@SetProtocol Alpha Release V0.2.0
2 parents 61d4fb9 + 5eb5987 commit 1b722a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+67758
-3365
lines changed

.circleci/config.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
docker:
6+
- image: circleci/node:9.6.1
7+
steps:
8+
- checkout
9+
- run: yarn
10+
- run:
11+
name: testrpc
12+
command: yarn chain
13+
background: true
14+
- run: yarn test

.gitignore

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
node_modules/
2-
build
1+
.DS_Store
2+
/node_modules
3+
/transpiled
4+
/types/generated/*
5+
/build
6+
/dist
7+
8+
### Node ###
9+
10+
# Logs
11+
*.log
12+
/logs
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
types/generated/

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .prettierrc
2+
printWidth: 100
3+
parser: typescript
4+
tabWidth: 2
5+
trailingComma: all
6+
arrowParens: always

.solhint.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
2-
"extends": "default",
3-
"rules": {
4-
"indent": ["error", 2],
5-
"quotes": ["error", "double"],
6-
"max-line-length": ["error", 120]
7-
}
2+
"extends": "default",
3+
"rules": {
4+
"indent": ["error", 2],
5+
"code-complexity": false,
6+
"function-max-lines": false,
7+
"separate-by-one-line-in-contract": false,
8+
"not-rely-on-time": false,
9+
"no-unused-vars": false,
10+
"no-empty-blocks": false
11+
}
812
}

README.md

+5-70
Original file line numberDiff line numberDiff line change
@@ -13,83 +13,18 @@ PLEASE NOTE that these contracts have not been extensively audited yet and are n
1313

1414
## Install and run the unit tests
1515

16-
1. Run npm install
16+
1. Run yarn install
1717
```
18-
npm install
18+
yarn install
1919
```
2020

2121
2. Install [truffle](http://truffleframework.com/) and [test-rpc](https://github.com/ethereumjs/testrpc) globally
2222
```
23-
npm i -g ethereumjs-testrpc
24-
npm install -g truffle
23+
yarn global add ethereumjs-testrpc
24+
yarn global add truffle
2525
```
2626

2727
3. Run unit tests
2828
```
29-
truffle compile
30-
truffle test
29+
yarn run test
3130
```
32-
33-
34-
35-
## Smart Contract
36-
The {Set} contract has three functions, which are the constructor, issue, and redeem.
37-
38-
### Underwriting (constructor)
39-
Underwriting is the process of creating a new {Set} contract. Anybody can create an Index Token by deploying a new {Set} contract that follows the {Set} specification to an Ethereum network. The constructor function is only called once during deployment. The required constructor parameters are below:
40-
41-
**Token Creation Parameters**
42-
43-
Parameter | Type | Description
44-
------------ | ------------- | -------------
45-
tokens | address[] | A list of ERC20 token addresses
46-
units | uint[] | A list of quantities for each token
47-
48-
There are no restrictions to how many different ERC20 tokens can be included, aside from the transaction gas limit and data input limits. Since {Set}s are ERC20 tokens, {Set}s could be composed of other {Set}s. Deploying a {Set} creates a clean-slate contract with 0 tokens.
49-
50-
51-
### Token Issuance (issue)
52-
Token issuance is the process of generating new tokens from a {Set} Contract. Given the {Set} contract has been deployed, anybody can call the contract's `issue` function to convert a specified mix of ERC20 tokens into a token that represents its underlying parts. There only exists as many {Set} tokens as there are tokens issued less redemptions. The issue function parameters are:
53-
54-
**Issue Function Parameters**
55-
56-
Parameter | Type | Description
57-
------------ | ------------- | -------------
58-
quantity | uint | The quantity of {Set}s to issue
59-
60-
There are 7 steps to issuing a {Set} token:
61-
62-
<p align="center"><strong>Figure 1: {Set} Issuance Process</strong></p>
63-
<p align="center"><img src="diagrams/SetIssuance.png" alt="Set Issuance" height="300"/></p>
64-
65-
Figure 1 steps explained
66-
67-
1. Issuer decides the quantity of {Set} tokens to issue
68-
2. Issuer calls Token A's `approve` function for the specified unit of Token A required multiplied by the quantity desired to issue
69-
3. Issuer calls Token B's `approve` function for the specified unit of Token B required multiplied by the quantity desired to issue
70-
4. Issue continues to call `approve` for the correct amount to all remaining tokens
71-
5. Issuer calls the {Set} Contract's `issue` function with the desired quantity of Index Tokens to issue
72-
6. The contract transfers the required quantities of tokens to the contracts. If any transfer is unsuccessful, the whole transaction is reverted.
73-
7. If the previous step was sucessful, the contract increments the corresponding quantity of tokens to the issuer
74-
75-
76-
### Token Redemption (redeem)
77-
Token Redemption is the process of converting an Index Token into its underlying component tokens. Redeeming tokens reduces the token supply of {Set} tokens in the contract. The issue function parameters are:
78-
79-
**Redeem Function Parameters**
80-
81-
Parameter | Type | Description
82-
------------ | ------------- | -------------
83-
quantity | uint | The quantity of {Set}s to redeem
84-
85-
There are 4 steps to issuing a {Set} token:
86-
87-
<p align="center"><strong>Figure 2: {Set} Redemption Process</strong></p>
88-
<p align="center"><img src="diagrams/SetRedemption.png" alt="Set Redemption" height="200"/></p>
89-
90-
Figure steps explained
91-
1. Issuer decides the quantity of {Set} tokens to redeem
92-
2. Issuer calls the `redeem` function with the quantity to redeem
93-
3. The contract checks to ensure that the user has enough Index tokens. The function reverts if not.
94-
4. The contract transfers the underlying tokens to the sender and then decrements the sender's index token balance
95-

artifacts/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { BasicToken } from "./ts/BasicToken";
2+
import { DetailedERC20 } from "./ts/DetailedERC20";
3+
import { ERC20 } from "./ts/ERC20";
4+
import { ERC20Basic } from "./ts/ERC20Basic";
5+
import { Set } from "./ts/Set";
6+
import { SetToken } from "./ts/SetToken";
7+
import { StandardToken } from "./ts/StandardToken";
8+
import { StandardTokenMock } from "./ts/StandardTokenMock";
9+
10+
export {
11+
BasicToken,
12+
DetailedERC20,
13+
ERC20,
14+
ERC20Basic,
15+
Set,
16+
SetToken,
17+
StandardToken,
18+
StandardTokenMock,
19+
};

0 commit comments

Comments
 (0)