Skip to content

Commit d00c39b

Browse files
committed
Organise files and folders
1 parent 60ab2b0 commit d00c39b

File tree

16 files changed

+91
-13
lines changed

16 files changed

+91
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
*.out
12
*.swp
23
mev-kompiled
34
.kprove-*
45
__pycache__
56
*~
7+
*.pyc
8+

bound_maker.k renamed to boundmaker.k

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module BOUND
1+
module BOUNDMAKER
22
imports MEV
33
rule <k>
44
0 in 0 gets 0;
@@ -23,4 +23,4 @@ module BOUND
2323
// orBool (notBool ((0 , SAI) in keys(?P)))
2424
// (notBool(?X ==K .K) andBool notBool(?Y ==K .K)) orBool (?X ==K .K andBool ?Y ==K .K andBool ({?S[0 in SAI]}:>Int <=Int 0 ))
2525
// ( notBool(?X ==K DONE)) orBool
26-
endmodule
26+
endmodule

calc_mev.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import sys
2+
from subprocess import Popen, PIPE
3+
import re
4+
5+
BLANK_SPEC = """module CALCBOUND
6+
imports MEV
7+
rule <k>
8+
%s
9+
=> ?X
10+
</k>
11+
<S> ( (Uniswap in 0) |-> 0 (Uniswap in SAI) |-> 0 ) =>?Y0:Map </S>
12+
<M> .Set => ?Y1:Set </M>
13+
<B> .List => ?Y2:List </B>
14+
<P> .Map => ?Y3:Map </P>
15+
<V> .Map => ?Y4:Map </V>
16+
ensures ( ({?Y0[0 in SAI]}:>Int <=Int 0) andBool ?X ==K DONE) orBool (?X ==K FAIL)
17+
endmodule
18+
"""
19+
20+
def find_mev_cdp(program, outfile):
21+
global BLANK_SPEC
22+
output = ""
23+
spec = BLANK_SPEC % (program)
24+
open("output/calcbound.k", "w").write(spec)
25+
print("Starting proof...")
26+
sys.stdout.flush()
27+
pipe = Popen("kprove -v --debug --default-claim-type all-path --z3-impl-timeout 500 output/calcbound.k", shell=True, stdout=PIPE, stderr=PIPE)
28+
output = pipe.stdout.read() + pipe.stderr.read()
29+
output = str(output, "utf-8")
30+
print(output)
31+
if "#True" not in output:
32+
print("MEV FOUND!")
33+
print("Writing MEV configuration to", outfile, "...")
34+
open(outfile, "w").write(output)
35+
return
36+
37+
def main():
38+
PROGRAM = open(sys.argv[1]).read()
39+
find_mev_cdp(PROGRAM, "output/calcmev.out")
40+
41+
if __name__ == '__main__':
42+
main()

output/calcbound.k

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module CALCBOUND
2+
imports MEV
3+
rule <k>
4+
0 in 0 gets 0;
5+
0 in SAI gets 0;
6+
1 in 0 gets 100000000;
7+
Uniswap in 0 gets 5;
8+
Uniswap in SAI gets 500;
9+
GetPrice 0 SAI;
10+
1 opens vault 2;
11+
1 locks 6 collateral to vault 2;
12+
1 draws 6 debt from vault 2;
13+
1 in 0 swaps 40 input for SAI fee 5;
14+
0 bites vault 2;
15+
16+
=> ?X
17+
</k>
18+
<S> ( (Uniswap in 0) |-> 0 (Uniswap in SAI) |-> 0 ) =>?Y0:Map </S>
19+
<M> .Set => ?Y1:Set </M>
20+
<B> .List => ?Y2:List </B>
21+
<P> .Map => ?Y3:Map </P>
22+
<V> .Map => ?Y4:Map </V>
23+
ensures ( ({?Y0[0 in SAI]}:>Int <=Int 0) andBool ?X ==K DONE) orBool (?X ==K FAIL)
24+
endmodule

test_maker

Lines changed: 0 additions & 11 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)