-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsimple.js
97 lines (52 loc) · 1.69 KB
/
simple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class rICO
{
constructor() {
this.block = 1;
this.blockCount = 100;
this.balances = [];
}
setBlock(block) {
this.block = block;
}
getRatio() {
return this.block * 100 / this.blockCount;
}
commit(address, eth) {
// do not allocate to project.
// contract eth just increases, and ProjectAvailable will include it
this.balances[address] = eth;
// increase number of tokens
}
withdraw(address, amount) {
// do not allocate to project.
// based on tokens we return, get eth to return
// decrease number of tokens
// allocated_by_withdraw
}
projectAvailable() {
/*
pending_in_contract = total_received - total_commited - withdrawn;
available_in_contract = total_commited (accepted contributions total) - withdrawn;
allocated_by_commit
allocated_by_withdraw
var unlockedPercentage = this.block / (buyEndBlock - buyStartBlock) (duration);
var unlockedPercentage = this.block / (buyEndBlock - lastWithdrawBlock)(duration);
unlocked = (available_in_contract - allocated) * unlockedPercentage
available = allocated - withdrawn_by_project + unlocked;
global
*/
}
projectWithdraw(amount) {
//
}
}
/*
user commits 50 at block 50
- project available = 25
- user available = 25
user withdraws 25
- project available is 12.5 -> should be 25..
* allocate "unlocked amount" to project
* subtract unlocked amount from global available
allocatedEthAmount
*/