Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Setting Up Governance for AMM Parameter Adjustments

A technical guide for developers to implement a decentralized governance system for modifying Automated Market Maker parameters like swap fees, protocol fees, and liquidity gauge weights.
Chainscore © 2026
introduction
GUIDE

Setting Up Governance for AMM Parameter Adjustments

A practical guide to implementing on-chain governance for managing Automated Market Maker (AMM) parameters like swap fees, liquidity provider rewards, and slippage tolerance.

Automated Market Maker (AMM) parameters are the core economic levers of a decentralized exchange. Key parameters include the swap fee percentage, which is the commission taken from each trade; the protocol fee share, which allocates a portion of fees to the treasury; and amplification coefficients for stablecoin pools. Without a governance framework, these values are static, preventing the protocol from adapting to market conditions or community preferences. On-chain governance empowers token holders to propose and vote on changes to these settings, creating a dynamic and community-owned financial primitive.

The technical architecture for parameter governance typically involves a governance token, a voting contract, and a timelock controller. Popular frameworks like OpenZeppelin's Governor provide a modular foundation. The process follows a standard cycle: a proposal is submitted, a voting period opens, votes are cast based on token weight, and if successful, the proposal actions are queued and executed after a delay. This delay, enforced by the timelock, is a critical security feature that allows users to react to potentially malicious parameter changes before they take effect.

Here is a simplified example of a proposal contract that adjusts a swap fee on a Uniswap V3-style pool. The core logic executes the parameter change via the pool's manager contract.

solidity
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/governance/Governor.sol";
contract FeeGovernor is Governor {
    IPoolManager public poolManager;
    uint24 public currentFee;

    constructor(IPoolManager _manager) Governor("FeeGovernor") {
        poolManager = _manager;
    }

    // This function is called by the timelock after a successful vote
    function setPoolFee(uint24 newFee) external onlyGovernance {
        currentFee = newFee;
        poolManager.setSwapFee(newFee);
    }
}

When designing governance for parameters, key considerations include voting power calculation (e.g., token-weighted, time-locked), proposal thresholds to prevent spam, and quorum requirements to ensure sufficient participation. For critical parameters like fees, a gradual change mechanism (or "fee switch") is often safer than an instantaneous update, allowing liquidity to adjust. Governance should also define clear emergency procedures, such as a multisig guardian capable of pausing the system in case of a discovered vulnerability, balancing decentralization with operational security.

Successful parameter governance requires active community engagement. Tools like Snapshot are often used for off-chain sentiment signaling before an on-chain vote. Transparency is achieved by publishing audit reports for proposal code and using Etherscan to verify contract interactions. Projects like Uniswap, which gradually enabled its fee switch via governance, and Curve, where votes directly control gauge weights for liquidity incentives, serve as real-world benchmarks for effective AMM parameter management.

prerequisites
SETUP GUIDE

Prerequisites and Technical Requirements

Before implementing on-chain governance for AMM parameters, ensure your development environment and smart contract architecture meet the necessary technical standards.

Effective governance for Automated Market Maker (AMM) parameters requires a secure and modular smart contract foundation. You must have a working knowledge of Solidity (v0.8.0+) and experience with OpenZeppelin libraries, particularly their governance contracts (Governor, TimelockController) and access control (Ownable, AccessControl). Your AMM's core contracts—such as the pool, factory, and math libraries—should already be deployed and tested on a network like Ethereum mainnet, Arbitrum, or Optimism. This guide assumes you are building on an EVM-compatible chain.

The primary technical prerequisite is a decentralized voting token. This is typically an ERC-20 or ERC-721 token distributed to your protocol's community, where voting power is proportional to token balance. You will need its contract address. Furthermore, critical AMM parameters must be upgradeable or adjustable via function calls. Common governance-controlled parameters include: the swap fee percentage, protocol fee cut, amplification coefficient (for stable pools), and whitelists for specific assets or liquidity providers. These should be exposed through onlyGovernance or onlyOwner modifier-protected functions.

You must choose a governance framework. The most common is a Governor contract paired with a TimelockController. The Governor (e.g., OpenZeppelin's Governor) manages proposal creation, voting, and execution logic. The Timelock introduces a mandatory delay between a proposal's approval and its execution, providing a safety net for the community to react to malicious proposals. For testing, configure a local Hardhat or Foundry environment with mainnet forking to simulate real governance scenarios, including token distribution and voting delegation.

Set up your development environment with essential tools. Use Hardhat or Foundry for compiling, testing, and deploying contracts. You will need Node.js (v18+) and package managers like npm or yarn. For interacting with contracts, prepare scripts using ethers.js (v6) or viem. It is also crucial to have access to an RPC provider (Alchemy, Infura) and a funded wallet for deployment. Write comprehensive unit tests for the entire governance flow: proposal creation, voting, queueing via the timelock, and final execution of parameter changes.

Finally, plan for real-world constraints. Determine your governance parameters: voting delay (blocks before voting starts), voting period (duration of the vote), proposal threshold (minimum tokens to propose), and quorum (minimum votes required for validity). These values significantly impact governance security and participation. Consider using a snapshot of token holders at a specific block to prevent manipulation. Document all contract addresses, roles, and parameters clearly for transparency, as this information is critical for users and front-end integrators who will interact with your governance system.

key-concepts-text
CORE GOVERNANCE CONCEPTS FOR AMS

Setting Up Governance for AMM Parameter Adjustments

Automated Market Makers (AMMs) rely on configurable parameters like swap fees and liquidity incentives. This guide explains how to implement on-chain governance to manage these critical settings.

AMM parameters are not static; they require adjustment to optimize for network conditions, competitive pressures, and protocol revenue. Key parameters include the swap fee percentage, which directly impacts protocol earnings and trader costs, and liquidity provider (LP) incentives like reward emission rates. Without a formal governance process, changing these values requires a privileged admin key, creating a central point of failure and community distrust. On-chain governance decentralizes this control, allowing token holders to propose, vote on, and execute parameter updates.

The technical foundation is a governance smart contract that holds the authority to call specific functions on the AMM core contracts. A typical flow involves three stages: Proposal, Voting, and Execution. First, a proposer submits a transaction to the governance contract specifying the target AMM contract, the function to call (e.g., setSwapFee(uint24 newFee)), and the proposed argument. This proposal is then subject to a timelock period, giving the community time to review the changes before voting begins.

During the voting period, governance token holders cast votes weighted by their stake. Major protocols like Uniswap and Curve use quorum and vote threshold mechanisms to ensure legitimacy. For example, a proposal may require a minimum quorum of 4% of the total token supply to participate and a majority of 50%+1 votes in favor to pass. Implementing this requires a voting contract that tracks votes and, upon successful passage, queues the action for execution after a mandatory delay—a timelock—which is a critical security feature to allow users to react to approved changes.

Here is a simplified code snippet for a governance proposal interaction using a typical structure:

solidity
// Pseudocode for proposing a fee change
IGovernor(governanceContract).propose(
    targets: [ammPoolAddress],
    values: [0],
    calldatas: [abi.encodeWithSignature("setSwapFee(uint24)", 300)], // Proposal for 0.03% fee
    description: "Proposal #42: Reduce swap fee to 0.03% to increase volume"
);

After the proposal succeeds and the timelock expires, any account can trigger the execute function, which will finally call setSwapFee on the AMM pool.

Best practices for parameter governance include setting conservative initial thresholds, providing clear off-chain discussion forums (like Commonwealth or governance forums), and using on-chain simulations via tools like Tenderly to model the impact of parameter changes before voting. It's also advisable to segment parameters by risk; critical changes (like fee changes over 50%) could require a higher threshold or longer timelock than minor tweaks. This layered approach balances agility with security.

Ultimately, effective parameter governance transforms an AMM from a static piece of infrastructure into a dynamic, community-owned protocol. It aligns incentives by giving stakeholders direct control over the economic levers that affect their returns. For developers, integrating a standard governance module like OpenZeppelin's Governor contract provides a secure, audited foundation to build upon, reducing implementation risk and accelerating deployment.

ARCHITECTURE

Comparison of Governance Frameworks: Compound vs. veToken

Key differences between two dominant on-chain governance models for managing AMM protocol parameters.

Governance FeatureCompound v2 (Governor Bravo)Curve Finance (veToken Model)

Voting Power Basis

Token-weighted (1 token = 1 vote)

Time-locked token weighted (veCRV)

Delegation

Yes, via smart contract

No, votes are non-transferable

Proposal Threshold

65,000 COMP (~$250k)

2,500 veCRV (~$1.5M at lock max)

Quorum Requirement

400,000 COMP (~4% supply)

30% of veCRV supply

Voting Delay

~2 days (13,140 blocks)

Minimum 2 days (configurable)

Voting Period

~3 days (19,740 blocks)

Minimum 3 days (configurable)

Parameter Control

Full (fees, reserves, markets)

Primarily gauge weights & emissions

Vote Snapshot

Block number at proposal creation

Weekly epoch (Thursdays 00:00 UTC)

implement-compound-governor
GOVERNANCE TUTORIAL

Implementing Parameter Control with Compound Governor

A step-by-step guide to using Compound's Governor framework to manage on-chain parameters for an Automated Market Maker (AMM).

The Compound Governor is a modular, open-source smart contract framework for building decentralized governance. It allows a community of token holders to propose, vote on, and execute changes to a protocol. For an AMM, this is critical for managing parameters like swap fees, liquidity provider (LP) rewards, and pool weights without relying on a centralized admin key. The system comprises three core contracts: the Governance Token (for voting power), the Governor Contract (to manage proposals), and a Timelock (to queue and delay executed actions). This separation of powers enhances security and transparency.

To begin, you must deploy and configure the Governor contract. Key parameters are set at deployment, including the voting delay (time before voting starts on a proposal), voting period (duration of the vote), proposal threshold (minimum tokens needed to submit a proposal), and quorum (minimum votes required for a proposal to pass). For an AMM managing sensitive parameters like a 0.3% swap fee, a typical configuration might be a 1-day voting delay, a 3-day voting period, a 1% proposal threshold of the total token supply, and a 4% quorum. These values balance responsiveness with security against proposal spam.

The core action is creating a proposal to modify an AMM contract. A proposal is a list of target addresses, values, and calldata for function calls. For example, to change the swapFee on a Uniswap V2-style router from 0.3% to 0.25%, you would encode a call to the setSwapFee function. This encoded data, along with the target contract address, forms the proposal's action. Proposers must hold tokens above the threshold. Once submitted, the proposal enters a review period (votingDelay), followed by the active voting period where token holders cast their votes.

Voting power is typically determined by a snapshot of token balances at the start of the voting period, preventing last-minute manipulation. Users can vote For, Against, or Abstain. After the voting period ends, the proposal is queued in the Timelock contract if it meets quorum and has more For than Against votes. The Timelock imposes a mandatory delay (e.g., 2 days) before the action can be executed. This delay gives users a final safety window to exit the system if they disagree with the passed change. Finally, anyone can call the execute function to apply the parameter update to the AMM.

Best practices for secure AMM parameter governance include using a bravo-style governance token with delegation, implementing a long enough Timelock delay (48+ hours) for community reaction, and setting a meaningful quorum to ensure broad consensus. It's also advisable to use separate, granular proposals for each parameter change to keep voter intent clear. For developers, thoroughly test proposal creation and execution on a testnet using tools like Hardhat or Foundry. The official Compound Governor documentation and OpenZeppelin's Governor implementation are essential references.

implement-vetoken-model
VE TOKEN MODEL

Setting Up Governance for AMM Parameter Adjustments

A veToken-based governance system allows a protocol to delegate control over critical Automated Market Maker (AMM) parameters to its most committed token holders. This guide explains how to implement the voting logic that enables this decentralized control.

The core mechanism for parameter governance in a veToken model is a vote-locking contract. Users lock their protocol tokens (e.g., ERC-20 tokens) to receive non-transferable, time-weighted voting power in the form of veTokens. The voting power vp is typically calculated as vp = amount * (lock_time / max_lock_time). This design aligns long-term incentives, as users with larger, longer-term commitments have greater influence over the protocol's future. The veToken balance is the key that unlocks governance rights.

Once voting power is established, it can be directed toward specific gauge weight votes or parameter proposal votes. For AMM parameter adjustments, a common pattern is to create executable proposals that modify values in the AMM's core contracts. For example, a proposal could change the swap fee percentage, the amplifier constant in a Curve-style pool, or the relative weights of assets in a Balancer pool. The proposal contract stores the new parameter value and the target contract address.

The voting process is managed by a Governor contract, often based on OpenZeppelin's governance standards. This contract handles proposal creation, the voting period, vote tallying, and execution. A user's vote weight is their veToken balance at the block the proposal was created. A typical implementation uses a vote function where a user specifies the proposal ID and their support (e.g., 1 for yes, 0 for no). The contract logic sums the veToken balances of all voters to determine the outcome.

Here is a simplified code snippet for a core voting function using a checkpointed veToken balance:

solidity
function castVote(uint256 proposalId, uint8 support) external returns (uint256) {
    address voter = msg.sender;
    uint256 votingPower = veToken.getPastVotes(voter, proposalSnapshot(proposalId));
    require(votingPower > 0, "No voting power");
    _castVote(proposalId, voter, support, votingPower);
    return votingPower;
}

The getPastVotes function is crucial; it reads the voter's veToken balance from a historical checkpoint taken at the proposal's snapshot block, preventing manipulation by locking or unlocking tokens after a vote has started.

After a successful vote, the proposal must be queued and executed. The Governor contract will have an execute function that calls the target contract with the encoded new parameter data. It is critical that the execution is permissionless but gated by the governance vote's success criteria (e.g., quorum and majority). Security considerations include implementing a timelock between vote conclusion and execution. This delay allows users to react to malicious or risky parameter changes by exiting liquidity positions before the change takes effect.

Effective parameter governance requires clear interfaces and monitoring. Proposals should explicitly state the current value, the proposed value, and the expected impact on pool dynamics (e.g., slippage, impermanent loss, revenue). Tools like Tally or Snapshot (for off-chain signaling) provide user interfaces for voting. For on-chain execution, integrating with a multisig or timelock contract as the final executor adds a critical layer of security, ensuring that even a passed proposal undergoes a final review period before altering live system parameters.

proposal-lifecycle-code
GOVERNANCE IN ACTION

Code Walkthrough: A Complete Proposal Lifecycle

This guide walks through the technical implementation of a full governance proposal to adjust parameters on a Uniswap V3-style Automated Market Maker (AMM), from smart contract interaction to on-chain execution.

Governance in decentralized protocols like Uniswap or Compound is executed through a series of smart contract calls. A typical lifecycle involves four main stages: proposal creation, voting, queueing, and execution. For an AMM, a common proposal might adjust a critical parameter like the protocol fee percentage, tick spacing, or the fee tier for a specific pool. These changes are not immediate; they follow a timelock pattern to give users time to react. We'll use Solidity and the OpenZeppelin Governor contract framework as our reference implementation.

The process begins with proposal creation. A governance token holder with sufficient voting power (e.g., above a proposalThreshold) calls the propose function on the governor contract. The function's arguments include a list of target addresses (the AMM's core contracts), values (usually 0 for non-payment calls), and calldata payloads. For a fee change, the calldata would encode a call to the pool's setProtocolFee function. Once submitted, the proposal gets a unique ID and enters a pending state for the votingDelay period, allowing voters to review.

After the delay, the voting period begins, typically lasting several days. Token holders cast their votes using castVote, specifying the proposal ID and their support (1 for, 0 against, 2 abstain). Votes are weighted by the voter's token balance at the block when the proposal was created, preventing manipulation via token transfers. The proposal succeeds if, after the voting period ends, the total votes "for" exceed a quorum (a minimum percentage of total supply) and outnumber votes "against." Off-chain voting platforms like Tally or Snapshot often provide a frontend for this process.

A successful proposal must then be queued before execution. This involves calling the queue function, which places the proposal in a Timelock contract. The Timelock enforces a mandatory waiting period (e.g., 48 hours), a critical security feature that allows users to exit the system if they disagree with the pending change. The proposal's ETA (Estimated Time of Arrival) is set to block.timestamp + delay. During this period, the encoded calldata to adjust the AMM parameter sits in the Timelock's queue, immutable and publicly visible.

Finally, after the timelock delay expires, anyone can call the execute function. This triggers the Timelock to perform the low-level call to the target AMM contract with the stored calldata, thereby implementing the parameter change—for instance, updating the protocol fee from 10% to 12%. The state change is now permanent. It's crucial to verify the proposal's effects post-execution by checking the contract state directly or through a block explorer like Etherscan to confirm the new parameter is active.

RISK ASSESSMENT

Risk Matrix for Governance-Controlled Parameters

Risk levels and governance considerations for key AMM parameters that can be adjusted via on-chain voting.

Parameter / FunctionLow Risk (Tier 1)Medium Risk (Tier 2)High Risk (Tier 3)

Swap Fee Rate

Adjustment within ±0.05% of current rate

Adjustment between ±0.06% to ±0.25%

Adjustment exceeding ±0.25% or to 0%

Protocol Fee Switch

Toggle off (0%)

Toggle on at ≤10% of swap fees

Toggle on at >10% of swap fees

Amplification Coefficient (A) for StableSwap

Adjustment within ±10 of current value

Adjustment between ±11 to ±50

Adjustment exceeding ±50 or to 1

Withdrawal Fee (for veToken models)

Fee change ≤0.01%

Fee change between 0.02% to 0.1%

Fee change >0.1% or new fee introduction

Governance Voting Delay

Change by < 1000 blocks

Change by 1000 to 10000 blocks

Change by > 10000 blocks or to 0

Whitelist for New Pool Factories

Add 1-2 audited, established factories

Add 3-5 new or unaudited factories

Remove all factory whitelists or add >5

Emergency Admin Powers

Extend timelock by 24h for security patch

Pause specific pool type for 48h

Grant unlimited pause/migrate authority

Oracle Freshness Threshold

Increase from 2h to 4h

Increase from 4h to 24h

Disable oracle checks or set to >7 days

PARAMETER MANAGEMENT

Frequently Asked Questions on AMM Governance

Common questions and troubleshooting for developers implementing or interacting with governance systems for Automated Market Maker (AMM) parameters.

The process is a multi-step, on-chain workflow managed by a governance token (e.g., UNI, CRV). A typical flow is:

  1. Proposal Creation: A governance member with a minimum token threshold submits a proposal, specifying the new fee parameter (e.g., changing a 0.3% swap fee to 0.25%).
  2. Voting Period: Token holders vote "For," "Against," or "Abstain" for a fixed period (often 3-7 days). Voting power is usually proportional to tokens staked or delegated.
  3. Time Lock & Execution: If the proposal passes a predefined quorum and majority threshold, it enters a timelock delay (e.g., 48 hours). This security period allows users to react before the changes are executed by the protocol's TimelockController.

Failure points include insufficient voter turnout (missing quorum) or the proposal being "queued" incorrectly for execution.

security-best-practices
SECURITY CONSIDERATIONS AND BEST PRACTICES

Setting Up Governance for AMM Parameter Adjustments

Decentralized governance for Automated Market Makers (AMMs) requires a secure framework to manage critical protocol parameters like fees, weights, and incentives. This guide outlines key security models and implementation strategies.

AMM governance controls parameters that directly impact protocol revenue, liquidity provider (LP) yields, and trader costs. Key adjustable parameters include the swap fee percentage, protocol fee ratio, amplification coefficient (for stable pools), and gauge weights for liquidity mining incentives. A poorly secured governance system can lead to treasury theft, value extraction, or protocol insolvency. For example, an attacker gaining control could set swap fees to 100% or drain the fee treasury. Governance must be designed with explicit checks, timelocks, and multi-signature safeguards.

The core security model involves separating proposal power from execution power. A common pattern uses a Governor contract (like OpenZeppelin's) where token holders vote on proposals, but execution is mediated by a TimelockController. This introduces a mandatory delay between a proposal's approval and its execution, providing a final safety window. During this delay, stakeholders can analyze the calldata and, if malicious, prepare counter-measures such as exiting liquidity or initiating an emergency shutdown via a separate guardian multisig. The timelock should be set appropriately (e.g., 2-7 days) based on the parameter's sensitivity.

When implementing parameter changes, all transactions must be explicit and bounded. Proposals should call specific, audited functions on the AMM pool or factory contract—never use generic call or delegatecall with arbitrary data. For instance, a proposal to update a swap fee should directly call pool.setSwapFeePercentage(uint256). Use parameter bounds within the contract logic itself; the setter function should require(newFee >= MIN_FEE && newFee <= MAX_FEE). These min/max values are non-upgradable constants or governed by a separate, slower process, preventing a single proposal from moving fees to an extreme value.

Upgradability of the governance system itself presents a major risk. Avoid using transparent proxy patterns for the core Governor or Timelock, as they centralize upgrade power. Instead, consider a brakes system or a dual-governance model like those used by MakerDAO or Curve. In such systems, changes to the governance apparatus require even higher thresholds, longer timelocks, or a separate vote using a different token (e.g., ve-token vs. governance token). All governance contracts should be comprehensively audited by multiple firms, and major parameter changes should be simulated on a testnet fork using tools like Tenderly or Foundry's forge script before live execution.

Finally, establish clear off-chain processes to complement on-chain security. This includes a community forum for Temperature Checks and Request for Comments (RFCs) before any on-chain proposal, ensuring broad consensus. Use snapshot voting for signaling off-chain before committing irreversible on-chain transactions. Maintain an emergency pause function controlled by a reputable, geographically distributed multisig to halt the system if a malicious proposal passes. By combining bounded on-chain functions, timelocks, multi-sig guardians, and robust community processes, AMMs can achieve secure and resilient parameter governance.

conclusion-next-steps
GOVERNANCE

Conclusion and Next Steps for Deployment

Your governance framework is configured. This section outlines the final verification steps and operational procedures for a secure, decentralized launch.

Before deploying your governance contracts to mainnet, conduct a final audit and simulation. Use a testnet like Goerli or Sepolia to execute the full governance lifecycle: - A user proposes a parameter change (e.g., adjusting the swap fee from 0.3% to 0.25%). - Token holders vote on the proposal. - The timelock executes the proposal after the delay. Verify that the TimelockController successfully calls the setFee function on your AMM's PoolManager contract. Tools like Tenderly's fork simulation or OpenZeppelin Defender's Sentinels are ideal for this dry run.

With testing complete, proceed to mainnet deployment in this sequence: 1. Deploy the token (e.g., MyAMMGovToken). 2. Deploy the governance contract (e.g., GovernorContract). 3. Deploy the timelock controller (e.g., TimelockController). 4. Grant the timelock the DEFAULT_ADMIN_ROLE and any specific roles (like FEE_SETTER_ROLE) on your core AMM contracts. 5. Transfer ownership of the governance contract to the timelock. Crucially, renounce any admin privileges held by your deployment EOA to ensure full decentralization.

Post-deployment, establish clear operational guidelines for your community. Document the process for creating proposals, including the required calldata format for AMM functions. For example, a proposal to update a Uniswap V3 pool's fee tier would encode a call to the Factory contract. Set up monitoring using The Graph for proposal indexing and Discord/Snapshot bots for notifications. The initial governance parameters (voting delay, voting period, proposal threshold) should be conservative but can be amended by future proposals, embodying the self-sovereign nature of the system.