Skip to content

Commit

Permalink
chore: rename back to checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
8sunyuan committed Aug 12, 2024
1 parent 374089b commit ef568e0
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 77 deletions.
30 changes: 25 additions & 5 deletions src/contracts/core/AVSDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract AVSDirectory is
AVSDirectoryStorage,
ReentrancyGuardUpgradeable
{
using MagnitudeCheckpoints for MagnitudeCheckpoints.History;
using Checkpoints for Checkpoints.History;

/// @dev Index for flag that pauses operator register/deregister to avs when set.
uint8 internal constant PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS = 0;
Expand Down Expand Up @@ -362,7 +362,7 @@ contract AVSDirectory is
slashedMagnitude = uint64(uint256(bipsToSlash) * uint256(currentMagnitude) / BIPS_FACTOR);

_magnitudeUpdate[operator][strategies[i]][msg.sender][operatorSetId].decrementAtAndFutureCheckpoints({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
decrementValue: slashedMagnitude
});
}
Expand Down Expand Up @@ -390,7 +390,7 @@ contract AVSDirectory is

// 3. update totalMagnitude, get total magnitude and subtract slashedMagnitude and slashedFromDeallocation
_totalMagnitudeUpdate[operator][strategies[i]].push({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
value: _totalMagnitudeUpdate[operator][strategies[i]].latest() - slashedMagnitude - slashedFromDeallocation
});
}
Expand Down Expand Up @@ -520,7 +520,7 @@ contract AVSDirectory is

// 3. allocate magnitude which will take effect in the future 21 days from now
_magnitudeUpdate[operator][strategy][operatorSets[i].avs][operatorSets[i].operatorSetId].push({
timestamp: effectTimestamp,
key: effectTimestamp,
value: value + uint224(allocation.magnitudeDiffs[i])
});
// 4. keep track of available freeMagnitude to update later
Expand Down Expand Up @@ -564,7 +564,7 @@ contract AVSDirectory is
// 2. update and decrement current and future queued amounts in case any pending allocations exist
_magnitudeUpdate[operator][strategy][operatorSets[i].avs][operatorSets[i].operatorSetId]
.decrementAtAndFutureCheckpoints({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
decrementValue: deallocation.magnitudeDiffs[i]
});

Expand Down Expand Up @@ -646,6 +646,26 @@ contract AVSDirectory is
|| registrationStatus.lastDeregisteredTimestamp + ALLOCATION_DELAY >= block.timestamp;
}

// /**
// * @notice fetches the minimum slashable shares for a certain operator and operatorSet for a list of strategies
// * from the current timestamp until the given timestamp
// *
// * @param operator the operator to get the minimum slashable shares for
// * @param operatorSet the operatorSet to get the minimum slashable shares for
// * @param strategies the strategies to get the minimum slashable shares for
// * @param timestamp the timestamp to the minimum slashable shares before
// *
// * @dev used to get the slashable stakes of operators to weigh over a given slashability window
// *
// * @return the list of share amounts for each strategy
// */
// function getMinimumSlashableSharesBefore(
// address operator,
// OperatorSet calldata operatorSet,
// IStrategy[] calldata strategies,
// uint32 timestamp
// ) external view returns (uint256[] calldata) {}

/**
* @notice Calculates the digest hash to be signed by an operator to register with an AVS.
*
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/core/AVSDirectoryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.12;

import "../interfaces/IAVSDirectory.sol";
import {MagnitudeCheckpoints} from "../libraries/MagnitudeCheckpoints.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";

abstract contract AVSDirectoryStorage is IAVSDirectory {
/// @notice The EIP-712 typehash for the contract's domain
Expand Down Expand Up @@ -55,14 +55,14 @@ abstract contract AVSDirectoryStorage is IAVSDirectory {

/// @notice Mapping: operator => strategy => checkpointed totalMagnitude
/// Note that totalMagnitude is monotonically decreasing and only gets updated upon slashing
mapping(address => mapping(IStrategy => MagnitudeCheckpoints.History)) internal _totalMagnitudeUpdate;
mapping(address => mapping(IStrategy => Checkpoints.History)) internal _totalMagnitudeUpdate;

/// @notice Mapping: operator => strategy => free available magnitude that can be allocated to operatorSets
/// Decrements whenever allocations take place and increments when deallocations are completed
mapping(address => mapping(IStrategy => uint64)) public freeMagnitude;

/// @notice Mapping: operator => strategy => avs => operatorSetId => checkpointed magnitude
mapping(address => mapping(IStrategy => mapping(address => mapping(uint32 => MagnitudeCheckpoints.History))))
mapping(address => mapping(IStrategy => mapping(address => mapping(uint32 => Checkpoints.History))))
internal _magnitudeUpdate;

/// @notice Mapping: operator => strategy => avs => operatorSetId => queuedDeallocations
Expand Down
Loading

0 comments on commit ef568e0

Please sign in to comment.