Skip to content

Commit 0201904

Browse files
committed
Refactor HostIt fee logic and update interface docs
Replaced dynamic HostIt fee basis points with a constant, refactored fee calculation to use pure functions, and removed related setter logic. Updated IMarketplace interface with detailed documentation and adjusted function signatures. Added HOST_IT_SALT to .env.example for deployment configuration.
1 parent 9cb8d42 commit 0201904

File tree

6 files changed

+71
-26
lines changed

6 files changed

+71
-26
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ AVALANCHE_FUJI_VERIFIER_URL=https://api.routescan.io/v2/network/testnet/evm/4311
2727

2828
# ACCOUNTS
2929
ACCOUNT=
30-
WALLET_ADDR=
30+
WALLET_ADDR=
31+
32+
# SALT
33+
HOST_IT_SALT=

script/DeployHostItTickets.s.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ contract DeployHostItTicketsTest is Script, DeployHostItTicketsHelper {
4949

5050
// Deploy HostItTickets diamond
5151
hostIt_ = address(
52-
new HostItTickets(
52+
new HostItTickets{
53+
salt: vm.envBytes32("HOST_IT_SALT")
54+
}(
5355
_createFacetCuts(
5456
diamondCutFacet, diamondLoupeFacet, ownableRolesFacet, factoryFacet, checkInFacet, marketplaceFacet
5557
),

src/facets/MarketplaceFacet.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ contract MarketplaceFacet is IMarketplace {
6464
return _feeType._getHostItBalance();
6565
}
6666

67-
function calculateHostItFee(uint256 _fee) external view returns (uint256) {
68-
return _fee._calculateHostItFee();
69-
}
70-
7167
//*//////////////////////////////////////////////////////////////////////////
7268
// PURE FUNCTIONS
7369
//////////////////////////////////////////////////////////////////////////*//
7470

71+
function getHostItFee(uint256 _fee) external pure returns (uint256) {
72+
return _fee._getHostItFee();
73+
}
74+
7575
function getRefundPeriod() external pure returns (uint256) {
7676
return LibMarketplace.REFUND_PERIOD;
7777
}

src/inits/HostItInit.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
pragma solidity 0.8.30;
33

4-
import {LibDiamond} from "@diamond/libraries/LibDiamond.sol";
54
import {FeeType} from "@ticket-storage/MarketplaceStorage.sol";
6-
import {ITicket} from "@ticket/interfaces/ITicket.sol";
75
import {LibFactory} from "@ticket/libs/LibFactory.sol";
86
import {LibMarketplace} from "@ticket/libs/LibMarketplace.sol";
97

108
event HostItInitialized();
119

1210
contract HostItInit {
1311
function initHostIt(address _ticketProxy, FeeType[] calldata _feeTypes, address[] calldata _tokens) public {
14-
LibDiamond._diamondStorage().supportedInterfaces[type(ITicket).interfaceId] = true;
1512
LibFactory._factoryStorage().ticketProxy = _ticketProxy;
1613
LibMarketplace._setFeeTokenAddresses(_feeTypes, _tokens);
17-
LibMarketplace._setHostItFeeBps(300);
1814
emit HostItInitialized();
1915
}
2016
}

src/interfaces/IMarketplace.sol

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,98 @@ pragma solidity 0.8.30;
33

44
import {FeeType} from "@ticket-storage/MarketplaceStorage.sol";
55

6+
/// @title Marketplace interface
7+
/// @notice Interface for the Marketplace facet
8+
/// @author HostIt Protocol
69
interface IMarketplace {
710
//*//////////////////////////////////////////////////////////////////////////
811
// EXTERNAL FUNCTIONS
912
//////////////////////////////////////////////////////////////////////////*//
1013

14+
/// @notice Mints a ticket for the specified buyer
15+
/// @param ticketId The ID of the ticket to mint
16+
/// @param feeType The type of fee to use for the ticket
17+
/// @param buyer The address of the buyer
18+
/// @return The token ID of the minted ticket
1119
function mintTicket(uint64 ticketId, FeeType feeType, address buyer) external payable returns (uint40);
1220

21+
/// @notice Sets the fees for the specified ticket
22+
/// @param ticketId The ID of the ticket to set fees for
23+
/// @param feeTypes The types of fees to set
24+
/// @param fees The fees to set
1325
function setTicketFees(uint64 ticketId, FeeType[] calldata feeTypes, uint256[] calldata fees) external;
1426

27+
/// @notice Claims a refund for the specified ticket
28+
/// @param ticketId The ID of the ticket to claim a refund for
29+
/// @param feeType The type of fee to claim a refund for
30+
/// @param tokenId The token ID of the ticket to claim a refund for
31+
/// @param to The address to send the refund to
1532
function claimRefund(uint64 ticketId, FeeType feeType, uint256 tokenId, address to) external;
1633

34+
/// @notice Withdraws the ticket balance for the specified ticket
35+
/// @param ticketId The ID of the ticket to withdraw the balance for
36+
/// @param feeType The type of fee to withdraw the balance for
37+
/// @param to The address to send the balance to
1738
function withdrawTicketBalance(uint64 ticketId, FeeType feeType, address to) external;
1839

40+
/// @notice Withdraws the HostIt balance for the specified fee type
41+
/// @param feeType The type of fee to withdraw the balance for
42+
/// @param to The address to send the balance to
1943
function withdrawHostItBalance(FeeType feeType, address to) external;
2044

2145
//*//////////////////////////////////////////////////////////////////////////
2246
// VIEW FUNCTIONS
2347
//////////////////////////////////////////////////////////////////////////*//
2448

49+
/// @notice Checks if the specified fee type is enabled for the specified ticket
50+
/// @param ticketId The ID of the ticket to check
51+
/// @param feeType The type of fee to check
52+
/// @return True if the fee type is enabled, false otherwise
2553
function isFeeEnabled(uint64 ticketId, FeeType feeType) external view returns (bool);
2654

55+
/// @notice Gets the address of the fee token for the specified fee type
56+
/// @param feeType The type of fee to get the address for
57+
/// @return The address of the fee token
2758
function getFeeTokenAddress(FeeType feeType) external view returns (address);
2859

60+
/// @notice Gets the fee for the specified ticket and fee type
61+
/// @param ticketId The ID of the ticket to get the fee for
62+
/// @param feeType The type of fee to get
63+
/// @return The fee for the ticket and fee type
2964
function getTicketFee(uint64 ticketId, FeeType feeType) external view returns (uint256);
65+
66+
/// @notice Gets the fees for the specified ticket
67+
/// @param ticketId The ID of the ticket to get the fees for
68+
/// @param feeType The type of fee to get
69+
/// @return ticketFee The ticket fee for the ticket
70+
/// @return hostItFee The HostIt fee for the ticket
71+
/// @return totalFee The total fee for the ticket
3072
function getAllFees(uint64 ticketId, FeeType feeType)
3173
external
3274
view
3375
returns (uint256 ticketFee, uint256 hostItFee, uint256 totalFee);
3476

77+
/// @notice Gets the balance of the specified ticket for the specified fee type
78+
/// @param ticketId The ID of the ticket to get the balance for
79+
/// @param feeType The type of fee to get the balance for
80+
/// @return The balance of the ticket for the fee type
3581
function getTicketBalance(uint64 ticketId, FeeType feeType) external view returns (uint256);
3682

83+
/// @notice Gets the balance of HostIt for the specified fee type
84+
/// @param feeType The type of fee to get the balance for
85+
/// @return The balance of HostIt for the fee type
3786
function getHostItBalance(FeeType feeType) external view returns (uint256);
3887

39-
function calculateHostItFee(uint256 fee) external view returns (uint256);
40-
4188
//*//////////////////////////////////////////////////////////////////////////
4289
// PURE FUNCTIONS
4390
//////////////////////////////////////////////////////////////////////////*//
4491

92+
/// @notice Calculates the HostIt fee for the specified fee
93+
/// @param fee The fee to calculate the HostIt fee for
94+
/// @return The HostIt fee for the fee
95+
function getHostItFee(uint256 fee) external pure returns (uint256);
96+
97+
/// @notice Gets the refund period
98+
/// @return The refund period
4599
function getRefundPeriod() external pure returns (uint256);
46100
}

src/libs/LibMarketplace.sol

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,6 @@ library LibMarketplace {
220220
emit TicketFeeAddressSet(_feeTypes, _tokenAddresses);
221221
}
222222

223-
function _setHostItFeeBps(uint16 _hostItFeePercentage) internal {
224-
if (_hostItFeePercentage > HOSTIT_FEE_BPS) revert InvalidHostItFeeBps();
225-
_marketplaceStorage().hostItFeeBps = _hostItFeePercentage;
226-
emit HostItFeeBpsSet(_hostItFeePercentage);
227-
}
228-
229223
//*//////////////////////////////////////////////////////////////////////////
230224
// VIEW FUNCTIONS
231225
//////////////////////////////////////////////////////////////////////////*//
@@ -273,7 +267,7 @@ library LibMarketplace {
273267
returns (uint256 ticketFee_, uint256 hostItFee_, uint256 totalFee_)
274268
{
275269
ticketFee_ = _getTicketFee(_ticketId, _feeType);
276-
hostItFee_ = _calculateHostItFee(ticketFee_);
270+
hostItFee_ = _getHostItFee(ticketFee_);
277271
totalFee_ = ticketFee_ + hostItFee_;
278272
}
279273

@@ -283,7 +277,7 @@ library LibMarketplace {
283277
returns (uint256 ticketFee_, uint256 hostItFee_, uint256 totalFee_)
284278
{
285279
ticketFee_ = _getTicketFee(_ms, _ticketId, _feeType);
286-
hostItFee_ = _calculateHostItFee(_ms, ticketFee_);
280+
hostItFee_ = _getHostItFee(ticketFee_);
287281
totalFee_ = ticketFee_ + hostItFee_;
288282
}
289283

@@ -311,12 +305,8 @@ library LibMarketplace {
311305
if (_address.code.length > 0) revert ContractNotAllowed();
312306
}
313307

314-
function _calculateHostItFee(uint256 _fee) internal view returns (uint256) {
315-
return _calculateHostItFee(_marketplaceStorage(), _fee);
316-
}
317-
318-
function _calculateHostItFee(MarketplaceStorage storage _ms, uint256 _fee) internal view returns (uint256) {
319-
return ((_fee * _ms.hostItFeeBps) / FEE_BASIS_POINTS);
308+
function _getHostItFee(uint256 _fee) internal pure returns (uint256) {
309+
return ((_fee * HOSTIT_FEE_BPS) / FEE_BASIS_POINTS);
320310
}
321311

322312
//*//////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)