Overview & Background
Currently, FlowFi allows individual stream senders to pause and resume their own streams. However, there is no protocol-level circuit breaker. In the event of an underlying Stellar asset de-peg, a security vulnerability in an integrated bridge or DEX, an identified contract exploit, or abnormal RPC network disruptions, the protocol admin or governance multisig needs the ability to execute a global emergency pause.
Detailed Problem Statement
- Lack of Central Circuit Breaker:
- The protocol administration cannot halt operations globally during an active exploit or emergency.
- Fund Safety Guarantee:
- While deposits and creations should be haltable, recipient withdrawals of already-vested funds must remain protected to prevent censorship or trapping user capital.
Technical Specification & Architecture
1. Protocol Configuration Extension (types.rs)
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProtocolConfig {
pub admin: Address,
pub treasury: Address,
pub fee_rate_bps: u32,
pub is_protocol_paused: bool,
pub emergency_guardian: Option<Address>,
}
2. Circuit Breaker Controls
pub fn set_protocol_pause(env: Env, paused: bool) -> Result<(), StreamError> {
let mut config = storage::load_config(&env).ok_or(StreamError::NotInitialized)?;
// Admin or emergency guardian can pause; only admin can unpause
if paused {
if let Some(ref guardian) = config.emergency_guardian {
if guardian != &config.admin {
// guardian or admin authorization
}
}
config.admin.require_auth();
} else {
config.admin.require_auth();
}
config.is_protocol_paused = paused;
storage::save_config(&env, &config);
events::emit_protocol_pause_status(&env, paused);
Ok(())
}
3. Guard Implementation
create_stream, batch_create_streams, create_stream_with_cliff, top_up_stream must check config.is_protocol_paused and revert with StreamError::ProtocolPaused.
withdraw remains operational so recipients can access already-vested collateral.
Target Files
contracts/stream_contract/src/types.rs
contracts/stream_contract/src/lib.rs
contracts/stream_contract/src/storage.rs
contracts/stream_contract/src/events.rs
contracts/stream_contract/src/test.rs
Acceptance Criteria
Overview & Background
Currently, FlowFi allows individual stream senders to pause and resume their own streams. However, there is no protocol-level circuit breaker. In the event of an underlying Stellar asset de-peg, a security vulnerability in an integrated bridge or DEX, an identified contract exploit, or abnormal RPC network disruptions, the protocol admin or governance multisig needs the ability to execute a global emergency pause.
Detailed Problem Statement
Technical Specification & Architecture
1. Protocol Configuration Extension (
types.rs)2. Circuit Breaker Controls
3. Guard Implementation
create_stream,batch_create_streams,create_stream_with_cliff,top_up_streammust checkconfig.is_protocol_pausedand revert withStreamError::ProtocolPaused.withdrawremains operational so recipients can access already-vested collateral.Target Files
contracts/stream_contract/src/types.rscontracts/stream_contract/src/lib.rscontracts/stream_contract/src/storage.rscontracts/stream_contract/src/events.rscontracts/stream_contract/src/test.rsAcceptance Criteria