Add token-to-native swap detection with NATIVE_SYMBOLS map
This commit is contained in:
@@ -104,6 +104,12 @@ const ALCHEMY_NETWORKS: Record<string, string> = {
|
||||
'56': 'bnb-mainnet',
|
||||
}
|
||||
|
||||
const NATIVE_SYMBOLS: Record<string, string> = {
|
||||
'1': 'ETH',
|
||||
'137': 'POL',
|
||||
'56': 'BNB',
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function fetchAlchemyTransfers(
|
||||
@@ -272,6 +278,14 @@ async function pairTransfers(
|
||||
pairedContractAddress:
|
||||
tokIn[0].rawContract?.address ?? undefined,
|
||||
})
|
||||
} else if (tokOut.length > 0 && extIn.length > 0) {
|
||||
combined.push({
|
||||
...mapTransfer(tokOut[0]),
|
||||
pairedValue: String(extIn[0].value),
|
||||
pairedSymbol: chainid
|
||||
? NATIVE_SYMBOLS[chainid]
|
||||
: undefined,
|
||||
})
|
||||
} else if (tokOut.length > 0) {
|
||||
combined.push(mapTransfer(tokOut[0]))
|
||||
} else if (tokIn.length > 0) {
|
||||
|
||||
@@ -459,7 +459,7 @@
|
||||
((e.target as HTMLElement).style.display =
|
||||
'none')} />
|
||||
{Number(tx.pairedValue).toFixed(4)}
|
||||
{tx.pairedSymbol}
|
||||
{tx.pairedSymbol ?? w.symbol}
|
||||
{:else if tx.tokenSymbol}
|
||||
<img
|
||||
src={tx.logo ||
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
{network?.symbol ?? 'ETH'}
|
||||
<span class="mx-1">→</span>
|
||||
{Number(details.pairedValue).toFixed(4)}
|
||||
{details.pairedSymbol}
|
||||
{details.pairedSymbol ?? network?.symbol ?? 'ETH'}
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user