or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

access-control.mdaccount-abstraction.mdfinance.mdgovernance.mdindex.mdmeta-transactions.mdproxy-upgradeability.mdsecurity-utilities.mdtoken-standards.md

finance.mddocs/

0

# Finance

1

2

Financial utilities including vesting wallets with linear and cliff-based release schedules for token distribution and payment management.

3

4

## Capabilities

5

6

### Vesting Wallet

7

8

Linear vesting wallet that releases tokens over time.

9

10

```solidity { .api }

11

/**

12

* @dev Contract that handles the vesting of Ether and ERC-20 tokens for a beneficiary

13

*/

14

contract VestingWalletUpgradeable {

15

function __VestingWallet_init(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) internal onlyInitializing;

16

17

/**

18

* @dev Returns the beneficiary of the tokens

19

*/

20

function beneficiary() external view returns (address);

21

22

/**

23

* @dev Returns the start time of the vesting period

24

*/

25

function start() external view returns (uint256);

26

27

/**

28

* @dev Returns the duration of the vesting period

29

*/

30

function duration() external view returns (uint256);

31

32

/**

33

* @dev Returns the end time of the vesting period

34

*/

35

function end() external view returns (uint256);

36

37

/**

38

* @dev Amount of eth already released

39

*/

40

function released() external view returns (uint256);

41

42

/**

43

* @dev Amount of token already released

44

*/

45

function released(address token) external view returns (uint256);

46

47

/**

48

* @dev Amount of releasable eth

49

*/

50

function releasable() external view returns (uint256);

51

52

/**

53

* @dev Amount of releasable token

54

*/

55

function releasable(address token) external view returns (uint256);

56

57

/**

58

* @dev Release the native token (ether) that have already vested

59

*/

60

function release() external;

61

62

/**

63

* @dev Release the tokens that have already vested

64

*/

65

function release(address token) external;

66

67

/**

68

* @dev Calculates the amount of ether that has already vested

69

*/

70

function vestedAmount(uint64 timestamp) external view returns (uint256);

71

72

/**

73

* @dev Calculates the amount of tokens that has already vested

74

*/

75

function vestedAmount(address token, uint64 timestamp) external view returns (uint256);

76

}

77

78

// Events

79

event EtherReleased(uint256 amount);

80

event ERC20Released(address indexed token, uint256 amount);

81

```

82

83

### Vesting Wallet with Cliff

84

85

Vesting wallet with cliff period before vesting begins.

86

87

```solidity { .api }

88

/**

89

* @dev Extension of VestingWallet that includes a cliff period

90

*/

91

contract VestingWalletCliffUpgradeable {

92

function __VestingWalletCliff_init(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds, uint64 cliffSeconds) internal onlyInitializing;

93

94

/**

95

* @dev Returns the cliff time of the vesting period

96

*/

97

function cliff() external view returns (uint256);

98

99

// Inherits all VestingWalletUpgradeable functions

100

}

101

```

102

103

## Usage Examples

104

105

### Basic Vesting Wallet

106

107

```solidity

108

import {VestingWalletUpgradeable} from "@openzeppelin/contracts-upgradeable/finance/VestingWalletUpgradeable.sol";

109

110

contract TeamVesting is VestingWalletUpgradeable {

111

function initialize(

112

address teamMember,

113

uint64 vestingStart,

114

uint64 vestingDuration

115

) initializer public {

116

__VestingWallet_init(teamMember, vestingStart, vestingDuration);

117

}

118

119

// Contract can receive ETH and ERC-20 tokens

120

receive() external payable {}

121

}

122

```

123

124

### Cliff Vesting for Token Sales

125

126

```solidity

127

import {VestingWalletCliffUpgradeable} from "@openzeppelin/contracts-upgradeable/finance/VestingWalletCliffUpgradeable.sol";

128

129

contract PrivateSaleVesting is VestingWalletCliffUpgradeable {

130

function initialize(

131

address investor,

132

uint64 saleEnd,

133

uint64 vestingDuration,

134

uint64 cliffDuration

135

) initializer public {

136

__VestingWalletCliff_init(investor, saleEnd, vestingDuration, cliffDuration);

137

}

138

139

function getVestingInfo() external view returns (

140

address beneficiaryAddr,

141

uint256 startTime,

142

uint256 cliffTime,

143

uint256 endTime,

144

uint256 totalDuration

145

) {

146

return (

147

beneficiary(),

148

start(),

149

cliff(),

150

end(),

151

duration()

152

);

153

}

154

}

155

```