> For a complete index of Agora Finance documentation, fetch https://docs.agora.finance/llms.txt # Smart Contracts > Overview of the Instant Settlement smart contract architecture — factory and pair contracts `Agora Instant Settlement` 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 Agora's Instant Settlement 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 `token0` and `token1` * **Holds the canonical implementation** address (`stableSwapImplementation`) used by every pair proxy. * **View helpers** & data registry * [`getAllPairData()`](/instant-settlement/smart-contracts/factory-contract#getallpairdata) → array of every pair with token metadata * `allPairs()` → ordered list of pair addresses * [`computePairDeploymentAddress(tokenA, tokenB)`](/instant-settlement/smart-contracts/factory-contract#computepairdeploymentaddress) – off-chain address prediction * `stableSwapProxyAdmin()` – 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** * [`swapTokensForExactTokens`](/instant-settlement/smart-contracts/pair-contract#swaptokensforexacttokens) and [`swapExactTokensForTokens`](/instant-settlement/smart-contracts/pair-contract#swapexacttokensfortokens) execute fixed-price trades for whitelisted users ([`APPROVED_SWAPPER`](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) role). * Reserves and accumulated fees are updated atomically and surfaced via `reserve0`, `reserve1`, and `SwapFees`. * **Oracle helpers** * [`getPrice()`](/instant-settlement/smart-contracts/pair-contract#read-only-functions) / [`getPrice(timestamp)`](/instant-settlement/smart-contracts/pair-contract#read-only-functions) – token0 / token1 price including linear interest-rate drift * [`getPriceNormalized()`](/instant-settlement/smart-contracts/pair-contract#read-only-functions) – same price normalized for differing token decimals * **Role-based management** * [**Fee Setter**](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) adjusts per-side purchase fees within bounds. * [**Price Setter**](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) pushes base price and interest rate. * [**Token Remover**](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) collects fees or withdraws idle inventory to the treasury. * [**Pauser**](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) can halt swaps in an emergency. * All role membership is controlled by the [**Admin**](/instant-settlement/smart-contracts/pair-contract#accesscontrol-roles) 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. > Documentation for the AUSD stablecoin and Agora's APIs. ## Docs - [Factory Contract](https://docs.agora.finance/instant-settlement/smart-contracts/factory-contract.md): Factory contract API reference — creating pairs, querying deployments, and deterministic CREATE3 addresses - [Pair Contract](https://docs.agora.finance/instant-settlement/smart-contracts/pair-contract.md): Pair contract API reference — swap execution, reserve management, pricing, and fee configuration