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

DO NOT REVIEW Strict Custom Types #784

Closed
wants to merge 2 commits into from

Conversation

ypatil12
Copy link
Collaborator

Adds custom types to SM & DM, with a focus on abstracting conversions away to the SlashingLibrary.

One item I'd like some comment on is how strict we want to be between conversions. Do we want to enforce conversion from A to B then B to C if we want to convert from A to C

We can currently do the following conversions:

  1. DelegatedShares -> Shares
  2. OwnedShares -> DelegatedShares
  3. Shares -> DelegatedShares
  4. DelegatedShares -> OwnedShares
  5. Shares -> OwnedShares

Is there room for simplification here?

feat: types everywhere
Copy link
Contributor

@0xClandestine 0xClandestine left a comment

Choose a reason for hiding this comment

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

few comments 🤝

.unwrap()
.divWad(existingShares.unwrap() + addedOwnedShares.unwrap())
.divWad(totalMagnitude);
newDepositScalingFactor = existingShares.calculateNewScalingFactor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, was planning on this 👍

@@ -516,7 +516,7 @@ contract DelegationManager is
operator: operator,
staker: staker,
strategy: strategies[i],
existingShares: uint256(0).wrapShares(),
existingShares: Shares(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh nice, didn't know this was valid syntax.

@@ -183,6 +183,7 @@ contract StrategyManager is
IERC20 token,
OwnedShares ownedShares
) external onlyDelegationManager {
// TODO: add Shares type to StrategyBase
Copy link
Contributor

Choose a reason for hiding this comment

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

Can do this if needed.

src/contracts/libraries/SlashingLib.sol Outdated Show resolved Hide resolved
@ypatil12 ypatil12 changed the title Strict Custom Types DO NOT REVIEW Strict Custom Types Sep 27, 2024
@0xClandestine 0xClandestine mentioned this pull request Sep 29, 2024
7 tasks
@ypatil12 ypatil12 closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants