-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.json
786 lines (786 loc) · 60.9 KB
/
config.json
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
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
{
"client_name": "Yield Studio Pte. Ltd.",
"commit_hash": "0dc7ea99f8e5e47e9f7b0ebc4a560854a98f52b0",
"date": "December 2020",
"date_interval": "December 8 to December 17, 2020",
"issues": [
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThere is some functionality that, at the moment, isn't tested; however, it is critical for the whole system to work together.\r\n\r\n**Recommendation**\r\n\r\nIncrease the number of tests and make sure the active code coverage (not taking into account the proxy contracts) is close to 100%.\r\n",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/11/comments",
"created_at": "2020-12-17T16:49:03Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/11/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/11",
"id": 770206093,
"labels": [
{
"color": "fef2c0",
"default": false,
"description": null,
"id": 2574825354,
"name": "Informational",
"node_id": "MDU6TGFiZWwyNTc0ODI1MzU0",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/11/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NzAyMDYwOTM=",
"number": 11,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "open",
"title": "Increase the number of tests",
"updated_at": "2020-12-17T16:49:03Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/11",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThis is a pattern that is not a recommendation, but its purpose is to inform of a way to track, save and handle contract instances that a contract needs to interact with.\r\n\r\nConsider this mapping where the contract is compiled with a list of predefined addresses.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L40-L44\r\n\r\nThis code needs to be updated before the final deployment with the updated addresses. This not only makes testing difficult but impossible because the addresses are not set in the contract and the functionality that relies on correct addresses cannot be tested. \r\n\r\nA different approach to provide the correct addresses of the needed contract deployments can be achieved by creating a centralized contract registry, which can be called by any contract. This registry will be able to provide the latest implementation for each contract. Consider it a glorified list mapping having a contract name as an argument and returning an address representing that contract's instance on the blockchain.\r\n\r\nExample of a registry contract.\r\n\r\n```solidity\r\ncontract DefiDollarMasterLedger {\r\n address public owner;\r\n \r\n modifier onlyOwner() {\r\n require(owner == msg.sender, \"Only the owner can update addresses\");\r\n _;\r\n }\r\n \r\n constructor() public {owner = msg.sender;}\r\n \r\n mapping (bytes32 => address) contractMapping;\r\n \r\n // Call this to return the latest contract instance\r\n function getLatestAddress(bytes32 _contractName) public view returns (address) {\r\n return contractMapping[_contractName];\r\n }\r\n \r\n // Define all contracts with this call\r\n function setLatestAddress(bytes32 _contractName, address _address) public onlyOwner {\r\n contractMapping[_contractName] = _address;\r\n }\r\n}\r\n```\r\n\r\nThis could then make the previous code be updated to something similar to this.\r\n\r\n```solidity\r\ncontract DFDComptroller {\r\n address public immutable uni;\r\n address public immutable beneficiary;\r\n IERC20 public immutable dfd;\r\n IERC20 public immutable dusd;\r\n IComptroller public immutable comptroller;\r\n\r\n constructor(DefiDollarMasterLedger _masterLedger) public {\r\n uni = _masterLedger.getLatestAddress(\"UniswapMarket\");\r\n beneficiary = _masterLedger.getLatestAddress(\"ibDFD\");\r\n dfd = IERC20(_masterLedger.getLatestAddress(\"DFD\"));\r\n dusd = IERC20(_masterLedger.getLatestAddress(\"DUSD\"));\r\n comptroller = IComptroller(_masterLedger.getLatestAddress(\"Comptroller\"));\r\n }\r\n}\r\n```\r\n\r\nThis obviously uses the Solidity `immutable` feature that makes sure the variables are saved in the bytecode, and the values are added at deploy time in the correct places. This would make sure the gas costs are the same as they are right now (having `constant` variables) while providing the flexibility to set the values at deploy time, while also providing a way for easy testing, mocking, plug and play of different implementations.\r\n\r\nIf the `immutable` feature is unavailable (because Solidity `0.5.17` does not support it), or the `constructor` not available (because of a specific upgradability pattern), a different approach can be made, admittedly having higher gas costs, while retaining the plug and play flexibility.\r\n\r\nThe contract can have a public function that obtains one or more addresses and stores them in its local state.\r\n\r\n```\r\ncontract DFDComptrollerCache {\r\n address public uni;\r\n address public beneficiary;\r\n IERC20 public dfd;\r\n IERC20 public dusd;\r\n IComptroller public comptroller; \r\n \r\n function updateAddresses() public {\r\n DefiDollarMasterLedger _masterLedger = DefiDollarMasterLedger(0x7EF2e0048f5bAeDe046f6BF797943daF4ED8CB47);\r\n \r\n uni = _masterLedger.getLatestAddress(\"UniswapMarket\");\r\n beneficiary = _masterLedger.getLatestAddress(\"ibDFD\");\r\n dfd = IERC20(_masterLedger.getLatestAddress(\"DFD\"));\r\n dusd = IERC20(_masterLedger.getLatestAddress(\"DUSD\"));\r\n comptroller = IComptroller(_masterLedger.getLatestAddress(\"Comptroller\"));\r\n }\r\n}\r\n```\r\n\r\nThis will add ~800 gas cost each time the address is retrieved from the storage (because SLOAD costs 800 gas).\r\n\r\n**Recommendation**\r\n\r\nThis isn't a recommendation to change the current pattern, but a tool to add to your inventory to be aware of and spark discussion on improving testing and upgradability. \r\n\r\nThe system may become really complex in the future and a centralized address mapping is useful. At the moment, there's no clear list of how the contracts are linked together, a personal knowledge of the system needs to be in place already.\r\n",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/10/comments",
"created_at": "2020-12-17T16:26:57Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/10/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/10",
"id": 770189218,
"labels": [
{
"color": "4054C7",
"default": false,
"description": null,
"id": 2574825629,
"name": "Acknowledged",
"node_id": "MDU6TGFiZWwyNTc0ODI1NjI5",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Acknowledged"
},
{
"color": "fef2c0",
"default": false,
"description": null,
"id": 2574825354,
"name": "Informational",
"node_id": "MDU6TGFiZWwyNTc0ODI1MzU0",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/10/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NzAxODkyMTg=",
"number": 10,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "open",
"title": "Consider using an contract registry tracker",
"updated_at": "2020-12-20T08:45:48Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/10",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThere are a few instances where time is retrieved in the contract and could be improved.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L133-L135\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L69\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L125\r\n\r\n**Recommendation**\r\n\r\nThe `_timestamp` method can be removed completely and `block.timestamp` can be used instead directly.\r\n\r\nThe `now` usage is deprecated in Solidity 0.7.0 and `block.timestamp` is required. This will make your code more future-proof.\r\n\r\n**[optional] References**\r\n",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/9/comments",
"created_at": "2020-12-17T10:09:27Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/9/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/9",
"id": 769809604,
"labels": [
{
"color": "4054C7",
"default": false,
"description": null,
"id": 2574825629,
"name": "Acknowledged",
"node_id": "MDU6TGFiZWwyNTc0ODI1NjI5",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Acknowledged"
},
{
"color": "fef2c0",
"default": false,
"description": null,
"id": 2574825354,
"name": "Informational",
"node_id": "MDU6TGFiZWwyNTc0ODI1MzU0",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Informational"
},
{
"color": "e9c46a",
"default": false,
"description": null,
"id": 2574825428,
"name": "Minor",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDI4",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/9/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3Njk4MDk2MDQ=",
"number": 9,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "open",
"title": "[DFDComptroller] - Optimize timestamp retrieval",
"updated_at": "2020-12-20T08:41:33Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/9",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
},
"assignees": [
{
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nWe'd like to further discuss what we believe might be a non-issue but thought it's worth investigating together with Arpit.\r\n\r\nImagine the following flow of contract interactions, all within one transaction. Please note the (*) at the end:\r\n\r\n1. borrow a lot of DUSD from Uniswap's DUSD/DFD pool\r\n1. ibDUSD.deposit DUSD: receive ibDUSD tokens\r\n1. borrow again DUSD from Uniswap's DUSD/DFD pool\r\n1. ibDUSD.deposit DUSD: receive a lot more ibDUSD tokens bc there was an increased amount of `earned` DUSD reward that has been distributed to ibDUSD (caveat: see (*) below)\r\n1. ibDUSD.withdraw all DUSD deposited (it will burn my ibDUSD)\r\n1. return borrowed DUSD to Uniswap\r\n1. I should have extra DUSD now\r\n\r\n(*) this is most probably a non-issue since Core.totalSystemAssets() does not include amount of dusd in ibDUSD contract (only includes amount of DUSD from peak(s)). Therefore the `Core.harvest()` method will not mint new `dusd` when a user deposits more `dusd` in the ibDUSD contract.\r\n\r\nBasically we're trying to make sure that:\r\n\r\n1. our understanding (*) above is correct\r\n1. the client is aware that this becomes an attack vector if for some reason in the future, the architecture of the system changes and somehow the DUSD stored in ibDUSD contract is being included in the calculation of `totalSystemAssets()` - this might not make sense anyway, but better to discuss it early.\r\n",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/8/comments",
"created_at": "2020-12-16T02:55:50Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/8/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/8",
"id": 768401542,
"labels": [
{
"color": "fef2c0",
"default": false,
"description": null,
"id": 2574825354,
"name": "Informational",
"node_id": "MDU6TGFiZWwyNTc0ODI1MzU0",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Informational"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/8/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3Njg0MDE1NDI=",
"number": 8,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "open",
"title": "[ibDUSD] - Discussion of (future) potential flash loan attack vector",
"updated_at": "2020-12-20T08:45:32Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/8",
"user": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe `harvest` method is called by the owner to harvest the DUSD tokens and exchange them for DFD tokens. This is done by calling the Uniswap router method `swapExactTokensForTokens`.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L125\r\n\r\nThe [Uniswap router documentation](https://uniswap.org/docs/v2/smart-contracts/router02/?#swapexacttokensfortokens) describes each argument of the `swapExactTokensForTokens`. \r\n\r\nThe last argument is `deadline` which defines when the transaction should fail, if it stays in the mempool for too long. Because the function is not called directly by an external account, but the method is called by a contract, the `deadline` parameter can be set to `now`. This is valid according to the Uniswap `ensure` modifier which tests if the provided `deadline` is equal or higher than the current time. \r\n\r\nhttps://github.com/Uniswap/uniswap-v2-periphery/blob/69617118cda519dab608898d62aaa79877a61004/contracts/UniswapV2Router02.sol#L18-L21\r\n\r\nBecause this is called by a contract, it happens instantly and a future `deadline` does not need to be provided.\r\n\r\n**Recommendation**\r\n\r\nUpdate the call to the Uniswap router to send `now` as the deadline, and not a future `deadline`.\r\n\r\nReplace `now.add(1800)` with `now` when calling `swapExactTokensForTokens`.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L125\r\n\r\n**References**\r\n\r\n- [Uniswap documentation](https://uniswap.org/docs/v2/smart-contracts/router02/?#swaptokensforexacttokens)\r\n\r\ndeadline | uint | Unix timestamp after which the transaction will revert.\r\n-- | -- | --\r\n\r\n- Uniswap implementation of deadline check\r\n\r\nhttps://github.com/Uniswap/uniswap-v2-periphery/blob/69617118cda519dab608898d62aaa79877a61004/contracts/UniswapV2Router02.sol#L18-L21",
"closed_at": "2020-12-20T08:31:26Z",
"comments": 2,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/7/comments",
"created_at": "2020-12-15T11:38:01Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/7/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/7",
"id": 767501492,
"labels": [
{
"color": "e9c46a",
"default": false,
"description": null,
"id": 2574825428,
"name": "Minor",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDI4",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/7/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3Njc1MDE0OTI=",
"number": 7,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[DFDComptroller] - Uniswap exchange will happen instantly",
"updated_at": "2020-12-20T08:31:27Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/7",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe harvested revenue is split to the beneficiaries according to a defined allocation.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/Comptroller.sol#L42-L44\r\n\r\nThis allocation can be updated by the owner of the contract using 2 methods: \r\n- `addBeneficiary` which adds a new beneficiary to the list, along with the new allocation for all of the existing beneficiaries (including the newly created one)\r\n- `modifyAllocation` which modifies the allocation for the existing beneficiaries\r\n\r\nIf, for example, a beneficiary needs to be replaced, or removed, its allocation will be updated by calling `modifyAllocation` and setting its allocation index to the value zero.\r\n\r\nIn case that happens, the revenue distribution will still loop over the beneficiary array, but it will send `0` tokens and iterate to the next beneficiary. The beneficiary array is always appended to, never replaced and items are never removed. Because of this, once a beneficiary was added to be distributed to, it will always be looped over, even if its distribution is `0`.\r\n\r\n**Recommendation**\r\n\r\nBecause the allocation is already replaced as an array, it will not be a significant and risky change to also replace the beneficiary array. This way the 2 methods can be replaced by one method which will update the beneficiary list and their allocations, in one call.\r\n",
"closed_at": "2020-12-20T08:08:56Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/6/comments",
"created_at": "2020-12-14T18:00:28Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/6/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/6",
"id": 766774867,
"labels": [
{
"color": "e9c46a",
"default": false,
"description": null,
"id": 2574825428,
"name": "Minor",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDI4",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/6/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjY3NzQ4Njc=",
"number": 6,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[Comptroller] - Improve management of beneficiary allocations",
"updated_at": "2020-12-20T08:08:56Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/6",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe `harvest()` method loops over all the beneficiaries and transfers the total revenue according to the defined proportions.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/Comptroller.sol#L42-L44\r\n\r\nThe loop ends when all of the beneficiaries have been processed.\r\n\r\nThe end of the loop does not change while the transfers are made; thus, the end of the loop can be cached to save gas.\r\n\r\nThe same principle applies to the `earned` method.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/Comptroller.sol#L51-L55\r\n\r\nA test contract was deployed with Remix to describe the gas impact.\r\n\r\n```solidity\r\ncontract LoopEndNoCache {\r\n uint[] public numbers;\r\n\r\n function setBeneficiaries(uint[] memory _numbers) public {\r\n numbers = _numbers;\r\n }\r\n\r\n // Looping over 10 items costs 23961 gas\r\n // Looping over 2 items costs 6132 gas\r\n function loop() public view returns (uint) {\r\n uint sum = 0;\r\n for (uint i=0; i < numbers.length; i++) {\r\n sum = sum + numbers[i];\r\n }\r\n return sum;\r\n }\r\n}\r\n\r\ncontract LoopEndCache {\r\n uint[] public numbers;\r\n\r\n function setBeneficiaries(uint[] memory _numbers) public {\r\n numbers = _numbers;\r\n }\r\n\r\n // Looping over 10 items costs 16772 gas\r\n // Looping over 2 items costs 4543 gas\r\n function loop() public view returns (uint) {\r\n uint sum = 0;\r\n uint numbersLength = numbers.length;\r\n for (uint i=0; i < numbersLength; i++) {\r\n sum = sum + numbers[i];\r\n }\r\n return sum;\r\n }\r\n}\r\n```\r\n\r\n**Recommendation**\r\n\r\nCache the end of the loop instead of making the EVM request the array length at each iteration.\r\n\r\ni.e.\r\n\r\n```solidity\r\nuint beneficiariesLength = beneficiaries.length;\r\nfor (uint i = 0; i < beneficiariesLength; i++) {\r\n```\r\n",
"closed_at": "2020-12-20T08:06:46Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/5/comments",
"created_at": "2020-12-14T17:17:18Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/5/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/5",
"id": 766736276,
"labels": [
{
"color": "e9c46a",
"default": false,
"description": null,
"id": 2574825428,
"name": "Minor",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDI4",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/5/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjY3MzYyNzY=",
"number": 5,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[Comptroller] - Loop iteration can be improved",
"updated_at": "2020-12-20T08:06:47Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/5",
"user": {
"avatar_url": "https://avatars3.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\n`DFDComptroller.getReward` method is called from both `ibDFD.deposit` and `ibDFD.withdraw` methods which are called when a user performs those actions.\r\n\r\nThe amount of `reward` accrued is calculated by subtracting the `rewardPaid` from the `rewardStored` state variable ( `L78` ).\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L73-L82\r\n\r\nThe issue is that when there is no additional rewards accrued and `reward` variable is 0 there is unnecessary code executed and an event is being emitted which can confuse any users relying on it.\r\n\r\n**Recommendation**\r\n\r\nNext lines of code should only be executed if the `reward` variable is greater than 0. This avoids unnecessary execution of code and emitting an event for a 0 value reward.\r\n",
"closed_at": "2020-12-20T08:14:00Z",
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/4/comments",
"created_at": "2020-12-14T07:56:03Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/4/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/4",
"id": 766072162,
"labels": [
{
"color": "e9c46a",
"default": false,
"description": null,
"id": 2574825428,
"name": "Minor",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDI4",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/4/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjYwNzIxNjI=",
"number": 4,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[DFDComptroller] - getReward method can save gas in certain situations",
"updated_at": "2020-12-20T08:14:00Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/4",
"user": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\n`DFDComptroller.harvest()` method is used to buy DFD tokens with the DUSD rewards accrued.\r\n\r\nIt does this by using [Uniswap's swapExactTokensForTokens](https://uniswap.org/docs/v2/smart-contracts/router02/#swapexacttokensfortokens) method to buy DFD from the DUSD/DFD liquidity pool.\r\n\r\nAn issue that was identified early in the presentation of the new code with the client is that `swapExactTokensForTokens` is called without specifying a minimum amount of `DFD` tokens to be bought (ie. `amountOutMin` param is set to 0).\r\n\r\nThis means that such a transaction can be frontrun by a malicious actor. This case is already described in the Uniswap Pricing Trades [documentation](https://uniswap.org/docs/v2/advanced-topics/pricing/#pricing-trades) :\r\n\r\n> Say a smart contract naively wants to send 10 DAI to the DAI/WETH pair and receive as much WETH as it can get, given the current reserve ratio. If, when called, the naive smart contract simply looks up the current price and executes the trade, it is vulnerable to front-running and will likely suffer an economic loss. To see why, consider a malicious actor who sees this transaction before it is confirmed. They could execute a swap which dramatically changes the DAI/WETH price immediately before the naive swap goes through, wait for the naive swap to execute at a bad rate, and then swap to change the price back to what it was before the naive swap. This attack is fairly cheap and low-risk, and can typically be performed for a profit.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/3c5a7e72b195e75fd518ab182b31afdf2eb3ce0a/code/contracts/stream/DFDComptroller.sol#L121-L125\r\n\r\nThe severity of this issue is somewhat reduced because if one wants to frontrun such a transaction, they themselves will be exposed to financial risk since they need to commit capital for 2 blocks and hope no arbitrage bot profits from their exposure.\r\n\r\nRegardless, below we provide two solutions, one which is simple enough to implement, which remove the risk of being frontrun completely.\r\n\r\n**Recommendation**\r\n\r\n1. The simplest way to ensure that the losses due to front-running are tightly bounded in the `harvest` method, is to expose the `amountOutMin` parameter to admin calling this method. Since `harvest` can only be executed by the owner of the contract (`onlyOwner` modifier) this user is already trusted. This is also [how the Uniswap frontend works](https://uniswap.org/docs/v2/advanced-topics/pricing/#pricing-trades) at the moment:\r\n\r\n> This is how, for example, the Uniswap frontend ensure trade safety. It calculates the optimal input/output amounts given observed intra-block prices, and uses the router to perform the swap, which guarantees the swap will execute at a rate no less that x% worse than the observed intra-block rate, where x is a user-specified slippage tolerance (0.5% by default).\r\n\r\n2. Another option is to let the contract automatically determine a fair price of DFD to be received with the downside of having to pay more gas: Uniswap's [ExampleSwapToPrice.sol](https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol)\r\n\r\n**References**\r\n\r\nhttps://uniswap.org/docs/v2/advanced-topics/pricing/",
"closed_at": "2020-12-20T08:39:59Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/3/comments",
"created_at": "2020-12-11T08:09:22Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/3/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/3",
"id": 762042827,
"labels": [
{
"color": "F4A261",
"default": false,
"description": null,
"id": 2574825486,
"name": "Medium",
"node_id": "MDU6TGFiZWwyNTc0ODI1NDg2",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Medium"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/3/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjIwNDI4Mjc=",
"number": 3,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[DFDComptroller] - harvest() method is vulnerable to frontrunning",
"updated_at": "2020-12-20T08:40:00Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/3",
"user": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe path variable is initialized with a size of 3 but only the first 2 slots are being used.\r\n\r\n[Uniswap's documentation](https://uniswap.org/docs/v2/smart-contracts/router02/#swapexacttokensfortokens) mentions that if a direct pair exists for the swap, then one can just specify the direct path, i.e., an array of 2 elements, the first element being the input token and the last element the output token.\r\n\r\n>Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L121-L129\r\n\r\n**Recommendation**\r\n\r\nChange `path` variable to an array length of 2 elements:\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/DFDComptroller.sol#L121-L123",
"closed_at": "2020-12-20T08:30:40Z",
"comments": 2,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/2/comments",
"created_at": "2020-12-11T08:08:41Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/2/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/2",
"id": 762042083,
"labels": [
{
"color": "E76F51",
"default": false,
"description": null,
"id": 2574825560,
"name": "Major",
"node_id": "MDU6TGFiZWwyNTc0ODI1NTYw",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Major"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/2/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjIwNDIwODM=",
"number": 2,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "[DFDComptroller] - Uniswap swapExactTokensForTokens wrong array size for path",
"updated_at": "2020-12-20T08:30:40Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/2",
"user": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThere are several instances where code that updates state is encapsulated as a modifier (eg. `DFDComptroller.updateReward`, `ibDFD.getReward`, `ibDUSD.harvest`).\r\n\r\nAlthough we haven't found any security issues with the code in these cases, this practice is an anti-pattern that can lead to harder to read code and potential security issues in the future.\r\n\r\nFor example in `ibDUSD` the `harvest` modifier calls `Comptroller.harvest()` method which in turn changes the state of the contract.\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/ibDUSD.sol#L28-L31\r\n\r\nhttps://github.com/monoceros-alpha/audit-defi-dollar-2020-12/blob/b333071efe533483eb99f8165e2cb2699647379c/code/contracts/stream/Comptroller.sol#L29-L46\r\n\r\nIn this case, removing the modifier from `ibDUSD` and calling `controller.harvest()` directly has the benefit of making the code easier to read and understand.\r\n\r\n**Recommendation**\r\n\r\n[It is recommended](https://consensys.net/blog/blockchain-development/solidity-best-practices-for-smart-contract-security/#use-modifiers-only-for-checks) to keep any state changes outside of modifiers.\r\n\r\nIn most cases, code that changes state that is present in modifiers can easily be moved to function blocks without too much development time invested.\r\n",
"closed_at": "2020-12-20T08:18:17Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/1/comments",
"created_at": "2020-12-11T08:06:12Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/1/events",
"html_url": "https://github.com/monoceros-alpha/audit-defi-dollar-2020-12/issues/1",
"id": 762039241,
"labels": [
{
"color": "fef2c0",
"default": false,
"description": null,
"id": 2574825354,
"name": "Informational",
"node_id": "MDU6TGFiZWwyNTc0ODI1MzU0",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2574825297,
"name": "Report",
"node_id": "MDU6TGFiZWwyNTc0ODI1Mjk3",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/1/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU3NjIwMzkyNDE=",
"number": 1,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12",
"state": "closed",
"title": "Aim to use modifiers only for checks",
"updated_at": "2020-12-20T08:18:17Z",
"url": "https://api.github.com/repos/monoceros-alpha/audit-defi-dollar-2020-12/issues/1",
"user": {
"avatar_url": "https://avatars0.githubusercontent.com/u/342638?v=4",
"events_url": "https://api.github.com/users/andreiashu/events{/privacy}",
"followers_url": "https://api.github.com/users/andreiashu/followers",
"following_url": "https://api.github.com/users/andreiashu/following{/other_user}",
"gists_url": "https://api.github.com/users/andreiashu/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/andreiashu",
"id": 342638,
"login": "andreiashu",
"node_id": "MDQ6VXNlcjM0MjYzOA==",
"organizations_url": "https://api.github.com/users/andreiashu/orgs",
"received_events_url": "https://api.github.com/users/andreiashu/received_events",
"repos_url": "https://api.github.com/users/andreiashu/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/andreiashu/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/andreiashu/subscriptions",
"type": "User",
"url": "https://api.github.com/users/andreiashu"
}
}
],
"person_days": "8",
"project_name": "DefiDollar",
"review_period": "~2 weeks",
"source_repository": "[email protected]:defidollar/defidollar-core.git",
"template": "./Readme.md.mustache"
}