Foundry project for Gild on BNB Smart Chain: DammHook, GildRouter, fee collector, and banded buyback. The Next.js app lives in the sibling folder gild-app.
This code is unaudited. Do not route production size until the Four.meme selectors are checked against the verified BscScan ABI and an independent review is done. Infinity Bin is not shipped.
srcSolidity sourcestestFoundry tests, including the Four.meme mockscriptDeploy.s.solandSeedPool.s.solconfig/addresses.jsoncanonical Pancake and WBNB addressesTOKENOMICS.mdFlap-launched GILD and the fee burn path
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge installforge install pulls forge-std and OpenZeppelin into lib. Those directories are gitignored. The Infinity types under lib/infinity-core are a layout-compatible excerpt so the hook matches ICLHooks without compiling Pancake's AMM. See lib/infinity-core/NOTICE.md.
forge testPancake Infinity does not mine permission bits into the hook address. getHooksRegistrationBitmap() is copied into PoolKey.parameters (low 16 bits). Tick spacing occupies bits 16–39. script/SeedPool.s.sol sets tick spacing 10 that way.
A CREATE2 vanity salt is optional and does not change permissions. Do not port Uniswap v4 address flags onto this hook.
Fill .env from .env.example. Never commit PRIVATE_KEY.
forge script script/Deploy.s.sol --rpc-url "$BSC_TESTNET_RPC" --broadcastSet GILD_TOKEN to the Flap launch address before running the script. The script does not deploy a token and does not mint. Buyback is constructed with that address. On chain id 56 the token must already be a Flap curve token (status 1) or a graduated Flap token (status 4); the script then calls syncFlap so the registry follows the portal. Chain id 97 uses the Infinity testnet manager and vault from config/addresses.json. Chain id 56 uses mainnet. The script deploys config, fee collector, buyback, hook, registry, adapter, router, and quoter, then proposes a 2-day TimelockController as the next config owner. The timelock must call acceptOwnership. Seed liquidity before that acceptance:
forge script script/SeedPool.s.sol --rpc-url "$BSC_RPC" --broadcastThe Pancake V2 router in config is 0x10ED43C718714eb63d5aA57B78B54704E256024E. That is the deployed router.
IFourMeme follows Four.meme's published TokenManager2 and Helper3 notes dated 2025-10-30:
- TokenManager2
0x5c952063c7fc8610FFDB798152D69F0B9550762b - Helper3
0xF251F83e40a78868FcfA3FA4599Dad6494E46034
Replace those interfaces if BscScan verification disagrees. Tests use MockFourMeme.
Flap uses the portal at 0xe2cE6ab80874Fa9Fa2aAE65D277Dd6B8e65C9De0. IFlap matches the swapExactInput and getTokenV8Safe fragments already used by the app. Deploy.s.sol calls setPortal on mainnet. FeeCollector.forwardToBuyback sends swept WBNB to the buyback contract.