Updated on 2026-08-14
This commit is contained in:
parent
246ab4b47e
commit
c4aba9a0b2
16 changed files with 365 additions and 0 deletions
27
domain/polymarket/build.gradle.kts
Normal file
27
domain/polymarket/build.gradle.kts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
plugins {
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
// region Kotlin
|
||||
api(deps.kotlin.coroutines)
|
||||
// endregion
|
||||
|
||||
// region Other libraries
|
||||
api(deps.arrow.core)
|
||||
// endregion
|
||||
|
||||
// region Domain
|
||||
api(projects.domain.core)
|
||||
// endregion
|
||||
|
||||
// region Tests
|
||||
testImplementation(deps.test.coroutine)
|
||||
testImplementation(deps.test.junit5)
|
||||
testImplementation(deps.test.mockk)
|
||||
testImplementation(deps.test.truth)
|
||||
testImplementation(projects.test.core)
|
||||
// endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.domain.polymarket
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.core.error.DataError
|
||||
import com.tangem.domain.polymarket.model.PolymarketEvent
|
||||
|
||||
interface PolymarketRepository {
|
||||
|
||||
/**
|
||||
* Fetch the Discovery feed of prediction events (each with its top active markets).
|
||||
*/
|
||||
suspend fun getEvents(): Either<DataError, List<PolymarketEvent>>
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.tangem.domain.polymarket.model
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* A prediction event — the primary Discovery feed entity (BFF `Event`).
|
||||
*
|
||||
* @property id unique event id
|
||||
* @property slug url-friendly event identifier
|
||||
* @property title event title
|
||||
* @property iconUrl optional event icon
|
||||
* @property imageUrl optional event image
|
||||
* @property volume total traded volume in USD, if known
|
||||
* @property totalMarketsCount total number of markets in the event (may exceed [markets] size,
|
||||
* since the Discovery feed carries only the top active markets)
|
||||
* @property markets nested markets (top active ones for the feed, all for event details)
|
||||
*/
|
||||
data class PolymarketEvent(
|
||||
val id: String,
|
||||
val slug: String,
|
||||
val title: String,
|
||||
val iconUrl: String?,
|
||||
val imageUrl: String?,
|
||||
val volume: BigDecimal?,
|
||||
val totalMarketsCount: Int,
|
||||
val markets: List<PolymarketMarket>,
|
||||
)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.domain.polymarket.model
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* A single Polymarket prediction market nested inside a [PolymarketEvent] (BFF `Market`).
|
||||
*
|
||||
* @property id unique market id
|
||||
* @property title the market question (e.g. "Will X happen by 2026?")
|
||||
* @property iconUrl optional market icon
|
||||
* @property volume total traded volume in USD, if known
|
||||
* @property outcomes normalized outcomes with their implied probabilities
|
||||
*/
|
||||
data class PolymarketMarket(
|
||||
val id: String,
|
||||
val title: String,
|
||||
val iconUrl: String?,
|
||||
val volume: BigDecimal?,
|
||||
val outcomes: List<PolymarketOutcome>,
|
||||
)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.domain.polymarket.model
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* A single normalized outcome of a [PolymarketMarket] (BFF `OutcomeSummary`).
|
||||
*
|
||||
* @property assetId upstream asset (clob token) id of the outcome
|
||||
* @property title outcome label as provided by upstream (e.g. "Yes" / "No"), never hardcoded
|
||||
* @property probability implied probability in the 0..1 range, if known
|
||||
*/
|
||||
data class PolymarketOutcome(
|
||||
val assetId: String,
|
||||
val title: String,
|
||||
val probability: BigDecimal?,
|
||||
)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.polymarket.usecase
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.core.error.DataError
|
||||
import com.tangem.domain.polymarket.PolymarketRepository
|
||||
import com.tangem.domain.polymarket.model.PolymarketEvent
|
||||
|
||||
class GetPolymarketEventsUseCase(
|
||||
private val polymarketRepository: PolymarketRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): Either<DataError, List<PolymarketEvent>> {
|
||||
return polymarketRepository.getEvents()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue