fix(swap response): parsing token out (#377)

This commit is contained in:
Yusuf Seyrek 2023-08-17 12:56:42 +03:00 committed by GitHub
parent 13d153de69
commit d63c7f100a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,8 @@ export default function getTokenOutFromSwapResponse(
const events = rawLogs[0].events const events = rawLogs[0].events
const tokenSwappedEvent = events.find((e: { type: string }) => e.type === 'token_swapped') const tokenSwappedEvent = events.find((e: { type: string }) => e.type === 'token_swapped')
const tokensOutValue = tokenSwappedEvent.attributes.find( const tokensOutValue = tokenSwappedEvent.attributes.find(
(a: { key: string }) => a.key === 'tokens_out', (a: { key: string; value: string }) =>
a.key === 'tokens_out' && a.value.toLowerCase().includes(denom.toLowerCase()),
).value ).value
const amount = tokensOutValue.split(denom)[0] const amount = tokensOutValue.split(denom)[0]