Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions neurowealth-vault/contracts/vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ pub enum VaultError {
/// variants this call site used interchangeably before) describes this
/// case; both are unrelated error conditions reused by mistake.
StandbyMatchesPrimaryAgent = 92,
/// The bootstrap 1:1 asset-to-share conversion was about to mint shares
/// while existing shares are outstanding but the vault reports zero
/// assets (#973). Minting here would value those existing holders'
/// shares at zero, so the deposit is rejected instead.
DepositRejectedZeroAssetsWithShares = 93,
}

impl VaultError {
Expand Down Expand Up @@ -2788,7 +2793,9 @@ impl NeuroWealthVault {
);
// Set default MinHoldingPeriod to prevent yield sniping (#975)
// 120 ledgers (~10 minutes) prevents same-block deposit/withdraw cycles
env.storage().instance().set(&DataKey::MinHoldingPeriod, &120_u32);
env.storage()
.instance()
.set(&DataKey::MinHoldingPeriod, &120_u32);
Self::initialize_rate_limit_defaults(&env);
env.storage().instance().set(&DataKey::Version, &1_u32);

Expand Down Expand Up @@ -8133,7 +8140,7 @@ impl NeuroWealthVault {
/// on full withdrawal). For n >> 500, consider a secondary hash-based
/// removal index in a future optimization.
fn prune_user_from_index(env: &Env, user: &Address) {
let mut index: Vec<Address> = env
let index: Vec<Address> = env
.storage()
.instance()
.get(&DataKey::UserSharesIndex)
Expand Down Expand Up @@ -10072,7 +10079,7 @@ impl NeuroWealthVault {
/// Removes an asset symbol from the supported-assets index (#646).
#[inline]
fn remove_from_supported_assets_index(env: &Env, asset: &Symbol) {
let mut index = Self::read_supported_assets(env);
let index = Self::read_supported_assets(env);
let mut kept = Vec::new(env);
for a in index.iter() {
if &a != asset {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use soroban_sdk::{testutils::Address as _, Address, Env};

/// Deposits are rejected when total_shares > 0 but total_assets == 0.
#[test]
#[should_panic(expected = "Error(Contract, #86)")]
#[should_panic(expected = "Error(Contract, #93)")]
fn test_deposit_rejected_when_shares_exist_but_assets_zero() {
let env = Env::default();
env.mock_all_auths();
Expand Down Expand Up @@ -89,7 +89,7 @@ fn test_deposit_succeeds_when_both_shares_and_assets_positive() {

/// batch_deposit is also rejected when total_shares > 0 but total_assets == 0.
#[test]
#[should_panic(expected = "Error(Contract, #86)")]
#[should_panic(expected = "Error(Contract, #93)")]
fn test_batch_deposit_rejected_when_shares_exist_but_assets_zero() {
let env = Env::default();
env.mock_all_auths();
Expand All @@ -114,6 +114,6 @@ fn test_batch_deposit_rejected_when_shares_exist_but_assets_zero() {
token.mint(&user2, &deposit2);

let mut entries = soroban_sdk::Vec::new(&env);
entries.push((usdc_token, deposit2));
entries.push_back((usdc_token, deposit2));
client.batch_deposit(&user2, &entries);
}
3 changes: 2 additions & 1 deletion neurowealth-vault/share-math/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ pub fn run_fuzz_input(data: &[u8]) {
let max_pending = data.first().map_or(4, |b| usize::from(b % 8) + 1);
let mut vault = QueueModel::new(max_pending);

for chunk in data.chunks_exact(4) {
let (chunks, _remainder) = data.as_chunks::<4>();
for chunk in chunks {
let (op, arg, amt) = (chunk[0] % 7, chunk[1], amount([chunk[2], chunk[3]]));
let user = usize::from(arg) % USERS;
let before = vault;
Expand Down
Loading