Validate settle_fund addresses to prevent settling to dex vault
This commit is contained in:
parent
43c66c7f3f
commit
2944582a49
|
@ -373,6 +373,11 @@ class Market:
|
|||
quote_wallet: PublicKey,
|
||||
vault_signer: PublicKey,
|
||||
) -> TransactionInstruction:
|
||||
if base_wallet == self.state.base_vault():
|
||||
raise ValueError("base_wallet should not be a vault address")
|
||||
if quote_wallet == self.state.quote_vault():
|
||||
raise ValueError("quote_wallet should not be a vault address")
|
||||
|
||||
return instructions.settle_funds(
|
||||
instructions.SettleFundsParams(
|
||||
market=self.state.public_key(),
|
||||
|
|
|
@ -88,6 +88,24 @@ def test_settle_fund(
|
|||
):
|
||||
open_order_accounts = bootstrapped_market.find_open_orders_accounts_for_owner(stubbed_payer.public_key())
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
# Should not allow base_wallet to be base_vault
|
||||
bootstrapped_market.settle_funds(
|
||||
stubbed_payer,
|
||||
open_order_accounts[0],
|
||||
bootstrapped_market.state.base_vault(),
|
||||
stubbed_quote_wallet.public_key(),
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
# Should not allow quote_wallet to be wallet_vault
|
||||
bootstrapped_market.settle_funds(
|
||||
stubbed_payer,
|
||||
open_order_accounts[0],
|
||||
stubbed_base_wallet.public_key(),
|
||||
bootstrapped_market.state.quote_vault(),
|
||||
)
|
||||
|
||||
for open_order_account in open_order_accounts:
|
||||
assert "error" not in bootstrapped_market.settle_funds(
|
||||
stubbed_payer,
|
||||
|
|
Loading…
Reference in New Issue