> For the complete documentation index, see [llms.txt](https://triple-plus-global.gitbook.io/tpt-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://triple-plus-global.gitbook.io/tpt-whitepaper/protocol-mechanics/smart-contracts.md).

# Smart Contracts

All capital flows through audited smart contracts with no centralized custody:

{% @mermaid/diagram content="sequenceDiagram
participant S as Seller
participant E as Escrow Contract
participant I as Investor
participant D as Debtor
participant O as Oracle

```
S->>E: Submit verified asset
I->>E: Deposit investment
E->>S: Release funds (immediate)
Note over E: Asset held in escrow
D->>E: Pay invoice at maturity
O->>E: Confirm payment received
E->>I: Release principal + yield" %}
```

## Escrow Mechanism

The escrow contract holds:

| Item                       | Description                                |
| -------------------------- | ------------------------------------------ |
| **Asset ownership rights** | Tokenized representation of the receivable |
| **Investor capital**       | Held until released to seller              |
| **Debtor payments**        | Held until distributed to investors        |

**No party—including the protocol team—can unilaterally access escrowed funds.**

## Settlement Triggers

Automated settlement occurs when:

* Debtor payment confirmed (via oracle or direct deposit)
* Maturity date reached
* All conditions in smart contract satisfied

Manual intervention is only possible through governance for exceptional circumstances (e.g., dispute resolution).

## Contract Architecture

{% @mermaid/diagram content="flowchart TB
subgraph Core\["Core Contracts"]
ESC\["Escrow"]
SET\["Settlement"]
REG\["Registry"]
end

```
subgraph Access["Access Control"]
    STAKE["Staking"]
    KYC["KYC/KYB"]
end

subgraph Assets["Asset Contracts"]
    INV["Invoice NFT"]
    PO["PO NFT"]
end

Access --> Core
Assets --> Core" %}
```

## Upgrade Mechanism

Contracts use a transparent proxy pattern:

| Feature                | Description                            |
| ---------------------- | -------------------------------------- |
| **Multi-sig approval** | Upgrades require multiple signatures   |
| **Time-lock delay**    | Waiting period on all upgrades         |
| **Emergency pause**    | Halt functionality for critical issues |

## Audit Status

All smart contracts undergo:

* Pre-deployment third-party audits
* Ongoing bug bounty program
* Formal verification for critical functions

{% hint style="warning" %}
Audit reports will be linked here upon completion.
{% endhint %}
