A unified, permissionless interface for seamless interaction with liquidity pools — by Zup Protocol
Modular Contracts are a set of smart contracts developed by Zup Protocol that provide a unified interface for interacting with liquidity pools across multiple decentralized exchange protocols.
They enable integrators to seamlessly interact with different AMM architectures (e.g., Uniswap V3, Algebra, PancakeSwap Infinity, etc.) through a consistent and predictable interface. Each protocol integration is implemented as an independent module, responsible for defining the logic of its specific actions (such as adding or removing liquidity) while maintaining a standardized function signature across all modules.
Modules are standalone, immutable, and permissionless, they can be deployed and used in any environment by anyone. The Modular contract serves as the registry and manager for all module versions, ensuring consistent usage across the ecosystem.
Unlike modules, only authorized users can update the module registry in the Modular contract and define which versions are currently used. To enhance security and transparency, any change to the officially used modules is subject to a 7-day activation delay before being able to be activated.
To contribute, test, or run this project locally, you’ll need the following tools installed:
Used as a framework for smart contract development, testing, and deployment.
- Check installation
forge --version
- Install (if missing): https://getfoundry.sh/introduction/installation/
Required for linters and development utilities.
- Check installation
node --version
- Install / Update: https://nodejs.org/en/download/
Package manager for JavaScript dependencies.
- Check installation
yarn --version
- Install: https://yarnpkg.com/getting-started/install
These tools enhance the development experience and improve security analysis, but are optional.
Tools for detecting vulnerabilities in smart contracts:
- Install CLI: https://cyfrin.gitbook.io/cyfrin-docs/aderyn-cli/installation
- Install VSCode extension: https://cyfrin.gitbook.io/cyfrin-docs/aderyn-vs-code/installation-and-usage
- Install CLI: https://prettier.io/docs/en/install.html
- Install VSCode extension: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
Clone the repository and setup the environment:
git clone https://github.com/Zup-Protocol/modular-contracts.git
cd modular-contracts
yarn install
forge buildRun the test suite:
yarn testRun the linter:
yarn lintThis command will run solhint linter to check for linting errors in the src folder.
Note that all commands will by default use a Trezor device to sign the transaction, if you want to use a different device please modify the script at the package.json file to specify your preferred signing method, according to the forge options.
All commands will also try to verify the contract after deployment, to do so you should set the ETHERSCAN_API_KEY in the .env file. To obtain an API key, check out Getting an API Key from Etherscan Docs.
To deploy the Modular contract, use the following command at the root of the repository in your terminal:
yarn deploy:Modular [network]This command deploys the Modular contract to the specified network. The network is required and can be one of the defined networks in the foundry.toml file, under the rpc_endpoints section.
To deploy the UniswapV3PoolModule contract, use the following command at the root of the repository in your terminal:
yarn deploy:UniswapV3PoolModule [network]this command deploys the UniswapV3PoolModule contract to the specified network. The network is required and can be one of the defined networks in the foundry.toml file, under the rpc_endpoints section.
src/ # Core smart contracts
├── modules/ # Individual liquidity pool modules
├── libraries/ # Shared utilities
├── interfaces/ # Smart contract interfaces
└── Modular.sol # Module registry and entry point
script/ # Deployment and management scripts
test/ # Test suitesThis project is released under the GNU General Public License v3.