-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
Hi team,
Thanks for the great package!
I found the current price and size calculation for the fill event (SIDE = BUY) in the below links may be wrong at least for Dex V3.
pyserum/pyserum/market/core.py
Lines 104 to 107 in d0938e9
price = (price_before_fees * self.state.base_spl_token_multiplier()) / ( | |
self.state.quote_spl_token_multiplier() * event.native_quantity_paid | |
) | |
size = event.native_quantity_paid / self.state.base_spl_token_multiplier() |
The potential update will be. Reference from
if event.event_flags.bid:
side = Side.BUY
price_before_fees = (
event.native_quantity_paid + event.native_fee_or_rebate
if event.event_flags.maker
else event.native_quantity_paid - event.native_fee_or_rebate
)
price = (price_before_fees * self.state.base_spl_token_multiplier()) / (
self.state.quote_spl_token_multiplier() * event.native_quantity_released
)
size = event.native_quantity_released / self.state.base_spl_token_multiplier()
else:
side = Side.SELL
price_before_fees = (
event.native_quantity_released - event.native_fee_or_rebate
if event.event_flags.maker
else event.native_quantity_released + event.native_fee_or_rebate
)
price = (price_before_fees * self.state.base_spl_token_multiplier()) / (
self.state.quote_spl_token_multiplier() * event.native_quantity_paid
)
size = event.native_quantity_paid / self.state.base_spl_token_multiplier()
Metadata
Metadata
Assignees
Labels
No labels