Liquid Bolt
Smart Contract Audit Report
Audit Summary
Liquid Bolt is building a new Decentralized Exchange.
For this audit, we reviewed the following contracts:
- LiquidRouter contract at 0x3AbB7B9ebA58770F84861adD4dF5aFd9C796b9dB on the Binance Smart Chain Mainnet.
- LiquidFactory contract at 0xBDEc20d9cdf8E222EDd536268A9883a4C2ca172D on the Binance Smart Chain Mainnet.
- LiquidRouter contract at 0x5995fCA2D7499Ac3a55c87D5B32D392504db0cBd on the Polygon Mainnet.
- LiquidFactory contract at 0xF301aE81800Aa97f68148531D487696EF939170E on the Polygon Mainnet.
- LiquidRouter contract at 0x5995fCA2D7499Ac3a55c87D5B32D392504db0cBd on the Fantom Mainnet.
- LiquidFactory contract at 0xdE08A0860B5971201f4d621B6eD4bb5BFed454be on the Fantom Mainnet.
Audit Findings
No findings were identified, though some centralized aspects are present.
Date: November 17th, 2022.
Updated: November 19th, 2022 to reflect the contract's Mainnet addresses.
Contracts Overview
LiquidERC20 Contract:
- The contracts utilize the SafeMath library to protect from any possible overflows/underflows.
LiquidPair Contract:
- This contract contains the core functionality of the Liquid LP token maintained by the LiquidPair contract.
- The contract supports ERC-712 signed messages which users can use to grant allowances via a signed message, allowing for gasless approvals.
- The contract complies with the ERC-20 token standard.
LiquidFactory Contract:
- This contract supports the core functionality of the Liquidity Pool token, which contains the logic behind LP minting, burning, and swapping between the assets in the liquidity pool.
- Anyone can use the mint function when the liquidity-add functionality is enabled to mint an amount of LP tokens proportional to the number of tokens in the contract that are not accounted for in the reserves.
- When the liquidity-add functionality is disabled, the user's address must have been pre-approved by the team.
- Anyone can use the burn function to burn any LP tokens in the contract and receive an amount of asset tokens proportional to the represented value of the LP tokens.
- Anyone can use the swap function when the swap functionality is enabled to transfer out an amount of the assets from the pool such that the new K value is at least as much as the current K value.
- When the swap functionality is disabled, the user must have been added as an allowed trader in the LiquidFactory contract to perform a swap.
- The swap function supports flash swaps which allows anyone to use a contract to borrow any amount of any asset, as long as the borrowed amount of each asset is returned within the call.
- There is a fee taken on all swaps as determined in the LiquidFactory contract; the fee remains in the liquidity pool and is proportionally allocated among all LP token holders.
- In the event that the team's platform fee is enabled, up to 50% of the fee is minted as LP tokens to an address controlled by the team.
- Anyone can use the skim function when the swap functionality is enabled to transfer out any excess tokens that are not accounted for in the reserve amounts. When the swap functionality is disabled, the user must have been added as an allowed trader in the LiquidFactory contract.
- Alternatively, anyone can use the sync function to include any excess tokens in the reserve amounts so that they cannot be removed.
LiquidRouter Contract:
- This contract is used to deploy new LiquidPair contracts specifying two underlying token assets.
- Anyone can create any pair at any time, as long as the pair has not been created yet.
- Only one LiquidPair contract can exist for any combination of two token assets.
- The FeeTo Setter address can add/remove addresses as an allowed trader at any time.
- The "FeeTo Setter" address can assign a custom fee to any specified Pair address (up to 20%) that is used during all swapping functionality in the LiquidRouter contract.
- The FeeTo Setter address can enable/disable the use of custom fees assigned to a pair at any time.
- In the event that custom fees are disabled and the user has been added as an allowed trader, the contract's "Trader" fees will be used.
- In the event that custom fees are disabled and the user has not been added as an allowed trader, the contract's "Other" fees will be used.
- The FeeTo Setter address can set Trader fees and Other fees to any values up to 20% at any time.
- The FeeTo Setter address can set Dev fees to any value up to 50%.
- The FeeTo Setter address can enable/disable the swap and liquidity-add functionality at any time.
- The "FeeTo Setter" address can set the "FeeTo" and the FeeTo Setter addresses to any addresses at any time.
- This contract is used to interact with any LiquidPair liquidity pool contract created by the LiquidFactory contract.
- Any user can add liquidity when the liquidity-add functionality is enabled or the user's address has been pre-approved by the team.
- Upon adding liquidity, the user specifies the desired minimum amount of each token in the pair to add to the liquidity pool; the user is minted LiquidPair LP tokens representing their share of ownership of the liquidity pool.
- Upon removing liquidity, the user specifies the desired minimum amount of each token asset to receive from the liquidity pool; the user's LP tokens are burnt in the process.
- Liquidity removals support ERC-712 permits which allow the user to approve the Router to spend the user's LP tokens in a gasless manner.
- Liquidity adds and removals support fee-on-transfer tokens.
- Anyone can use this contract to swap one token asset for any other supported asset along a user-specified path of token assets.
- The owner can withdraw any tokens or ETH from the contract at any time.
Audit Results
Vulnerability Category | Notes | Result |
---|---|---|
Arbitrary Jump/Storage Write | N/A | PASS |
Centralization of Control | The team can set Trader fees and Other fees to any values up to 20% at any time. | PASS |
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 |
Sybil Attack | N/A | PASS |
Unbounded Loops | N/A | PASS |
Unused Code | N/A | PASS |
Overall Contract Safety | PASS |
LiquidFactory, LiquidERC20, LiquidPair Contracts
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] ILiquidFactory
- [Ext] feeTo
- [Ext] feeToSetter
- [Ext] traderFees
- [Ext] otherFees
- [Ext] getFees
- [Ext] getDevFees
- [Ext] allowOtherSwap
- [Ext] allowOtherLiquidity
- [Ext] isAllowedToSwap
- [Ext] isAllowedToProvideLiquidity
- [Ext] getPair
- [Ext] allPairs
- [Ext] allPairsLength
- [Ext] createPair #
- [Ext] setFeeTo #
- [Ext] setFeeToSetter #
+ [Int] ILiquidPair
- [Ext] name
- [Ext] symbol
- [Ext] decimals
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] allowance
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
- [Ext] DOMAIN_SEPARATOR
- [Ext] PERMIT_TYPEHASH
- [Ext] nonces
- [Ext] permit #
- [Ext] MINIMUM_LIQUIDITY
- [Ext] factory
- [Ext] token0
- [Ext] token1
- [Ext] getReserves
- [Ext] price0CumulativeLast
- [Ext] price1CumulativeLast
- [Ext] kLast
- [Ext] mint #
- [Ext] burn #
- [Ext] swap #
- [Ext] skim #
- [Ext] sync #
- [Ext] initialize #
+ [Int] ILiquidERC20
- [Ext] name
- [Ext] symbol
- [Ext] decimals
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] allowance
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
- [Ext] DOMAIN_SEPARATOR
- [Ext] PERMIT_TYPEHASH
- [Ext] nonces
- [Ext] permit #
+ [Lib] SafeMath
- [Int] add
- [Int] sub
- [Int] mul
+ LiquidERC20 (ILiquidERC20)
- [Pub] #
- [Int] _mint #
- [Int] _burn #
- [Prv] _approve #
- [Prv] _transfer #
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
- [Ext] permit #
+ [Lib] Math
- [Int] min
- [Int] sqrt
+ [Lib] UQ112x112
- [Int] encode
- [Int] uqdiv
+ [Int] IERC20
- [Ext] name
- [Ext] symbol
- [Ext] decimals
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] allowance
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
+ [Int] ILiquidCallee
- [Ext] liquidCall #
+ LiquidPair (ILiquidPair, LiquidERC20)
- [Pub] getReserves
- [Prv] _safeTransfer #
- [Pub] #
- [Ext] initialize #
- [Prv] _update #
- [Prv] _mintFee #
- [Ext] mint #
- modifiers: lock
- [Ext] burn #
- modifiers: lock
- [Ext] swap #
- modifiers: lock
- [Ext] skim #
- modifiers: lock
- [Ext] sync #
- modifiers: lock
+ LiquidFactory (ILiquidFactory)
- [Pub] #
- [Ext] allPairsLength
- [Pub] getFees
- [Pub] getDevFees
- [Pub] isAllowedToProvideLiquidity
- [Pub] isAllowedToSwap
- [Ext] createPair #
- [Ext] setFeeTo #
- [Ext] setTraderFees #
- [Ext] setOtherFees #
- [Ext] setAllowOtherSwap #
- [Ext] setAllowedTrader #
- [Ext] setAllowOtherLiquidity #
- [Ext] setAllowedLiquidityProvider #
- [Ext] setFeeToSetter #
- [Ext] setUseCustomFees #
- [Ext] setCustomFees #
- [Ext] setDevFees #
LiquidRouter Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Lib] TransferHelper
- [Int] safeApprove #
- [Int] safeTransfer #
- [Int] safeTransferFrom #
- [Int] safeTransferETH #
+ [Int] ILiquidRouter01
- [Ext] factory
- [Ext] WETH
- [Ext] addLiquidity #
- [Ext] addLiquidityETH ($)
- [Ext] removeLiquidity #
- [Ext] removeLiquidityETH #
- [Ext] removeLiquidityWithPermit #
- [Ext] removeLiquidityETHWithPermit #
- [Ext] swapExactTokensForTokens #
- [Ext] swapTokensForExactTokens #
- [Ext] swapExactETHForTokens ($)
- [Ext] swapTokensForExactETH #
- [Ext] swapExactTokensForETH #
- [Ext] swapETHForExactTokens ($)
- [Ext] quote
- [Ext] getAmountOut
- [Ext] getAmountIn
- [Ext] getAmountsOut
- [Ext] getAmountsIn
+ [Int] ILiquidRouter02 (ILiquidRouter01)
- [Ext] removeLiquidityETHSupportingFeeOnTransferTokens #
- [Ext] removeLiquidityETHWithPermitSupportingFeeOnTransferTokens #
- [Ext] swapExactTokensForTokensSupportingFeeOnTransferTokens #
- [Ext] swapExactETHForTokensSupportingFeeOnTransferTokens ($)
- [Ext] swapExactTokensForETHSupportingFeeOnTransferTokens #
+ [Int] ILiquidFactory
- [Ext] feeTo
- [Ext] feeToSetter
- [Ext] getFees
- [Ext] getPair
- [Ext] allPairs
- [Ext] allPairsLength
- [Ext] createPair #
- [Ext] setFeeTo #
- [Ext] setFeeToSetter #
- [Ext] INIT_CODE_PAIR_HASH
+ [Lib] SafeMath
- [Int] add
- [Int] sub
- [Int] mul
+ [Int] ILiquidPair
- [Ext] name
- [Ext] symbol
- [Ext] decimals
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] allowance
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
- [Ext] DOMAIN_SEPARATOR
- [Ext] PERMIT_TYPEHASH
- [Ext] nonces
- [Ext] permit #
- [Ext] MINIMUM_LIQUIDITY
- [Ext] factory
- [Ext] token0
- [Ext] token1
- [Ext] getReserves
- [Ext] price0CumulativeLast
- [Ext] price1CumulativeLast
- [Ext] kLast
- [Ext] mint #
- [Ext] burn #
- [Ext] swap #
- [Ext] skim #
- [Ext] sync #
- [Ext] initialize #
+ [Lib] LiquidLibrary
- [Int] sortTokens
- [Int] pairFor
- [Int] getReserves
- [Int] quote
- [Int] getAmountOut
- [Int] getAmountIn
- [Int] getAmountsOut
- [Int] getAmountsIn
+ [Int] IERC20
- [Ext] name
- [Ext] symbol
- [Ext] decimals
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] allowance
- [Ext] approve #
- [Ext] transfer #
- [Ext] transferFrom #
+ [Int] IWETH
- [Ext] deposit ($)
- [Ext] transfer #
- [Ext] withdraw #
+ Ownable
- [Pub] #
- [Pub] owner
- [Pub] renounceOwnership #
- modifiers: onlyOwner
- [Pub] transferOwnership #
- modifiers: onlyOwner
- [Prv] _setOwner #
+ LiquidRouter (ILiquidRouter02, Ownable)
- [Pub] #
- [Ext] ($)
- [Int] _addLiquidity #
- [Ext] addLiquidity #
- modifiers: ensure
- [Ext] addLiquidityETH ($)
- modifiers: ensure
- [Pub] removeLiquidity #
- modifiers: ensure
- [Pub] removeLiquidityETH #
- modifiers: ensure
- [Ext] removeLiquidityWithPermit #
- [Ext] removeLiquidityETHWithPermit #
- [Pub] removeLiquidityETHSupportingFeeOnTransferTokens #
- modifiers: ensure
- [Ext] removeLiquidityETHWithPermitSupportingFeeOnTransferTokens #
- [Int] _swap #
- [Ext] swapExactTokensForTokens #
- modifiers: ensure
- [Ext] swapTokensForExactTokens #
- modifiers: ensure
- [Ext] swapExactETHForTokens ($)
- modifiers: ensure
- [Ext] swapTokensForExactETH #
- modifiers: ensure
- [Ext] swapExactTokensForETH #
- modifiers: ensure
- [Ext] swapETHForExactTokens ($)
- modifiers: ensure
- [Int] _swapSupportingFeeOnTransferTokens #
- [Ext] swapExactTokensForTokensSupportingFeeOnTransferTokens #
- modifiers: ensure
- [Ext] swapExactETHForTokensSupportingFeeOnTransferTokens ($)
- modifiers: ensure
- [Ext] swapExactTokensForETHSupportingFeeOnTransferTokens #
- modifiers: ensure
- [Pub] quote
- [Pub] getAmountOut
- [Pub] getAmountIn
- [Pub] getAmountsOut
- [Pub] getAmountsIn
- [Pub] recoverEth #
- modifiers: onlyOwner
- [Pub] recoverToken #
- modifiers: onlyOwner
About SourceHat
SourceHat has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1300+ 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 across 1500 projects!.
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.