1
1
// SPDX-License-Identifier: UNLICENSED
2
2
pragma solidity ^ 0.8.13 ;
3
3
4
+ import "openzeppelin/token/ERC20/IERC20.sol " ;
5
+
4
6
interface SafuLike {
5
7
// Record that white-hat has deposited funds.
6
8
function deposit (address erc20 , uint256 wad ) external ;
7
9
8
10
// all eligible bounties for msg.sender are transfered
9
- function withdraw () external ;
11
+ function claim () external ;
12
+
13
+ function bounty (uint16 id ) external returns (uint256 amt , bool approved );
14
+
15
+ function approveBounty (uint16 id ) external ;
10
16
}
11
17
12
18
contract SimpleSafu {
13
- struct Deposit {
14
- IERC20 token
15
-
19
+ struct Receipt {
20
+ uint16 id;
21
+ IERC20 token;
22
+ uint256 amt;
23
+ uint256 blockTime;
24
+ bool rewardApproved;
16
25
}
17
26
18
27
address [] public depositors;
19
- mapping (address => )
28
+ mapping (address => Receipt[]) depositorToReceipts;
29
+ mapping (IERC20 => uint256 ) public tokenToBountyCap;
30
+ mapping (IERC20 => uint256 ) public tokenToTotalDeposited;
31
+ mapping (IERC20 => uint256 ) public tokenToBountyWithdrawn;
32
+ uint256 public immutable defaultBountyCap;
33
+ uint256 public immutable minDelay;
34
+ uint256 public immutable maxDelay;
35
+ uint8 public immutable bountyPercent;
36
+
37
+ bool public rewardsClaimable;
38
+ bool public autoApprove;
39
+
40
+ constructor (
41
+ uint256 _defaultBountyCap ,
42
+ uint256 _minDelay ,
43
+ uint256 _maxDelay ,
44
+ uint8 _bountyPercent ,
45
+ bool _rewardsClaimable ,
46
+ bool _autoApprove
47
+ ) {
48
+ defaultBountyCap = _defaultBountyCap;
49
+ minDelay = _minDelay;
50
+ maxDelay = _maxDelay;
51
+ bountyPercent = _bountyPercent;
52
+ rewardsClaimable = _rewardsClaimable;
53
+ autoApprove = _autoApprove;
54
+ }
55
+
56
+ function deposit (address _erc20 , uint256 wad ) external {
57
+ require (wad > 0 , "Safu/zero-deposit " );
58
+ depositors.push (msg .sender );
59
+ IERC20 erc20 = IERC20 (_erc20);
60
+
61
+ uint256 prevTotalBounty = tokenToTotalDeposited[erc20] -
62
+ tokenToBountyWithdrawn[erc20];
63
+ // if (prevTotalBounty + )
64
+ }
65
+
66
+ function bounty (address guy , uint16 id ) public view returns (uint256 amt , bool approved ) {
67
+ Receipt memory receipt = getReceipt (guy, id);
68
+ approved = receipt.rewardApproved;
69
+ if ()
70
+ }
71
+
72
+ function bounty (uint16 id ) public view returns (uint256 amt , bool approved ) {
73
+ return bounty (msg .sender , id);
74
+ }
75
+
76
+ function getReceipt (address depositor , uint16 id )
77
+ public
78
+ view
79
+ returns (Receipt memory )
80
+ {
81
+ Receipt[] storage deposits = depositorToReceipts[depositor];
82
+ for (uint256 i = 0 ; i < deposits.length ; ++ i) {
83
+ if (deposits[i].id == id) {
84
+ return deposits[i];
85
+ }
86
+ }
87
+ revert ("Safu/deposit-not-found-for-id-address-pair " );
88
+ }
20
89
}
21
90
22
91
/*
23
92
pro rata with cap per token
24
93
mapping : token -> cap
25
- mapping : token -> percentOfDepositWithdrawable
94
+ mapping : token -> percentOfReceiptWithdrawable
26
95
27
96
depositor delay
28
97
@@ -33,4 +102,4 @@ sender
33
102
34
103
each deposit keyed by (sender addr, blocktime)
35
104
36
- */
105
+ */
0 commit comments