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

[Gnosis]: Show a better price estimate on transactions #635

Merged
merged 1 commit into from
Aug 6, 2021
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
23 changes: 16 additions & 7 deletions src/composables/trade/useGnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,25 @@ export default function useGnosis({
owner: account.value
});

const sellAmount = exactIn.value
? tokenInAmountInput.value
: formatUnits(quote.maximumInAmount, tokenIn.value.decimals).toString();

const buyAmount = exactIn.value
? formatUnits(
quote.minimumOutAmount,
tokenOut.value.decimals
).toString()
: tokenOutAmountInput.value;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will help the user understand where the amounts are coming from when exploring Gnosis explorer.


const tokenInAmountEst = exactIn.value ? '' : '~';
const tokenOutAmountEst = exactIn.value ? '~' : '';

const summary = `${tokenInAmountEst}${fNum(
tokenInAmountInput.value,
'token'
)} ${tokenIn.value.symbol} -> ${tokenOutAmountEst}${fNum(
tokenOutAmountInput.value,
'token'
)} ${tokenOut.value.symbol}`;
const summary = `${tokenInAmountEst}${fNum(sellAmount, 'token')} ${
tokenIn.value.symbol
} -> ${tokenOutAmountEst}${fNum(buyAmount, 'token')} ${
tokenOut.value.symbol
}`;

const { validTo, partiallyFillable } = unsignedOrder;

Expand Down