From 08bc6ec11cf9a7c7e72e52912e4282497153f1a3 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Tue, 29 Oct 2024 13:08:11 -0400 Subject: [PATCH] another invariant --- programs/drift_vaults/src/state/vault.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/programs/drift_vaults/src/state/vault.rs b/programs/drift_vaults/src/state/vault.rs index 76b0658f..6a2e8357 100644 --- a/programs/drift_vaults/src/state/vault.rs +++ b/programs/drift_vaults/src/state/vault.rs @@ -311,6 +311,12 @@ impl Vault { } // this will underflow if there is an issue with protocol fee calc + validate!( + self.total_shares >= self.user_shares, + ErrorCode::InvalidVaultSharesDetected, + "total_shares must be >= user_shares" + )?; + self.get_manager_shares(vault_protocol)?; Ok(VaultFee {