Platform: Code4rena
Start Date: 31/10/2023
Pot Size: $60,500 USDC
Total HM: 9
Participants: 65
Period: 10 days
Judge: gzeon
Total Solo HM: 2
Id: 301
League: ETH
Rank: 62/65
Findings: 1
Award: $15.78
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 3docSec
Also found by: 0xMosh, 0xadrii, 0xmystery, Bauchibred, Ch_301, Emmanuel, J4X, Madalad, Pechenite, Shaheen, Topmark, TresDelinquentes, Walter, ZanyBonzy, adeolu, adriro, chainsnake, joaovwfreire, lsaudit, osmanozdemir1, sin1st3r__
15.7808 USDC - $15.78
it is a small difference between the actual refund and the current refund of about few wei in case the crowdfund was created with a fundingSplitRecipient, fundingSplitBps and exchangeRateBps
function test_powerToContribution(uint256 commissions,uint256 exchangeRateBpss)public{ uint256 amount = 10e18; vm.assume(commissions<5e3 && commissions>100 ); vm.assume(exchangeRateBpss<10000 && exchangeRateBpss>100); address fundingSplitRecipientAddress = _randomAddress(); uint256 startingAmount = amount; InitialETHCrowdfund crowdfund = _createCrowdfund( CreateCrowdfundArgs({ initialContribution: 0, initialContributor: payable(address(0)), initialDelegate: address(0), minContributions: 0, maxContributions: type(uint96).max, disableContributingForExistingCard: false, minTotalContributions: 10 ether, maxTotalContributions: 500 ether, duration: 1 days, exchangeRateBps: uint16(exchangeRateBpss), fundingSplitBps: uint16(commissions), fundingSplitRecipient: payable(fundingSplitRecipientAddress), gateKeeper: IGateKeeper(address(0)), gateKeeperId: bytes12(0) }), false ); crowdfund.initialize(crowdfundOpts, partyOpts, MetadataProvider(address(0)), ""); address payable fundingSplitRecipient_ = crowdfund.fundingSplitRecipient(); uint16 fundingSplitBps_ = crowdfund.fundingSplitBps(); if (fundingSplitRecipient_ != address(0) && fundingSplitBps_ > 0) { amount = (startingAmount * (exchangeRateBpss - fundingSplitBps_)) / exchangeRateBpss; } uint256 votingPower = (amount * crowdfund.exchangeRateBps()) / exchangeRateBpss; uint256 resultAmount = (votingPower * exchangeRateBpss) / crowdfund.exchangeRateBps(); if (fundingSplitRecipient_ != address(0) && fundingSplitBps_ > 0) { resultAmount = (resultAmount * exchangeRateBpss) / (exchangeRateBpss - fundingSplitBps_); } address member = _randomAddress(); vm.deal(member, amount); vm.startPrank(member); vm.expectEmit(true, false, false, true); emit Contributed(member, member, amount, member); crowdfund.contribute{ value: amount }(member, ""); console.log(address(crowdfund).balance); vm.stopPrank(); vm.warp(block.timestamp + 1 days); vm.startPrank(member); uint256 resussslt = crowdfund.refund(1); vm.stopPrank(); assertEq(resussslt,10e18-((commissions*10e18)/exchangeRateBpss)); }
add this into the initialETHCrowdfund.t.sol test file
could be resolved by seeing the hypothetical refund value,calculated for,for example, by an internal function and compare it to the actual value,get the few wei difference and use the new amount to get the refund
#0 - c4-pre-sort
2023-11-13T04:15:53Z
ydspa marked the issue as sufficient quality report
#1 - c4-judge
2023-11-19T18:10:41Z
gzeon-c4 marked the issue as grade-b