sablier-labs / v2-core

⏳ Core smart contracts of the Sablier V2 token distribution protocol
https://sablier.com
Other
291 stars 40 forks source link

Bespoke timelock contract #706

Closed PaulRBerg closed 7 months ago

PaulRBerg commented 9 months ago

Context

We keep getting requests for timelocks - e.g. see this recent tag on Twitter:

https://twitter.com/Arr00c/status/1712559004814381308

This mention has resulted in two LockupDynamic streams with one segment and a duration of 1 second:

This is how the release curve looks like:

Screenshot 2023-10-13 at 11 26 33 AM

Task

The context above is sufficient proof that there's a need for timelocks in web3. We should build a bespoke contract focused on this use case.

Building this feature entails a soft pivot from "streaming-only" to "token distribution", but that's ok. See the related discussions here and here.

andreivladbrg commented 9 months ago

Can you give details on how we plan to implement this contract? Would SablierV2Timelock inherit SablierV2Lockup ? How would the struct that is stored would look like?

Thinking to something like this:

    struct Stream {
        // slot 0
        address sender;
        uint40 startTime;
        uint40 cliffTime;
        bool isCancelable;
        bool wasCanceled;
        // slot 1
        IERC20 asset;
        uint40 endTime;
        bool isDepleted;
        bool isStream;
        bool isTransferable;
        // slot 2 and 3
        Lockup.Amounts amounts;
        // slot [3..n]
        UnlockDetails[] unlockDetails;
    }

    struct UnlockDetails {
        uint40 milestones;
        uint128 amount;
    }
PaulRBerg commented 9 months ago

@andreivladbrg the design of the contract is up to you because I don't have much time on my hands nowadays.

But no, Timelock would not inherit Lockup, because Timelock won't be a streaming contract. Please refer to the business strategy discussions mentioned in the OP.

PaulRBerg commented 8 months ago

Another timelock user:

https://twitter.com/ashleighschap/status/1712946120584781961

Created this LockupDynamic stream:

https://app.sablier.com/stream/LD-1-9/

PaulRBerg commented 7 months ago

As discussed with @andreivladbrg on the call, it is not worth it to over-optimize the protocol for this particular use case.

We can consider this optimized contract later if we suddenly get a large influx of timelock users.