Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swap): yoroi entry for non ada tokens #2773

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions apps/wallet-mobile/src/features/Swap/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ export const createYoroiEntry = (
): YoroiEntry => {
const amountEntry = {}

const tokenId = createOrder.amounts.sell.tokenId
if (tokenId != null && createOrder.amounts.sell.quantity !== undefined) {
if (tokenId === wallet.primaryTokenInfo.id) {
amountEntry[tokenId] = Quantities.sum([
createOrder.selectedPool.deposit.quantity,
createOrder.selectedPool.batcherFee.quantity,
createOrder.amounts.sell.quantity,
])
} else {
amountEntry[''] = createOrder.selectedPool.deposit.quantity
amountEntry[tokenId] = createOrder.amounts.sell.quantity
}
const sellTokenId = createOrder.amounts.sell.tokenId
// summing fees is missing the frontend fee
if (sellTokenId === wallet.primaryTokenInfo.id) {
amountEntry[sellTokenId] = Quantities.sum([
createOrder.selectedPool.deposit.quantity,
createOrder.selectedPool.batcherFee.quantity,
createOrder.amounts.sell.quantity,
])
} else {
amountEntry[wallet.primaryTokenInfo.id] = Quantities.sum([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

createOrder.selectedPool.deposit.quantity,
createOrder.selectedPool.batcherFee.quantity,
])
amountEntry[sellTokenId] = createOrder.amounts.sell.quantity
}

return {
address: address,
amounts: amountEntry,
Expand Down