# On-Chain Contracts

### **1. Overview**

Deploy’s smart contracts form the on-chain backbone of the protocol. They governs how dAssets (dUSD) are issued, redeemed, staked, and yield-distributed, while maintaining verifiable 1:1 collateral backing.

All contracts are currently undergoing an audi&#x74;**,** and designed with strict role segregation to reduce operational risk.

The system consists of three primary modules:

| Module            | Contract            | Purpose                                                                           |
| ----------------- | ------------------- | --------------------------------------------------------------------------------- |
| **Asset Layer**   | `dUSD.sol`          | ERC-20 representations of synthetic assets (1:1 backed).                          |
| **Minting Layer** | `DeployMinting.sol` | Handles EIP-712 signed mint/redeem orders, custodian routing, and access control. |
| **Staking Layer** | `StakedDUSD.sol`    | ERC-4626 vaults for staking and yield accrual.                                    |

***

### **2. Asset Layer**

#### **dUSD.sol**

* Standard ERC-20 implementations of Deploy’s synthetic assets.
* Each token contract maintains a single privileged address, the `minter`, which is set to the minting contract.
* Owner (multi-sig) can rotate or revoke the minter if required.
* No other permissions exist. Minting and burning are fully restricted.

**Core Functions**

* `mint(address to, uint256 amount)`  callable only by `DeployMinting.sol`.
* `burn(address from, uint256 amount)`  callable only by `DeployMinting.sol` or the designated redeemer.

***

### **3. Minting Layer**

#### **DeployMinting.sol**

The core operational contract managing issuance and redemption of dAssets. It enforces all permissions, routes collateral, validates user signatures, and ensures every mint/redeem event adheres to the protocol’s collateral and custody requirements.

**Key Responsibilities**

* Validate EIP-712 signed orders for both mint and redeem.
* Route collateral exclusively to whitelisted MPC custodian addresses.
* Apply per-block mint and redeem ceilings to mitigate risk.
* Maintain a list of approved beneficiary wallets that are allowed to mint/redeem

**Roles & Access Control**

| Role                 | Description                                                                                      |
| -------------------- | ------------------------------------------------------------------------------------------------ |
| `DEFAULT_ADMIN_ROLE` | Cold multi-sig. Can assign or revoke all roles, manage custodians, supported tokens, and limits. |
| `MINTER`             | Authorized operational wallet(s) allowed to execute verified mint orders.                        |
| `REDEEMER`           | Authorized wallet(s) for redemption once custodian prefunds are confirmed.                       |
| `GATEKEEPER`         | Independent safety key; can disable minting/redeeming and revoke roles instantly.                |

### **4. Staking Layer**

#### **StakedDUSD.sol**

Deploy’s staking contracts enable users to earn yield on their dAssets. Each vault follows the ERC-4626 Tokenized Vault standard, ensuring transparency and compatibility across DeFi.

**Core Functions**

* `deposit(uint256 assets, address receiver)`  stake dAssets and receive sdAssets (vault shares).
* `withdraw(uint256 assets, address receiver, address owner)`  initiate unstake; triggers cooldown.
* `previewDeposit()` / `previewWithdraw()` read-only functions for front-end integrations.

**Key Properties**

* **In-kind yield:** Vault balances increase as yield (in dUSD) is periodically deposited.
* **Cooldown Period:** Delay between unstake and claim.
* **1:1 Redeemability:** Staked and unstaked dAssets remain part of the same fully-collateralized pool.
* **Single-Asset Vaults:** One vault per dAsset type (sdUSD).

**Safety Measures**

* Vaults only receive positive inflows, share price can never decrease.
* Cooldown prevents rapid entry/exit gaming around yield updates.

### **5. Governance & Ownership**

| Contract            | Controlled By        | Powers                                                         |
| ------------------- | -------------------- | -------------------------------------------------------------- |
| `dUSD`              | Cold multi-sig       | Update `minter`, revoke or reassign in emergencies.            |
| `DeployMinting.sol` | Admin multi-sig      | Assign/revoke roles, manage custodians, adjust per-block caps. |
| `StakedVaults`      | Governance multi-sig | Configure cooldown duration, fee split, and yield parameters.  |
