Skip to content

Commit e3b09de

Browse files
committed
fix: deduct taxAmount from msg.value to preserve it in contracts' balance
This change adjust the value passed to the createDispute function to ensure that the contract's balance accurately reflects the dudcted tax amount, maintaining proper accounting.
1 parent 3252016 commit e3b09de

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

contracts/TruthPost.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,17 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
142142
/// @inheritdoc ITruthPost
143143
function challenge(uint80 _articleStorageAddress) external payable override {
144144
Article storage article = articleStorage[_articleStorageAddress];
145+
require(article.bountyAmount > 0, "Nothing to challenge.");
145146
require(article.withdrawalPermittedAt != type(uint32).max, "There is an ongoing challenge.");
146147
article.withdrawalPermittedAt = type(uint32).max;
147148
// Mark as challenged.
148149

149150
require(msg.value >= challengeFee(_articleStorageAddress), "Insufficient funds to challenge.");
150151

151-
treasuryBalance += ((uint96(article.bountyAmount) << NUMBER_OF_LEAST_SIGNIFICANT_BITS_TO_IGNORE) * challengeTaxRate) / MULTIPLIER_DENOMINATOR;
152-
153-
// To prevent mistakes.
154-
require(article.bountyAmount > 0, "Nothing to challenge.");
152+
uint taxAmount = ((uint96(article.bountyAmount) << NUMBER_OF_LEAST_SIGNIFICANT_BITS_TO_IGNORE) * challengeTaxRate) / MULTIPLIER_DENOMINATOR;
153+
treasuryBalance += taxAmount;
155154

156-
uint256 disputeID = ARBITRATOR.createDispute{value : msg.value}(NUMBER_OF_RULING_OPTIONS, categoryToArbitratorExtraData[article.category]);
155+
uint256 disputeID = ARBITRATOR.createDispute{value : msg.value - taxAmount }(NUMBER_OF_RULING_OPTIONS, categoryToArbitratorExtraData[article.category]);
157156

158157
disputes[disputeID].challenger = payable(msg.sender);
159158
disputes[disputeID].rounds.push();

0 commit comments

Comments
 (0)