Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default configs #677

Merged
merged 8 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion contracts/prebuilts/drop/DropERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ contract DropERC1155 is
/// @dev Max bps in the thirdweb system.
uint256 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/*///////////////////////////////////////////////////////////////
Mappings
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -250,6 +253,7 @@ contract DropERC1155 is
: _primarySaleRecipient;

uint256 totalPrice = _quantityToClaim * _pricePerToken;
uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;

bool validMsgValue;
Expand All @@ -260,8 +264,14 @@ contract DropERC1155 is
}
require(validMsgValue, "!V");

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), _saleRecipient, totalPrice - platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
_saleRecipient,
totalPrice - platformFees - platformFeesTw
);
}

/// @dev Transfers the NFTs being claimed.
Expand Down
12 changes: 11 additions & 1 deletion contracts/prebuilts/drop/DropERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ contract DropERC20 is
/// @dev Max bps in the thirdweb system.
uint256 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/// @dev Global max total supply of tokens.
uint256 public maxTotalSupply;

Expand Down Expand Up @@ -157,6 +160,7 @@ contract DropERC20 is
uint256 totalPrice = (_quantityToClaim * _pricePerToken) / 1 ether;
require(totalPrice > 0, "quantity too low");

uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;

bool validMsgValue;
Expand All @@ -167,8 +171,14 @@ contract DropERC20 is
}
require(validMsgValue, "Invalid msg value");

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice - platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
saleRecipient,
totalPrice - platformFees - platformFeesTw
);
}

/// @dev Transfers the tokens being claimed.
Expand Down
12 changes: 11 additions & 1 deletion contracts/prebuilts/drop/DropERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ contract DropERC721 is
/// @dev Max bps in the thirdweb system.
uint256 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/// @dev Global max total supply of NFTs.
uint256 public maxTotalSupply;

Expand Down Expand Up @@ -261,6 +264,7 @@ contract DropERC721 is
address saleRecipient = _primarySaleRecipient == address(0) ? primarySaleRecipient() : _primarySaleRecipient;

uint256 totalPrice = _quantityToClaim * _pricePerToken;
uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;

bool validMsgValue;
Expand All @@ -271,8 +275,14 @@ contract DropERC721 is
}
require(validMsgValue, "!V");

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice - platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
saleRecipient,
totalPrice - platformFees - platformFeesTw
);
}

/// @dev Transfers the NFTs being claimed.
Expand Down
15 changes: 13 additions & 2 deletions contracts/prebuilts/loyalty/LoyaltyCard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ contract LoyaltyCard is
/// @dev Max bps in the thirdweb system.
uint256 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/*///////////////////////////////////////////////////////////////
Constructor + initializer
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -226,6 +229,8 @@ contract LoyaltyCard is
uint256 fees;
address feeRecipient;

uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;

PlatformFeeType feeType = getPlatformFeeType();
if (feeType == PlatformFeeType.Flat) {
(feeRecipient, fees) = getFlatPlatformFeeInfo();
Expand All @@ -235,10 +240,16 @@ contract LoyaltyCard is
fees = (totalPrice * platformFeeBps) / MAX_BPS;
}

require(totalPrice >= fees, "Fees greater than price");
require(totalPrice >= fees + platformFeesTw, "Fees greater than price");

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), feeRecipient, fees);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice - fees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
saleRecipient,
totalPrice - fees - platformFeesTw
);
}

/// @dev Mints an NFT to `to`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuard, ERC2771Context
/// @dev The max bps of the contract. So, 10_000 == 100 %
uint64 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/// @dev The address of the native token wrapper contract.
address private immutable nativeTokenWrapper;

Expand Down Expand Up @@ -500,10 +503,18 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuard, ERC2771Context

// Payout platform fee
{
uint256 platformFeesTw = (_totalPayoutAmount * DEFAULT_FEE_BPS) / MAX_BPS;
(address platformFeeRecipient, uint16 platformFeeBps) = IPlatformFee(address(this)).getPlatformFeeInfo();
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;

// Transfer platform fee
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
DEFAULT_FEE_RECIPIENT,
platformFeesTw,
_nativeTokenWrapper
);
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
Expand All @@ -512,7 +523,7 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuard, ERC2771Context
_nativeTokenWrapper
);

amountRemaining = _totalPayoutAmount - platformFeeCut;
amountRemaining = _totalPayoutAmount - platformFeeCut - platformFeesTw;
}

// Payout royalties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ contract EnglishAuctionsLogic is IEnglishAuctions, ReentrancyGuard, ERC2771Conte
/// @dev The max bps of the contract. So, 10_000 == 100 %
uint64 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/// @dev The address of the native token wrapper contract.
address private immutable nativeTokenWrapper;

Expand Down Expand Up @@ -467,10 +470,18 @@ contract EnglishAuctionsLogic is IEnglishAuctions, ReentrancyGuard, ERC2771Conte

// Payout platform fee
{
uint256 platformFeesTw = (_totalPayoutAmount * DEFAULT_FEE_BPS) / MAX_BPS;
(address platformFeeRecipient, uint16 platformFeeBps) = IPlatformFee(address(this)).getPlatformFeeInfo();
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;

// Transfer platform fee
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
DEFAULT_FEE_RECIPIENT,
platformFeesTw,
_nativeTokenWrapper
);
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
Expand All @@ -479,7 +490,7 @@ contract EnglishAuctionsLogic is IEnglishAuctions, ReentrancyGuard, ERC2771Conte
_nativeTokenWrapper
);

amountRemaining = _totalPayoutAmount - platformFeeCut;
amountRemaining = _totalPayoutAmount - platformFeeCut - platformFeesTw;
}

// Payout royalties
Expand Down
13 changes: 12 additions & 1 deletion contracts/prebuilts/marketplace/offers/OffersLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ contract OffersLogic is IOffers, ReentrancyGuard, ERC2771ContextConsumer {
/// @dev The max bps of the contract. So, 10_000 == 100 %
uint64 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/*///////////////////////////////////////////////////////////////
Modifiers
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -285,10 +288,18 @@ contract OffersLogic is IOffers, ReentrancyGuard, ERC2771ContextConsumer {

// Payout platform fee
{
uint256 platformFeesTw = (_totalPayoutAmount * DEFAULT_FEE_BPS) / MAX_BPS;
(address platformFeeRecipient, uint16 platformFeeBps) = IPlatformFee(address(this)).getPlatformFeeInfo();
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;

// Transfer platform fee
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
DEFAULT_FEE_RECIPIENT,
platformFeesTw,
address(0)
);
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
Expand All @@ -297,7 +308,7 @@ contract OffersLogic is IOffers, ReentrancyGuard, ERC2771ContextConsumer {
address(0)
);

amountRemaining = _totalPayoutAmount - platformFeeCut;
amountRemaining = _totalPayoutAmount - platformFeeCut - platformFeesTw;
}

// Payout royalties
Expand Down
15 changes: 13 additions & 2 deletions contracts/prebuilts/open-edition/OpenEditionERC721FlatFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ contract OpenEditionERC721FlatFee is
/// @dev Max bps in the thirdweb system.
uint256 private constant MAX_BPS = 10_000;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

/*///////////////////////////////////////////////////////////////
Constructor + initializer logic
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -157,14 +160,16 @@ contract OpenEditionERC721FlatFee is
uint256 platformFees;
address platformFeeRecipient;

uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;

if (getPlatformFeeType() == IPlatformFee.PlatformFeeType.Flat) {
(platformFeeRecipient, platformFees) = getFlatPlatformFeeInfo();
} else {
(address recipient, uint16 platformFeeBps) = getPlatformFeeInfo();
platformFeeRecipient = recipient;
platformFees = ((totalPrice * platformFeeBps) / MAX_BPS);
}
require(totalPrice >= platformFees, "price less than platform fee");
require(totalPrice >= platformFees + platformFeesTw, "price less than platform fee");

bool validMsgValue;
if (_currency == CurrencyTransferLib.NATIVE_TOKEN) {
Expand All @@ -176,8 +181,14 @@ contract OpenEditionERC721FlatFee is

address saleRecipient = _primarySaleRecipient == address(0) ? primarySaleRecipient() : _primarySaleRecipient;

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice - platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
saleRecipient,
totalPrice - platformFees - platformFeesTw
);
}

/// @dev Transfers the NFTs being claimed.
Expand Down
14 changes: 12 additions & 2 deletions contracts/prebuilts/token/TokenERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ contract TokenERC1155 is
bytes32 private constant MODULE_TYPE = bytes32("TokenERC1155");
uint256 private constant VERSION = 1;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

// Token name
string public name;

Expand Down Expand Up @@ -447,10 +450,11 @@ contract TokenERC1155 is
}

uint256 totalPrice = _req.pricePerToken * _req.quantity;
uint256 platformFeesTw = (totalPrice * DEFAULT_FEE_BPS) / MAX_BPS;
uint256 platformFees = platformFeeType == PlatformFeeType.Flat
? flatPlatformFee
: ((totalPrice * platformFeeBps) / MAX_BPS);
require(totalPrice >= platformFees, "price less than platform fee");
require(totalPrice >= platformFees + platformFeesTw, "price less than platform fee");

if (_req.currency == CurrencyTransferLib.NATIVE_TOKEN) {
require(msg.value == totalPrice, "must send total price.");
Expand All @@ -462,8 +466,14 @@ contract TokenERC1155 is
? primarySaleRecipient
: _req.primarySaleRecipient;

CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), saleRecipient, totalPrice - platformFees);
CurrencyTransferLib.transferCurrency(
_req.currency,
_msgSender(),
saleRecipient,
totalPrice - platformFees - platformFeesTw
);
}

/// ===== Low-level overrides =====
Expand Down
12 changes: 11 additions & 1 deletion contracts/prebuilts/token/TokenERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ contract TokenERC20 is
bytes32 private constant MODULE_TYPE = bytes32("TokenERC20");
uint256 private constant VERSION = 1;

address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 private constant DEFAULT_FEE_BPS = 250;

bytes32 private constant TYPEHASH =
keccak256(
"MintRequest(address to,address primarySaleRecipient,uint256 quantity,uint256 price,address currency,uint128 validityStartTimestamp,uint128 validityEndTimestamp,bytes32 uid)"
Expand Down Expand Up @@ -215,6 +218,7 @@ contract TokenERC20 is
return;
}

uint256 platformFeesTw = (_req.price * DEFAULT_FEE_BPS) / MAX_BPS;
uint256 platformFees = (_req.price * platformFeeBps) / MAX_BPS;

if (_req.currency == CurrencyTransferLib.NATIVE_TOKEN) {
Expand All @@ -227,8 +231,14 @@ contract TokenERC20 is
? primarySaleRecipient
: _req.primarySaleRecipient;

CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(_req.currency, _msgSender(), saleRecipient, _req.price - platformFees);
CurrencyTransferLib.transferCurrency(
_req.currency,
_msgSender(),
saleRecipient,
_req.price - platformFees - platformFeesTw
);
}

/// @dev Mints `amount` of tokens to `to`
Expand Down
Loading
Loading