Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program: add vault invariant to update_spot_market_cumulative_interes… #524

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixes

- program: add vault invariant to update_spot_market_cumulative_interest ix (([#524](https://github.com/drift-labs/protocol-v2/pull/524)))
- program: check oracles valid in meets_withdraw_margin_requirement if number_of_liabilities > 0
- program: only get quote spot market if user has quote position in validate_spot_margin_trading
- program: fix decrement_open_orders for makers
Expand Down
10 changes: 10 additions & 0 deletions programs/drift/src/instructions/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,11 @@ pub fn handle_update_spot_market_cumulative_interest(
)?;
}

math::spot_withdraw::validate_spot_market_vault_amount(
spot_market,
ctx.accounts.spot_market_vault.amount,
)?;

Ok(())
}

Expand Down Expand Up @@ -1640,6 +1645,11 @@ pub struct UpdateSpotMarketCumulativeInterest<'info> {
pub spot_market: AccountLoader<'info, SpotMarket>,
/// CHECK: checked in `update_spot_market_cumulative_interest` ix constraint
pub oracle: AccountInfo<'info>,
#[account(
seeds = [b"spot_market_vault".as_ref(), spot_market.load()?.market_index.to_le_bytes().as_ref()],
bump,
)]
pub spot_market_vault: Box<Account<'info, TokenAccount>>,
}

#[derive(Accounts)]
Expand Down
1 change: 1 addition & 0 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,7 @@ export class DriftClient {
accounts: {
state: await this.getStatePublicKey(),
spotMarket: spotMarket.pubkey,
spotMarketVault: spotMarket.vault,
oracle: spotMarket.oracle,
},
});
Expand Down
Loading