From 1718d084d686bad1a89ab6644d7525b68711634c Mon Sep 17 00:00:00 2001 From: aforaleka Date: Thu, 11 Apr 2024 13:51:19 -0400 Subject: [PATCH] use optimistic execution price --- .../calculator/AccountTransformer.kt | 13 +- .../calculator/SubaccountTransformer.kt | 26 ++- .../calculator/TradeInputCalculator.kt | 1 + .../state/manager/Enviroment.kt | 3 + .../utils/AnalyticsUtils.kt | 5 +- .../payload/TradeInputTests.kt | 210 +++++++++--------- .../payload/v3/V3ClosePositionTests.kt | 8 +- .../payload/v4/V4TradeInputTests.kt | 4 +- .../tests/payloads/AbacusMockData.kt | 3 +- .../tests/payloads/EnvironmentsMock.kt | 6 +- 10 files changed, 157 insertions(+), 122 deletions(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountTransformer.kt b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountTransformer.kt index c246a664e..caad0251a 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountTransformer.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountTransformer.kt @@ -13,7 +13,8 @@ class AccountTransformer() { market: Map?, parser: ParserProtocol, period: String, - usePessimisticCollateralCheck: Boolean + usePessimisticCollateralCheck: Boolean, + useOptimisticCollateralCheck: Boolean ): Map? { val modified = account?.mutable() ?: return null val subaccount = if (subaccountNumber != null) { @@ -27,7 +28,15 @@ class AccountTransformer() { null } val modifiedSubaccount = - subaccountTransformer.applyTradeToSubaccount(subaccount, trade, market, parser, period, usePessimisticCollateralCheck) + subaccountTransformer.applyTradeToSubaccount( + subaccount, + trade, + market, + parser, + period, + usePessimisticCollateralCheck, + useOptimisticCollateralCheck, + ) modified.safeSet("subaccounts.$subaccountNumber", modifiedSubaccount) return modified } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/SubaccountTransformer.kt b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/SubaccountTransformer.kt index 508283b82..ab48261c1 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/SubaccountTransformer.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/SubaccountTransformer.kt @@ -29,15 +29,22 @@ internal class SubaccountTransformer { limitPrice: Double?, isBuying: Boolean, usePessimisticPrice: Boolean, + useOptimisticPrice: Boolean, ): Double? { - if (usePessimisticPrice) { - oraclePrice?.let { oraclePrice -> - limitPrice?.let { limitPrice -> + oraclePrice?.let { oraclePrice -> + limitPrice?.let { limitPrice -> + if (usePessimisticPrice) { return if (isBuying) { max(oraclePrice, limitPrice) } else { min(oraclePrice, limitPrice) } + } else if (useOptimisticPrice) { + return if (isBuying) { + min(oraclePrice, limitPrice) + } else { + max(oraclePrice, limitPrice) + } } } } @@ -49,6 +56,7 @@ internal class SubaccountTransformer { trade: Map, market: Map?, usePessimisticCollateralCheck: Boolean, + useOptimisticCollateralCheck: Boolean, ): Map? { val marketId = parser.asString(trade["marketId"]) val side = parser.asString(trade["side"]) @@ -64,6 +72,7 @@ internal class SubaccountTransformer { originalPrice, side == "BUY", usePessimisticCollateralCheck, + useOptimisticCollateralCheck, ) } ?: originalPrice val size = ( @@ -196,10 +205,17 @@ internal class SubaccountTransformer { market: Map?, parser: ParserProtocol, period: String, - usePessimisticCollateralCheck: Boolean + usePessimisticCollateralCheck: Boolean, + useOptimisticCollateralCheck: Boolean, ): Map? { if (subaccount != null) { - val delta = deltaFromTrade(parser, trade, market, usePessimisticCollateralCheck) + val delta = deltaFromTrade( + parser, + trade, + market, + usePessimisticCollateralCheck, + useOptimisticCollateralCheck, + ) return applyDeltaToSubaccount(subaccount, delta, parser, period) } return subaccount diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt index 1786e532d..a2dcb4561 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt @@ -118,6 +118,7 @@ internal class TradeInputCalculator( parser, "postOrder", featureFlags.usePessimisticCollateralCheck, + featureFlags.useOptimisticCollateralCheck, ), ) modified diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Enviroment.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Enviroment.kt index 5f5dec229..1fda228e5 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Enviroment.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Enviroment.kt @@ -103,6 +103,7 @@ data class EnvironmentLinks( data class EnvironmentFeatureFlags( val reduceOnlySupported: Boolean, val usePessimisticCollateralCheck: Boolean, + val useOptimisticCollateralCheck: Boolean, val withdrawalSafetyEnabled: Boolean, ) { companion object { @@ -112,11 +113,13 @@ data class EnvironmentFeatureFlags( ): EnvironmentFeatureFlags { val reduceOnlySupported = parser.asBool(data?.get("reduceOnlySupported")) ?: false val usePessimisticCollateralCheck = parser.asBool(data?.get("usePessimisticCollateralCheck")) ?: false + val useOptimisticCollateralCheck = parser.asBool(data?.get("useOptimisticCollateralCheck")) ?: false val withdrawalSafetyEnabled = parser.asBool(data?.get("withdrawalSafetyEnabled")) ?: false return EnvironmentFeatureFlags( reduceOnlySupported, usePessimisticCollateralCheck, + useOptimisticCollateralCheck, withdrawalSafetyEnabled, ) } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/utils/AnalyticsUtils.kt b/src/commonMain/kotlin/exchange.dydx.abacus/utils/AnalyticsUtils.kt index 433f5c797..c559f92a3 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/utils/AnalyticsUtils.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/utils/AnalyticsUtils.kt @@ -41,7 +41,10 @@ class AnalyticsUtils { * @param payload HumanReadableCancelOrderPayload * @param fromSlTpDialog Boolean */ - fun formatCancelOrderPayload(payload: HumanReadableCancelOrderPayload, fromSlTpDialog: Boolean? = false,): IMap? { + fun formatCancelOrderPayload( + payload: HumanReadableCancelOrderPayload, + fromSlTpDialog: Boolean? = false, + ): IMap? { return iMapOf( "fromSlTpDialog" to fromSlTpDialog, "subaccountNumber" to payload.subaccountNumber, diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/TradeInputTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/TradeInputTests.kt index e5f43f4da..3423a9e0b 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/TradeInputTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/TradeInputTests.kt @@ -220,7 +220,7 @@ class TradeInputTests : V3BaseTests() { "size": { "size": 1.0, "usdcSize": 1655.7, - "leverage": 0.8021, + "leverage": 0.8017, "input": "size.size" }, "marketOrder": { @@ -243,13 +243,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206723.72 + "postOrder": 206821.31 }, "freeCollateral": { - "postOrder": 187878.84 + "postOrder": 187976.44 }, "quoteBalance": { - "postOrder": -64451.4 + "postOrder": -64353.8 }, "notionalTotal": { "postOrder": 271353.21 @@ -261,13 +261,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 18844.87 }, "leverage": { - "postOrder": 1.3130 + "postOrder": 1.312 }, "marginUsage": { - "postOrder": 0.0912 + "postOrder": 0.0911 }, "buyingPower": { - "postOrder": 3757576.88 + "postOrder": 3759528.74 }, "openPositions": { "ETH-USD": { @@ -280,7 +280,7 @@ class TradeInputTests : V3BaseTests() { }, "buyingPower": { "current": 3759346.73, - "postOrder": 3757576.88 + "postOrder": 3759528.74 } } } @@ -340,13 +340,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206723.72 + "postOrder": 206821.31 }, "freeCollateral": { - "postOrder": 187878.84 + "postOrder": 187976.44 }, "quoteBalance": { - "postOrder": -64451.4 + "postOrder": -64353.8 }, "notionalTotal": { "postOrder": 271353.21 @@ -358,13 +358,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 18844.87 }, "leverage": { - "postOrder": 1.3130 + "postOrder": 1.312 }, "marginUsage": { - "postOrder": 0.0912 + "postOrder": 0.0911 }, "buyingPower": { - "postOrder": 3757576.88 + "postOrder": 3759528.74 }, "openPositions": { "ETH-USD": { @@ -400,7 +400,7 @@ class TradeInputTests : V3BaseTests() { "size": { "size": 35.0, "usdcSize": 57949.8769, - "leverage": 1.09, + "leverage": 1.07, "input": "size.size" }, "marketOrder": { @@ -423,13 +423,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206695.57 + "postOrder": 210110.96 }, "freeCollateral": { - "postOrder": 184870.1 + "postOrder": 188285.5 }, "quoteBalance": { - "postOrder": -124091.52 + "postOrder": -120676.13 }, "notionalTotal": { "postOrder": 330965.18 @@ -441,13 +441,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 21825.47 }, "leverage": { - "postOrder": 1.6012 + "postOrder": 1.5752 }, "marginUsage": { - "postOrder": 0.1056 + "postOrder": 0.1039 }, "buyingPower": { - "postOrder": 3697401.97 + "postOrder": 3765709.67 }, "openPositions": { "ETH-USD": { @@ -482,7 +482,7 @@ class TradeInputTests : V3BaseTests() { "size": { "size": 2.114, "usdcSize": 3500.0, - "leverage": 0.8115, + "leverage": 0.8107, "input": "size.usdcSize" }, "marketOrder": { @@ -505,13 +505,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206722.8 + "postOrder": 206929.1 }, "freeCollateral": { - "postOrder": 187780.26 + "postOrder": 187986.58 }, "quoteBalance": { - "postOrder": -66405.49 + "postOrder": -66199.18 }, "notionalTotal": { "postOrder": 273306.38 @@ -526,10 +526,10 @@ class TradeInputTests : V3BaseTests() { "postOrder": 1.32 }, "marginUsage": { - "postOrder": 0.0916 + "postOrder": 0.0915 }, "buyingPower": { - "postOrder": 3755605.3 + "postOrder": 3759731.5 }, "openPositions": { "ETH-USD": { @@ -588,13 +588,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206694.55 + "postOrder": 210230.63 }, "freeCollateral": { - "postOrder": 184760.54 + "postOrder": 188296.63 }, "quoteBalance": { - "postOrder": -126263.12 + "postOrder": -122727.04 }, "notionalTotal": { "postOrder": 333135.76 @@ -606,13 +606,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 21934.00 }, "leverage": { - "postOrder": 1.61 + "postOrder": 1.58 }, "marginUsage": { - "postOrder": 0.1061 + "postOrder": 0.1043 }, "buyingPower": { - "postOrder": 3695210.89 + "postOrder": 3765932.52 }, "openPositions": { "ETH-USD": { @@ -675,13 +675,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 200162.99 + "postOrder": 206670.79 }, "freeCollateral": { - "postOrder": 187106.52 + "postOrder": 193614.33 }, "quoteBalance": { - "postOrder": 44756.06 + "postOrder": 51263.87 }, "notionalTotal": { "postOrder": 155585.01 @@ -693,13 +693,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 13056.46 }, "leverage": { - "postOrder": 0.78 + "postOrder": 0.75 }, "marginUsage": { - "postOrder": 0.0652 + "postOrder": 0.0632 }, "buyingPower": { - "postOrder": 3742130.44 + "postOrder": 3872286.56 }, "openPositions": { "ETH-USD": { @@ -754,13 +754,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206676.7 + "postOrder": 212314.4 }, "freeCollateral": { - "postOrder": 182852.64 + "postOrder": 188490.39 }, "quoteBalance": { - "postOrder": -164081.97 + "postOrder": -158444.22 }, "notionalTotal": { "postOrder": 370936.76 @@ -772,13 +772,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 23824.05 }, "leverage": { - "postOrder": 1.79 + "postOrder": 1.75 }, "marginUsage": { - "postOrder": 0.1153 + "postOrder": 0.1122 }, "buyingPower": { - "postOrder": 3657052.9 + "postOrder": 3769807.9 }, "openPositions": { "ETH-USD": { @@ -833,13 +833,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 183865.53 + "postOrder": 206538.94 }, "freeCollateral": { - "postOrder": 161819.49 + "postOrder": 184492.9 }, "quoteBalance": { - "postOrder": 308331.54 + "postOrder": 331004.95 }, "notionalTotal": { "postOrder": 335376.47 @@ -851,13 +851,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 22046.04 }, "leverage": { - "postOrder": 1.82 + "postOrder": 1.62 }, "marginUsage": { - "postOrder": 0.1199 + "postOrder": 0.1067 }, "buyingPower": { - "postOrder": 3236389.81 + "postOrder": 3689858.04 }, "openPositions": { "ETH-USD": { @@ -871,7 +871,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 229832.19 }, "leverage": { - "postOrder": -1.25 + "postOrder": -1.11 } } } @@ -898,7 +898,7 @@ class TradeInputTests : V3BaseTests() { "size": { "size": 250.0, "usdcSize": 413058.0213, - "leverage": -1.5132, + "leverage": -1.3281, "input": "size.size" }, "marketOrder": { @@ -921,13 +921,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 181252.74 + "postOrder": 206518.02 }, "freeCollateral": { - "postOrder": 156984.93 + "postOrder": 182250.21 }, "quoteBalance": { - "postOrder": 350154.21 + "postOrder": 375419.49 }, "notionalTotal": { "postOrder": 379811.93 @@ -939,13 +939,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 24267.81 }, "leverage": { - "postOrder": 2.0955 + "postOrder": 1.8391 }, "marginUsage": { - "postOrder": 0.1339 + "postOrder": 0.1175 }, "buyingPower": { - "postOrder": 3139698.56 + "postOrder": 3645004.14 }, "openPositions": { "ETH-USD": { @@ -959,7 +959,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 274267.66 }, "leverage": { - "postOrder": -1.51 + "postOrder": -1.33 } } } @@ -1013,13 +1013,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206592.2 + "postOrder": 222112.4 }, "freeCollateral": { - "postOrder": 173826.55 + "postOrder": 189346.72 }, "quoteBalance": { - "postOrder": -342998.84 + "postOrder": -327478.67 }, "notionalTotal": { "postOrder": 549769.2 @@ -1031,13 +1031,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 32765.67 }, "leverage": { - "postOrder": 2.66 + "postOrder": 2.48 }, "marginUsage": { - "postOrder": 0.1586 + "postOrder": 0.1475 }, "buyingPower": { - "postOrder": 3476531.0 + "postOrder": 3786934.0 }, "openPositions": { "ETH-USD": { @@ -1096,13 +1096,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 190521.41 + "postOrder": 206592.5 }, "freeCollateral": { - "postOrder": 174161.3 + "postOrder": 190232.4 }, "quoteBalance": { - "postOrder": 201268.83 + "postOrder": 217339.91 }, "notionalTotal": { "postOrder": 221657.87 @@ -1114,13 +1114,13 @@ class TradeInputTests : V3BaseTests() { "postOrder": 16360.11 }, "leverage": { - "postOrder": 1.16 + "postOrder": 1.07 }, "marginUsage": { - "postOrder": 0.0859 + "postOrder": 0.0792 }, "buyingPower": { - "postOrder": 3483226.09 + "postOrder": 3804647.8 }, "openPositions": { "ETH-USD": { @@ -1232,13 +1232,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206643.57 + "postOrder": 206724.18 }, "freeCollateral": { - "postOrder": 187798.70 + "postOrder": 187879.3 }, "quoteBalance": { - "postOrder": -64531.55 + "postOrder": -64450.94 }, "notionalTotal": { "postOrder": 271353.21 @@ -1256,7 +1256,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.0912 }, "buyingPower": { - "postOrder": 3755973.96 + "postOrder": 3757586.1 }, "openPositions": { "ETH-USD": { @@ -1321,13 +1321,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206643.57 + "postOrder": 206724.18 }, "freeCollateral": { - "postOrder": 187798.70 + "postOrder": 187879.3 }, "quoteBalance": { - "postOrder": -64531.55 + "postOrder": -64450.94 }, "notionalTotal": { "postOrder": 271353.21 @@ -1345,7 +1345,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.0912 }, "buyingPower": { - "postOrder": 3755973.96 + "postOrder": 3757586.1 }, "openPositions": { "ETH-USD": { @@ -1410,13 +1410,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206643.57 + "postOrder": 206724.18 }, "freeCollateral": { - "postOrder": 187798.70 + "postOrder": 187879.3 }, "quoteBalance": { - "postOrder": -64531.55 + "postOrder": -64450.94 }, "notionalTotal": { "postOrder": 271353.21 @@ -1434,7 +1434,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.0912 }, "buyingPower": { - "postOrder": 3755973.96 + "postOrder": 3757586.1 }, "openPositions": { "ETH-USD": { @@ -1516,13 +1516,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206643.02 + "postOrder": 206723.63 }, "freeCollateral": { - "postOrder": 187798.15 + "postOrder": 187878.75 }, "quoteBalance": { - "postOrder": -64532.10 + "postOrder": -64451.5 }, "notionalTotal": { "postOrder": 271353.21 @@ -1540,7 +1540,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.09 }, "buyingPower": { - "postOrder": 3755962.96 + "postOrder": 3757575.1 }, "openPositions": { "ETH-USD": { @@ -1622,13 +1622,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206643.02 + "postOrder": 206723.63 }, "freeCollateral": { - "postOrder": 187798.15 + "postOrder": 187878.75 }, "quoteBalance": { - "postOrder": -64532.10 + "postOrder": -64451.5 }, "notionalTotal": { "postOrder": 271353.21 @@ -1646,7 +1646,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.0912 }, "buyingPower": { - "postOrder": 3755962.96 + "postOrder": 3757575.1 }, "openPositions": { "ETH-USD": { @@ -1741,13 +1741,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206476.84 + "postOrder": 206723.55 }, "freeCollateral": { - "postOrder": 187631.96 + "postOrder": 187878.67 }, "quoteBalance": { - "postOrder": -64698.28 + "postOrder": -64451.57 }, "notionalTotal": { "postOrder": 271353.21 @@ -1765,7 +1765,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.09 }, "buyingPower": { - "postOrder": 3752639.30 + "postOrder": 3757573.4 }, "openPositions": { "ETH-USD": { @@ -1842,13 +1842,13 @@ class TradeInputTests : V3BaseTests() { "subaccounts": { "0": { "equity": { - "postOrder": 206723.8 + "postOrder": 206977.1 }, "freeCollateral": { - "postOrder": 187878.92 + "postOrder": 188132.21 }, "quoteBalance": { - "postOrder": -64451.32 + "postOrder": -64198.03 }, "notionalTotal": { "postOrder": 271353.21 @@ -1866,7 +1866,7 @@ class TradeInputTests : V3BaseTests() { "postOrder": 0.091 }, "buyingPower": { - "postOrder": 3757578.4 + "postOrder": 3762644.3 }, "openPositions": { "ETH-USD": { @@ -2001,15 +2001,15 @@ class TradeInputTests : V3BaseTests() { "0": { "equity": { "current": 10000.0, - "postOrder": 9999.92 + "postOrder": 10009.68 }, "freeCollateral": { "current": 10000.0, - "postOrder": 9991.15 + "postOrder": 10000.91 }, "quoteBalance": { "current": 10000.0, - "postOrder": 9824.59 + "postOrder": 9834.35 }, "notionalTotal": { "current": 0.0, @@ -2029,11 +2029,11 @@ class TradeInputTests : V3BaseTests() { }, "marginUsage": { "current": 0.0, - "postOrder": 0.000877 + "postOrder": 0.000876 }, "buyingPower": { "current": 200000.0, - "postOrder": 199823.0 + "postOrder": 200018.0 }, "openPositions": { "ETH-USD": { diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v3/V3ClosePositionTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v3/V3ClosePositionTests.kt index dcc3c9583..e5dee2a3b 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v3/V3ClosePositionTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v3/V3ClosePositionTests.kt @@ -81,7 +81,7 @@ class V3ClosePositionTests : V3BaseTests() { "0": { "quoteBalance": { "current": -62697.28, - "postOrder": -24012.93 + "postOrder": -21684.24 }, "openPositions": { "ETH-USD": { @@ -131,7 +131,7 @@ class V3ClosePositionTests : V3BaseTests() { "0": { "quoteBalance": { "current": -62697.28, - "postOrder": -37884.91 + "postOrder": -36397.88 }, "openPositions": { "ETH-USD": { @@ -206,7 +206,7 @@ class V3ClosePositionTests : V3BaseTests() { "0": { "quoteBalance": { "current": 68257.22, - "postOrder": 21717.8 + "postOrder": 24308.3 }, "openPositions": { "ETH-USD": { @@ -256,7 +256,7 @@ class V3ClosePositionTests : V3BaseTests() { "0": { "quoteBalance": { "current": 68257.22, - "postOrder": 41957.82 + "postOrder": 43421.72 }, "openPositions": { "ETH-USD": { diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4TradeInputTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4TradeInputTests.kt index 56df60e38..eaa2bc672 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4TradeInputTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4TradeInputTests.kt @@ -135,7 +135,7 @@ open class V4TradeInputTests : V4BaseTests() { "0": { "equity": { "current": 100000.0, - "postOrder": 98300.0 + "postOrder": 100000.0 }, "openPositions": { "ETH-USD": { @@ -212,7 +212,7 @@ open class V4TradeInputTests : V4BaseTests() { "0": { "equity": { "current": 100000.0, - "postOrder": 99700.2 + "postOrder": 100000.0 }, "openPositions": { "ETH-USD": { diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt index 7a64e709d..4112aa04d 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt @@ -104,7 +104,8 @@ class AbacusMockData { null, EnvironmentFeatureFlags( reduceOnlySupported = true, - usePessimisticCollateralCheck = true, + usePessimisticCollateralCheck = false, + useOptimisticCollateralCheck = true, withdrawalSafetyEnabled = true, ), ) diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/EnvironmentsMock.kt b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/EnvironmentsMock.kt index 2d72fbb7a..de8363901 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/EnvironmentsMock.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/EnvironmentsMock.kt @@ -87,7 +87,8 @@ class EnvironmentsMock { }, "featureFlags":{ "reduceOnlySupported":true, - "usePessimisticCollateralCheck":false + "usePessimisticCollateralCheck":false, + "useOptimisticCollateralCheck":true }, "governance": { "newMarketProposal": { @@ -120,7 +121,8 @@ class EnvironmentsMock { }, "featureFlags":{ "reduceOnlySupported":false, - "usePessimisticCollateralCheck":true + "usePessimisticCollateralCheck":true, + "useOptimisticCollateralCheck":false }, "governance": { "newMarketProposal": {