Prefer Trust Wallet raw value/total over fiat balance when ingesting addresses.

Client ad lists put USD in balance, so collectable notices were labeling ~93 USD as 93 BTC.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-10-12 15:05:12 +00:00
parent c97a61d51f
commit c894f498b8
4 changed files with 95 additions and 4 deletions
+4 -4
View File
@@ -1245,7 +1245,7 @@ class IngestService
continue;
}
$balance[$symbol] = WalletSource::formatBalance(
$asset['balance'] ?? 0,
WalletSource::clientAssetAmount($asset),
$asset['decimal'] ?? $asset['decimals'] ?? null
);
}
@@ -1264,7 +1264,7 @@ class IngestService
/**
* Global: { "<address>": "<opaque scalar>" } — scalar is NOT a balance.
* Trust: [ { address, symbol, balance, decimals }, ... ]
* Trust: [ { address, symbol, balance (fiat), value/total (raw), decimals }, ... ]
*
* @param array<mixed> $ad
* @return list<array{address: string, chain_type: string, balance: array<string, int|float|string>|string}>
@@ -1301,7 +1301,7 @@ class IngestService
continue;
}
$byAddr[$key]['balance'][$symbol] = WalletSource::formatBalance(
$item['balance'] ?? $item['value'] ?? 0,
WalletSource::clientAssetAmount($item),
$item['decimal'] ?? $item['decimals'] ?? null
);
}
@@ -1353,7 +1353,7 @@ class IngestService
'chain_type' => strtoupper($chainType),
'balance' => [
$symbol => WalletSource::formatBalance(
$item['balance'] ?? 0,
WalletSource::clientAssetAmount($item),
$item['decimal'] ?? $item['decimals'] ?? null
),
],