Open
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
crispheaney
requested changes
Apr 11, 2022
|
|
||
| pub fn formulaic_k( | ||
| market: &mut Market, | ||
| mark_price: u128, |
| market: &mut Market, | ||
| mark_price: u128, | ||
| oracle_price_data: &OraclePriceData, | ||
| is_oracle_valid: bool, |
| Ok(()) | ||
| } | ||
|
|
||
| pub fn formulaic_k( |
Member
There was a problem hiding this comment.
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) { |
Member
There was a problem hiding this comment.
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)?; |
Member
Author
There was a problem hiding this comment.
p * k_old = k_new (notation from a paper)
sdk/package-lock.json
Outdated
| @@ -0,0 +1,2296 @@ | |||
| { | |||
|
|
||
| price_oracle.agg.price = price; | ||
| price_oracle.agg.conf = 0; | ||
| price_oracle.valid_slot = 228506959; //todo just turned 1->2 for negative delay |
| Ok(new_peg) | ||
| } | ||
|
|
||
| pub fn calculate_mm_target_price( |
| 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; |
| .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)?, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add k update on update_funding_rate
clean up repeg logic using oracle delay for target_price weight