How pancakeswap/infinity-core works
Project type and purpose
• This is a blockchain-focused smart-contract system (“Infinity Core”) written in Solidity and managed with Foundry (forge), targeting multiple EVM chains (Ethereum, BSC).
• It contains core contracts (vault, pools, fee hooks), utility libraries (math, hooks), interfaces, deployment scripts, and a test suite (Forge and JS).
File structure
• Top-level:
– lib/ – external Solidity dependencies (openzeppelin, solmate, pancake-create3-factory, forge-std)
– src/ – project source, subdivided into base, pool-bin, pool-cl modules, libraries, interfaces, types, tests
– script/ – deployment scripts and configurations per network
– test/ & snapshots/ – exhaustive on-chain behavior tests (Forge & JS)
– foundry.toml, package.json, remappings.txt, CI workflows
• Pattern: modular contract design (separate “bin” vs “concentrated liquidity” pools), common libraries (math, hooks), a vault layer.
• Deployment setup uses a Create3 factory pattern (external lib) for deterministic contract addresses.
README for additional insights
• Testing via forge test --isolate
• Deployment via forge script … --broadcast against EVM RPC
• Verification on Etherscan post-deployment
• Configuration driven by JSON files in script/config
a. On-chain components:
– Vault contract
– Pool-bin contracts (factory, pair, manager, hooks)
– Pool-cl (concentrated liquidity) contracts
– Shared libraries (Math, TickBitmap, BitMath, LiquidityMath, SqrtPriceMath)
– Create3 factory (from pancake-create3-factory lib)
b. Off-chain/development components:
– Foundry (forge) toolchain – compiles & tests contracts
– Deployment scripts (S.sol) reading script/config/*.json
– RPC providers (Ethereum, BSC endpoints)
– Etherscan API (for verification)
– CI pipelines (.github/workflows – lint.yml, test.yml)
c. Relationships & data flow:
– Developer invokes forge test -> local EVM simulation -> reads src contracts & libs -> outputs test results & snapshots
– Deployment: script -> Create3 factory -> on-chain contract instantiation -> record addresses
– Verification: on-chain bytecode -> Etherscan API
– CI: commits & PRs trigger workflows -> run linters, tests
d. Architectural patterns:
– Modular multi-pool design (bin vs CL)
– Library-driven Math abstraction
– Create3 pattern for deterministic deployments
– Config-driven scripts for multi-network
e. Technology stack: Solidity, Foundry (forge), Hardhat-like scripts, OpenZeppelin, Solmate, CI (GitHub Actions), Node (yarn)