48 lines
1.5 KiB
Python
Executable File
48 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import os
|
|
import os.path
|
|
import sys
|
|
import typing
|
|
|
|
from solana.publickey import PublicKey
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
import mango # nopep8
|
|
|
|
parser = argparse.ArgumentParser(description="Shows Mango open orders accounts.")
|
|
mango.ContextBuilder.add_command_line_parameters(parser)
|
|
mango.Wallet.add_command_line_parameters(parser)
|
|
parser.add_argument(
|
|
"--market", type=str, required=True, help="market symbol (e.g. ETH/USDC)"
|
|
)
|
|
parser.add_argument(
|
|
"--address",
|
|
type=PublicKey,
|
|
help="Root address to check (if not provided, the wallet address is used)",
|
|
)
|
|
args: argparse.Namespace = mango.parse_args(parser)
|
|
|
|
with mango.ContextBuilder.from_command_line_parameters(args) as context:
|
|
address: typing.Optional[PublicKey] = args.address
|
|
if address is None:
|
|
wallet = mango.Wallet.from_command_line_parameters_or_raise(args)
|
|
address = wallet.address
|
|
|
|
market = mango.SerumMarket.ensure(mango.market(context, args.market))
|
|
|
|
all_open_orders_for_market = mango.OpenOrders.load_for_market_and_owner(
|
|
context,
|
|
market.address,
|
|
address,
|
|
context.serum_program_address,
|
|
market.base,
|
|
market.quote,
|
|
)
|
|
mango.output(
|
|
f"Found {len(all_open_orders_for_market)} Serum OpenOrders account(s) for market {market.symbol}."
|
|
)
|
|
for open_orders in all_open_orders_for_market:
|
|
mango.output(open_orders)
|