Skip to content
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
e62ac29
initial implementation
oddaf Feb 14, 2025
13e9d95
Update script/input/1/README.md
oddaf Feb 18, 2025
2d4ff02
Update src/DSPC.sol
oddaf Feb 18, 2025
2bccdbe
Update src/DSPC.sol
oddaf Feb 18, 2025
2c3f886
Update src/DSPC.sol
oddaf Feb 18, 2025
3c60b1f
Update src/DSPC.sol
oddaf Feb 18, 2025
52a59f7
refactor: rename function put to set
oddaf Feb 18, 2025
c04ef6c
fix: add check if data can be safely cast to uint16 in file()
oddaf Feb 18, 2025
d6ff178
refactor: remove step restriction
oddaf Feb 18, 2025
b341255
chore: forge fmt
oddaf Feb 18, 2025
917eb4d
refactor: Update Set event to be emitted for each rate update
oddaf Feb 18, 2025
def70fa
Update src/deployment/DSPCInstance.sol
oddaf Feb 19, 2025
9c2898d
Update src/deployment/DSPCInit.sol
oddaf Feb 19, 2025
b6c57c0
Update src/deployment/DSPCInit.sol
oddaf Feb 19, 2025
253af36
Update src/deployment/DSPCDeploy.sol
oddaf Feb 19, 2025
45a1834
Update src/deployment/DSPCDeploy.sol
oddaf Feb 19, 2025
cec6dc4
Update src/deployment/DSPCDeploy.sol
oddaf Feb 19, 2025
48b668a
Update src/deployment/DSPCInit.sol
oddaf Feb 19, 2025
b9482c3
refactor: use addresses instead of interfaces in DSPCInstance to ease…
oddaf Feb 19, 2025
2274abe
fix: enforce min < max and max > min on file()
oddaf Feb 19, 2025
75211ed
fix: typo in RelyLike
oddaf Feb 21, 2025
3d3a515
Update src/DSPC.sol
oddaf Feb 21, 2025
b7dadb5
feat: dspc cooldown + step
oddaf Feb 24, 2025
0582668
remove unnecessary setup from dspcMom test
oddaf Feb 24, 2025
e03048f
chore: forge fmt
oddaf Feb 24, 2025
d685819
Apply suggestions from code review
oddaf Feb 24, 2025
9dcf622
fix: revert message in test
oddaf Feb 24, 2025
0a79139
chore: forge fmt
oddaf Feb 24, 2025
a47d4ff
feat: improvements to initialization script
oddaf Feb 26, 2025
4077e06
Apply suggestions from code review
oddaf Mar 6, 2025
117aa00
chore: adjust tests for new var names
oddaf Mar 6, 2025
a1b8da7
chore: improve DSPCInit natspec
oddaf Mar 6, 2025
12d2bfd
feat: add bud address to DSPCConfig
oddaf Mar 6, 2025
c64ce03
fix: Remove setAuthority from deploy script in favor of only executin…
oddaf Mar 6, 2025
4f5bd78
Update src/DSPC.sol
oddaf Mar 7, 2025
bfc5de0
refactor: optimize storage layout
oddaf Mar 7, 2025
f6c7987
Update src/DSPC.sol
oddaf Mar 7, 2025
1d08161
chore: test case for tau overflow in file()
oddaf Mar 7, 2025
43ed724
fix: prevent duplicate ilks
oddaf Mar 10, 2025
c81e895
chore: fix natspec
oddaf Mar 10, 2025
4fc314a
chore: fix readme reference to SUSDS
oddaf Mar 10, 2025
cfe098a
refactor: fisibility of _cfgs to public
oddaf Mar 10, 2025
d45a82d
fix: check if ilk setup on set()
oddaf Mar 10, 2025
f6d6d67
chore: Add comment to file function (ilks) mentioned order of calls m…
oddaf Mar 10, 2025
827b25f
Update src/DSPC.sol
oddaf Mar 11, 2025
7342217
Update src/DSPC.t.sol
oddaf Mar 11, 2025
15e83c3
fix: update revert reason in test_revert_set_not_configured_rate
oddaf Mar 11, 2025
990ac84
fix: prevent setup of unexisting Ilks
oddaf Mar 11, 2025
94af8f0
refactor: ordering of ilks check
oddaf Mar 11, 2025
a67531b
refactor: improve invalid bad check
oddaf Mar 11, 2025
e5177a9
chore: improve natspec dos for file(what, data)
oddaf Mar 11, 2025
ea0b5f3
refactor: order of checks on set()
oddaf Mar 11, 2025
a72e855
fix: ilk initialization verification
oddaf Mar 12, 2025
6d0cf28
feat: allow ward to edit toc
oddaf Mar 13, 2025
61c6c88
feat: revert if current rate outside range
oddaf Mar 13, 2025
7145e55
Apply suggestions from code review
oddaf Mar 13, 2025
aec447a
Update src/mocks/ConvMock.sol
oddaf Mar 13, 2025
d9d9b5a
chore: update natspec of set() to include all cases where it reverts
oddaf Mar 13, 2025
1d678cb
chore: improve tests
oddaf Mar 14, 2025
d9612a6
chore: natspec
oddaf Mar 14, 2025
31512e2
chore: add step to readme.md instructions
oddaf Mar 14, 2025
2af4fe2
Update README.md
oddaf Mar 14, 2025
afc6f55
Apply suggestions from code review
oddaf Mar 14, 2025
8c0131b
Update README.md
oddaf Mar 14, 2025
50fd0d4
chore: order of operations in readme instructions
oddaf Mar 14, 2025
454136e
Merge branch 'initial-implementation' of https://github.com/dewiz-xyz…
oddaf Mar 14, 2025
13bc3b4
chore: order natspec revert reasons
oddaf Mar 14, 2025
473fffb
chore: update foundry.toml
oddaf Mar 14, 2025
4587323
chore: formatting
oddaf Mar 14, 2025
b7d6a98
chore: remove redundant selectors from test_auth_methods
oddaf Mar 14, 2025
aae64b8
chore: add .editorconfig
oddaf Mar 17, 2025
1f8b03c
Apply suggestions from code review
oddaf Mar 17, 2025
5650c3f
feat: rate covnersion check
oddaf Mar 17, 2025
4da6795
chore: forge fmt
oddaf Mar 17, 2025
e8c317b
refactor: allow setting rates when current rate out of bounds
oddaf Mar 18, 2025
84e5e3b
chore: test rates below min bound
oddaf Mar 18, 2025
54dacb4
chore: formatting
oddaf Mar 18, 2025
c9dfdfb
Apply suggestions from code review
oddaf Mar 19, 2025
4e7a435
Rename module (DSPC -> SPBEAM) (#9)
oddaf Mar 28, 2025
b46ac6b
chore: add audit reports
oddaf Apr 3, 2025
4ed07c8
Update README.md
oddaf Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Direct Stability Parameters Change Module (DSPC)

A module for the Sky Protocol that enables direct changes to stability parameters (duty, dsr, ssr) through a simple, secure interface with proper constraints and timelocks.

## Overview

The DSPC module provides a streamlined way to modify stability parameters in the Maker Protocol, including:
- Stability fees (duty) for different collateral types via the Jug contract
- Dai Savings Rate (DSR) via the Pot contract
- Sky Savings Rate (SSR) via the sUSDS contract

## Features

- Batch updates for multiple rate changes
- Two-level access control:
- Admins can configure the module
- Facilitators can propose and execute rate changes
- Rate change constraints:
- Min/max caps per rate
- Max update delta
- Event emission for all actions
- Simple, auditable implementation

## Installation

```bash
forge install
```

## Testing

```bash
forge test
```

## Usage

1. Deploy the contract with the required addresses:
```solidity
DSPC dspc = new DSPC(
jugAddress, // For stability fees
potAddress, // For DSR
susdsAddress, // For SSR
convAddress // For rate conversions
);
```

2. Configure the module parameters:
```solidity
// Set timelock duration
dspc.file("tau", 1 days);

// Configure constraints for a collateral type
dspc.file("ETH-A", "min", 1); // Min rate: 0.01%
dspc.file("ETH-A", "max", 1000); // Max rate: 10%
dspc.file("ETH-A", "step", 100); // Max change: 1%

// Configure constraints for DSR
dspc.file("DSR", "min", 1); // Min rate: 0.01%
dspc.file("DSR", "max", 800); // Max rate: 8%
dspc.file("DSR", "step", 100); // Max change: 1%
```

3. Add facilitators who can propose and execute rate changes:
```solidity
dspc.kiss(facilitatorAddress);
```

4. Execute a batch of rate changes:
```solidity
DSPC.ParamChange[] memory updates = new DSPC.ParamChange[](2);
updates[0] = DSPC.ParamChange("ETH-A", 150); // Set ETH-A rate to 1.5%
updates[1] = DSPC.ParamChange("DSR", 75); // Set DSR to 0.75%
dspc.set(updates);
```

## Security

The module implements a robust security model:
- Two-level access control (admins and facilitators)
- Rate constraints to prevent extreme changes
- Disabling without GSM delay via DSPCMom contract
- Circuit breaker (halt) functionality
- All actions emit events for transparency

## License

AGPL-3.0-or-later
61 changes: 61 additions & 0 deletions script/DSPCDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: © 2025 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pragma solidity ^0.8.24;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {DSPCDeploy, DSPCDeployParams} from "src/deployment/DSPCDeploy.sol";
import {DSPCInstance} from "src/deployment/DSPCInstance.sol";

contract DSPCDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "dspc-deploy";
string config;

address constant CHAINLOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F;
DssInstance dss = MCD.loadFromChainlog(CHAINLOG);
address pauseProxy = dss.chainlog.getAddress("MCD_PAUSE_PROXY");
address conv;
DSPCInstance inst;

function run() external {
config = ScriptTools.loadConfig();
conv = config.readAddress(".conv", "FOUNDRY_CONV");

vm.startBroadcast();

inst = DSPCDeploy.deploy(
DSPCDeployParams({
deployer: msg.sender,
owner: pauseProxy,
jug: address(dss.jug),
pot: address(dss.pot),
susds: dss.chainlog.getAddress("SUSDS"),
conv: conv
})
);

vm.stopBroadcast();

ScriptTools.exportContract(NAME, "dspc", address(inst.dspc));
ScriptTools.exportContract(NAME, "mom", address(inst.mom));
ScriptTools.exportContract(NAME, "conv", conv);
}
}
24 changes: 24 additions & 0 deletions script/input/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Network 1 (Ethereum Mainnet) Deployment Configuration

This directory contains the configuration files for deploying DSPC on Ethereum Mainnet.

## Files

### dspc-deploy.json
Configuration for deploying DSPC and DSPCMom contracts:
- `conv`: Address of the converter contract that handles rate conversions between basis points and ray format

## Usage

1. Copy `template-dspc-deploy.json` into a new file (i.e.: `dspc-deploy.json`)
2. Edit the new file with the correct `conv` address
3. Run the deployment script:
```bash
FOUNDRY_SCRIPT_CONFIG=dspc-deploy forge script script/DSPCDeploy.s.sol:DSPCDeployScript \
--rpc-url $ETH_RPC_URL \
--broadcast

The deployment script will:
1. Load system addresses from chainlog (jug, pot, susds)
2. Deploy DSPC and DSPCMom contracts
4. Export addresses to `/script/output/1/dspc-deploy.json`
3 changes: 3 additions & 0 deletions script/input/1/template-dspc-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"conv": "address: the address of the rate conversion contract."
}
1 change: 1 addition & 0 deletions script/output/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Outputs for Mainnet scripts.
Loading