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

draft/wip/do not review #607

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.9.6"
version = "1.9.11"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,7 @@ internal object MarginCalculator {

// Cap targetLeverage to 98% of max leverage
val adjustedTargetLeverage = if (maxLeverageForMarket != null) {
val cappedLeverage = maxLeverageForMarket * MAX_LEVERAGE_BUFFER_PERCENT
min(targetLeverage, cappedLeverage)
maxLeverageForMarket * MAX_LEVERAGE_BUFFER_PERCENT
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import exchange.dydx.abacus.utils.Numeric
import exchange.dydx.abacus.utils.mutable
import exchange.dydx.abacus.utils.safeSet
import kotlin.math.max
import exchange.dydx.abacus.utils.Logger

internal enum class CalculationPeriod(val rawValue: String) {
current("current"),
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ internal class TradeInputOptionsCalculator(
options.postOnlyTooltip = buildToolTip(postOnlyPromptFromTrade(trade.type))
}

options.needsTargetLeverage = trade.marginMode == MarginMode.Isolated
options.needsTargetLeverage = false

return options
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ internal fun TradingStateMachine.tradeInMarket(
}

val input = this.input?.mutable() ?: mutableMapOf()

if (parser.asString(parser.value(input, "trade.marketId")) == marketId) {
if (parser.asString(parser.value(input, "current")) == "trade") {
return StateResponse(state, StateChanges(iListOf()), null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import kotlinx.serialization.json.jsonObject
import kotlin.math.max
import kotlin.math.min
import kotlin.time.Duration.Companion.days
import exchange.dydx.abacus.output.input.MarginMode

@Suppress("UNCHECKED_CAST")
@JsExport
Expand Down Expand Up @@ -1070,11 +1071,17 @@ open class TradingStateMachine(
val marketId =
parser.asString(parser.value(modified, "trade.marketId"))
if (subaccountNumber != null && marketId != null) {
val marginMode = parser.asString(parser.value(modified, "marginMode"))?.let { MarginMode.invoke(it) }
val subaccount = if (marginMode == MarginMode.Cross) {
parser.asNativeMap(parser.value(this.account, "subaccounts.$subaccountNumber"))
} else {
parser.asNativeMap(parser.value(this.account, "groupedSubaccounts.$subaccountNumber"))
}
val leverage =
parser.asDouble(
parser.value(
this.account,
"subaccounts.$subaccountNumber.openPositions.$marketId.leverage.postOrder",
subaccount,
"openPositions.$marketId.leverage.postOrder",
),
)
modified.safeSet("trade.size.leverage", leverage)
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'v4_abacus'
spec.version = '1.9.6'
spec.version = '1.9.11'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down