Vesting/Lockup Contract

This is a pure contract (no frontend). Basically, this contract acts as "escrow" to lock up others' token for a period of time, for whatever reason.

Lockup and vesting have some differences. In particular, Vesting has 2 extra configurations:

  1. You can terminate the vesting and refund the non-vested tokens.
  2. Cliff vesting

In NEAR, the most common uses of lockup contract is during Staking. Owner whom stake their tokens have their tokens locked-up, and unstaking requires an amount of time before the lockup is unlocked.

For more info, check out their readme (link in references section). Without further ado, let's start looking at the contracts.

Extra information on the contract

#TODO: The contract consists of two parts that are intertwined with each other: the owner and the foundation. foundation are linked to NEAR Foundation, while owner are linked to (to be updated).

Some further details on the programs

For this, we shall use near-sdk-4.0.0-pre.7, as opposed to the stable version 3.1.0 used in the contract. This means we might get lots of error (if you use VSCode rust-analyzer extension) about near_sdk not found. That's because they check for only stable ones, not pre-release versions.

We would also talk about simulation tests in this chapter, although not in depth.

As usual, we would skip those explanations for things that are self-explanatory. Those that requires further explanation will have further explanations.

NOTE: If you call cargo test, it's gonna take quite long to build, and it's gonna take up GBs of your space. So if you're renting the VM, make sure you have at least 12GB to build the thingy, otherwise your VM might get stuck, unable to shut down (well, force shut down takes a long while, at least for Azure VM) and perhaps other problems be introduced.

References