Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 04f674b

Browse files
authored
Merge pull request #144 from almndbtr/collection-offers-nonzero-protocol-fee
Collection Offers v1.0: add tests when the protocol fee is non-zero
2 parents ebbebd4 + 4e6b08a commit 04f674b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

contracts/test/modules/CollectionOffers/V1/CollectionOffers.integration.t.sol

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ contract CollectionOffersV1IntegrationTest is DSTest {
3636
Zorb internal buyer;
3737
Zorb internal finder;
3838
Zorb internal royaltyRecipient;
39+
Zorb internal protocolFeeRecipient;
3940

4041
function setUp() public {
4142
// Cheatcodes
@@ -45,6 +46,7 @@ contract CollectionOffersV1IntegrationTest is DSTest {
4546
registrar = new ZoraRegistrar();
4647
ZPFS = new ZoraProtocolFeeSettings();
4748
ZMM = new ZoraModuleManager(address(registrar), address(ZPFS));
49+
protocolFeeRecipient = new Zorb(address(ZMM));
4850
erc20TransferHelper = new ERC20TransferHelper(address(ZMM));
4951
erc721TransferHelper = new ERC721TransferHelper(address(ZMM));
5052

@@ -73,6 +75,10 @@ contract CollectionOffersV1IntegrationTest is DSTest {
7375
);
7476
registrar.registerModule(address(offers));
7577

78+
// Set fee parameters for Collection Offers v1.0
79+
vm.prank(address(registrar));
80+
ZPFS.setFeeParams(address(offers), address(protocolFeeRecipient), 1);
81+
7682
// Set seller balance
7783
vm.deal(address(seller), 100 ether);
7884

@@ -144,6 +150,7 @@ contract CollectionOffersV1IntegrationTest is DSTest {
144150
uint256 beforeBuyerBalance = address(buyer).balance;
145151
uint256 beforeRoyaltyRecipientBalance = address(royaltyRecipient).balance;
146152
uint256 beforeFinderBalance = address(finder).balance;
153+
uint256 beforeProtocolFeeRecipient = address(protocolFeeRecipient).balance;
147154
address beforeTokenOwner = token.ownerOf(0);
148155

149156
fill();
@@ -152,16 +159,19 @@ contract CollectionOffersV1IntegrationTest is DSTest {
152159
uint256 afterSellerBalance = address(seller).balance;
153160
uint256 afterRoyaltyRecipientBalance = address(royaltyRecipient).balance;
154161
uint256 afterFinderBalance = address(finder).balance;
162+
uint256 afterProtocolFeeRecipient = address(protocolFeeRecipient).balance;
155163
address afterTokenOwner = token.ownerOf(0);
156164

157165
// 1 ETH withdrawn from seller
158166
require((beforeSellerBalance - afterSellerBalance) == 1 ether);
159167
// 0.05 ETH creator royalty
160168
require((afterRoyaltyRecipientBalance - beforeRoyaltyRecipientBalance) == 0.05 ether);
161-
// 100 bps finders fee (Remaining 0.95 ETH * 10% finders fee = 0.0095 ETH)
162-
require((afterFinderBalance - beforeFinderBalance) == 0.0095 ether);
163-
// Remaining 0.9405 ETH paid to buyer
164-
require((afterBuyerBalance - beforeBuyerBalance) == 0.9405 ether);
169+
// 1 bps protocol fee (Remaining 0.95 ETH * 0.01% protocol fee = 0.000095 ETH)
170+
require((afterProtocolFeeRecipient - beforeProtocolFeeRecipient) == 0.000095 ether);
171+
// 100 bps finders fee (Remaining 0.949905 ETH * 1% finders fee = 0.00949905 ETH)
172+
require((afterFinderBalance - beforeFinderBalance) == 0.00949905 ether);
173+
// Remaining 0.94040595 ETH paid to buyer
174+
require((afterBuyerBalance - beforeBuyerBalance) == 0.94040595 ether);
165175
// NFT transferred to seller
166176
require((beforeTokenOwner == address(buyer)) && afterTokenOwner == address(seller));
167177
}

0 commit comments

Comments
 (0)