Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-06 17:10:55 +04:00
parent 91200c4973
commit 0693835f07
9 changed files with 99 additions and 13 deletions

View file

@ -62,20 +62,21 @@ interface ExpressHistoryDao {
): Flow<List<ExpressExchangeEntity>>
/**
* Incoming swaps: the viewed currency is the swap's `to` side. Such a deal was initiated from a
* different coin, so the row is stored under that coin's `from_address` hence this query is
* cross-address, matched by the `to` asset. Join to on-chain by `payout_hash`.
* Incoming swaps: the viewed currency is the swap's `to` side, so the row is looked up by its `payout_address`
* (where the target assets landed = this currency's address). Join to on-chain by `payout_hash`.
*/
@Query(
"""
SELECT * FROM express_exchange
WHERE to_network = :network
WHERE payout_address = :payoutAddress
AND to_network = :network
AND to_contract_address = :contract
AND (created_at >= :fromCreatedAtIso OR status IN (:activeStatuses))
ORDER BY created_at DESC
""",
)
fun observeIncomingSwaps(
payoutAddress: String,
network: String,
contract: String,
fromCreatedAtIso: String,

View file

@ -12,9 +12,8 @@ import androidx.room.*
indices = [
// Outgoing swaps lookup (observeOutgoingSwaps): from-address + from-asset equality, created_at range/sort.
Index(value = ["from_address", "from_network", "from_contract_address", "created_at"]),
// Incoming (cross-owner) swaps lookup (observeIncomingSwaps): to-asset equality, created_at range/sort.
// No owner filter here, so to_contract_address in the index is what keeps a popular to-network selective.
Index(value = ["to_network", "to_contract_address", "created_at"]),
// Incoming swaps lookup (observeIncomingSwaps): payout-address + to-asset equality, created_at range/sort.
Index(value = ["payout_address", "to_network", "to_contract_address", "created_at"]),
],
)
data class ExpressExchangeEntity(