-
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
Static typing: Historical funding and fixing issues with isolated market orders #739
Changes from all commits
5a581c8
19337c0
15b8c11
d81f155
2dc7d54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,11 +193,12 @@ internal class SubaccountTransformerV2( | |
hasTransfer: Boolean = false, | ||
) { | ||
val deltaMarketId = delta?.marketId | ||
val positions = subaccount.openPositions | ||
val positions = subaccount.openPositions ?: mapOf() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing issue when create a new subaccount for isolated margin. |
||
|
||
val marketPosition = positions?.get(deltaMarketId) | ||
val marketPosition = positions[deltaMarketId] | ||
val modifiedDelta = if (delta != null) { | ||
val positionSize = marketPosition?.calculated?.get(CalculationPeriod.current)?.size ?: Numeric.double.ZERO | ||
val positionSize = marketPosition?.calculated?.get(CalculationPeriod.current)?.size | ||
?: Numeric.double.ZERO | ||
transformDelta( | ||
delta = delta, | ||
positionSize = positionSize, | ||
|
@@ -207,19 +208,18 @@ internal class SubaccountTransformerV2( | |
null | ||
} | ||
|
||
if (positions != null) { | ||
subaccount.openPositions = applyDeltaToPositions( | ||
positions = positions, | ||
delta = modifiedDelta, | ||
period = period, | ||
) | ||
} | ||
subaccount.openPositions = applyDeltaToPositions( | ||
positions = positions, | ||
delta = modifiedDelta, | ||
period = period, | ||
) | ||
|
||
val calculatedAtPeriod = subaccount.calculated[period] ?: InternalSubaccountCalculated() | ||
val usdcSize = modifiedDelta?.usdcSize ?: Numeric.double.ZERO | ||
if (delta != null && usdcSize != Numeric.double.ZERO) { | ||
val fee = modifiedDelta?.fee ?: Numeric.double.ZERO | ||
val quoteBalance = subaccount.calculated[CalculationPeriod.current]?.quoteBalance ?: Numeric.double.ZERO | ||
val quoteBalance = subaccount.calculated[CalculationPeriod.current]?.quoteBalance | ||
?: Numeric.double.ZERO | ||
calculatedAtPeriod.quoteBalance = quoteBalance + usdcSize + fee | ||
} else { | ||
calculatedAtPeriod.quoteBalance = null | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,8 @@ enum class ReceiptLine(val rawValue: String) { | |
CrossMarginUsage("CROSS_MARGIN_USAGE"), | ||
PositionMargin("POSITION_MARGIN"), | ||
PositionLeverage("POSITION_LEVERAGE"), | ||
LiquidationPrice("LIQUIDATION_PRICE"); | ||
LiquidationPrice("LIQUIDATION_PRICE"), | ||
TransferFee("TRANSFER_FEE"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For mobile only. FE web doesn't use this. |
||
|
||
companion object { | ||
operator fun invoke(rawValue: String) = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -865,13 +865,22 @@ internal class OnboardingSupervisor( | |
} | ||
|
||
private fun receiveTransferGas(gas: BigDecimal?) { | ||
val input = stateMachine.input | ||
val oldFee = helper.parser.asDecimal(helper.parser.value(input, "transfer.fee")) | ||
if (oldFee != gas) { | ||
val oldState = stateMachine.state | ||
val modified = input?.mutable() ?: iMapOf<String, Any>().mutable() | ||
modified.safeSet("transfer.fee", gas) | ||
update(StateChanges(iListOf(Changes.input)), oldState) | ||
if (stateMachine.staticTyping) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding processing for transfer gas |
||
val gas = helper.parser.asDouble(gas) | ||
val oldFee = stateMachine.internalState.input.transfer.fee | ||
if (oldFee != gas) { | ||
stateMachine.internalState.input.transfer.fee = gas | ||
update(StateChanges(iListOf(Changes.input)), stateMachine.state) | ||
} | ||
} else { | ||
val input = stateMachine.input | ||
val oldFee = helper.parser.asDecimal(helper.parser.value(input, "transfer.fee")) | ||
if (oldFee != gas) { | ||
val oldState = stateMachine.state | ||
val modified = input?.mutable() ?: iMapOf<String, Any>().mutable() | ||
modified.safeSet("transfer.fee", gas) | ||
update(StateChanges(iListOf(Changes.input)), oldState) | ||
} | ||
} | ||
} | ||
|
||
|
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.
For mobile only. FE web doesn't use this.