Skip to content

Commit

Permalink
program: add vault invariant to update_spot_market_cumulative_interes…
Browse files Browse the repository at this point in the history
…t ix (#524)
  • Loading branch information
crispheaney committed Jul 7, 2023
1 parent bbfc037 commit 670fc12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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

0 comments on commit 670fc12

Please sign in to comment.