Skip to content

Commit

Permalink
chore: add vesting extension (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
GAtom22 authored Oct 2, 2023
1 parent 298e180 commit 77dec9e
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ queries, and examples of using them:
- [`x/staking` module EVM extension](./staking.md)
- [`x/distribution` module EVM extension](./distribution.md)
- [`ibc/transfer` module EVM extension](./ibc-transfer.md)
- [`x/vesting` module EVM extension](./vesting.md)

:::tip
**Note**: Find the EVM Extensions Solidity interfaces and examples in the [Evmos Extensions repo](https://github.com/evmos/extensions).
Expand Down
163 changes: 163 additions & 0 deletions docs/develop/smart-contracts/evm-extensions/vesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
sidebar_position: 6
---

# Vesting

## Solidity Interface & ABI

`Vesting.sol` is an interface through which Solidity contracts can interact with Evmos vesting module.
This is convenient for developers as they don’t need to know the implementation details behind the `x/vesting`
module in Evmos. Instead,
they can interact with vesting accounts using the Ethereum interface they are familiar with.

:::tip
To learn more about the `x/vesting` module, check out the [module's docs](https://docs.evmos.org/protocol/modules/vesting).
:::

### Interface `Vesting.sol`

Find the [Solidity interface in the evmos/extensions repo](https://github.com/evmos/extensions/blob/main/precompiles/stateful/Vesting.sol).

### ABI

Find the [ABI in the evmos/extensions repo](https://github.com/evmos/extensions/blob/main/precompiles/abi/vesting.json).

## Transactions

The Vesting solidity interface includes the following transactions

- `createClawbackVestingAccount`

`createClawbackVestingAccount` defines a method for the creation of a `ClawbackVestingAccount`.

```solidity
function createClawbackVestingAccount(
address funderAddress,
address vestingAddress,
bool enableGovClawback
) external returns (bool success);
```

- `fundVestingAccount`

`fundVestingAccount` defines a method for funding a vesting account.

```solidity
function fundVestingAccount(
address funderAddress,
address vestingAddress,
uint64 startTime,
Period[] calldata lockupPeriods,
Period[] calldata vestingPeriods
) external returns (bool success);
```

- `clawback`

`clawback` defines a method for clawing back coins from a vesting account.

```solidity
function clawback(
address funderAddress,
address accountAddress,
address destAddress
) external returns (Coin[] memory);
```

- `updateVestingFunder`

`updateVestingFunder` defines a method for updating the funder of a vesting account.

```solidity
function updateVestingFunder(
address funderAddress,
address newFunderAddress,
address vestingAddress
) external returns (bool success);
```

- `convertVestingAccount`

`convertVestingAccount` defines a method for converting a clawback vesting account to an eth account.

```solidity
function convertVestingAccount(
address vestingAddress
) external returns (bool success);
```

## Queries

- `balances`

`balances` query the balances of a vesting account

```solidity
function balances(
address vestingAddress
) external view returns (Coin[] memory locked, Coin[] memory unvested, Coin[] memory vested);
```

## Events

Each of the transactions emits its corresponding event. These are:

- `CreateClawbackVestingAccount`

Event that is emitted when a clawback vesting account is created.

```solidity
event CreateClawbackVestingAccount(
address indexed funderAddress,
address indexed vestingAddress
);
```

- `FundVestingAccount`

Event that is emitted when a clawback vesting account is funded.

```solidity
event FundVestingAccount(
address indexed funderAddress,
address indexed vestingAddress,
uint64 startTime,
Period[] lockupPeriods,
Period[] vestingPeriods
);
```

- `Clawback`

Event that is emitted when a vesting account is clawed back.

```solidity
event Clawback(
address indexed funderAddress,
address indexed accountAddress,
address destAddress
);
```

- `UpdateVestingFunder`

Event that is emitted when a vesting account's funder is updated.

```solidity
event UpdateVestingFunder(
address indexed funderAddress,
address indexed vestingAddress,
address newFunderAddress
);
```

- `ConvertVestingAccount`

Event that is emitted when a vesting account is converted to a clawback vesting account.

```solidity
event ConvertVestingAccount(
address indexed vestingAddress
);
```
1 change: 1 addition & 0 deletions docs/develop/smart-contracts/list-evm-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The following extensions are available in Evmos' implementation of the EVM:
| `0x0000000000000000000000000000000000000800` | Staking module | Yes | | :heavy_check_mark: | :heavy_check_mark: |
| `0x0000000000000000000000000000000000000801` | Distribution module | Yes | | :heavy_check_mark: | :heavy_check_mark: |
| `0x0000000000000000000000000000000000000802` | IBC Transfer | Yes | | :heavy_check_mark: | :heavy_check_mark: |
| `0x0000000000000000000000000000000000000803` | Vesting module | Yes | | :heavy_check_mark: | :heavy_check_mark: |

## Further Reading

Expand Down

0 comments on commit 77dec9e

Please sign in to comment.