Skip to content
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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

initial implementation #3

wants to merge 29 commits into from

Conversation

oddaf
Copy link
Member

@oddaf oddaf commented Feb 14, 2025

No description provided.

Copy link
Member

@amusingaxl amusingaxl left a 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.

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?

Copy link
Member

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.

Copy link
Member

@amusingaxl amusingaxl left a 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.

@@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RelayLike(inst.dspc).rely(address(inst.mom));
RelyLike(inst.dspc).rely(address(inst.mom));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 75211ed.


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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RelayLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc));
RelyLike(dss.chainlog.getAddress("SUSDS")).rely(address(inst.dspc));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 75211ed.

Copy link
Member

@amusingaxl amusingaxl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions.

Comment on lines +80 to +84
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;
Copy link
Member

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.

Suggested change
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;

Copy link
Member Author

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?

Comment on lines 35 to 42
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));
}
Copy link
Member

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).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a47d4ff.

Copy link
Member

@amusingaxl amusingaxl left a 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.

Comment on lines +49 to +50
uint256 tau;
/// @dev Time delay between rate updates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint256 tau;
/// @dev Time delay between rate updates
/// @dev Time delay between rate updates
uint256 tau;

Comment on lines +39 to +41
/// @dev Minimum rate in basis points [0-65535]
uint16 max;
/// @dev Maximum rate in basis points [0-65535]
Copy link
Member

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:

  1. It can be implicitly derived from the uint16 type
  2. $655.35\%$ is not meaningful in this context.
Suggested change
/// @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;
Copy link
Member

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);
Copy link
Member

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.

Suggested change
DSPCLike(dss.chainlog.getAddress("SUSDS")).rely(inst.dspc);
RelyLike(dss.chainlog.getAddress("SUSDS")).rely(inst.dspc);

Comment on lines +66 to +67
DSPCLike dspc = DSPCLike(inst.dspc);
DSPCMomLike mom = DSPCMomLike(inst.mom);
Copy link
Member

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.

Suggested change
DSPCLike dspc = DSPCLike(inst.dspc);
DSPCMomLike mom = DSPCMomLike(inst.mom);

Comment on lines +22 to +26
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @dev Collateral identifier
/// @dev Rate identifier

Comment on lines +36 to +44
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]
Copy link
Member

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;
Copy link
Member

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:

Suggested change
uint256 tau;
uint256 tau;
address[] buds;

Copy link
Member

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.

Comment on lines +61 to +62
// First set authority for DSPCMom
DSPCMom(inst.mom).setAuthority(params.owner);
Copy link
Member

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.

Suggested change
// First set authority for DSPCMom
DSPCMom(inst.mom).setAuthority(params.owner);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants