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',
|
'56': 'bnb-mainnet',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NATIVE_SYMBOLS: Record<string, string> = {
|
||||||
|
'1': 'ETH',
|
||||||
|
'137': 'POL',
|
||||||
|
'56': 'BNB',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function fetchAlchemyTransfers(
|
async function fetchAlchemyTransfers(
|
||||||
@@ -272,6 +278,14 @@ async function pairTransfers(
|
|||||||
pairedContractAddress:
|
pairedContractAddress:
|
||||||
tokIn[0].rawContract?.address ?? undefined,
|
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) {
|
} else if (tokOut.length > 0) {
|
||||||
combined.push(mapTransfer(tokOut[0]))
|
combined.push(mapTransfer(tokOut[0]))
|
||||||
} else if (tokIn.length > 0) {
|
} else if (tokIn.length > 0) {
|
||||||
|
|||||||
@@ -459,7 +459,7 @@
|
|||||||
((e.target as HTMLElement).style.display =
|
((e.target as HTMLElement).style.display =
|
||||||
'none')} />
|
'none')} />
|
||||||
{Number(tx.pairedValue).toFixed(4)}
|
{Number(tx.pairedValue).toFixed(4)}
|
||||||
{tx.pairedSymbol}
|
{tx.pairedSymbol ?? w.symbol}
|
||||||
{:else if tx.tokenSymbol}
|
{:else if tx.tokenSymbol}
|
||||||
<img
|
<img
|
||||||
src={tx.logo ||
|
src={tx.logo ||
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
{network?.symbol ?? 'ETH'}
|
{network?.symbol ?? 'ETH'}
|
||||||
<span class="mx-1">→</span>
|
<span class="mx-1">→</span>
|
||||||
{Number(details.pairedValue).toFixed(4)}
|
{Number(details.pairedValue).toFixed(4)}
|
||||||
{details.pairedSymbol}
|
{details.pairedSymbol ?? network?.symbol ?? 'ETH'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user