# System Architecture

### Core Contract Modules

The APACX Protocol implements a modular architecture with specialized contracts:

<table><thead><tr><th width="134">Contract</th><th>Function</th><th>Technical Notes</th></tr></thead><tbody><tr><td><code>Vat</code></td><td>Core ledger tracking collateral and debt positions</td><td>Maintains a global accounting system with all vault positions</td></tr><tr><td><code>Spot</code></td><td>Calculates collateral valuations</td><td>Applies collateral factors to oracle prices</td></tr><tr><td><code>Jug</code></td><td>Stability fee accrual mechanism</td><td>Uses compound interest formula to accumulate fees continuously</td></tr><tr><td><code>Dog</code></td><td>Coordinates liquidation process</td><td>Replaces the older <code>Cat</code> contract with improved efficiency</td></tr><tr><td><code>Clip</code></td><td>Dutch auction for liquidated collateral</td><td>Replaces the older <code>Flip</code> auction with fixed price decreases</td></tr><tr><td><code>Flap</code></td><td>Surplus auction distributing excess system value</td><td>Activated when system builds significant surplus</td></tr><tr><td><code>Flop</code></td><td>Debt auction to recapitalize the system</td><td>Activated during shortfalls to restore system solvency</td></tr><tr><td><code>End</code></td><td>Coordinates emergency shutdown</td><td>Ensures fair distribution of remaining collateral</td></tr></tbody></table>

These contracts interact through a carefully designed permission system that ensures security while enabling modular upgrades.

### Collateral Types

The protocol accepts various assets as collateral, each with risk parameters calibrated to its specific characteristics:

* Major Stablecoins: USDC, USDT with dynamic Liquidation Ratio, Debt Ceiling, and Stability Fee parameters.
* PHP-Pegged Stablecoins: Native tokens maintaining a 1:1 PHP peg through algorithmic or backed mechanisms.
* Regulated Assets: Government-issued debt or regulated financial instruments, subjected to enhanced due diligence and verification.

Each collateral type is managed in a separate ilk (collateral class) with independent risk parameters.

### Keeper Network

The decentralized keeper network ensures protocol automation:

* **Price Feed Updates**: Keepers monitor and submit Chainlink oracle updates to the Pip contract.
* **Liquidation Processing**: Identifies unhealthy vaults and triggers `Dog` to initiate liquidation.
* **Auction Participation**: Bids in collateral auctions to ensure efficient collateral liquidation.
* **System Maintenance**: Performs routine operations like debt ceiling adjustments.

Keepers are economically incentivized through auction participation fees and system rewards. The network operates without central coordination, increasing system resilience. The APACX Platform runs its own Keepers to ensure the safety and stability of the platform, especially after the initial deployment when other Keepers will not exist on the chain.

### External Integrations

| Integration       | Purpose                       | Technical Specifications                                     |
| ----------------- | ----------------------------- | ------------------------------------------------------------ |
| Chainlink Oracles | Price feed aggregation        | Maximum heartbeat of 24 hours with deviation threshold of 1% |
| Ethereum Mainnet  | Primary execution environment | EVM-compatible, gas optimization for complex operations      |
| Tron Network      | PHT Bridged environment       | Lower fee structure, cross-chain interoperability            |
