Skip to content

Add a cooldown period between consecutive buys by the same wallet to prevent bot-driven accumulation #830

Description

@Chucks1093

Summary

Automated bots can send consecutive buy transactions in rapid succession to accumulate large positions before manual buyers can react. A per-wallet cooldown period between buys enforced in the buy function would slow bot-driven accumulation.

Scope

  • Record the last_buy_ledger per (key_id, wallet) in persistent storage on every buy
  • Add set_buy_cooldown(key_id: BytesN<32>, cooldown_ledgers: u32) callable by the key creator (0–720 ledgers ≈ 1 hour)
  • In the buy function, panic with CooldownActive if fewer than cooldown_ledgers have elapsed since last_buy_ledger
  • Default cooldown to 0 (no restriction) when not configured
  • Emit a cooldown_blocked event with wallet, key_id, and ledgers_remaining when the guard triggers

Acceptance Criteria

  • Second buy within cooldown period panics with CooldownActive
  • Buy after cooldown has elapsed succeeds normally
  • cooldown_ledgers above 720 panics with CooldownTooLong
  • Non-creator set_buy_cooldown panics with Unauthorized
  • cooldown_blocked event emitted with correct ledgers_remaining

ETA: 24 hours


Coordinate on Telegram

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions