-
Notifications
You must be signed in to change notification settings - Fork 152
Bigz/adl #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
let quote_entry = (-market.amm.quote_entry_amount_long) | ||
.safe_add(market.amm.quote_entry_amount_short)? | ||
.safe_add( | ||
loss_to_socialize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on our convo, sounds like this doesnt make sense
{ | ||
-(mean_entry_basis.safe_sub(user_entry_basis.cast()?)?) | ||
} else { | ||
-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does -1 represent here?
}; | ||
|
||
let max_user_payment = if deleverage_user_stats.base_asset_amount == 0 { | ||
deleverage_user_stats.quote_asset_amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it matter if the deleverage_user has negative pnl here?
loss_to_socialize | ||
.abs() | ||
.safe_div(market.number_of_users.max(1).cast()?)? | ||
.max(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this extra max?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if loss_to_socialize
is less than market.number_of_users
. and if number_of_users
is 0 dont want to divide by 0
let base_amount = | ||
(-market.amm.base_asset_amount_short).safe_add(market.amm.base_asset_amount_long)?; | ||
|
||
let cost_basis_above_mean = if deleverage_user_stats.base_asset_amount != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is above
right terminology now? because above mea
n is good or bad depending on long versus shorts
.amm | ||
.order_tick_size | ||
.cast::<i128>()? | ||
.safe_mul(MAX_FUNDING_SOCIAL_LOSS_MULT)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how'd you decide this? if bitcoin tick size $.01, then a user would only lose $1 per base?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel like ticks is the unit of "how much amount per base does the market care about". picking the constant across all markets is tbd, but .01 * 100 / 30 => 3% (which i'd argue might be too high). so a $30 asset would ideally have a perp tick of around .001
|
||
let mean_long_pnl_per_base = mean_long_entry_basis | ||
.safe_add(oracle_price.cast()?)? | ||
.safe_div(PRICE_TO_QUOTE_PRECISION_RATIO.cast()?)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this made me think this ends up in quote precision, got kinda confused. might be better to pick a better constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is in quote precision though, "pnl" per base
No description provided.