@@ -14,6 +14,9 @@ contract Hyperfund is AccessControlUpgradeable, PausableUpgradeable, UUPSUpgrade
1414 uint256 public hypercertId;
1515 uint256 public hypercertTypeId;
1616 uint256 public hypercertUnits;
17+ address public feeRecipient;
18+ /// @notice fee percentage, 10000 = 100%
19+ uint256 public feePercentage;
1720
1821 // erc20 token allowlist, 0 means the token is not allowed
1922 // negative multiplier means the total amount of Hypercert units is smaller than the amount of tokens it represents and rounding is applied
@@ -66,7 +69,9 @@ contract Hyperfund is AccessControlUpgradeable, PausableUpgradeable, UUPSUpgrade
6669 address _admin ,
6770 address _manager ,
6871 address _pauser ,
69- address _upgrader
72+ address _upgrader ,
73+ address _feeRecipient ,
74+ uint256 _feePercentage
7075 ) public initializer {
7176 __AccessControl_init ();
7277 __Pausable_init ();
@@ -81,6 +86,8 @@ contract Hyperfund is AccessControlUpgradeable, PausableUpgradeable, UUPSUpgrade
8186 hypercertTypeId = _hypercertTypeId;
8287 hypercertId = hypercertTypeId + 1 ;
8388 hypercertUnits = hypercertMinter.unitsOf (hypercertId);
89+ feeRecipient = _feeRecipient;
90+ feePercentage = _feePercentage;
8491 }
8592
8693 function _authorizeUpgrade (address newImplementation ) internal override onlyRole (UPGRADER_ROLE) {}
@@ -163,10 +170,14 @@ contract Hyperfund is AccessControlUpgradeable, PausableUpgradeable, UUPSUpgrade
163170 uint256 units = _tokenAmountToUnits (_token, _amount);
164171 uint256 availableSupply = hypercertMinter.unitsOf (hypercertId);
165172 require (availableSupply >= units, AmountExceedsAvailableSupply (availableSupply));
173+ uint256 feeAmount = (_amount * feePercentage) / 10000 ;
166174 if (_token == address (0 )) {
167175 require (msg .value == _amount, InvalidAmount ());
176+ (bool success ,) = payable (feeRecipient).call {value: feeAmount}("" );
177+ require (success, TransferFailed ());
168178 } else {
169179 require (IERC20 (_token).transferFrom (msg .sender , address (this ), _amount), TransferFailed ());
180+ require (IERC20 (_token).transfer (feeRecipient, feeAmount), TransferFailed ());
170181 }
171182 _mintFraction (msg .sender , units);
172183 emit Funded (_token, _amount);
0 commit comments