---
# System prepended metadata

title: Dillinger

---


<div style="text-align:center">
  <img src="https://avatars.githubusercontent.com/u/3339759?s=280&v=4" alt="Sublime's custom image"/>
</div>


# Brain Station 23 Ltd.

This report was made by 

| Name | Brain Station 23 ID | Official Email | Auditor Type |
| --- | --- | --- | --- | 
| [Sampad Sikder](https://www.linkedin.com/in/sampad-sikder-897b90200/) | BS1464 |sampad.sikder@brainstation-23.com  | External |
| [Mashiat Amin Farin](https://www.linkedin.com/in/mashiataminfarin/)| BS1463 |  mashiat.amin@brainstation-23.com | External|
| [Md. Ariful Islam](https://www.linkedin.com/in/engr-arif/) | BS1121 | ariful.islam@brainstation-23.com | Internal |




### Tools used 
- Solidity Metrics (IDE Extenstion)
- Slither
- Aderyn
<div style="text-align:left">
  <img src="https://tintinweb.gallerycdn.vsassets.io/extensions/tintinweb/solidity-metrics/0.0.23/1697194552562/Microsoft.VisualStudio.Services.Icons.Default" alt="Sublime's custom image"/ width ="10%">
    <img src="https://pypi-camo.freetls.fastly.net/7eddc9243716c076b02e313302c993d7293a45e7/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6372797469632f736c69746865722f6d61737465722f6c6f676f2e706e67" alt="Sublime's custom image"/ width ="25%">
        <img src="https://framerusercontent.com/images/JatrJSTzKGDcgdyx9sNdTbxtBjg.png" alt="Sublime's custom image"/ width ="25%">

</div>


### Standards used
- Rekt test
- Tincho Method
- [cyfrin.io standard](https://www.cyfrin.io/)

# Hotelereum NFT Market Audit Report

## Private Audit
A NFT Marketplace for Hotel Rooms and Holiday packages. Hotel partners can enlist their inventory price in stable coins. Users can purchase NFTs (Bookings) in MATIC coin or stable coin.


## Developer report
In progress
- how to setup project
npm install --force
install and run hardhat

- Commit Hash
e12d3e29ce9ae74774110d47b53d7e426ef08e64

- Repo URL: (https://github.com/nsal-ai/Blockchain-Web3/tree/develop)
Branch:Develop

- In scope vs out of scope contracts
./contract/
└── Hotelereum-NFT-Marketplace.sol


- Compatibilities
Solc Version: 0.8.19
Chain(s) to deploy contract to: Polygon Mumbai
Native Tokens: MATIC

### Security review scope (Unit Test and Coverage)
Hotelereum NFT Marketplace
    Deployment
      √ Should set the right Smart Contract owner (2319ms)
    Oracle
      √ Ask the oracle about MATIC price (117ms)
    On-Chain Inventory
      √ Should be able to enroll a hotel partner
      √ Should be able to manage inventory with Proper Stable-Coin Value (71ms)
    Super Admin NFT Mint
      √ Should mint an NFT by the Smart Contract owner where guest will be the owner of NFT (48ms)
      √ Should fail to mint if the sender is not actual Smart Contract owner
    Regular Guest NFT Mint
      √ Should mint if the sender is paying with crypto (117ms)
      √ Should primary market stakeholder's crypto balances got updated after a successful mint (94ms)
    NFT Reselling
      √ Should mark an NFT for resell when the sender is the current NFT owner (52ms)
      √ Should fail to mark NFT for resell when the sender is not the current NFT owner (46ms)
      √ Should be able to purchase resellable NFT as hotel reservation (92ms)
      √ Should secondary market stakeholder's crypto balances got updated after a successful sale (130ms)
    Smart Contract Ownership Transfer
      √ Should transfer the Smart Contract's ownership if the request is from current owner
      √ Should fail to transfer the Smart Contract's ownership if the sender is not current Smart Contract owner

 
  14 passing (3s)
  
 | File | % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
| --- | --- | --- | --- | --- | --- |
|contracts |    97.22 |    53.45 |     91.3 |    96.91 |     |
|  HotelereumNFTMarketplace.sol |    97.22 |    53.45 |     91.3 |    96.91 |     46,183,595 |
|All files                      |    97.22 |    53.45 |     91.3 |    96.91 | 

              

### Roles
- **Superadmin** 
Owner of smart contract
- **Hotel organizations**
Hotel Partners
- **NFT owners**
Guests or reservation owners

### Known issues

- createCryptoBooking - client requested back to back changes which caused to create a lot more parameters 
<mark>Struct will be introduced to deal with this issue </mark>


## Rekt Test (needs editing and spell check and icon adding)
- [x] Do you have all actors, roles and privileges documented? 
- [x] Do you keep documentation of all the external services, contracts, and oracles you rely on? 
- [ ] Do you have a written and tested incident response plan? 
- [ ] Do you document the best ways to attack your system? 
- [ ] Do you perform identity verification and background checks on all employees? 
- [x] Do you have a team member with securtity defined in their role 
- [ ] Do you require hardware security keys for production system (?)
- [ ] Does your key management system require multiple humans and physical steps? (?)(managed with ENV (12 Factor authentication))
- [x] Do you define key invariants for your system and test rthem on every commit? 
- [x] Do you use the best automated tools to discover security issues in your code? 
- [ ] Do you undergo external audits and maintain a vulneravbilitiy disclosue or bug bounty program? 
- [x] Have you considered and mitigated avenues for abusing users of your system? 


## Metrics report from .sol (Consensys Diligence)

### Files Summary 

| Key | Value |
| --- | --- |
| .sol Files | 1 |
| Total nSLOC | 348 |

### Files Details

| Type | File | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex Score | Capabilities |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 
| 📝🔍| HotelereumNFTMarketplace.sol | 1 | 1 | 601 | 502 | 348 | 109 | 165 |💰📤🔆Σ|




### Report Overview

The analysis finished with 0 errors and 0 duplicate files.


#### Risk 
![image](https://hackmd.io/_uploads/rJU-87rYa.png)



#### Inline documentation 
- Comment to source ratio: On average there are4.09 code lines per comment (lower=better).

#### Components 


## Issue Summary (From Aderyn)
 Category | No. of Issues |
| --- | --- |
| Critical | 0 |
| High | 0 |
| Medium | 1 |
| Low | 1 |
| NC | 3 |

##  Issues

### Medium Issues
- [ ] ***Centralization Issues***
Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds.
- Found in contracts/HotelereumNFTMarketplace.sol [Line: 245](contracts/HotelereumNFTMarketplace.sol#L245)

	```solidity
	        onlyOwner
	```

### Low Issues
- [ ] ***L-1: Unsafe ERC20 Operations should not be used***

ERC20 functions may not behave as expected. For example: return values are not always meaningful. It is recommended to use OpenZeppelin's SafeERC20 library.

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 410](contracts/HotelereumNFTMarketplace.sol#L410)

	```solidity
	        idToMarketItem[_tokenId].hotel.transfer(primaryHotelFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 411](contracts/HotelereumNFTMarketplace.sol#L411)

	```solidity
	        payable(owner()).transfer(primaryPlatformFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 436](contracts/HotelereumNFTMarketplace.sol#L436)

	```solidity
	        idToMarketItem[_tokenId].hotel.transfer(secondaryHotelFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 437](contracts/HotelereumNFTMarketplace.sol#L437)

	```solidity
	        payable(owner()).transfer(secondaryPlatformFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 438](contracts/HotelereumNFTMarketplace.sol#L438)

	```solidity
	        sellerWallet.transfer(secondaryOwnerFee);
	```



### NC Issues

- [ ] ***NC-1: Functions not used internally could be marked external***



- Found in contracts/HotelereumNFTMarketplace.sol [Line: 30](contracts/HotelereumNFTMarketplace.sol#L30)

	```solidity
	    function initialize(address _maticOracleRoute) public initializer {
	```


- Found in contracts/HotelereumNFTMarketplace.sol [Line: 322](contracts/HotelereumNFTMarketplace.sol#L322)

	```solidity
	    function createBookingTwin(
	```


- Found in contracts/HotelereumNFTMarketplace.sol [Line: 358](contracts/HotelereumNFTMarketplace.sol#L358)

	```solidity
	    function createCryptoBookingTwin(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 492](contracts/HotelereumNFTMarketplace.sol#L492)

	```solidity
	    function markForResell(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 521](contracts/HotelereumNFTMarketplace.sol#L521)

	```solidity
	    function createFixMarketSale(uint256 _tokenId) public payable {
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 574](contracts/HotelereumNFTMarketplace.sol#L574)

	```solidity
	    function tokenURI(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 586](contracts/HotelereumNFTMarketplace.sol#L586)

	```solidity
	    function supportsInterface(
	```


- [ ] ***NC-2: Constants should be defined and used instead of literals***

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 181](contracts/HotelereumNFTMarketplace.sol#L181)

	```solidity
	            return 82110000;
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 265](contracts/HotelereumNFTMarketplace.sol#L265)

	```solidity
	        return (_expirationDate - _startingDate) / 86400;
	```
<mark>Mentioned in @dev tag</mark>

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 300](contracts/HotelereumNFTMarketplace.sol#L300)

	```solidity
	        uint256 rate = uint256(getLatestMaticPriceInUSD()) / 10 ** 2;
	```
<mark>Decimal scaling for calculation purpose</mark>

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 305](contracts/HotelereumNFTMarketplace.sol#L305)

	```solidity
	                (10 ** 18) / rate;
	```
<mark>Gas optimization purpose </mark>

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 408](contracts/HotelereumNFTMarketplace.sol#L408)

	```solidity
	            100;
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 409](contracts/HotelereumNFTMarketplace.sol#L409)

	```solidity
	        uint256 primaryHotelFee = (_amount * primaryHotelPercentage) / 100;
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 433](contracts/HotelereumNFTMarketplace.sol#L433)

	```solidity
	            secondaryPlatformFeePercentage) / 100;
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 434](contracts/HotelereumNFTMarketplace.sol#L434)

	```solidity
	        uint256 secondaryHotelFee = (_amount * secondaryHotelPercentage) / 100;
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 435](contracts/HotelereumNFTMarketplace.sol#L435)

	```solidity
	        uint256 secondaryOwnerFee = (_amount * secondaryOwnerPercentage) / 100;
	```
<mark> All these are for storage gas optimization purpose </mark>

- [ ] ***NC-3: Does indexing cost outweigh storage costs (Follow up)***

Index event fields make the field more quickly accessible to off-chain tools that parse events. It should be checked if all events having indices are being emitted repeatedly.

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 102](contracts/HotelereumNFTMarketplace.sol#L102)

	```solidity
	    event InventoryItemCreated(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 121](contracts/HotelereumNFTMarketplace.sol#L121)

	```solidity
	    event MarketItemPayemt(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 128](contracts/HotelereumNFTMarketplace.sol#L128)

	```solidity
	    event PrimaryRevenueDistributed(
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 135](contracts/HotelereumNFTMarketplace.sol#L135)

	```solidity
	    event SecondaryRevenueDistributed(
	```





## Issues Summary (Manual audit)

 Category | No. of Issues |
| --- | --- |
| Critical |  0|
| High | 2 |
| Medium |1  |
| Low |  2|
| NC |5  |


##  Issues

### Critical Issues



### High Issues
- [ ] ***H-1: initialize is a public function*** [Line 32]((contracts/HotelereumNFTMarketplace.sol#L435)). 
It can be called by anyone and they may change important parameters of the contract or change the contract address.
```
function initialize(address _maticOracleRoute) public initializer
```
 
 - [ ] ***H-2 : ERC20 used instead of IERC20***
 - [ ] ERC20 functions may not behave as expected. For example: return values are not always meaningful. It is recommended to use OpenZeppelin's SafeERC20 library.

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 410](contracts/HotelereumNFTMarketplace.sol#L410)

	```solidity
	        idToMarketItem[_tokenId].hotel.transfer(primaryHotelFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 411](contracts/HotelereumNFTMarketplace.sol#L411)

	```solidity
	        payable(owner()).transfer(primaryPlatformFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 436](contracts/HotelereumNFTMarketplace.sol#L436)

	```solidity
	        idToMarketItem[_tokenId].hotel.transfer(secondaryHotelFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 437](contracts/HotelereumNFTMarketplace.sol#L437)

	```solidity
	        payable(owner()).transfer(secondaryPlatformFee);
	```

- Found in contracts/HotelereumNFTMarketplace.sol [Line: 438](contracts/HotelereumNFTMarketplace.sol#L438)

	```solidity
	        sellerWallet.transfer(secondaryOwnerFee);

### Medium Issues
 
- [ ] ***M-1: Adding updatable function for enrolled entities***
 
### Low Issues

- [ ] ***L-1: use caching while using .length*** [line 255]((contracts/HotelereumNFTMarketplace.sol#L255))
```
for (uint i; i < _propertyIds.length; ) {
            items[i] = hotelIdToInventory[_hotelId][_propertyIds[i]];
            unchecked {
                ++i;
            }
        }
```


- [ ] ***L-2: use caching while using .length*** [line 284]((contracts/HotelereumNFTMarketplace.sol#L2))

```
for (uint i; i < _propertyIds.length; ) {
            items[i] = hotelIdToInventory[_hotelId][_propertyIds[i]];
            unchecked {
                ++i;
            }
        }
```    

### NC Issues

- [ ] ***NC-1: Need to add natspec documentation*** [Line 32]((contracts/HotelereumNFTMarketplace.sol#L435))
 

- [ ] ***NC-2: Variable packing. must be careful while upgrading contract*** [Line 55](contracts/HotelereumNFTMarketplace.sol#L55)

***Storage Collision:*** In upgradable contracts, mixing up variable locations can cause storage collisions. This is extremely high Impact High likelihood error.
```
ThunderLoan.sol
uint256 private s_feePrecision;
uint256 private s_flashLoanFee; // 0.3% ETH fee

ThunderLoanUpgraded.sol
uint256 private s_flashLoanFee; // 0.3% ETH fee
uint256 public constant FEE_PRECISION = 1e18;

```
So in upgraded contract flashLoanFee will be replaced by feePrecision.


- [ ] ***NC-3: Events dont have natspec documentation*** [Line 104]((contracts/HotelereumNFTMarketplace.sol#L104))

- [ ] ***NC-4: Spelling Mistakes***

- Found in [Line:238](contracts/HotelereumNFTMarketplace.sol#L238)
- Found in [Line:320](contracts/HotelereumNFTMarketplace.sol#L320)
- Found in [Line:361](contracts/HotelereumNFTMarketplace.sol#L361)
- Found in [Line:411](contracts/HotelereumNFTMarketplace.sol#L411)

```
function primeryRevenueDistribution(
        uint256 _tokenId,
        uint256 _amount
    ) private {
```
- Found in [Line:531](contracts/HotelereumNFTMarketplace.sol#L531)

- [ ] ***NC-5: Inappropriate modifier naming*** [Line 163](contracts/HotelereumNFTMarketplace.sol#163)
```
  modifier validHotelPartner(uint256 hotelId) {
        require(hotelIdToWallet[hotelId] != address(0), "Invalid Hotel ID");
        _;
    }
    ```