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

Create Input for Adjusting Isolated Position's Margin #326

Merged

Conversation

jaredvu
Copy link
Contributor

@jaredvu jaredvu commented Apr 30, 2024

  • Add AdjustIsolatedMarginInput InputType and introduced to Input state
  • Add commitAdjustIsolatedMargin to initiate transfer between parent and child subaccounts
  • Update Input docs
  • Added test to check parent and child subaccounts' quoteBalance

Copy link

linear bot commented Apr 30, 2024

@jaredvu jaredvu requested a review from prashanDYDX May 6, 2024 22:56
existing.errorMessage != errorMessage ||
existing.fee != fee
) {
AdjustIsolatedMarginInput(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] use named args

@@ -0,0 +1,136 @@
package exchange.dydx.abacus.calculator

import exchange.dydx.abacus.output.input.IsolatedMarginAdjustmentType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use static imports for Add and Remove specifically to make the code easier to read below.

import exchange.dydx.abacus.output.input.IsolatedMarginAdjustmentType.Add
import exchange.dydx.abacus.output.input.IsolatedMarginAdjustmentType.Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: wdym by easier to read? The import would be easier to read?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like at usage sites you now get:

when(type) {
  Add -> ...
  Remove -> ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's pretty cool! I don't have a preference on either though. With the static import I think we would lose some readability unless you double check the enum, and what happens if there are multiple enums with the same .name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah up to you, i don't feel strongly.

re multiple enums: you have to explicitly say what type you're casting the value to, so that ends up not being an issue. ex:

val type = "Add"
when(IsolatedMarginAdjustmentType.valueOf(type)) {
  Add -> ...
  Remove -> ...
}


@JsExport
@Serializable
enum class AdjustIsolatedMarginInputField(val rawValue: String) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely used by clients right? so can use built-in conversion? i guess you'd run into the enum naming rule (maybe disable?)

@jaredvu jaredvu merged commit 1471edd into main May 8, 2024
3 checks passed
@jaredvu jaredvu deleted the jared/tra-183-create-input-for-adjusting-position-margin branch May 8, 2024 20:47
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.

3 participants