Factory

The factory is a smart contract mainly for creating and managing the pairs.

Function createPair

This function can be used to deploy a new pool contract for an asset pair. The function was modified from the original Uniswap version to allow Facet Swap pool contracts to be deployed behind a proxy to allow upgradability.

The function behaves as intended, and we did not find any security issues.

We note that the implementation address for the initial version of the pool contract code is derived from the hash of the pool contract creation code; this differs from how contract addresses are normally computed on EVM chains, and it only works because the pool contract is manually deployed at the address derived from the hash of the pool creation code from the genesis state of Facet.

Function initialize

This function allows to initialize the factory contract. It can only be called once. It was introduced in the Facet fork of Uniswap. No security issues were found in the function, provided that the function is called in the same transaction that deploys the factory, or that the factory configuration is verified, to ensure no malicious call to initialize was made before the legitimate call to initialize is made.

Function allPairsLength

This function allows to retrieve the number of pool contracts deployed by this factory. It is functionally equivalent to the function from the Uniswap codebase, with only changes needed to support accessing storage in a manner compatible with the chosen upgradability pattern.

Function getPair

This function allows to retrieve the address of the pool contract for a given pair of assets. It is functionally equivalent to the function from the Uniswap codebase, with only changes needed to support accessing storage in a manner compatible with the chosen upgradability pattern.

Function feeTo

This function allows to retrieve the address that receives the fees charged by the pool contracts. It is functionally equivalent to the function from the Uniswap codebase, with only changes needed to support accessing storage in a manner compatible with the chosen upgradability pattern.

Function setFeeTo

This function allows the feeToSetter address to change the address that receives the fees accrued by Facet Swap pools. It is functionally equivalent to the function from the Uniswap codebase, with only changes needed to support accessing storage in a manner compatible with the chosen upgradability pattern.

Function setFeeToSetter

This function allows the feeToSetter address to transfer its own role to another address. It is functionally equivalent to the function from the Uniswap codebase, with only changes needed to support accessing storage in a manner compatible with the chosen upgradability pattern.

Function lpFeeBPS

This function allows to retrieve the current fee rate charged by Facet Swap pools. It was introduced in the Facet fork of Uniswap. No security issues were found in the function.

Function setLpFeeBPS

This function allows the feeToSetter address to change the fees charged by Facet Swap pools. It was introduced in the Facet fork of Uniswap. No security issues were found in the function.

Function upgradePairs

This function allows the upgrade admin to upgrade the implementation address of a batch of Pair contracts. It was introduced in the Facet fork of Uniswap. No security issues were found in the function.

We note that the newSource argument is ignored, and an empty string is used to upgrade the contract instead. However, the argument appears to be unused in the implementation of the Upgradeable base contract.

Function upgradePair

This function allows the upgrade admin to upgrade the implementation address of a Pair contract. It was introduced in the Facet fork of Uniswap. No security issues were found in the function.

Zellic © 2025Back to top ↑