Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions src/base/events.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ pub mod Events {
#[derive(Drop, starknet::Event)]
pub struct BetPlaced {
/// @notice The pool ID.
#[key]
pub pool_id: u256,
/// @notice The address of the user who placed the bet.
#[key]
pub address: ContractAddress,
/// @notice The option selected by the user.
pub option: felt252,
Expand All @@ -32,7 +34,9 @@ pub mod Events {
/// @param amount Amount of tokens staked
#[derive(Drop, starknet::Event)]
pub struct UserStaked {
#[key]
pub pool_id: u256,
#[key]
pub address: ContractAddress,
pub amount: u256,
}
Expand Down Expand Up @@ -68,6 +72,7 @@ pub mod Events {
/// @param timestamp Time of the state transition
#[derive(Drop, starknet::Event)]
pub struct PoolStateTransition {
#[key]
pub pool_id: u256,
pub previous_status: Status,
pub new_status: Status,
Expand All @@ -82,6 +87,7 @@ pub mod Events {
/// @param min_bet_amount Minimum bet requirement
#[derive(Drop, starknet::Event)]
pub struct PoolResolved {
#[key]
pub pool_id: u256,
pub winning_option: bool,
pub total_payout: u256,
Expand Down Expand Up @@ -116,7 +122,9 @@ pub mod Events {
/// @param caller Address of the admin who performed the addition
#[derive(Drop, starknet::Event)]
pub struct ValidatorAdded {
#[key]
pub account: ContractAddress,
#[key]
pub caller: ContractAddress,
}

Expand All @@ -125,7 +133,9 @@ pub mod Events {
/// @param caller Address of the admin who performed the removal
#[derive(Drop, starknet::Event)]
pub struct ValidatorRemoved {
#[key]
pub account: ContractAddress,
#[key]
pub caller: ContractAddress,
}

Expand All @@ -135,7 +145,9 @@ pub mod Events {
/// @param timestamp Time of dispute initiation
#[derive(Drop, starknet::Event)]
pub struct DisputeRaised {
#[key]
pub pool_id: u256,
#[key]
pub user: ContractAddress,
pub timestamp: u64,
}
Expand Down Expand Up @@ -258,4 +270,101 @@ pub mod Events {
pub admin: ContractAddress,
pub timestamp: u64,
}

// Configuration Events

/// @notice Emitted when the required validator confirmations count is updated.
#[derive(Drop, starknet::Event)]
pub struct ValidatorConfirmationsUpdated {
pub previous_count: u256,
pub new_count: u256,
#[key]
pub admin: ContractAddress,
pub timestamp: u64,
}

/// @notice Emitted when the dispute threshold is updated.
#[derive(Drop, starknet::Event)]
pub struct DisputeThresholdUpdated {
pub previous_threshold: u256,
pub new_threshold: u256,
pub admin: ContractAddress,
pub timestamp: u64,
}

// Pool Lifecycle Events

/// @notice Emitted when a new pool is created.
#[derive(Drop, starknet::Event)]
pub struct PoolCreated {
#[key]
pub pool_id: u256,
#[key]
pub creator: ContractAddress,
pub pool_name: felt252,
#[key]
pub category: felt252,
pub end_time: u64,
pub min_bet_amount: u256,
pub max_bet_amount: u256,
pub creator_fee: u8,
pub timestamp: u64,
}

// Contract Management Events

/// @notice Emitted when the contract is paused.
#[derive(Drop, starknet::Event)]
pub struct ContractPaused {
#[key]
pub admin: ContractAddress,
pub timestamp: u64,
}

/// @notice Emitted when the contract is unpaused.
#[derive(Drop, starknet::Event)]
pub struct ContractUnpaused {
#[key]
pub admin: ContractAddress,
pub timestamp: u64,
}


// Fee Collection Events

/// @notice Emitted when protocol fees are collected.
#[derive(Drop, starknet::Event)]
pub struct ProtocolFeesCollected {
pub pool_id: u256,
pub amount: u256,
pub recipient: ContractAddress,
pub timestamp: u64,
}

/// @notice Emitted when creator fees are collected.
#[derive(Drop, starknet::Event)]
pub struct CreatorFeesCollected {
pub pool_id: u256,
pub creator: ContractAddress,
pub amount: u256,
pub timestamp: u64,
}

/// @notice Emitted when validator fees are distributed.
#[derive(Drop, starknet::Event)]
pub struct ValidatorFeesDistributed {
pub pool_id: u256,
pub total_amount: u256,
pub validator_count: u256,
pub timestamp: u64,
}

/// @notice Emitted when pool creation fee is collected.
#[derive(Drop, starknet::Event)]
pub struct PoolCreationFeeCollected {
pub pool_id: u256,
pub creator: ContractAddress,
pub amount: u256,
pub timestamp: u64,
}
}
3 changes: 2 additions & 1 deletion src/interfaces/ipredifi.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ pub trait IPredifi<TContractState> {
/// @notice Collects the pool creation fee from the creator.
/// @dev Transfers 1 STRK from creator to contract.
/// @param creator The creator's address.
fn collect_pool_creation_fee(ref self: TContractState, creator: ContractAddress);
/// @param pool_id The pool ID for which the fee is being collected.
fn collect_pool_creation_fee(ref self: TContractState, creator: ContractAddress, pool_id: u256);

/// @notice Manually updates the state of a pool.
/// @dev Only callable by admin or validator. Enforces valid state transitions.
Expand Down
Loading
Loading