From 07482ec82adab6a51fb1c9e4ed102a885241f7bc Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:07:21 -0700 Subject: [PATCH 1/2] Indexer codegen (#663) --- .../IndexerAddress_registerToken_body.kt | 28 +++++++++++++ .../IndexerAffiliateAddressResponse.kt | 26 ++++++++++++ .../IndexerAffiliateMetadataResponse.kt | 30 ++++++++++++++ .../IndexerAffiliateSnapshotResponse.kt | 30 ++++++++++++++ .../IndexerAffiliateSnapshotResponseObject.kt | 40 +++++++++++++++++++ .../IndexerAffiliateTotalVolumeResponse.kt | 26 ++++++++++++ .../codegen/IndexerFillResponseObject.kt | 2 + .../IndexerMegavaultHistoricalPnlResponse.kt | 26 ++++++++++++ .../IndexerMegavaultPositionResponse.kt | 26 ++++++++++++ .../indexer/codegen/IndexerPnlTickInterval.kt | 26 ++++++++++++ .../codegen/IndexerVaultHistoricalPnl.kt | 28 +++++++++++++ .../indexer/codegen/IndexerVaultPosition.kt | 32 +++++++++++++++ .../IndexerVaultsHistoricalPnlResponse.kt | 26 ++++++++++++ swagger_codegen.sh | 2 + 14 files changed, 348 insertions(+) create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAddress_registerToken_body.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAffiliateAddressResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAffiliateMetadataResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponseObject.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerAffiliateTotalVolumeResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerMegavaultHistoricalPnlResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerMegavaultPositionResponse.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerPnlTickInterval.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerVaultHistoricalPnl.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerVaultPosition.kt create mode 100644 src/commonMain/kotlin/indexer/codegen/IndexerVaultsHistoricalPnlResponse.kt diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAddress_registerToken_body.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAddress_registerToken_body.kt new file mode 100644 index 000000000..caf05ad3e --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAddress_registerToken_body.kt @@ -0,0 +1,28 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param language + * @param token + */ +@JsExport +@Serializable +data class AddressRegisterTokenBody( + + val language: kotlin.String? = null, + val token: kotlin.String? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateAddressResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateAddressResponse.kt new file mode 100644 index 000000000..d2b9f92ab --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateAddressResponse.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param address + */ +@JsExport +@Serializable +data class IndexerAffiliateAddressResponse( + + val address: kotlin.String? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateMetadataResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateMetadataResponse.kt new file mode 100644 index 000000000..fa1f0d849 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateMetadataResponse.kt @@ -0,0 +1,30 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param referralCode + * @param isVolumeEligible + * @param isAffiliate + */ +@JsExport +@Serializable +data class IndexerAffiliateMetadataResponse( + + val referralCode: kotlin.String? = null, + val isVolumeEligible: kotlin.Boolean? = null, + val isAffiliate: kotlin.Boolean? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponse.kt new file mode 100644 index 000000000..822d5ef2b --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponse.kt @@ -0,0 +1,30 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param affiliateList + * @param total + * @param currentOffset + */ +@JsExport +@Serializable +data class IndexerAffiliateSnapshotResponse( + + val affiliateList: kotlin.Array? = null, + val total: kotlin.Double? = null, + val currentOffset: kotlin.Double? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponseObject.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponseObject.kt new file mode 100644 index 000000000..104ded4b5 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateSnapshotResponseObject.kt @@ -0,0 +1,40 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param affiliateAddress + * @param affiliateReferralCode + * @param affiliateEarnings + * @param affiliateReferredTrades + * @param affiliateTotalReferredFees + * @param affiliateReferredUsers + * @param affiliateReferredNetProtocolEarnings + * @param affiliateReferredTotalVolume + */ +@JsExport +@Serializable +data class IndexerAffiliateSnapshotResponseObject( + + val affiliateAddress: kotlin.String? = null, + val affiliateReferralCode: kotlin.String? = null, + val affiliateEarnings: kotlin.Double? = null, + val affiliateReferredTrades: kotlin.Double? = null, + val affiliateTotalReferredFees: kotlin.Double? = null, + val affiliateReferredUsers: kotlin.Double? = null, + val affiliateReferredNetProtocolEarnings: kotlin.Double? = null, + val affiliateReferredTotalVolume: kotlin.Double? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateTotalVolumeResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateTotalVolumeResponse.kt new file mode 100644 index 000000000..1a2c84a7c --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerAffiliateTotalVolumeResponse.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param totalVolume + */ +@JsExport +@Serializable +data class IndexerAffiliateTotalVolumeResponse( + + val totalVolume: kotlin.Double? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerFillResponseObject.kt b/src/commonMain/kotlin/indexer/codegen/IndexerFillResponseObject.kt index f92fceb0a..520618f62 100644 --- a/src/commonMain/kotlin/indexer/codegen/IndexerFillResponseObject.kt +++ b/src/commonMain/kotlin/indexer/codegen/IndexerFillResponseObject.kt @@ -25,6 +25,7 @@ import kotlin.js.JsExport * @param price * @param size * @param fee + * @param affiliateRevShare * @param createdAt * @param createdAtHeight * @param orderId @@ -44,6 +45,7 @@ data class IndexerFillResponseObject( val price: kotlin.String? = null, val size: kotlin.String? = null, val fee: kotlin.String? = null, + val affiliateRevShare: kotlin.String? = null, val createdAt: IndexerIsoString? = null, val createdAtHeight: kotlin.String? = null, val orderId: kotlin.String? = null, diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultHistoricalPnlResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultHistoricalPnlResponse.kt new file mode 100644 index 000000000..fca650ace --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultHistoricalPnlResponse.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param megavaultPnl + */ +@JsExport +@Serializable +data class IndexerMegavaultHistoricalPnlResponse( + + val megavaultPnl: kotlin.Array? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultPositionResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultPositionResponse.kt new file mode 100644 index 000000000..9d6c45a35 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerMegavaultPositionResponse.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param positions + */ +@JsExport +@Serializable +data class IndexerMegavaultPositionResponse( + + val positions: kotlin.Array? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerPnlTickInterval.kt b/src/commonMain/kotlin/indexer/codegen/IndexerPnlTickInterval.kt new file mode 100644 index 000000000..44d928ff5 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerPnlTickInterval.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * Values: HOUR,DAY + */ +@JsExport +@Serializable +enum class IndexerPnlTickInterval(val value: kotlin.String) { + HOUR("hour"), // :/ + DAY("day"); // :/ +} diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerVaultHistoricalPnl.kt b/src/commonMain/kotlin/indexer/codegen/IndexerVaultHistoricalPnl.kt new file mode 100644 index 000000000..f5040a8d1 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerVaultHistoricalPnl.kt @@ -0,0 +1,28 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param ticker + * @param historicalPnl + */ +@JsExport +@Serializable +data class IndexerVaultHistoricalPnl( + + val ticker: kotlin.String? = null, + val historicalPnl: kotlin.Array? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerVaultPosition.kt b/src/commonMain/kotlin/indexer/codegen/IndexerVaultPosition.kt new file mode 100644 index 000000000..3d62e4536 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerVaultPosition.kt @@ -0,0 +1,32 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param ticker + * @param assetPosition + * @param perpetualPosition + * @param equity + */ +@JsExport +@Serializable +data class IndexerVaultPosition( + + val ticker: kotlin.String? = null, + val assetPosition: IndexerAssetPositionResponseObject? = null, + val perpetualPosition: IndexerPerpetualPositionResponseObject? = null, + val equity: kotlin.String? = null +) diff --git a/src/commonMain/kotlin/indexer/codegen/IndexerVaultsHistoricalPnlResponse.kt b/src/commonMain/kotlin/indexer/codegen/IndexerVaultsHistoricalPnlResponse.kt new file mode 100644 index 000000000..4645ef866 --- /dev/null +++ b/src/commonMain/kotlin/indexer/codegen/IndexerVaultsHistoricalPnlResponse.kt @@ -0,0 +1,26 @@ +/** + * Indexer API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: v1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package indexer.codegen + +import kotlinx.serialization.Serializable +import kotlin.js.JsExport + +/** + * + * @param vaultsPnl + */ +@JsExport +@Serializable +data class IndexerVaultsHistoricalPnlResponse( + + val vaultsPnl: kotlin.Array? = null +) diff --git a/swagger_codegen.sh b/swagger_codegen.sh index 4fed07522..1feab1053 100755 --- a/swagger_codegen.sh +++ b/swagger_codegen.sh @@ -74,6 +74,8 @@ sed -i '' 's/\ PerpetualPositionsMap/\ Map in SubaccountResponseObject.kt sed -i '' 's/\ AssetPositionsMap/\ Map/g' generated/src/main/kotlin/indexer/codegen/SubaccountResponseObject.kt +# add import kotlinx.serialization.SerialName to the top of CandleResolution.kt +sed -i '' 's/package indexer.codegen/package indexer.codegen\n\nimport kotlinx.serialization.SerialName/' generated/src/main/kotlin/indexer/codegen/CandleResolution.kt # add import kotlinx.serialization.Serializable to the top of CandleResolution.kt sed -i '' 's/package indexer.codegen/package indexer.codegen\n\nimport kotlinx.serialization.Serializable/' generated/src/main/kotlin/indexer/codegen/CandleResolution.kt From 5dd1ce84d2811816801ea1996f1f4ce09c7c8b57 Mon Sep 17 00:00:00 2001 From: tyleroooo Date: Thu, 19 Sep 2024 19:14:36 -0400 Subject: [PATCH 2/2] feat: use new indexer models for vaults (#666) --- .../functional/vault/Vault.kt | 37 +++++++++------- .../functional/vault/VaultIndexerModels.kt | 42 ------------------- .../functional/vault/VaultTests.kt | 21 ++++++---- 3 files changed, 33 insertions(+), 67 deletions(-) delete mode 100644 src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultIndexerModels.kt 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 73bf916c1..2176b2ecb 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt @@ -12,6 +12,11 @@ import exchange.dydx.abacus.state.internalstate.InternalSubaccountState import exchange.dydx.abacus.utils.IList import exchange.dydx.abacus.utils.IMap import exchange.dydx.abacus.utils.Parser +import indexer.codegen.IndexerMegavaultHistoricalPnlResponse +import indexer.codegen.IndexerMegavaultPositionResponse +import indexer.codegen.IndexerVaultHistoricalPnl +import indexer.codegen.IndexerVaultPosition +import indexer.codegen.IndexerVaultsHistoricalPnlResponse import kollections.toIList import kotlinx.datetime.Clock import kotlinx.serialization.Serializable @@ -74,24 +79,24 @@ object VaultCalculator { private val assetPositionProcessor = AssetPositionProcessor(parser) private val subaccountCalculator = SubaccountCalculatorV2(parser) - fun getVaultHistoricalPnlResponse(apiResponse: String): IndexerVaultHistoricalPnlResponse? { - return parser.asTypedObject(apiResponse) + fun getVaultHistoricalPnlResponse(apiResponse: String): IndexerMegavaultHistoricalPnlResponse? { + return parser.asTypedObject(apiResponse) } - fun getSubvaultHistoricalPnlResponse(apiResponse: String): IndexerSubvaultHistoricalPnlResponse? { - return parser.asTypedObject(apiResponse) + fun getSubvaultHistoricalPnlResponse(apiResponse: String): IndexerVaultsHistoricalPnlResponse? { + return parser.asTypedObject(apiResponse) } - fun getVaultPositionsResponse(apiResponse: String): IndexerVaultPositionResponse? { - return parser.asTypedObject(apiResponse) + fun getVaultPositionsResponse(apiResponse: String): IndexerMegavaultPositionResponse? { + return parser.asTypedObject(apiResponse) } - fun calculateVaultSummary(historical: IndexerVaultHistoricalPnlResponse?): VaultDetails? { - if (historical?.vaultOfVaultsPnl.isNullOrEmpty()) { + fun calculateVaultSummary(historical: IndexerMegavaultHistoricalPnlResponse?): VaultDetails? { + if (historical?.megavaultPnl.isNullOrEmpty()) { return null } - val vaultOfVaultsPnl = historical!!.vaultOfVaultsPnl!!.sortedByDescending { parser.asDouble(it.createdAt) } + val vaultOfVaultsPnl = historical!!.megavaultPnl!!.sortedByDescending { parser.asDouble(it.createdAt) } val history = vaultOfVaultsPnl.mapNotNull { entry -> parser.asDouble(entry.createdAt)?.let { createdAt -> @@ -132,21 +137,21 @@ object VaultCalculator { } fun calculateVaultPositions( - positions: IndexerVaultPositionResponse?, - histories: IndexerSubvaultHistoricalPnlResponse?, + positions: IndexerMegavaultPositionResponse?, + histories: IndexerVaultsHistoricalPnlResponse?, markets: IMap? ): VaultPositions? { if (positions?.positions == null) { return null } - val historiesMap = histories?.vaultsPnl?.associateBy { it.marketId } + val historiesMap = histories?.vaultsPnl?.associateBy { it.ticker } - return VaultPositions(positions = positions.positions.mapNotNull { calculateVaultPosition(it, historiesMap?.get(it.market), markets?.get(it.market)) }.toIList()) + return VaultPositions(positions = positions.positions.mapNotNull { calculateVaultPosition(it, historiesMap?.get(it.ticker), markets?.get(it.ticker)) }.toIList()) } fun calculateVaultPosition(position: IndexerVaultPosition, history: IndexerVaultHistoricalPnl?, perpetualMarket: PerpetualMarket?): VaultPosition? { - if (position.market == null) { + if (position.ticker == null) { return null } val perpetualPosition = perpetualPositionProcessor.process(null, position.perpetualPosition) @@ -165,7 +170,7 @@ object VaultCalculator { ), ), - marketsSummary = InternalMarketSummaryState(markets = mutableMapOf(position.market to InternalMarketState(perpetualMarket = perpetualMarket))), + marketsSummary = InternalMarketSummaryState(markets = mutableMapOf(position.ticker to InternalMarketState(perpetualMarket = perpetualMarket))), periods = setOf(CalculationPeriod.current), price = null, configs = null, @@ -173,7 +178,7 @@ object VaultCalculator { val calculated = subaccount?.calculated?.get(CalculationPeriod.current) val perpCalculated = perpetualPosition?.calculated?.get(CalculationPeriod.current) return VaultPosition( - marketId = position.market, + marketId = position.ticker, marginUsdc = calculated?.equity, currentLeverageMultiple = perpCalculated?.leverage, currentPosition = CurrentPosition( diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultIndexerModels.kt b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultIndexerModels.kt deleted file mode 100644 index c04dab0af..000000000 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultIndexerModels.kt +++ /dev/null @@ -1,42 +0,0 @@ -package exchange.dydx.abacus.functional.vault - -import exchange.dydx.abacus.utils.IList -import indexer.codegen.IndexerAssetPositionResponseObject -import indexer.codegen.IndexerPerpetualPositionResponseObject -import indexer.codegen.IndexerPnlTicksResponseObject -import kotlinx.serialization.Serializable -import kotlin.js.JsExport - -@JsExport -@Serializable -data class IndexerVaultHistoricalPnlResponse( - val vaultOfVaultsPnl: IList? = null -) - -@JsExport -@Serializable -data class IndexerVaultHistoricalPnl( - val marketId: String? = null, - val historicalPnl: IList? = null -) - -@JsExport -@Serializable -data class IndexerSubvaultHistoricalPnlResponse( - val vaultsPnl: IList? = null -) - -@JsExport -@Serializable -data class IndexerVaultPosition( - val market: String? = null, - val assetPosition: IndexerAssetPositionResponseObject? = null, - val perpetualPosition: IndexerPerpetualPositionResponseObject? = null, - val equity: String? = null -) - -@JsExport -@Serializable -data class IndexerVaultPositionResponse( - val positions: IList? = null -) 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 fcfd0ee75..495e8a6d1 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt @@ -5,10 +5,13 @@ import exchange.dydx.abacus.functional.vault.VaultCalculator.calculateVaultSumma import exchange.dydx.abacus.output.PerpetualMarket import exchange.dydx.abacus.utils.NUM_PARENT_SUBACCOUNTS import indexer.codegen.IndexerAssetPositionResponseObject +import indexer.codegen.IndexerMegavaultHistoricalPnlResponse import indexer.codegen.IndexerPerpetualPositionResponseObject import indexer.codegen.IndexerPerpetualPositionStatus import indexer.codegen.IndexerPnlTicksResponseObject import indexer.codegen.IndexerPositionSide +import indexer.codegen.IndexerVaultHistoricalPnl +import indexer.codegen.IndexerVaultPosition import kollections.iListOf import kotlin.test.Test import kotlin.test.assertEquals @@ -19,8 +22,8 @@ class VaultTests { @Test fun calculateVaultSummary_basic() { - val historicalPnl = IndexerVaultHistoricalPnlResponse( - vaultOfVaultsPnl = iListOf( + val historicalPnl = IndexerMegavaultHistoricalPnlResponse( + megavaultPnl = arrayOf( IndexerPnlTicksResponseObject( equity = "10000.0", totalPnl = "1000.0", @@ -60,8 +63,8 @@ class VaultTests { @Test fun shouldReturnNullForNullOrEmptyHistoricalPnl() { - val nullHistoricalPnl = IndexerVaultHistoricalPnlResponse(vaultOfVaultsPnl = null) - val emptyHistoricalPnl = IndexerVaultHistoricalPnlResponse(vaultOfVaultsPnl = iListOf()) + val nullHistoricalPnl = IndexerMegavaultHistoricalPnlResponse(megavaultPnl = null) + val emptyHistoricalPnl = IndexerMegavaultHistoricalPnlResponse(megavaultPnl = arrayOf()) val nullVaultDetails = calculateVaultSummary(nullHistoricalPnl) val emptyVaultDetails = calculateVaultSummary(emptyHistoricalPnl) @@ -77,8 +80,8 @@ class VaultTests { val thirtyDaysAgoTimestamp = latestTimestamp - 30.days.inWholeMilliseconds val twentyNineDaysAgoTimestamp = latestTimestamp - 29.days.inWholeMilliseconds - val historicalPnl = IndexerVaultHistoricalPnlResponse( - vaultOfVaultsPnl = iListOf( + val historicalPnl = IndexerMegavaultHistoricalPnlResponse( + megavaultPnl = arrayOf( IndexerPnlTicksResponseObject( equity = "10000.0", totalPnl = "1000.0", @@ -121,7 +124,7 @@ class VaultTests { @Test fun shouldCalculateVaultPositionCorrectly() { val position = IndexerVaultPosition( - market = "BTC-USD", + ticker = "BTC-USD", assetPosition = IndexerAssetPositionResponseObject( symbol = "USDC", side = IndexerPositionSide.SHORT, @@ -151,8 +154,8 @@ class VaultTests { ) val history = IndexerVaultHistoricalPnl( - marketId = "BTC-USD", - historicalPnl = iListOf( + ticker = "BTC-USD", + historicalPnl = arrayOf( IndexerPnlTicksResponseObject( id = "1", equity = "10500.0",