Skip to content

fix: REFUND_FEE_BPS is hardcoded — make admin-configurable via instance storage #379

Description

@Pvsaint

Problem

The refund processing fee is hardcoded as a compile-time constant:

const REFUND_FEE_BPS: i128 = 100; // 1% — lib.rs line 16

This cannot be changed post-deployment without a full contract upgrade. As business requirements evolve (promotions, regulatory changes, tiered merchants), the inability to adjust fees is a significant operational limitation.

Proposed Solution

Store refund_fee_bps in instance storage, initialized during initialize_refund_manager and updatable by admin.

DataKey::RefundFeeBps  // instance storage key

Add:

  • set_refund_fee_bps(env, admin, bps: i128) — admin-only setter
  • get_refund_fee_bps(env)i128 — public getter

Acceptance Criteria

  • REFUND_FEE_BPS constant is replaced by a storage-backed value
  • Default value of 100 bps (1%) is set during contract initialization
  • set_refund_fee_bps requires admin auth and validates 0 <= bps <= 1000 (max 10%)
  • get_refund_fee_bps is publicly readable
  • process_refund reads from storage rather than the constant
  • CHANGELOG.md notes this as a storage key change (bumps version if storage layout changes)
  • Tests cover: default fee, fee update by admin, fee update rejected by non-admin, fee applied correctly

Branch & Commit Examples

branch: feat/configurable-refund-fee
commit: feat(refund-manager): make refund fee bps admin-configurable via instance storage

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions