@@ -3,6 +3,8 @@ pragma solidity ^0.6.10;
3
3
4
4
import "../schemes/ContributionReward.sol " ;
5
5
import "../schemes/ContributionRewardExt.sol " ;
6
+ import "../schemes/FundingRequest.sol " ;
7
+ import "../schemes/JoinAndQuit.sol " ;
6
8
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol " ;
7
9
8
10
@@ -119,6 +121,96 @@ contract Redeemer {
119
121
}
120
122
}
121
123
124
+ /**
125
+ * @dev helper to redeem rewards for a proposal
126
+ * It calls execute on the proposal if it is not yet executed.
127
+ * It tries to redeem reputation and stake from the GenesisProtocol.
128
+ * It tries to redeem proposal rewards from the JoinAndQuit scheme.
129
+ * This function does not emit events.
130
+ * A client should listen to GenesisProtocol and JoinAndQuit redemption events
131
+ * to monitor redemption operations.
132
+ * @param _joinAndQuit joinAndQuit scheme
133
+ * @param _genesisProtocol genesisProtocol
134
+ * @param _proposalId the ID of the voting in the voting machine
135
+ * @param _beneficiary beneficiary
136
+ * @return gpRewards array
137
+ * gpRewards[0] - stakerTokenAmount
138
+ * gpRewards[1] - voterReputationAmount
139
+ * gpRewards[2] - proposerReputationAmount
140
+ * @return gpDaoBountyReward array
141
+ * gpDaoBountyReward[0] - staker dao bounty reward -
142
+ * will be zero for the case there is not enough tokens in avatar for the reward.
143
+ * gpDaoBountyReward[1] - staker potential dao bounty reward.
144
+ * @return executed bool true or false
145
+ * @return winningVote
146
+ * 1 - executed or closed and the winning vote is YES
147
+ * 2 - executed or closed and the winning vote is NO
148
+ * @return joinAndQuitReputationReward Reputation - from JoinAndQuit reputation reward
149
+ */
150
+ function redeemJoinAndQuit (JoinAndQuit _joinAndQuit ,
151
+ GenesisProtocol _genesisProtocol ,
152
+ bytes32 _proposalId ,
153
+ address _beneficiary )
154
+ external
155
+ returns (uint [3 ] memory gpRewards ,
156
+ uint [2 ] memory gpDaoBountyReward ,
157
+ bool executed ,
158
+ uint256 winningVote ,
159
+ uint256 joinAndQuitReputationReward
160
+ )
161
+ {
162
+ bool callJoinAndQuit;
163
+ (gpRewards, gpDaoBountyReward, executed, winningVote, callJoinAndQuit) =
164
+ genesisProtocolRedeem (_genesisProtocol, _proposalId, _beneficiary);
165
+ if (callJoinAndQuit) {
166
+ joinAndQuitReputationReward = _joinAndQuit.redeemReputation (_proposalId);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * @dev helper to redeem rewards for a proposal
172
+ * It calls execute on the proposal if it is not yet executed.
173
+ * It tries to redeem reputation and stake from the GenesisProtocol.
174
+ * It tries to redeem proposal rewards from the FundingRequest scheme.
175
+ * This function does not emit events.
176
+ * A client should listen to GenesisProtocol and FundingRequest redemption events
177
+ * to monitor redemption operations.
178
+ * @param _fundingRequest fundingRequest scheme
179
+ * @param _genesisProtocol genesisProtocol
180
+ * @param _proposalId the ID of the voting in the voting machine
181
+ * @param _beneficiary beneficiary
182
+ * @return gpRewards array
183
+ * gpRewards[0] - stakerTokenAmount
184
+ * gpRewards[1] - voterReputationAmount
185
+ * gpRewards[2] - proposerReputationAmount
186
+ * @return gpDaoBountyReward array
187
+ * gpDaoBountyReward[0] - staker dao bounty reward -
188
+ * will be zero for the case there is not enough tokens in avatar for the reward.
189
+ * gpDaoBountyReward[1] - staker potential dao bounty reward.
190
+ * @return executed bool true or false
191
+ * @return winningVote
192
+ * 1 - executed or closed and the winning vote is YES
193
+ * 2 - executed or closed and the winning vote is NO
194
+ */
195
+ function redeemFundingRequest (FundingRequest _fundingRequest ,
196
+ GenesisProtocol _genesisProtocol ,
197
+ bytes32 _proposalId ,
198
+ address _beneficiary )
199
+ external
200
+ returns (uint [3 ] memory gpRewards ,
201
+ uint [2 ] memory gpDaoBountyReward ,
202
+ bool executed ,
203
+ uint256 winningVote
204
+ )
205
+ {
206
+ bool callFundingRequest;
207
+ (gpRewards, gpDaoBountyReward, executed, winningVote, callFundingRequest) =
208
+ genesisProtocolRedeem (_genesisProtocol, _proposalId, _beneficiary);
209
+ if (callFundingRequest) {
210
+ _fundingRequest.redeem (_proposalId);
211
+ }
212
+ }
213
+
122
214
function genesisProtocolRedeem (GenesisProtocol _genesisProtocol ,
123
215
bytes32 _proposalId ,
124
216
address _beneficiary )
0 commit comments