SwapzMultichainBridge
Smart Contract Audit Report
Audit Summary
SwapzMultichainBridge is a new bridge contract to support cross-chain swaps of specified tokens.
For this audit, we reviewed the SwapzMultichainBridge and TokenMagic contracts provided to us by the project team.
Audit Findings
Please ensure trust in the team prior to investing as they have substantial control in the ecosystem.
Date: April 15th, 2022.
Updated: April 22, 2022, to address changes made by the team.Finding #1 - SwapzMultichainBridge - Low (Resolved)
Description: Token swaps use thetransfer()
function instead of thecall()
function to transfer swapped funds to the users.
Risk/Impact: Thetransfer()
function uses a hardcoded gas amount of 2300, meaning transactions could run out of gas as the team receives ETH.
Recommendation: Use.call.value(...)("")
instead as it does not have a gas limitation.
Resolution: The team has implemented a customtransfer()
function that allows the owner to set a gas limit of any amount at any time.
Contracts Overview
- This contract enables users to swap team-designated tokens between different blockchains as well as utilize flash loans.
- On deployment, the owner is set as the admin address and sets the tokenFactory address; the TokenMagic contract is intended to be used as the tokenFactory contract address.
- Users can take out a flash loan of any native currency or token held in the contract provided that the loan amount is returned in addition to a fee in the same transaction; fee amounts are calculated based on the flash loan amount.
- There is a 1% fee on all flash loan transactions.
- Users can use this contract to submit a swap request in order to initiate the process of moving an amount of native currency or tokens from one chain to another; users must pay a chain fee in the origin chain's native currency in order to do so.
- Chain fees are specific to each chain and can be changed by the owner.
- If the token being swapped is not deployed on the destination chain then the tokenFactory contract address is used to create a placeholder contract and mint a placeholder token to the user; placeholder tokens are burned when used to swap to a different chain.
- The placeholder contract type is dependent on the token hash provided by the owner; the placeholder contract created complies with either the ERC-20 or ERC-721 standard based on the token hash.
- Additionally, the chain fee of the new placeholder token is set at an amount of 1 in the chains native currency.
- Users also can receive an airdrop amount in the native currency of their destination chain if the native currency within the contract is more than the airdrop amount.
- When swapping, users can provide a referral address to receive half of the set fee for the specified chain; only owner-approved referral addresses are eligible for rewards.
- The team is responsible for transferring assets to users appropriately as cross-chain swaps involve some off-chain logic run by the team. Please note we have not reviewed the off-chain logic related to the bridge.
- The owner can transfer any amount of any token stored within the contract to any address with a non-used transaction hash.
- The owner can transfer ownership at any time.
- The owner can change the admin address at any time.
- The owner can set the base URI of any placeholder ERC-721 token a single time.
- The admin address can add or remove any address from the referral list at any time.
- The admin address can change the tokenFactory address at any time.
- The admin address can change the base URI of any token address at any time.
- The admin address can add and remove token addresses from the whitelist at any time.
- The admin address can change any chain's fee to any value at any time.
- The admin address can change the owner of any token address at any time.
- The admin address can assign any token address to any asset ID at any time.
- The admin address can set the airdrop amount to any value at any time.
- The team must exercise caution when setting the approved tokens and must avoid using any fee-on-transfer tokens; if a fee-on-transfer token is used as a swap token then this contract should be excluded from the token's fee mechanism.
- As the contracts are implemented with Solidity v0.8.X, they are protected from any underflow/overflow attacks.
Audit Results
Vulnerability Category | Notes | Result |
---|---|---|
Arbitrary Jump/Storage Write | N/A | PASS |
Centralization of Control |
| WARNING |
Compiler Issues | N/A | PASS |
Delegate Call to Untrusted Contract | N/A | PASS |
Dependence on Predictable Variables | N/A | PASS |
Ether/Token Theft | N/A | PASS |
Flash Loans | N/A | PASS |
Front Running | N/A | PASS |
Improper Events | N/A | PASS |
Improper Authorization Scheme | N/A | PASS |
Integer Over/Underflow | N/A | PASS |
Logical Issues | N/A | PASS |
Oracle Issues | N/A | PASS |
Outdated Compiler Version | N/A | PASS |
Race Conditions | N/A | PASS |
Reentrancy | N/A | PASS |
Signature Issues | N/A | PASS |
Unbounded Loops | N/A | PASS |
Unused Code | N/A | PASS |
Overall Contract Safety | PASS |
SwapzMultichainBridge Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] IERC20
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] transfer #
- [Ext] allowance
- [Ext] approve #
- [Ext] transferFrom #
+ TokenFactory
- [Pub] create #
+ Token (IERC20)
- [Pub] mint #
- [Pub] burn #
- [Pub] setBaseURI #
- [Pub] transferOwnership #
- [Pub] tokenType #
+ FlashReceiver
- [Pub] executeOperation #
+ SwapzMultichainBridge
- [Pub] changeTokenFactory #
- modifiers: onlyAdmin
- [Pub] transferOwnership #
- modifiers: onlyOwner
- [Pub] transferAdmin #
- modifiers: onlyOwner
- [Pub] #
- [Pub] setBaseURI #
- modifiers: onlyAdmin
- [Pub] allowSwapToken #
- modifiers: onlyAdmin
- [Pub] changeChainFee #
- modifiers: onlyAdmin
- [Pub] changeTokenOwner #
- modifiers: onlyAdmin
- [Pub] assignTokenToAsset #
- modifiers: onlyAdmin
- [Pub] chainAirdrop #
- modifiers: onlyAdmin
- [Prv] bytesToAddress
- [Ext] sendAll #
- modifiers: onlyOwner
- [Prv] send #
- [Prv] sendWrapped #
- [Prv] sendNative #
- [Pub] flashLoad #
- [Pub] setAcceptedReferral #
- modifiers: onlyAdmin
- [Ext] swapRequestNative ($)
- [Pub] getName
- [Pub] getSymbol
- [Pub] getType
- [Pub] getChainId
- [Ext] swapRequestWrapped ($)
- [Ext] ($)
TokenMagic Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] IERC20
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] transfer #
- [Ext] allowance
- [Ext] approve #
- [Ext] transferFrom #
+ [Int] IERC20Metadata (IERC20)
- [Ext] name
- [Ext] symbol
- [Ext] decimals
+ Context
- [Int] _msgSender
- [Int] _msgData
+ ERC20 (Context, IERC20, IERC20Metadata)
- [Pub] #
- [Pub] name
- [Pub] symbol
- [Pub] decimals
- [Pub] totalSupply
- [Pub] balanceOf
- [Pub] transfer #
- [Pub] allowance
- [Pub] approve #
- [Pub] transferFrom #
- [Pub] increaseAllowance #
- [Pub] decreaseAllowance #
- [Int] _transfer #
- [Int] _mint #
- [Int] _burn #
- [Int] _approve #
- [Int] _spendAllowance #
- [Int] _beforeTokenTransfer #
- [Int] _afterTokenTransfer #
+ [Int] IERC165
- [Ext] supportsInterface
+ [Int] IERC721 (IERC165)
- [Ext] balanceOf
- [Ext] ownerOf
- [Ext] safeTransferFrom #
- [Ext] transferFrom #
- [Ext] approve #
- [Ext] getApproved
- [Ext] setApprovalForAll #
- [Ext] isApprovedForAll
- [Ext] safeTransferFrom #
+ [Int] IERC721Receiver
- [Ext] onERC721Received #
+ [Int] IERC721Metadata (IERC721)
- [Ext] name
- [Ext] symbol
- [Ext] tokenURI
+ [Lib] Address
- [Int] isContract
- [Int] sendValue #
- [Int] functionCall #
- [Int] functionCall #
- [Int] functionCallWithValue #
- [Int] functionCallWithValue #
- [Int] functionStaticCall
- [Int] functionStaticCall
- [Int] functionDelegateCall #
- [Int] functionDelegateCall #
- [Int] verifyCallResult
+ [Lib] Strings
- [Int] toString
- [Int] toHexString
- [Int] toHexString
+ ERC165 (IERC165)
- [Pub] supportsInterface
+ ERC721 (Context, ERC165, IERC721, IERC721Metadata)
- [Pub] #
- [Pub] supportsInterface
- [Pub] balanceOf
- [Pub] ownerOf
- [Pub] name
- [Pub] symbol
- [Pub] tokenURI
- [Int] _baseURI
- [Pub] approve #
- [Pub] getApproved
- [Pub] setApprovalForAll #
- [Pub] isApprovedForAll
- [Pub] transferFrom #
- [Pub] safeTransferFrom #
- [Pub] safeTransferFrom #
- [Int] _safeTransfer #
- [Int] _exists
- [Int] _isApprovedOrOwner
- [Int] _safeMint #
- [Int] _safeMint #
- [Int] _mint #
- [Int] _burn #
- [Int] _transfer #
- [Int] _approve #
- [Int] _setApprovalForAll #
- [Prv] _checkOnERC721Received #
- [Int] _beforeTokenTransfer #
- [Int] _afterTokenTransfer #
+ Ownable (Context)
- [Pub] #
- [Pub] owner
- [Pub] renounceOwnership #
- modifiers: onlyOwner
- [Pub] transferOwnership #
- modifiers: onlyOwner
- [Int] _transferOwnership #
+ WrappedNonFungable (ERC721, Ownable)
- [Pub] #
- modifiers: ERC721
- [Pub] mint #
- modifiers: onlyOwner
- [Pub] burn #
- modifiers: onlyOwner
- [Int] _baseURI
- [Pub] setBaseURI #
- modifiers: onlyOwner
- [Pub] transfer #
- [Pub] tokenType
+ WrappedFungable (ERC20, Ownable)
- [Pub] #
- modifiers: ERC20
- [Pub] mint #
- modifiers: onlyOwner
- [Pub] burn #
- modifiers: onlyOwner
- [Pub] tokenType
+ TokenMagic
- [Pub] create #
About SourceHat
SourceHat (formerly Solidity Finance - founded in 2020) has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1700+ solidity smart contract audits covering all major project types and protocols, securing a total of over $50 billion U.S. dollars in on-chain value!
Our firm is well-reputed in the community and is trusted as a top smart contract auditing company for the review of solidity code, no matter how complex. Our team of experienced solidity smart contract auditors performs audits for tokens, NFTs, crowdsales, marketplaces, gambling games, financial protocols, and more!
Contact us today to get a free quote for a smart contract audit of your project!
What is a SourceHat Audit?
Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A SourceHat Audit takes this a step further by verifying economic logic to ensure the stability of smart contracts and highlighting privileged functionality to create a report that is easy to understand for developers and community members alike.
How Do I Interpret the Findings?
Each of our Findings will be labeled with a Severity level. We always recommend the team resolve High, Medium, and Low severity findings prior to deploying the code to the mainnet. Here is a breakdown on what each Severity level means for the project:
- High severity indicates that the issue puts a large number of users' funds at risk and has a high probability of exploitation, or the smart contract contains serious logical issues which can prevent the code from operating as intended.
- Medium severity issues are those which place at least some users' funds at risk and has a medium to high probability of exploitation.
- Low severity issues have a relatively minor risk association; these issues have a low probability of occurring or may have a minimal impact.
- Informational issues pose no immediate risk, but inform the project team of opportunities for gas optimizations and following smart contract security best practices.