Skip to content

Commit 82f9031

Browse files
Merge branch 'main' into fix/completed-issue-security-hardening
2 parents 47aa811 + 3874e2e commit 82f9031

460 files changed

Lines changed: 40053 additions & 61401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contract/src/events.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,60 @@ pub struct DelegationPoolEvent {
160160
pub timestamp: u64,
161161
}
162162

163+
/// Event payload for user fee discount tier progression
164+
#[contracttype]
165+
#[derive(Clone, Debug)]
166+
pub struct FeeDiscountTierUpdatedEvent {
167+
pub creator: Address,
168+
pub old_tier: u32,
169+
pub new_tier: u32,
170+
pub total_executions: u64,
171+
/// Event payload for oracle volatility breaches
172+
#[contracttype]
173+
#[derive(Clone, Debug)]
174+
pub struct OracleVolatilityBreachEvent {
175+
pub previous_price: i128,
176+
pub new_price: i128,
177+
pub volatility_bps: u32,
178+
pub max_volatility_bps: u32,
179+
pub timestamp: u64,
180+
}
181+
182+
/// Event payload for unpausing volatility circuit breaker
183+
#[contracttype]
184+
#[derive(Clone, Debug)]
185+
pub struct VolatilityCircuitBreakerUnpausedEvent {
186+
pub admin: Address,
187+
pub timestamp: u64,
188+
}
189+
163190
pub struct EventLogger;
164191

165192
impl EventLogger {
193+
/// Logs a user fee discount tier update
194+
pub fn log_fee_discount_tier_updated(
195+
env: &Env,
196+
creator: Address,
197+
old_tier: u32,
198+
new_tier: u32,
199+
total_executions: u64,
200+
) {
201+
let timestamp = env.ledger().timestamp();
202+
let event_data = FeeDiscountTierUpdatedEvent {
203+
creator: creator.clone(),
204+
old_tier,
205+
new_tier,
206+
total_executions,
207+
timestamp,
208+
};
209+
210+
let topics = (
211+
Symbol::new(env, "sorotask"),
212+
Symbol::new(env, "fee_discount_tier"),
213+
creator,
214+
);
215+
env.events().publish(topics, event_data);
216+
}
166217
/// Logs a state change for off-chain indexers
167218
pub fn log_state_change(
168219
env: &Env,
@@ -381,4 +432,41 @@ impl EventLogger {
381432
);
382433
env.events().publish(topics, event_data);
383434
}
435+
436+
pub fn log_oracle_volatility_breach(
437+
env: &Env,
438+
previous_price: i128,
439+
new_price: i128,
440+
volatility_bps: u32,
441+
max_volatility_bps: u32,
442+
) {
443+
let timestamp = env.ledger().timestamp();
444+
let event_data = OracleVolatilityBreachEvent {
445+
previous_price,
446+
new_price,
447+
volatility_bps,
448+
max_volatility_bps,
449+
timestamp,
450+
};
451+
452+
let topics = (
453+
Symbol::new(env, "sorotask"),
454+
Symbol::new(env, "volatility_breach"),
455+
);
456+
env.events().publish(topics, event_data);
457+
}
458+
459+
pub fn log_volatility_circuit_breaker_unpaused(env: &Env, admin: Address) {
460+
let timestamp = env.ledger().timestamp();
461+
let event_data = VolatilityCircuitBreakerUnpausedEvent {
462+
admin,
463+
timestamp,
464+
};
465+
466+
let topics = (
467+
Symbol::new(env, "sorotask"),
468+
Symbol::new(env, "volatility_unpaused"),
469+
);
470+
env.events().publish(topics, event_data);
471+
}
384472
}

0 commit comments

Comments
 (0)