Skip to content

deploy config poc #684

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions contracts/extension/interface/IMintFeeManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

interface IMintFeeManager {
function calculatePlatformFeeAndRecipient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the actual implementation of this?

also was thinking of keeping the naming a bit generic, drop the 'mint' from it since it can be for all sorts of fees

uint256 _price
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here i think it makes sense to send some sort of 'source' or 'id' that the calling contract would pass. For example for drop721 it could pass "dropERC721". that way the fee manager can decide to change the fees for different contracts based on that passed 'id'.

ie. maybe marketplace has a diff fee than a drop erc721

) external view returns (uint256 platformFee, address feeRecipient);
}
23 changes: 17 additions & 6 deletions contracts/prebuilts/drop/DropERC721.sol
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ import "../../extension/LazyMint.sol";
import "../../extension/PermissionsEnumerable.sol";
import "../../extension/Drop.sol";

import "../../extension/interface/IMintFeeManager.sol";

contract DropERC721 is
Initializable,
ContractMetadata,
@@ -68,20 +70,21 @@ 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 = 100;

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

address public immutable mintFeeManager;

/// @dev Emitted when the global max supply of tokens is updated.
event MaxTotalSupplyUpdated(uint256 maxTotalSupply);

/*///////////////////////////////////////////////////////////////
Constructor + initializer logic
//////////////////////////////////////////////////////////////*/

constructor() initializer {}
constructor(address _mintFeeManager) initializer {
mintFeeManager = _mintFeeManager;
}

/// @dev Initializes the contract, like a constructor.
function initialize(
@@ -264,8 +267,16 @@ 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;
address _mintFeeManager = mintFeeManager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont really need this var

uint256 platformFeesTw = 0;
address feeRecipientTw;
if (_mintFeeManager != address(0)) {
(platformFeesTw, feeRecipientTw) = IMintFeeManager(_mintFeeManager).calculatePlatformFeeAndRecipient(
totalPrice
);
}

bool validMsgValue;
if (_currency == CurrencyTransferLib.NATIVE_TOKEN) {
@@ -275,7 +286,7 @@ contract DropERC721 is
}
require(validMsgValue, "!V");

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), DEFAULT_FEE_RECIPIENT, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), feeRecipientTw, platformFeesTw);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ import { TWProxy } from "contracts/infra/TWProxy.sol";
import "../../../utils/BaseTest.sol";

contract HarnessDropERC721 is DropERC721 {
constructor() DropERC721(address(new MockMintFeeManager(0x1Af20C6B23373350aD464700B5965CE4B0D2aD94, 100))) {}

function collectionPriceOnClaim(
address _primarySaleRecipient,
uint256 _quantityToClaim,
@@ -50,7 +52,7 @@ contract DropERC721Test_collectPrice is BaseTest {

dropImp = address(new HarnessDropERC721());
proxy = HarnessDropERC721(address(new TWProxy(dropImp, initializeData)));
defaultFeeRecipient = proxy.DEFAULT_FEE_RECIPIENT();
defaultFeeRecipient = DEFAULT_FEE_RECIPIENT;
}

modifier pricePerTokenZero() {
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import "erc721a-upgradeable/contracts/IERC721AUpgradeable.sol";
import "../../../utils/BaseTest.sol";

contract HarnessDropERC721 is DropERC721 {
constructor() DropERC721(address(new MockMintFeeManager(0x1Af20C6B23373350aD464700B5965CE4B0D2aD94, 100))) {}

function transferTokensOnClaim(address _to, uint256 _quantityToClaim) public payable {
_transferTokensOnClaim(_to, _quantityToClaim);
}
2 changes: 2 additions & 0 deletions src/test/drop/drop-erc721/miscellaneous/miscellaneous.t.sol
Original file line number Diff line number Diff line change
@@ -189,6 +189,8 @@ contract DropERC721Test_misc is BaseTest {
}

contract HarnessDropERC721MsgData is DropERC721 {
constructor() DropERC721(address(new MockMintFeeManager(0x1Af20C6B23373350aD464700B5965CE4B0D2aD94, 100))) {}

function msgData() public view returns (bytes memory) {
return _msgData();
}
19 changes: 19 additions & 0 deletions src/test/mocks/MockMintFeeManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

contract MockMintFeeManager {
address public feeRecipient;
uint256 public feeBps;

constructor(address _feeRecipient, uint256 _feeBps) {
feeRecipient = _feeRecipient;
feeBps = _feeBps;
}

function calculatePlatformFeeAndRecipient(
uint256 _price
) external view returns (uint256 _platformFee, address _feeRecipient) {
_platformFee = (_price * feeBps) / 10_000;
_feeRecipient = feeRecipient;
}
}
8 changes: 7 additions & 1 deletion src/test/utils/BaseTest.sol
Original file line number Diff line number Diff line change
@@ -49,12 +49,15 @@ import { ERC721Holder, IERC721Receiver } from "@openzeppelin/contracts/token/ERC
import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol";
import { Strings } from "contracts/lib/Strings.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { MockMintFeeManager } from "../mocks/MockMintFeeManager.sol";

abstract contract BaseTest is DSTest, Test {
string public constant NAME = "NAME";
string public constant SYMBOL = "SYMBOL";
string public constant CONTRACT_URI = "CONTRACT_URI";
address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant DEFAULT_FEE_RECIPIENT = 0x1Af20C6B23373350aD464700B5965CE4B0D2aD94;
uint16 public constant DEFAULT_FEE_BPS = 100;

MockERC20 public erc20;
MockERC20 public erc20Aux;
@@ -63,6 +66,7 @@ abstract contract BaseTest is DSTest, Test {
MockERC721NonBurnable public erc721NonBurnable;
MockERC1155NonBurnable public erc1155NonBurnable;
WETH9 public weth;
MockMintFeeManager public mintFeeManager;

address public forwarder;
address public eoaForwarder;
@@ -121,6 +125,8 @@ abstract contract BaseTest is DSTest, Test {
contractPublisher = address(new ContractPublisher(factoryAdmin, forwarders(), new MockContractPublisher()));
linkToken = address(new Link());
vrfV2Wrapper = address(new VRFV2Wrapper());
mintFeeManager = new MockMintFeeManager(DEFAULT_FEE_RECIPIENT, DEFAULT_FEE_BPS);

TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), factory);
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), contractPublisher);

@@ -129,7 +135,7 @@ abstract contract BaseTest is DSTest, Test {
TWFactory(factory).addImplementation(address(new TokenERC1155()));
TWFactory(factory).addImplementation(address(new DropERC20()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("DropERC721"), 1)));
TWFactory(factory).addImplementation(address(new DropERC721()));
TWFactory(factory).addImplementation(address(new DropERC721(address(mintFeeManager))));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("DropERC1155"), 1)));
TWFactory(factory).addImplementation(address(new DropERC1155()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("SignatureDrop"), 1)));