@@ -37,9 +37,11 @@ contract Fraxiversarry is
3737 using ONFT721MsgCodec for bytes32 ;
3838
3939 address public constant WFRAX_ADDRESS = 0xFc00000000000000000000000000000000000002 ;
40+ uint256 public constant MAX_BASIS_POINTS = 1e4 ;
4041
4142 mapping (address erc20 = > uint256 price ) public mintPrices;
4243 mapping (address erc20 = > string uri ) public baseAssetTokenUris;
44+ mapping (address erc20 = > uint256 fee ) public collectedFees;
4345 mapping (uint256 index = > address erc20 ) public supportedErc20s;
4446 mapping (uint256 tokenId = > mapping (uint256 index = > address underlyingAsset )) public underlyingAssets;
4547 mapping (uint256 tokenId = > uint256 numberOfAssets ) public numberOfTokenUnderlyingAssets;
@@ -56,6 +58,7 @@ contract Fraxiversarry is
5658 uint256 public mintingLimit;
5759 uint256 public giftMintingLimit;
5860 uint256 public giftMintingPrice;
61+ uint256 public mintingFeeBasisPoints;
5962
6063 bool private _isBridgeOperation;
6164
@@ -79,6 +82,7 @@ contract Fraxiversarry is
7982 giftMintingPrice = 50 * 1e18 ; // 50 WFRAX
8083 nextGiftTokenId = mintingLimit;
8184 nextPremiumTokenId = mintingLimit + giftMintingLimit;
85+ mintingFeeBasisPoints = 25 ; // 0.25%
8286
8387 //TODO: Set correct URIs
8488 giftTokenUri = "https://gift.tba.frax/ " ;
@@ -298,6 +302,41 @@ contract Fraxiversarry is
298302 emit GiftMintPriceUpdated (previousPrice, newPrice);
299303 }
300304
305+ function updateMintingFeeBasisPoints (uint256 newFeeBasisPoints ) public onlyOwner {
306+ if (newFeeBasisPoints > MAX_BASIS_POINTS) revert OutOfBounds ();
307+
308+ uint256 previousFeeBasisPoints = mintingFeeBasisPoints;
309+ mintingFeeBasisPoints = newFeeBasisPoints;
310+
311+ emit MintingFeeUpdated (previousFeeBasisPoints, newFeeBasisPoints);
312+ }
313+
314+ function retrieveCollectedFees (address erc20Contract , address to ) public onlyOwner {
315+ uint256 feeAmount = collectedFees[erc20Contract];
316+ if (feeAmount == 0 ) return ;
317+
318+ collectedFees[erc20Contract] = 0 ;
319+ if (! IERC20 (erc20Contract).transfer (to, feeAmount)) revert TransferFailed ();
320+
321+ emit FeesRetrieved (erc20Contract, to, feeAmount);
322+ }
323+
324+ function getMintingPriceWithFee (address erc20Contract )
325+ public
326+ view
327+ returns (uint256 mintPrice , uint256 fee , uint256 totalPrice )
328+ {
329+ mintPrice = mintPrices[erc20Contract];
330+ fee = (mintPrice * mintingFeeBasisPoints) / MAX_BASIS_POINTS;
331+ totalPrice = mintPrice + fee;
332+ }
333+
334+ function getGiftMintingPriceWithFee () public view returns (uint256 mintPrice , uint256 fee , uint256 totalPrice ) {
335+ mintPrice = giftMintingPrice;
336+ fee = (mintPrice * mintingFeeBasisPoints) / MAX_BASIS_POINTS;
337+ totalPrice = mintPrice + fee;
338+ }
339+
301340 function getUnderlyingTokenIds (uint256 premiumTokenId )
302341 external
303342 view
@@ -513,15 +552,19 @@ contract Fraxiversarry is
513552
514553 function _transferERC20ToToken (address erc20Contract , uint256 tokenId , address from , uint256 amount ) internal {
515554 IERC20 erc20Token = IERC20 (erc20Contract);
555+ uint256 fee = (amount * mintingFeeBasisPoints) / MAX_BASIS_POINTS;
556+ uint256 amountWithFee = amount + fee;
516557
517- if (erc20Token.allowance (from, address (this )) < amount ) revert InsufficientAllowance ();
518- if (erc20Token.balanceOf (from) < amount ) revert InsufficientBalance ();
558+ if (erc20Token.allowance (from, address (this )) < amountWithFee ) revert InsufficientAllowance ();
559+ if (erc20Token.balanceOf (from) < amountWithFee ) revert InsufficientBalance ();
519560
520- if (! erc20Token.transferFrom (from, address (this ), amount )) revert TransferFailed ();
561+ if (! erc20Token.transferFrom (from, address (this ), amountWithFee )) revert TransferFailed ();
521562
522563 erc20Balances[tokenId][erc20Contract] += amount;
564+ collectedFees[erc20Contract] += fee;
523565
524566 emit ReceivedERC20 (erc20Contract, tokenId, from, amount);
567+ emit FeeCollected (erc20Contract, from, fee);
525568 }
526569
527570 // ********** Internal functions to facilitate the ONFT operations **********
0 commit comments