> For the complete documentation index, see [llms.txt](https://docs.syndromics.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.syndromics.xyz/architecture/deployment.md).

# Deployment

The contracts are a Foundry project in `contracts/` at the root of the Syndromics repository.

## Production addresses

The canonical list of deployed contract addresses on Robinhood Chain (chain ID 4663) is `contracts/deployments/4663.json` in the repository. The platform reads the same addresses from the `deployment` row of its protocol parameters, and the explorer shows the `LoanSettlement` address on the parameters panel. No address should be trusted unless it appears in that file. Source is verified on Blockscout for every deployment.

## Build and test

```bash
cd contracts
forge soldeer install      # forge-std and OpenZeppelin into dependencies/, no git submodules
forge build
forge test -vv
```

The suite has 49 tests across five files:

| File                | Covers                                                                                                                                                                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Settlement.t.sol`  | Three-lender syndicate, LTV ceiling, ineligible borrower and lender, APR mismatch, cancelled offers, standing offers across loans, relayer path, exposure cap, guardian pause, idle-capital fills                                                 |
| `Repayment.t.sol`   | Per-slice accrual against the documented example, minimum interest period, full and partial repayment, top-up, repayment during grace and under pause, third-party repayment                                                                      |
| `Liquidation.t.sol` | Health factor tracking, full Dutch auction with proceeds distribution, partial buys, liquidator role, default after grace, sequencer grace, oracle pause, move cap, closed-market haircut, split for opt-outs, in-kind, stream report requirement |
| `Refinance.t.sol`   | Open rules, linear rate, clearing with a new syndicate, failure and default, rate ceiling, borrower cancel, liquidation mid-refinance                                                                                                             |
| `Governance.t.sol`  | Bootstrap and timelock, guardian scope, parameter validation, attestation expiry and revocation, issuer removal, gated NFT transfer, fee withdrawal, one-shot wiring                                                                              |

## Deploying a new environment

Copy `.env.example` to `.env` and set at least:

```
PRIVATE_KEY=
ROBINHOOD_RPC=
```

Then:

```bash
source .env
forge script script/Deploy.s.sol --rpc-url robinhood --broadcast --verify
```

The script deploys and configures every contract in one run:

1. `ParamController`, `EligibilityRegistry`, `NativeAttestationAdapter`, `OracleRouter`, `PositionNFT`, `FeeCollector`, `LoanSettlement`, `LiquidationAuction`, `RefinanceAuction`.
2. Parameters in bootstrap mode: tiers A to C, the initial collateral tokens with their exposure caps, USDG as loan token, 7, 14, 30 and 90 day terms, loan, auction, refinance and fee parameters, the idle-capital vault whitelist.
3. Oracle feed configuration and the Chainlink Sequencer Uptime Feed.
4. `IdleCapitalAdapter`, then `PositionNFT.setSettlement`, `IdleCapitalAdapter.setSettlement` and `LoanSettlement.wire`.
5. `finishBootstrap()` and ownership hand-off to the governance multisig.

| Variable                                     | Purpose                                                                                                           |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `USDG`, `STOCK_TOKEN`, `STOCK_FEED`, `VAULT` | Live addresses of the settlement asset, the first collateral token, its Chainlink feed and the idle-capital vault |
| `SEQUENCER_FEED`                             | Chainlink L2 Sequencer Uptime Feed                                                                                |
| `MARKET_STATUS_SOURCE`                       | Contract exposing `marketStatus()` for session classification                                                     |
| `STREAM_ADAPTER`                             | Data Streams verifier adapter for auction pricing                                                                 |
| `GOV`, `GUARDIAN`                            | Governance multisig and pause guardian                                                                            |
| `TIMELOCK_DELAY`                             | Seconds. Cannot be set below 3600 once bootstrapped.                                                              |
| `ATTESTATION_ISSUER`                         | KYC signer allowed to issue attestations                                                                          |
| `FINISH_BOOTSTRAP`                           | `true` locks the ParamController to the timelock at the end of the script                                         |

Addresses are written to `contracts/deployments/<chainId>.json`.

## Local development

On a local Anvil chain the script deploys mock tokens, a mock Chainlink aggregator and a mock ERC-4626 vault when the live addresses are left blank, and attests the deployer for every role so the full loan flow can be exercised from the command line:

1. Mint mock USDG to a lender and mock Stock Tokens to a borrower, and approve `LoanSettlement` from both.
2. Sign a lend `Offer` (EIP-712, domain `Syndromics` / `1` / the local chain id, verifying contract `LoanSettlement`).
3. Call `settle(request, "", [offer], [signature])` from the borrower.
4. Read `debtOf`, `healthFactor` and the position NFT.
5. Move the mock feed with `MockAggregatorV3.set()` and call `LiquidationAuction.startAuction`, or `repay`.

Mocks are never part of a production deployment.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.syndromics.xyz/architecture/deployment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
