mirror of https://github.com/crytic/slither
parent
36c60a93b0
commit
0efef8babf
@ -0,0 +1,117 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
a = block.coinbase |
||||
|
||||
IRs: |
||||
a(address) := block.coinbase(address)"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
b = block.difficulty |
||||
|
||||
IRs: |
||||
b(uint256) := block.difficulty(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: NEW VARIABLE 3 |
||||
|
||||
EXPRESSION: |
||||
c = block.prevrandao |
||||
|
||||
IRs: |
||||
c(uint256) := block.prevrandao(uint256)"]; |
||||
3->4; |
||||
4[label="Node Type: NEW VARIABLE 4 |
||||
|
||||
EXPRESSION: |
||||
d = block.number |
||||
|
||||
IRs: |
||||
d(uint256) := block.number(uint256)"]; |
||||
4->5; |
||||
5[label="Node Type: NEW VARIABLE 5 |
||||
|
||||
EXPRESSION: |
||||
e = block.prevhash |
||||
|
||||
IRs: |
||||
e(bytes32) := block.prevhash(bytes32)"]; |
||||
5->6; |
||||
6[label="Node Type: NEW VARIABLE 6 |
||||
|
||||
EXPRESSION: |
||||
f = block.timestamp |
||||
|
||||
IRs: |
||||
f(uint256) := block.timestamp(uint256)"]; |
||||
6->7; |
||||
7[label="Node Type: NEW VARIABLE 7 |
||||
|
||||
EXPRESSION: |
||||
h = chain.id |
||||
|
||||
IRs: |
||||
h(uint256) := chain.id(uint256)"]; |
||||
7->8; |
||||
8[label="Node Type: NEW VARIABLE 8 |
||||
|
||||
EXPRESSION: |
||||
i = slice()(msg.data,0,32) |
||||
|
||||
IRs: |
||||
TMP_0(None) = SOLIDITY_CALL slice()(msg.data,0,32) |
||||
i(bytes[32]) = ['TMP_0(None)']"]; |
||||
8->9; |
||||
9[label="Node Type: NEW VARIABLE 9 |
||||
|
||||
EXPRESSION: |
||||
j = msg.gas |
||||
|
||||
IRs: |
||||
j(uint256) := msg.gas(uint256)"]; |
||||
9->10; |
||||
10[label="Node Type: NEW VARIABLE 10 |
||||
|
||||
EXPRESSION: |
||||
k = msg.sender |
||||
|
||||
IRs: |
||||
k(address) := msg.sender(address)"]; |
||||
10->11; |
||||
11[label="Node Type: NEW VARIABLE 11 |
||||
|
||||
EXPRESSION: |
||||
l = msg.value |
||||
|
||||
IRs: |
||||
l(uint256) := msg.value(uint256)"]; |
||||
11->12; |
||||
12[label="Node Type: NEW VARIABLE 12 |
||||
|
||||
EXPRESSION: |
||||
m = tx.origin |
||||
|
||||
IRs: |
||||
m(address) := tx.origin(address)"]; |
||||
12->13; |
||||
13[label="Node Type: NEW VARIABLE 13 |
||||
|
||||
EXPRESSION: |
||||
n = tx.gasprice |
||||
|
||||
IRs: |
||||
n(uint256) := tx.gasprice(uint256)"]; |
||||
13->14; |
||||
14[label="Node Type: NEW VARIABLE 14 |
||||
|
||||
EXPRESSION: |
||||
x = self.balance |
||||
|
||||
IRs: |
||||
x(uint256) := self.balance(uint256)"]; |
||||
} |
@ -0,0 +1,13 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
x = bytes32(chain.id) |
||||
|
||||
IRs: |
||||
TMP_0 = CONVERT chain.id to bytes32 |
||||
x(bytes32) := TMP_0(bytes32)"]; |
||||
} |
@ -0,0 +1,63 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
_strategies = strategies |
||||
|
||||
IRs: |
||||
_strategies(address[3]) = ['strategies(address[3])']"]; |
||||
1->2; |
||||
2[label="Node Type: BEGIN_LOOP 2 |
||||
"]; |
||||
2->3; |
||||
3[label="Node Type: NEW VARIABLE 3 |
||||
|
||||
EXPRESSION: |
||||
counter_var = 0 |
||||
|
||||
IRs: |
||||
counter_var(uint256) := 0(uint256)"]; |
||||
3->4; |
||||
4[label="Node Type: IF_LOOP 4 |
||||
|
||||
EXPRESSION: |
||||
counter_var <= 10 |
||||
|
||||
IRs: |
||||
TMP_0(bool) = counter_var <= 10 |
||||
CONDITION TMP_0"]; |
||||
4->5[label="True"]; |
||||
4->7[label="False"]; |
||||
5[label="Node Type: NEW VARIABLE 5 |
||||
|
||||
EXPRESSION: |
||||
i = counter_var |
||||
|
||||
IRs: |
||||
i(uint256) := counter_var(uint256)"]; |
||||
5->6; |
||||
6[label="Node Type: NEW VARIABLE 6 |
||||
|
||||
EXPRESSION: |
||||
max_withdraw = IStrategy(_strategies[i]).maxWithdraw(self) |
||||
|
||||
IRs: |
||||
REF_0(address) -> _strategies[i] |
||||
TMP_1 = CONVERT REF_0 to IStrategy |
||||
TMP_2(uint256) = HIGH_LEVEL_CALL, dest:TMP_1(IStrategy), function:maxWithdraw, arguments:['self'] |
||||
max_withdraw(uint256) := TMP_2(uint256)"]; |
||||
6->8; |
||||
7[label="Node Type: END_LOOP 7 |
||||
"]; |
||||
8[label="Node Type: EXPRESSION 8 |
||||
|
||||
EXPRESSION: |
||||
counter_var += 1 |
||||
|
||||
IRs: |
||||
counter_var(uint256) = counter_var (c)+ 1"]; |
||||
8->4; |
||||
} |
@ -0,0 +1,19 @@ |
||||
digraph{ |
||||
0[label="Node Type: OTHER_ENTRYPOINT 0 |
||||
|
||||
EXPRESSION: |
||||
x = 1 + 1 |
||||
|
||||
IRs: |
||||
TMP_3(uint256) = 1 + 1 |
||||
x(uint256) := TMP_3(uint256)"]; |
||||
0->1; |
||||
1[label="Node Type: OTHER_ENTRYPOINT 1 |
||||
|
||||
EXPRESSION: |
||||
MAX_QUEUE = 1 + x |
||||
|
||||
IRs: |
||||
TMP_4(uint256) = 1 + x |
||||
MAX_QUEUE(uint256) := TMP_4(uint256)"]; |
||||
} |
@ -0,0 +1,62 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
S = 0 |
||||
|
||||
IRs: |
||||
S(uint256) := 0(uint256)"]; |
||||
1->2; |
||||
2[label="Node Type: BEGIN_LOOP 2 |
||||
"]; |
||||
2->3; |
||||
3[label="Node Type: NEW VARIABLE 3 |
||||
|
||||
EXPRESSION: |
||||
counter_var = 0 |
||||
|
||||
IRs: |
||||
counter_var(uint256) := 0(uint256)"]; |
||||
3->4; |
||||
4[label="Node Type: IF_LOOP 4 |
||||
|
||||
EXPRESSION: |
||||
counter_var <= len()(_xp) |
||||
|
||||
IRs: |
||||
TMP_0(uint256) = SOLIDITY_CALL len()(_xp) |
||||
TMP_1(bool) = counter_var <= TMP_0 |
||||
CONDITION TMP_1"]; |
||||
4->5[label="True"]; |
||||
4->7[label="False"]; |
||||
5[label="Node Type: NEW VARIABLE 5 |
||||
|
||||
EXPRESSION: |
||||
x = _xp[counter_var] |
||||
|
||||
IRs: |
||||
REF_0(uint256) -> _xp[counter_var] |
||||
x(uint256) := REF_0(uint256)"]; |
||||
5->6; |
||||
6[label="Node Type: EXPRESSION 6 |
||||
|
||||
EXPRESSION: |
||||
S += x |
||||
|
||||
IRs: |
||||
S(uint256) = S (c)+ x"]; |
||||
6->8; |
||||
7[label="Node Type: END_LOOP 7 |
||||
"]; |
||||
8[label="Node Type: EXPRESSION 8 |
||||
|
||||
EXPRESSION: |
||||
counter_var += 1 |
||||
|
||||
IRs: |
||||
counter_var(uint256) = counter_var (c)+ 1"]; |
||||
8->4; |
||||
} |
@ -0,0 +1,56 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: BEGIN_LOOP 1 |
||||
"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
counter_var = 0 |
||||
|
||||
IRs: |
||||
counter_var(uint256) := 0(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: IF_LOOP 3 |
||||
|
||||
EXPRESSION: |
||||
counter_var <= len()(super.strategies) |
||||
|
||||
IRs: |
||||
TMP_0(uint256) = SOLIDITY_CALL len()(strategies) |
||||
TMP_1(bool) = counter_var <= TMP_0 |
||||
CONDITION TMP_1"]; |
||||
3->4[label="True"]; |
||||
3->6[label="False"]; |
||||
4[label="Node Type: NEW VARIABLE 4 |
||||
|
||||
EXPRESSION: |
||||
strategy = strategies[counter_var] |
||||
|
||||
IRs: |
||||
REF_0(address) -> strategies[counter_var] |
||||
strategy(address) := REF_0(address)"]; |
||||
4->5; |
||||
5[label="Node Type: NEW VARIABLE 5 |
||||
|
||||
EXPRESSION: |
||||
z = IStrategy(strategy).asset() |
||||
|
||||
IRs: |
||||
TMP_2 = CONVERT strategy to IStrategy |
||||
TMP_3(address) = HIGH_LEVEL_CALL, dest:TMP_2(IStrategy), function:asset, arguments:[] |
||||
z(address) := TMP_3(address)"]; |
||||
5->7; |
||||
6[label="Node Type: END_LOOP 6 |
||||
"]; |
||||
7[label="Node Type: EXPRESSION 7 |
||||
|
||||
EXPRESSION: |
||||
counter_var += 1 |
||||
|
||||
IRs: |
||||
counter_var(uint256) = counter_var (c)+ 1"]; |
||||
7->3; |
||||
} |
@ -0,0 +1,19 @@ |
||||
digraph{ |
||||
0[label="Node Type: OTHER_ENTRYPOINT 0 |
||||
|
||||
EXPRESSION: |
||||
x = 1 + 1 |
||||
|
||||
IRs: |
||||
TMP_4(uint256) = 1 + 1 |
||||
x(uint256) := TMP_4(uint256)"]; |
||||
0->1; |
||||
1[label="Node Type: OTHER_ENTRYPOINT 1 |
||||
|
||||
EXPRESSION: |
||||
MAX_QUEUE = 1 + x |
||||
|
||||
IRs: |
||||
TMP_5(uint256) = 1 + x |
||||
MAX_QUEUE(uint256) := TMP_5(uint256)"]; |
||||
} |
@ -0,0 +1,172 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
p_new = p |
||||
|
||||
IRs: |
||||
p_new(uint256) := p(uint256)"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
dt = 1 |
||||
|
||||
IRs: |
||||
dt(uint256) := 1(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: NEW VARIABLE 3 |
||||
|
||||
EXPRESSION: |
||||
ratio = 0 |
||||
|
||||
IRs: |
||||
ratio(uint256) := 0(uint256)"]; |
||||
3->4; |
||||
4[label="Node Type: IF 4 |
||||
|
||||
EXPRESSION: |
||||
dt > 0 |
||||
|
||||
IRs: |
||||
TMP_0(bool) = dt > 0 |
||||
CONDITION TMP_0"]; |
||||
4->6[label="True"]; |
||||
4->5[label="False"]; |
||||
5[label="Node Type: END_IF 5 |
||||
"]; |
||||
6[label="Node Type: NEW VARIABLE 6 |
||||
|
||||
EXPRESSION: |
||||
old_p_o = 1 |
||||
|
||||
IRs: |
||||
old_p_o(uint256) := 1(uint256)"]; |
||||
6->7; |
||||
7[label="Node Type: NEW VARIABLE 7 |
||||
|
||||
EXPRESSION: |
||||
old_ratio = 2 |
||||
|
||||
IRs: |
||||
old_ratio(uint256) := 2(uint256)"]; |
||||
7->8; |
||||
8[label="Node Type: IF 8 |
||||
|
||||
EXPRESSION: |
||||
p > old_p_o |
||||
|
||||
IRs: |
||||
TMP_1(bool) = p > old_p_o |
||||
CONDITION TMP_1"]; |
||||
8->10[label="True"]; |
||||
8->15[label="False"]; |
||||
9[label="Node Type: END_IF 9 |
||||
"]; |
||||
9->20; |
||||
10[label="Node Type: EXPRESSION 10 |
||||
|
||||
EXPRESSION: |
||||
ratio = unsafe_div()(old_p_o * 10 ** 18,p) |
||||
|
||||
IRs: |
||||
TMP_2(uint256) = 10 (c)** 18 |
||||
TMP_3(uint256) = old_p_o (c)* TMP_2 |
||||
TMP_4(None) = SOLIDITY_CALL unsafe_div()(TMP_3,p) |
||||
ratio(uint256) := TMP_4(None)"]; |
||||
10->11; |
||||
11[label="Node Type: IF 11 |
||||
|
||||
EXPRESSION: |
||||
ratio < 10 ** 36 / 1 |
||||
|
||||
IRs: |
||||
TMP_5(uint256) = 10 (c)** 36 |
||||
TMP_6(uint256) = TMP_5 (c)/ 1 |
||||
TMP_7(bool) = ratio < TMP_6 |
||||
CONDITION TMP_7"]; |
||||
11->13[label="True"]; |
||||
11->12[label="False"]; |
||||
12[label="Node Type: END_IF 12 |
||||
"]; |
||||
12->9; |
||||
13[label="Node Type: EXPRESSION 13 |
||||
|
||||
EXPRESSION: |
||||
p_new = unsafe_div()(old_p_o * 1,10 ** 18) |
||||
|
||||
IRs: |
||||
TMP_8(uint256) = old_p_o (c)* 1 |
||||
TMP_9(uint256) = 10 (c)** 18 |
||||
TMP_10(None) = SOLIDITY_CALL unsafe_div()(TMP_8,TMP_9) |
||||
p_new(uint256) := TMP_10(None)"]; |
||||
13->14; |
||||
14[label="Node Type: EXPRESSION 14 |
||||
|
||||
EXPRESSION: |
||||
ratio = 10 ** 36 / 1 |
||||
|
||||
IRs: |
||||
TMP_11(uint256) = 10 (c)** 36 |
||||
TMP_12(uint256) = TMP_11 (c)/ 1 |
||||
ratio(uint256) := TMP_12(uint256)"]; |
||||
14->12; |
||||
15[label="Node Type: EXPRESSION 15 |
||||
|
||||
EXPRESSION: |
||||
ratio = unsafe_div()(p * 10 ** 18,old_p_o) |
||||
|
||||
IRs: |
||||
TMP_13(uint256) = 10 (c)** 18 |
||||
TMP_14(uint256) = p (c)* TMP_13 |
||||
TMP_15(None) = SOLIDITY_CALL unsafe_div()(TMP_14,old_p_o) |
||||
ratio(uint256) := TMP_15(None)"]; |
||||
15->16; |
||||
16[label="Node Type: IF 16 |
||||
|
||||
EXPRESSION: |
||||
ratio < 10 ** 36 / 1 |
||||
|
||||
IRs: |
||||
TMP_16(uint256) = 10 (c)** 36 |
||||
TMP_17(uint256) = TMP_16 (c)/ 1 |
||||
TMP_18(bool) = ratio < TMP_17 |
||||
CONDITION TMP_18"]; |
||||
16->18[label="True"]; |
||||
16->17[label="False"]; |
||||
17[label="Node Type: END_IF 17 |
||||
"]; |
||||
17->9; |
||||
18[label="Node Type: EXPRESSION 18 |
||||
|
||||
EXPRESSION: |
||||
p_new = unsafe_div()(old_p_o * 10 ** 18,1) |
||||
|
||||
IRs: |
||||
TMP_19(uint256) = 10 (c)** 18 |
||||
TMP_20(uint256) = old_p_o (c)* TMP_19 |
||||
TMP_21(None) = SOLIDITY_CALL unsafe_div()(TMP_20,1) |
||||
p_new(uint256) := TMP_21(None)"]; |
||||
18->19; |
||||
19[label="Node Type: EXPRESSION 19 |
||||
|
||||
EXPRESSION: |
||||
ratio = 10 ** 36 / 1 |
||||
|
||||
IRs: |
||||
TMP_22(uint256) = 10 (c)** 36 |
||||
TMP_23(uint256) = TMP_22 (c)/ 1 |
||||
ratio(uint256) := TMP_23(uint256)"]; |
||||
19->17; |
||||
20[label="Node Type: EXPRESSION 20 |
||||
|
||||
EXPRESSION: |
||||
ratio = 1 |
||||
|
||||
IRs: |
||||
ratio(uint256) := 1(uint256)"]; |
||||
20->5; |
||||
} |
@ -0,0 +1,50 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
a = 0 |
||||
|
||||
IRs: |
||||
a(int128) := 0(uint256)"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
b = 0 |
||||
|
||||
IRs: |
||||
b(int128) := 0(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: IF 3 |
||||
|
||||
EXPRESSION: |
||||
x & 1 | 2 |
||||
|
||||
IRs: |
||||
TMP_0(uint256) = 1 | 2 |
||||
TMP_1(in.Roles) = x & TMP_0 |
||||
CONDITION TMP_1"]; |
||||
3->5[label="True"]; |
||||
3->4[label="False"]; |
||||
4[label="Node Type: END_IF 4 |
||||
"]; |
||||
4->6; |
||||
5[label="Node Type: RETURN 5 |
||||
|
||||
EXPRESSION: |
||||
True |
||||
|
||||
IRs: |
||||
RETURN True"]; |
||||
5->4; |
||||
6[label="Node Type: RETURN 6 |
||||
|
||||
EXPRESSION: |
||||
False |
||||
|
||||
IRs: |
||||
RETURN False"]; |
||||
} |
@ -0,0 +1,51 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
a = 0 |
||||
|
||||
IRs: |
||||
a(int128) := 0(uint256)"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
b = 0 |
||||
|
||||
IRs: |
||||
b(int128) := 0(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: IF 3 |
||||
|
||||
EXPRESSION: |
||||
x == b || x == a |
||||
|
||||
IRs: |
||||
TMP_2(bool) = x == b |
||||
TMP_3(bool) = x == a |
||||
TMP_4(bool) = TMP_2 || TMP_3 |
||||
CONDITION TMP_4"]; |
||||
3->5[label="True"]; |
||||
3->4[label="False"]; |
||||
4[label="Node Type: END_IF 4 |
||||
"]; |
||||
4->6; |
||||
5[label="Node Type: RETURN 5 |
||||
|
||||
EXPRESSION: |
||||
True |
||||
|
||||
IRs: |
||||
RETURN True"]; |
||||
5->4; |
||||
6[label="Node Type: RETURN 6 |
||||
|
||||
EXPRESSION: |
||||
False |
||||
|
||||
IRs: |
||||
RETURN False"]; |
||||
} |
@ -0,0 +1,22 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: EXPRESSION 1 |
||||
|
||||
EXPRESSION: |
||||
BORROWED_TOKEN = ERC20(x) |
||||
|
||||
IRs: |
||||
TMP_0 = CONVERT x to ERC20 |
||||
BORROWED_TOKEN(ERC20) := TMP_0(ERC20)"]; |
||||
1->2; |
||||
2[label="Node Type: EXPRESSION 2 |
||||
|
||||
EXPRESSION: |
||||
COLLATERAL_TOKEN = ERC20(y) |
||||
|
||||
IRs: |
||||
TMP_1 = CONVERT y to ERC20 |
||||
COLLATERAL_TOKEN(ERC20) := TMP_1(ERC20)"]; |
||||
} |
@ -0,0 +1,16 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: RETURN 1 |
||||
|
||||
EXPRESSION: |
||||
(address(BORROWED_TOKEN),address(COLLATERAL_TOKEN))[i] |
||||
|
||||
IRs: |
||||
TMP_2 = CONVERT BORROWED_TOKEN to address |
||||
TMP_3 = CONVERT COLLATERAL_TOKEN to address |
||||
TMP_4(address[2]) = ['TMP_2(address)', 'TMP_3(address)'] |
||||
REF_0(address) -> TMP_4[i] |
||||
RETURN REF_0"]; |
||||
} |
@ -0,0 +1,9 @@ |
||||
digraph{ |
||||
0[label="Node Type: OTHER_ENTRYPOINT 0 |
||||
|
||||
EXPRESSION: |
||||
MAX_BANDS = 10 |
||||
|
||||
IRs: |
||||
MAX_BANDS(uint256) := 10(uint256)"]; |
||||
} |
@ -0,0 +1,12 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: RETURN 1 |
||||
|
||||
EXPRESSION: |
||||
1 |
||||
|
||||
IRs: |
||||
RETURN 1"]; |
||||
} |
@ -0,0 +1,4 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
} |
@ -0,0 +1,17 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: RETURN 1 |
||||
|
||||
EXPRESSION: |
||||
x != super.fb() && x != super.fa() |
||||
|
||||
IRs: |
||||
TMP_0(uint256) = INTERNAL_CALL, precedence.fb()() |
||||
TMP_1(bool) = x != TMP_0 |
||||
TMP_2(uint256) = INTERNAL_CALL, precedence.fa()() |
||||
TMP_3(bool) = x != TMP_2 |
||||
TMP_4(bool) = TMP_1 && TMP_3 |
||||
RETURN TMP_4"]; |
||||
} |
@ -0,0 +1,13 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: RETURN 1 |
||||
|
||||
EXPRESSION: |
||||
X(1) |
||||
|
||||
IRs: |
||||
TMP_0(struct.X) = new X(1) |
||||
RETURN TMP_0"]; |
||||
} |
@ -0,0 +1,9 @@ |
||||
digraph{ |
||||
0[label="Node Type: OTHER_ENTRYPOINT 0 |
||||
|
||||
EXPRESSION: |
||||
MAX_TICKS_UINT = 50 |
||||
|
||||
IRs: |
||||
MAX_TICKS_UINT(uint256) := 50(uint256)"]; |
||||
} |
@ -0,0 +1,57 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: NEW VARIABLE 1 |
||||
|
||||
EXPRESSION: |
||||
a = 0 |
||||
|
||||
IRs: |
||||
a(int128) := 0(uint256)"]; |
||||
1->2; |
||||
2[label="Node Type: NEW VARIABLE 2 |
||||
|
||||
EXPRESSION: |
||||
b = 0 |
||||
|
||||
IRs: |
||||
b(int128) := 0(uint256)"]; |
||||
2->3; |
||||
3[label="Node Type: EXPRESSION 3 |
||||
|
||||
EXPRESSION: |
||||
(a,b) = super.foo() |
||||
|
||||
IRs: |
||||
TUPLE_0(int128,int128) = INTERNAL_CALL, tuple.foo()() |
||||
a(int128)= UNPACK TUPLE_0 index: 0 |
||||
b(int128)= UNPACK TUPLE_0 index: 1 "]; |
||||
3->4; |
||||
4[label="Node Type: NEW VARIABLE 4 |
||||
|
||||
EXPRESSION: |
||||
x = 0x0000000000000000000000000000000000000000 |
||||
|
||||
IRs: |
||||
x(address) := 0(address)"]; |
||||
4->5; |
||||
5[label="Node Type: NEW VARIABLE 5 |
||||
|
||||
EXPRESSION: |
||||
c = 0 |
||||
|
||||
IRs: |
||||
c(uint256) := 0(uint256)"]; |
||||
5->6; |
||||
6[label="Node Type: EXPRESSION 6 |
||||
|
||||
EXPRESSION: |
||||
(a,c) = Test(x).foo() |
||||
|
||||
IRs: |
||||
TMP_0 = CONVERT x to Test |
||||
TUPLE_1(int128,uint256) = HIGH_LEVEL_CALL, dest:TMP_0(Test), function:foo, arguments:[] |
||||
a(int128)= UNPACK TUPLE_1 index: 0 |
||||
c(uint256)= UNPACK TUPLE_1 index: 1 "]; |
||||
} |
@ -0,0 +1,12 @@ |
||||
digraph{ |
||||
0[label="Node Type: ENTRY_POINT 0 |
||||
"]; |
||||
0->1; |
||||
1[label="Node Type: RETURN 1 |
||||
|
||||
EXPRESSION: |
||||
(2,3) |
||||
|
||||
IRs: |
||||
RETURN 2,3"]; |
||||
} |
@ -0,0 +1,26 @@ |
||||
from typing import Dict |
||||
from pathlib import Path |
||||
from slither import Slither |
||||
|
||||
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" |
||||
|
||||
ALL_TESTS = list(Path(TEST_DATA_DIR).glob("*.vy")) |
||||
|
||||
|
||||
def pytest_generate_tests(metafunc): |
||||
test_cases = [] |
||||
for test_file in ALL_TESTS: |
||||
sl = Slither(test_file.as_posix()) |
||||
for contract in sl.contracts: |
||||
if contract.is_interface: |
||||
continue |
||||
for func_or_modifier in contract.functions: |
||||
test_cases.append( |
||||
(func_or_modifier.canonical_name, func_or_modifier.slithir_cfg_to_dot_str()) |
||||
) |
||||
|
||||
metafunc.parametrize("test_case", test_cases, ids=lambda x: x[0]) |
||||
|
||||
|
||||
def test_vyper_cfgir(test_case, snapshot): |
||||
assert snapshot() == test_case[1] |
@ -0,0 +1,22 @@ |
||||
|
||||
|
||||
interface ERC20: |
||||
|
||||
def totalSupply() -> uint256: view |
||||
|
||||
|
||||
|
||||
def balanceOf(_owner: address) -> uint256: view |
||||
|
||||
|
||||
|
||||
def allowance(_owner: address, _spender: address) -> uint256: view |
||||
|
||||
|
||||
def transfer(_to: address, _value: uint256) -> bool: nonpayable |
||||
|
||||
|
||||
def transferFrom(_from: address, _to: address, _value: uint256) -> bool: nonpayable |
||||
|
||||
|
||||
def approve(_spender: address, _value: uint256) -> bool: nonpayable |
@ -0,0 +1,31 @@ |
||||
|
||||
@payable |
||||
@external |
||||
def test_builtins(): |
||||
a: address = block.coinbase |
||||
|
||||
b: uint256 = block.difficulty |
||||
|
||||
c: uint256 = block.prevrandao |
||||
|
||||
d: uint256 = block.number |
||||
|
||||
e: bytes32 = block.prevhash |
||||
|
||||
f: uint256 = block.timestamp |
||||
|
||||
h: uint256 = chain.id |
||||
|
||||
i: Bytes[32] = slice(msg.data, 0, 32) |
||||
|
||||
j: uint256 = msg.gas |
||||
|
||||
k: address = msg.sender |
||||
|
||||
l: uint256 = msg.value |
||||
|
||||
m: address = tx.origin |
||||
|
||||
n: uint256 = tx.gasprice |
||||
|
||||
x: uint256 = self.balance |
@ -0,0 +1,4 @@ |
||||
|
||||
@external |
||||
def test(): |
||||
x: bytes32 = convert(chain.id, bytes32) |
@ -0,0 +1,32 @@ |
||||
|
||||
|
||||
x: constant(uint256) = 1 + 1 |
||||
MAX_QUEUE: constant(uint256) = 1 + x |
||||
|
||||
interface IStrategy: |
||||
def asset() -> address: view |
||||
def balanceOf(owner: address) -> uint256: view |
||||
def maxDeposit(receiver: address) -> uint256: view |
||||
def maxWithdraw(owner: address) -> uint256: view |
||||
def withdraw(amount: uint256, receiver: address, owner: address) -> uint256: nonpayable |
||||
def redeem(shares: uint256, receiver: address, owner: address) -> uint256: nonpayable |
||||
def deposit(assets: uint256, receiver: address) -> uint256: nonpayable |
||||
def totalAssets() -> (uint256): view |
||||
def convertToAssets(shares: uint256) -> uint256: view |
||||
def convertToShares(assets: uint256) -> uint256: view |
||||
def previewWithdraw(assets: uint256) -> uint256: view |
||||
|
||||
|
||||
|
||||
|
||||
struct X: |
||||
y: int8 |
||||
|
||||
strategies: public(DynArray[address, MAX_QUEUE]) |
||||
|
||||
@external |
||||
def for_loop(): |
||||
|
||||
for strategy in self.strategies: |
||||
z: address = IStrategy(strategy).asset() |
||||
|
@ -0,0 +1,26 @@ |
||||
|
||||
|
||||
x: constant(uint256) = 1 + 1 |
||||
MAX_QUEUE: constant(uint256) = 1 + x |
||||
|
||||
interface IStrategy: |
||||
def asset() -> address: view |
||||
def balanceOf(owner: address) -> uint256: view |
||||
def maxDeposit(receiver: address) -> uint256: view |
||||
def maxWithdraw(owner: address) -> uint256: view |
||||
def withdraw(amount: uint256, receiver: address, owner: address) -> uint256: nonpayable |
||||
def redeem(shares: uint256, receiver: address, owner: address) -> uint256: nonpayable |
||||
def deposit(assets: uint256, receiver: address) -> uint256: nonpayable |
||||
def totalAssets() -> (uint256): view |
||||
def convertToAssets(shares: uint256) -> uint256: view |
||||
def convertToShares(assets: uint256) -> uint256: view |
||||
def previewWithdraw(assets: uint256) -> uint256: view |
||||
|
||||
@external |
||||
def for_loop(strategies: DynArray[address, MAX_QUEUE]): |
||||
_strategies: DynArray[address, MAX_QUEUE] = strategies |
||||
|
||||
for i in range(10): |
||||
|
||||
max_withdraw: uint256 = IStrategy(_strategies[i]).maxWithdraw(self) |
||||
|
@ -0,0 +1,6 @@ |
||||
|
||||
@external |
||||
def get_D(_xp: uint256[3], _amp: uint256): |
||||
S: uint256 = 0 |
||||
for x in _xp: |
||||
S += x |
@ -0,0 +1,25 @@ |
||||
@external |
||||
@view |
||||
def limit_p_o(p: uint256): |
||||
p_new: uint256 = p |
||||
dt: uint256 = 1 |
||||
ratio: uint256 = 0 |
||||
|
||||
if dt > 0: |
||||
old_p_o: uint256 = 1 |
||||
old_ratio: uint256 = 2 |
||||
# ratio = p_o_min / p_o_max |
||||
if p > old_p_o: |
||||
ratio = unsafe_div(old_p_o * 10**18, p) |
||||
if ratio < 10**36 / 1: |
||||
p_new = unsafe_div(old_p_o * 1, 10**18) |
||||
ratio = 10**36 / 1 |
||||
else: |
||||
ratio = unsafe_div(p * 10**18, old_p_o) |
||||
if ratio < 10**36 / 1: |
||||
p_new = unsafe_div(old_p_o * 10**18, 1) |
||||
ratio = 10**36 / 1 |
||||
|
||||
# ratio is guaranteed to be less than 1e18 |
||||
# Also guaranteed to be limited, therefore can have all ops unsafe |
||||
ratio = 1 |
@ -0,0 +1,23 @@ |
||||
enum Roles: |
||||
A |
||||
B |
||||
|
||||
roles: public(HashMap[address, Roles]) |
||||
|
||||
@external |
||||
def bar(x: Roles) -> bool: |
||||
a: int128 = 0 |
||||
b: int128 = 0 |
||||
|
||||
if x in self.roles[self]: |
||||
return True |
||||
return False |
||||
|
||||
@external |
||||
def foo(x: int128) -> bool: |
||||
a: int128 = 0 |
||||
b: int128 = 0 |
||||
|
||||
if x in [a, b]: |
||||
return True |
||||
return False |
@ -0,0 +1,17 @@ |
||||
interface ERC20: |
||||
def transfer(_to: address, _value: uint256) -> bool: nonpayable |
||||
def transferFrom(_from: address, _to: address, _value: uint256) -> bool: nonpayable |
||||
def approve(_spender: address, _value: uint256) -> bool: nonpayable |
||||
|
||||
BORROWED_TOKEN: immutable(ERC20) # x |
||||
COLLATERAL_TOKEN: immutable(ERC20) # x |
||||
|
||||
@external |
||||
def __init__(x: address, y: address): |
||||
BORROWED_TOKEN = ERC20(x) |
||||
COLLATERAL_TOKEN = ERC20(y) |
||||
|
||||
@external |
||||
@pure |
||||
def coins(i: uint256) -> address: |
||||
return [BORROWED_TOKEN.address, COLLATERAL_TOKEN.address][i] |
@ -0,0 +1,20 @@ |
||||
name: public(String[64]) |
||||
symbol: public(String[32]) |
||||
decimals: public(uint256) |
||||
totalSupply: public(uint256) |
||||
|
||||
|
||||
|
||||
|
||||
balances: HashMap[address, uint256] |
||||
allowances: HashMap[address, HashMap[address, uint256]] |
||||
|
||||
|
||||
MAX_BANDS: constant(uint256) = 10 |
||||
|
||||
x: public(uint256[3][4]) |
||||
y: public(uint256[2]) |
||||
|
||||
struct Loan: |
||||
liquidation_range: DynArray[uint256, MAX_BANDS] |
||||
deposit_amounts: DynArray[uint256, MAX_BANDS] |
@ -0,0 +1,13 @@ |
||||
@internal |
||||
def fa() -> uint256: |
||||
return 1 |
||||
|
||||
@internal |
||||
def fb() -> uint256: |
||||
raise |
||||
|
||||
@external |
||||
def foo(x: uint256) -> bool: |
||||
return x not in [self.fa(), self.fb()] |
||||
|
||||
|
@ -0,0 +1,7 @@ |
||||
struct X: |
||||
y: int8 |
||||
|
||||
|
||||
@external |
||||
def test() -> X: |
||||
return X({y: 1}) |
@ -0,0 +1,15 @@ |
||||
interface LMGauge: |
||||
def callback_collateral_shares(n: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT]): nonpayable |
||||
def callback_user_shares(user: address, n: int256, user_shares: DynArray[uint256, MAX_TICKS_UINT]): nonpayable |
||||
|
||||
|
||||
MAX_TICKS_UINT: constant(uint256) = 50 |
||||
|
||||
|
||||
struct Loan: |
||||
liquidation_range: LMGauge |
||||
|
||||
x: public(Loan) |
||||
|
||||
|
||||
# TODO Will this overly complicate analyzing AST https://github.com/vyperlang/vyper/pull/3411 |
@ -0,0 +1,19 @@ |
||||
|
||||
|
||||
interface Test: |
||||
def foo() -> (int128, uint256): nonpayable |
||||
|
||||
@internal |
||||
def foo() -> (int128, int128): |
||||
return 2, 3 |
||||
|
||||
@external |
||||
def bar(): |
||||
a: int128 = 0 |
||||
b: int128 = 0 |
||||
(a, b) = self.foo() |
||||
|
||||
x: address = 0x0000000000000000000000000000000000000000 |
||||
c: uint256 = 0 |
||||
a, c = Test(x).foo() |
||||
|
Loading…
Reference in new issue