Skip to content

Commit 4ff902d

Browse files
committed
Add option-specific value tracker
1 parent 6d5c2ff commit 4ff902d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/modules/ApprovalVotingModule.sol

+8-5
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,16 @@ contract ApprovalVotingModule is VotingModule {
209209
for (uint256 i; i < succeededOptionsLength; ++i) {
210210
bool budgetExceeded = false;
211211
option = sortedOptions[i];
212+
uint256 optionTotalValue = 0;
212213

213214
for (n = 0; n < option.targets.length;) {
214-
// If `budgetToken` is ETH and value is not zero, add transaction value to `totalValue`
215+
// If `budgetToken` is ETH and value is not zero, add transaction value to `optionTotalValue`
215216
if (settings.budgetToken == address(0) && option.values[n] != 0) {
216-
if (totalValue + option.values[n] > settings.budgetAmount) {
217+
if (totalValue + optionTotalValue + option.values[n] > settings.budgetAmount) {
217218
budgetExceeded = true;
218219
break; // break inner loop
219220
}
220-
totalValue += option.values[n];
221+
optionTotalValue += option.values[n];
221222
}
222223

223224
unchecked {
@@ -234,11 +235,13 @@ contract ApprovalVotingModule is VotingModule {
234235
// Check if budgetAmount is exceeded for non-ETH tokens
235236
if (settings.budgetToken != address(0) && settings.budgetAmount != 0) {
236237
if (option.budgetTokensSpent != 0) {
237-
if (totalValue + option.budgetTokensSpent > settings.budgetAmount) continue; // break outer loop for non-ETH tokens
238-
totalValue += option.budgetTokensSpent;
238+
if (totalValue + optionTotalValue + option.budgetTokensSpent > settings.budgetAmount) continue; // break outer loop for non-ETH tokens
239+
optionTotalValue += option.budgetTokensSpent;
239240
}
240241
}
241242

243+
// Add option-specific value to the total value
244+
totalValue += optionTotalValue;
242245
unchecked {
243246
executeParamsLength += n;
244247
}

0 commit comments

Comments
 (0)