Replace Deprecated Account type with Keypair (#92)

* Replace Deprecated Account type with Keypair

* revert python version change

* removed comments, unnecessary spaces

* require solana-py >= 0.15.0

* fixed mypy errors

* fixed account loader

* Fix lint error

* fixing market tests

* fixing async_test_ market for Keypair

Co-authored-by: Ian MacLean <Imaclean74@github.com>
This commit is contained in:
Imaclean74 2021-11-04 10:57:08 +09:00 committed by GitHub
parent 4ab65b0de7
commit 7d10ecc9eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 600 additions and 659 deletions

View File

@ -28,7 +28,7 @@ pytest-asyncio = "*"
types-requests = "*"
[packages]
solana = {version = ">=0.11.3"}
solana = {version = ">=0.15.0"}
construct = "*"
flake8 = "*"
construct-typing = "*"

1028
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import List
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.async_api import AsyncClient
from solana.rpc.types import RPCResponse, TxOpts
@ -91,7 +91,7 @@ class AsyncMarket(MarketCore):
async def place_order( # pylint: disable=too-many-arguments,too-many-locals
self,
payer: PublicKey,
owner: Account,
owner: Keypair,
order_type: OrderType,
side: Side,
limit_price: float,
@ -100,8 +100,8 @@ class AsyncMarket(MarketCore):
opts: TxOpts = TxOpts(),
) -> RPCResponse: # TODO: Add open_orders_address_key param and fee_discount_pubkey
transaction = Transaction()
signers: List[Account] = [owner]
open_order_accounts = await self.find_open_orders_accounts_for_owner(owner.public_key())
signers: List[Keypair] = [owner]
open_order_accounts = await self.find_open_orders_accounts_for_owner(owner.public_key)
if open_order_accounts:
place_order_open_order_account = open_order_accounts[0].address
else:
@ -128,24 +128,24 @@ class AsyncMarket(MarketCore):
return await self._conn.send_transaction(transaction, *signers, opts=opts)
async def cancel_order_by_client_id(
self, owner: Account, open_orders_account: PublicKey, client_id: int, opts: TxOpts = TxOpts()
self, owner: Keypair, open_orders_account: PublicKey, client_id: int, opts: TxOpts = TxOpts()
) -> RPCResponse:
txs = self._build_cancel_order_by_client_id_tx(
owner=owner, open_orders_account=open_orders_account, client_id=client_id
)
return await self._conn.send_transaction(txs, owner, opts=opts)
async def cancel_order(self, owner: Account, order: t.Order, opts: TxOpts = TxOpts()) -> RPCResponse:
async def cancel_order(self, owner: Keypair, order: t.Order, opts: TxOpts = TxOpts()) -> RPCResponse:
txn = self._build_cancel_order_tx(owner=owner, order=order)
return await self._conn.send_transaction(txn, owner, opts=opts)
async def match_orders(self, fee_payer: Account, limit: int, opts: TxOpts = TxOpts()) -> RPCResponse:
async def match_orders(self, fee_payer: Keypair, limit: int, opts: TxOpts = TxOpts()) -> RPCResponse:
txn = self._build_match_orders_tx(limit)
return await self._conn.send_transaction(txn, fee_payer, opts=opts)
async def settle_funds( # pylint: disable=too-many-arguments
self,
owner: Account,
owner: Keypair,
open_orders: AsyncOpenOrdersAccount,
base_wallet: PublicKey,
quote_wallet: PublicKey, # TODO: add referrer_quote_wallet.

View File

@ -5,7 +5,7 @@ import itertools
import logging
from typing import List, Union
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.types import RPCResponse
from solana.system_program import CreateAccountParams, create_account
@ -115,14 +115,15 @@ class MarketCore:
)
def _prepare_new_oo_account(
self, owner: Account, balance_needed: int, signers: List[Account], transaction: Transaction
self, owner: Keypair, balance_needed: int, signers: List[Keypair], transaction: Transaction
) -> PublicKey:
new_open_orders_account = Account()
place_order_open_order_account = new_open_orders_account.public_key()
# new_open_orders_account = Account()
new_open_orders_account = Keypair()
place_order_open_order_account = new_open_orders_account.public_key
transaction.add(
make_create_account_instruction(
owner_address=owner.public_key(),
new_account_address=new_open_orders_account.public_key(),
owner_address=owner.public_key,
new_account_address=new_open_orders_account.public_key,
lamports=balance_needed,
program_id=self.state.program_id(),
)
@ -134,10 +135,10 @@ class MarketCore:
self,
transaction: Transaction,
payer: PublicKey,
owner: Account,
owner: Keypair,
order_type: OrderType,
side: Side,
signers: List[Account],
signers: List[Keypair],
limit_price: float,
max_quantity: float,
client_id: int,
@ -145,7 +146,7 @@ class MarketCore:
place_order_open_order_account: PublicKey,
) -> None:
# unwrapped SOL cannot be used for payment
if payer == owner.public_key():
if payer == owner.public_key:
raise ValueError("Invalid payer account. Cannot use unwrapped SOL.")
# TODO: add integration test for SOL wrapping.
@ -154,14 +155,15 @@ class MarketCore:
)
if should_wrap_sol:
wrapped_sol_account = Account()
payer = wrapped_sol_account.public_key()
# wrapped_sol_account = Account()
wrapped_sol_account = Keypair()
payer = wrapped_sol_account.public_key
signers.append(wrapped_sol_account)
transaction.add(
create_account(
CreateAccountParams(
from_pubkey=owner.public_key(),
new_account_pubkey=wrapped_sol_account.public_key(),
from_pubkey=owner.public_key,
new_account_pubkey=wrapped_sol_account.public_key,
lamports=self._get_lamport_need_for_sol_wrapping(
limit_price, max_quantity, side, open_order_accounts
),
@ -173,9 +175,9 @@ class MarketCore:
transaction.add(
initialize_account(
InitializeAccountParams(
account=wrapped_sol_account.public_key(),
account=wrapped_sol_account.public_key,
mint=WRAPPED_SOL_MINT,
owner=owner.public_key(),
owner=owner.public_key,
program_id=TOKEN_PROGRAM_ID,
)
)
@ -198,16 +200,16 @@ class MarketCore:
transaction.add(
close_account(
CloseAccountParams(
account=wrapped_sol_account.public_key(),
owner=owner.public_key(),
dest=owner.public_key(),
account=wrapped_sol_account.public_key,
owner=owner.public_key,
dest=owner.public_key,
program_id=TOKEN_PROGRAM_ID,
)
)
)
def _after_oo_mbfre_resp(
self, mbfre_resp: RPCResponse, owner: Account, signers: List[Account], transaction: Transaction
self, mbfre_resp: RPCResponse, owner: Keypair, signers: List[Keypair], transaction: Transaction
) -> PublicKey:
balance_needed = mbfre_resp["result"]
place_order_open_order_account = self._prepare_new_oo_account(owner, balance_needed, signers, transaction)
@ -235,7 +237,7 @@ class MarketCore:
def make_place_order_instruction( # pylint: disable=too-many-arguments
self,
payer: PublicKey,
owner: Account,
owner: Keypair,
order_type: OrderType,
side: Side,
limit_price: float,
@ -254,7 +256,7 @@ class MarketCore:
market=self.state.public_key(),
open_orders=open_order_account,
payer=payer,
owner=owner.public_key(),
owner=owner.public_key,
request_queue=self.state.request_queue(),
base_vault=self.state.base_vault(),
quote_vault=self.state.quote_vault(),
@ -271,7 +273,7 @@ class MarketCore:
market=self.state.public_key(),
open_orders=open_order_account,
payer=payer,
owner=owner.public_key(),
owner=owner.public_key,
request_queue=self.state.request_queue(),
event_queue=self.state.event_queue(),
bids=self.state.bids(),
@ -294,18 +296,18 @@ class MarketCore:
)
def _build_cancel_order_by_client_id_tx(
self, owner: Account, open_orders_account: PublicKey, client_id: int
self, owner: Keypair, open_orders_account: PublicKey, client_id: int
) -> Transaction:
return Transaction().add(self.make_cancel_order_by_client_id_instruction(owner, open_orders_account, client_id))
def make_cancel_order_by_client_id_instruction(
self, owner: Account, open_orders_account: PublicKey, client_id: int
self, owner: Keypair, open_orders_account: PublicKey, client_id: int
) -> TransactionInstruction:
if self._use_request_queue():
return instructions.cancel_order_by_client_id(
instructions.CancelOrderByClientIDParams(
market=self.state.public_key(),
owner=owner.public_key(),
owner=owner.public_key,
open_orders=open_orders_account,
request_queue=self.state.request_queue(),
client_id=client_id,
@ -315,7 +317,7 @@ class MarketCore:
return instructions.cancel_order_by_client_id_v2(
instructions.CancelOrderByClientIDV2Params(
market=self.state.public_key(),
owner=owner.public_key(),
owner=owner.public_key,
open_orders=open_orders_account,
bids=self.state.bids(),
asks=self.state.asks(),
@ -325,8 +327,8 @@ class MarketCore:
)
)
def _build_cancel_order_tx(self, owner: Account, order: t.Order) -> Transaction:
return Transaction().add(self.make_cancel_order_instruction(owner.public_key(), order))
def _build_cancel_order_tx(self, owner: Keypair, order: t.Order) -> Transaction:
return Transaction().add(self.make_cancel_order_instruction(owner.public_key, order))
def make_cancel_order_instruction(self, owner: PublicKey, order: t.Order) -> TransactionInstruction:
if self._use_request_queue():
@ -376,8 +378,8 @@ class MarketCore:
def _build_settle_funds_tx( # pylint: disable=too-many-arguments
self,
owner: Account,
signers: List[Account],
owner: Keypair,
signers: List[Keypair],
open_orders: Union[OpenOrdersAccount, AsyncOpenOrdersAccount],
base_wallet: PublicKey,
quote_wallet: PublicKey, # TODO: add referrer_quote_wallet.
@ -385,7 +387,7 @@ class MarketCore:
should_wrap_sol: bool,
) -> Transaction:
# TODO: Handle wrapped sol accounts
if open_orders.owner != owner.public_key():
if open_orders.owner != owner.public_key:
raise Exception("Invalid open orders account")
vault_signer = PublicKey.create_program_address(
[bytes(self.state.public_key()), self.state.vault_signer_nonce().to_bytes(8, byteorder="little")],
@ -394,15 +396,15 @@ class MarketCore:
transaction = Transaction()
if should_wrap_sol:
wrapped_sol_account = Account()
wrapped_sol_account = Keypair()
signers.append(wrapped_sol_account)
# make a wrapped SOL account with enough balance to
# fund the trade, run the program, then send itself back home
transaction.add(
create_account(
CreateAccountParams(
from_pubkey=owner.public_key(),
new_account_pubkey=wrapped_sol_account.public_key(),
from_pubkey=owner.public_key,
new_account_pubkey=wrapped_sol_account.public_key,
lamports=min_bal_for_rent_exemption,
space=ACCOUNT_LEN,
program_id=TOKEN_PROGRAM_ID,
@ -413,9 +415,9 @@ class MarketCore:
transaction.add(
initialize_account(
InitializeAccountParams(
account=wrapped_sol_account.public_key(),
account=wrapped_sol_account.public_key,
mint=WRAPPED_SOL_MINT,
owner=owner.public_key(),
owner=owner.public_key,
program_id=TOKEN_PROGRAM_ID,
)
)
@ -424,8 +426,8 @@ class MarketCore:
transaction.add(
self.make_settle_funds_instruction(
open_orders,
base_wallet if self.state.base_mint() != WRAPPED_SOL_MINT else wrapped_sol_account.public_key(),
quote_wallet if self.state.quote_mint() != WRAPPED_SOL_MINT else wrapped_sol_account.public_key(),
base_wallet if self.state.base_mint() != WRAPPED_SOL_MINT else wrapped_sol_account.public_key,
quote_wallet if self.state.quote_mint() != WRAPPED_SOL_MINT else wrapped_sol_account.public_key,
vault_signer,
)
)
@ -435,9 +437,9 @@ class MarketCore:
transaction.add(
close_account(
CloseAccountParams(
account=wrapped_sol_account.public_key(),
owner=owner.public_key(),
dest=owner.public_key(),
account=wrapped_sol_account.public_key,
owner=owner.public_key,
dest=owner.public_key,
program_id=TOKEN_PROGRAM_ID,
)
)

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import List
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.api import Client
from solana.rpc.types import RPCResponse, TxOpts
@ -91,7 +91,7 @@ class Market(MarketCore):
def place_order( # pylint: disable=too-many-arguments,too-many-locals
self,
payer: PublicKey,
owner: Account,
owner: Keypair,
order_type: OrderType,
side: Side,
limit_price: float,
@ -100,8 +100,8 @@ class Market(MarketCore):
opts: TxOpts = TxOpts(),
) -> RPCResponse: # TODO: Add open_orders_address_key param and fee_discount_pubkey
transaction = Transaction()
signers: List[Account] = [owner]
open_order_accounts = self.find_open_orders_accounts_for_owner(owner.public_key())
signers: List[Keypair] = [owner]
open_order_accounts = self.find_open_orders_accounts_for_owner(owner.public_key)
if open_order_accounts:
place_order_open_order_account = open_order_accounts[0].address
else:
@ -128,24 +128,24 @@ class Market(MarketCore):
return self._conn.send_transaction(transaction, *signers, opts=opts)
def cancel_order_by_client_id(
self, owner: Account, open_orders_account: PublicKey, client_id: int, opts: TxOpts = TxOpts()
self, owner: Keypair, open_orders_account: PublicKey, client_id: int, opts: TxOpts = TxOpts()
) -> RPCResponse:
txs = self._build_cancel_order_by_client_id_tx(
owner=owner, open_orders_account=open_orders_account, client_id=client_id
)
return self._conn.send_transaction(txs, owner, opts=opts)
def cancel_order(self, owner: Account, order: t.Order, opts: TxOpts = TxOpts()) -> RPCResponse:
def cancel_order(self, owner: Keypair, order: t.Order, opts: TxOpts = TxOpts()) -> RPCResponse:
txn = self._build_cancel_order_tx(owner=owner, order=order)
return self._conn.send_transaction(txn, owner, opts=opts)
def match_orders(self, fee_payer: Account, limit: int, opts: TxOpts = TxOpts()) -> RPCResponse:
def match_orders(self, fee_payer: Keypair, limit: int, opts: TxOpts = TxOpts()) -> RPCResponse:
txn = self._build_match_orders_tx(limit)
return self._conn.send_transaction(txn, fee_payer, opts=opts)
def settle_funds( # pylint: disable=too-many-arguments
self,
owner: Account,
owner: Keypair,
open_orders: OpenOrdersAccount,
base_wallet: PublicKey,
quote_wallet: PublicKey, # TODO: add referrer_quote_wallet.
@ -166,4 +166,4 @@ class Market(MarketCore):
min_bal_for_rent_exemption=min_bal_for_rent_exemption,
should_wrap_sol=should_wrap_sol,
)
return self._conn.send_transaction(transaction, *signers, opts=opts)
return self._conn.send_transaction(transaction, owner, opts=opts)

View File

@ -2,7 +2,7 @@ from typing import Dict
import asyncio
import pytest
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.api import Client
from solana.rpc.async_api import AsyncClient
@ -26,11 +26,12 @@ def __bs_params() -> Dict[str, str]:
return params
def __bootstrap_account(pubkey: str, secretkey: str) -> Account:
def __bootstrap_account(pubkey: str, secretkey: str) -> Keypair:
secret = [int(b) for b in secretkey[1:-1].split(" ")]
account = Account(secret)
assert str(account.public_key()) == pubkey, "account must map to provided public key"
return account
secret_bytes = bytes(secret)
keypair = Keypair.from_secret_key(secret_bytes)
assert str(keypair.public_key) == pubkey, "account must map to provided public key"
return keypair
@pytest.mark.integration
@ -42,35 +43,35 @@ def stubbed_dex_program_pk(__bs_params) -> PublicKey:
@pytest.mark.integration
@pytest.fixture(scope="session")
def stubbed_payer(__bs_params) -> Account:
def stubbed_payer(__bs_params) -> Keypair:
"""Bootstrapped payer account."""
return __bootstrap_account(__bs_params["payer"], __bs_params["payer_secret"])
@pytest.mark.integration
@pytest.fixture(scope="session")
def stubbed_base_mint(__bs_params) -> Account:
def stubbed_base_mint(__bs_params) -> Keypair:
"""Bootstrapped base mint account."""
return __bootstrap_account(__bs_params["coin_mint"], __bs_params["coin_mint_secret"])
@pytest.mark.integration
@pytest.fixture(scope="session")
def stubbed_quote_mint(__bs_params) -> Account:
def stubbed_quote_mint(__bs_params) -> Keypair:
"""Bootstrapped quote mint account."""
return __bootstrap_account(__bs_params["pc_mint"], __bs_params["pc_mint_secret"])
@pytest.mark.integration
@pytest.fixture(scope="session")
def stubbed_base_wallet(__bs_params) -> Account:
def stubbed_base_wallet(__bs_params) -> Keypair:
"""Bootstrapped base mint account."""
return __bootstrap_account(__bs_params["coin_wallet"], __bs_params["coin_wallet_secret"])
@pytest.mark.integration
@pytest.fixture(scope="session")
def stubbed_quote_wallet(__bs_params) -> Account:
def stubbed_quote_wallet(__bs_params) -> Keypair:
"""Bootstrapped quote mint account."""
return __bootstrap_account(__bs_params["pc_wallet"], __bs_params["pc_wallet_secret"])

View File

@ -1,7 +1,7 @@
# pylint: disable=redefined-outer-name
import pytest
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.async_api import AsyncClient
from solana.rpc.types import TxOpts
@ -26,14 +26,14 @@ async def test_bootstrapped_market(
bootstrapped_market: AsyncMarket,
stubbed_market_pk: PublicKey,
stubbed_dex_program_pk: PublicKey,
stubbed_base_mint: PublicKey,
stubbed_quote_mint: PublicKey,
stubbed_base_mint: Keypair,
stubbed_quote_mint: Keypair,
):
assert isinstance(bootstrapped_market, AsyncMarket)
assert bootstrapped_market.state.public_key() == stubbed_market_pk
assert bootstrapped_market.state.program_id() == stubbed_dex_program_pk
assert bootstrapped_market.state.base_mint() == stubbed_base_mint.public_key()
assert bootstrapped_market.state.quote_mint() == stubbed_quote_mint.public_key()
assert bootstrapped_market.state.base_mint() == stubbed_base_mint.public_key
assert bootstrapped_market.state.quote_mint() == stubbed_quote_mint.public_key
@pytest.mark.async_integration
@ -69,7 +69,7 @@ async def test_market_load_requests(bootstrapped_market: AsyncMarket):
@pytest.mark.async_integration
@pytest.mark.asyncio
async def test_match_order(bootstrapped_market: AsyncMarket, stubbed_payer: Account):
async def test_match_order(bootstrapped_market: AsyncMarket, stubbed_payer: Keypair):
await bootstrapped_market.match_orders(stubbed_payer, 2, TxOpts(skip_confirmation=False))
request_queue = await bootstrapped_market.load_request_queue()
@ -93,11 +93,11 @@ async def test_match_order(bootstrapped_market: AsyncMarket, stubbed_payer: Acco
@pytest.mark.asyncio
async def test_settle_fund(
bootstrapped_market: AsyncMarket,
stubbed_payer: Account,
stubbed_quote_wallet: Account,
stubbed_base_wallet: Account,
stubbed_payer: Keypair,
stubbed_quote_wallet: Keypair,
stubbed_base_wallet: Keypair,
):
open_order_accounts = await bootstrapped_market.find_open_orders_accounts_for_owner(stubbed_payer.public_key())
open_order_accounts = await 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
@ -105,7 +105,7 @@ async def test_settle_fund(
stubbed_payer,
open_order_accounts[0],
bootstrapped_market.state.base_vault(),
stubbed_quote_wallet.public_key(),
stubbed_quote_wallet.public_key,
)
with pytest.raises(ValueError):
@ -113,7 +113,7 @@ async def test_settle_fund(
await bootstrapped_market.settle_funds(
stubbed_payer,
open_order_accounts[0],
stubbed_base_wallet.public_key(),
stubbed_base_wallet.public_key,
bootstrapped_market.state.quote_vault(),
)
@ -121,8 +121,8 @@ async def test_settle_fund(
assert "error" not in await bootstrapped_market.settle_funds(
stubbed_payer,
open_order_account,
stubbed_base_wallet.public_key(),
stubbed_quote_wallet.public_key(),
stubbed_base_wallet.public_key,
stubbed_quote_wallet.public_key,
opts=TxOpts(skip_confirmation=False),
)
@ -133,13 +133,13 @@ async def test_settle_fund(
@pytest.mark.asyncio
async def test_order_placement_cancellation_cycle(
bootstrapped_market: AsyncMarket,
stubbed_payer: Account,
stubbed_quote_wallet: Account,
stubbed_base_wallet: Account,
stubbed_payer: Keypair,
stubbed_quote_wallet: Keypair,
stubbed_base_wallet: Keypair,
):
initial_request_len = len(await bootstrapped_market.load_request_queue())
await bootstrapped_market.place_order(
payer=stubbed_quote_wallet.public_key(),
payer=stubbed_quote_wallet.public_key,
owner=stubbed_payer,
side=Side.BUY,
order_type=OrderType.LIMIT,
@ -161,7 +161,7 @@ async def test_order_placement_cancellation_cycle(
assert sum(1 for _ in asks) == 0
await bootstrapped_market.place_order(
payer=stubbed_base_wallet.public_key(),
payer=stubbed_base_wallet.public_key,
owner=stubbed_payer,
side=Side.SELL,
order_type=OrderType.LIMIT,

View File

@ -1,21 +1,23 @@
import pytest
from solana.account import Account
# from solana.account import Keypair
from solana.keypair import Keypair
from solana.publickey import PublicKey
@pytest.mark.integration
def test_payer(stubbed_payer):
assert isinstance(stubbed_payer, Account)
assert isinstance(stubbed_payer, Keypair)
@pytest.mark.integration
def test_base_mint(stubbed_base_mint):
assert isinstance(stubbed_base_mint, Account)
assert isinstance(stubbed_base_mint, Keypair)
@pytest.mark.integration
def test_base_wallet(stubbed_base_wallet):
assert isinstance(stubbed_base_wallet, Account)
assert isinstance(stubbed_base_wallet, Keypair)
@pytest.mark.integration
@ -25,12 +27,12 @@ def test_base_vault_pk(stubbed_base_vault_pk):
@pytest.mark.integration
def test_quote_mint(stubbed_quote_mint):
assert isinstance(stubbed_quote_mint, Account)
assert isinstance(stubbed_quote_mint, Keypair)
@pytest.mark.integration
def test_quote_wallet(stubbed_quote_wallet):
assert isinstance(stubbed_quote_wallet, Account)
assert isinstance(stubbed_quote_wallet, Keypair)
@pytest.mark.integration

View File

@ -1,7 +1,7 @@
# pylint: disable=redefined-outer-name
import pytest
from solana.account import Account
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.api import Client
from solana.rpc.types import TxOpts
@ -21,14 +21,14 @@ def test_bootstrapped_market(
bootstrapped_market: Market,
stubbed_market_pk: PublicKey,
stubbed_dex_program_pk: PublicKey,
stubbed_base_mint: PublicKey,
stubbed_quote_mint: PublicKey,
stubbed_base_mint: Keypair,
stubbed_quote_mint: Keypair,
):
assert isinstance(bootstrapped_market, Market)
assert bootstrapped_market.state.public_key() == stubbed_market_pk
assert bootstrapped_market.state.program_id() == stubbed_dex_program_pk
assert bootstrapped_market.state.base_mint() == stubbed_base_mint.public_key()
assert bootstrapped_market.state.quote_mint() == stubbed_quote_mint.public_key()
assert bootstrapped_market.state.base_mint() == stubbed_base_mint.public_key
assert bootstrapped_market.state.quote_mint() == stubbed_quote_mint.public_key
@pytest.mark.integration
@ -59,7 +59,7 @@ def test_market_load_requests(bootstrapped_market: Market):
@pytest.mark.integration
def test_match_order(bootstrapped_market: Market, stubbed_payer: Account):
def test_match_order(bootstrapped_market: Market, stubbed_payer: Keypair):
bootstrapped_market.match_orders(stubbed_payer, 2, TxOpts(skip_confirmation=False))
request_queue = bootstrapped_market.load_request_queue()
@ -82,11 +82,11 @@ def test_match_order(bootstrapped_market: Market, stubbed_payer: Account):
@pytest.mark.integration
def test_settle_fund(
bootstrapped_market: Market,
stubbed_payer: Account,
stubbed_quote_wallet: Account,
stubbed_base_wallet: Account,
stubbed_payer: Keypair,
stubbed_quote_wallet: Keypair,
stubbed_base_wallet: Keypair,
):
open_order_accounts = bootstrapped_market.find_open_orders_accounts_for_owner(stubbed_payer.public_key())
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
@ -94,7 +94,7 @@ def test_settle_fund(
stubbed_payer,
open_order_accounts[0],
bootstrapped_market.state.base_vault(),
stubbed_quote_wallet.public_key(),
stubbed_quote_wallet.public_key,
)
with pytest.raises(ValueError):
@ -102,7 +102,7 @@ def test_settle_fund(
bootstrapped_market.settle_funds(
stubbed_payer,
open_order_accounts[0],
stubbed_base_wallet.public_key(),
stubbed_base_wallet.public_key,
bootstrapped_market.state.quote_vault(),
)
@ -110,8 +110,8 @@ def test_settle_fund(
assert "error" not in bootstrapped_market.settle_funds(
stubbed_payer,
open_order_account,
stubbed_base_wallet.public_key(),
stubbed_quote_wallet.public_key(),
stubbed_base_wallet.public_key,
stubbed_quote_wallet.public_key,
opts=TxOpts(skip_confirmation=False),
)
@ -121,13 +121,13 @@ def test_settle_fund(
@pytest.mark.integration
def test_order_placement_cancellation_cycle(
bootstrapped_market: Market,
stubbed_payer: Account,
stubbed_quote_wallet: Account,
stubbed_base_wallet: Account,
stubbed_payer: Keypair,
stubbed_quote_wallet: Keypair,
stubbed_base_wallet: Keypair,
):
initial_request_len = len(bootstrapped_market.load_request_queue())
bootstrapped_market.place_order(
payer=stubbed_quote_wallet.public_key(),
payer=stubbed_quote_wallet.public_key,
owner=stubbed_payer,
side=Side.BUY,
order_type=OrderType.LIMIT,
@ -149,7 +149,7 @@ def test_order_placement_cancellation_cycle(
assert sum(1 for _ in asks) == 0
bootstrapped_market.place_order(
payer=stubbed_base_wallet.public_key(),
payer=stubbed_base_wallet.public_key,
owner=stubbed_payer,
side=Side.SELL,
order_type=OrderType.LIMIT,