You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/vault/STORAGE.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,8 +32,8 @@ pub enum StorageKey {
32
32
|`AllowedDepositors`|`Vec<Address>`| List of addresses allowed to deposit into the vault | Access control for deposits |`set_allowed_depositor()`, readable via `is_authorized_depositor()`|
33
33
|`Admin`|`Address`| Administrator address authorized to call `distribute()` and `set_admin()`| Access control for distributions |`get_admin()`, `set_admin()` (admin-only) |
34
34
|`UsdcToken`|`Address`| USDC token contract address | Token transfers for deposits, deducts, distributions | Set during `init()`, used by token operations |
35
-
|`Settlement`|`Option<Address>`| Settlement contract address; receives USDC on deduct operations | Deduct routing (priority over RevenuePool) |`set_settlement()`, `get_settlement()` (admin-only) |
36
-
|`RevenuePool`|`Option<Address>`| Revenue pool contract address; receives USDC on deduct if Settlement is not set | Deduct routing (fallback) |Set during `init()`, used if Settlement not configured|
35
+
|`Settlement`|`Option<Address>`| Settlement contract address; receives USDC on deduct operations | Deduct routing (priority over RevenuePool) |`set_settlement()`, `get_settlement()` (admin-only write, public read) |
36
+
|`RevenuePool`|`Option<Address>`| Revenue pool contract address; receives USDC on deduct if Settlement is not set | Deduct routing (fallback) |`set_revenue_pool()`, `get_revenue_pool()` (admin-only write, public read)|
37
37
|`MaxDeduct`|`i128`| Maximum USDC amount per single deduct operation | Deduct limit enforcement | Set during `init()`, read by `deduct()` and `batch_deduct()`|
38
38
|`Metadata(offering_id)`|`String`| Off-chain metadata reference (IPFS CID or URI) for a specific offering | Offering metadata |`set_metadata()`, `get_metadata()`, `update_metadata()` (owner-only) |
39
39
@@ -116,13 +116,22 @@ Sets up the vault with initial state:
116
116
| Operation | Reads | Writes | Authorization |
117
117
|-----------|-------|--------|-----------------|
118
118
|`set_settlement(settlement_address)`| Admin | Settlement | Admin only |
119
-
|`get_settlement()`| Settlement | — | Public read |
119
+
|`get_settlement()`| Settlement | — | Public read (view-only, no mutation) |
120
+
|`set_revenue_pool(revenue_pool)`| Admin | RevenuePool | Admin only |
121
+
|`get_revenue_pool()`| RevenuePool | — | Public read (view-only, no mutation) |
120
122
121
123
**Deduct Routing Logic:**
122
124
1. If `StorageKey::Settlement` is set: transfer USDC to settlement
123
125
2. Else if `StorageKey::RevenuePool` is set: transfer USDC to revenue pool
124
126
3. Else: USDC remains in vault
125
127
128
+
**View Function Safety:**
129
+
- Both `get_settlement()` and `get_revenue_pool()` are read-only operations
130
+
- They return only final committed state, never intermediate or pending values
131
+
- Safe for external indexers and off-chain queries
132
+
- Deterministic: identical state inputs always produce identical outputs
133
+
-`get_settlement()` panics if not configured; `get_revenue_pool()` returns `None` gracefully
0 commit comments