Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
556 changes: 556 additions & 0 deletions content/contracts-sui/1.x/api/finance.mdx

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions content/contracts-sui/1.x/finance.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Finance
---

<Callout type="warn">
The example code snippets used in this guide are experimental and have not been audited. They simply help exemplify usage of the OpenZeppelin Sui Package.
</Callout>

The `openzeppelin_finance` package provides vesting primitives for releasing a locked coin to a beneficiary over time. It locks a `Balance<C>` for a single beneficiary and pays it out on a schedule: a curve-agnostic core handles release accounting and conservation of funds, while the curve - linear, stepped, cliff, or a custom shape you write - is a separate, swappable concern. Use it for token grants, team and investor vesting, payroll streams, and emission schedules.

## Usage

There are two ways to pull the package into your project. Pick whichever fits how much you want to own the code.

### Git dependency

Add the dependency in `Move.toml`, pinned to a git revision:

```toml
[dependencies]
openzeppelin_finance = { git = "https://github.com/OpenZeppelin/contracts-sui.git", subdir = "contracts/finance", rev = "v1.4.0" }
```

### Copy the source

Alternatively, copy [`vesting_wallet.move`](https://github.com/OpenZeppelin/contracts-sui/blob/v1.4.0/contracts/finance/sources/vesting_wallet.move) and [`vesting_wallet_linear.move`](https://github.com/OpenZeppelin/contracts-sui/blob/v1.4.0/contracts/finance/sources/vesting_wallet_linear.move) directly into your package's `sources/` (renaming the module addresses to your own package). You then fully own the code - free to trim, fork, or extend the curve - at the cost of tracking upstream fixes yourself.

### Import

Once the package is available, import the module you want to use:

```move
use openzeppelin_finance::vesting_wallet_linear; // the built-in linear-with-cliff curve
use openzeppelin_finance::vesting_wallet; // the curve-agnostic core
```

## Modules

<Cards>
<Card href="/contracts-sui/1.x/vesting-wallet" title="Vesting Wallet">
Lock a coin for a single beneficiary and release it on a schedule - linear or stepped vesting with an optional cliff via `vesting_wallet_linear`, or a custom curve on the curve-agnostic `vesting_wallet` core.
</Card>
</Cards>

## Choosing a module

| Module | Use it when |
|---|---|
| `vesting_wallet_linear` | You want standard token-grant vesting: a linear unlock, or `N` equal tranches, with an optional cliff. **Most integrators only need this module.** |
| `vesting_wallet` | You're authoring a custom curve (milestone unlocks, oracle-gated release, exotic cliff shapes), or building a protocol that drives vesting wallets **curve-agnostically** - wrapping or gating release without committing to a schedule. |

## Next steps

- [Vesting Wallet](/contracts-sui/1.x/vesting-wallet) for the module guide, the linear curve, topologies, and building custom curves on the core.
- [Finance API reference](/contracts-sui/1.x/api/finance) for function signatures, events, and errors.
- [Access](/contracts-sui/1.x/access) for role-based authorization to gate a curve-agnostic wrapper's privileged operations.
21 changes: 17 additions & 4 deletions content/contracts-sui/1.x/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
title: Contracts for Sui 1.x
---

**OpenZeppelin Contracts for Sui v1.x** ships four core packages:
**OpenZeppelin Contracts for Sui v1.x** ships these core packages:

- `openzeppelin_math` for deterministic integer arithmetic, configurable rounding, and decimal scaling.
- `openzeppelin_fp_math` for 9-decimal fixed-point arithmetic (`UD30x9`, `SD29x9`) backed by `u128`.
- `openzeppelin_access` for role-based authorization and ownership-transfer wrappers around privileged `key + store` objects.
- `openzeppelin_finance` for vesting: locking a coin for a beneficiary and releasing it on a schedule, with a built-in linear-with-cliff curve and a curve-agnostic core for custom schedules.
- `openzeppelin_utils` for embeddable building blocks; its first module, `rate_limiter`, provides multi-strategy rate limiting.

## Quickstart
Expand Down Expand Up @@ -35,9 +36,11 @@ mvr add @openzeppelin-move/utils

You only need the dependencies your app actually uses. Add what you need and drop the others.

Packages not yet on the Move Registry - currently `openzeppelin_finance` - are added by git revision instead of `mvr add` (see the next step).

### 3. Verify `Move.toml`

`mvr add` updates `Move.toml` automatically. With all three installed it should include:
`mvr add` updates `Move.toml` automatically. With all four installed it should include:

```toml
[dependencies]
Expand All @@ -47,6 +50,14 @@ openzeppelin_fp_math = { r.mvr = "@openzeppelin-move/fixed-point-math" }
openzeppelin_utils = { r.mvr = "@openzeppelin-move/utils" }
```

Since `openzeppelin_finance` isn't on MVR yet, add it manually, pinned to a git revision:

```toml
openzeppelin_finance = { git = "https://github.com/OpenZeppelin/contracts-sui.git", subdir = "contracts/finance", rev = "v1.4.0" }
```

Alternatively, copy the module sources directly into your package's `sources/` so you fully own the code - see each package guide for the per-package options.

### 4. Add a Minimal Module

Create `sources/quickstart.move`:
Expand Down Expand Up @@ -80,6 +91,7 @@ sui move test
## Picking a package

- Need role-based authorization for privileged functions or controlled transfer of admin/treasury/upgrade capabilities? Use [Access](/contracts-sui/1.x/access).
- Need to vest a token grant, team/investor allocation, or payroll stream to a beneficiary over time? Use [Vesting Wallet](/contracts-sui/1.x/vesting-wallet).
- Need fractional values like prices, fees, rates, or signed deltas? Use [Fixed-Point Math](/contracts-sui/1.x/fixed-point).
- Need integer arithmetic with safe overflow and explicit rounding? Use [Integer Math](/contracts-sui/1.x/math).
- Need to throttle withdrawals, meter per-user budgets, gate action reuse, or delay an action? Use [Rate Limiter](/contracts-sui/1.x/rate-limiter).
Expand All @@ -88,8 +100,9 @@ The packages compose. A typical protocol module imports `openzeppelin_math` for

## Next steps

- Package guides: [Integer Math](/contracts-sui/1.x/math), [Fixed-Point Math](/contracts-sui/1.x/fixed-point), [Access](/contracts-sui/1.x/access), [Utilities](/contracts-sui/1.x/utils).
- Package guides: [Integer Math](/contracts-sui/1.x/math), [Fixed-Point Math](/contracts-sui/1.x/fixed-point), [Access](/contracts-sui/1.x/access), [Finance](/contracts-sui/1.x/finance), [Utilities](/contracts-sui/1.x/utils).
- Access modules: [RBAC](/contracts-sui/1.x/access-control), [Two-Step Transfer](/contracts-sui/1.x/two-step-transfer), [Delayed Transfer](/contracts-sui/1.x/delayed-transfer).
- Finance modules: [Vesting Wallet](/contracts-sui/1.x/vesting-wallet).
- Utilities modules: [Rate Limiter](/contracts-sui/1.x/rate-limiter).
- Learn: [Role Based Access Control](/contracts-sui/1.x/guides/access-control).
- API reference: [Integer Math](/contracts-sui/1.x/api/math), [Fixed-Point Math](/contracts-sui/1.x/api/fixed-point), [Access](/contracts-sui/1.x/api/access), [Utilities](/contracts-sui/1.x/api/utils).
- API reference: [Integer Math](/contracts-sui/1.x/api/math), [Fixed-Point Math](/contracts-sui/1.x/api/fixed-point), [Access](/contracts-sui/1.x/api/access), [Finance](/contracts-sui/1.x/api/finance), [Utilities](/contracts-sui/1.x/api/utils).
Loading