Contracts

ParFactory

Deploys one ParVault clone per user and holds the risk parameters.

ParFactory deploys one ParVault clone (EIP-1167) per call and stores the risk parameters every vault is initialised with. It also keeps a registry of vaults, which ParCircuit uses to accept only genuine Par vaults.

Source: contracts/contracts/ParFactory.sol · Address: 0x2907A39A64c3f304E7eEdF2F7107Bc825756E4f0

Functions#

FunctionAccessDescription
createVault() → address vaultAnyoneClones the implementation, initialises it with the caller as owner and the factory's parameters, registers it, and emits VaultCreated.
onVaultOwnerChanged(address from, address to)Vaults onlyCalled by a vault when a two-step ownership transfer completes. Moves the vault from vaultsOf[from] to vaultsOf[to]. Reverts NotVault() for any other caller.
vaultCount(address owner) → uint256ViewNumber of vaults owned by owner.
allVaultsLength() → uint256ViewNumber of vaults ever created.

State#

NameTypeDescription
implementationaddress (immutable)The ParVault implementation every clone points to. Locked at deploy so it can never be initialised.
borrowerOpsIBorrowerOperations (immutable)MUSD BorrowerOperations.
troveManagerITroveManager (immutable)MUSD TroveManager.
priceFeedIPriceFeed (immutable)MUSD PriceFeed.
musdIERC20 (immutable)The MUSD token.
stressBpsuint256 (immutable)Stress drop in basis points: 4000 (40%).
targetIcruint256 (immutable)Ratio required under stress: 1.6e18 (160%).
vaultsOf(address, uint256)addressThe vaults owned by an address, by index.
allVaults(uint256)addressEvery vault ever created, by index.
isVault(address)boolTrue for vaults created by this factory.

Events#

EventEmitted when
VaultCreated(address indexed owner, address vault)A vault is created.
VaultOwnerChanged(address indexed vault, address indexed from, address indexed to)A vault's ownership transfer completes.

Errors#

ErrorMeaning
NotVault()onVaultOwnerChanged was called by an address that is not a vault from this factory.

Example: find a user's vault#

TypeScript
import { createPublicClient, http } from "viem"import { mezoTestnet } from "viem/chains"import { parFactoryAbi } from "./abi" // generated: web/lib/abi.ts const client = createPublicClient({ chain: mezoTestnet, transport: http() })const factory = "0x2907A39A64c3f304E7eEdF2F7107Bc825756E4f0" const count = await client.readContract({ address: factory, abi: parFactoryAbi, functionName: "vaultCount", args: [user] })const vault = count > 0n  ? await client.readContract({ address: factory, abi: parFactoryAbi, functionName: "vaultsOf", args: [user, count - 1n] })  : undefined

ABIs are exported to web/lib/abi.ts and keeper/src/abi.ts by npm run abis in contracts/.

Last updated 16 November 2026Suggest an edit on GitHub