Skip to content

Commit

Permalink
refactor: rename Stream structs within LockupLinear and LockupDynamic…
Browse files Browse the repository at this point in the history
… namespaces
  • Loading branch information
andreivladbrg committed Feb 15, 2024
1 parent 6174941 commit 4031ace
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/SablierV2LockupDynamic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contract SablierV2LockupDynamic is
view
override
notNull(streamId)
returns (LockupDynamic.Stream memory stream)
returns (LockupDynamic.StreamLD memory stream)
{
Lockup.Stream memory lockupStream = _streams[streamId];

Expand All @@ -117,7 +117,7 @@ contract SablierV2LockupDynamic is
lockupStream.isCancelable = false;
}

stream = LockupDynamic.Stream({
stream = LockupDynamic.StreamLD({
amounts: lockupStream.amounts,
asset: lockupStream.asset,
endTime: lockupStream.endTime,
Expand Down
4 changes: 2 additions & 2 deletions src/SablierV2LockupLinear.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ contract SablierV2LockupLinear is
view
override
notNull(streamId)
returns (LockupLinear.Stream memory stream)
returns (LockupLinear.StreamLL memory stream)
{
Lockup.Stream memory lockupStream = _streams[streamId];

Expand All @@ -105,7 +105,7 @@ contract SablierV2LockupLinear is
lockupStream.isCancelable = false;
}

stream = LockupLinear.Stream({
stream = LockupLinear.StreamLL({
amounts: lockupStream.amounts,
asset: lockupStream.asset,
cliffTime: _cliffs[streamId],
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ISablierV2LockupDynamic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface ISablierV2LockupDynamic is ISablierV2Lockup {
/// @notice Retrieves the stream details, which is a struct documented in {DataTypes}.
/// @dev Reverts if `streamId` references a null stream.
/// @param streamId The stream id for the query.
function getStream(uint256 streamId) external view returns (LockupDynamic.Stream memory stream);
function getStream(uint256 streamId) external view returns (LockupDynamic.StreamLD memory stream);

/// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.
///
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ISablierV2LockupLinear.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface ISablierV2LockupLinear is ISablierV2Lockup {
/// @notice Retrieves the stream details, which is a struct documented in {DataTypes}.
/// @dev Reverts if `streamId` references a null stream.
/// @param streamId The stream id for the query.
function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);
function getStream(uint256 streamId) external view returns (LockupLinear.StreamLL memory stream);

/// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.
///
Expand Down
10 changes: 5 additions & 5 deletions src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ library Lockup {
DEPLETED
}

/// @notice A common data structure to be stored in all contracts inheriting {SablierV2Lockup}.
/// @notice A common data structure to be stored in all child contracts of {SablierV2Lockup}.
/// @dev The fields are arranged like this to save gas via tight variable packing.
/// @param sender The address streaming the assets, with the ability to cancel the stream.
/// @param startTime The Unix timestamp indicating the stream's start.
Expand Down Expand Up @@ -178,10 +178,10 @@ library LockupDynamic {
uint40 duration;
}

/// @notice Struct encapsulating all the data for a specific id, so that anyone can obtain all information
/// within one call to our contract.
/// @notice Struct encapsulating all the data for a specific id, allowing anyone to retrieve all information within
/// one call to the contract.
/// @dev It contains the same data as the `Lockup.Stream` struct, plus the segments.
struct Stream {
struct StreamLD {
address sender;
uint40 startTime;
uint40 endTime;
Expand Down Expand Up @@ -266,7 +266,7 @@ library LockupLinear {
/// @notice Struct encapsulating all the data for a specific id, so that anyone can obtain all information
/// within one call to our contract.
/// @dev It contains the same data as the `Lockup.Stream` struct, plus the cliff value.
struct Stream {
struct StreamLL {
address sender;
uint40 startTime;
bool isCancelable;
Expand Down
2 changes: 1 addition & 1 deletion test/fork/LockupDynamic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ abstract contract LockupDynamic_Fork_Test is Fork_Test {
vars.isCancelable = vars.isSettled ? false : true;

// Assert that the stream has been created.
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(vars.streamId);
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(vars.streamId);
assertEq(actualStream.amounts, Lockup.Amounts(vars.createAmounts.deposit, 0, 0));
assertEq(actualStream.asset, ASSET, "asset");
assertEq(actualStream.endTime, vars.range.end, "endTime");
Expand Down
2 changes: 1 addition & 1 deletion test/fork/LockupLinear.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ abstract contract LockupLinear_Fork_Test is Fork_Test {
);

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(vars.streamId);
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(vars.streamId);
assertEq(actualStream.amounts, Lockup.Amounts(vars.createAmounts.deposit, 0, 0));
assertEq(actualStream.asset, ASSET, "asset");
assertEq(actualStream.cliffTime, params.range.cliff, "cliffTime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ contract CreateWithDurations_LockupDynamic_Integration_Concrete_Test is
createDefaultStreamWithDurations();

// Assert that the stream has been created.
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.Stream memory expectedStream = defaults.lockupDynamicStream();
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory expectedStream = defaults.lockupDynamicStream();
expectedStream.endTime = range.end;
expectedStream.segments = segments;
expectedStream.startTime = range.start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ contract CreateWithTimestamps_LockupDynamic_Integration_Concrete_Test is
streamId = createDefaultStreamWithAsset(IERC20(asset));

// Assert that the stream has been created.
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.Stream memory expectedStream = defaults.lockupDynamicStream();
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory expectedStream = defaults.lockupDynamicStream();
expectedStream.asset = IERC20(asset);
assertEq(actualStream, expectedStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ contract GetStream_LockupDynamic_Integration_Concrete_Test is LockupDynamic_Inte

function test_GetStream_StatusSettled() external givenNotNull {
vm.warp({ timestamp: defaults.END_TIME() });
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(defaultStreamId);
LockupDynamic.Stream memory expectedStream = defaults.lockupDynamicStream();
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(defaultStreamId);
LockupDynamic.StreamLD memory expectedStream = defaults.lockupDynamicStream();
expectedStream.isCancelable = false;
assertEq(actualStream, expectedStream);
}
Expand All @@ -38,8 +38,8 @@ contract GetStream_LockupDynamic_Integration_Concrete_Test is LockupDynamic_Inte

function test_GetStream() external givenNotNull givenStatusNotSettled {
uint256 streamId = createDefaultStream();
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.Stream memory expectedStream = defaults.lockupDynamicStream();
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory expectedStream = defaults.lockupDynamicStream();
assertEq(actualStream, expectedStream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ contract CreateWithDurations_LockupLinear_Integration_Concrete_Test is
createDefaultStreamWithDurations();

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
expectedStream.startTime = range.start;
expectedStream.cliffTime = range.cliff;
expectedStream.endTime = range.end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ contract CreateWithTimestamps_LockupLinear_Integration_Concrete_Test is
);

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
expectedStream.cliffTime = 0;
assertEq(actualStream, expectedStream);

Expand Down Expand Up @@ -291,8 +291,8 @@ contract CreateWithTimestamps_LockupLinear_Integration_Concrete_Test is
createDefaultStreamWithAsset(IERC20(asset));

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
expectedStream.asset = IERC20(asset);
assertEq(actualStream, expectedStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ contract GetStream_LockupLinear_Integration_Concrete_Test is LockupLinear_Integr

function test_GetStream_StatusSettled() external givenNotNull {
vm.warp({ timestamp: defaults.END_TIME() });
LockupLinear.Stream memory actualStream = lockupLinear.getStream(defaultStreamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(defaultStreamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
expectedStream.isCancelable = false;
assertEq(actualStream, expectedStream);
}
Expand All @@ -37,8 +37,8 @@ contract GetStream_LockupLinear_Integration_Concrete_Test is LockupLinear_Integr
}

function test_GetStream() external givenNotNull givenStatusNotSettled {
LockupLinear.Stream memory actualStream = lockupLinear.getStream(defaultStreamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(defaultStreamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
assertEq(actualStream, expectedStream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ contract CreateWithDurations_LockupDynamic_Integration_Fuzz_Test is
vars.isCancelable = vars.isSettled ? false : true;

// Assert that the stream has been created.
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(streamId);
assertEq(actualStream.amounts, Lockup.Amounts(vars.createAmounts.deposit, 0, 0));
assertEq(actualStream.asset, dai, "asset");
assertEq(actualStream.endTime, range.end, "endTime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ contract CreateWithTimestamps_LockupDynamic_Integration_Fuzz_Test is
vars.isCancelable = vars.isSettled ? false : params.cancelable;

// Assert that the stream has been created.
LockupDynamic.Stream memory actualStream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(streamId);
assertEq(actualStream.amounts, Lockup.Amounts(vars.createAmounts.deposit, 0, 0));
assertEq(actualStream.asset, dai, "asset");
assertEq(actualStream.endTime, range.end, "endTime");
Expand Down
4 changes: 2 additions & 2 deletions test/integration/fuzz/lockup-linear/createWithDurations.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ contract CreateWithDurations_LockupLinear_Integration_Fuzz_Test is
createDefaultStreamWithDurations(durations);

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.Stream memory expectedStream = defaults.lockupLinearStream();
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory expectedStream = defaults.lockupLinearStream();
expectedStream.cliffTime = range.cliff;
expectedStream.endTime = range.end;
expectedStream.startTime = range.start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ contract CreateWithTimestamps_LockupLinear_Integration_Fuzz_Test is
);

// Assert that the stream has been created.
LockupLinear.Stream memory actualStream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory actualStream = lockupLinear.getStream(streamId);
assertEq(actualStream.amounts, Lockup.Amounts(vars.createAmounts.deposit, 0, 0));
assertEq(actualStream.asset, dai, "asset");
assertEq(actualStream.cliffTime, params.range.cliff, "cliffTime");
Expand Down
4 changes: 2 additions & 2 deletions test/invariant/LockupDynamic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract LockupDynamic_Invariant_Test is Lockup_Invariant_Test {
uint256 lastStreamId = lockupStore.lastStreamId();
for (uint256 i = 0; i < lastStreamId; ++i) {
uint256 streamId = lockupStore.streamIds(i);
LockupDynamic.Stream memory stream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory stream = lockupDynamic.getStream(streamId);
assertNotEq(stream.amounts.deposited, 0, "Invariant violated: stream non-null, deposited amount zero");
}
}
Expand All @@ -74,7 +74,7 @@ contract LockupDynamic_Invariant_Test is Lockup_Invariant_Test {
uint256 lastStreamId = lockupStore.lastStreamId();
for (uint256 i = 0; i < lastStreamId; ++i) {
uint256 streamId = lockupStore.streamIds(i);
LockupDynamic.Stream memory stream = lockupDynamic.getStream(streamId);
LockupDynamic.StreamLD memory stream = lockupDynamic.getStream(streamId);
assertNotEq(stream.endTime, 0, "Invariant violated: end time zero");
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/invariant/LockupLinear.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract LockupLinear_Invariant_Test is Lockup_Invariant_Test {
uint256 lastStreamId = lockupStore.lastStreamId();
for (uint256 i = 0; i < lastStreamId; ++i) {
uint256 streamId = lockupStore.streamIds(i);
LockupLinear.Stream memory stream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory stream = lockupLinear.getStream(streamId);
assertNotEq(stream.amounts.deposited, 0, "Invariant violated: stream non-null, deposited amount zero");
}
}
Expand All @@ -101,7 +101,7 @@ contract LockupLinear_Invariant_Test is Lockup_Invariant_Test {
uint256 lastStreamId = lockupStore.lastStreamId();
for (uint256 i = 0; i < lastStreamId; ++i) {
uint256 streamId = lockupStore.streamIds(i);
LockupLinear.Stream memory stream = lockupLinear.getStream(streamId);
LockupLinear.StreamLL memory stream = lockupLinear.getStream(streamId);
assertNotEq(stream.endTime, 0, "Invariant violated: stream non-null, end time zero");
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/utils/Assertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract contract Assertions is PRBTest, PRBMathAssertions {
}

/// @dev Compares two {LockupLinear.Stream} struct entities.
function assertEq(LockupLinear.Stream memory a, LockupLinear.Stream memory b) internal {
function assertEq(LockupLinear.StreamLL memory a, LockupLinear.StreamLL memory b) internal {
assertEq(a.amounts, b.amounts);
assertEq(a.asset, b.asset, "asset");
assertEq(a.cliffTime, b.cliffTime, "cliffTime");
Expand All @@ -55,7 +55,7 @@ abstract contract Assertions is PRBTest, PRBMathAssertions {
}

/// @dev Compares two {LockupDynamic.Stream} struct entities.
function assertEq(LockupDynamic.Stream memory a, LockupDynamic.Stream memory b) internal {
function assertEq(LockupDynamic.StreamLD memory a, LockupDynamic.StreamLD memory b) internal {
assertEq(a.asset, b.asset, "asset");
assertEq(a.endTime, b.endTime, "endTime");
assertEq(a.isCancelable, b.isCancelable, "isCancelable");
Expand Down
8 changes: 4 additions & 4 deletions test/utils/Defaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ contract Defaults is Constants {
return LockupDynamic.Range({ start: START_TIME, end: END_TIME });
}

function lockupDynamicStream() public view returns (LockupDynamic.Stream memory) {
return LockupDynamic.Stream({
function lockupDynamicStream() public view returns (LockupDynamic.StreamLD memory) {
return LockupDynamic.StreamLD({
amounts: lockupAmounts(),
asset: asset,
endTime: END_TIME,
Expand All @@ -111,8 +111,8 @@ contract Defaults is Constants {
return LockupLinear.Range({ start: START_TIME, cliff: CLIFF_TIME, end: END_TIME });
}

function lockupLinearStream() public view returns (LockupLinear.Stream memory) {
return LockupLinear.Stream({
function lockupLinearStream() public view returns (LockupLinear.StreamLL memory) {
return LockupLinear.StreamLL({
amounts: lockupAmounts(),
asset: asset,
cliffTime: CLIFF_TIME,
Expand Down

0 comments on commit 4031ace

Please sign in to comment.