-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial logic to scale initial weight * add cargo test * add initial sdk logic * tweak field comments * program: add twap to initial asset weight calc * inital work for worst case to account for free collateral contribution * add strict oracle price * tests work * used cache values from calc worst case token amounts * rm comment * use free collateral contribution in place_spot_order * use strict quote in calculate_perp_position_value_and_pnl * remove w bounds from pnl calc * expand worst case tests * test the twap logic in worst case calc * some simplifications * add some tests for scaled asset weight using twap * make calc max spot order size work * tweak place_spot_order on how it checks if spot order is risk decreasing * always do margin check in place order * log margin type in meets_place_order_margin_requirement * fix a bug * better logic for deciding if trigger order is risk increasing * sdk: rework calculateWorstCaseTokenAmounts * place order params keep track of risk increasing * tweaks * tweak some tests * add some comments * tweak some tests * calculate_max_withdrawable_amount use spot_market.get_asset_weight * fix ts tests * get_asset_weight just takes oracle price * calculateAssetWeight doesn't look at twap * add strictOraclePrice * add strictOraclePrice * add some sdk tests for worst case token amount calc * add MarginCalculation struct * add get_margin_ratio to MarginCalculation * make strict() modifier for MarginContext * dont deconstruct margin calculation in liq ix * apply max if fee * make margin_requirement_with_buffer private * if fee for spot liquidation still lets user outta liq territory * rm comment * add new max if fee calcs * remove calculate_if_fee fn * remove logic to track margin ratio * tweak language for tracking mkt margin requirement * add test for calculate_perp_if_fee * calculate_spot_if_fee tests * fix bug w tracked_market_margin_shortage * change how margin is check in fills * extra safety check in MarginCalculation * make MarketIdentifier a struct * add back isolated liability * fix tests/liquidateSpotSocialLoss.ts (no if liq fee) * fix sdk/src/user.ts * fix tests/insuranceFundStake.ts * prettify tests/insuranceFundStake.ts * try fix liq perp tests * yarn prettify:fix * fix merge * try fix insurance fund stake test * CHANGELOG --------- Co-authored-by: 0xbigz <[email protected]>
- Loading branch information
1 parent
383574c
commit ce80b36
Showing
21 changed files
with
2,174 additions
and
1,252 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.