Skip to content

[FEATURE] Add per-user and global deposit caps to savings lock contract #11

Description

@derbydaniels9-cpu

Summary

There is no rate limiting or per-user deposit cap enforced in the contracts. A single user could deposit an unlimited amount into the savings lock contract, creating concentration risk where one user holds a disproportionate share of locked funds.

Impact

  • If one user deposits 90% of all locked funds and triggers an early withdrawal, the penalty treasury may not have enough liquidity to pay interest to other users.
  • No regulatory deposit cap compliance (e.g. NDIC-equivalent limits for digital wallets).

Proposed solution

Add per-user and global deposit caps to the savings lock contract:

const MAX_PER_USER: i128 = 10_000_000_0000000; // 10M NGN equivalent in stroops
const MAX_GLOBAL: i128 = 1_000_000_000_0000000; // 1B NGN equivalent

pub fn deposit(env: Env, user: Address, amount: i128, ...) {
    user.require_auth();
    assert_not_paused(&env);

    let user_balance = get_user_balance(&env, &user);
    assert!(user_balance + amount <= MAX_PER_USER, "Per-user deposit cap exceeded");

    let global_tvl = get_total_value_locked(&env);
    assert!(global_tvl + amount <= MAX_GLOBAL, "Global deposit cap exceeded");

    // proceed with deposit
}

Caps should be configurable by the multisig admin with an on-chain governance vote for changes above 2x the current cap.

Files affected:

  • src/savings_lock/lib.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions