Join our community of builders on

Telegram!Telegram
API Reference

Finance

This crate includes primitives for financial systems.

Interfaces

Starting from version 3.x.x, the interfaces are no longer part of the openzeppelin_access package. The references documented here are contained in the openzeppelin_interfaces package version 2.1.0.

use openzeppelin_interfaces::vesting::IVesting;

Common interface for contracts implementing the vesting functionality.

Functions

Events

Functions

start() → u64

external

#

Returns the timestamp marking the beginning of the vesting period.

cliff() → u64

external

#

Returns the timestamp marking the end of the cliff period.

duration() → u64

external

#

Returns the total duration of the vesting period.

end() → u64

external

#

Returns the timestamp marking the end of the vesting period.

released(token: ContractAddress) → u256

external

#

Returns the already released amount for a given token.

releasable(token: ContractAddress) → u256

external

#

Returns the amount of a given token that can be released at the time of the call.

vested_amount(token: ContractAddress, timestamp: u64) → u256

external

#

Returns the total vested amount of a specified token at a given timestamp.

release(token: ContractAddress) → u256

external

#

Releases the amount of a given token that has already vested and returns that amount.

May emit an AmountReleased event.

Events

AmountReleased(token: ContractAddress, amount: u256)

event

#

Emitted when vested tokens are released to the beneficiary.

Vesting

use openzeppelin_finance::vesting::VestingComponent;

Vesting component implementing the IVesting interface.

Vesting Schedule Trait Implementations

functions

Embeddable Implementations

VestingImpl

Internal implementations

InternalImpl

A trait that defines the logic for calculating the vested amount based on a given timestamp.

You can read more about the trait's purpose and how to use it here.

calculate_vested_amount(self: @ContractState, token: ContractAddress, total_allocation: u256, timestamp: u64, start: u64, duration: u64, cliff: u64) → u256

internal

#

Calculates and returns the vested amount at a given timestamp based on the core vesting parameters.

Functions

start(self: @ContractState) → u64

external

#

Returns the timestamp marking the beginning of the vesting period.

cliff(self: @ContractState) → u64

external

#

Returns the timestamp marking the end of the cliff period.

duration(self: @ContractState) → u64

external

#

Returns the total duration of the vesting period.

end(self: @ContractState) → u64

external

#

Returns the timestamp marking the end of the vesting period.

released(self: @ContractState, token: ContractAddress) → u256

external

#

Returns the already released amount for a given token.

releasable(self: @ContractState, token: ContractAddress) → u256

external

#

Returns the amount of a given token that can be released at the time of the call.

vested_amount(self: @ContractState, token: ContractAddress, timestamp: u64) → u256

external

#

Returns the total vested amount of a specified token at a given timestamp.

release(ref self: ContractState, token: ContractAddress) → u256

external

#

Releases the amount of a given token that has already vested and returns that amount.

If the releasable amount is zero, this function won't emit the event or attempt to transfer the tokens.

Requirements:

  • transfer call to the token must return true indicating a successful transfer.

May emit an AmountReleased event.

Internal functions

initializer(ref self: ContractState, start: u64, duration: u64, cliff_duration: u64)

internal

#

Initializes the component by setting the vesting start, duration and cliff_duration. To prevent reinitialization, this should only be used inside of a contract's constructor.

Requirements:

  • cliff_duration must be less than or equal to duration.

resolve_vested_amount(self: @ContractState, token: ContractAddress, timestamp: u64) → u256

internal

#

Returns the vested amount that's calculated using the VestingSchedule trait implementation.

use openzeppelin_finance::vesting::LinearVestingSchedule;

Defines the logic for calculating the vested amount, incorporating a cliff period. It returns 0 before the cliff ends. After the cliff period, the vested amount returned is directly proportional to the time passed since the start of the vesting schedule.

Presets

use openzeppelin::presets::VestingWallet;

A non-upgradable contract leveraging VestingComponent and OwnableComponent.

The contract is intentionally designed to be non-upgradable to ensure that neither the vesting initiator nor the vesting beneficiary can modify the vesting schedule without the consent of the other party.

Sierra class hash

0x00540c7f907539e1a283318fb3da16f1bf9d9e60ad10c20d0557a0185043b08f

Constructor

Embedded Implementations

VestingComponent

OwnableComponent

Constructor

constructor(ref self: ContractState, beneficiary: ContractAddress, start: u64, duration: u64, cliff_duration: u64)

constructor

#

Initializes the vesting component by setting the vesting start, duration and cliff_duration. Assigns beneficiary as the contract owner and the vesting beneficiary.

Requirements:

  • cliff_duration must be less than or equal to duration.