-
Notifications
You must be signed in to change notification settings - Fork 15
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
v1.7.75: Add buffer and use oraclePrice to determine collateral movement #445
Merged
jaredvu
merged 7 commits into
main
from
jared/tra-404-update-collateral-calculation-to-incorporate-oracleprice-and
Jun 14, 2024
Merged
v1.7.75: Add buffer and use oraclePrice to determine collateral movement #445
jaredvu
merged 7 commits into
main
from
jared/tra-404-update-collateral-calculation-to-incorporate-oracleprice-and
Jun 14, 2024
Conversation
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
…ate-oracleprice-and' of github.com:dydxprotocol/v4-abacus into jared/tra-404-update-collateral-calculation-to-incorporate-oracleprice-and
ruixhuang
reviewed
Jun 14, 2024
// Cap targetLeverage to 98% of max leverage | ||
val adjustedTargetLeverage = if (maxLeverageForMarket != null) { | ||
val cappedLeverage = maxLeverageForMarket * MAX_LEVERAGE_BUFFER_PERCENT | ||
if (targetLeverage > cappedLeverage) { |
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: Can simplify with min()
ruixhuang
reviewed
Jun 14, 2024
val initialMarginFraction = parser.asDouble(parser.value(market, "configs.initialMarginFraction")) | ||
val effectiveImf = parser.asDouble(parser.value(market, "configs.effectiveInitialMarginFraction")) | ||
|
||
val maxLeverageForMarket = if (effectiveImf != null) { |
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.
Safer to check effectiveImf != 0.. Same on the next condition
ruixhuang
approved these changes
Jun 14, 2024
jaredvu
changed the title
Add buffer and use oraclePrice to determine collateral movement
v1.7.75: Add buffer and use oraclePrice to determine collateral movement
Jun 14, 2024
jaredvu
deleted the
jared/tra-404-update-collateral-calculation-to-incorporate-oracleprice-and
branch
June 14, 2024 23:29
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.
Description
AccountTransformer
calculateIsolatedMarginTransferAmount
. Moved calculation for transfer amount intoMarginModeCalculator
getShouldTransferCollateral
andcalculateIsolatedMarginTranasferAmount
MarginModeCalculator
getIsIncreasingPositionSize
which is used ingetShouldTransferCollateral
calculateIsolatedMarginTransferAmount
which caps the targetLeverage to 98% of Max Leverage and returnsgetTransferAmountFromTargetLeverage
TradeInputCalculator
ISOLATED
switch cases to return correct valuesgetShouldTransferCollateral
to determine whether tocalculateIsolatedMarginTransferAmount
summary.isolatedMarginTransferAmount
TradeInput
isolatedMarginTransferAmount
toTradeInputSummary
TradingStateMachine
subaccountNumber
required, it should never be nullSubaccountSupervisor
trade.summary.isolatedMarginTransferAmount
Constants
MAX_LEVERAGE_BUFFER_PERCENT
IsolatedMarginModeTests
summary.isolatedMarginTransferAmount
comparison