Skip to content

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

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Bigz/adl #209

wants to merge 26 commits into from

Conversation

0xbigz
Copy link
Member

@0xbigz 0xbigz commented Oct 24, 2022

No description provided.

let quote_entry = (-market.amm.quote_entry_amount_long)
.safe_add(market.amm.quote_entry_amount_short)?
.safe_add(
loss_to_socialize
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this extra max?

Copy link
Member Author

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 {
Copy link
Member

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 mean is good or bad depending on long versus shorts

.amm
.order_tick_size
.cast::<i128>()?
.safe_mul(MAX_FUNDING_SOCIAL_LOSS_MULT)?
Copy link
Member

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?

Copy link
Member Author

@0xbigz 0xbigz Oct 29, 2022

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()?)?;
Copy link
Member

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

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants