-
Notifications
You must be signed in to change notification settings - Fork 51
Formulaic k #56
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?
Formulaic k #56
Conversation
…stributions for capped funding
…t in clearinghouse
…n order requested" This reverts commit 201fe72.
…et only returns base asset left to fill
…lised oracle price
|
|
||
| pub fn formulaic_k( | ||
| market: &mut Market, | ||
| mark_price: u128, |
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.
unused
| market: &mut Market, | ||
| mark_price: u128, | ||
| oracle_price_data: &OraclePriceData, | ||
| is_oracle_valid: bool, |
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.
unused
| Ok(()) | ||
| } | ||
|
|
||
| pub fn formulaic_k( |
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.
the name should be a verb/action e.g. formulaic_update_k
| funding_imbalance_cost | ||
| .checked_div(2) | ||
| .ok_or_else(math_error!())? | ||
| } else if market.amm.net_revenue_since_last_funding < (funding_imbalance_cost as i64) { |
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.
casting i128 to i64 can technically fail, so i'd use cast_to_i64.
Also i'd just declare it once instead of casting twice
let funding_imbalance_cost_i64 = cast_to_i64(funding_imbalance_cost)?;
| let curve_history = curve_history.unwrap(); | ||
|
|
||
| // single k scale is capped by .1% increase and .09% decrease (regardless of budget) | ||
| let (p_numer, p_denom) = amm::calculate_budgeted_k_scale(market, budget)?; |
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 p stand for?
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.
p * k_old = k_new (notation from a paper)
sdk/package-lock.json
Outdated
| @@ -0,0 +1,2296 @@ | |||
| { | |||
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.
delete
|
|
||
| price_oracle.agg.price = price; | ||
| price_oracle.agg.conf = 0; | ||
| price_oracle.valid_slot = 228506959; //todo just turned 1->2 for negative delay |
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.
delete?
| Ok(new_peg) | ||
| } | ||
|
|
||
| pub fn calculate_mm_target_price( |
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 is mm?
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.
amm, updating name
| oracle_price_data: &OraclePriceData, | ||
| ) -> ClearingHouseResult<u128> { | ||
| // calculates peg_multiplier that changing to would cost no more than budget | ||
| let oracle_delay = oracle_price_data.delay; |
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.
unused
| .checked_mul(market.base_asset_amount) | ||
| .ok_or_else(math_error!())? | ||
| .checked_div( | ||
| AMM_TO_QUOTE_PRECISION_RATIO_I128 * cast_to_i128(FUNDING_PAYMENT_PRECISION)?, |
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.
can be a constant
add k update on update_funding_rate
clean up repeg logic using oracle delay for target_price weight