Contracts

ParCircuit

Circles, members, invoices, netting and settlement.

ParCircuit is the central counterparty for trade-credit circles: membership, invoices, incremental netting, settlement and claims. One contract serves every circle.

Source: contracts/contracts/ParCircuit.sol · Address: 0x198099cF3C11A6A7E0f107a63B013E20A96f9CB1

The constructor takes the ParFactory; MUSD is read from it. Only vaults created by that factory can back a membership.

Types#

TypeFields
Circleadmin, genesis, cycleLength, settleWindow, exists
Membervault, lineId, active
Invitevault, lineId, open
InvoicecircleId, creditor, debtor, amount, cycle, status, ref
InvStatusNone (0), Pending (1), Accepted (2), Rejected (3)

Circles and members#

FunctionAccessDescription
createCircle(uint64 cycleLength, uint64 settleWindow) → idAnyoneCaller becomes admin; genesis is now. Requires cycleLength > 0 and settleWindow ≤ cycleLength. Emits CircleCreated.
addMember(uint256 circleId, address member, address vault, uint256 lineId)AdminCreates (or replaces) an invite for member with this vault and line, after checking the line. Emits MemberInvited.
join(uint256 circleId, address vault, uint256 lineId)Invited memberAccepts the invite. Checks the line again, and that it is not bound to another membership. Re-pointing an existing membership requires no exposure on the old line. Emits MemberJoined.
setSuspended(uint256 circleId, address member, bool value)AdminSuspends (or reinstates) an active member, e.g. a defaulter: no new invoices to or from them (Suspended). Existing obligations stay collectable (settle, forceSettle) and their credits stay claimable. Emits MemberSuspended.
removeMember(uint256 circleId, address member)Admin or the memberOnly with zero outstanding and a zero net in the current and previous cycle. Frees the line. Emits MemberRemoved.

Line checks (at invite, at join): the vault is a factory vault (NotParVault); the circle exists and the member owns the vault (BadParams); the commitment is an active ClearingLine whose beneficiary is ParCircuit (BadParams); and its expiry is at least cycleClose(current cycle) + settleWindow (LineExpiresTooSoon).

Invoices#

FunctionAccessDescription
createInvoice(uint256 circleId, address debtor, uint128 amount, bytes32 ref) → idActive memberBills another active member in the current cycle. Neither side may be suspended (Suspended). Emits InvoiceCreated.
acceptInvoice(uint256 id)DebtorSame cycle only (WrongCycle); neither side may be suspended (Suspended). Updates both nets, gross, totalOwed and the debtor's outstanding. If the debtor ends up a net debtor: the line must live until this cycle's settle deadline (LineExpiresTooSoon) and outstanding ≤ available() (OverLimit). Emits InvoiceAccepted.
rejectInvoice(uint256 id)Debtor or creditorRejects a pending invoice. Emits InvoiceRejected.

Settlement#

FunctionAccessDescription
settle(uint256 circleId, uint64 cycle)Net debtorAfter cycleClose. Pulls the owed MUSD (approve first). Late settlement is accepted, even after the cycle is final. Emits Settled(..., false).
forceSettle(uint256 circleId, uint64 cycle, address debtor, address up, address lo)AnyoneAfter cycleClose + settleWindow. Draws the debtor's clearing line for exactly the amount owed, even if the line has expired since the debt was booked. Emits Settled(..., true).
claim(uint256 circleId, uint64 cycle)Net creditorIn full once collected ≥ totalOwed; otherwise, after finalAt, pro rata credit × collected ÷ totalOwed minus what was already claimed. Can be called again as more is collected. Emits Claimed, and CycleFinalized on the first pro-rata claim.

Views#

FunctionReturns
currentCycle(uint256 circleId) → uint64(now − genesis) ÷ cycleLength.
cycleClose(uint256 circleId, uint64 cycle) → uint256genesis + (cycle + 1) × cycleLength.
finalAt(uint256 circleId, uint64 cycle) → uint256cycleClose + settleWindow + cycleLength.
creditLimit(uint256 circleId, address member) → uint256What the member's line can still pay (available(lineId)), or 0.
lineHeadroom(uint256 circleId, address member) → uint256creditLimit − outstanding, floored at 0.
nettingEfficiencyBps(uint256 circleId, uint64 cycle) → uint256(gross − totalOwed) × 10000 ÷ gross.
members_(uint256 circleId) → address[]Everyone who ever joined (check members(c, m).active).
circles(id), members(circleId, member), invites(circleId, member), invoices(id)Struct getters.
net(circleId, cycle, member) → int256Positive receives, negative owes.
gross, totalOwed, collected (circleId, cycle) → uint256Cycle totals.
suspended(circleId, member) → boolWhether the admin has suspended the member.
settled(circleId, cycle, member) → boolDebtor paid, or creditor claimed in full.
claimed(circleId, cycle, creditor) → uint256What a creditor has received so far.
finalized(circleId, cycle) → boolSet on the first pro-rata claim.
outstanding(vault, lineId) → uint256Unsettled obligations on a line across all cycles.
lineBound(vault, lineId) → boolWhether the line currently backs a membership.
musd(), factory(), nextCircleId(), nextInvoiceId()Addresses and counters.

Events#

EventEmitted when
CircleCreated(uint256 indexed circleId, address admin, uint64 cycleLength, uint64 settleWindow)A circle is created.
MemberInvited(uint256 indexed circleId, address indexed member, address vault, uint256 lineId)The admin invites a member.
MemberJoined(uint256 indexed circleId, address indexed member, address vault, uint256 lineId)A member accepts.
MemberRemoved(uint256 indexed circleId, address indexed member)A member leaves or is removed.
MemberSuspended(uint256 indexed circleId, address indexed member, bool suspended)The admin suspends or reinstates a member.
InvoiceCreated(uint256 indexed id, uint256 indexed circleId, address creditor, address debtor, uint256 amount, uint64 cycle, bytes32 ref)An invoice is created.
InvoiceAccepted(uint256 indexed id, uint256 indexed circleId, uint64 cycle)The debtor accepts.
InvoiceRejected(uint256 indexed id)Either side rejects.
Settled(uint256 indexed circleId, uint64 indexed cycle, address indexed debtor, uint256 amount, bool forced)A debtor settles or is force-settled.
Claimed(uint256 indexed circleId, uint64 indexed cycle, address indexed creditor, uint256 amount)A creditor claims.
CycleFinalized(uint256 indexed circleId, uint64 indexed cycle, uint256 collected, uint256 totalOwed)The first pro-rata claim on a cycle.

Errors#

NotMember, NotAdmin, BadParams, WrongCycle, OverLimit(uint256 limit, uint256 wouldOwe), NotYet, Done, NotInvited, LineInUse, HasObligations, LineExpiresTooSoon(uint256 expiry, uint256 needed), NotParVault, Suspended. See Errors.

Last updated 16 November 2026Suggest an edit on GitHub