Skip to content

Commit 2ba51ba

Browse files
authored
Remove twfee (#231)
* remove twfee * update tests * run prettier * keep constructor with initializer modifier
1 parent b7ad03c commit 2ba51ba

File tree

10 files changed

+19
-110
lines changed

10 files changed

+19
-110
lines changed

contracts/Split.sol

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.11;
33

4-
// Thirdweb top-level
5-
import "./interfaces/ITWFee.sol";
6-
74
// Base
85
import "./openzeppelin-presets/finance/PaymentSplitterUpgradeable.sol";
96
import "./interfaces/IThirdwebContract.sol";
@@ -32,15 +29,10 @@ contract Split is
3229
/// @dev Max bps in the thirdweb system
3330
uint128 private constant MAX_BPS = 10_000;
3431

35-
/// @dev The thirdweb contract with fee related information.
36-
ITWFee public immutable thirdwebFee;
37-
3832
/// @dev Contract level metadata.
3933
string public contractURI;
4034

41-
constructor(address _thirdwebFee) initializer {
42-
thirdwebFee = ITWFee(_thirdwebFee);
43-
}
35+
constructor() initializer {}
4436

4537
/// @dev Performs the job of the constructor.
4638
/// @dev shares_ are scaled by 10,000 to prevent precision loss when including fees
@@ -102,15 +94,7 @@ contract Split is
10294
_released[account] += payment;
10395
_totalReleased += payment;
10496

105-
// fees
106-
uint256 fee = 0;
107-
(address feeRecipient, uint256 feeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.SPLIT);
108-
if (feeRecipient != address(0) && feeBps > 0) {
109-
fee = (payment * feeBps) / MAX_BPS;
110-
AddressUpgradeable.sendValue(payable(feeRecipient), fee);
111-
}
112-
113-
AddressUpgradeable.sendValue(account, payment - fee);
97+
AddressUpgradeable.sendValue(account, payment);
11498
emit PaymentReleased(account, payment);
11599

116100
return payment;
@@ -130,15 +114,7 @@ contract Split is
130114
_erc20Released[token][account] += payment;
131115
_erc20TotalReleased[token] += payment;
132116

133-
// fees
134-
uint256 fee = 0;
135-
(address feeRecipient, uint256 feeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.SPLIT);
136-
if (feeRecipient != address(0) && feeBps > 0) {
137-
fee = (payment * feeBps) / MAX_BPS;
138-
SafeERC20Upgradeable.safeTransfer(token, feeRecipient, fee);
139-
}
140-
141-
SafeERC20Upgradeable.safeTransfer(token, account, payment - fee);
117+
SafeERC20Upgradeable.safeTransfer(token, account, payment);
142118
emit ERC20PaymentReleased(token, account, payment);
143119

144120
return payment;

contracts/drop/DropERC1155.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import "../extension/interface/IRoyalty.sol";
2626
import "../extension/interface/IOwnable.sol";
2727

2828
import { IDropERC1155 } from "../interfaces/drop/IDropERC1155.sol";
29-
import { ITWFee } from "../interfaces/ITWFee.sol";
3029

3130
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
3231

contracts/drop/DropERC20.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import "../extension/interface/IPlatformFee.sol";
2222
import "../extension/interface/IPrimarySale.sol";
2323

2424
import { IDropERC20 } from "../interfaces/drop/IDropERC20.sol";
25-
import { ITWFee } from "../interfaces/ITWFee.sol";
2625

2726
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
2827

contracts/drop/DropERC721.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
1616
// ========== Internal imports ==========
1717

1818
import { IDropERC721 } from "../interfaces/drop/IDropERC721.sol";
19-
import { ITWFee } from "../interfaces/ITWFee.sol";
2019
import "../interfaces/IThirdwebContract.sol";
2120

2221
// ========== Features ==========

contracts/marketplace/Marketplace.sol

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
2020
// ========== Internal imports ==========
2121

2222
import { IMarketplace } from "../interfaces/marketplace/IMarketplace.sol";
23-
import { ITWFee } from "../interfaces/ITWFee.sol";
2423

2524
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
2625

@@ -52,9 +51,6 @@ contract Marketplace is
5251
/// @dev The address of the native token wrapper contract.
5352
address private immutable nativeTokenWrapper;
5453

55-
/// @dev The thirdweb contract with fee related information.
56-
ITWFee public immutable thirdwebFee;
57-
5854
/// @dev Total number of listings ever created in the marketplace.
5955
uint256 public totalListings;
6056

@@ -113,8 +109,7 @@ contract Marketplace is
113109
Constructor + initializer logic
114110
//////////////////////////////////////////////////////////////*/
115111

116-
constructor(address _nativeTokenWrapper, address _thirdwebFee) initializer {
117-
thirdwebFee = ITWFee(_thirdwebFee);
112+
constructor(address _nativeTokenWrapper) initializer {
118113
nativeTokenWrapper = _nativeTokenWrapper;
119114
}
120115

@@ -707,9 +702,6 @@ contract Marketplace is
707702
) internal {
708703
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;
709704

710-
(address twFeeRecipient, uint256 twFeeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.MARKET_SALE);
711-
uint256 twFeeCut = (_totalPayoutAmount * twFeeBps) / MAX_BPS;
712-
713705
uint256 royaltyCut;
714706
address royaltyRecipient;
715707

@@ -719,7 +711,7 @@ contract Marketplace is
719711
uint256 royaltyFeeAmount
720712
) {
721713
if (royaltyFeeRecipient != address(0) && royaltyFeeAmount > 0) {
722-
require(royaltyFeeAmount + platformFeeCut + twFeeCut <= _totalPayoutAmount, "fees exceed the price");
714+
require(royaltyFeeAmount + platformFeeCut <= _totalPayoutAmount, "fees exceed the price");
723715
royaltyRecipient = royaltyFeeRecipient;
724716
royaltyCut = royaltyFeeAmount;
725717
}
@@ -742,18 +734,11 @@ contract Marketplace is
742734
royaltyCut,
743735
_nativeTokenWrapper
744736
);
745-
CurrencyTransferLib.transferCurrencyWithWrapper(
746-
_currencyToUse,
747-
_payer,
748-
twFeeRecipient,
749-
twFeeCut,
750-
_nativeTokenWrapper
751-
);
752737
CurrencyTransferLib.transferCurrencyWithWrapper(
753738
_currencyToUse,
754739
_payer,
755740
_payee,
756-
_totalPayoutAmount - (platformFeeCut + royaltyCut + twFeeCut),
741+
_totalPayoutAmount - (platformFeeCut + royaltyCut),
757742
_nativeTokenWrapper
758743
);
759744
}

contracts/token/TokenERC1155.sol

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
3131
// Helper interfaces
3232
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
3333

34-
// Thirdweb top-level
35-
import "../interfaces/ITWFee.sol";
36-
3734
contract TokenERC1155 is
3835
Initializable,
3936
IThirdwebContract,
@@ -77,9 +74,6 @@ contract TokenERC1155 is
7774
/// @dev The address interpreted as native token of the chain.
7875
address private constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
7976

80-
/// @dev The thirdweb contract with fee related information.
81-
ITWFee public immutable thirdwebFee;
82-
8377
/// @dev Owner of the contract (purpose: OpenSea compatibility, etc.)
8478
address private _owner;
8579

@@ -118,9 +112,7 @@ contract TokenERC1155 is
118112
/// @dev Token ID => royalty recipient and bps for token
119113
mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken;
120114

121-
constructor(address _thirdwebFee) initializer {
122-
thirdwebFee = ITWFee(_thirdwebFee);
123-
}
115+
constructor() initializer {}
124116

125117
/// @dev Initiliazes the contract, like a constructor.
126118
function initialize(
@@ -400,8 +392,6 @@ contract TokenERC1155 is
400392

401393
uint256 totalPrice = _req.pricePerToken * _req.quantity;
402394
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;
403-
(address twFeeRecipient, uint256 twFeeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.PRIMARY_SALE);
404-
uint256 twFee = (totalPrice * twFeeBps) / MAX_BPS;
405395

406396
if (_req.currency == NATIVE_TOKEN) {
407397
require(msg.value == totalPrice, "must send total price.");
@@ -412,13 +402,7 @@ contract TokenERC1155 is
412402
: _req.primarySaleRecipient;
413403

414404
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), platformFeeRecipient, platformFees);
415-
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), twFeeRecipient, twFee);
416-
CurrencyTransferLib.transferCurrency(
417-
_req.currency,
418-
_msgSender(),
419-
saleRecipient,
420-
totalPrice - platformFees - twFee
421-
);
405+
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), saleRecipient, totalPrice - platformFees);
422406
}
423407

424408
/// ===== Low-level overrides =====

contracts/token/TokenERC20.sol

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
2929
import "../lib/CurrencyTransferLib.sol";
3030
import "../lib/FeeType.sol";
3131

32-
// Thirdweb top-level
33-
import "../interfaces/ITWFee.sol";
34-
3532
contract TokenERC20 is
3633
Initializable,
3734
IThirdwebContract,
@@ -60,9 +57,6 @@ contract TokenERC20 is
6057
bytes32 internal constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
6158
bytes32 internal constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");
6259

63-
/// @dev The thirdweb contract with fee related information.
64-
ITWFee internal immutable thirdwebFee;
65-
6660
/// @dev Returns the URI for the storefront-level metadata of the contract.
6761
string public contractURI;
6862

@@ -81,9 +75,7 @@ contract TokenERC20 is
8175
/// @dev Mapping from mint request UID => whether the mint request is processed.
8276
mapping(bytes32 => bool) private minted;
8377

84-
constructor(address _thirdwebFee) initializer {
85-
thirdwebFee = ITWFee(_thirdwebFee);
86-
}
78+
constructor() initializer {}
8779

8880
/// @dev Initiliazes the contract, like a constructor.
8981
function initialize(
@@ -221,21 +213,13 @@ contract TokenERC20 is
221213
}
222214

223215
uint256 platformFees = (_price * platformFeeBps) / MAX_BPS;
224-
(address twFeeRecipient, uint256 twFeeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.PRIMARY_SALE);
225-
uint256 twFee = (_price * twFeeBps) / MAX_BPS;
226216

227217
if (_currency == CurrencyTransferLib.NATIVE_TOKEN) {
228218
require(msg.value == _price, "must send total price.");
229219
}
230220

231221
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
232-
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), twFeeRecipient, twFee);
233-
CurrencyTransferLib.transferCurrency(
234-
_currency,
235-
_msgSender(),
236-
_primarySaleRecipient,
237-
_price - platformFees - twFee
238-
);
222+
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), _primarySaleRecipient, _price - platformFees);
239223
}
240224

241225
/// @dev Mints `amount` of tokens to `to`

contracts/token/TokenERC721.sol

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ import "../lib/FeeType.sol";
3333
// Helper interfaces
3434
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
3535

36-
// Thirdweb top-level
37-
import "../interfaces/ITWFee.sol";
38-
3936
contract TokenERC721 is
4037
Initializable,
4138
IThirdwebContract,
@@ -73,9 +70,6 @@ contract TokenERC721 is
7370
/// @dev The address interpreted as native token of the chain.
7471
address private constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
7572

76-
/// @dev The thirdweb contract with fee related information.
77-
ITWFee public immutable thirdwebFee;
78-
7973
/// @dev Owner of the contract (purpose: OpenSea compatibility, etc.)
8074
address private _owner;
8175

@@ -109,9 +103,7 @@ contract TokenERC721 is
109103
/// @dev Token ID => royalty recipient and bps for token
110104
mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken;
111105

112-
constructor(address _thirdwebFee) initializer {
113-
thirdwebFee = ITWFee(_thirdwebFee);
114-
}
106+
constructor() initializer {}
115107

116108
/// @dev Initiliazes the contract, like a constructor.
117109
function initialize(
@@ -364,8 +356,6 @@ contract TokenERC721 is
364356

365357
uint256 totalPrice = _req.price;
366358
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;
367-
(address twFeeRecipient, uint256 twFeeBps) = thirdwebFee.getFeeInfo(address(this), FeeType.PRIMARY_SALE);
368-
uint256 twFee = (totalPrice * twFeeBps) / MAX_BPS;
369359

370360
if (_req.currency == NATIVE_TOKEN) {
371361
require(msg.value == totalPrice, "must send total price.");
@@ -376,13 +366,7 @@ contract TokenERC721 is
376366
: _req.primarySaleRecipient;
377367

378368
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), platformFeeRecipient, platformFees);
379-
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), twFeeRecipient, twFee);
380-
CurrencyTransferLib.transferCurrency(
381-
_req.currency,
382-
_msgSender(),
383-
saleRecipient,
384-
totalPrice - platformFees - twFee
385-
);
369+
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), saleRecipient, totalPrice - platformFees);
386370
}
387371

388372
/// ===== Low-level overrides =====

lib/forge-std

src/test/utils/BaseTest.sol

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import "../mocks/MockERC20.sol";
1010
import "../mocks/MockERC721.sol";
1111
import "../mocks/MockERC1155.sol";
1212
import "contracts/Forwarder.sol";
13-
import "contracts/TWFee.sol";
1413
import "contracts/TWRegistry.sol";
1514
import "contracts/TWFactory.sol";
1615
import { Multiwrap } from "contracts/multiwrap/Multiwrap.sol";
@@ -77,10 +76,10 @@ abstract contract BaseTest is DSTest, Test {
7776
contractPublisher = address(new ContractPublisher(forwarder, new MockContractPublisher()));
7877
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), factory);
7978
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), contractPublisher);
80-
fee = address(new TWFee(forwarder, factory));
81-
TWFactory(factory).addImplementation(address(new TokenERC20(fee)));
82-
TWFactory(factory).addImplementation(address(new TokenERC721(fee)));
83-
TWFactory(factory).addImplementation(address(new TokenERC1155(fee)));
79+
80+
TWFactory(factory).addImplementation(address(new TokenERC20()));
81+
TWFactory(factory).addImplementation(address(new TokenERC721()));
82+
TWFactory(factory).addImplementation(address(new TokenERC1155()));
8483
TWFactory(factory).addImplementation(address(new DropERC20()));
8584
TWFactory(factory).addImplementation(address(new MockContract(bytes32("DropERC721"), 1)));
8685
TWFactory(factory).addImplementation(address(new DropERC721()));
@@ -89,8 +88,8 @@ abstract contract BaseTest is DSTest, Test {
8988
TWFactory(factory).addImplementation(address(new MockContract(bytes32("SignatureDrop"), 1)));
9089
TWFactory(factory).addImplementation(address(new SignatureDrop()));
9190
TWFactory(factory).addImplementation(address(new MockContract(bytes32("Marketplace"), 1)));
92-
TWFactory(factory).addImplementation(address(new Marketplace(address(weth), fee)));
93-
TWFactory(factory).addImplementation(address(new Split(fee)));
91+
TWFactory(factory).addImplementation(address(new Marketplace(address(weth))));
92+
TWFactory(factory).addImplementation(address(new Split()));
9493
TWFactory(factory).addImplementation(address(new Multiwrap(address(weth))));
9594
TWFactory(factory).addImplementation(address(new MockContract(bytes32("Pack"), 1)));
9695
TWFactory(factory).addImplementation(address(new Pack(address(weth))));

0 commit comments

Comments
 (0)