Skip to content

Commit e7502c6

Browse files
committed
doc: docs update
1 parent 52ce4a7 commit e7502c6

4 files changed

Lines changed: 47 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ while maintaining exposure to staking rewards.
2626

2727
### L2 Layer (i.e. Base, etc)
2828
- **StakingManager**: Orchestrates service deployment and staking operations
29-
- **ExternalStakingDistributor**: Performs service deployment and staking for external staking contracts
29+
- **ExternalStakingDistributor**: Manages external staking on third-party staking proxies — deploys services (creates Safe multisigs with self as module), stakes/unstakes/re-stakes, claims and distributes rewards (split between Collector, protocol, and curating agent per configurable reward factors). Supports V1 (rewards on multisig) and V2 (rewards on contract) staking types. Access-controlled via owner, managing agents (unstakes), and per-proxy curating agents with staking guards
3030
- **StakingTokenLocked**: Manages individual staking instances and reward distribution
3131
- **ActivityModule**: Handles service activity verification and reward claiming
3232
- **Collector**: Collects and bridges rewards back to L1
@@ -49,7 +49,7 @@ contracts/
4949
│ └── UnstakeRelayer.sol # Unstake request handling
5050
├── l2/ # L2 (Gnosis Chain) contracts
5151
│ ├── StakingManager.sol # Staking orchestration
52-
│ ├── ExternalStakingDistributor # External staking orchestration
52+
│ ├── ExternalStakingDistributor.sol # External staking orchestration
5353
│ ├── StakingTokenLocked.sol # Individual staking instances
5454
│ ├── ActivityModule.sol # Service activity management
5555
│ └── Collector.sol # Reward collection and bridging
@@ -80,7 +80,7 @@ doc/ # Documentation and whitepaper
8080
1. Services are deployed on L2 with OLAS backing
8181
2. Rewards accumulate based on service performance
8282
3. ActivityModule verifies service liveness and required KPI performance
83-
4. ExternalStakingDistributor curates all external staking and forces unstakes, if required
83+
4. ExternalStakingDistributor curates external staking on third-party proxies: deploys services via Safe multisigs, stakes them, claims rewards (split between Collector, protocol, and curating agents per configurable factors), and forces unstakes for underperformers or when rewards are zero/service is evicted
8484
5. Collector gathers rewards and bridges them back to L1 via a Distributor contract
8585

8686
### 3. Withdrawal Process

doc/agent-workflow.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,31 @@ if ((stakingProxy.getNumServiceIds() > 0) && (block.timestamp - stakingProxy.tsC
156156
This check is going to skip the `checkpoint()` call if no agents are staked or if the checkpoint has been already
157157
triggered within the `livenessPeriod` time.
158158

159+
### External Staking (ExternalStakingDistributor)
160+
161+
The [ExternalStakingDistributor](../contracts/l2/ExternalStakingDistributor.sol) manages staking on third-party staking proxy contracts. It deploys services (creating Safe multisigs with itself as module), stakes/unstakes/re-stakes them, and claims and distributes rewards.
162+
163+
**Staking:** Whitelisted curating agents (or the owner) call `stake()` to deploy a service on a whitelisted staking proxy. The contract creates a Safe multisig, registers it as a service, and stakes it. The curating agent is recorded per service.
164+
165+
**Claiming rewards:** Agents call `claim()` with arrays of staking proxies and service Ids. Rewards are distributed according to per-proxy configurable factors (must sum to 100%):
166+
- **Collector share** — sent to Collector via `topUpBalance(amount, REWARD)` for L1 bridging
167+
- **Protocol share** — sent to Collector via `topUpProtocol(amount)` for protocol use
168+
- **Curating agent share** — transferred directly to the curating agent address
169+
170+
For V1 staking types, rewards land on the service multisig and are distributed via `execTransactionFromModule`. For V2 staking types, rewards land directly on the contract.
171+
172+
**Unstaking:** Managing agents (or the owner) call `unstakeAndWithdraw()` to unstake a service, distribute remaining rewards, and optionally fulfill pending withdraw requests through Collector. Anyone can trigger unstake if the staking proxy has zero available rewards or if the service is evicted.
173+
174+
**Re-staking:** If a service is evicted, curating agents, managing agents, or the owner can call `reStake()` to unstake and immediately re-stake it.
175+
176+
Events to track external staking activity:
177+
```solidity
178+
event ExternalServiceStaked(address indexed sender, address indexed stakingProxy, uint256 indexed serviceId, uint256 agentId, bytes32 configHash, uint256 stakingDeposit, uint256 stakedBalance);
179+
event ExternalServiceUnstaked(address indexed sender, address indexed stakingProxy, uint256 indexed serviceId, uint256 stakingDeposit, uint256 stakedBalance);
180+
event ExternalServiceRestaked(address indexed sender, address indexed stakingProxy, uint256 indexed serviceId);
181+
event Claimed(address[] stakingProxies, uint256[] serviceIds, uint256[] rewards);
182+
```
183+
159184
### Trigger L2 to L1 Tokens Bridging
160185

161186
Each L2 [Collector](../contracts/l2/Collector.sol) proxy contract collects OLAS from **REWARD** / **UNSTAKE** / **UNSTAKE_RETIRED**

doc/architecture-diagrams.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ flowchart LR
2424
2525
subgraph L2 [L2 — Gnosis, Base]
2626
SM[StakingManager]
27+
ESD[ExternalStakingDistributor]
2728
STL[StakingTokenLocked]
2829
Coll[Collector]
2930
Svc[Services]
@@ -54,6 +55,10 @@ flowchart LR
5455
A-->|claim|AM
5556
AM-->|claim|SM
5657
AM-->|controls|Svc
58+
BP2 -->|deposit OLAS| ESD
59+
ESD -->|stake / unstake / re-stake| Svc
60+
ESD -->|claim rewards| Svc
61+
ESD -->|distribute rewards| Coll
5762
5863
%% C) Withdraw & Unstake (UNSTAKE → Treasury)
5964
U -->|request to withdraw and finalize| T
@@ -86,6 +91,7 @@ sequenceDiagram
8691
participant UR as UnstakeRelayer
8792
participant BP1 as Bridge (L1)
8893
participant SM as StakingManager
94+
participant ESD as ExternalStakingDistributor
8995
participant STL as StakingTokenLocked
9096
participant Coll as Collector
9197
participant S as Services
@@ -109,6 +115,14 @@ sequenceDiagram
109115
Dist->>V: top up vault balance
110116
Dist-->>V: optional lock to veOLAS
111117
118+
%% B2) External Staking (ExternalStakingDistributor)
119+
BP1->>ESD: deposit OLAS (via L2 staking processor)
120+
ESD->>S: deploy service (create Safe multisig, stake)
121+
S->>ESD: rewards accrue
122+
ESD->>ESD: claim & distribute rewards
123+
ESD->>Coll: collector share (topUpBalance REWARD)
124+
ESD->>Coll: protocol share (topUpProtocol)
125+
112126
%% C) Withdraw with possible shortfall (UNSTAKE -> Treasury)
113127
U->>T: request withdraw
114128
T->>V: redeem up to vault+reserve
@@ -142,7 +156,8 @@ sequenceDiagram
142156
- **UnstakeRelayer** — receives **UNSTAKE_RETIRED** returns and forwards to `stOLAS.topUpRetiredBalance` (does not directly fund Treasury payouts).
143157

144158
**L2 components**
145-
- **StakingManager / StakingTokenLocked** — manage staking lifecycle for services and accrue rewards.
159+
- **StakingManager / StakingTokenLocked** — manage internal staking lifecycle for LST services and accrue rewards.
160+
- **ExternalStakingDistributor** — manages external staking on third-party staking proxies. Deploys services (creates Safe multisigs with self as module), stakes/unstakes/re-stakes, claims and distributes rewards split between Collector (for L1 bridging), protocol (`topUpProtocol`), and curating agents per configurable reward factors (must sum to 100%). Supports V1 (rewards on multisig) and V2 (rewards on contract) staking types. Access control: owner, whitelisted managing agents (unstakes), per-proxy curating agents with staking guards. Receives OLAS from L2 staking processor (`deposit`) and handles withdraw/unstake requests back through Collector (`withdrawAndRequestUnstake`, `unstakeAndWithdraw`).
146161
- **Collector** — bridges ops/tokens to L1 with explicit routing for: **REWARD**, **UNSTAKE**, **UNSTAKE_RETIRED**.
147162

148163
**Bridge Processor (L1/L2)** — abstract transport for messages + OLAS between chains.

doc/architecture.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ It is meant to accompany `README.md` and serve as a quick reference for develope
1818
- **`UnstakeRelayer`** — handles returns of permanently closed staking model unstakes; tops up `stOLAS` with retired reserves.
1919

2020
**L2 (Gnosis, Base, etc.):**
21-
- **`StakingManager` / `ExternalStakingDistributor` / `StakingTokenLocked`** — staking logic for services, accrual of rewards, initiation of stake and unstake.
21+
- **`StakingManager`** — orchestrates internal service deployment/staking for LST-managed services.
22+
- **`ExternalStakingDistributor`** — manages external staking on third-party staking proxies. Deploys services by creating Safe multisigs (with self as module), stakes/unstakes/re-stakes services, claims rewards and distributes them (split between Collector for L1 bridging, protocol via `topUpProtocol`, and curating agent per configurable reward factors). Supports two staking types: V1 (rewards land on service multisig, distributed via `execTransactionFromModule`) and V2 (rewards land directly on the contract). Access control: owner can do everything; whitelisted **managing agents** can force unstakes; per-proxy **curating agents** (guarded by a **staking guard** address) can stake. Receives OLAS deposits from L2 staking processor and handles withdraw/unstake requests back through Collector.
23+
- **`StakingTokenLocked`** — restricted StakingToken that only allows StakingManager as staker.
2224
- **`Collector`** — bridge intermediary: routes collected tokens back to L1.
2325

2426
**Bridging Processors:**

0 commit comments

Comments
 (0)