Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ interface MarketUserDataProxy {
offset: Int?,
): List<OrderData>

suspend fun getOrderHistoryCount(
uuid : String,
symbol: String?,
startTime: Long?,
endTime: Long?,
orderType: MatchingOrderType?,
direction: OrderDirection?,
): Long

suspend fun getTradeHistory(
uuid : String,
symbol: String?,
Expand All @@ -51,4 +60,12 @@ interface MarketUserDataProxy {
limit: Int?,
offset: Int?,
): List<Trade>

suspend fun getTradeHistoryCount(
uuid : String,
symbol: String?,
startTime: Long?,
endTime: Long?,
direction: OrderDirection?,
): Long
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ interface WalletProxy {
ascendingByTime: Boolean?,
): List<DepositHistoryResponse>

suspend fun getDepositTransactionsCount(
uuid: String,
token: String,
currency: String?,
startTime: Long?,
endTime: Long?,
): Long

suspend fun getWithdrawTransactions(
uuid: String,
token: String,
Expand All @@ -32,6 +40,14 @@ interface WalletProxy {
ascendingByTime: Boolean?,
): List<WithdrawHistoryResponse>

suspend fun getWithdrawTransactionsCount(
uuid: String,
token: String,
currency: String?,
startTime: Long?,
endTime: Long?,
): Long

suspend fun getTransactions(
uuid: String,
token: String,
Expand All @@ -44,6 +60,15 @@ interface WalletProxy {
ascendingByTime: Boolean?,
): List<UserTransactionHistory>

suspend fun getTransactionsCount(
uuid: String,
token: String,
currency: String?,
category: UserTransactionCategory?,
startTime: Long?,
endTime: Long?,
): Long

suspend fun getGateWays(
includeOffChainGateways: Boolean,
includeOnChainGateways: Boolean,
Expand Down Expand Up @@ -97,4 +122,6 @@ interface WalletProxy {
suspend fun submitVoucher(code: String, token: String): SubmitVoucherResponse

suspend fun getQuoteCurrencies(): List<QuoteCurrency>

suspend fun getSwapTransactionsCount(token: String, request: UserTransactionRequest):Long
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import co.nilin.opex.api.ports.opex.util.tokenValue
import org.springframework.security.core.annotation.CurrentSecurityContext
import org.springframework.security.core.context.SecurityContext
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
Expand Down Expand Up @@ -42,6 +44,25 @@ class UserHistoryController(
)
}

@GetMapping("/history/order/count")
suspend fun getOrderHistoryCount(
@RequestParam symbol: String?,
@RequestParam startTime: Long?,
@RequestParam endTime: Long?,
@RequestParam orderType: MatchingOrderType?,
@RequestParam direction: OrderDirection?,
@CurrentSecurityContext securityContext: SecurityContext,
): Long {
return marketUserDataProxy.getOrderHistoryCount(
securityContext.authentication.name,
symbol,
startTime,
endTime,
orderType,
direction,
)
}

@GetMapping("/history/trade")
suspend fun getTradeHistory(
@RequestParam symbol: String?,
Expand All @@ -57,6 +78,19 @@ class UserHistoryController(
)
}

@GetMapping("/history/trade/count")
suspend fun getTradeHistoryCount(
@RequestParam symbol: String?,
@RequestParam startTime: Long?,
@RequestParam endTime: Long?,
@RequestParam direction: OrderDirection?,
@CurrentSecurityContext securityContext: SecurityContext,
): Long {
return marketUserDataProxy.getTradeHistoryCount(
securityContext.authentication.name, symbol, startTime, endTime, direction
)
}

@GetMapping("/history/withdraw")
suspend fun getWithdrawHistory(
@RequestParam currency: String?,
Expand All @@ -79,6 +113,22 @@ class UserHistoryController(
)
}

@GetMapping("/history/withdraw/count")
suspend fun getWithdrawHistoryCount(
@RequestParam currency: String?,
@RequestParam startTime: Long?,
@RequestParam endTime: Long?,
@CurrentSecurityContext securityContext: SecurityContext,
): Long {
return walletProxy.getWithdrawTransactionsCount(
securityContext.jwtAuthentication().name,
securityContext.jwtAuthentication().tokenValue(),
currency,
startTime,
endTime,
)
}

@GetMapping("/history/deposit")
suspend fun getDepositHistory(
@RequestParam currency: String?,
Expand All @@ -101,6 +151,22 @@ class UserHistoryController(
)
}

@GetMapping("/history/deposit/count")
suspend fun getDepositHistoryCount(
@RequestParam currency: String?,
@RequestParam startTime: Long?,
@RequestParam endTime: Long?,
@CurrentSecurityContext securityContext: SecurityContext,
): Long {
return walletProxy.getDepositTransactionsCount(
securityContext.jwtAuthentication().name,
securityContext.jwtAuthentication().tokenValue(),
currency,
startTime,
endTime,
)
}

@GetMapping("/history/transaction")
suspend fun getTransactionHistory(
@RequestParam currency: String?,
Expand All @@ -125,6 +191,24 @@ class UserHistoryController(
)
}

@GetMapping("/history/transaction/count")
suspend fun getTransactionHistoryCount(
@RequestParam currency: String?,
@RequestParam category: UserTransactionCategory?,
@RequestParam startTime: Long?,
@RequestParam endTime: Long?,
@CurrentSecurityContext securityContext: SecurityContext,
): Long {
return walletProxy.getTransactionsCount(
securityContext.jwtAuthentication().name,
securityContext.jwtAuthentication().tokenValue(),
currency,
category,
startTime,
endTime,
)
}

@GetMapping("/summary/trade")
suspend fun getTradeTransactionSummary(
@RequestParam startTime: Long?,
Expand Down Expand Up @@ -172,4 +256,11 @@ class UserHistoryController(
limit,
)
}
@PostMapping("/history/swap/count")
suspend fun getSwapHistoryCount(
@CurrentSecurityContext securityContext: SecurityContext,
@RequestBody request: UserTransactionRequest
): Long {
return walletProxy.getSwapTransactionsCount(securityContext.jwtAuthentication().tokenValue(), request)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data class TransactionRequest(
val currency: String?,
val startTime: Long? = null,
val endTime: Long? = null,
val limit: Int,
val offset: Int,
val limit: Int?,
val offset: Int?,
val ascendingByTime: Boolean? = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,32 @@ class MarketUserDataProxyImpl(private val webClient: WebClient) : MarketUserData
}
}

override suspend fun getOrderHistoryCount(
uuid: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
orderType: MatchingOrderType?,
direction: OrderDirection?,
): Long {
return withContext(ProxyDispatchers.market) {
webClient.get()
.uri("$baseUrl/v1/user/order/history/count/$uuid") {
it.queryParam("symbol", symbol)
it.queryParam("startTime", startTime)
it.queryParam("endTime", endTime)
it.queryParam("orderType", orderType)
it.queryParam("direction", direction)
it.build()
}.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}
}

override suspend fun getTradeHistory(
uuid: String,
symbol: String?,
Expand Down Expand Up @@ -167,4 +193,28 @@ class MarketUserDataProxyImpl(private val webClient: WebClient) : MarketUserData
.awaitFirstOrElse { emptyList() }
}
}

override suspend fun getTradeHistoryCount(
uuid: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
direction: OrderDirection?,
): Long {
return withContext(ProxyDispatchers.market) {
webClient.get()
.uri("$baseUrl/v1/user/trade/history/count/$uuid") {
it.queryParam("symbol", symbol)
it.queryParam("startTime", startTime)
it.queryParam("endTime", endTime)
it.queryParam("direction", direction)
it.build()
}.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ class WalletProxyImpl(private val webClient: WebClient) : WalletProxy {
}
}

override suspend fun getDepositTransactionsCount(
uuid: String,
token: String,
currency: String?,
startTime: Long?,
endTime: Long?,
): Long {
logger.info("fetching deposit transaction count for $uuid")
return withContext(ProxyDispatchers.wallet) {
webClient.post()
.uri("$baseUrl/v1/deposit/history/count")
.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, "Bearer $token")
.body(Mono.just(TransactionRequest(currency, startTime, endTime, null, null)))
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}
}

override suspend fun getWithdrawTransactions(
uuid: String,
token: String,
Expand All @@ -121,6 +142,27 @@ class WalletProxyImpl(private val webClient: WebClient) : WalletProxy {
}
}

override suspend fun getWithdrawTransactionsCount(
uuid: String,
token: String,
currency: String?,
startTime: Long?,
endTime: Long?,
): Long {
logger.info("fetching withdraw transaction count for $uuid")
return withContext(ProxyDispatchers.wallet) {
webClient.post()
.uri("$baseUrl/withdraw/history/count")
.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, "Bearer $token")
.body(Mono.just(TransactionRequest(currency, startTime, endTime, null, null)))
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}
}

override suspend fun getTransactions(
uuid: String,
token: String,
Expand Down Expand Up @@ -156,6 +198,25 @@ class WalletProxyImpl(private val webClient: WebClient) : WalletProxy {
.awaitFirstOrElse { emptyList() }
}

override suspend fun getTransactionsCount(
uuid: String,
token: String,
currency: String?,
category: UserTransactionCategory?,
startTime: Long?,
endTime: Long?,
): Long {
return webClient.post()
.uri("$baseUrl/v2/transaction/count")
.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, "Bearer $token")
.body(Mono.just(UserTransactionRequest(currency, category, startTime, endTime)))
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}

override suspend fun getGateWays(
includeOffChainGateways: Boolean,
includeOnChainGateways: Boolean,
Expand Down Expand Up @@ -347,5 +408,20 @@ class WalletProxyImpl(private val webClient: WebClient) : WalletProxy {
.awaitFirstOrElse { emptyList() }
}
}

override suspend fun getSwapTransactionsCount(
token: String,
request: UserTransactionRequest
): Long {
return webClient.post()
.uri("$baseUrl/v1/swap/history/count")
.accept(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, "Bearer $token")
.body(Mono.just(request))
.retrieve()
.onStatus({ t -> t.isError }, { it.createException() })
.bodyToMono<Long>()
.awaitFirstOrElse { 0L }
}
}

Loading
Loading