SSSwap

First Flight #41
Beginner FriendlyRust
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Missing Pool Initialization Timestamp

Description: The LiquidityPool struct doesn't include a timestamp for when the pool was initialized, which could be useful for analytics, fee adjustments, or other time-based features.

Inside the file liquidity_pool.rs file:

#[account]
#[derive(InitSpace)]
pub struct LiquidityPool {
pub token_a: Pubkey,
pub token_b: Pubkey,
pub lp_mint: Pubkey,
pub bump: u8,
}

Impact: Lack of timestamp information limits the protocol's ability to implement time-based features or provide useful analytics to users and developers.

Proof of Concept: If the protocol wanted to implement time-weighted average price (TWAP) oracles or graduated fee structures based on pool age, it would be unable to do so without this timestamp information.

Recommended Mitigation: Add a timestamp field to the LiquidityPool struct and set it during pool initialization:

#[account]
#[derive(InitSpace)]
pub struct LiquidityPool {
pub token_a: Pubkey,
pub token_b: Pubkey,
pub lp_mint: Pubkey,
pub bump: u8,
pub creation_timestamp: i64,
}
// In initialize_pool function
context.accounts.liquidity_pool.
set_inner(LiquidityPool {
token_a: context.accounts.
token_mint_a.key(),
token_b: context.accounts.
token_mint_b.key(),
lp_mint: context.accounts.lp_mint.
key(),
bump: context.bumps.liquidity_pool,
creation_timestamp: Clock::get()?.
unix_timestamp,
});
Updates

Lead Judging Commences

0xtimefliez Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.