From 94b38055b032d52f73380ea9eaa1926e760aa697 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 23 Oct 2024 15:48:31 -0400 Subject: [PATCH 1/2] iList->Array --- build.gradle.kts | 2 +- .../kotlin/exchange.dydx.abacus/functional/vault/Vault.kt | 2 +- .../processor/vault/VaultProcessor.kt | 6 +++--- .../state/model/TradingStateMachine+Vault.kt | 2 +- .../state/v2/supervisor/VaultSupervisor.kt | 2 +- .../exchange.dydx.abacus/functional/vault/VaultTests.kt | 8 ++++---- .../tests/extensions/TradingStateMachine+TestUtils.kt | 2 +- v4_abacus.podspec | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3a49e1f16..803e063c6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.10" +version = "1.13.11" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt index fa027b0ea..b38362362 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt @@ -94,7 +94,7 @@ object VaultCalculator { return parser.asTypedObject(apiResponse) } - fun calculateVaultSummary(historicals: IList?): VaultDetails? { + fun calculateVaultSummary(historicals: Array?): VaultDetails? { val combinedPnls = historicals?.flatMap { it.megavaultPnl?.toList() ?: emptyList() } // Convert Array to List if (combinedPnls.isNullOrEmpty()) { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt index 97770c71c..793491a8e 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt @@ -26,13 +26,13 @@ internal class VaultProcessor( fun processMegaVaultsHistoricalPnl( existing: InternalVaultState?, - payload: List?, + payloads: List?, ): InternalVaultState? { - if (payload == null) { + if (payloads == null) { return existing } - val newValue = VaultCalculator.calculateVaultSummary(payload.toIList()) + val newValue = VaultCalculator.calculateVaultSummary(payloads.toTypedArray()) return if (newValue != existing?.details) { existing?.copy(details = newValue) ?: InternalVaultState(details = newValue) } else { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Vault.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Vault.kt index e4175ce0e..460c2fadd 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Vault.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Vault.kt @@ -13,7 +13,7 @@ import indexer.models.chain.OnChainAccountVaultResponse import kollections.iListOf internal fun TradingStateMachine.onMegaVaultPnl( - payloads: List + payloads: Array ): StateChanges { val responses = payloads.mapNotNull { parser.asTypedObject(it) } val newState = vaultProcessor.processMegaVaultsHistoricalPnl(internalState.vault, responses) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt index 366509c85..6146c3ff9 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt @@ -147,7 +147,7 @@ internal class VaultSupervisor( val hourlyResponse = deferredHourly.await() if (dailyResponse.response != null || hourlyResponse.response != null) { - stateMachine.onMegaVaultPnl(listOfNotNull(dailyResponse.response, hourlyResponse.response)) + stateMachine.onMegaVaultPnl(listOfNotNull(dailyResponse.response, hourlyResponse.response).toTypedArray()) } else if (dailyResponse.error != null) { Logger.e { "Failed to retrieve day mega vault pnl: ${dailyResponse.error}" diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt index 5981e455e..7386bf52c 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt @@ -61,7 +61,7 @@ class VaultTests { ), ) - val vaultDetails = calculateVaultSummary(iListOf(historicalPnl1, historicalPnl2)) + val vaultDetails = calculateVaultSummary(arrayOf(historicalPnl1, historicalPnl2)) val expectedVaultDetails = VaultDetails( totalValue = 10000.0, @@ -98,8 +98,8 @@ class VaultTests { val nullHistoricalPnl = IndexerMegavaultHistoricalPnlResponse(megavaultPnl = null) val emptyHistoricalPnl = IndexerMegavaultHistoricalPnlResponse(megavaultPnl = arrayOf()) - val nullVaultDetails = calculateVaultSummary(iListOf(nullHistoricalPnl)) - val emptyVaultDetails = calculateVaultSummary(iListOf(emptyHistoricalPnl)) + val nullVaultDetails = calculateVaultSummary(arrayOf(nullHistoricalPnl)) + val emptyVaultDetails = calculateVaultSummary(arrayOf(emptyHistoricalPnl)) assertEquals(null, nullVaultDetails) assertEquals(null, emptyVaultDetails) @@ -147,7 +147,7 @@ class VaultTests { ), ) - val vaultDetails = calculateVaultSummary(iListOf(historicalPnl)) + val vaultDetails = calculateVaultSummary(arrayOf(historicalPnl)) assertNotNull(vaultDetails) assertEquals(0.6403508771929824, vaultDetails.thirtyDayReturnPercent) diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/tests/extensions/TradingStateMachine+TestUtils.kt b/src/commonTest/kotlin/exchange.dydx.abacus/tests/extensions/TradingStateMachine+TestUtils.kt index caeba4796..faf3b76ec 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/tests/extensions/TradingStateMachine+TestUtils.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/tests/extensions/TradingStateMachine+TestUtils.kt @@ -597,7 +597,7 @@ fun TradingStateMachine.rest( } "/v4/vault/v1/megavault/historicalPnl" -> { - changes = onMegaVaultPnl(listOf(payload)) + changes = onMegaVaultPnl(arrayOf(payload)) } "/v4/vault/v1/megavault/positions" -> { diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 16564ee29..7150b8710 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.13.10' + spec.version = '1.13.11' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' From 0c7a31122c7472f8bfaa8124f92c5881212bd555 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 23 Oct 2024 15:53:50 -0400 Subject: [PATCH 2/2] spotless --- .../exchange.dydx.abacus/processor/vault/VaultProcessor.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt index 793491a8e..25855af5a 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/vault/VaultProcessor.kt @@ -14,7 +14,6 @@ import indexer.codegen.IndexerMegavaultPositionResponse import indexer.codegen.IndexerTransferBetweenResponse import indexer.codegen.IndexerVaultsHistoricalPnlResponse import indexer.models.chain.OnChainAccountVaultResponse -import kollections.toIList internal class VaultProcessor( parser: ParserProtocol,