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
**Synonyms:** the indexer accepts `rebalance_executed` or `executed` as the second topic for the rebalance event (same payload rules).
56
58
@@ -64,9 +66,43 @@ The `deposit` event now includes a `memo: String` field at tuple index `3`. Back
64
66
-**Amount (deposit / withdraw):** tuple index `2`.
65
67
-**Timestamp (rebalanced / cooldown_override):** tuple index `1` for rebalanced; index `2` for cooldown_override when admin is at index `1`.
66
68
-**Memo (deposit):** tuple index `3`, or object keys `memo`.
69
+
-**Old allocations (alloc_upd):** tuple index `1`, `Map<Address, u32>` of previous target allocations.
70
+
-**New allocations (alloc_upd):** tuple index `2`, `Map<Address, u32>` of updated target allocations.
67
71
68
72
Events from other contracts or with unknown second topics are skipped without failing the batch.
69
73
74
+
### `alloc_upd` event details
75
+
76
+
Emitted by the `update_allocations` entrypoint when a user changes a portfolio's target allocation percentages.
77
+
78
+
**Contract entrypoint:**`update_allocations(portfolio_id: u64, new_allocations: Map<Address, u32>)` — see [`contracts/src/lib.rs`](../contracts/src/lib.rs) and the [Contract Capability Matrix](CONTRACT_CAPABILITY_MATRIX.md) (`update_allocations` row).
79
+
80
+
**Emit source:**`contracts/src/events.rs` (`emit_allocation_updated`) and inline in `contracts/src/lib.rs`.
81
+
82
+
**Sample event payload:**
83
+
84
+
```json
85
+
{
86
+
"type": "contract",
87
+
"topics": ["portfolio", "alloc_upd"],
88
+
"data": {
89
+
"portfolio_id": 1,
90
+
"old_allocations": {
91
+
"CDLZFC...XLM": 40,
92
+
"CDMLFK...USDC": 35,
93
+
"CBKTPM...BTC": 25
94
+
},
95
+
"new_allocations": {
96
+
"CDLZFC...XLM": 50,
97
+
"CDMLFK...USDC": 30,
98
+
"CBKTPM...BTC": 20
99
+
}
100
+
}
101
+
}
102
+
```
103
+
104
+
> **Note:** The `events.rs` helper (`emit_allocation_updated`) emits the event with topics `(alloc_upd, invoker, correlation_id)` and payload `portfolio_id`. The inline emit in `lib.rs` uses topics `(portfolio, alloc_upd)` with payload `(portfolio_id, old_allocations, new_allocations)`. Backend indexers should handle both shapes.
105
+
70
106
## Reusable test fixtures
71
107
72
108
The contract test suite emits canonical event sequences that backend integration tests can replay.
@@ -91,6 +127,7 @@ The contract test suite emits canonical event sequences that backend integration
91
127
|`test_deposit_with_memo.1.json`|`portfolio.created`, `portfolio.deposit`| Deposit with explicit reference memo |
92
128
|`test_execute_rebalance_success.1.json`|`portfolio.created`, `portfolio.deposit`, `portfolio.rebalanced`| Full rebalance lifecycle |
93
129
|`test_set_fee_config.1.json`|`portfolio.created`, `portfolio.rebalanced`, `portfolio.fee_charged`| Rebalance with fee config enabled |
130
+
|`test_update_allocations_success.1.json`|`portfolio.created`, `portfolio.alloc_upd`| Allocation update with old and new maps |
94
131
95
132
### Exporting fixtures for external use
96
133
@@ -114,3 +151,4 @@ The `test_contract_events_fixture_export` test in `contracts/src/test.rs` valida
114
151
-`contracts/src/test.rs` — Soroban contract tests that produce event snapshot fixtures.
115
152
-`backend/src/test/contractEventSchema.test.ts` — version string parsing and mismatch behavior.
116
153
-`contracts/src/test.rs` — Soroban integration tests and snapshot fixtures for contract calls.
0 commit comments