Skip to content

Commit

Permalink
Merge pull request #26 from bitmark-inc/fix-audit-issue
Browse files Browse the repository at this point in the history
Fix the wrong bps check logic for cost receiver
  • Loading branch information
Jim Yeh authored Jul 18, 2023
2 parents e001fee + af3c7ce commit a2f4ffb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 4 additions & 1 deletion contracts/FeralfileArtworkV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ contract FeralfileExhibitionV4 is
}

uint256 distributedRevenue;
uint256 platformRevenue;
for (uint256 i = 0; i < saleData_.tokenIds.length; i++) {
// send NFT
_safeTransfer(
Expand All @@ -449,6 +450,7 @@ contract FeralfileExhibitionV4 is
if (
saleData_.revenueShares[i][j].recipient == costReceiver
) {
platformRevenue += rev;
continue;
}
distributedRevenue += rev;
Expand All @@ -462,7 +464,8 @@ contract FeralfileExhibitionV4 is
}

require(
saleData_.price - saleData_.cost >= distributedRevenue,
saleData_.price - saleData_.cost >=
distributedRevenue + platformRevenue,
"FeralfileExhibitionV4: total bps over 10,000"
);

Expand Down
20 changes: 10 additions & 10 deletions test/feralfile_exhibition_v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,23 @@ contract("FeralfileExhibitionV4_0", async (accounts) => {
[
[
[accounts[3], 8001],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 8001],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 9000],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 9000],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 8500],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
],
false,
Expand Down Expand Up @@ -662,23 +662,23 @@ contract("FeralfileExhibitionV4_0", async (accounts) => {
[
[
[accounts[3], 8001],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 8001],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 9000],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 9000],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
[
[accounts[3], 8500],
[accounts[4], 2000],
[COST_RECEIVER, 2000],
],
],
false,
Expand Down

0 comments on commit a2f4ffb

Please sign in to comment.