Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Jun 1, 2024
2 parents ead2243 + 19de38d commit 6d3550a
Show file tree
Hide file tree
Showing 26 changed files with 307 additions and 218 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/bump_version.yml

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.45"
version = "1.7.47"

repositories {
google()
Expand Down
220 changes: 125 additions & 95 deletions integration/iOS/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal class AdjustIsolatedMarginInputCalculator(val parser: ParserProtocol) {
val crossMarginUsage = parentSubaccount?.get("marginUsage")
val openPositions = parser.asNativeMap(childSubaccount?.get("openPositions"))
val marketId = openPositions?.keys?.firstOrNull()
val positionMargin = childSubaccount?.get("freeCollateral")
val positionMargin = childSubaccount?.get("equity")
val positionLeverage = parser.value(childSubaccount, "openPositions.$marketId.leverage")
val liquidationPrice = parser.value(childSubaccount, "openPositions.$marketId.liquidationPrice")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class AsyncAbacusStateManager(
value?.historicalPnlPeriod = historicalPnlPeriod
value?.candlesResolution = candlesResolution
value?.readyToConnect = readyToConnect
value?.cosmosWalletConnected = cosmosWalletConnected
field = value
}
}
Expand Down Expand Up @@ -144,6 +145,14 @@ class AsyncAbacusStateManager(
}
}

override var cosmosWalletConnected: Boolean? = false
set(value) {
field = value
ioImplementations.threading?.async(ThreadingType.abacus) {
adaptor?.cosmosWalletConnected = field
}
}

override var sourceAddress: String? = null
set(value) {
field = value
Expand Down Expand Up @@ -251,27 +260,37 @@ class AsyncAbacusStateManager(
}

private fun load(configFile: ConfigFile) {
val path = configFile.path
if (appConfigs.loadRemote) {
loadFromRemoteConfigFile(configFile)
val configFileUrl = "$deploymentUri$path"
ioImplementations.rest?.get(configFileUrl, null, callback = { response, httpCode, _ ->
if (success(httpCode) && response != null) {
if (parse(response, configFile)) {
writeToLocalFile(response, path)
}
}
})
} else {
loadFromBundledLocalConfigFile(configFile)
ioImplementations.threading?.async(ThreadingType.network) {
val path = configFile.path
if (appConfigs.loadRemote) {
loadFromRemoteConfigFile(configFile)
val configFileUrl = "$deploymentUri$path"
ioImplementations.rest?.get(
configFileUrl,
null,
callback = { response, httpCode, _ ->
ioImplementations.threading?.async(ThreadingType.abacus) {
if (success(httpCode) && response != null) {
if (parse(response, configFile)) {
writeToLocalFile(response, path)
}
}
}
},
)
} else {
loadFromBundledLocalConfigFile(configFile)
}
}
}

private fun loadFromRemoteConfigFile(configFile: ConfigFile) {
ioImplementations.fileSystem?.readCachedTextFile(
configFile.path,
)?.let {
parse(it, configFile)
ioImplementations.threading?.async(ThreadingType.abacus) {
parse(it, configFile)
}
}
}

Expand All @@ -280,7 +299,9 @@ class AsyncAbacusStateManager(
FileLocation.AppBundle,
configFile.path,
)?.let {
parse(it, configFile)
ioImplementations.threading?.async(ThreadingType.abacus) {
parse(it, configFile)
}
}
}

Expand All @@ -300,10 +321,12 @@ class AsyncAbacusStateManager(
}

private fun writeToLocalFile(response: String, file: String) {
ioImplementations.fileSystem?.writeTextFile(
file,
response,
)
ioImplementations.threading?.async(ThreadingType.network) {
ioImplementations.fileSystem?.writeTextFile(
file,
response,
)
}
}

private fun parseDocumentation(response: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ interface AsyncAbacusStateManagerSingletonProtocol {
var sourceAddress: String?
var subaccountNumber: Int
var market: String?
var cosmosWalletConnected: Boolean?
}

@JsExport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ open class StateManagerAdaptor(
}
}

var cosmosWalletConnected: Boolean? = false

private var accountAddressTimer: LocalTimerProtocol? = null
set(value) {
if (field !== value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ class V4StateManagerAdaptor(
}

private fun pollNobleBalance() {
if (cosmosWalletConnected == true) {
return
}
val timer = ioImplementations.timer ?: CoroutineTimer.instance
nobleBalancesTimer = timer.schedule(0.0, nobleBalancePollingDuration) {
if (validatorConnected && accountAddress != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,24 +920,46 @@ open class TradingStateMachine(
"trade" -> {
val trade = parser.asNativeMap(input["trade"]) ?: return null
val type = parser.asString(trade["type"]) ?: return null
val isolatedMargin = parser.asString(trade["marginMode"]) == "ISOLATED"
return when (type) {
"MARKET", "STOP_MARKET", "TAKE_PROFIT_MARKET", "TRAILING_STOP" -> {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
if (isolatedMargin) {
listOf(
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.LiquidationPrice.rawValue,
ReceiptLine.PositionMargin.rawValue,
ReceiptLine.PositionLeverage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
} else {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
}
}

else -> {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
if (isolatedMargin) {
listOf(
ReceiptLine.LiquidationPrice.rawValue,
ReceiptLine.PositionMargin.rawValue,
ReceiptLine.PositionLeverage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
} else {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
}
}
}
}
Expand Down
Loading

0 comments on commit 6d3550a

Please sign in to comment.