-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from horizontalsystems/add_pro_charts
Add PRO charts methods
- Loading branch information
Showing
4 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
marketkit/src/main/java/io/horizontalsystems/marketkit/models/HsProModels.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package io.horizontalsystems.marketkit.models | ||
|
||
import java.math.BigDecimal | ||
|
||
data class ProChartPointDataRaw( | ||
val timestamp: Long, | ||
val count: Int?, | ||
val volume: BigDecimal? | ||
) { | ||
|
||
companion object { | ||
|
||
fun volumePoints(rawChartPoints: List<ProChartPointDataRaw>): List<ChartPoint> = | ||
rawChartPoints.mapNotNull { raw -> | ||
raw.volume?.let { | ||
ChartPoint( | ||
it, | ||
raw.timestamp, | ||
mapOf() | ||
) | ||
} | ||
} | ||
|
||
fun countPoints(rawChartPoints: List<ProChartPointDataRaw>): List<ChartPoint> = | ||
rawChartPoints.mapNotNull { raw -> | ||
raw.count?.let { | ||
ChartPoint( | ||
it.toBigDecimal(), | ||
raw.timestamp, | ||
mapOf() | ||
) | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
data class DexLiquiditiesResponse( | ||
val platforms: List<String>, | ||
val liquidity: List<ProChartPointDataRaw> | ||
) { | ||
|
||
val volumePoints: List<ChartPoint> | ||
get() = ProChartPointDataRaw.volumePoints(liquidity) | ||
|
||
} | ||
|
||
data class DexVolumesResponse( | ||
val platforms: List<String>, | ||
val volumes: List<ProChartPointDataRaw> | ||
) { | ||
|
||
val volumePoints: List<ChartPoint> | ||
get() = ProChartPointDataRaw.volumePoints(volumes) | ||
|
||
} | ||
|
||
data class TransactionsDataResponse( | ||
val platforms: List<String>, | ||
val transactions: List<ProChartPointDataRaw> | ||
) { | ||
|
||
val volumePoints: List<ChartPoint> | ||
get() = ProChartPointDataRaw.volumePoints(transactions) | ||
|
||
val countPoints: List<ChartPoint> | ||
get() = ProChartPointDataRaw.countPoints(transactions) | ||
|
||
} | ||
|
||
data class ActiveAddressesDataResponse( | ||
val platforms: List<String>, | ||
val addresses: List<ProChartPointDataRaw> | ||
) { | ||
|
||
val countPoints: List<ChartPoint> | ||
get() = ProChartPointDataRaw.countPoints(addresses) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters