-
Notifications
You must be signed in to change notification settings - Fork 2
initial implementation #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 70 commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
e62ac29
initial implementation
oddaf 13e9d95
Update script/input/1/README.md
oddaf 2d4ff02
Update src/DSPC.sol
oddaf 2bccdbe
Update src/DSPC.sol
oddaf 2c3f886
Update src/DSPC.sol
oddaf 3c60b1f
Update src/DSPC.sol
oddaf 52a59f7
refactor: rename function put to set
oddaf c04ef6c
fix: add check if data can be safely cast to uint16 in file()
oddaf d6ff178
refactor: remove step restriction
oddaf b341255
chore: forge fmt
oddaf 917eb4d
refactor: Update Set event to be emitted for each rate update
oddaf def70fa
Update src/deployment/DSPCInstance.sol
oddaf 9c2898d
Update src/deployment/DSPCInit.sol
oddaf b6c57c0
Update src/deployment/DSPCInit.sol
oddaf 253af36
Update src/deployment/DSPCDeploy.sol
oddaf 45a1834
Update src/deployment/DSPCDeploy.sol
oddaf cec6dc4
Update src/deployment/DSPCDeploy.sol
oddaf 48b668a
Update src/deployment/DSPCInit.sol
oddaf b9482c3
refactor: use addresses instead of interfaces in DSPCInstance to ease…
oddaf 2274abe
fix: enforce min < max and max > min on file()
oddaf 75211ed
fix: typo in RelyLike
oddaf 3d3a515
Update src/DSPC.sol
oddaf b7dadb5
feat: dspc cooldown + step
oddaf 0582668
remove unnecessary setup from dspcMom test
oddaf e03048f
chore: forge fmt
oddaf d685819
Apply suggestions from code review
oddaf 9dcf622
fix: revert message in test
oddaf 0a79139
chore: forge fmt
oddaf a47d4ff
feat: improvements to initialization script
oddaf 4077e06
Apply suggestions from code review
oddaf 117aa00
chore: adjust tests for new var names
oddaf a1b8da7
chore: improve DSPCInit natspec
oddaf 12d2bfd
feat: add bud address to DSPCConfig
oddaf c64ce03
fix: Remove setAuthority from deploy script in favor of only executin…
oddaf 4f5bd78
Update src/DSPC.sol
oddaf bfc5de0
refactor: optimize storage layout
oddaf f6c7987
Update src/DSPC.sol
oddaf 1d08161
chore: test case for tau overflow in file()
oddaf 43ed724
fix: prevent duplicate ilks
oddaf c81e895
chore: fix natspec
oddaf 4fc314a
chore: fix readme reference to SUSDS
oddaf cfe098a
refactor: fisibility of _cfgs to public
oddaf d45a82d
fix: check if ilk setup on set()
oddaf f6d6d67
chore: Add comment to file function (ilks) mentioned order of calls m…
oddaf 827b25f
Update src/DSPC.sol
oddaf 7342217
Update src/DSPC.t.sol
oddaf 15e83c3
fix: update revert reason in test_revert_set_not_configured_rate
oddaf 990ac84
fix: prevent setup of unexisting Ilks
oddaf 94af8f0
refactor: ordering of ilks check
oddaf a67531b
refactor: improve invalid bad check
oddaf e5177a9
chore: improve natspec dos for file(what, data)
oddaf ea0b5f3
refactor: order of checks on set()
oddaf a72e855
fix: ilk initialization verification
oddaf 6d0cf28
feat: allow ward to edit toc
oddaf 61c6c88
feat: revert if current rate outside range
oddaf 7145e55
Apply suggestions from code review
oddaf aec447a
Update src/mocks/ConvMock.sol
oddaf d9d9b5a
chore: update natspec of set() to include all cases where it reverts
oddaf 1d678cb
chore: improve tests
oddaf d9612a6
chore: natspec
oddaf 31512e2
chore: add step to readme.md instructions
oddaf 2af4fe2
Update README.md
oddaf afc6f55
Apply suggestions from code review
oddaf 8c0131b
Update README.md
oddaf 50fd0d4
chore: order of operations in readme instructions
oddaf 454136e
Merge branch 'initial-implementation' of https://github.com/dewiz-xyz…
oddaf 13bc3b4
chore: order natspec revert reasons
oddaf 473fffb
chore: update foundry.toml
oddaf 4587323
chore: formatting
oddaf b7d6a98
chore: remove redundant selectors from test_auth_methods
oddaf aae64b8
chore: add .editorconfig
oddaf 1f8b03c
Apply suggestions from code review
oddaf 5650c3f
feat: rate covnersion check
oddaf 4da6795
chore: forge fmt
oddaf e8c317b
refactor: allow setting rates when current rate out of bounds
oddaf 84e5e3b
chore: test rates below min bound
oddaf 54dacb4
chore: formatting
oddaf c9dfdfb
Apply suggestions from code review
oddaf 4e7a435
Rename module (DSPC -> SPBEAM) (#9)
oddaf b46ac6b
chore: add audit reports
oddaf 4ed07c8
Update README.md
oddaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", "max", 1000); // Max rate: 10% | ||
| dspc.file("ETH-A", "min", 1); // Min rate: 0.01% | ||
| dspc.file("ETH-A", "step", 100); // Max change: 1% | ||
|
|
||
oddaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Configure constraints for DSR | ||
| dspc.file("DSR", "max", 800); // Max rate: 8% | ||
| dspc.file("DSR", "min", 1); // Min rate: 0.01% | ||
| 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("DSR", 75); // Set DSR to 0.75% | ||
| updates[1] = DSPC.ParamChange("ETH-A", 150); // Set ETH-A rate to 1.5% | ||
| 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 | ||
oddaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## License | ||
|
|
||
| AGPL-3.0-or-later | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "conv": "address: the address of the rate conversion contract." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Outputs for Mainnet scripts. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.