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

Check if the start time is in the future in linear contract #938

Closed
andreivladbrg opened this issue Jun 6, 2024 · 1 comment
Closed
Assignees
Labels
effort: medium Default level of effort. priority: 1 This is important. It should be dealt with shortly. type: bug Something isn't working. work: clear Sense-categorize-respond. The relationship between cause and effect is clear.

Comments

@andreivladbrg
Copy link
Member

Now, since cliff time can be zero, this check is not enough in SablierV2LockupLinear._calculateStreamedAmount:

uint256 cliffTime = uint256(_cliffs[streamId]);
uint256 blockTimestamp = block.timestamp;
if (cliffTime > blockTimestamp) {
return 0;
}

Test to run

It will revert with a PRB Math error since we use unchecked: https://app.warp.dev/block/OBorEzMLUvWOk9R8CmXlky

    function test_Cancel_Pending_Linear() public {
        vm.warp({ newTimestamp: defaults.START_TIME() - 100 });

        LockupLinear.Timestamps memory timestamps = defaults.lockupLinearTimestamps();
        timestamps.cliff = 0;

        uint256 streamId = createDefaultStreamWithTimestamps(timestamps);

        console2.log("Stream ID: %d status is %d", streamId, uint8(lockup.statusOf(streamId)));

        lockup.cancel(streamId);
    }

Thus, we should also check if the start time is in the future.

Also, ref of the issue here.

@andreivladbrg andreivladbrg self-assigned this Jun 6, 2024
@andreivladbrg andreivladbrg added priority: 0 Do this first before everything else. This is critical and nothing works without this. type: bug Something isn't working. work: clear Sense-categorize-respond. The relationship between cause and effect is clear. effort: medium Default level of effort. labels Jun 6, 2024
@PaulRBerg PaulRBerg added priority: 1 This is important. It should be dealt with shortly. and removed priority: 0 Do this first before everything else. This is critical and nothing works without this. labels Jun 7, 2024
@PaulRBerg
Copy link
Member

It is worth noting that this bug does not affect any Sablier contract running in production, since we haven't deployed V2.2 yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Default level of effort. priority: 1 This is important. It should be dealt with shortly. type: bug Something isn't working. work: clear Sense-categorize-respond. The relationship between cause and effect is clear.
Projects
None yet
Development

No branches or pull requests

3 participants