-
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
Create Input for Adjusting Isolated Position's Margin #326
Create Input for Adjusting Isolated Position's Margin #326
Conversation
src/commonMain/kotlin/exchange.dydx.abacus/calculator/AdjustIsolatedMarginInputCalculator.kt
Outdated
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/calculator/AdjustIsolatedMarginInputCalculator.kt
Outdated
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/calculator/AdjustIsolatedMarginInputCalculator.kt
Outdated
Show resolved
Hide resolved
existing.errorMessage != errorMessage || | ||
existing.fee != fee | ||
) { | ||
AdjustIsolatedMarginInput( |
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.
[suggestion] use named args
src/commonMain/kotlin/exchange.dydx.abacus/output/input/AdjustIsolatedMarginInput.kt
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,136 @@ | |||
package exchange.dydx.abacus.calculator | |||
|
|||
import exchange.dydx.abacus.output.input.IsolatedMarginAdjustmentType |
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.
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
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.
qq: wdym by easier to read? The import would be easier to read?
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.
like at usage sites you now get:
when(type) {
Add -> ...
Remove -> ...
}
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.
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
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.
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 -> ...
}
src/commonMain/kotlin/exchange.dydx.abacus/calculator/SubaccountTransformer.kt
Outdated
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/output/input/AdjustIsolatedMarginInput.kt
Outdated
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/output/input/AdjustIsolatedMarginInput.kt
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/output/input/AdjustIsolatedMarginInput.kt
Show resolved
Hide resolved
src/commonMain/kotlin/exchange.dydx.abacus/state/manager/StateManagerAdaptor.kt
Show resolved
Hide resolved
...ain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+AdjustIsolatedMarginInput.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+AdjustIsolatedMarginInput.kt
Show resolved
Hide resolved
|
||
@JsExport | ||
@Serializable | ||
enum class AdjustIsolatedMarginInputField(val rawValue: String) { |
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.
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?)
AdjustIsolatedMarginInput
InputType
and introduced toInput
statecommitAdjustIsolatedMargin
to initiate transfer between parent and child subaccountsquoteBalance