Skip to content

Commit

Permalink
fix: megavault use today tvl (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Nov 18, 2024
1 parent 198cbd5 commit 8c7beb5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.13.31"
version = "1.13.32"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -150,7 +150,7 @@ class VaultTests {
val vaultDetails = calculateVaultSummary(arrayOf(historicalPnl))

assertNotNull(vaultDetails)
assertEquals(0.6403508771929824, vaultDetails.thirtyDayReturnPercent)
assertEquals(0.6083333333333333, vaultDetails.thirtyDayReturnPercent)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand Down

0 comments on commit 8c7beb5

Please sign in to comment.