-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoyaltyFeeRegistry.sol
99 lines (86 loc) · 3.21 KB
/
RoyaltyFeeRegistry.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IRoyaltyFeeRegistry} from "../interfaces/IRoyaltyFeeRegistry.sol";
/**
* @title RoyaltyFeeRegistry
* @notice It is a royalty fee registry for the LooksRare exchange.
*/
contract RoyaltyFeeRegistry is IRoyaltyFeeRegistry, Ownable {
struct FeeInfo {
address setter;
address receiver;
uint256 fee;
}
// Limit (if enforced for fee royalty in percentage (10,000 = 100%)
uint256 public royaltyFeeLimit;
mapping(address => FeeInfo) private _royaltyFeeInfoCollection;
event NewRoyaltyFeeLimit(uint256 royaltyFeeLimit);
event RoyaltyFeeUpdate(address indexed collection, address indexed setter, address indexed receiver, uint256 fee);
/**
* @notice Constructor
* @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%)
*/
constructor(uint256 _royaltyFeeLimit) {
require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high");
royaltyFeeLimit = _royaltyFeeLimit;
}
/**
* @notice Update royalty info for collection
* @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%)
*/
function updateRoyaltyFeeLimit(uint256 _royaltyFeeLimit) external override onlyOwner {
require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high");
royaltyFeeLimit = _royaltyFeeLimit;
emit NewRoyaltyFeeLimit(_royaltyFeeLimit);
}
/**
* @notice Update royalty info for collection
* @param collection address of the NFT contract
* @param setter address that sets the receiver
* @param receiver receiver for the royalty fee
* @param fee fee (500 = 5%, 1,000 = 10%)
*/
function updateRoyaltyInfoForCollection(
address collection,
address setter,
address receiver,
uint256 fee
) external override onlyOwner {
require(fee <= royaltyFeeLimit, "Registry: Royalty fee too high");
_royaltyFeeInfoCollection[collection] = FeeInfo({setter: setter, receiver: receiver, fee: fee});
emit RoyaltyFeeUpdate(collection, setter, receiver, fee);
}
/**
* @notice Calculate royalty info for a collection address and a sale gross amount
* @param collection collection address
* @param amount amount
* @return receiver address and amount received by royalty recipient
*/
function royaltyInfo(address collection, uint256 amount) external view override returns (address, uint256) {
return (
_royaltyFeeInfoCollection[collection].receiver,
(amount * _royaltyFeeInfoCollection[collection].fee) / 10000
);
}
/**
* @notice View royalty info for a collection address
* @param collection collection address
*/
function royaltyFeeInfoCollection(address collection)
external
view
override
returns (
address,
address,
uint256
)
{
return (
_royaltyFeeInfoCollection[collection].setter,
_royaltyFeeInfoCollection[collection].receiver,
_royaltyFeeInfoCollection[collection].fee
);
}
}