-
Notifications
You must be signed in to change notification settings - Fork 1
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
initial implementation #3
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Found one major issue that allows bypassing step
the way it's implemented.
ℹ️ Some additional suggestions are applicable.
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this contract for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a standalone struct that can be imported when the spell onboarding.
See an example here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some additional suggestions for the deploy/init scripts.
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
src/deployment/DSPCInit.sol
Outdated
@@ -29,11 +33,11 @@ library DSPCInit { | |||
* @param inst The DSCP instance. | |||
*/ | |||
function init(DssInstance memory dss, DSPCInstance memory inst) internal { | |||
inst.dspc.rely(address(inst.mom)); | |||
inst.mom.setAuthority(dss.chainlog.getAddress("MCD_ADM")); | |||
RelayLike(inst.dspc).rely(address(inst.mom)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RelayLike(inst.dspc).rely(address(inst.mom)); | |
RelyLike(inst.dspc).rely(address(inst.mom)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 75211ed.
src/deployment/DSPCInit.sol
Outdated
|
||
dss.jug.rely(address(inst.dspc)); | ||
dss.pot.rely(address(inst.dspc)); | ||
SUSDSLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc)); | ||
RelayLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RelayLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc)); | |
RelyLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 75211ed.
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions.
uint256 public bad; | ||
/// @notice Cooldown period between rate changes in seconds | ||
uint256 public tau; | ||
/// @notice Last time when rates were updated (Unix timestamp) | ||
uint256 public toc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make those fit into the same storage slot.
They are all going to be read in the same call, so we save a bit on gas.
uint256 public bad; | |
/// @notice Cooldown period between rate changes in seconds | |
uint256 public tau; | |
/// @notice Last time when rates were updated (Unix timestamp) | |
uint256 public toc; | |
uint8 public bad; | |
/// @notice Cooldown period between rate changes in seconds | |
uint64 public tau; | |
/// @notice Last time when rates were updated (Unix timestamp) | |
uint128 public toc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to save on storage we're gonna have to store them all in a struct. Is that ok?
Co-authored-by: amusingaxl <[email protected]> Signed-off-by: oddaf <[email protected]>
src/deployment/DSPCInit.sol
Outdated
function init(DssInstance memory dss, DSPCInstance memory inst) internal { | ||
RelyLike(inst.dspc).rely(address(inst.mom)); | ||
MomLike(inst.mom).setAuthority(dss.chainlog.getAddress("MCD_ADM")); | ||
|
||
dss.jug.rely(address(inst.dspc)); | ||
dss.pot.rely(address(inst.dspc)); | ||
RelyLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realized now that we're missing the initialization of the parameters, both global (i.e.: tau
) and per-rate ones (i.e.: min
, max
, step
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a47d4ff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions for the init script to be more inline with spell crafting style.
uint256 tau; | ||
/// @dev Time delay between rate updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint256 tau; | |
/// @dev Time delay between rate updates | |
/// @dev Time delay between rate updates | |
uint256 tau; |
/// @dev Minimum rate in basis points [0-65535] | ||
uint16 max; | ||
/// @dev Maximum rate in basis points [0-65535] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range here is not relevant because:
- It can be implicitly derived from the
uint16
type -
$655.35\%$ is not meaningful in this context.
/// @dev Minimum rate in basis points [0-65535] | |
uint16 max; | |
/// @dev Maximum rate in basis points [0-65535] | |
/// @dev Minimum rate in basis points | |
uint16 max; | |
/// @dev Maximum rate in basis points |
struct DSPCConfig { | ||
uint256 tau; | ||
/// @dev Time delay between rate updates | ||
DSPCIlkConfig[] ilks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing natspec here.
// Authorize DSPC in core contracts | ||
dss.jug.rely(inst.dspc); | ||
dss.pot.rely(inst.dspc); | ||
DSPCLike(dss.chainlog.getAddress("SUSDS")).rely(inst.dspc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface name doesn't make a lot of sense.
DSPCLike(dss.chainlog.getAddress("SUSDS")).rely(inst.dspc); | |
RelyLike(dss.chainlog.getAddress("SUSDS")).rely(inst.dspc); |
DSPCLike dspc = DSPCLike(inst.dspc); | ||
DSPCMomLike mom = DSPCMomLike(inst.mom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's cleaner if we don't add the casting here and just use inline casting. Otherwise, we're referencing the same values using 2 different names throughout the script.
DSPCLike dspc = DSPCLike(inst.dspc); | |
DSPCMomLike mom = DSPCMomLike(inst.mom); |
interface DSPCLike { | ||
function rely(address usr) external; | ||
function file(bytes32 what, uint256 data) external; | ||
function file(bytes32 ilk, bytes32 what, uint256 data) external; | ||
function kiss(address usr) external; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface DSPCLike { | |
function rely(address usr) external; | |
function file(bytes32 what, uint256 data) external; | |
function file(bytes32 ilk, bytes32 what, uint256 data) external; | |
function kiss(address usr) external; | |
interface RelyLike { | |
function rely(address usr) external; | |
} | |
interface DSPCLike is RelyLike { | |
function file(bytes32 what, uint256 data) external; | |
function file(bytes32 ilk, bytes32 what, uint256 data) external; | |
function kiss(address usr) external; |
/// @dev Used to configure rate parameters for a specific collateral | ||
struct DSPCIlkConfig { | ||
bytes32 ilk; | ||
/// @dev Collateral identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// @dev Collateral identifier | |
/// @dev Rate identifier |
bytes32 ilk; | ||
/// @dev Collateral identifier | ||
uint16 min; | ||
/// @dev Minimum rate in basis points [0-65535] | ||
uint16 max; | ||
/// @dev Maximum rate in basis points [0-65535] | ||
uint16 step; | ||
} | ||
/// @dev Step size in basis points [0-65535] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is intentional, but you're adding the natspec AFTER the corresponding line. I'd expect it to come before.
/// @title Global configuration parameters for DSPC | ||
/// @dev Used to configure global parameters and collateral-specific settings | ||
struct DSPCConfig { | ||
uint256 tau; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the setup of the buds:
uint256 tau; | |
uint256 tau; | |
address[] buds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially this could be 1 single address, as I don't think we'll ever onboard 2 facilitator wallets at once.
// First set authority for DSPCMom | ||
DSPCMom(inst.mom).setAuthority(params.owner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the initialization script.
// First set authority for DSPCMom | |
DSPCMom(inst.mom).setAuthority(params.owner); |
No description provided.