Skip to content

feat: Implement share transfer lock-up period after deposit#147

Open
Nanle-code wants to merge 2 commits into
StellarYield:mainfrom
Nanle-code:fix
Open

feat: Implement share transfer lock-up period after deposit#147
Nanle-code wants to merge 2 commits into
StellarYield:mainfrom
Nanle-code:fix

Conversation

@Nanle-code
Copy link
Copy Markdown

Summary

Implements configurable lock-up periods for share transfers after deposits to prevent immediate speculation and ensure regulatory compliance for RWA securities.

Problem Solved

Previously, users could deposit, receive shares, and transfer them in the same ledger, enabling:

  • Regulatory non-compliance (violating required holding periods)
  • Deposit-and-flip arbitrage
  • Gaming of the epoch snapshot system for yield distribution

Solution

Added a configurable lock-up period that restricts share transfers, withdrawals, and redemptions for a specified duration after each deposit.

Key Features

  • Configurable lock-up period (seconds) set during vault construction
  • Per-user deposit timestamp tracking - new deposits reset the lock-up timer
  • Admin control - admins can update lock-up period for future deposits
  • Maturity bypass - redeem_at_maturity() works regardless of lock-up status
  • View function - lock_up_remaining() shows remaining lock-up time
  • Zero-period bypass - lock_up_period = 0 disables restrictions

Functions Modified

  • transfer(), transfer_from() - Block during lock-up
  • withdraw(), redeem() - Block during lock-up
  • request_early_redemption() - Block during lock-up
  • deposit(), mint() - Store deposit timestamps
  • redeem_at_maturity() - Unchanged (correctly bypasses lock-up)

New Functions

  • lock_up_remaining(user: Address) -> u64 - View remaining lock-up time
  • set_lock_up_period(admin: Address, period: u64) - Admin configuration

Error Handling

  • Added Error::SharesLocked - Returned when transfer attempts occur during lock-up

Files Changed

  • types.rs - Added lock_up_period to InitParams
  • storage.rs - Added LockUpPeriod and DepositTimestamp storage keys
  • errors.rs - Added SharesLocked error variant
  • lib.rs - Implemented lock-up logic and new functions
  • test_lock_up_period.rs - Comprehensive test suite

Tests

  • ✅ Lock-up enforcement on all restricted functions
  • ✅ Lock-up expiration allows transfers
  • ✅ redeem_at_maturity() bypasses lock-up
  • ✅ Admin can update lock-up period
  • ✅ Zero period disables restrictions
  • ✅ Per-user timestamp tracking

Backward Compatibility

  • Existing deployments work with default lock_up_period = 0
  • No breaking changes to existing function signatures
  • New admin function is optional

Security Benefits

  • ✅ Regulatory compliance for securities holding periods
  • ✅ Prevents speculative trading patterns
  • ✅ Protects yield distribution fairness

Definition of Done ✅

  • Shares cannot be transferred or redeemed during lock-up
  • Lock-up is configurable at construction and updatable by admin
  • redeem_at_maturity bypasses lock-up
  • View function shows remaining lock-up time
  • Tests cover lock-up enforcement and bypass scenarios

Closes #103

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Share Transfer Lock-Up Period After Deposit

1 participant