Ring Protocol
Search…
LinearTokenTimelock
A token timelock that releases continuously at the same rate

Contract

Description

A timelock for releasing tokens over a continuous linear schedule. There is an appointed beneficiary who controls the tokens when vested. The beneficiary can set a new one if needed using the offer-accept pattern.

Release Calculation

Uses Timed to have a fixed period d of release. The elapsed time t is on the range [0,d].
The contract maintains the following:
    T - a total token amount which includes any already released and locked tokens. It can increase if new tokens enter the timelock but it cannot decrease.
    C - the current held tokens in the contract
The portion of T available for release is T*t/d.
The already released amount is T - C.
The net amount available for release is the total available minus already released. The beneficiary can claim these at any time, and distribute to any address.

Events

Release
BeneficiaryUpdate
PendingBeneficiaryUpdate
A release of timelocked tokens
type
param
description
address indexed
_beneficiary
the address that owns the timelocked tokens
address indexed
_recipient
the address receiving this unlocked distribution
uint256
_amount
the amount of unlocked tokens released
A change in beneficiary to the timelock
type
param
description
address indexed
_beneficiary
the new beneficiary address
A change in pending beneficiary to the timelock
type
param
description
address indexed
_pendingBeneficiary
the new beneficiary address

Read-Only Functions

lockedToken

1
function lockedToken() external view returns (IERC20);
Copied!
Returns the address of the locked token casted as an IERC20 interface.

beneficiary

1
function beneficiary() external view returns (address);
Copied!
Returns the current beneficiary address.

pendingBeneficiary

1
function pendingBeneficiary() external view returns (address);
Copied!
Returns the pending beneficiary, which could assume the beneficiary role at any time by calling acceptBeneficiary()

initialBalance

1
function initialBalance() external view returns (uint256);
Copied!
Returns the initial total amount of locked tokens. If new tokens are dropped into the timelock, this number increases to prevent accounting errors.

availableForRelease

1
function availableForRelease() external view returns (uint256);
Copied!
The amount of lockedToken available to be released by the beneficiary.

totalToken

1
function totalToken() external view returns(uint256);
Copied!
Returns the total amount of tokens held by the timelock pending release.

alreadyReleasedAmount

1
function alreadyReleasedAmount() external view returns (uint256);
Copied!
The amount of lockedToken already released by the beneficiary.

Public State-Changing Functions

acceptBeneficiary

1
function acceptBeneficiary() external;
Copied!
Accepts the beneficiary role for msg.sender. Must already be the pending beneficiary.
emits BeneficiaryUpdate

Beneficiary-Only👑 State-Changing Functions

1
function release(address to, uint amount) external;
Copied!
Releases amount of timelocked tokens to address to. The amount must be less than or equal to the released amount of tokens.
emits Release

setPendingBeneficiary

1
function setPendingBeneficiary(address _pendingBeneficiary) external;
Copied!
Sets the pending beneficiary to _pendingBeneficiary.
emits PendingBeneficiaryUpdate

ABIs

lineartokentimelock.json
4KB
Binary
LinearTokenTimelock ABI
ilineartokentimelock.json
2KB
Binary
LinearTokenTimelock Interface ABI
Last modified 4mo ago