-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor royalty #440
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
base: dev
Are you sure you want to change the base?
Refactor royalty #440
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ node_modules | |
#Hardhat files | ||
cache | ||
artifacts | ||
.openzeppelin/* | ||
workspace.code-workspace |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,9 +94,10 @@ contract NonFungibleRegistryEnumerableUpgradeable is | |
address public burnAddress; | ||
|
||
/// @notice The amount in basis points of registrationFee to send to the burnAddress account | ||
/// @notice This variable must be less than or equal to 10000 | ||
/// @notice This variable must be less than or equal to 10000 / burnDenom | ||
uint256 public burnFee; | ||
|
||
|
||
/** @dev address of primary NFR registry required for participation | ||
* if the primaryRegistry is address(0), then this variable is ignored | ||
* if the primaryRegistry is an ERC721, then the recipient of an NFI must | ||
|
@@ -125,6 +126,10 @@ contract NonFungibleRegistryEnumerableUpgradeable is | |
/// @dev The REGISTRAR_ROLE_ADMIN curates the address with REGISTRAR_ROLE permissions | ||
bytes32 public constant REGISTRAR_ROLE_ADMIN = keccak256("REGISTRAR_ROLE_ADMIN"); | ||
|
||
|
||
/// @notice used to calculate burn % in calculating royaltyAmount | ||
uint constant burnDenom = 10000; | ||
|
||
/** | ||
* @dev Emitted when updateLabel is called successfully | ||
*/ | ||
|
@@ -143,7 +148,7 @@ contract NonFungibleRegistryEnumerableUpgradeable is | |
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() initializer {} | ||
|
||
/// @notice initialize is called once on the creation of an upgradable proxy | ||
/// @notice initialize is called once on the creation of an upgradable proxy. | ||
/// @dev can only be called once due to the initializer modifier | ||
/// @param name_ name to be given to the Non Fungible Registry | ||
/// @param symbol_ shorthand symbol to be given to the Non Fungible Registry | ||
|
@@ -273,7 +278,8 @@ contract NonFungibleRegistryEnumerableUpgradeable is | |
|
||
_createLabeledToken(to, label, registrationData, tokenId); | ||
|
||
uint256 burnAmount = registrationFee * burnFee / 10000; | ||
uint256 burnAmount = calculateRoyalty(registrationFee); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the intended functionality; this function costs "registration token" (ie Hypertoken) to use, and isn't/shouldn't be related to the royalties at all. |
||
|
||
IERC20Upgradeable(registrationToken).transfer(burnAddress, burnAmount); | ||
// the fee stays with the token, not the token owner | ||
identityStakes[tokenId] = Fee(registrationToken, registrationFee-burnAmount); | ||
|
@@ -443,12 +449,16 @@ contract NonFungibleRegistryEnumerableUpgradeable is | |
} | ||
} | ||
|
||
function calculateRoyalty(uint256 salePrice) internal view returns(uint256 amount) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can change this to |
||
amount = salePrice * burnFee / burnDenom; | ||
} | ||
|
||
function royaltyInfo(uint256 tokenId, uint256 salePrice) | ||
external | ||
view | ||
override(IERC2981Upgradeable) | ||
returns (address receiver, uint256 royaltyAmount) { | ||
royaltyAmount = salePrice * burnFee / 10000; | ||
royaltyAmount = calculateRoyalty(salePrice); | ||
receiver = burnAddress; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to uint256