Skip to content

Commit 729a680

Browse files
committed
feat: update skill
1 parent 65a101d commit 729a680

16 files changed

Lines changed: 1696 additions & 898 deletions

File tree

content/contracts-sui/1.x/access.mdx

Lines changed: 312 additions & 4 deletions
Large diffs are not rendered by default.

content/contracts-sui/1.x/fixed-point.mdx

Lines changed: 381 additions & 9 deletions
Large diffs are not rendered by default.

content/contracts-sui/1.x/index.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
title: Contracts for Sui 1.x
33
---
44

5-
**OpenZeppelin Contracts for Sui v1.x** ships two core packages:
5+
**OpenZeppelin Contracts for Sui v1.x** ships three core packages:
66

7-
- `openzeppelin_math` for deterministic arithmetic, configurable rounding, and decimal scaling.
7+
- `openzeppelin_math` for deterministic integer arithmetic, configurable rounding, and decimal scaling.
8+
- `openzeppelin_fp_math` for 9-decimal fixed-point arithmetic (`UD30x9`, `SD29x9`) backed by `u128`.
89
- `openzeppelin_access` for ownership-transfer wrappers around privileged `key + store` objects.
910

1011
## Quickstart
@@ -27,16 +28,20 @@ cd my_sui_app
2728
```bash
2829
mvr add @openzeppelin-move/access
2930
mvr add @openzeppelin-move/integer-math
31+
mvr add @openzeppelin-move/fixed-point-math
3032
```
3133

34+
You only need the dependencies your app actually uses — add what you need and drop the others.
35+
3236
### 3. Verify `Move.toml`
3337

34-
`mvr add` updates `Move.toml` automatically. It should include:
38+
`mvr add` updates `Move.toml` automatically. With all three installed it should include:
3539

3640
```toml
3741
[dependencies]
3842
openzeppelin_access = { r.mvr = "@openzeppelin-move/access" }
3943
openzeppelin_math = { r.mvr = "@openzeppelin-move/integer-math" }
44+
openzeppelin_fp_math = { r.mvr = "@openzeppelin-move/fixed-point-math" }
4045
```
4146

4247
### 4. Add a Minimal Module
@@ -53,7 +58,7 @@ use openzeppelin_math::u64::{mul_div, sqrt};
5358
5459
public fun quote_with_fee(amount: u64): u64 {
5560
// 2.5% fee, rounded to nearest.
56-
let quoted = mul_div(amount,1025u64, 1000u64, rounding::nearest());
61+
let quoted = mul_div(amount, 1025u64, 1000u64, rounding::nearest());
5762
quoted.destroy_some()
5863
}
5964
@@ -69,7 +74,15 @@ sui move build
6974
sui move test
7075
```
7176

77+
## Picking a package
78+
79+
- Need integer arithmetic with safe overflow and explicit rounding? Use [Integer Math](/contracts-sui/1.x/math).
80+
- Need fractional values — prices, fees, rates, signed deltas? Use [Fixed-Point Math](/contracts-sui/1.x/fixed-point).
81+
- Need controlled transfer of admin/treasury/upgrade capabilities? Use [Access](/contracts-sui/1.x/access).
82+
83+
The packages compose. A typical protocol module imports `openzeppelin_math` for share math, `openzeppelin_fp_math` for rate and fee math, and `openzeppelin_access` for the admin capability that governs both.
84+
7285
## Next Steps
7386

74-
- Read package guides: [Integer Math](/contracts-sui/1.x/math), [Access](/contracts-sui/1.x/access).
75-
- Use API docs: [Integer Math](/contracts-sui/1.x/api/math), [Access](/contracts-sui/1.x/api/access).
87+
- Package guides: [Integer Math](/contracts-sui/1.x/math), [Fixed-Point Math](/contracts-sui/1.x/fixed-point), [Access](/contracts-sui/1.x/access).
88+
- 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).

content/contracts-sui/1.x/learn/access-walkthrough.mdx

Lines changed: 0 additions & 331 deletions
This file was deleted.

content/contracts-sui/1.x/learn/index.mdx

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)