From 8c7beb5325c6f068763db37fc1de7724e731f396 Mon Sep 17 00:00:00 2001 From: tyleroooo Date: Mon, 18 Nov 2024 16:42:09 -0500 Subject: [PATCH] fix: megavault use today tvl (#757) --- build.gradle.kts | 2 +- .../kotlin/exchange.dydx.abacus/functional/vault/Vault.kt | 5 ++--- .../exchange.dydx.abacus/functional/vault/VaultTests.kt | 4 ++-- .../kotlin/exchange.dydx.abacus/payload/v4/V4VaultTests.kt | 4 ++-- v4_abacus.podspec | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cd609a10e..c437aaf2a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.31" +version = "1.13.32" 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 1f9bedb95..17a0835f9 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/Vault.kt @@ -133,9 +133,8 @@ object VaultCalculator { } else { 0.0 } - val thirtyDaysAgoEquity = thirtyDaysAgoEntry.equity ?: 0.0 - val thirtyDayReturnPercent = if (thirtyDaysAgoEquity != 0.0) { - (pnlDifference / thirtyDaysAgoEquity) + val thirtyDayReturnPercent = if (totalValue != 0.0) { + (pnlDifference / totalValue) } else { 0.0 } 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 7386bf52c..8886559ad 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultTests.kt @@ -65,7 +65,7 @@ class VaultTests { val expectedVaultDetails = VaultDetails( totalValue = 10000.0, - thirtyDayReturnPercent = 0.1 * 365, + thirtyDayReturnPercent = 0.05 * 365, history = iListOf( VaultHistoryEntry( date = 1659465600000.0, @@ -150,7 +150,7 @@ class VaultTests { val vaultDetails = calculateVaultSummary(arrayOf(historicalPnl)) assertNotNull(vaultDetails) - assertEquals(0.6403508771929824, vaultDetails.thirtyDayReturnPercent) + assertEquals(0.6083333333333333, vaultDetails.thirtyDayReturnPercent) } @Test diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4VaultTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4VaultTests.kt index 36a91fe5f..638074501 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4VaultTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4VaultTests.kt @@ -27,7 +27,7 @@ class V4VaultTests : V4BaseTests() { val vaultDetails = vault?.details assertEquals(10000.0, vaultDetails?.totalValue) - assertEquals(0.1 * 365, vaultDetails?.thirtyDayReturnPercent) + assertEquals(18.25, vaultDetails?.thirtyDayReturnPercent) assertEquals(2, vaultDetails?.history?.size) assertEquals(1000.0, vaultDetails?.history?.get(0)?.totalPnl) assertEquals(500.0, vaultDetails?.history?.get(1)?.totalPnl) @@ -50,7 +50,7 @@ class V4VaultTests : V4BaseTests() { val vault = perp.internalState.vault assertEquals(10000.0, vault?.details?.totalValue) - assertEquals(0.1 * 365, vault?.details?.thirtyDayReturnPercent) + assertEquals(18.25, vault?.details?.thirtyDayReturnPercent) assertEquals(2, vault?.details?.history?.size) assertEquals(1000.0, vault?.details?.history?.get(0)?.totalPnl) assertEquals(500.0, vault?.details?.history?.get(1)?.totalPnl) diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 16515ebbd..ff24f26e4 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.31' + spec.version = '1.13.32' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''