forked from runtimeverification/verified-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyRewardPool.modified.inlined.evm
671 lines (623 loc) · 12.3 KB
/
KeyRewardPool.modified.inlined.evm
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
// return address
[000] 60 PUSH1 96:0x60
[002] 60 PUSH1 64:0x40
[004] 52 MSTORE
// check calldatasize >= 4
[005] 60 PUSH1 4:0x04
[007] 36 CALLDATASIZE
[008] 10 LT
[009] 61 PUSH2 109:0x006d
[012] 57 JUMPI
// extract func sig
[013] 60 PUSH1 0:0x00
[015] 35 CALLDATALOAD
[016] 7c PUSH29 26959946667150639794667015087019630673637144422540572481103610249216:0x0100000000000000000000000000000000000000000000000000000000
[046] 90 SWAP1
[047] 04 DIV
[048] 63 PUSH4 4294967295:0xffffffff
[053] 16 AND
// jump table
[054] 80 DUP1
[055] 63 PUSH4 239791423:0x0e4aed3f
[060] 14 EQ
[061] 61 PUSH2 114:0x0072
[064] 57 JUMPI
[065] 80 DUP1
[066] 63 PUSH4 1085936235:0x40ba126b
[071] 14 EQ
[072] 61 PUSH2 155:0x009b
[075] 57 JUMPI
[076] 80 DUP1
[077] 63 PUSH4 2021560631:0x787e9137
[082] 14 EQ
[083] 61 PUSH2 219:0x00db
[086] 57 JUMPI
[087] 80 DUP1
[088] 63 PUSH4 3063871656:0xb69ef8a8
[093] 14 EQ
[094] 61 PUSH2 260:0x0104
[097] 57 JUMPI
[098] 80 DUP1
[099] 63 PUSH4 3107859675:0xb93e2cdb // collectToken
[104] 14 EQ
[105] 61 PUSH2 301:0x012d
[108] 57 JUMPI
[109] 5b JUMPDEST
[110] 60 PUSH1 0:0x00
[112] 80 DUP1
[113] fd REVERT
[114] 5b JUMPDEST
[115] 34 CALLVALUE
[116] 15 ISZERO
[117] 61 PUSH2 125:0x007d
[120] 57 JUMPI
[121] 60 PUSH1 0:0x00
[123] 80 DUP1
[124] fd REVERT
[125] 5b JUMPDEST
[126] 61 PUSH2 133:0x0085
[129] 61 PUSH2 369:0x0171
[132] 56 JUMP
[133] 5b JUMPDEST
[134] 60 PUSH1 64:0x40
[136] 51 MLOAD
[137] 80 DUP1
[138] 82 DUP3
[139] 81 DUP2
[140] 52 MSTORE
[141] 60 PUSH1 32:0x20
[143] 01 ADD
[144] 91 SWAP2
[145] 50 POP
[146] 50 POP
[147] 60 PUSH1 64:0x40
[149] 51 MLOAD
[150] 80 DUP1
[151] 91 SWAP2
[152] 03 SUB
[153] 90 SWAP1
[154] f3 RETURN
[155] 5b JUMPDEST
[156] 34 CALLVALUE
[157] 15 ISZERO
[158] 61 PUSH2 166:0x00a6
[161] 57 JUMPI
[162] 60 PUSH1 0:0x00
[164] 80 DUP1
[165] fd REVERT
[166] 5b JUMPDEST
[167] 61 PUSH2 197:0x00c5
[170] 60 PUSH1 4:0x04
[172] 80 DUP1
[173] 80 DUP1
[174] 35 CALLDATALOAD
[175] 90 SWAP1
[176] 60 PUSH1 32:0x20
[178] 01 ADD
[179] 90 SWAP1
[180] 91 SWAP2
[181] 90 SWAP1
[182] 80 DUP1
[183] 35 CALLDATALOAD
[184] 90 SWAP1
[185] 60 PUSH1 32:0x20
[187] 01 ADD
[188] 90 SWAP1
[189] 91 SWAP2
[190] 90 SWAP1
[191] 50 POP
[192] 50 POP
[193] 61 PUSH2 374:0x0176
[196] 56 JUMP
[197] 5b JUMPDEST
[198] 60 PUSH1 64:0x40
[200] 51 MLOAD
[201] 80 DUP1
[202] 82 DUP3
[203] 81 DUP2
[204] 52 MSTORE
[205] 60 PUSH1 32:0x20
[207] 01 ADD
[208] 91 SWAP2
[209] 50 POP
[210] 50 POP
[211] 60 PUSH1 64:0x40
[213] 51 MLOAD
[214] 80 DUP1
[215] 91 SWAP2
[216] 03 SUB
[217] 90 SWAP1
[218] f3 RETURN
[219] 5b JUMPDEST
[220] 34 CALLVALUE
[221] 15 ISZERO
[222] 61 PUSH2 230:0x00e6
[225] 57 JUMPI
[226] 60 PUSH1 0:0x00
[228] 80 DUP1
[229] fd REVERT
[230] 5b JUMPDEST
[231] 61 PUSH2 238:0x00ee
[234] 61 PUSH2 424:0x01a8
[237] 56 JUMP
[238] 5b JUMPDEST
[239] 60 PUSH1 64:0x40
[241] 51 MLOAD
[242] 80 DUP1
[243] 82 DUP3
[244] 81 DUP2
[245] 52 MSTORE
[246] 60 PUSH1 32:0x20
[248] 01 ADD
[249] 91 SWAP2
[250] 50 POP
[251] 50 POP
[252] 60 PUSH1 64:0x40
[254] 51 MLOAD
[255] 80 DUP1
[256] 91 SWAP2
[257] 03 SUB
[258] 90 SWAP1
[259] f3 RETURN
[260] 5b JUMPDEST
[261] 34 CALLVALUE
[262] 15 ISZERO
[263] 61 PUSH2 271:0x010f
[266] 57 JUMPI
[267] 60 PUSH1 0:0x00
[269] 80 DUP1
[270] fd REVERT
[271] 5b JUMPDEST
[272] 61 PUSH2 279:0x0117
[275] 61 PUSH2 430:0x01ae
[278] 56 JUMP
[279] 5b JUMPDEST
[280] 60 PUSH1 64:0x40
[282] 51 MLOAD
[283] 80 DUP1
[284] 82 DUP3
[285] 81 DUP2
[286] 52 MSTORE
[287] 60 PUSH1 32:0x20
[289] 01 ADD
[290] 91 SWAP2
[291] 50 POP
[292] 50 POP
[293] 60 PUSH1 64:0x40
[295] 51 MLOAD
[296] 80 DUP1
[297] 91 SWAP2
[298] 03 SUB
[299] 90 SWAP1
[300] f3 RETURN
// collectToken parameter
[301] 5b JUMPDEST
[302] 34 CALLVALUE
[303] 15 ISZERO
[304] 61 PUSH2 312:0x0138
[307] 57 JUMPI
[308] 60 PUSH1 0:0x00
[310] 80 DUP1
[311] fd REVERT
[312] 5b JUMPDEST
[313] 61 PUSH2 343:0x0157
[316] 60 PUSH1 4:0x04
[318] 80 DUP1
[319] 80 DUP1
[320] 35 CALLDATALOAD
[321] 90 SWAP1
[322] 60 PUSH1 32:0x20
[324] 01 ADD
[325] 90 SWAP1
[326] 91 SWAP2
[327] 90 SWAP1
[328] 80 DUP1
[329] 35 CALLDATALOAD
[330] 90 SWAP1
[331] 60 PUSH1 32:0x20
[333] 01 ADD
[334] 90 SWAP1
[335] 91 SWAP2
[336] 90 SWAP1
[337] 50 POP
[338] 50 POP
[339] 61 PUSH2 436:0x01b4
[342] 56 JUMP
// collectToken return
[343] 5b JUMPDEST
[344] 60 PUSH1 64:0x40
[346] 51 MLOAD
[347] 80 DUP1
[348] 82 DUP3
[349] 15 ISZERO
[350] 15 ISZERO
[351] 15 ISZERO
[352] 15 ISZERO
[353] 81 DUP2
[354] 52 MSTORE
[355] 60 PUSH1 32:0x20
[357] 01 ADD
[358] 91 SWAP2
[359] 50 POP
[360] 50 POP
[361] 60 PUSH1 64:0x40
[363] 51 MLOAD
[364] 80 DUP1
[365] 91 SWAP2
[366] 03 SUB
[367] 90 SWAP1
[368] f3 RETURN
[369] 5b JUMPDEST
[370] 60 PUSH1 10:0x0a
[372] 81 DUP2
[373] 56 JUMP
// yearFor
[374] 5b JUMPDEST
[375] 60 PUSH1 0:0x00
[377] 81 DUP2
[378] 83 DUP4
[379] 10 LT // nowTime< rewardStartTime // step 2514
[380] 61 PUSH2 413:0x019d
[383] 57 JUMPI
// sub(nowTime, rewardStartTime) / (365 days);
[384] 63 PUSH4 31536000:0x01e13380
[389] 61 PUSH2 398:0x018e
[392] 84 DUP5
[393] 84 DUP5
[394] 61 PUSH2 700:0x02bc
[397] 56 JUMP // call sub
[398] 5b JUMPDEST
[399] 81 DUP2
[400] 15 ISZERO
[401] 15 ISZERO
[402] 61 PUSH2 407:0x0197
[405] 57 JUMPI
[406] fe INVALID
[407] 5b JUMPDEST
[408] 04 DIV
[409] 61 PUSH2 416:0x01a0
[412] 56 JUMP
// 0
[413] 5b JUMPDEST
[414] 60 PUSH1 0:0x00
// yearFor return
[416] 5b JUMPDEST
[417] 90 SWAP1
[418] 50 POP
[419] 92 SWAP3
[420] 91 SWAP2
[421] 50 POP
[422] 50 POP
[423] 56 JUMP
[424] 5b JUMPDEST
[425] 60 PUSH1 0:0x00
[427] 54 SLOAD
[428] 81 DUP2
[429] 56 JUMP
[430] 5b JUMPDEST
[431] 60 PUSH1 1:0x01
[433] 54 SLOAD
[434] 81 DUP2
[435] 56 JUMP
// collectToken body // step 1349
[436] 5b JUMPDEST
[437] 60 PUSH1 0:0x00
[439] 80 DUP1
[440] 60 PUSH1 0:0x00
[442] 80 DUP1
[443] 60 PUSH1 0:0x00
[445] 80 DUP1
[446] 60 PUSH1 0:0x00
[448] 80 DUP1
// require(nowTime > rewardStartTime);
[449] 88 DUP9
[450] 8a DUP11
[451] 11 GT
[452] 15 ISZERO
[453] 15 ISZERO
[454] 61 PUSH2 462:0x01ce
[457] 57 JUMPI
[458] 60 PUSH1 0:0x00
[460] 80 DUP1
[461] fd REVERT
// step 1661
// uint total = add(collectedTokens, balance);
[462] 5b JUMPDEST
[463] 61 PUSH2 476:0x01dc
[466] 60 PUSH1 0:0x00
[468] 54 SLOAD
[469] 60 PUSH1 1:0x01
[471] 54 SLOAD
[472] 61 PUSH2 725:0x02d5
[475] 56 JUMP
[476] 5b JUMPDEST
[477] 96 SWAP7
[478] 50 POP
// uint remainingTokens = total;
[479] 86 DUP7
[480] 95 SWAP6
[481] 50 POP
// uint yearCount = yearFor(nowTime, rewardStartTime);
[482] 61 PUSH2 491:0x01eb
[485] 8a DUP11
[486] 8a DUP11
[487] 61 PUSH2 374:0x0176
[490] 56 JUMP
[491] 5b JUMPDEST
[492] 94 SWAP5
[493] 50 POP
// step 3499
// uint i = 0
[494] 60 PUSH1 0:0x00
[496] 93 SWAP4
[497] 50 POP
// step 3549 : invariant rule
// loop
// if i < yearCount; _; else break
[498] 5b JUMPDEST
[499] 84 DUP5
[500] 84 DUP5
[501] 10 LT
[502] 15 ISZERO
[503] 61 PUSH2 545:0x0221
[506] 57 JUMPI
// remainingTokens = div(mul(remainingTokens, 100 - yearlyRewardPercentage), 100);
[507] 61 PUSH2 530:0x0212 // ?
[510] 61 PUSH2 523:0x020b // ?
[513] 87 DUP8 // remainingTokens
[514] 60 PUSH1 10:0x0a // yearlyRewardPercentage
[516] 60 PUSH1 100:0x64
[518] 03 SUB // 100 - yearlyRewardPercentage
[519] 61 PUSH2 750:0x02ee
[522] 56 JUMP // call mul
[523] 5b JUMPDEST
[524] 60 PUSH1 100:0x64
[526] 61 PUSH2 796:0x031c
[529] 56 JUMP // call div
[530] 5b JUMPDEST
[531] 95 SWAP6 // remainingTokens = ...
[532] 50 POP
[533] 83 DUP4
[534] 80 DUP1
[535] 60 PUSH1 1:0x01
[537] 01 ADD // i + 1
[538] 94 SWAP5
[539] 50 POP
[540] 50 POP
[541] 61 PUSH2 498:0x01f2
[544] 56 JUMP
// step 3550
// loop end
// uint totalRewardThisYear = div(mul(remainingTokens, yearlyRewardPercentage), 100);
[545] 5b JUMPDEST
[546] 61 PUSH2 566:0x0236
[549] 61 PUSH2 559:0x022f
[552] 87 DUP8 // remainingTokens
[553] 60 PUSH1 10:0x0a
[555] 61 PUSH2 750:0x02ee
[558] 56 JUMP // call mul
[559] 5b JUMPDEST
[560] 60 PUSH1 100:0x64
[562] 61 PUSH2 796:0x031c
[565] 56 JUMP // call div
// uint canExtractThisYear = div(mul(totalRewardThisYear, (nowTime - rewardStartTime) % 365 days), 365 days);
[566] 5b JUMPDEST
[567] 92 SWAP3
[568] 50 POP
[569] 61 PUSH2 608:0x0260
[572] 61 PUSH2 598:0x0256
[575] 84 DUP5
[576] 63 PUSH4 31536000:0x01e13380 // 365 days in seconds
[581] 8c DUP13
[582] 8e DUP15
[583] 03 SUB // nowTime - rewardStartTime
[584] 81 DUP2
[585] 15 ISZERO
[586] 15 ISZERO
[587] 61 PUSH2 592:0x0250
[590] 57 JUMPI
[591] fe INVALID
[592] 5b JUMPDEST
[593] 06 MOD // ... % 365 days
[594] 61 PUSH2 750:0x02ee
[597] 56 JUMP // call mul // mul(totalRewardThisYear, (nowTime - rewardStartTime) % 365 days)
[598] 5b JUMPDEST
[599] 63 PUSH4 31536000:0x01e13380
[604] 61 PUSH2 796:0x031c
[607] 56 JUMP // call div // div(mul(totalRewardThisYear, (nowTime - rewardStartTime) % 365 days), 365 days)
// uint canExtract = canExtractThisYear + total - remainingTokens;
[608] 5b JUMPDEST
[609] 91 SWAP2
[610] 50 POP
[611] 85 DUP6
[612] 87 DUP8
[613] 83 DUP4
[614] 01 ADD // canExtractThisYear + total
[615] 03 SUB // ... - remainingTokens
[616] 90 SWAP1
[617] 50 POP
// canExtract = sub(canExtract, collectedTokens);
[618] 61 PUSH2 629:0x0275
[621] 81 DUP2
[622] 60 PUSH1 0:0x00
[624] 54 SLOAD
[625] 61 PUSH2 700:0x02bc
[628] 56 JUMP // call sub // sub(canExtract, collectedTokens);
// if(canExtract > balance) {
// canExtract = balance;
// }
[629] 5b JUMPDEST
[630] 90 SWAP1
[631] 50 POP
[632] 60 PUSH1 1:0x01
[634] 54 SLOAD
[635] 81 DUP2
[636] 11 GT
[637] 15 ISZERO
[638] 61 PUSH2 647:0x0287
[641] 57 JUMPI
[642] 60 PUSH1 1:0x01
[644] 54 SLOAD
[645] 90 SWAP1
[646] 50 POP
// collectedTokens = add(collectedTokens, canExtract);
[647] 5b JUMPDEST
[648] 61 PUSH2 659:0x0293
[651] 60 PUSH1 0:0x00
[653] 54 SLOAD
[654] 82 DUP3
[655] 61 PUSH2 725:0x02d5
[658] 56 JUMP // call add
[659] 5b JUMPDEST
[660] 60 PUSH1 0:0x00
[662] 81 DUP2
[663] 90 SWAP1
[664] 55 SSTORE // collectedTokens = ...
[665] 50 POP
// balance = sub(balance, canExtract);
[666] 61 PUSH2 677:0x02a5
[669] 60 PUSH1 1:0x01
[671] 54 SLOAD
[672] 82 DUP3
[673] 61 PUSH2 700:0x02bc
[676] 56 JUMP // call sub
[677] 5b JUMPDEST
[678] 60 PUSH1 1:0x01
[680] 81 DUP2
[681] 90 SWAP1
[682] 55 SSTORE // balance = ...
[683] 50 POP
// collectToken function body end
[684] 60 PUSH1 1:0x01
[686] 97 SWAP8
[687] 50 POP
[688] 50 POP
[689] 50 POP
[690] 50 POP
[691] 50 POP
[692] 50 POP
[693] 50 POP
[694] 50 POP
[695] 92 SWAP3
[696] 91 SWAP2
[697] 50 POP
[698] 50 POP
[699] 56 JUMP
// end of collectToken function body
// safemath sub
[700] 5b JUMPDEST
[701] 60 PUSH1 0:0x00
[703] 82 DUP3
[704] 82 DUP3
[705] 84 DUP5
[706] 03 SUB // z = x - y
[707] 91 SWAP2
[708] 50 POP
[709] 81 DUP2
[710] 11 GT // if z > x then invalid
[711] 15 ISZERO
[712] 15 ISZERO
[713] 15 ISZERO
[714] 61 PUSH2 719:0x02cf
[717] 57 JUMPI
[718] fe INVALID
[719] 5b JUMPDEST
[720] 92 SWAP3
[721] 91 SWAP2
[722] 50 POP
[723] 50 POP
[724] 56 JUMP
// step 1814
// safemath add
// z = x + y
[725] 5b JUMPDEST
[726] 60 PUSH1 0:0x00
[728] 82 DUP3
[729] 82 DUP3
[730] 84 DUP5
[731] 01 ADD
// assert(z >= x);
[732] 91 SWAP2
[733] 50 POP
[734] 81 DUP2
[735] 10 LT
[736] 15 ISZERO
[737] 15 ISZERO
[738] 15 ISZERO
[739] 61 PUSH2 744:0x02e8
[742] 57 JUMPI
[743] fe INVALID
// return z
[744] 5b JUMPDEST
[745] 92 SWAP3
[746] 91 SWAP2
[747] 50 POP
[748] 50 POP
[749] 56 JUMP
// safemath mul
[750] 5b JUMPDEST
[751] 60 PUSH1 0:0x00
[753] 81 DUP2
[754] 83 DUP4
[755] 02 MUL // x * y
[756] 90 SWAP1
[757] 50 POP
[758] 60 PUSH1 0:0x00
[760] 83 DUP4
[761] 14 EQ // x == 0
[762] 80 DUP1
[763] 61 PUSH2 782:0x030e
[766] 57 JUMPI // step 262
[767] 50 POP
[768] 81 DUP2
[769] 83 DUP4
[770] 82 DUP3
[771] 81 DUP2
[772] 15 ISZERO
[773] 15 ISZERO
[774] 61 PUSH2 779:0x030b
[777] 57 JUMPI
[778] fe INVALID
[779] 5b JUMPDEST
[780] 04 DIV // z / x
[781] 14 EQ // z / x == y
[782] 5b JUMPDEST
[783] 15 ISZERO
[784] 15 ISZERO
[785] 61 PUSH2 790:0x0316
[788] 57 JUMPI
[789] fe INVALID
[790] 5b JUMPDEST
[791] 92 SWAP3
[792] 91 SWAP2
[793] 50 POP
[794] 50 POP
[795] 56 JUMP
// safemath div
[796] 5b JUMPDEST
[797] 60 PUSH1 0:0x00
[799] 81 DUP2
[800] 83 DUP4
[801] 81 DUP2
[802] 15 ISZERO
[803] 15 ISZERO
[804] 61 PUSH2 809:0x0329
[807] 57 JUMPI
[808] fe INVALID
[809] 5b JUMPDEST
[810] 04 DIV // x / y
[811] 90 SWAP1
[812] 50 POP
[813] 92 SWAP3
[814] 91 SWAP2
[815] 50 POP
[816] 50 POP
[817] 56 JUMP
[818] 00 STOP
[819] a1 LOG1
[820] 65 PUSH6 108278179835992:0x627a7a723058
[827] 20 SHA3
[828] d8 ERROR
[829] 72 PUSH19 3988032952120969194914029572071075941020958339:0xb2d45f83e947bca970275ff6b79e7236317e83
[849] b4 ERROR
[850] 6d PUSH14 ERROR 261035784345894295431413801:0xd7ec7a3966138aa8260029 (3 bytes missed)