Skip to content
Closed
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
52 changes: 52 additions & 0 deletions content/contracts-sui/1.x/allowance.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Allowance
---

<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_allowance` package provides cap-keyed, multi-coin spending allowances for Sui Move protocols. A shared, untyped `Vault` escrows funds for any number of coin types, an `OwnerCap` controls the pool and the budgets, and each `SpenderCap` draws against per-`(cap, coin)` budgets with optional expiry.

Use this package when a protocol or keeper custodies a user's `SpenderCap` and spends on their behalf within the owner's budget, without the user signing each spend; the same primitive also covers subscription pulls and per-partner budgets across coin types.

## 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 (the package is not yet on the Move Registry):

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

### Copy the source

Alternatively, copy [`spend_vault.move`](https://github.com/OpenZeppelin/contracts-sui/blob/v1.4.0/contracts/allowance/sources/spend_vault.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, at the cost of tracking upstream fixes yourself.

### Import

Once the package is available, import the module:

```move
use openzeppelin_allowance::spend_vault::{Self, Vault, OwnerCap, SpenderCap};
```

## Modules

<Cards>
<Card href="/contracts-sui/1.x/spend-vault" title="Spend Vault">
Cap-keyed, multi-coin allowance ledger over an escrowed shared vault, with per-`(cap, coin)` budgets, expiries, suspension, revocation, and unconditional owner exit.
</Card>
</Cards>

## Next steps

- [Spend Vault](/contracts-sui/1.x/spend-vault) for the module guide and key concepts.
- [Integrating into a protocol](/contracts-sui/1.x/spend-vault#integrating-into-a-protocol) to custody a user's cap and spend on their behalf under the owner's budget.
- [Security considerations](/contracts-sui/1.x/spend-vault#security-considerations) for bearer-cap custody, budget-ceiling, and teardown caveats.
- [Allowance API reference](/contracts-sui/1.x/api/allowance) for function signatures, events, and errors.
- [Delegated Spending](/contracts-sui/1.x/guides/delegated-spending) for the end-to-end tutorial.
615 changes: 615 additions & 0 deletions content/contracts-sui/1.x/api/allowance.mdx

Large diffs are not rendered by default.

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.
Loading