forked from balancer/balancer-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TBTokenERC20.sol
170 lines (147 loc) · 4.97 KB
/
TBTokenERC20.sol
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import "../crytic-export/flattening/BPool.sol";
contract CryticInterface{
address internal crytic_owner = address(0x41414141);
address internal crytic_user = address(0x42424242);
address internal crytic_attacker = address(0x43434343);
uint internal initialTotalSupply = uint(-1);
uint internal initialBalance_owner;
uint internal initialBalance_user;
uint internal initialBalance_attacker;
uint initialAllowance_user_attacker;
uint initialAllowance_attacker_user;
uint initialAllowance_attacker_attacker;
}
contract TBTokenERC20 is CryticInterface, BToken {
constructor() public {
_totalSupply = initialTotalSupply;
_balance[crytic_owner] = 0;
_balance[crytic_user] = initialTotalSupply/2;
initialBalance_user = initialTotalSupply/2;
_balance[crytic_attacker] = initialTotalSupply/2;
initialBalance_attacker = initialTotalSupply/2;
}
/*
Type: Code quality
Return: Success
*/
function echidna_zero_always_empty() public returns(bool){
return this.balanceOf(address(0x0)) == 0;
}
/*
Type: Code Quality
Return:
*/
function echidna_approve_overwrites() public returns (bool) {
bool approve_return;
approve_return = approve(crytic_user, 10);
require(approve_return);
approve_return = approve(crytic_user, 20);
require(approve_return);
return this.allowance(msg.sender, crytic_user) == 20;
}
/*
Type: Undetermined severity
Return: Success
*/
function echidna_balance_less_than_totalSupply() public returns(bool){
return this.balanceOf(msg.sender) <= _totalSupply;
}
/*
Type: Low severity
Return: Success
*/
function echidna_totalSupply_balances_consistency() public returns(bool){
return this.balanceOf(crytic_owner) + this.balanceOf(crytic_user) + this.balanceOf(crytic_attacker) <= totalSupply();
}
/*
Properties: Transferable
*/
/*
Type: Code Quality
Return: Fail or Throw
*/
function echidna_revert_transfer_to_zero() public returns (bool) {
if (this.balanceOf(msg.sender) == 0)
revert();
return transfer(address(0x0), this.balanceOf(msg.sender));
}
/*
Type: Code Quality
Return: Fail or Throw
*/
function echidna_revert_transferFrom_to_zero() public returns (bool) {
uint balance = this.balanceOf(msg.sender);
bool approve_return = approve(msg.sender, balance);
return transferFrom(msg.sender, address(0x0), this.balanceOf(msg.sender));
}
/*
Type: ERC20 Standard
Fire: Transfer(msg.sender, msg.sender, balanceOf(msg.sender))
Return: Success
*/
function echidna_self_transferFrom() public returns(bool){
uint balance = this.balanceOf(msg.sender);
bool approve_return = approve(msg.sender, balance);
bool transfer_return = transferFrom(msg.sender, msg.sender, balance);
return (this.balanceOf(msg.sender) == balance) && approve_return && transfer_return;
}
/*
Type: ERC20 Standard
Return: Success
*/
function echidna_self_transferFrom_to_other() public returns(bool){
uint balance = this.balanceOf(msg.sender);
bool approve_return = approve(msg.sender, balance);
bool transfer_return = transferFrom(msg.sender, crytic_owner, balance);
return (this.balanceOf(msg.sender) == 0) && approve_return && transfer_return;
}
/*
Type: ERC20 Standard
Fire: Transfer(msg.sender, msg.sender, balanceOf(msg.sender))
Return: Success
*/
function echidna_self_transfer() public returns(bool){
uint balance = this.balanceOf(msg.sender);
bool transfer_return = transfer(msg.sender, balance);
return (this.balanceOf(msg.sender) == balance) && transfer_return;
}
/*
Type: ERC20 Standard
Fire: Transfer(msg.sender, other, 1)
Return: Success
*/
function echidna_transfer_to_other() public returns(bool){
uint balance = this.balanceOf(msg.sender);
address other = crytic_user;
if (other == msg.sender) {
other = crytic_owner;
}
if (balance >= 1) {
bool transfer_other = transfer(other, 1);
return (this.balanceOf(msg.sender) == balance-1) && (this.balanceOf(other) >= 1) && transfer_other;
}
return true;
}
/*
Type: ERC20 Standard
Fire: Transfer(msg.sender, user, balance+1)
Return: Fail or Throw
*/
function echidna_revert_transfer_to_user() public returns(bool){
uint balance = this.balanceOf(msg.sender);
if (balance == (2 ** 256 - 1))
revert();
bool transfer_other = transfer(crytic_user, balance+1);
return true;
}
/*
Properties: Not Mintable
*/
/*
Type: Undetermined severity
Return: Success
*/
function echidna_totalSupply_constant() public returns(bool){
return initialTotalSupply == totalSupply();
}
}