Update IDL

This commit is contained in:
waterquarks 2023-03-28 18:31:56 +00:00
parent 009f67ad7d
commit da348d44c5
88 changed files with 3913 additions and 487 deletions

1250
idl.json

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
@ -55,6 +55,7 @@ class BankJSON(typing.TypedDict):
net_borrows_in_window: int
borrow_weight_scale_start_quote: float
deposit_weight_scale_start_quote: float
reduce_only: int
reserved: list[int]
@ -104,7 +105,8 @@ class Bank:
"net_borrows_in_window" / borsh.I64,
"borrow_weight_scale_start_quote" / borsh.F64,
"deposit_weight_scale_start_quote" / borsh.F64,
"reserved" / borsh.U8[2120],
"reduce_only" / borsh.U8,
"reserved" / borsh.U8[2119],
)
group: PublicKey
name: list[int]
@ -148,6 +150,7 @@ class Bank:
net_borrows_in_window: int
borrow_weight_scale_start_quote: float
deposit_weight_scale_start_quote: float
reduce_only: int
reserved: list[int]
@classmethod
@ -156,7 +159,7 @@ class Bank:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["Bank"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -173,7 +176,7 @@ class Bank:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["Bank"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["Bank"]] = []
@ -244,6 +247,7 @@ class Bank:
net_borrows_in_window=dec.net_borrows_in_window,
borrow_weight_scale_start_quote=dec.borrow_weight_scale_start_quote,
deposit_weight_scale_start_quote=dec.deposit_weight_scale_start_quote,
reduce_only=dec.reduce_only,
reserved=dec.reserved,
)
@ -291,6 +295,7 @@ class Bank:
"net_borrows_in_window": self.net_borrows_in_window,
"borrow_weight_scale_start_quote": self.borrow_weight_scale_start_quote,
"deposit_weight_scale_start_quote": self.deposit_weight_scale_start_quote,
"reduce_only": self.reduce_only,
"reserved": self.reserved,
}
@ -347,5 +352,6 @@ class Bank:
net_borrows_in_window=obj["net_borrows_in_window"],
borrow_weight_scale_start_quote=obj["borrow_weight_scale_start_quote"],
deposit_weight_scale_start_quote=obj["deposit_weight_scale_start_quote"],
reduce_only=obj["reduce_only"],
reserved=obj["reserved"],
)

View File

@ -7,7 +7,7 @@ import borsh_construct as borsh
from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
@ -38,7 +38,7 @@ class BookSide:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["BookSide"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -55,7 +55,7 @@ class BookSide:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["BookSide"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["BookSide"]] = []
@ -119,4 +119,4 @@ class BookSide:
),
reserved=obj["reserved"],
nodes=types.order_tree_nodes.OrderTreeNodes.from_json(obj["nodes"]),
)
)

View File

@ -7,7 +7,7 @@ import borsh_construct as borsh
from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
@ -35,7 +35,7 @@ class EventQueue:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["EventQueue"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -52,7 +52,7 @@ class EventQueue:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["EventQueue"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["EventQueue"]] = []

View File

@ -8,7 +8,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class GroupJSON(typing.TypedDict):
@ -16,14 +16,21 @@ class GroupJSON(typing.TypedDict):
group_num: int
admin: str
fast_listing_admin: str
mngo_token_index: int
padding: list[int]
insurance_vault: str
insurance_mint: str
bump: int
testing: int
version: int
padding2: list[int]
buyback_fees: int
buyback_fees_mngo_bonus_factor: float
address_lookup_tables: list[str]
security_admin: str
deposit_limit_quote: int
ix_gate: int
buyback_fees_swap_mango_account: str
buyback_fees_expiry_interval: int
reserved: list[int]
@ -35,28 +42,42 @@ class Group:
"group_num" / borsh.U32,
"admin" / BorshPubkey,
"fast_listing_admin" / BorshPubkey,
"padding" / borsh.U8[4],
"mngo_token_index" / borsh.U16,
"padding" / borsh.U8[2],
"insurance_vault" / BorshPubkey,
"insurance_mint" / BorshPubkey,
"bump" / borsh.U8,
"testing" / borsh.U8,
"version" / borsh.U8,
"padding2" / borsh.U8[5],
"buyback_fees" / borsh.U8,
"buyback_fees_mngo_bonus_factor" / borsh.F32,
"address_lookup_tables" / BorshPubkey[20],
"reserved" / borsh.U8[1920],
"security_admin" / BorshPubkey,
"deposit_limit_quote" / borsh.U64,
"ix_gate" / borsh.U128,
"buyback_fees_swap_mango_account" / BorshPubkey,
"buyback_fees_expiry_interval" / borsh.U64,
"reserved" / borsh.U8[1824],
)
creator: PublicKey
group_num: int
admin: PublicKey
fast_listing_admin: PublicKey
mngo_token_index: int
padding: list[int]
insurance_vault: PublicKey
insurance_mint: PublicKey
bump: int
testing: int
version: int
padding2: list[int]
buyback_fees: int
buyback_fees_mngo_bonus_factor: float
address_lookup_tables: list[PublicKey]
security_admin: PublicKey
deposit_limit_quote: int
ix_gate: int
buyback_fees_swap_mango_account: PublicKey
buyback_fees_expiry_interval: int
reserved: list[int]
@classmethod
@ -65,7 +86,7 @@ class Group:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["Group"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -82,7 +103,7 @@ class Group:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["Group"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["Group"]] = []
@ -107,14 +128,21 @@ class Group:
group_num=dec.group_num,
admin=dec.admin,
fast_listing_admin=dec.fast_listing_admin,
mngo_token_index=dec.mngo_token_index,
padding=dec.padding,
insurance_vault=dec.insurance_vault,
insurance_mint=dec.insurance_mint,
bump=dec.bump,
testing=dec.testing,
version=dec.version,
padding2=dec.padding2,
buyback_fees=dec.buyback_fees,
buyback_fees_mngo_bonus_factor=dec.buyback_fees_mngo_bonus_factor,
address_lookup_tables=dec.address_lookup_tables,
security_admin=dec.security_admin,
deposit_limit_quote=dec.deposit_limit_quote,
ix_gate=dec.ix_gate,
buyback_fees_swap_mango_account=dec.buyback_fees_swap_mango_account,
buyback_fees_expiry_interval=dec.buyback_fees_expiry_interval,
reserved=dec.reserved,
)
@ -124,16 +152,25 @@ class Group:
"group_num": self.group_num,
"admin": str(self.admin),
"fast_listing_admin": str(self.fast_listing_admin),
"mngo_token_index": self.mngo_token_index,
"padding": self.padding,
"insurance_vault": str(self.insurance_vault),
"insurance_mint": str(self.insurance_mint),
"bump": self.bump,
"testing": self.testing,
"version": self.version,
"padding2": self.padding2,
"buyback_fees": self.buyback_fees,
"buyback_fees_mngo_bonus_factor": self.buyback_fees_mngo_bonus_factor,
"address_lookup_tables": list(
map(lambda item: str(item), self.address_lookup_tables)
),
"security_admin": str(self.security_admin),
"deposit_limit_quote": self.deposit_limit_quote,
"ix_gate": self.ix_gate,
"buyback_fees_swap_mango_account": str(
self.buyback_fees_swap_mango_account
),
"buyback_fees_expiry_interval": self.buyback_fees_expiry_interval,
"reserved": self.reserved,
}
@ -144,15 +181,24 @@ class Group:
group_num=obj["group_num"],
admin=PublicKey(obj["admin"]),
fast_listing_admin=PublicKey(obj["fast_listing_admin"]),
mngo_token_index=obj["mngo_token_index"],
padding=obj["padding"],
insurance_vault=PublicKey(obj["insurance_vault"]),
insurance_mint=PublicKey(obj["insurance_mint"]),
bump=obj["bump"],
testing=obj["testing"],
version=obj["version"],
padding2=obj["padding2"],
buyback_fees=obj["buyback_fees"],
buyback_fees_mngo_bonus_factor=obj["buyback_fees_mngo_bonus_factor"],
address_lookup_tables=list(
map(lambda item: PublicKey(item), obj["address_lookup_tables"])
),
security_admin=PublicKey(obj["security_admin"]),
deposit_limit_quote=obj["deposit_limit_quote"],
ix_gate=obj["ix_gate"],
buyback_fees_swap_mango_account=PublicKey(
obj["buyback_fees_swap_mango_account"]
),
buyback_fees_expiry_interval=obj["buyback_fees_expiry_interval"],
reserved=obj["reserved"],
)

View File

@ -9,7 +9,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
@ -26,6 +26,10 @@ class MangoAccountJSON(typing.TypedDict):
net_deposits: int
perp_spot_transfers: int
health_region_begin_init_health: int
frozen_until: int
buyback_fees_accrued_current: int
buyback_fees_accrued_previous: int
buyback_fees_expiry_timestamp: int
reserved: list[int]
header_version: int
padding3: list[int]
@ -55,7 +59,11 @@ class MangoAccount:
"net_deposits" / borsh.I64,
"perp_spot_transfers" / borsh.I64,
"health_region_begin_init_health" / borsh.I64,
"reserved" / borsh.U8[240],
"frozen_until" / borsh.U64,
"buyback_fees_accrued_current" / borsh.U64,
"buyback_fees_accrued_previous" / borsh.U64,
"buyback_fees_expiry_timestamp" / borsh.U64,
"reserved" / borsh.U8[208],
"header_version" / borsh.U8,
"padding3" / borsh.U8[7],
"padding4" / borsh.U32,
@ -83,6 +91,10 @@ class MangoAccount:
net_deposits: int
perp_spot_transfers: int
health_region_begin_init_health: int
frozen_until: int
buyback_fees_accrued_current: int
buyback_fees_accrued_previous: int
buyback_fees_expiry_timestamp: int
reserved: list[int]
header_version: int
padding3: list[int]
@ -101,7 +113,7 @@ class MangoAccount:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["MangoAccount"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -118,7 +130,7 @@ class MangoAccount:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["MangoAccount"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["MangoAccount"]] = []
@ -151,6 +163,10 @@ class MangoAccount:
net_deposits=dec.net_deposits,
perp_spot_transfers=dec.perp_spot_transfers,
health_region_begin_init_health=dec.health_region_begin_init_health,
frozen_until=dec.frozen_until,
buyback_fees_accrued_current=dec.buyback_fees_accrued_current,
buyback_fees_accrued_previous=dec.buyback_fees_accrued_previous,
buyback_fees_expiry_timestamp=dec.buyback_fees_expiry_timestamp,
reserved=dec.reserved,
header_version=dec.header_version,
padding3=dec.padding3,
@ -198,6 +214,10 @@ class MangoAccount:
"net_deposits": self.net_deposits,
"perp_spot_transfers": self.perp_spot_transfers,
"health_region_begin_init_health": self.health_region_begin_init_health,
"frozen_until": self.frozen_until,
"buyback_fees_accrued_current": self.buyback_fees_accrued_current,
"buyback_fees_accrued_previous": self.buyback_fees_accrued_previous,
"buyback_fees_expiry_timestamp": self.buyback_fees_expiry_timestamp,
"reserved": self.reserved,
"header_version": self.header_version,
"padding3": self.padding3,
@ -228,6 +248,10 @@ class MangoAccount:
net_deposits=obj["net_deposits"],
perp_spot_transfers=obj["perp_spot_transfers"],
health_region_begin_init_health=obj["health_region_begin_init_health"],
frozen_until=obj["frozen_until"],
buyback_fees_accrued_current=obj["buyback_fees_accrued_current"],
buyback_fees_accrued_previous=obj["buyback_fees_accrued_previous"],
buyback_fees_expiry_timestamp=obj["buyback_fees_expiry_timestamp"],
reserved=obj["reserved"],
header_version=obj["header_version"],
padding3=obj["padding3"],

View File

@ -8,7 +8,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class MintInfoJSON(typing.TypedDict):
@ -56,7 +56,7 @@ class MintInfo:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["MintInfo"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -73,7 +73,7 @@ class MintInfo:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["MintInfo"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["MintInfo"]] = []

View File

@ -8,17 +8,15 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
from ..constants import QUOTE_DECIMALS
from decimal import Decimal
class PerpMarketJSON(typing.TypedDict):
group: str
settle_token_index: int
perp_market_index: int
trusted_market: int
blocked1: int
group_insurance_fund: int
bump: int
base_decimals: int
@ -31,10 +29,10 @@ class PerpMarketJSON(typing.TypedDict):
stable_price_model: types.stable_price_model.StablePriceModelJSON
quote_lot_size: int
base_lot_size: int
maint_asset_weight: types.i80f48.I80F48JSON
init_asset_weight: types.i80f48.I80F48JSON
maint_liab_weight: types.i80f48.I80F48JSON
init_liab_weight: types.i80f48.I80F48JSON
maint_base_asset_weight: types.i80f48.I80F48JSON
init_base_asset_weight: types.i80f48.I80F48JSON
maint_base_liab_weight: types.i80f48.I80F48JSON
init_base_liab_weight: types.i80f48.I80F48JSON
open_interest: int
seq_num: int
registration_time: int
@ -44,7 +42,7 @@ class PerpMarketJSON(typing.TypedDict):
long_funding: types.i80f48.I80F48JSON
short_funding: types.i80f48.I80F48JSON
funding_last_updated: int
liquidation_fee: types.i80f48.I80F48JSON
base_liquidation_fee: types.i80f48.I80F48JSON
maker_fee: types.i80f48.I80F48JSON
taker_fee: types.i80f48.I80F48JSON
fees_accrued: types.i80f48.I80F48JSON
@ -56,6 +54,11 @@ class PerpMarketJSON(typing.TypedDict):
settle_pnl_limit_factor: float
padding3: list[int]
settle_pnl_limit_window_size_ts: int
reduce_only: int
padding4: list[int]
maint_overall_asset_weight: types.i80f48.I80F48JSON
init_overall_asset_weight: types.i80f48.I80F48JSON
positive_pnl_liquidation_fee: types.i80f48.I80F48JSON
reserved: list[int]
@ -66,7 +69,7 @@ class PerpMarket:
"group" / BorshPubkey,
"settle_token_index" / borsh.U16,
"perp_market_index" / borsh.U16,
"trusted_market" / borsh.U8,
"blocked1" / borsh.U8,
"group_insurance_fund" / borsh.U8,
"bump" / borsh.U8,
"base_decimals" / borsh.U8,
@ -79,10 +82,10 @@ class PerpMarket:
"stable_price_model" / types.stable_price_model.StablePriceModel.layout,
"quote_lot_size" / borsh.I64,
"base_lot_size" / borsh.I64,
"maint_asset_weight" / types.i80f48.I80F48.layout,
"init_asset_weight" / types.i80f48.I80F48.layout,
"maint_liab_weight" / types.i80f48.I80F48.layout,
"init_liab_weight" / types.i80f48.I80F48.layout,
"maint_base_asset_weight" / types.i80f48.I80F48.layout,
"init_base_asset_weight" / types.i80f48.I80F48.layout,
"maint_base_liab_weight" / types.i80f48.I80F48.layout,
"init_base_liab_weight" / types.i80f48.I80F48.layout,
"open_interest" / borsh.I64,
"seq_num" / borsh.U64,
"registration_time" / borsh.U64,
@ -92,7 +95,7 @@ class PerpMarket:
"long_funding" / types.i80f48.I80F48.layout,
"short_funding" / types.i80f48.I80F48.layout,
"funding_last_updated" / borsh.U64,
"liquidation_fee" / types.i80f48.I80F48.layout,
"base_liquidation_fee" / types.i80f48.I80F48.layout,
"maker_fee" / types.i80f48.I80F48.layout,
"taker_fee" / types.i80f48.I80F48.layout,
"fees_accrued" / types.i80f48.I80F48.layout,
@ -104,12 +107,17 @@ class PerpMarket:
"settle_pnl_limit_factor" / borsh.F32,
"padding3" / borsh.U8[4],
"settle_pnl_limit_window_size_ts" / borsh.U64,
"reserved" / borsh.U8[1944],
"reduce_only" / borsh.U8,
"padding4" / borsh.U8[7],
"maint_overall_asset_weight" / types.i80f48.I80F48.layout,
"init_overall_asset_weight" / types.i80f48.I80F48.layout,
"positive_pnl_liquidation_fee" / types.i80f48.I80F48.layout,
"reserved" / borsh.U8[1888],
)
group: PublicKey
settle_token_index: int
perp_market_index: int
trusted_market: int
blocked1: int
group_insurance_fund: int
bump: int
base_decimals: int
@ -122,10 +130,10 @@ class PerpMarket:
stable_price_model: types.stable_price_model.StablePriceModel
quote_lot_size: int
base_lot_size: int
maint_asset_weight: types.i80f48.I80F48
init_asset_weight: types.i80f48.I80F48
maint_liab_weight: types.i80f48.I80F48
init_liab_weight: types.i80f48.I80F48
maint_base_asset_weight: types.i80f48.I80F48
init_base_asset_weight: types.i80f48.I80F48
maint_base_liab_weight: types.i80f48.I80F48
init_base_liab_weight: types.i80f48.I80F48
open_interest: int
seq_num: int
registration_time: int
@ -135,7 +143,7 @@ class PerpMarket:
long_funding: types.i80f48.I80F48
short_funding: types.i80f48.I80F48
funding_last_updated: int
liquidation_fee: types.i80f48.I80F48
base_liquidation_fee: types.i80f48.I80F48
maker_fee: types.i80f48.I80F48
taker_fee: types.i80f48.I80F48
fees_accrued: types.i80f48.I80F48
@ -147,14 +155,20 @@ class PerpMarket:
settle_pnl_limit_factor: float
padding3: list[int]
settle_pnl_limit_window_size_ts: int
reduce_only: int
padding4: list[int]
maint_overall_asset_weight: types.i80f48.I80F48
init_overall_asset_weight: types.i80f48.I80F48
positive_pnl_liquidation_fee: types.i80f48.I80F48
reserved: list[int]
@classmethod
async def fetch(
cls,
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["PerpMarket"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -171,7 +185,7 @@ class PerpMarket:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["PerpMarket"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["PerpMarket"]] = []
@ -195,7 +209,7 @@ class PerpMarket:
group=dec.group,
settle_token_index=dec.settle_token_index,
perp_market_index=dec.perp_market_index,
trusted_market=dec.trusted_market,
blocked1=dec.blocked1,
group_insurance_fund=dec.group_insurance_fund,
bump=dec.bump,
base_decimals=dec.base_decimals,
@ -212,10 +226,18 @@ class PerpMarket:
),
quote_lot_size=dec.quote_lot_size,
base_lot_size=dec.base_lot_size,
maint_asset_weight=types.i80f48.I80F48.from_decoded(dec.maint_asset_weight),
init_asset_weight=types.i80f48.I80F48.from_decoded(dec.init_asset_weight),
maint_liab_weight=types.i80f48.I80F48.from_decoded(dec.maint_liab_weight),
init_liab_weight=types.i80f48.I80F48.from_decoded(dec.init_liab_weight),
maint_base_asset_weight=types.i80f48.I80F48.from_decoded(
dec.maint_base_asset_weight
),
init_base_asset_weight=types.i80f48.I80F48.from_decoded(
dec.init_base_asset_weight
),
maint_base_liab_weight=types.i80f48.I80F48.from_decoded(
dec.maint_base_liab_weight
),
init_base_liab_weight=types.i80f48.I80F48.from_decoded(
dec.init_base_liab_weight
),
open_interest=dec.open_interest,
seq_num=dec.seq_num,
registration_time=dec.registration_time,
@ -225,7 +247,9 @@ class PerpMarket:
long_funding=types.i80f48.I80F48.from_decoded(dec.long_funding),
short_funding=types.i80f48.I80F48.from_decoded(dec.short_funding),
funding_last_updated=dec.funding_last_updated,
liquidation_fee=types.i80f48.I80F48.from_decoded(dec.liquidation_fee),
base_liquidation_fee=types.i80f48.I80F48.from_decoded(
dec.base_liquidation_fee
),
maker_fee=types.i80f48.I80F48.from_decoded(dec.maker_fee),
taker_fee=types.i80f48.I80F48.from_decoded(dec.taker_fee),
fees_accrued=types.i80f48.I80F48.from_decoded(dec.fees_accrued),
@ -237,6 +261,17 @@ class PerpMarket:
settle_pnl_limit_factor=dec.settle_pnl_limit_factor,
padding3=dec.padding3,
settle_pnl_limit_window_size_ts=dec.settle_pnl_limit_window_size_ts,
reduce_only=dec.reduce_only,
padding4=dec.padding4,
maint_overall_asset_weight=types.i80f48.I80F48.from_decoded(
dec.maint_overall_asset_weight
),
init_overall_asset_weight=types.i80f48.I80F48.from_decoded(
dec.init_overall_asset_weight
),
positive_pnl_liquidation_fee=types.i80f48.I80F48.from_decoded(
dec.positive_pnl_liquidation_fee
),
reserved=dec.reserved,
)
@ -245,7 +280,7 @@ class PerpMarket:
"group": str(self.group),
"settle_token_index": self.settle_token_index,
"perp_market_index": self.perp_market_index,
"trusted_market": self.trusted_market,
"blocked1": self.blocked1,
"group_insurance_fund": self.group_insurance_fund,
"bump": self.bump,
"base_decimals": self.base_decimals,
@ -258,10 +293,10 @@ class PerpMarket:
"stable_price_model": self.stable_price_model.to_json(),
"quote_lot_size": self.quote_lot_size,
"base_lot_size": self.base_lot_size,
"maint_asset_weight": self.maint_asset_weight.to_json(),
"init_asset_weight": self.init_asset_weight.to_json(),
"maint_liab_weight": self.maint_liab_weight.to_json(),
"init_liab_weight": self.init_liab_weight.to_json(),
"maint_base_asset_weight": self.maint_base_asset_weight.to_json(),
"init_base_asset_weight": self.init_base_asset_weight.to_json(),
"maint_base_liab_weight": self.maint_base_liab_weight.to_json(),
"init_base_liab_weight": self.init_base_liab_weight.to_json(),
"open_interest": self.open_interest,
"seq_num": self.seq_num,
"registration_time": self.registration_time,
@ -271,7 +306,7 @@ class PerpMarket:
"long_funding": self.long_funding.to_json(),
"short_funding": self.short_funding.to_json(),
"funding_last_updated": self.funding_last_updated,
"liquidation_fee": self.liquidation_fee.to_json(),
"base_liquidation_fee": self.base_liquidation_fee.to_json(),
"maker_fee": self.maker_fee.to_json(),
"taker_fee": self.taker_fee.to_json(),
"fees_accrued": self.fees_accrued.to_json(),
@ -283,6 +318,11 @@ class PerpMarket:
"settle_pnl_limit_factor": self.settle_pnl_limit_factor,
"padding3": self.padding3,
"settle_pnl_limit_window_size_ts": self.settle_pnl_limit_window_size_ts,
"reduce_only": self.reduce_only,
"padding4": self.padding4,
"maint_overall_asset_weight": self.maint_overall_asset_weight.to_json(),
"init_overall_asset_weight": self.init_overall_asset_weight.to_json(),
"positive_pnl_liquidation_fee": self.positive_pnl_liquidation_fee.to_json(),
"reserved": self.reserved,
}
@ -292,7 +332,7 @@ class PerpMarket:
group=PublicKey(obj["group"]),
settle_token_index=obj["settle_token_index"],
perp_market_index=obj["perp_market_index"],
trusted_market=obj["trusted_market"],
blocked1=obj["blocked1"],
group_insurance_fund=obj["group_insurance_fund"],
bump=obj["bump"],
base_decimals=obj["base_decimals"],
@ -309,10 +349,18 @@ class PerpMarket:
),
quote_lot_size=obj["quote_lot_size"],
base_lot_size=obj["base_lot_size"],
maint_asset_weight=types.i80f48.I80F48.from_json(obj["maint_asset_weight"]),
init_asset_weight=types.i80f48.I80F48.from_json(obj["init_asset_weight"]),
maint_liab_weight=types.i80f48.I80F48.from_json(obj["maint_liab_weight"]),
init_liab_weight=types.i80f48.I80F48.from_json(obj["init_liab_weight"]),
maint_base_asset_weight=types.i80f48.I80F48.from_json(
obj["maint_base_asset_weight"]
),
init_base_asset_weight=types.i80f48.I80F48.from_json(
obj["init_base_asset_weight"]
),
maint_base_liab_weight=types.i80f48.I80F48.from_json(
obj["maint_base_liab_weight"]
),
init_base_liab_weight=types.i80f48.I80F48.from_json(
obj["init_base_liab_weight"]
),
open_interest=obj["open_interest"],
seq_num=obj["seq_num"],
registration_time=obj["registration_time"],
@ -322,7 +370,9 @@ class PerpMarket:
long_funding=types.i80f48.I80F48.from_json(obj["long_funding"]),
short_funding=types.i80f48.I80F48.from_json(obj["short_funding"]),
funding_last_updated=obj["funding_last_updated"],
liquidation_fee=types.i80f48.I80F48.from_json(obj["liquidation_fee"]),
base_liquidation_fee=types.i80f48.I80F48.from_json(
obj["base_liquidation_fee"]
),
maker_fee=types.i80f48.I80F48.from_json(obj["maker_fee"]),
taker_fee=types.i80f48.I80F48.from_json(obj["taker_fee"]),
fees_accrued=types.i80f48.I80F48.from_json(obj["fees_accrued"]),
@ -334,30 +384,16 @@ class PerpMarket:
settle_pnl_limit_factor=obj["settle_pnl_limit_factor"],
padding3=obj["padding3"],
settle_pnl_limit_window_size_ts=obj["settle_pnl_limit_window_size_ts"],
reduce_only=obj["reduce_only"],
padding4=obj["padding4"],
maint_overall_asset_weight=types.i80f48.I80F48.from_json(
obj["maint_overall_asset_weight"]
),
init_overall_asset_weight=types.i80f48.I80F48.from_json(
obj["init_overall_asset_weight"]
),
positive_pnl_liquidation_fee=types.i80f48.I80F48.from_json(
obj["positive_pnl_liquidation_fee"]
),
reserved=obj["reserved"],
)
# TODO: Transform all convertors into functions
def __post_init__(self):
self.price_lots_to_ui_converter = (((Decimal(10) ** Decimal(self.base_decimals - QUOTE_DECIMALS)) * Decimal(self.quote_lot_size)) / Decimal(self.base_lot_size))
self.base_lots_to_ui_converter = (Decimal(self.base_lot_size) / Decimal(10) ** Decimal(self.base_decimals))
self.quote_lots_to_ui_converter = (Decimal(self.quote_lot_size) / (Decimal(10) ** Decimal(QUOTE_DECIMALS)))
def price_lots_to_ui(self, price_lots: int):
return float(Decimal(price_lots) * Decimal(self.price_lots_to_ui_converter))
def base_lots_to_ui(self, base_lots: int):
return float(Decimal(base_lots) * (Decimal(self.base_lot_size) / Decimal(10) ** Decimal(self.base_decimals)))
def quote_lots_to_ui(self, quote_lots: int):
raise NotImplementedError
def ui_price_to_lots(self, ui_price: float) -> int:
return int(Decimal(ui_price * 10 ** QUOTE_DECIMALS) * Decimal(self.base_lot_size) / Decimal(self.quote_lot_size * 10 ** self.base_decimals))
def ui_base_to_lots(self, ui_base: float) -> int:
return int(Decimal(ui_base * 10 ** self.base_decimals) / Decimal(self.base_lot_size))
def ui_quote_to_lots(self, ui_quote: float) -> int:
return int(Decimal(ui_quote * 10 ** QUOTE_DECIMALS) / Decimal(self.quote_lot_size))

View File

@ -8,13 +8,14 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3MarketJSON(typing.TypedDict):
group: str
base_token_index: int
quote_token_index: int
reduce_only: int
padding1: list[int]
name: list[int]
serum_program: str
@ -33,7 +34,8 @@ class Serum3Market:
"group" / BorshPubkey,
"base_token_index" / borsh.U16,
"quote_token_index" / borsh.U16,
"padding1" / borsh.U8[4],
"reduce_only" / borsh.U8,
"padding1" / borsh.U8[3],
"name" / borsh.U8[16],
"serum_program" / BorshPubkey,
"serum_market_external" / BorshPubkey,
@ -46,6 +48,7 @@ class Serum3Market:
group: PublicKey
base_token_index: int
quote_token_index: int
reduce_only: int
padding1: list[int]
name: list[int]
serum_program: PublicKey
@ -62,7 +65,7 @@ class Serum3Market:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["Serum3Market"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -79,7 +82,7 @@ class Serum3Market:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["Serum3Market"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["Serum3Market"]] = []
@ -103,6 +106,7 @@ class Serum3Market:
group=dec.group,
base_token_index=dec.base_token_index,
quote_token_index=dec.quote_token_index,
reduce_only=dec.reduce_only,
padding1=dec.padding1,
name=dec.name,
serum_program=dec.serum_program,
@ -119,6 +123,7 @@ class Serum3Market:
"group": str(self.group),
"base_token_index": self.base_token_index,
"quote_token_index": self.quote_token_index,
"reduce_only": self.reduce_only,
"padding1": self.padding1,
"name": self.name,
"serum_program": str(self.serum_program),
@ -136,6 +141,7 @@ class Serum3Market:
group=PublicKey(obj["group"]),
base_token_index=obj["base_token_index"],
quote_token_index=obj["quote_token_index"],
reduce_only=obj["reduce_only"],
padding1=obj["padding1"],
name=obj["name"],
serum_program=PublicKey(obj["serum_program"]),

View File

@ -8,7 +8,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3MarketIndexReservationJSON(typing.TypedDict):
@ -33,7 +33,7 @@ class Serum3MarketIndexReservation:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["Serum3MarketIndexReservation"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -50,7 +50,7 @@ class Serum3MarketIndexReservation:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["Serum3MarketIndexReservation"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["Serum3MarketIndexReservation"]] = []

View File

@ -8,7 +8,7 @@ from anchorpy.coder.accounts import ACCOUNT_DISCRIMINATOR_SIZE
from anchorpy.error import AccountInvalidDiscriminator
from anchorpy.utils.rpc import get_multiple_accounts
from anchorpy.borsh_extension import BorshPubkey
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from .. import types
@ -42,7 +42,7 @@ class StubOracle:
conn: AsyncClient,
address: PublicKey,
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.Optional["StubOracle"]:
resp = await conn.get_account_info(address, commitment=commitment)
info = resp.value
@ -59,7 +59,7 @@ class StubOracle:
conn: AsyncClient,
addresses: list[PublicKey],
commitment: typing.Optional[Commitment] = None,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
) -> typing.List[typing.Optional["StubOracle"]]:
infos = await get_multiple_accounts(conn, addresses, commitment=commitment)
res: typing.List[typing.Optional["StubOracle"]] = []

View File

@ -7,7 +7,7 @@ from solders.transaction_status import (
from solana.rpc.core import RPCException
from solders.rpc.errors import SendTransactionPreflightFailureMessage
from anchorpy.error import extract_code_and_logs
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
from . import anchor
from . import custom
@ -23,7 +23,7 @@ def from_tx_error(
error: RPCException,
) -> typing.Union[anchor.AnchorError, custom.CustomError, None]:
err_info = error.args[0]
extracted = extract_code_and_logs(err_info, MANGO_PROGRAM_ID)
extracted = extract_code_and_logs(err_info, PROGRAM_ID)
if extracted is None:
return None
return from_code(extracted[0])

View File

@ -268,6 +268,153 @@ class TokenPositionDoesNotExist(ProgramError):
msg = "token position does not exist"
class DepositsIntoLiquidatingMustRecover(ProgramError):
def __init__(self) -> None:
super().__init__(
6029,
"token deposits into accounts that are being liquidated must bring their health above the init threshold",
)
code = 6029
name = "DepositsIntoLiquidatingMustRecover"
msg = "token deposits into accounts that are being liquidated must bring their health above the init threshold"
class TokenInReduceOnlyMode(ProgramError):
def __init__(self) -> None:
super().__init__(6030, "token is in reduce only mode")
code = 6030
name = "TokenInReduceOnlyMode"
msg = "token is in reduce only mode"
class MarketInReduceOnlyMode(ProgramError):
def __init__(self) -> None:
super().__init__(6031, "market is in reduce only mode")
code = 6031
name = "MarketInReduceOnlyMode"
msg = "market is in reduce only mode"
class GroupIsHalted(ProgramError):
def __init__(self) -> None:
super().__init__(6032, "group is halted")
code = 6032
name = "GroupIsHalted"
msg = "group is halted"
class PerpHasBaseLots(ProgramError):
def __init__(self) -> None:
super().__init__(6033, "the perp position has non-zero base lots")
code = 6033
name = "PerpHasBaseLots"
msg = "the perp position has non-zero base lots"
class HasOpenOrUnsettledSerum3Orders(ProgramError):
def __init__(self) -> None:
super().__init__(6034, "there are open or unsettled serum3 orders")
code = 6034
name = "HasOpenOrUnsettledSerum3Orders"
msg = "there are open or unsettled serum3 orders"
class HasLiquidatableTokenPosition(ProgramError):
def __init__(self) -> None:
super().__init__(6035, "has liquidatable token position")
code = 6035
name = "HasLiquidatableTokenPosition"
msg = "has liquidatable token position"
class HasLiquidatablePerpBasePosition(ProgramError):
def __init__(self) -> None:
super().__init__(6036, "has liquidatable perp base position")
code = 6036
name = "HasLiquidatablePerpBasePosition"
msg = "has liquidatable perp base position"
class HasLiquidatablePositivePerpPnl(ProgramError):
def __init__(self) -> None:
super().__init__(6037, "has liquidatable positive perp pnl")
code = 6037
name = "HasLiquidatablePositivePerpPnl"
msg = "has liquidatable positive perp pnl"
class AccountIsFrozen(ProgramError):
def __init__(self) -> None:
super().__init__(6038, "account is frozen")
code = 6038
name = "AccountIsFrozen"
msg = "account is frozen"
class InitAssetWeightCantBeNegative(ProgramError):
def __init__(self) -> None:
super().__init__(6039, "Init Asset Weight can't be negative")
code = 6039
name = "InitAssetWeightCantBeNegative"
msg = "Init Asset Weight can't be negative"
class HasOpenPerpTakerFills(ProgramError):
def __init__(self) -> None:
super().__init__(6040, "has open perp taker fills")
code = 6040
name = "HasOpenPerpTakerFills"
msg = "has open perp taker fills"
class DepositLimit(ProgramError):
def __init__(self) -> None:
super().__init__(6041, "deposit crosses the current group deposit limit")
code = 6041
name = "DepositLimit"
msg = "deposit crosses the current group deposit limit"
class IxIsDisabled(ProgramError):
def __init__(self) -> None:
super().__init__(6042, "instruction is disabled")
code = 6042
name = "IxIsDisabled"
msg = "instruction is disabled"
class NoLiquidatablePerpBasePosition(ProgramError):
def __init__(self) -> None:
super().__init__(6043, "no liquidatable perp base position")
code = 6043
name = "NoLiquidatablePerpBasePosition"
msg = "no liquidatable perp base position"
class PerpOrderIdNotFound(ProgramError):
def __init__(self) -> None:
super().__init__(6044, "perp order id not found on the orderbook")
code = 6044
name = "PerpOrderIdNotFound"
msg = "perp order id not found on the orderbook"
CustomError = typing.Union[
SomeError,
NotImplementedError,
@ -298,6 +445,22 @@ CustomError = typing.Union[
BankBorrowLimitReached,
BankNetBorrowsLimitReached,
TokenPositionDoesNotExist,
DepositsIntoLiquidatingMustRecover,
TokenInReduceOnlyMode,
MarketInReduceOnlyMode,
GroupIsHalted,
PerpHasBaseLots,
HasOpenOrUnsettledSerum3Orders,
HasLiquidatableTokenPosition,
HasLiquidatablePerpBasePosition,
HasLiquidatablePositivePerpPnl,
AccountIsFrozen,
InitAssetWeightCantBeNegative,
HasOpenPerpTakerFills,
DepositLimit,
IxIsDisabled,
NoLiquidatablePerpBasePosition,
PerpOrderIdNotFound,
]
CUSTOM_ERROR_MAP: dict[int, CustomError] = {
6000: SomeError(),
@ -329,6 +492,22 @@ CUSTOM_ERROR_MAP: dict[int, CustomError] = {
6026: BankBorrowLimitReached(),
6027: BankNetBorrowsLimitReached(),
6028: TokenPositionDoesNotExist(),
6029: DepositsIntoLiquidatingMustRecover(),
6030: TokenInReduceOnlyMode(),
6031: MarketInReduceOnlyMode(),
6032: GroupIsHalted(),
6033: PerpHasBaseLots(),
6034: HasOpenOrUnsettledSerum3Orders(),
6035: HasLiquidatableTokenPosition(),
6036: HasLiquidatablePerpBasePosition(),
6037: HasLiquidatablePositivePerpPnl(),
6038: AccountIsFrozen(),
6039: InitAssetWeightCantBeNegative(),
6040: HasOpenPerpTakerFills(),
6041: DepositLimit(),
6042: IxIsDisabled(),
6043: NoLiquidatablePerpBasePosition(),
6044: PerpOrderIdNotFound(),
}

View File

@ -1,5 +1,6 @@
from .group_create import group_create, GroupCreateArgs, GroupCreateAccounts
from .group_edit import group_edit, GroupEditArgs, GroupEditAccounts
from .ix_gate_set import ix_gate_set, IxGateSetArgs, IxGateSetAccounts
from .group_close import group_close, GroupCloseAccounts
from .token_register import token_register, TokenRegisterArgs, TokenRegisterAccounts
from .token_register_trustless import (
@ -17,7 +18,17 @@ from .token_update_index_and_rate import (
from .account_create import account_create, AccountCreateArgs, AccountCreateAccounts
from .account_expand import account_expand, AccountExpandArgs, AccountExpandAccounts
from .account_edit import account_edit, AccountEditArgs, AccountEditAccounts
from .account_toggle_freeze import (
account_toggle_freeze,
AccountToggleFreezeArgs,
AccountToggleFreezeAccounts,
)
from .account_close import account_close, AccountCloseArgs, AccountCloseAccounts
from .account_buyback_fees_with_mngo import (
account_buyback_fees_with_mngo,
AccountBuybackFeesWithMngoArgs,
AccountBuybackFeesWithMngoAccounts,
)
from .stub_oracle_create import (
stub_oracle_create,
StubOracleCreateArgs,
@ -45,6 +56,11 @@ from .serum3_register_market import (
Serum3RegisterMarketArgs,
Serum3RegisterMarketAccounts,
)
from .serum3_edit_market import (
serum3_edit_market,
Serum3EditMarketArgs,
Serum3EditMarketAccounts,
)
from .serum3_deregister_market import (
serum3_deregister_market,
Serum3DeregisterMarketAccounts,
@ -73,6 +89,11 @@ from .serum3_cancel_all_orders import (
Serum3CancelAllOrdersAccounts,
)
from .serum3_settle_funds import serum3_settle_funds, Serum3SettleFundsAccounts
from .serum3_settle_funds_v2 import (
serum3_settle_funds_v2,
Serum3SettleFundsV2Args,
Serum3SettleFundsV2Accounts,
)
from .serum3_liq_force_cancel_orders import (
serum3_liq_force_cancel_orders,
Serum3LiqForceCancelOrdersArgs,
@ -155,20 +176,20 @@ from .perp_settle_fees import (
PerpSettleFeesArgs,
PerpSettleFeesAccounts,
)
from .perp_liq_base_position import (
perp_liq_base_position,
PerpLiqBasePositionArgs,
PerpLiqBasePositionAccounts,
from .perp_liq_base_or_positive_pnl import (
perp_liq_base_or_positive_pnl,
PerpLiqBaseOrPositivePnlArgs,
PerpLiqBaseOrPositivePnlAccounts,
)
from .perp_liq_force_cancel_orders import (
perp_liq_force_cancel_orders,
PerpLiqForceCancelOrdersArgs,
PerpLiqForceCancelOrdersAccounts,
)
from .perp_liq_bankruptcy import (
perp_liq_bankruptcy,
PerpLiqBankruptcyArgs,
PerpLiqBankruptcyAccounts,
from .perp_liq_negative_pnl_or_bankruptcy import (
perp_liq_negative_pnl_or_bankruptcy,
PerpLiqNegativePnlOrBankruptcyArgs,
PerpLiqNegativePnlOrBankruptcyAccounts,
)
from .alt_set import alt_set, AltSetArgs, AltSetAccounts
from .alt_extend import alt_extend, AltExtendArgs, AltExtendAccounts

View File

@ -0,0 +1,52 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class AccountBuybackFeesWithMngoArgs(typing.TypedDict):
max_buyback: int
layout = borsh.CStruct("max_buyback" / borsh.U64)
class AccountBuybackFeesWithMngoAccounts(typing.TypedDict):
group: PublicKey
account: PublicKey
owner: PublicKey
dao_account: PublicKey
mngo_bank: PublicKey
mngo_oracle: PublicKey
fees_bank: PublicKey
fees_oracle: PublicKey
def account_buyback_fees_with_mngo(
args: AccountBuybackFeesWithMngoArgs,
accounts: AccountBuybackFeesWithMngoAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["account"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["owner"], is_signer=True, is_writable=False),
AccountMeta(pubkey=accounts["dao_account"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["mngo_bank"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["mngo_oracle"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["fees_bank"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["fees_oracle"], is_signer=False, is_writable=False),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"\x0c\x19B\x8b\x16`f\xc1"
encoded_args = layout.build(
{
"max_buyback": args["max_buyback"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AccountCloseArgs(typing.TypedDict):
@ -24,7 +24,7 @@ class AccountCloseAccounts(typing.TypedDict):
def account_close(
args: AccountCloseArgs,
accounts: AccountCloseAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.system_program import SYS_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AccountCreateArgs(typing.TypedDict):
@ -36,7 +36,7 @@ class AccountCreateAccounts(typing.TypedDict):
def account_create(
args: AccountCreateArgs,
accounts: AccountCreateAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from anchorpy.borsh_extension import BorshPubkey
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AccountEditArgs(typing.TypedDict):
@ -26,7 +26,7 @@ class AccountEditAccounts(typing.TypedDict):
def account_edit(
args: AccountEditArgs,
accounts: AccountEditAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.system_program import SYS_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AccountExpandArgs(typing.TypedDict):
@ -32,7 +32,7 @@ class AccountExpandAccounts(typing.TypedDict):
def account_expand(
args: AccountExpandArgs,
accounts: AccountExpandAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -0,0 +1,42 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class AccountToggleFreezeArgs(typing.TypedDict):
freeze: bool
layout = borsh.CStruct("freeze" / borsh.Bool)
class AccountToggleFreezeAccounts(typing.TypedDict):
group: PublicKey
account: PublicKey
admin: PublicKey
def account_toggle_freeze(
args: AccountToggleFreezeArgs,
accounts: AccountToggleFreezeAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["account"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["admin"], is_signer=True, is_writable=False),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"\x0b\xf3\xe9\xf7WO`\xc6"
encoded_args = layout.build(
{
"freeze": args["freeze"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -5,7 +5,7 @@ from solana.transaction import TransactionInstruction, AccountMeta
from anchorpy.borsh_extension import BorshPubkey
from construct import Construct
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AltExtendArgs(typing.TypedDict):
@ -28,7 +28,7 @@ class AltExtendAccounts(typing.TypedDict):
def alt_extend(
args: AltExtendArgs,
accounts: AltExtendAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class AltSetArgs(typing.TypedDict):
@ -22,7 +22,7 @@ class AltSetAccounts(typing.TypedDict):
def alt_set(
args: AltSetArgs,
accounts: AltSetAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -2,11 +2,11 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
def benchmark(
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = []

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class ComputeAccountDataAccounts(typing.TypedDict):
@ -12,7 +12,7 @@ class ComputeAccountDataAccounts(typing.TypedDict):
def compute_account_data(
accounts: ComputeAccountDataAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from construct import Construct
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class FlashLoanBeginArgs(typing.TypedDict):
@ -24,7 +24,7 @@ class FlashLoanBeginAccounts(typing.TypedDict):
def flash_loan_begin(
args: FlashLoanBeginArgs,
accounts: FlashLoanBeginAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class FlashLoanEndArgs(typing.TypedDict):
@ -23,7 +23,7 @@ class FlashLoanEndAccounts(typing.TypedDict):
def flash_loan_end(
args: FlashLoanEndArgs,
accounts: FlashLoanEndAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class GroupCloseAccounts(typing.TypedDict):
@ -15,7 +15,7 @@ class GroupCloseAccounts(typing.TypedDict):
def group_close(
accounts: GroupCloseAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -6,7 +6,7 @@ from solana.sysvar import SYSVAR_RENT_PUBKEY
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class GroupCreateArgs(typing.TypedDict):
@ -31,7 +31,7 @@ class GroupCreateAccounts(typing.TypedDict):
def group_create(
args: GroupCreateArgs,
accounts: GroupCreateAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,21 +4,35 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from anchorpy.borsh_extension import BorshPubkey
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class GroupEditArgs(typing.TypedDict):
admin_opt: typing.Optional[PublicKey]
fast_listing_admin_opt: typing.Optional[PublicKey]
security_admin_opt: typing.Optional[PublicKey]
testing_opt: typing.Optional[int]
version_opt: typing.Optional[int]
deposit_limit_quote_opt: typing.Optional[int]
buyback_fees_opt: typing.Optional[bool]
buyback_fees_bonus_factor_opt: typing.Optional[float]
buyback_fees_swap_mango_account_opt: typing.Optional[PublicKey]
mngo_token_index_opt: typing.Optional[int]
buyback_fees_expiry_interval_opt: typing.Optional[int]
layout = borsh.CStruct(
"admin_opt" / borsh.Option(BorshPubkey),
"fast_listing_admin_opt" / borsh.Option(BorshPubkey),
"security_admin_opt" / borsh.Option(BorshPubkey),
"testing_opt" / borsh.Option(borsh.U8),
"version_opt" / borsh.Option(borsh.U8),
"deposit_limit_quote_opt" / borsh.Option(borsh.U64),
"buyback_fees_opt" / borsh.Option(borsh.Bool),
"buyback_fees_bonus_factor_opt" / borsh.Option(borsh.F32),
"buyback_fees_swap_mango_account_opt" / borsh.Option(BorshPubkey),
"mngo_token_index_opt" / borsh.Option(borsh.U16),
"buyback_fees_expiry_interval_opt" / borsh.Option(borsh.U64),
)
@ -30,7 +44,7 @@ class GroupEditAccounts(typing.TypedDict):
def group_edit(
args: GroupEditArgs,
accounts: GroupEditAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -44,8 +58,19 @@ def group_edit(
{
"admin_opt": args["admin_opt"],
"fast_listing_admin_opt": args["fast_listing_admin_opt"],
"security_admin_opt": args["security_admin_opt"],
"testing_opt": args["testing_opt"],
"version_opt": args["version_opt"],
"deposit_limit_quote_opt": args["deposit_limit_quote_opt"],
"buyback_fees_opt": args["buyback_fees_opt"],
"buyback_fees_bonus_factor_opt": args["buyback_fees_bonus_factor_opt"],
"buyback_fees_swap_mango_account_opt": args[
"buyback_fees_swap_mango_account_opt"
],
"mngo_token_index_opt": args["mngo_token_index_opt"],
"buyback_fees_expiry_interval_opt": args[
"buyback_fees_expiry_interval_opt"
],
}
)
data = identifier + encoded_args

View File

@ -2,23 +2,25 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class HealthRegionBeginAccounts(typing.TypedDict):
instructions: PublicKey
group: PublicKey
account: PublicKey
def health_region_begin(
accounts: HealthRegionBeginAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(
pubkey=accounts["instructions"], is_signer=False, is_writable=False
),
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["account"], is_signer=False, is_writable=True),
]
if remaining_accounts is not None:

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class HealthRegionEndAccounts(typing.TypedDict):
@ -11,7 +11,7 @@ class HealthRegionEndAccounts(typing.TypedDict):
def health_region_end(
accounts: HealthRegionEndAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -0,0 +1,40 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class IxGateSetArgs(typing.TypedDict):
ix_gate: int
layout = borsh.CStruct("ix_gate" / borsh.U128)
class IxGateSetAccounts(typing.TypedDict):
group: PublicKey
admin: PublicKey
def ix_gate_set(
args: IxGateSetArgs,
accounts: IxGateSetAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["admin"], is_signer=True, is_writable=False),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"\xc9\xb1Ub/\xdd\x8a\xf8"
encoded_args = layout.build(
{
"ix_gate": args["ix_gate"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -5,7 +5,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class LiqTokenBankruptcyArgs(typing.TypedDict):
@ -28,7 +28,7 @@ class LiqTokenBankruptcyAccounts(typing.TypedDict):
def liq_token_bankruptcy(
args: LiqTokenBankruptcyArgs,
accounts: LiqTokenBankruptcyAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class LiqTokenWithTokenArgs(typing.TypedDict):
@ -30,7 +30,7 @@ class LiqTokenWithTokenAccounts(typing.TypedDict):
def liq_token_with_token(
args: LiqTokenWithTokenArgs,
accounts: LiqTokenWithTokenAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCancelAllOrdersArgs(typing.TypedDict):
@ -25,7 +25,7 @@ class PerpCancelAllOrdersAccounts(typing.TypedDict):
def perp_cancel_all_orders(
args: PerpCancelAllOrdersArgs,
accounts: PerpCancelAllOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCancelAllOrdersBySideArgs(typing.TypedDict):
@ -29,7 +29,7 @@ class PerpCancelAllOrdersBySideAccounts(typing.TypedDict):
def perp_cancel_all_orders_by_side(
args: PerpCancelAllOrdersBySideArgs,
accounts: PerpCancelAllOrdersBySideAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCancelOrderArgs(typing.TypedDict):
@ -25,7 +25,7 @@ class PerpCancelOrderAccounts(typing.TypedDict):
def perp_cancel_order(
args: PerpCancelOrderArgs,
accounts: PerpCancelOrderAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCancelOrderByClientOrderIdArgs(typing.TypedDict):
@ -25,7 +25,7 @@ class PerpCancelOrderByClientOrderIdAccounts(typing.TypedDict):
def perp_cancel_order_by_client_order_id(
args: PerpCancelOrderByClientOrderIdArgs,
accounts: PerpCancelOrderByClientOrderIdAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCloseMarketAccounts(typing.TypedDict):
@ -18,7 +18,7 @@ class PerpCloseMarketAccounts(typing.TypedDict):
def perp_close_market(
accounts: PerpCloseMarketAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpConsumeEventsArgs(typing.TypedDict):
@ -22,7 +22,7 @@ class PerpConsumeEventsAccounts(typing.TypedDict):
def perp_consume_events(
args: PerpConsumeEventsArgs,
accounts: PerpConsumeEventsAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from solana.system_program import SYS_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpCreateMarketArgs(typing.TypedDict):
@ -15,18 +15,19 @@ class PerpCreateMarketArgs(typing.TypedDict):
base_decimals: int
quote_lot_size: int
base_lot_size: int
maint_asset_weight: float
init_asset_weight: float
maint_liab_weight: float
init_liab_weight: float
liquidation_fee: float
maint_base_asset_weight: float
init_base_asset_weight: float
maint_base_liab_weight: float
init_base_liab_weight: float
maint_overall_asset_weight: float
init_overall_asset_weight: float
base_liquidation_fee: float
maker_fee: float
taker_fee: float
min_funding: float
max_funding: float
impact_quantity: int
group_insurance_fund: bool
trusted_market: bool
fee_penalty: float
settle_fee_flat: float
settle_fee_amount_threshold: float
@ -34,6 +35,7 @@ class PerpCreateMarketArgs(typing.TypedDict):
settle_token_index: int
settle_pnl_limit_factor: float
settle_pnl_limit_window_size_ts: int
positive_pnl_liquidation_fee: float
layout = borsh.CStruct(
@ -43,18 +45,19 @@ layout = borsh.CStruct(
"base_decimals" / borsh.U8,
"quote_lot_size" / borsh.I64,
"base_lot_size" / borsh.I64,
"maint_asset_weight" / borsh.F32,
"init_asset_weight" / borsh.F32,
"maint_liab_weight" / borsh.F32,
"init_liab_weight" / borsh.F32,
"liquidation_fee" / borsh.F32,
"maint_base_asset_weight" / borsh.F32,
"init_base_asset_weight" / borsh.F32,
"maint_base_liab_weight" / borsh.F32,
"init_base_liab_weight" / borsh.F32,
"maint_overall_asset_weight" / borsh.F32,
"init_overall_asset_weight" / borsh.F32,
"base_liquidation_fee" / borsh.F32,
"maker_fee" / borsh.F32,
"taker_fee" / borsh.F32,
"min_funding" / borsh.F32,
"max_funding" / borsh.F32,
"impact_quantity" / borsh.I64,
"group_insurance_fund" / borsh.Bool,
"trusted_market" / borsh.Bool,
"fee_penalty" / borsh.F32,
"settle_fee_flat" / borsh.F32,
"settle_fee_amount_threshold" / borsh.F32,
@ -62,6 +65,7 @@ layout = borsh.CStruct(
"settle_token_index" / borsh.U16,
"settle_pnl_limit_factor" / borsh.F32,
"settle_pnl_limit_window_size_ts" / borsh.U64,
"positive_pnl_liquidation_fee" / borsh.F32,
)
@ -79,7 +83,7 @@ class PerpCreateMarketAccounts(typing.TypedDict):
def perp_create_market(
args: PerpCreateMarketArgs,
accounts: PerpCreateMarketAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -104,18 +108,19 @@ def perp_create_market(
"base_decimals": args["base_decimals"],
"quote_lot_size": args["quote_lot_size"],
"base_lot_size": args["base_lot_size"],
"maint_asset_weight": args["maint_asset_weight"],
"init_asset_weight": args["init_asset_weight"],
"maint_liab_weight": args["maint_liab_weight"],
"init_liab_weight": args["init_liab_weight"],
"liquidation_fee": args["liquidation_fee"],
"maint_base_asset_weight": args["maint_base_asset_weight"],
"init_base_asset_weight": args["init_base_asset_weight"],
"maint_base_liab_weight": args["maint_base_liab_weight"],
"init_base_liab_weight": args["init_base_liab_weight"],
"maint_overall_asset_weight": args["maint_overall_asset_weight"],
"init_overall_asset_weight": args["init_overall_asset_weight"],
"base_liquidation_fee": args["base_liquidation_fee"],
"maker_fee": args["maker_fee"],
"taker_fee": args["taker_fee"],
"min_funding": args["min_funding"],
"max_funding": args["max_funding"],
"impact_quantity": args["impact_quantity"],
"group_insurance_fund": args["group_insurance_fund"],
"trusted_market": args["trusted_market"],
"fee_penalty": args["fee_penalty"],
"settle_fee_flat": args["settle_fee_flat"],
"settle_fee_amount_threshold": args["settle_fee_amount_threshold"],
@ -123,6 +128,7 @@ def perp_create_market(
"settle_token_index": args["settle_token_index"],
"settle_pnl_limit_factor": args["settle_pnl_limit_factor"],
"settle_pnl_limit_window_size_ts": args["settle_pnl_limit_window_size_ts"],
"positive_pnl_liquidation_fee": args["positive_pnl_liquidation_fee"],
}
)
data = identifier + encoded_args

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpDeactivatePositionAccounts(typing.TypedDict):
@ -14,7 +14,7 @@ class PerpDeactivatePositionAccounts(typing.TypedDict):
def perp_deactivate_position(
accounts: PerpDeactivatePositionAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,25 +5,26 @@ from solana.transaction import TransactionInstruction, AccountMeta
from anchorpy.borsh_extension import BorshPubkey
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpEditMarketArgs(typing.TypedDict):
oracle_opt: typing.Optional[PublicKey]
oracle_config_opt: typing.Optional[types.oracle_config_params.OracleConfigParams]
base_decimals_opt: typing.Optional[int]
maint_asset_weight_opt: typing.Optional[float]
init_asset_weight_opt: typing.Optional[float]
maint_liab_weight_opt: typing.Optional[float]
init_liab_weight_opt: typing.Optional[float]
liquidation_fee_opt: typing.Optional[float]
maint_base_asset_weight_opt: typing.Optional[float]
init_base_asset_weight_opt: typing.Optional[float]
maint_base_liab_weight_opt: typing.Optional[float]
init_base_liab_weight_opt: typing.Optional[float]
maint_overall_asset_weight_opt: typing.Optional[float]
init_overall_asset_weight_opt: typing.Optional[float]
base_liquidation_fee_opt: typing.Optional[float]
maker_fee_opt: typing.Optional[float]
taker_fee_opt: typing.Optional[float]
min_funding_opt: typing.Optional[float]
max_funding_opt: typing.Optional[float]
impact_quantity_opt: typing.Optional[int]
group_insurance_fund_opt: typing.Optional[bool]
trusted_market_opt: typing.Optional[bool]
fee_penalty_opt: typing.Optional[float]
settle_fee_flat_opt: typing.Optional[float]
settle_fee_amount_threshold_opt: typing.Optional[float]
@ -32,7 +33,11 @@ class PerpEditMarketArgs(typing.TypedDict):
stable_price_delay_growth_limit_opt: typing.Optional[float]
stable_price_growth_limit_opt: typing.Optional[float]
settle_pnl_limit_factor_opt: typing.Optional[float]
settle_pnl_limit_window_size_ts: typing.Optional[int]
settle_pnl_limit_window_size_ts_opt: typing.Optional[int]
reduce_only_opt: typing.Optional[bool]
reset_stable_price: bool
positive_pnl_liquidation_fee_opt: typing.Optional[float]
name_opt: typing.Optional[str]
layout = borsh.CStruct(
@ -40,18 +45,19 @@ layout = borsh.CStruct(
"oracle_config_opt"
/ borsh.Option(types.oracle_config_params.OracleConfigParams.layout),
"base_decimals_opt" / borsh.Option(borsh.U8),
"maint_asset_weight_opt" / borsh.Option(borsh.F32),
"init_asset_weight_opt" / borsh.Option(borsh.F32),
"maint_liab_weight_opt" / borsh.Option(borsh.F32),
"init_liab_weight_opt" / borsh.Option(borsh.F32),
"liquidation_fee_opt" / borsh.Option(borsh.F32),
"maint_base_asset_weight_opt" / borsh.Option(borsh.F32),
"init_base_asset_weight_opt" / borsh.Option(borsh.F32),
"maint_base_liab_weight_opt" / borsh.Option(borsh.F32),
"init_base_liab_weight_opt" / borsh.Option(borsh.F32),
"maint_overall_asset_weight_opt" / borsh.Option(borsh.F32),
"init_overall_asset_weight_opt" / borsh.Option(borsh.F32),
"base_liquidation_fee_opt" / borsh.Option(borsh.F32),
"maker_fee_opt" / borsh.Option(borsh.F32),
"taker_fee_opt" / borsh.Option(borsh.F32),
"min_funding_opt" / borsh.Option(borsh.F32),
"max_funding_opt" / borsh.Option(borsh.F32),
"impact_quantity_opt" / borsh.Option(borsh.I64),
"group_insurance_fund_opt" / borsh.Option(borsh.Bool),
"trusted_market_opt" / borsh.Option(borsh.Bool),
"fee_penalty_opt" / borsh.Option(borsh.F32),
"settle_fee_flat_opt" / borsh.Option(borsh.F32),
"settle_fee_amount_threshold_opt" / borsh.Option(borsh.F32),
@ -60,7 +66,11 @@ layout = borsh.CStruct(
"stable_price_delay_growth_limit_opt" / borsh.Option(borsh.F32),
"stable_price_growth_limit_opt" / borsh.Option(borsh.F32),
"settle_pnl_limit_factor_opt" / borsh.Option(borsh.F32),
"settle_pnl_limit_window_size_ts" / borsh.Option(borsh.U64),
"settle_pnl_limit_window_size_ts_opt" / borsh.Option(borsh.U64),
"reduce_only_opt" / borsh.Option(borsh.Bool),
"reset_stable_price" / borsh.Bool,
"positive_pnl_liquidation_fee_opt" / borsh.Option(borsh.F32),
"name_opt" / borsh.Option(borsh.String),
)
@ -74,7 +84,7 @@ class PerpEditMarketAccounts(typing.TypedDict):
def perp_edit_market(
args: PerpEditMarketArgs,
accounts: PerpEditMarketAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -95,18 +105,19 @@ def perp_edit_market(
else args["oracle_config_opt"].to_encodable()
),
"base_decimals_opt": args["base_decimals_opt"],
"maint_asset_weight_opt": args["maint_asset_weight_opt"],
"init_asset_weight_opt": args["init_asset_weight_opt"],
"maint_liab_weight_opt": args["maint_liab_weight_opt"],
"init_liab_weight_opt": args["init_liab_weight_opt"],
"liquidation_fee_opt": args["liquidation_fee_opt"],
"maint_base_asset_weight_opt": args["maint_base_asset_weight_opt"],
"init_base_asset_weight_opt": args["init_base_asset_weight_opt"],
"maint_base_liab_weight_opt": args["maint_base_liab_weight_opt"],
"init_base_liab_weight_opt": args["init_base_liab_weight_opt"],
"maint_overall_asset_weight_opt": args["maint_overall_asset_weight_opt"],
"init_overall_asset_weight_opt": args["init_overall_asset_weight_opt"],
"base_liquidation_fee_opt": args["base_liquidation_fee_opt"],
"maker_fee_opt": args["maker_fee_opt"],
"taker_fee_opt": args["taker_fee_opt"],
"min_funding_opt": args["min_funding_opt"],
"max_funding_opt": args["max_funding_opt"],
"impact_quantity_opt": args["impact_quantity_opt"],
"group_insurance_fund_opt": args["group_insurance_fund_opt"],
"trusted_market_opt": args["trusted_market_opt"],
"fee_penalty_opt": args["fee_penalty_opt"],
"settle_fee_flat_opt": args["settle_fee_flat_opt"],
"settle_fee_amount_threshold_opt": args["settle_fee_amount_threshold_opt"],
@ -121,7 +132,15 @@ def perp_edit_market(
],
"stable_price_growth_limit_opt": args["stable_price_growth_limit_opt"],
"settle_pnl_limit_factor_opt": args["settle_pnl_limit_factor_opt"],
"settle_pnl_limit_window_size_ts": args["settle_pnl_limit_window_size_ts"],
"settle_pnl_limit_window_size_ts_opt": args[
"settle_pnl_limit_window_size_ts_opt"
],
"reduce_only_opt": args["reduce_only_opt"],
"reset_stable_price": args["reset_stable_price"],
"positive_pnl_liquidation_fee_opt": args[
"positive_pnl_liquidation_fee_opt"
],
"name_opt": args["name_opt"],
}
)
data = identifier + encoded_args

View File

@ -0,0 +1,58 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class PerpLiqBaseOrPositivePnlArgs(typing.TypedDict):
max_base_transfer: int
max_pnl_transfer: int
layout = borsh.CStruct("max_base_transfer" / borsh.I64, "max_pnl_transfer" / borsh.U64)
class PerpLiqBaseOrPositivePnlAccounts(typing.TypedDict):
group: PublicKey
perp_market: PublicKey
oracle: PublicKey
liqor: PublicKey
liqor_owner: PublicKey
liqee: PublicKey
settle_bank: PublicKey
settle_vault: PublicKey
settle_oracle: PublicKey
def perp_liq_base_or_positive_pnl(
args: PerpLiqBaseOrPositivePnlArgs,
accounts: PerpLiqBaseOrPositivePnlAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["perp_market"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["oracle"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["liqor"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["liqor_owner"], is_signer=True, is_writable=False),
AccountMeta(pubkey=accounts["liqee"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["settle_bank"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["settle_vault"], is_signer=False, is_writable=True),
AccountMeta(
pubkey=accounts["settle_oracle"], is_signer=False, is_writable=False
),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"k\xaa]\x8b\xc0\x8dy\xcd"
encoded_args = layout.build(
{
"max_base_transfer": args["max_base_transfer"],
"max_pnl_transfer": args["max_pnl_transfer"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpLiqForceCancelOrdersArgs(typing.TypedDict):
@ -24,7 +24,7 @@ class PerpLiqForceCancelOrdersAccounts(typing.TypedDict):
def perp_liq_force_cancel_orders(
args: PerpLiqForceCancelOrdersArgs,
accounts: PerpLiqForceCancelOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -0,0 +1,62 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class PerpLiqNegativePnlOrBankruptcyArgs(typing.TypedDict):
max_liab_transfer: int
layout = borsh.CStruct("max_liab_transfer" / borsh.U64)
class PerpLiqNegativePnlOrBankruptcyAccounts(typing.TypedDict):
group: PublicKey
liqor: PublicKey
liqor_owner: PublicKey
liqee: PublicKey
perp_market: PublicKey
oracle: PublicKey
settle_bank: PublicKey
settle_vault: PublicKey
settle_oracle: PublicKey
insurance_vault: PublicKey
def perp_liq_negative_pnl_or_bankruptcy(
args: PerpLiqNegativePnlOrBankruptcyArgs,
accounts: PerpLiqNegativePnlOrBankruptcyAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["liqor"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["liqor_owner"], is_signer=True, is_writable=False),
AccountMeta(pubkey=accounts["liqee"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["perp_market"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["oracle"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["settle_bank"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["settle_vault"], is_signer=False, is_writable=True),
AccountMeta(
pubkey=accounts["settle_oracle"], is_signer=False, is_writable=False
),
AccountMeta(
pubkey=accounts["insurance_vault"], is_signer=False, is_writable=True
),
AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"\x1f\xaf\xd6\xb4u\xe3\x985"
encoded_args = layout.build(
{
"max_liab_transfer": args["max_liab_transfer"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpPlaceOrderArgs(typing.TypedDict):
@ -46,7 +46,7 @@ class PerpPlaceOrderAccounts(typing.TypedDict):
def perp_place_order(
args: PerpPlaceOrderArgs,
accounts: PerpPlaceOrderAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpPlaceOrderPeggedArgs(typing.TypedDict):
@ -50,7 +50,7 @@ class PerpPlaceOrderPeggedAccounts(typing.TypedDict):
def perp_place_order_pegged(
args: PerpPlaceOrderPeggedArgs,
accounts: PerpPlaceOrderPeggedAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpSettleFeesArgs(typing.TypedDict):
@ -25,7 +25,7 @@ class PerpSettleFeesAccounts(typing.TypedDict):
def perp_settle_fees(
args: PerpSettleFeesArgs,
accounts: PerpSettleFeesAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpSettlePnlAccounts(typing.TypedDict):
@ -19,7 +19,7 @@ class PerpSettlePnlAccounts(typing.TypedDict):
def perp_settle_pnl(
accounts: PerpSettlePnlAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class PerpUpdateFundingAccounts(typing.TypedDict):
@ -15,7 +15,7 @@ class PerpUpdateFundingAccounts(typing.TypedDict):
def perp_update_funding(
accounts: PerpUpdateFundingAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3CancelAllOrdersArgs(typing.TypedDict):
@ -29,7 +29,7 @@ class Serum3CancelAllOrdersAccounts(typing.TypedDict):
def serum3_cancel_all_orders(
args: Serum3CancelAllOrdersArgs,
accounts: Serum3CancelAllOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3CancelOrderArgs(typing.TypedDict):
@ -31,7 +31,7 @@ class Serum3CancelOrderAccounts(typing.TypedDict):
def serum3_cancel_order(
args: Serum3CancelOrderArgs,
accounts: Serum3CancelOrderAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3CloseOpenOrdersAccounts(typing.TypedDict):
@ -18,7 +18,7 @@ class Serum3CloseOpenOrdersAccounts(typing.TypedDict):
def serum3_close_open_orders(
accounts: Serum3CloseOpenOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.system_program import SYS_PROGRAM_ID
from solana.sysvar import SYSVAR_RENT_PUBKEY
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3CreateOpenOrdersAccounts(typing.TypedDict):
@ -20,7 +20,7 @@ class Serum3CreateOpenOrdersAccounts(typing.TypedDict):
def serum3_create_open_orders(
accounts: Serum3CreateOpenOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3DeregisterMarketAccounts(typing.TypedDict):
@ -16,7 +16,7 @@ class Serum3DeregisterMarketAccounts(typing.TypedDict):
def serum3_deregister_market(
accounts: Serum3DeregisterMarketAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -0,0 +1,42 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class Serum3EditMarketArgs(typing.TypedDict):
reduce_only_opt: typing.Optional[bool]
layout = borsh.CStruct("reduce_only_opt" / borsh.Option(borsh.Bool))
class Serum3EditMarketAccounts(typing.TypedDict):
group: PublicKey
admin: PublicKey
market: PublicKey
def serum3_edit_market(
args: Serum3EditMarketArgs,
accounts: Serum3EditMarketAccounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["admin"], is_signer=True, is_writable=False),
AccountMeta(pubkey=accounts["market"], is_signer=False, is_writable=True),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"1s\xff\x17R\t^~"
encoded_args = layout.build(
{
"reduce_only_opt": args["reduce_only_opt"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3LiqForceCancelOrdersArgs(typing.TypedDict):
@ -36,7 +36,7 @@ class Serum3LiqForceCancelOrdersAccounts(typing.TypedDict):
def serum3_liq_force_cancel_orders(
args: Serum3LiqForceCancelOrdersArgs,
accounts: Serum3LiqForceCancelOrdersAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID, SERUM_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3PlaceOrderArgs(typing.TypedDict):
@ -54,7 +54,7 @@ class Serum3PlaceOrderAccounts(typing.TypedDict):
def serum3_place_order(
args: Serum3PlaceOrderArgs,
accounts: Serum3PlaceOrderAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.system_program import SYS_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3RegisterMarketArgs(typing.TypedDict):
@ -30,7 +30,7 @@ class Serum3RegisterMarketAccounts(typing.TypedDict):
def serum3_register_market(
args: Serum3RegisterMarketArgs,
accounts: Serum3RegisterMarketAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class Serum3SettleFundsAccounts(typing.TypedDict):
@ -25,7 +25,7 @@ class Serum3SettleFundsAccounts(typing.TypedDict):
def serum3_settle_funds(
accounts: Serum3SettleFundsAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -0,0 +1,131 @@
from __future__ import annotations
import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import PROGRAM_ID
class Serum3SettleFundsV2Args(typing.TypedDict):
fees_to_dao: bool
layout = borsh.CStruct("fees_to_dao" / borsh.Bool)
class Serum3SettleFundsV2Accounts(typing.TypedDict):
v1: V1Nested
v2: V2Nested
class V1Nested(typing.TypedDict):
group: PublicKey
account: PublicKey
owner: PublicKey
open_orders: PublicKey
serum_market: PublicKey
serum_program: PublicKey
serum_market_external: PublicKey
market_base_vault: PublicKey
market_quote_vault: PublicKey
market_vault_signer: PublicKey
quote_bank: PublicKey
quote_vault: PublicKey
base_bank: PublicKey
base_vault: PublicKey
class V2Nested(typing.TypedDict):
quote_oracle: PublicKey
base_oracle: PublicKey
class V1Nested(typing.TypedDict):
group: PublicKey
account: PublicKey
owner: PublicKey
open_orders: PublicKey
serum_market: PublicKey
serum_program: PublicKey
serum_market_external: PublicKey
market_base_vault: PublicKey
market_quote_vault: PublicKey
market_vault_signer: PublicKey
quote_bank: PublicKey
quote_vault: PublicKey
base_bank: PublicKey
base_vault: PublicKey
def serum3_settle_funds_v2(
args: Serum3SettleFundsV2Args,
accounts: Serum3SettleFundsV2Accounts,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["v1"]["group"], is_signer=False, is_writable=False),
AccountMeta(
pubkey=accounts["v1"]["account"], is_signer=False, is_writable=True
),
AccountMeta(pubkey=accounts["v1"]["owner"], is_signer=True, is_writable=False),
AccountMeta(
pubkey=accounts["v1"]["open_orders"], is_signer=False, is_writable=True
),
AccountMeta(
pubkey=accounts["v1"]["serum_market"], is_signer=False, is_writable=False
),
AccountMeta(
pubkey=accounts["v1"]["serum_program"], is_signer=False, is_writable=False
),
AccountMeta(
pubkey=accounts["v1"]["serum_market_external"],
is_signer=False,
is_writable=True,
),
AccountMeta(
pubkey=accounts["v1"]["market_base_vault"],
is_signer=False,
is_writable=True,
),
AccountMeta(
pubkey=accounts["v1"]["market_quote_vault"],
is_signer=False,
is_writable=True,
),
AccountMeta(
pubkey=accounts["v1"]["market_vault_signer"],
is_signer=False,
is_writable=False,
),
AccountMeta(
pubkey=accounts["v1"]["quote_bank"], is_signer=False, is_writable=True
),
AccountMeta(
pubkey=accounts["v1"]["quote_vault"], is_signer=False, is_writable=True
),
AccountMeta(
pubkey=accounts["v1"]["base_bank"], is_signer=False, is_writable=True
),
AccountMeta(
pubkey=accounts["v1"]["base_vault"], is_signer=False, is_writable=True
),
AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False),
AccountMeta(
pubkey=accounts["v2"]["quote_oracle"], is_signer=False, is_writable=False
),
AccountMeta(
pubkey=accounts["v2"]["base_oracle"], is_signer=False, is_writable=False
),
]
if remaining_accounts is not None:
keys += remaining_accounts
identifier = b"\x05\xddk\x17\xf7\xd3/\xdd"
encoded_args = layout.build(
{
"fees_to_dao": args["fees_to_dao"],
}
)
data = identifier + encoded_args
return TransactionInstruction(keys, program_id, data)

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class StubOracleCloseAccounts(typing.TypedDict):
@ -15,7 +15,7 @@ class StubOracleCloseAccounts(typing.TypedDict):
def stub_oracle_close(
accounts: StubOracleCloseAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from solana.system_program import SYS_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class StubOracleCreateArgs(typing.TypedDict):
@ -26,7 +26,7 @@ class StubOracleCreateAccounts(typing.TypedDict):
def stub_oracle_create(
args: StubOracleCreateArgs,
accounts: StubOracleCreateAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class StubOracleSetArgs(typing.TypedDict):
@ -23,7 +23,7 @@ class StubOracleSetAccounts(typing.TypedDict):
def stub_oracle_set(
args: StubOracleSetArgs,
accounts: StubOracleSetAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -6,7 +6,7 @@ from solana.sysvar import SYSVAR_RENT_PUBKEY
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenAddBankArgs(typing.TypedDict):
@ -31,7 +31,7 @@ class TokenAddBankAccounts(typing.TypedDict):
def token_add_bank(
args: TokenAddBankArgs,
accounts: TokenAddBankAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,14 +4,15 @@ from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenDepositArgs(typing.TypedDict):
amount: int
reduce_only: bool
layout = borsh.CStruct("amount" / borsh.U64)
layout = borsh.CStruct("amount" / borsh.U64, "reduce_only" / borsh.Bool)
class TokenDepositAccounts(typing.TypedDict):
@ -28,7 +29,7 @@ class TokenDepositAccounts(typing.TypedDict):
def token_deposit(
args: TokenDepositArgs,
accounts: TokenDepositAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -52,6 +53,7 @@ def token_deposit(
encoded_args = layout.build(
{
"amount": args["amount"],
"reduce_only": args["reduce_only"],
}
)
data = identifier + encoded_args

View File

@ -4,14 +4,15 @@ from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenDepositIntoExistingArgs(typing.TypedDict):
amount: int
reduce_only: bool
layout = borsh.CStruct("amount" / borsh.U64)
layout = borsh.CStruct("amount" / borsh.U64, "reduce_only" / borsh.Bool)
class TokenDepositIntoExistingAccounts(typing.TypedDict):
@ -27,7 +28,7 @@ class TokenDepositIntoExistingAccounts(typing.TypedDict):
def token_deposit_into_existing(
args: TokenDepositIntoExistingArgs,
accounts: TokenDepositIntoExistingAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -50,6 +51,7 @@ def token_deposit_into_existing(
encoded_args = layout.build(
{
"amount": args["amount"],
"reduce_only": args["reduce_only"],
}
)
data = identifier + encoded_args

View File

@ -3,7 +3,7 @@ import typing
from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenDeregisterAccounts(typing.TypedDict):
@ -16,7 +16,7 @@ class TokenDeregisterAccounts(typing.TypedDict):
def token_deregister(
accounts: TokenDeregisterAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -5,7 +5,7 @@ from solana.transaction import TransactionInstruction, AccountMeta
from anchorpy.borsh_extension import BorshPubkey
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenEditArgs(typing.TypedDict):
@ -32,6 +32,8 @@ class TokenEditArgs(typing.TypedDict):
deposit_weight_scale_start_quote_opt: typing.Optional[float]
reset_stable_price: bool
reset_net_borrow_limit: bool
reduce_only_opt: typing.Optional[bool]
name_opt: typing.Optional[str]
layout = borsh.CStruct(
@ -58,6 +60,8 @@ layout = borsh.CStruct(
"deposit_weight_scale_start_quote_opt" / borsh.Option(borsh.F64),
"reset_stable_price" / borsh.Bool,
"reset_net_borrow_limit" / borsh.Bool,
"reduce_only_opt" / borsh.Option(borsh.Bool),
"name_opt" / borsh.Option(borsh.String),
)
@ -71,7 +75,7 @@ class TokenEditAccounts(typing.TypedDict):
def token_edit(
args: TokenEditArgs,
accounts: TokenEditAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
@ -126,6 +130,8 @@ def token_edit(
],
"reset_stable_price": args["reset_stable_price"],
"reset_net_borrow_limit": args["reset_net_borrow_limit"],
"reduce_only_opt": args["reduce_only_opt"],
"name_opt": args["name_opt"],
}
)
data = identifier + encoded_args

View File

@ -5,7 +5,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenLiqBankruptcyArgs(typing.TypedDict):
@ -28,7 +28,7 @@ class TokenLiqBankruptcyAccounts(typing.TypedDict):
def token_liq_bankruptcy(
args: TokenLiqBankruptcyArgs,
accounts: TokenLiqBankruptcyAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenLiqWithTokenArgs(typing.TypedDict):
@ -30,7 +30,7 @@ class TokenLiqWithTokenAccounts(typing.TypedDict):
def token_liq_with_token(
args: TokenLiqWithTokenArgs,
accounts: TokenLiqWithTokenAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -7,7 +7,7 @@ from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from .. import types
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenRegisterArgs(typing.TypedDict):
@ -59,7 +59,7 @@ class TokenRegisterAccounts(typing.TypedDict):
def token_register(
args: TokenRegisterArgs,
accounts: TokenRegisterAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -6,7 +6,7 @@ from solana.sysvar import SYSVAR_RENT_PUBKEY
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenRegisterTrustlessArgs(typing.TypedDict):
@ -19,7 +19,7 @@ layout = borsh.CStruct("token_index" / borsh.U16, "name" / borsh.String)
class TokenRegisterTrustlessAccounts(typing.TypedDict):
group: PublicKey
fast_listing_admin: PublicKey
admin: PublicKey
mint: PublicKey
bank: PublicKey
vault: PublicKey
@ -31,14 +31,12 @@ class TokenRegisterTrustlessAccounts(typing.TypedDict):
def token_register_trustless(
args: TokenRegisterTrustlessArgs,
accounts: TokenRegisterTrustlessAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [
AccountMeta(pubkey=accounts["group"], is_signer=False, is_writable=False),
AccountMeta(
pubkey=accounts["fast_listing_admin"], is_signer=True, is_writable=False
),
AccountMeta(pubkey=accounts["admin"], is_signer=True, is_writable=False),
AccountMeta(pubkey=accounts["mint"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["bank"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["vault"], is_signer=False, is_writable=True),

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import typing
from solana.publickey import PublicKey
from solana.transaction import TransactionInstruction, AccountMeta
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenUpdateIndexAndRateAccounts(typing.TypedDict):
@ -14,7 +14,7 @@ class TokenUpdateIndexAndRateAccounts(typing.TypedDict):
def token_update_index_and_rate(
accounts: TokenUpdateIndexAndRateAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -4,7 +4,7 @@ from solana.publickey import PublicKey
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.transaction import TransactionInstruction, AccountMeta
import borsh_construct as borsh
from ..program_id import MANGO_PROGRAM_ID
from ..program_id import PROGRAM_ID
class TokenWithdrawArgs(typing.TypedDict):
@ -28,7 +28,7 @@ class TokenWithdrawAccounts(typing.TypedDict):
def token_withdraw(
args: TokenWithdrawArgs,
accounts: TokenWithdrawAccounts,
program_id: PublicKey = MANGO_PROGRAM_ID,
program_id: PublicKey = PROGRAM_ID,
remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
) -> TransactionInstruction:
keys: list[AccountMeta] = [

View File

@ -1,4 +1,3 @@
from solana.publickey import PublicKey
MANGO_PROGRAM_ID = PublicKey("4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg")
SERUM_PROGRAM_ID = PublicKey('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX')
PROGRAM_ID = PublicKey("4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg")

View File

@ -1,4 +1,6 @@
import typing
from . import interest_rate_params
from .interest_rate_params import InterestRateParams, InterestRateParamsJSON
from . import equity
from .equity import Equity, EquityJSON
from . import token_equity
@ -15,8 +17,6 @@ from . import perp_info
from .perp_info import PerpInfo, PerpInfoJSON
from . import health_cache
from .health_cache import HealthCache, HealthCacheJSON
from . import interest_rate_params
from .interest_rate_params import InterestRateParams, InterestRateParamsJSON
from . import flash_loan_token_detail
from .flash_loan_token_detail import FlashLoanTokenDetail, FlashLoanTokenDetailJSON
from . import token_position
@ -61,8 +61,6 @@ from . import perp_market_index
from .perp_market_index import PerpMarketIndex, PerpMarketIndexJSON
from . import i80f48
from .i80f48 import I80F48, I80F48JSON
from . import health_type
from .health_type import HealthTypeKind, HealthTypeJSON
from . import flash_loan_type
from .flash_loan_type import FlashLoanTypeKind, FlashLoanTypeJSON
from . import serum3_self_trade_behavior
@ -74,11 +72,15 @@ from . import serum3_order_type
from .serum3_order_type import Serum3OrderTypeKind, Serum3OrderTypeJSON
from . import serum3_side
from .serum3_side import Serum3SideKind, Serum3SideJSON
from . import health_type
from .health_type import HealthTypeKind, HealthTypeJSON
from . import loan_origination_fee_instruction
from .loan_origination_fee_instruction import (
LoanOriginationFeeInstructionKind,
LoanOriginationFeeInstructionJSON,
)
from . import ix_gate
from .ix_gate import IxGateKind, IxGateJSON
from . import oracle_type
from .oracle_type import OracleTypeKind, OracleTypeJSON
from . import order_state

View File

@ -1,7 +1,4 @@
from __future__ import annotations
from . import (
i80f48,
)
import typing
from dataclasses import dataclass
from construct import Container
@ -19,15 +16,17 @@ class FillEventJSON(typing.TypedDict):
timestamp: int
seq_num: int
maker: str
maker_order_id: int
maker_fee: i80f48.I80F48JSON
padding2: list[int]
maker_timestamp: int
taker: str
taker_order_id: int
padding3: list[int]
taker_client_order_id: int
taker_fee: i80f48.I80F48JSON
padding4: list[int]
price: int
quantity: int
maker_client_order_id: int
maker_fee: float
taker_fee: float
reserved: list[int]
@ -42,16 +41,18 @@ class FillEvent:
"timestamp" / borsh.U64,
"seq_num" / borsh.U64,
"maker" / BorshPubkey,
"maker_order_id" / borsh.U128,
"maker_fee" / i80f48.I80F48.layout,
"padding2" / borsh.U8[32],
"maker_timestamp" / borsh.U64,
"taker" / BorshPubkey,
"taker_order_id" / borsh.U128,
"padding3" / borsh.U8[16],
"taker_client_order_id" / borsh.U64,
"taker_fee" / i80f48.I80F48.layout,
"padding4" / borsh.U8[16],
"price" / borsh.I64,
"quantity" / borsh.I64,
"reserved" / borsh.U8[24],
"maker_client_order_id" / borsh.U64,
"maker_fee" / borsh.F32,
"taker_fee" / borsh.F32,
"reserved" / borsh.U8[8],
)
event_type: int
taker_side: int
@ -61,15 +62,17 @@ class FillEvent:
timestamp: int
seq_num: int
maker: PublicKey
maker_order_id: int
maker_fee: i80f48.I80F48
padding2: list[int]
maker_timestamp: int
taker: PublicKey
taker_order_id: int
padding3: list[int]
taker_client_order_id: int
taker_fee: i80f48.I80F48
padding4: list[int]
price: int
quantity: int
maker_client_order_id: int
maker_fee: float
taker_fee: float
reserved: list[int]
@classmethod
@ -83,15 +86,17 @@ class FillEvent:
timestamp=obj.timestamp,
seq_num=obj.seq_num,
maker=obj.maker,
maker_order_id=obj.maker_order_id,
maker_fee=i80f48.I80F48.from_decoded(obj.maker_fee),
padding2=obj.padding2,
maker_timestamp=obj.maker_timestamp,
taker=obj.taker,
taker_order_id=obj.taker_order_id,
padding3=obj.padding3,
taker_client_order_id=obj.taker_client_order_id,
taker_fee=i80f48.I80F48.from_decoded(obj.taker_fee),
padding4=obj.padding4,
price=obj.price,
quantity=obj.quantity,
maker_client_order_id=obj.maker_client_order_id,
maker_fee=obj.maker_fee,
taker_fee=obj.taker_fee,
reserved=obj.reserved,
)
@ -105,15 +110,17 @@ class FillEvent:
"timestamp": self.timestamp,
"seq_num": self.seq_num,
"maker": self.maker,
"maker_order_id": self.maker_order_id,
"maker_fee": self.maker_fee.to_encodable(),
"padding2": self.padding2,
"maker_timestamp": self.maker_timestamp,
"taker": self.taker,
"taker_order_id": self.taker_order_id,
"padding3": self.padding3,
"taker_client_order_id": self.taker_client_order_id,
"taker_fee": self.taker_fee.to_encodable(),
"padding4": self.padding4,
"price": self.price,
"quantity": self.quantity,
"maker_client_order_id": self.maker_client_order_id,
"maker_fee": self.maker_fee,
"taker_fee": self.taker_fee,
"reserved": self.reserved,
}
@ -127,15 +134,17 @@ class FillEvent:
"timestamp": self.timestamp,
"seq_num": self.seq_num,
"maker": str(self.maker),
"maker_order_id": self.maker_order_id,
"maker_fee": self.maker_fee.to_json(),
"padding2": self.padding2,
"maker_timestamp": self.maker_timestamp,
"taker": str(self.taker),
"taker_order_id": self.taker_order_id,
"padding3": self.padding3,
"taker_client_order_id": self.taker_client_order_id,
"taker_fee": self.taker_fee.to_json(),
"padding4": self.padding4,
"price": self.price,
"quantity": self.quantity,
"maker_client_order_id": self.maker_client_order_id,
"maker_fee": self.maker_fee,
"taker_fee": self.taker_fee,
"reserved": self.reserved,
}
@ -150,14 +159,16 @@ class FillEvent:
timestamp=obj["timestamp"],
seq_num=obj["seq_num"],
maker=PublicKey(obj["maker"]),
maker_order_id=obj["maker_order_id"],
maker_fee=i80f48.I80F48.from_json(obj["maker_fee"]),
padding2=obj["padding2"],
maker_timestamp=obj["maker_timestamp"],
taker=PublicKey(obj["taker"]),
taker_order_id=obj["taker_order_id"],
padding3=obj["padding3"],
taker_client_order_id=obj["taker_client_order_id"],
taker_fee=i80f48.I80F48.from_json(obj["taker_fee"]),
padding4=obj["padding4"],
price=obj["price"],
quantity=obj["quantity"],
maker_client_order_id=obj["maker_client_order_id"],
maker_fee=obj["maker_fee"],
taker_fee=obj["taker_fee"],
reserved=obj["reserved"],
)

View File

@ -13,6 +13,10 @@ class MaintJSON(typing.TypedDict):
kind: typing.Literal["Maint"]
class LiquidationEndJSON(typing.TypedDict):
kind: typing.Literal["LiquidationEnd"]
@dataclass
class Init:
discriminator: typing.ClassVar = 0
@ -49,8 +53,26 @@ class Maint:
}
HealthTypeKind = typing.Union[Init, Maint]
HealthTypeJSON = typing.Union[InitJSON, MaintJSON]
@dataclass
class LiquidationEnd:
discriminator: typing.ClassVar = 2
kind: typing.ClassVar = "LiquidationEnd"
@classmethod
def to_json(cls) -> LiquidationEndJSON:
return LiquidationEndJSON(
kind="LiquidationEnd",
)
@classmethod
def to_encodable(cls) -> dict:
return {
"LiquidationEnd": {},
}
HealthTypeKind = typing.Union[Init, Maint, LiquidationEnd]
HealthTypeJSON = typing.Union[InitJSON, MaintJSON, LiquidationEndJSON]
def from_decoded(obj: dict) -> HealthTypeKind:
@ -60,6 +82,8 @@ def from_decoded(obj: dict) -> HealthTypeKind:
return Init()
if "Maint" in obj:
return Maint()
if "LiquidationEnd" in obj:
return LiquidationEnd()
raise ValueError("Invalid enum object")
@ -68,8 +92,14 @@ def from_json(obj: HealthTypeJSON) -> HealthTypeKind:
return Init()
if obj["kind"] == "Maint":
return Maint()
if obj["kind"] == "LiquidationEnd":
return LiquidationEnd()
kind = obj["kind"]
raise ValueError(f"Unrecognized enum kind: {kind}")
layout = EnumForCodegen("Init" / borsh.CStruct(), "Maint" / borsh.CStruct())
layout = EnumForCodegen(
"Init" / borsh.CStruct(),
"Maint" / borsh.CStruct(),
"LiquidationEnd" / borsh.CStruct(),
)

View File

@ -3,7 +3,6 @@ import typing
from dataclasses import dataclass
from construct import Container
import borsh_construct as borsh
from decimal import Decimal, getcontext
class I80F48JSON(typing.TypedDict):
@ -15,10 +14,6 @@ class I80F48:
layout: typing.ClassVar = borsh.CStruct("val" / borsh.I128)
val: int
MAX_SIZE = 128
FRACTIONS = 48
MULTIPLIER_BIG = 2 ** 48
@classmethod
def from_decoded(cls, obj: Container) -> "I80F48":
return cls(val=obj.val)
@ -32,9 +27,3 @@ class I80F48:
@classmethod
def from_json(cls, obj: I80F48JSON) -> "I80F48":
return cls(val=obj["val"])
def parsed(self):
return float(Decimal(self.val) / Decimal(self.MULTIPLIER_BIG))
def __float__(self):
return float(Decimal(self.val) / Decimal(self.MULTIPLIER_BIG))

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ class LeafNodeJSON(typing.TypedDict):
quantity: int
timestamp: int
peg_limit: int
client_order_id: int
reserved: list[int]
@ -36,7 +37,8 @@ class LeafNode:
"quantity" / borsh.I64,
"timestamp" / borsh.U64,
"peg_limit" / borsh.I64,
"reserved" / borsh.U8[40],
"client_order_id" / borsh.U64,
"reserved" / borsh.U8[32],
)
tag: int
owner_slot: int
@ -49,6 +51,7 @@ class LeafNode:
quantity: int
timestamp: int
peg_limit: int
client_order_id: int
reserved: list[int]
@classmethod
@ -65,6 +68,7 @@ class LeafNode:
quantity=obj.quantity,
timestamp=obj.timestamp,
peg_limit=obj.peg_limit,
client_order_id=obj.client_order_id,
reserved=obj.reserved,
)
@ -81,6 +85,7 @@ class LeafNode:
"quantity": self.quantity,
"timestamp": self.timestamp,
"peg_limit": self.peg_limit,
"client_order_id": self.client_order_id,
"reserved": self.reserved,
}
@ -97,6 +102,7 @@ class LeafNode:
"quantity": self.quantity,
"timestamp": self.timestamp,
"peg_limit": self.peg_limit,
"client_order_id": self.client_order_id,
"reserved": self.reserved,
}
@ -114,5 +120,6 @@ class LeafNode:
quantity=obj["quantity"],
timestamp=obj["timestamp"],
peg_limit=obj["peg_limit"],
client_order_id=obj["client_order_id"],
reserved=obj["reserved"],
)

View File

@ -20,6 +20,10 @@ class MangoAccountFixedJSON(typing.TypedDict):
net_deposits: int
perp_spot_transfers: int
health_region_begin_init_health: int
frozen_until: int
buyback_fees_accrued_current: int
buyback_fees_accrued_previous: int
buyback_fees_expiry_timestamp: int
reserved: list[int]
@ -38,7 +42,11 @@ class MangoAccountFixed:
"net_deposits" / borsh.I64,
"perp_spot_transfers" / borsh.I64,
"health_region_begin_init_health" / borsh.I64,
"reserved" / borsh.U8[240],
"frozen_until" / borsh.U64,
"buyback_fees_accrued_current" / borsh.U64,
"buyback_fees_accrued_previous" / borsh.U64,
"buyback_fees_expiry_timestamp" / borsh.U64,
"reserved" / borsh.U8[208],
)
group: PublicKey
owner: PublicKey
@ -52,6 +60,10 @@ class MangoAccountFixed:
net_deposits: int
perp_spot_transfers: int
health_region_begin_init_health: int
frozen_until: int
buyback_fees_accrued_current: int
buyback_fees_accrued_previous: int
buyback_fees_expiry_timestamp: int
reserved: list[int]
@classmethod
@ -69,6 +81,10 @@ class MangoAccountFixed:
net_deposits=obj.net_deposits,
perp_spot_transfers=obj.perp_spot_transfers,
health_region_begin_init_health=obj.health_region_begin_init_health,
frozen_until=obj.frozen_until,
buyback_fees_accrued_current=obj.buyback_fees_accrued_current,
buyback_fees_accrued_previous=obj.buyback_fees_accrued_previous,
buyback_fees_expiry_timestamp=obj.buyback_fees_expiry_timestamp,
reserved=obj.reserved,
)
@ -86,6 +102,10 @@ class MangoAccountFixed:
"net_deposits": self.net_deposits,
"perp_spot_transfers": self.perp_spot_transfers,
"health_region_begin_init_health": self.health_region_begin_init_health,
"frozen_until": self.frozen_until,
"buyback_fees_accrued_current": self.buyback_fees_accrued_current,
"buyback_fees_accrued_previous": self.buyback_fees_accrued_previous,
"buyback_fees_expiry_timestamp": self.buyback_fees_expiry_timestamp,
"reserved": self.reserved,
}
@ -103,6 +123,10 @@ class MangoAccountFixed:
"net_deposits": self.net_deposits,
"perp_spot_transfers": self.perp_spot_transfers,
"health_region_begin_init_health": self.health_region_begin_init_health,
"frozen_until": self.frozen_until,
"buyback_fees_accrued_current": self.buyback_fees_accrued_current,
"buyback_fees_accrued_previous": self.buyback_fees_accrued_previous,
"buyback_fees_expiry_timestamp": self.buyback_fees_expiry_timestamp,
"reserved": self.reserved,
}
@ -121,5 +145,9 @@ class MangoAccountFixed:
net_deposits=obj["net_deposits"],
perp_spot_transfers=obj["perp_spot_transfers"],
health_region_begin_init_health=obj["health_region_begin_init_health"],
frozen_until=obj["frozen_until"],
buyback_fees_accrued_current=obj["buyback_fees_accrued_current"],
buyback_fees_accrued_previous=obj["buyback_fees_accrued_previous"],
buyback_fees_expiry_timestamp=obj["buyback_fees_expiry_timestamp"],
reserved=obj["reserved"],
)

View File

@ -11,10 +11,12 @@ import borsh_construct as borsh
class PerpInfoJSON(typing.TypedDict):
perp_market_index: int
maint_asset_weight: i80f48.I80F48JSON
init_asset_weight: i80f48.I80F48JSON
maint_liab_weight: i80f48.I80F48JSON
init_liab_weight: i80f48.I80F48JSON
maint_base_asset_weight: i80f48.I80F48JSON
init_base_asset_weight: i80f48.I80F48JSON
maint_base_liab_weight: i80f48.I80F48JSON
init_base_liab_weight: i80f48.I80F48JSON
maint_overall_asset_weight: i80f48.I80F48JSON
init_overall_asset_weight: i80f48.I80F48JSON
base_lot_size: int
base_lots: int
bids_base_lots: int
@ -22,17 +24,19 @@ class PerpInfoJSON(typing.TypedDict):
quote: i80f48.I80F48JSON
prices: prices.PricesJSON
has_open_orders: bool
trusted_market: bool
has_open_fills: bool
@dataclass
class PerpInfo:
layout: typing.ClassVar = borsh.CStruct(
"perp_market_index" / borsh.U16,
"maint_asset_weight" / i80f48.I80F48.layout,
"init_asset_weight" / i80f48.I80F48.layout,
"maint_liab_weight" / i80f48.I80F48.layout,
"init_liab_weight" / i80f48.I80F48.layout,
"maint_base_asset_weight" / i80f48.I80F48.layout,
"init_base_asset_weight" / i80f48.I80F48.layout,
"maint_base_liab_weight" / i80f48.I80F48.layout,
"init_base_liab_weight" / i80f48.I80F48.layout,
"maint_overall_asset_weight" / i80f48.I80F48.layout,
"init_overall_asset_weight" / i80f48.I80F48.layout,
"base_lot_size" / borsh.I64,
"base_lots" / borsh.I64,
"bids_base_lots" / borsh.I64,
@ -40,13 +44,15 @@ class PerpInfo:
"quote" / i80f48.I80F48.layout,
"prices" / prices.Prices.layout,
"has_open_orders" / borsh.Bool,
"trusted_market" / borsh.Bool,
"has_open_fills" / borsh.Bool,
)
perp_market_index: int
maint_asset_weight: i80f48.I80F48
init_asset_weight: i80f48.I80F48
maint_liab_weight: i80f48.I80F48
init_liab_weight: i80f48.I80F48
maint_base_asset_weight: i80f48.I80F48
init_base_asset_weight: i80f48.I80F48
maint_base_liab_weight: i80f48.I80F48
init_base_liab_weight: i80f48.I80F48
maint_overall_asset_weight: i80f48.I80F48
init_overall_asset_weight: i80f48.I80F48
base_lot_size: int
base_lots: int
bids_base_lots: int
@ -54,16 +60,28 @@ class PerpInfo:
quote: i80f48.I80F48
prices: prices.Prices
has_open_orders: bool
trusted_market: bool
has_open_fills: bool
@classmethod
def from_decoded(cls, obj: Container) -> "PerpInfo":
return cls(
perp_market_index=obj.perp_market_index,
maint_asset_weight=i80f48.I80F48.from_decoded(obj.maint_asset_weight),
init_asset_weight=i80f48.I80F48.from_decoded(obj.init_asset_weight),
maint_liab_weight=i80f48.I80F48.from_decoded(obj.maint_liab_weight),
init_liab_weight=i80f48.I80F48.from_decoded(obj.init_liab_weight),
maint_base_asset_weight=i80f48.I80F48.from_decoded(
obj.maint_base_asset_weight
),
init_base_asset_weight=i80f48.I80F48.from_decoded(
obj.init_base_asset_weight
),
maint_base_liab_weight=i80f48.I80F48.from_decoded(
obj.maint_base_liab_weight
),
init_base_liab_weight=i80f48.I80F48.from_decoded(obj.init_base_liab_weight),
maint_overall_asset_weight=i80f48.I80F48.from_decoded(
obj.maint_overall_asset_weight
),
init_overall_asset_weight=i80f48.I80F48.from_decoded(
obj.init_overall_asset_weight
),
base_lot_size=obj.base_lot_size,
base_lots=obj.base_lots,
bids_base_lots=obj.bids_base_lots,
@ -71,16 +89,18 @@ class PerpInfo:
quote=i80f48.I80F48.from_decoded(obj.quote),
prices=prices.Prices.from_decoded(obj.prices),
has_open_orders=obj.has_open_orders,
trusted_market=obj.trusted_market,
has_open_fills=obj.has_open_fills,
)
def to_encodable(self) -> dict[str, typing.Any]:
return {
"perp_market_index": self.perp_market_index,
"maint_asset_weight": self.maint_asset_weight.to_encodable(),
"init_asset_weight": self.init_asset_weight.to_encodable(),
"maint_liab_weight": self.maint_liab_weight.to_encodable(),
"init_liab_weight": self.init_liab_weight.to_encodable(),
"maint_base_asset_weight": self.maint_base_asset_weight.to_encodable(),
"init_base_asset_weight": self.init_base_asset_weight.to_encodable(),
"maint_base_liab_weight": self.maint_base_liab_weight.to_encodable(),
"init_base_liab_weight": self.init_base_liab_weight.to_encodable(),
"maint_overall_asset_weight": self.maint_overall_asset_weight.to_encodable(),
"init_overall_asset_weight": self.init_overall_asset_weight.to_encodable(),
"base_lot_size": self.base_lot_size,
"base_lots": self.base_lots,
"bids_base_lots": self.bids_base_lots,
@ -88,16 +108,18 @@ class PerpInfo:
"quote": self.quote.to_encodable(),
"prices": self.prices.to_encodable(),
"has_open_orders": self.has_open_orders,
"trusted_market": self.trusted_market,
"has_open_fills": self.has_open_fills,
}
def to_json(self) -> PerpInfoJSON:
return {
"perp_market_index": self.perp_market_index,
"maint_asset_weight": self.maint_asset_weight.to_json(),
"init_asset_weight": self.init_asset_weight.to_json(),
"maint_liab_weight": self.maint_liab_weight.to_json(),
"init_liab_weight": self.init_liab_weight.to_json(),
"maint_base_asset_weight": self.maint_base_asset_weight.to_json(),
"init_base_asset_weight": self.init_base_asset_weight.to_json(),
"maint_base_liab_weight": self.maint_base_liab_weight.to_json(),
"init_base_liab_weight": self.init_base_liab_weight.to_json(),
"maint_overall_asset_weight": self.maint_overall_asset_weight.to_json(),
"init_overall_asset_weight": self.init_overall_asset_weight.to_json(),
"base_lot_size": self.base_lot_size,
"base_lots": self.base_lots,
"bids_base_lots": self.bids_base_lots,
@ -105,17 +127,29 @@ class PerpInfo:
"quote": self.quote.to_json(),
"prices": self.prices.to_json(),
"has_open_orders": self.has_open_orders,
"trusted_market": self.trusted_market,
"has_open_fills": self.has_open_fills,
}
@classmethod
def from_json(cls, obj: PerpInfoJSON) -> "PerpInfo":
return cls(
perp_market_index=obj["perp_market_index"],
maint_asset_weight=i80f48.I80F48.from_json(obj["maint_asset_weight"]),
init_asset_weight=i80f48.I80F48.from_json(obj["init_asset_weight"]),
maint_liab_weight=i80f48.I80F48.from_json(obj["maint_liab_weight"]),
init_liab_weight=i80f48.I80F48.from_json(obj["init_liab_weight"]),
maint_base_asset_weight=i80f48.I80F48.from_json(
obj["maint_base_asset_weight"]
),
init_base_asset_weight=i80f48.I80F48.from_json(
obj["init_base_asset_weight"]
),
maint_base_liab_weight=i80f48.I80F48.from_json(
obj["maint_base_liab_weight"]
),
init_base_liab_weight=i80f48.I80F48.from_json(obj["init_base_liab_weight"]),
maint_overall_asset_weight=i80f48.I80F48.from_json(
obj["maint_overall_asset_weight"]
),
init_overall_asset_weight=i80f48.I80F48.from_json(
obj["init_overall_asset_weight"]
),
base_lot_size=obj["base_lot_size"],
base_lots=obj["base_lots"],
bids_base_lots=obj["bids_base_lots"],
@ -123,5 +157,5 @@ class PerpInfo:
quote=i80f48.I80F48.from_json(obj["quote"]),
prices=prices.Prices.from_json(obj["prices"]),
has_open_orders=obj["has_open_orders"],
trusted_market=obj["trusted_market"],
has_open_fills=obj["has_open_fills"],
)

View File

@ -28,7 +28,10 @@ class PerpPositionJSON(typing.TypedDict):
taker_volume: int
perp_spot_transfers: int
avg_entry_price_per_base_lot: float
realized_pnl_native: i80f48.I80F48JSON
realized_trade_pnl_native: i80f48.I80F48JSON
realized_other_pnl_native: i80f48.I80F48JSON
settle_pnl_limit_realized_trade: int
realized_pnl_for_position_native: i80f48.I80F48JSON
reserved: list[int]
@ -54,8 +57,11 @@ class PerpPosition:
"taker_volume" / borsh.U64,
"perp_spot_transfers" / borsh.I64,
"avg_entry_price_per_base_lot" / borsh.F64,
"realized_pnl_native" / i80f48.I80F48.layout,
"reserved" / borsh.U8[128],
"realized_trade_pnl_native" / i80f48.I80F48.layout,
"realized_other_pnl_native" / i80f48.I80F48.layout,
"settle_pnl_limit_realized_trade" / borsh.I64,
"realized_pnl_for_position_native" / i80f48.I80F48.layout,
"reserved" / borsh.U8[88],
)
market_index: int
padding: list[int]
@ -76,7 +82,10 @@ class PerpPosition:
taker_volume: int
perp_spot_transfers: int
avg_entry_price_per_base_lot: float
realized_pnl_native: i80f48.I80F48
realized_trade_pnl_native: i80f48.I80F48
realized_other_pnl_native: i80f48.I80F48
settle_pnl_limit_realized_trade: int
realized_pnl_for_position_native: i80f48.I80F48
reserved: list[int]
@classmethod
@ -101,7 +110,16 @@ class PerpPosition:
taker_volume=obj.taker_volume,
perp_spot_transfers=obj.perp_spot_transfers,
avg_entry_price_per_base_lot=obj.avg_entry_price_per_base_lot,
realized_pnl_native=i80f48.I80F48.from_decoded(obj.realized_pnl_native),
realized_trade_pnl_native=i80f48.I80F48.from_decoded(
obj.realized_trade_pnl_native
),
realized_other_pnl_native=i80f48.I80F48.from_decoded(
obj.realized_other_pnl_native
),
settle_pnl_limit_realized_trade=obj.settle_pnl_limit_realized_trade,
realized_pnl_for_position_native=i80f48.I80F48.from_decoded(
obj.realized_pnl_for_position_native
),
reserved=obj.reserved,
)
@ -126,7 +144,10 @@ class PerpPosition:
"taker_volume": self.taker_volume,
"perp_spot_transfers": self.perp_spot_transfers,
"avg_entry_price_per_base_lot": self.avg_entry_price_per_base_lot,
"realized_pnl_native": self.realized_pnl_native.to_encodable(),
"realized_trade_pnl_native": self.realized_trade_pnl_native.to_encodable(),
"realized_other_pnl_native": self.realized_other_pnl_native.to_encodable(),
"settle_pnl_limit_realized_trade": self.settle_pnl_limit_realized_trade,
"realized_pnl_for_position_native": self.realized_pnl_for_position_native.to_encodable(),
"reserved": self.reserved,
}
@ -151,7 +172,10 @@ class PerpPosition:
"taker_volume": self.taker_volume,
"perp_spot_transfers": self.perp_spot_transfers,
"avg_entry_price_per_base_lot": self.avg_entry_price_per_base_lot,
"realized_pnl_native": self.realized_pnl_native.to_json(),
"realized_trade_pnl_native": self.realized_trade_pnl_native.to_json(),
"realized_other_pnl_native": self.realized_other_pnl_native.to_json(),
"settle_pnl_limit_realized_trade": self.settle_pnl_limit_realized_trade,
"realized_pnl_for_position_native": self.realized_pnl_for_position_native.to_json(),
"reserved": self.reserved,
}
@ -179,6 +203,15 @@ class PerpPosition:
taker_volume=obj["taker_volume"],
perp_spot_transfers=obj["perp_spot_transfers"],
avg_entry_price_per_base_lot=obj["avg_entry_price_per_base_lot"],
realized_pnl_native=i80f48.I80F48.from_json(obj["realized_pnl_native"]),
realized_trade_pnl_native=i80f48.I80F48.from_json(
obj["realized_trade_pnl_native"]
),
realized_other_pnl_native=i80f48.I80F48.from_json(
obj["realized_other_pnl_native"]
),
settle_pnl_limit_realized_trade=obj["settle_pnl_limit_realized_trade"],
realized_pnl_for_position_native=i80f48.I80F48.from_json(
obj["realized_pnl_for_position_native"]
),
reserved=obj["reserved"],
)

View File

@ -14,6 +14,7 @@ class Serum3InfoJSON(typing.TypedDict):
base_index: int
quote_index: int
market_index: int
has_zero_funds: bool
@dataclass
@ -24,12 +25,14 @@ class Serum3Info:
"base_index" / borsh.U64,
"quote_index" / borsh.U64,
"market_index" / borsh.U16,
"has_zero_funds" / borsh.Bool,
)
reserved_base: i80f48.I80F48
reserved_quote: i80f48.I80F48
base_index: int
quote_index: int
market_index: int
has_zero_funds: bool
@classmethod
def from_decoded(cls, obj: Container) -> "Serum3Info":
@ -39,6 +42,7 @@ class Serum3Info:
base_index=obj.base_index,
quote_index=obj.quote_index,
market_index=obj.market_index,
has_zero_funds=obj.has_zero_funds,
)
def to_encodable(self) -> dict[str, typing.Any]:
@ -48,6 +52,7 @@ class Serum3Info:
"base_index": self.base_index,
"quote_index": self.quote_index,
"market_index": self.market_index,
"has_zero_funds": self.has_zero_funds,
}
def to_json(self) -> Serum3InfoJSON:
@ -57,6 +62,7 @@ class Serum3Info:
"base_index": self.base_index,
"quote_index": self.quote_index,
"market_index": self.market_index,
"has_zero_funds": self.has_zero_funds,
}
@classmethod
@ -67,4 +73,5 @@ class Serum3Info:
base_index=obj["base_index"],
quote_index=obj["quote_index"],
market_index=obj["market_index"],
has_zero_funds=obj["has_zero_funds"],
)

View File

@ -13,8 +13,10 @@ class TokenInfoJSON(typing.TypedDict):
token_index: int
maint_asset_weight: i80f48.I80F48JSON
init_asset_weight: i80f48.I80F48JSON
init_scaled_asset_weight: i80f48.I80F48JSON
maint_liab_weight: i80f48.I80F48JSON
init_liab_weight: i80f48.I80F48JSON
init_scaled_liab_weight: i80f48.I80F48JSON
prices: prices.PricesJSON
balance_native: i80f48.I80F48JSON
@ -25,16 +27,20 @@ class TokenInfo:
"token_index" / borsh.U16,
"maint_asset_weight" / i80f48.I80F48.layout,
"init_asset_weight" / i80f48.I80F48.layout,
"init_scaled_asset_weight" / i80f48.I80F48.layout,
"maint_liab_weight" / i80f48.I80F48.layout,
"init_liab_weight" / i80f48.I80F48.layout,
"init_scaled_liab_weight" / i80f48.I80F48.layout,
"prices" / prices.Prices.layout,
"balance_native" / i80f48.I80F48.layout,
)
token_index: int
maint_asset_weight: i80f48.I80F48
init_asset_weight: i80f48.I80F48
init_scaled_asset_weight: i80f48.I80F48
maint_liab_weight: i80f48.I80F48
init_liab_weight: i80f48.I80F48
init_scaled_liab_weight: i80f48.I80F48
prices: prices.Prices
balance_native: i80f48.I80F48
@ -44,8 +50,14 @@ class TokenInfo:
token_index=obj.token_index,
maint_asset_weight=i80f48.I80F48.from_decoded(obj.maint_asset_weight),
init_asset_weight=i80f48.I80F48.from_decoded(obj.init_asset_weight),
init_scaled_asset_weight=i80f48.I80F48.from_decoded(
obj.init_scaled_asset_weight
),
maint_liab_weight=i80f48.I80F48.from_decoded(obj.maint_liab_weight),
init_liab_weight=i80f48.I80F48.from_decoded(obj.init_liab_weight),
init_scaled_liab_weight=i80f48.I80F48.from_decoded(
obj.init_scaled_liab_weight
),
prices=prices.Prices.from_decoded(obj.prices),
balance_native=i80f48.I80F48.from_decoded(obj.balance_native),
)
@ -55,8 +67,10 @@ class TokenInfo:
"token_index": self.token_index,
"maint_asset_weight": self.maint_asset_weight.to_encodable(),
"init_asset_weight": self.init_asset_weight.to_encodable(),
"init_scaled_asset_weight": self.init_scaled_asset_weight.to_encodable(),
"maint_liab_weight": self.maint_liab_weight.to_encodable(),
"init_liab_weight": self.init_liab_weight.to_encodable(),
"init_scaled_liab_weight": self.init_scaled_liab_weight.to_encodable(),
"prices": self.prices.to_encodable(),
"balance_native": self.balance_native.to_encodable(),
}
@ -66,8 +80,10 @@ class TokenInfo:
"token_index": self.token_index,
"maint_asset_weight": self.maint_asset_weight.to_json(),
"init_asset_weight": self.init_asset_weight.to_json(),
"init_scaled_asset_weight": self.init_scaled_asset_weight.to_json(),
"maint_liab_weight": self.maint_liab_weight.to_json(),
"init_liab_weight": self.init_liab_weight.to_json(),
"init_scaled_liab_weight": self.init_scaled_liab_weight.to_json(),
"prices": self.prices.to_json(),
"balance_native": self.balance_native.to_json(),
}
@ -78,8 +94,14 @@ class TokenInfo:
token_index=obj["token_index"],
maint_asset_weight=i80f48.I80F48.from_json(obj["maint_asset_weight"]),
init_asset_weight=i80f48.I80F48.from_json(obj["init_asset_weight"]),
init_scaled_asset_weight=i80f48.I80F48.from_json(
obj["init_scaled_asset_weight"]
),
maint_liab_weight=i80f48.I80F48.from_json(obj["maint_liab_weight"]),
init_liab_weight=i80f48.I80F48.from_json(obj["init_liab_weight"]),
init_scaled_liab_weight=i80f48.I80F48.from_json(
obj["init_scaled_liab_weight"]
),
prices=prices.Prices.from_json(obj["prices"]),
balance_native=i80f48.I80F48.from_json(obj["balance_native"]),
)