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

refactor: Range to Timestamps #335

Merged
merged 3 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@openzeppelin/contracts": "5.0.2",
"@prb/math": "github:PaulRBerg/prb-math#16419e5686504e15f973ebe73c3a75bd618d6ca4",
"@sablier/v2-core": "github:sablier-labs/v2-core#6f0879891b046fc14d941b2a58804193b25dff38"
"@sablier/v2-core": "github:sablier-labs/v2-core#staging"
},
"devDependencies": {
"@sphinx-labs/plugins": "^0.31.9",
Expand Down
2 changes: 1 addition & 1 deletion src/SablierV2BatchLockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ contract SablierV2BatchLockup is ISablierV2BatchLockup {
asset: asset,
cancelable: batch[i].cancelable,
transferable: batch[i].transferable,
range: batch[i].range,
timestamps: batch[i].timestamps,
broker: batch[i].broker
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ library BatchLockup {
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupLinear.Range range;
LockupLinear.Timestamps timestamps;
Broker broker;
}

Expand Down
15 changes: 9 additions & 6 deletions test/fork/batch-lockup/createWithTimestampsLL.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract contract CreateWithTimestamps_LockupLinear_BatchLockup_Fork_Test is For

struct CreateWithTimestampsParams {
uint128 batchSize;
LockupLinear.Range range;
LockupLinear.Timestamps timestamps;
address sender;
address recipient;
uint128 perStreamAmount;
Expand All @@ -29,10 +29,13 @@ abstract contract CreateWithTimestamps_LockupLinear_BatchLockup_Fork_Test is For
function testForkFuzz_CreateWithTimestampsLL(CreateWithTimestampsParams memory params) external {
params.batchSize = boundUint128(params.batchSize, 1, 20);
params.perStreamAmount = boundUint128(params.perStreamAmount, 1, MAX_UINT128 / params.batchSize);
params.range.start = boundUint40(params.range.start, getBlockTimestamp(), getBlockTimestamp() + 24 hours);
params.range.cliff =
boundUint40(params.range.cliff, params.range.start + 1 seconds, params.range.start + 52 weeks);
params.range.end = boundUint40(params.range.end, params.range.cliff + 1 seconds, MAX_UNIX_TIMESTAMP);
params.timestamps.start =
boundUint40(params.timestamps.start, getBlockTimestamp(), getBlockTimestamp() + 24 hours);
params.timestamps.cliff = boundUint40(
params.timestamps.cliff, params.timestamps.start + 1 seconds, params.timestamps.start + 52 weeks
);
params.timestamps.end =
boundUint40(params.timestamps.end, params.timestamps.cliff + 1 seconds, MAX_UNIX_TIMESTAMP);

checkUsers(params.sender, params.recipient);

Expand All @@ -49,7 +52,7 @@ abstract contract CreateWithTimestamps_LockupLinear_BatchLockup_Fork_Test is For
asset: FORK_ASSET,
cancelable: true,
transferable: true,
range: params.range,
timestamps: params.timestamps,
broker: defaults.broker()
});
BatchLockup.CreateWithTimestampsLL[] memory batchParams =
Expand Down
2 changes: 1 addition & 1 deletion test/utils/BatchLockupBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ library BatchLockupBuilder {
totalAmount: params.totalAmount,
cancelable: params.cancelable,
transferable: params.transferable,
range: params.range,
timestamps: params.timestamps,
broker: params.broker
});
batch = fillBatch(batchSingle, batchSize);
Expand Down
6 changes: 3 additions & 3 deletions test/utils/Defaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ contract Defaults is Merkle {
asset: asset_,
cancelable: true,
transferable: true,
range: linearRange(),
timestamps: linearTimestamps(),
broker: broker()
});
}
Expand All @@ -290,8 +290,8 @@ contract Defaults is Merkle {
return LockupLinear.Durations({ cliff: CLIFF_DURATION, total: TOTAL_DURATION });
}

function linearRange() private view returns (LockupLinear.Range memory) {
return LockupLinear.Range({ start: START_TIME, cliff: CLIFF_TIME, end: END_TIME });
function linearTimestamps() private view returns (LockupLinear.Timestamps memory) {
return LockupLinear.Timestamps({ start: START_TIME, cliff: CLIFF_TIME, end: END_TIME });
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down