// Deploy Controller with fee distribution
const controller = await Controller.deploy(
[
treasury.address, // DAO treasury
devFund.address, // Development fund
burnAddress // Burn for deflation
],
[2, 2, 1] // 40%, 40%, 20%
);
// Transfer factory ownership to controller
await factory.setOwner(controller.address);
// Set up defaults for standard pool creation
await controller.setDefaultFeeManager(factory.address, tieredDiscount.address);
await controller.setDefaultTickSpacing(factory.address, 3000, 60); // 0.3% fee → 60 tick spacing
await controller.setDefaultTickSpacing(factory.address, 500, 10); // 0.05% fee → 10 tick spacing
// Option 1: Create pool with full control (owner only)
const poolAddress = await controller.createPool(
factory.address,
WVC,
USDT,
3000, // 0.3% fee
60, // tick spacing
tieredDiscount.address, // fee manager
sqrtPriceX96 // initial price
);
// Option 2: Create standard pool (anyone, uses defaults)
const standardPool = await controller.createStandardPool(
factory.address,
WVC,
USDT,
3000, // 0.3% fee (tick spacing from defaults)
sqrtPriceX96 // initial price
);
// Any account or owner can collect fees
const pools = [pool1, pool2, pool3];
for (const pool of pools) {
await controller.collectProtocolFees(
pool,
ethers.constants.MaxUint128,
ethers.constants.MaxUint128
);
}
// Each account withdraws their share
const myBalance = await controller.balanceOf(myAddress, WVC);
if (myBalance.gt(0)) {
await controller.withdraw(WVC, myBalance);
}
Shares: [1, 1, 1], Total: 3
Amount: 10 tokens
Each account: 10 / 3 = 3 tokens
Lost to rounding: 10 - (3 * 3) = 1 token
Note: Rounding dust is given to the first account