Repository navigation
Description
Overview
investment_vault/src/lib.rs's deposit() (lines 407-470ish) deducts an insurance premium from the investable amount before minting shares, but never removes the premium's USDC from the vault's own token balance — so total_assets() (lines 354-370) counts it twice: once as part of liquid (the contract's raw token balance, which still physically holds the premium), and once again implicitly via the separate InsuranceFund bookkeeping counter used by claim_insurance_internal/insurance_fund_balance().
// deposit():
let premium = usdc_amount * INSURANCE_PREMIUM_BPS / BPS_SCALE; // 50 bps = 0.5%
...
let investable = usdc_amount - premium - fee_amount;
let shares = Self::convert_to_shares(env.clone(), investable); // shares minted on the REDUCED amount
...
token.transfer(&from, env.current_contract_address(), &usdc_amount); // FULL amount moves into the vault
// Credit insurance fund with the premium (#135) — bookkeeping only, no separate transfer out:
let ins: i128 = env.storage().persistent().get(&VaultKey::InsuranceFund).unwrap_or(0);
env.storage().persistent().set(&VaultKey::InsuranceFund, &(ins + premium));// total_assets():
pub fn total_assets(env: Env) -> i128 {
let usdc_sac: Address = ...;
let liquid = soroban_sdk::token::TokenClient::new(&env, &usdc_sac)
.balance(&env.current_contract_address()); // includes the premium USDC — never subtracted
let investments: i128 = ...;
let expected = Self::get_expected_returns(env.clone());
liquid + investments + expected
}Because the full usdc_amount (not investable) is transferred into the contract, and total_assets() never subtracts the accumulated InsuranceFund balance from liquid, every depositor's premium inflates the vault's reported NAV (total_assets / total_supply) without minting corresponding shares for that inflation. The very next depositor (and every prior shareholder) benefits from free NAV appreciation funded by premiums that are supposed to be a segregated insurance reserve, not distributable yield.
Reproduced by the codebase's own tests
Two existing regression tests fail on this once the workspace's several compile errors (filed separately) are fixed and the suite actually runs:
-
test_get_portfolio_after_single_deposit(investment_vault/src/test.rs): a single 1000 USDC deposit (no fee configured, so only the 0.5% insurance premium applies) assertsportfolio.usdc_value == shares. It fails:usdc_value = 10_000_000_000(the full 1000 USDC —total_assetsdidn't subtract the premium) whileshares = 9_950_000_000(995-USDC-equivalent — minted only on the post-premiuminvestableamount). The very first depositor's shares are already worth ~0.503% more than they paid, funded entirely by their own premium never being excluded from NAV. -
test_get_portfolio_share_of_pool_with_two_investors: Alice and Bob each deposit 500 USDC and are asserted to each own exactly 5,000 bps (50%) of the pool. It fails with Alice at5012bps instead of5000— because Alice's deposit inflatedtotal_assets(via her uncorrected premium) before Bob'sconvert_to_sharescall priced his deposit against that inflated NAV, so Bob receives measurably fewer shares per USDC than Alice did for an identical deposit.
Why it matters
- Economic correctness: the insurance-fund reserve is supposed to be a segregated buffer, not distributable value — its premium should not appreciate share price. As implemented, it silently does, meaning
total_assets()/convert_to_shares()/convert_to_assets()all overstate real backing. - Solvency risk:
claim_insurance_internalpresumably pays claims out of the vault's liquid USDC balance (the same balance backing share NAV), since the "insurance fund" was never actually segregated. A real insurance payout would draw down the same liquidity that share price assumes is available 1:1 for redemptions, meaning the vault could become under-collateralized relative to its reported share price exactly when insurance claims are paid — the scenario the segregated fund is meant to protect against in the first place. - Fairness between depositors: later depositors get diluted relative to earlier ones purely as an artifact of deposit ordering, unrelated to any real yield or performance.
Suggested fix
Subtract the tracked InsuranceFund balance from liquid in total_assets():
let insurance_reserve: i128 = env.storage().persistent().get(&VaultKey::InsuranceFund).unwrap_or(0);
let total = (liquid - insurance_reserve) + investments + expected;(and apply the same correction anywhere else liquid/total_assets is used to compute NAV, e.g. get_portfolio, convert_to_shares, convert_to_assets, is_healthy/utilization checks). Alternatively, physically transfer the premium out to a separate, dedicated insurance-fund address at deposit time so liquid never includes it in the first place — this would also make insurance_fund_balance() reflect real, independently verifiable custody rather than a same-pool bookkeeping counter.
Activity
Hardebayor1 commentedon Sep 30, 2026
@Hardebayor1 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Hardebayor1 to this issue.
rhemy-arc commentedon Sep 30, 2026
@rhemy-arc has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @rhemy-arc to this issue.
drips-wave commentedon Sep 30, 2026
Congratulations, @rhemy-arc! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.
🧑💻 @rhemy-arc: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
drips-wave commentedon Sep 30, 2026
This issue has been completed by @rhemy-arc as part of the Stellar Wave Program's 9th Wave 🥳
😎 @rhemy-arc: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.