From 4b0db89d08742af9724782a0b33314ec2b37a465 Mon Sep 17 00:00:00 2001 From: robertu <4065233+robertu7@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:41:43 +0800 Subject: [PATCH] feat(billboard): return tax on `withdrawTax` --- .gas-snapshot | 20 ++++++++++---------- src/Billboard/Billboard.sol | 4 +++- src/Billboard/IBillboard.sol | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index c694ec2..5d44419 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -12,15 +12,15 @@ ACLManagerTest:testTransferRole() (gas: 21528) BillboardTest:testAddToWhitelist() (gas: 35114) BillboardTest:testApproveAndTransfer() (gas: 162468) BillboardTest:testCalculateTax() (gas: 21760) -BillboardTest:testCannnotWithdrawTaxIfSmallAmount(uint8) (runs: 256, μ: 519318, ~: 524555) -BillboardTest:testCannnotWithdrawTaxIfZero() (gas: 490374) +BillboardTest:testCannnotWithdrawTaxIfSmallAmount(uint8) (runs: 256, μ: 519077, ~: 524563) +BillboardTest:testCannnotWithdrawTaxIfZero() (gas: 490384) BillboardTest:testCannotAddToWhitelistByAttacker() (gas: 9037) BillboardTest:testCannotApproveByAttacker() (gas: 130281) BillboardTest:testCannotClearAuctionIfAuctionNotEnded() (gas: 700985) BillboardTest:testCannotClearAuctionOnNewBoard() (gas: 136261) BillboardTest:testCannotMintBoardByAttacker() (gas: 13321) BillboardTest:testCannotPlaceBidByAttacker() (gas: 246293) -BillboardTest:testCannotPlaceBidTwice(uint96) (runs: 256, μ: 749802, ~: 754906) +BillboardTest:testCannotPlaceBidTwice(uint96) (runs: 256, μ: 749739, ~: 754904) BillboardTest:testCannotRemoveToWhitelistByAttacker() (gas: 9104) BillboardTest:testCannotSafeTransferByAttacker() (gas: 127438) BillboardTest:testCannotSetBoardProprtiesByAttacker() (gas: 157292) @@ -34,19 +34,19 @@ BillboardTest:testCannotWithdrawBidIfAuctionNotCleared(uint96) (runs: 256, μ: 9 BillboardTest:testCannotWithdrawBidIfAuctionNotEnded(uint96) (runs: 256, μ: 725782, ~: 725782) BillboardTest:testCannotWithdrawBidIfNotFound() (gas: 428052) BillboardTest:testCannotWithdrawBidIfWon(uint96) (runs: 256, μ: 834282, ~: 834282) -BillboardTest:testCannotWithdrawTaxByAttacker() (gas: 16677) +BillboardTest:testCannotWithdrawTaxByAttacker() (gas: 16687) BillboardTest:testClearAuctionIfAuctionEnded(uint96) (runs: 256, μ: 837581, ~: 837581) BillboardTest:testClearAuctionsIfAuctionEnded() (gas: 1379962) -BillboardTest:testGetBids(uint8,uint8,uint8) (runs: 256, μ: 4580822, ~: 2075259) +BillboardTest:testGetBids(uint8,uint8,uint8) (runs: 256, μ: 4390609, ~: 2070952) BillboardTest:testGetTokenURI() (gas: 154936) BillboardTest:testMintBoard() (gas: 225541) BillboardTest:testMintBoardByWhitelist() (gas: 154942) BillboardTest:testMintBoardIfOpened() (gas: 145715) BillboardTest:testPlaceBidByWhitelist() (gas: 579179) BillboardTest:testPlaceBidIfAuctionEnded() (gas: 1090700) -BillboardTest:testPlaceBidOnNewBoard(uint96) (runs: 256, μ: 618577, ~: 635089) -BillboardTest:testPlaceBidWithHigherPrice(uint96) (runs: 256, μ: 905402, ~: 913254) -BillboardTest:testPlaceBidWithSamePrices(uint96) (runs: 256, μ: 908177, ~: 918050) +BillboardTest:testPlaceBidOnNewBoard(uint96) (runs: 256, μ: 619044, ~: 635089) +BillboardTest:testPlaceBidWithHigherPrice(uint96) (runs: 256, μ: 905247, ~: 913254) +BillboardTest:testPlaceBidWithSamePrices(uint96) (runs: 256, μ: 908333, ~: 918050) BillboardTest:testPlaceBidZeroPrice() (gas: 376947) BillboardTest:testRemoveToWhitelist() (gas: 23188) BillboardTest:testSafeTransferByOperator() (gas: 141193) @@ -54,9 +54,9 @@ BillboardTest:testSetBoardProperties() (gas: 305972) BillboardTest:testSetBoardPropertiesAfterTransfer() (gas: 335477) BillboardTest:testSetIsOpened() (gas: 22661) BillboardTest:testSetTaxRate() (gas: 22887) -BillboardTest:testUpgradeRegistry() (gas: 3131297) +BillboardTest:testUpgradeRegistry() (gas: 3132307) BillboardTest:testWithdrawBid(uint96) (runs: 256, μ: 1081415, ~: 1081415) -BillboardTest:testWithdrawTax(uint96) (runs: 256, μ: 597638, ~: 597638) +BillboardTest:testWithdrawTax(uint96) (runs: 256, μ: 597714, ~: 597714) CurationTest:testCannotCurateERC20CurateZeroAmount() (gas: 12194) CurationTest:testCannotCurateERC20EmptyURI() (gas: 15797) CurationTest:testCannotCurateERC20IfNotApproval() (gas: 21624) diff --git a/src/Billboard/Billboard.sol b/src/Billboard/Billboard.sol index 9ed4450..4f1efef 100644 --- a/src/Billboard/Billboard.sol +++ b/src/Billboard/Billboard.sol @@ -338,7 +338,7 @@ contract Billboard is IBillboard { } /// @inheritdoc IBillboard - function withdrawTax() external { + function withdrawTax() external returns (uint256 tax) { (uint256 _taxAccumulated, uint256 _taxWithdrawn) = registry.taxTreasury(msg.sender); uint256 amount = _taxAccumulated - _taxWithdrawn; @@ -354,6 +354,8 @@ contract Billboard is IBillboard { // emit TaxWithdrawn registry.emitTaxWithdrawn(msg.sender, amount); + + return amount; } /// @inheritdoc IBillboard diff --git a/src/Billboard/IBillboard.sol b/src/Billboard/IBillboard.sol index c1f1457..18e3ffc 100644 --- a/src/Billboard/IBillboard.sol +++ b/src/Billboard/IBillboard.sol @@ -225,7 +225,7 @@ interface IBillboard { * @notice Withdraw accumulated taxation of a board. * */ - function withdrawTax() external; + function withdrawTax() external returns (uint256 tax); /** * @notice Withdraw bid that were not won by auction id;