Skip to content
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

Feature/tra 327 isolated margin delta #409

Merged
merged 35 commits into from
Jun 7, 2024

Conversation

johnqh
Copy link
Contributor

@johnqh johnqh commented May 31, 2024

Description

Will add a brief description of the results for each file changed to aid in code review

  • AccountCalculator

    • Move mergeChildPendingPositions outside of if/else conditional so that we are always attempting to process child pending positions. It was originally in the ternary because it was thought that there would be no need to merge pendingPositions if a regular position existed. Since Abacus adds a "dummy" position when in a market, our pendingPositions were getting lost.
  • AccountTransformer

    • Apply deltas to the appropriate subaccount, when attempting to trade previously we were only applying deltas to subaccount 0.
  • MarginModeCalculator

    • add additional helper functions and break out key logic so that we can use in multiple places. i.e. "finding a position or order" is applicable in multiple helper fn's exported from this file.
  • SubaccountTransformer

    • Transfer deltas will now be taken into account when trading in Isolated Margin
  • TradingStateMachine+AdjustIsolatedMargin

    • Fix validation to be inclusive of 0. Bug that I had introduced that killed the inputs if we cleared or set to 0.
  • TradingStateMachine+Markets

    • Market updates should apply changes to childSubaccounts as well (if they hold a position in that market)
  • TradingStateMachine+TradeInput

    • Fix for setting marginMode when navigating markets. We want to ensure MarginMode is never null
    • Sets targetLeverage to it's default or the abs value of existing positionLeverage
    • Update change events to include childSubaccount if applicable (this is necessary for Web to receive the updates to the childSubaccount when inputs change)
    • Adding missing new TradeInputFields to the when statement to determine when to update state.
  • TradingStateMachine+Wallet

    • Add childSubaccountNumber to change events
  • AccountInputValidator

    • Will revisit when working on supporting multiple subaccounts w/ our Validators but this is a temporary fix to skip equity checks for childSubaccountNumber. This is pretty much never applicable to the childSubaccount because the transfer will have been sent before the order is placed. This validation error blocks the start of that place order flow.
  • TradeStateValidator

    • Will revisit for the same reasons as above. Apply different checks to parentSubaccount vs childSubaccount and make the delineation more clear.

Testing Improvements ✨

  • IsolatedMarginTests

    • Add new test file purely for IsolatedMargin flows. Tried to be as descriptive and informative as possible. It would be cool if we could update our test suite to allow commenting within the test flow i.e. describe('should not ....', () => testStuff)
  • V4BaseTests

    • Add open to loadMarketsConfiguration so that it can be overridable. It is using v3 configs right now.
  • V4ParentSubaccountTests/ParentSubaccountMocks

    • Added new tests that leverage real subscription data instead of mockData from schema (prior to Indexer work being completed)
    • Added tests for different parentSubaccount states (added mocks to represent each state)
  • MarketConfigurationMock/MarketsChannelMock

    • Updated MarketsChannelMock data
    • Added ISO-USD to test Isolated Markets (Before we had just updated AVAX-USD and I had no idea wtf was going on because I was unaware we just designated AVAX to that market type for testing)

Notes

@johnqh is a godsend 👼 for catching the issues w/ all of the childSubaccount deltas ❤️ ❤️ ❤️

@johnqh johnqh requested review from jaredvu and ruixhuang May 31, 2024 23:36
@jaredvu jaredvu requested review from prashanDYDX and tyleroooo June 7, 2024 07:18
@jaredvu jaredvu merged commit cae2583 into main Jun 7, 2024
4 checks passed
@jaredvu jaredvu deleted the feature/TRA-327-isolated-margin-delta branch June 7, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants