npx skills add ...
npx skills add uniswap/uniswap-ai --skill deployer
Deploy CCA (Continuous Clearing Auction) smart contracts using the Factory pattern. Use when user says "deploy auction", "deploy cca", "factory deployment", or wants to deploy a configured auction.
npx skills add uniswap/uniswap-ai --skill deployer
Deploy Continuous Clearing Auction (CCA) smart contracts using the ContinuousClearingAuctionFactory with CREATE2 for consistent addresses across chains.
Runtime Compatibility: This skill uses
AskUserQuestionfor interactive prompts. IfAskUserQuestionis not available in your runtime, collect the same parameters through natural language conversation instead.
When the user invokes this skill, guide them through the CCA deployment process with appropriate safety warnings and validation.
Before proceeding with deployment, you MUST:
IMPORTANT: Before proceeding with deployment, you must acknowledge:
This tool and all deployment instructions are provided for educational purposes only. AI-generated deployment commands may contain errors or security vulnerabilities.
You must:
Use AskUserQuestion to confirm the user acknowledges these warnings before proceeding with deployment steps.
Before interpolating ANY user-provided value into forge/cast commands or deployment scripts:
^0x[a-fA-F0-9]{40}$ — reject otherwise^[0-9]+\.?[0-9]*$$RPC_URL): MUST be https://-scheme and MUST NOT contain any metacharacter or whitespace from the rule below. This value does not come from the configuration file, the user supplies it during the walkthrough, and it reaches --rpc-url on every forge script, cast send, and forge verify-contract command below. "It came from the user, not the config" is not an exemption. Validate it the first time it is supplied, assign it to $RPC_URL, and reference only that variable afterwards; never re-read a raw URL into a later command. An endpoint whose URL needs a query string (a provider API key, for example) is exported into the environment out of band and referenced as $RPC_URL, never pasted into command text.;, |, &, $, `, (, ), >, <, \, ', ", spaces, tabs, newlines. $(...) and backticks execute even inside double quotes, and a space splits one value into extra forge/cast flags, so neither is ever safe to interpolate. Abort and report which value and which character failed rather than stripping the offending characters and continuing.--rpc-url "$RPC_URL", never the bare unquoted form). Quoting is the second layer, not the first: validate the value before it reaches the command, then quote it as well.Do NOT auto-approve Bash(forge:*) or Bash(cast:*) in your Claude Code settings. Always require per-invocation approval for commands that spend gas or broadcast transactions. The PreToolUse hooks in .claude/hooks/ provide programmatic validation as a safety net, but user approval per command is the primary control.
CRITICAL: Handling private keys safely is essential for secure deployments.
--private-key flag (blocked by PreToolUse hook)Use Ledger or Trezor hardware wallets with the --ledger flag:
Create an encrypted keystore with cast wallet import:
If using environment variables, ensure they are:
.env file (never committed to git)source .env or dotenvExample:
Always test on testnets before mainnet:
CCA instances are deployed via the ContinuousClearingAuctionFactory contract, which uses CREATE2 for consistent addresses across chains.
| Version | Address | Status |
|---|---|---|
| v1.1.0 | 0xCCccCcCAE7503Cac057829BF2811De42E16e0bD5 | Recommended |
If you don't already have the CCA contracts locally, clone the repository and install dependencies:
This gives you access to the deployment scripts, contract ABIs, and test helpers referenced in later steps.
Ensure you have a valid configuration file (generated via the configurator skill or manually created).
Example configuration file structure:
Before deployment, verify the configuration passes all validation rules (see Validation Rules section).
The factory has a simple interface:
Where:
token: Address of the token to be soldamount: Amount of tokens to sell in the auctionconfigData: ABI-encoded AuctionParameters structsalt: Optional bytes32 value for vanity address miningThe factory's initializeDistribution expects configData as ABI-encoded AuctionParameters. Convert your JSON config to encoded bytes:
Using cast (Foundry CLI):
Using a Foundry Script:
Important: You must approve the token transfer to the factory before calling initializeDistribution. The factory will transfer amount tokens from your address to the newly created auction contract.
After deployment, you must call onTokensReceived() to notify the auction that tokens have been transferred:
This is a required prerequisite before the auction can accept bids.
You can also deploy directly via the constructor:
This approach doesn't require a salt parameter but won't benefit from CREATE2's deterministic addressing.
Generate standard JSON input for verification:
Upload this file to block explorers for verification.
Before deployment, ensure:
startBlock < endBlock <= claimBlockThe auction uses Q96 fixed-point arithmetic:
Steps are packed into bytes, where each step is a uint64:
mps (per-block issuance rate in MPS)blockDelta (number of blocks)The data is deployed to an external SSTORE2 contract for cheaper reads.
Users submit bids with:
maxPrice: Maximum price willing to pay (Q96)amount: Currency amount to bidowner: Address to receive tokens/refundsprevTickPrice: Hint for gas optimizationhookData: Optional data for validation hooksAuction is checkpointed once per block with a new bid. Checkpoints determine token allocations.
Bids can be exited when outbid or when auction ends (only after graduation).
Returns true if currencyRaised >= requiredCurrencyRaised. No bids can exit before graduation.
Users claim purchased tokens after claimBlock (only for graduated auctions).
After auction ends:
sweepCurrency(): Withdraw raised currency (graduated only)sweepUnsoldTokens(): Withdraw unsold tokensCCA is deployed to canonical addresses across select EVM chains:
| Chain ID | Network | Block Time |
|---|---|---|
| 1 | Mainnet | 12s |
| 130 | Unichain | 1s |
| 1301 | Unichain Sepolia | 2s |
| 8453 | Base | 2s |
| 42161 | Arbitrum | 2s |
| 11155111 | Sepolia | 12s |
| Issue | Solution |
|---|---|
| "Invalid block sequence" | Ensure startBlock < endBlock <= claimBlock |
| "Floor price not aligned" | Round floor price to multiple of tick spacing |
| "Tick spacing too small" | Use at least 1% of floor price |
| "Total supply too large" | Max 1e30 wei (1 trillion 18-decimal tokens) |
| "Gas inefficiency" | Increase tick spacing |
| "Invalid address" | Verify addresses are 42 characters starting with 0x |
Before deployment:
onTokensReceived() called post-deploymentdocs/TechnicalDocumentation.md in repodocs/DeploymentGuide.md in repodocs/assets/whitepaper.pdf in repodocs/audits/README.md in repo# Import private key to encrypted keystore (one-time setup)
cast wallet import deployer --interactive
# Use keystore for deployment
forge script script/Example.s.sol:ExampleScript \
--rpc-url "$RPC_URL" \
--broadcast \
--account deployer \
--sender "$DEPLOYER_ADDRESS"# .env file (add to .gitignore)
PRIVATE_KEY=0x...
RPC_URL=https://...
# Load environment
source .env
# Deploy (use encrypted keystore instead of --private-key)
cast wallet import deployer --interactive
forge script ... --account deployer --sender "$DEPLOYER_ADDRESS"git clone https://github.com/Uniswap/continuous-clearing-auction.git
cd continuous-clearing-auction
forge install{
"1": {
"token": "0x...",
"totalSupply": 1e29,
"currency": "0x0000000000000000000000000000000000000000",
"tokensRecipient": "0x...",
"fundsRecipient": "0x...",
"startBlock": 24321000,
"endBlock": 24327001,
"claimBlock": 24327001,
"tickSpacing": 79228162514264337593543950,
"validationHook": "0x0000000000000000000000000000000000000000",
"floorPrice": 7922816251426433759354395000,
"requiredCurrencyRaised": 0,
"supplySchedule": [
{ "mps": 1000, "blockDelta": 6000 },
{ "mps": 4000000, "blockDelta": 1 }
]
}
}function initializeDistribution(
address token,
uint256 amount,
bytes calldata configData,
bytes32 salt
) external returns (IDistributionContract);# Encode the AuctionParameters struct
cast abi-encode "initializeDistribution(address,uint256,bytes,bytes32)" \
"$TOKEN_ADDRESS" \
"$TOTAL_SUPPLY" \
"$(cast abi-encode "(address,address,address,uint64,uint64,uint64,uint256,address,uint256,uint128,bytes)" \
"$CURRENCY" \
"$TOKENS_RECIPIENT" \
"$FUNDS_RECIPIENT" \
"$START_BLOCK" \
"$END_BLOCK" \
"$CLAIM_BLOCK" \
"$TICK_SPACING" \
"$VALIDATION_HOOK" \
"$FLOOR_PRICE" \
"$REQUIRED_CURRENCY_RAISED" \
"$ENCODED_SUPPLY_SCHEDULE")" \
"0x0000000000000000000000000000000000000000000000000000000000000000"// script/DeployAuction.s.sol
pragma solidity ^0.8.24;
import "forge-std/Script.sol";
interface ICCAFactory {
function initializeDistribution(
address token,
uint256 amount,
bytes calldata configData,
bytes32 salt
) external returns (address);
}
contract DeployAuction is Script {
function run() external {
// Load config values
address token = vm.envAddress("TOKEN");
uint256 amount = vm.envUint("TOTAL_SUPPLY");
// Encode AuctionParameters
bytes memory configData = abi.encode(
vm.envAddress("CURRENCY"),
vm.envAddress("TOKENS_RECIPIENT"),
vm.envAddress("FUNDS_RECIPIENT"),
uint64(vm.envUint("START_BLOCK")),
uint64(vm.envUint("END_BLOCK")),
uint64(vm.envUint("CLAIM_BLOCK")),
vm.envUint("TICK_SPACING"),
vm.envAddress("VALIDATION_HOOK"),
vm.envUint("FLOOR_PRICE"),
uint128(vm.envUint("REQUIRED_CURRENCY_RAISED")),
vm.envBytes("ENCODED_SUPPLY_SCHEDULE")
);
vm.startBroadcast();
// Approve token transfer to factory
IERC20(token).approve(
0xCCccCcCAE7503Cac057829BF2811De42E16e0bD5,
amount
);
// Deploy auction
address auction = ICCAFactory(
0xCCccCcCAE7503Cac057829BF2811De42E16e0bD5
).initializeDistribution(
token,
amount,
configData,
bytes32(0) // salt
);
vm.stopBroadcast();
console.log("Auction deployed at:", auction);
}
}# Deploy factory (if needed on new network)
forge script script/deploy/DeployContinuousAuctionFactory.s.sol:DeployContinuousAuctionFactoryScript \
--rpc-url "$RPC_URL" \
--broadcast \
--account deployer --sender "$DEPLOYER_ADDRESS"
# Deploy auction instance
forge script script/Example.s.sol:ExampleScript \
--rpc-url "$RPC_URL" \
--broadcast \
--account deployer --sender "$DEPLOYER_ADDRESS"cast send "$AUCTION_ADDRESS" "onTokensReceived()" --rpc-url "$RPC_URL" --account deployer --sender "$DEPLOYER_ADDRESS"constructor(
address token,
uint128 amount,
AuctionParameters memory parameters
) {}forge verify-contract "$AUCTION_ADDRESS" \
src/ContinuousClearingAuction.sol:ContinuousClearingAuction \
--rpc-url "$RPC_URL" \
--show-standard-json-input > standard-json-input.jsonlibrary FixedPoint96 {
uint8 internal constant RESOLUTION = 96;
uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96
}function parse(bytes8 data) internal pure returns (uint24 mps, uint40 blockDelta) {
mps = uint24(bytes3(data));
blockDelta = uint40(uint64(data));
}