Smart Contracts
Agora Stable Swap is a collection of smart contracts, consisting of a singleton factory and many pairs. These have been audited, providing safety guarantees for all participants interacting with the system. All contracts within the Agora’s Stable swap ecosystem are deployed following an upgradeable proxy pattern.
Factory – AgoraStableSwapFactory
The Factory is the deployment contract:
- Deploys new pairs to deterministic CREATE3 addresses derived from
token0andtoken1 - Holds the canonical implementation address (
stableSwapImplementation) used by every pair proxy. - View helpers & data registry
getAllPairData()→ array of every pair with token metadataallPairs()→ ordered list of pair addressescomputePairDeploymentAddress(tokenA, tokenB)– off-chain address predictionstableSwapProxyAdmin()– ProxyAdmin address for governance upgrades
Only wallets with the APPROVED_DEPLOYER role can create new pairs; the Factory owner can curate that list.
Pair – AgoraStableSwapPair
Each Pair proxy represents a dual-token pool (e.g., AUSD / USDT) and implements the familiar Uniswap-V2 swap surface, plus oracle-driven pricing:
- Core functionality
swapTokensForExactTokensandswapExactTokensForTokensexecute fixed-price trades for whitelisted users (APPROVED_SWAPPERrole).- Reserves and accumulated fees are updated atomically and surfaced via
reserve0,reserve1, andSwapFees.
- Oracle helpers
getPrice()/getPrice(timestamp)– token0 / token1 price including linear interest-rate driftgetPriceNormalized()– same price normalized for differing token decimals
- Role-based management
- Fee Setter adjusts per-side purchase fees within bounds.
- Price Setter pushes base price and interest rate.
- Token Remover collects fees or withdraws idle inventory to the treasury.
- Pauser can halt swaps in an emergency.
- All role membership is controlled by the Admin role.
- Upgradeable storage follows the EIP-1967 + ERC-7201 unstructured pattern used across Agora contracts.
Source code and ABIs for both the Factory and Pairs live in the contracts/ directory of this repository.

