show slippage msg in notifications

This commit is contained in:
tjs 2023-01-05 19:44:27 -05:00
parent e3aedfc8a9
commit 8a04998374
4 changed files with 17 additions and 19 deletions

View File

@ -301,23 +301,14 @@ const Balance = ({ bank }: { bank: Bank }) => {
{asPath.includes('/trade') && isBaseOrQuote ? (
<LinkButton
className="font-normal underline-offset-4"
onClick={() =>
handleTradeFormBalanceClick(
parseFloat(formatDecimal(balance, bank.mintDecimals)),
isBaseOrQuote
)
}
onClick={() => handleTradeFormBalanceClick(balance, isBaseOrQuote)}
>
{formatDecimal(balance, bank.mintDecimals)}
</LinkButton>
) : asPath.includes('/swap') ? (
<LinkButton
className="font-normal underline-offset-4"
onClick={() =>
handleSwapFormBalanceClick(
parseFloat(formatDecimal(balance, bank.mintDecimals))
)
}
onClick={() => handleSwapFormBalanceClick(balance)}
>
{formatDecimal(balance, bank.mintDecimals)}
</LinkButton>

View File

@ -123,13 +123,20 @@ const Notification = ({ notification }: { notification: Notification }) => {
let parsedTitle: string | undefined
if (description) {
if (
description?.includes('Timed out awaiting') ||
description?.includes('was not confirmed')
description.includes('Timed out awaiting') ||
description.includes('was not confirmed')
) {
parsedTitle = 'Transaction status unknown'
}
}
let parsedDescription = description
if (
description?.includes('{"err":{"InstructionError":[2,{"Custom":6001}]}}')
) {
parsedDescription = 'Your max slippage tolerance was exceeded'
}
// if the notification is a success, then hide the confirming tx notification with the same txid
useEffect(() => {
if ((type === 'error' || type === 'success') && txid) {
@ -247,11 +254,11 @@ const Notification = ({ notification }: { notification: Notification }) => {
</div>
<div className={`ml-2 flex-1`}>
<p className={`text-th-fgd-1`}>{parsedTitle || title}</p>
{description ? (
{parsedDescription ? (
<p
className={`mb-0 mt-0.5 break-all text-sm leading-tight text-th-fgd-4`}
>
{description}
{parsedDescription}
</p>
) : null}
{txid ? (

View File

@ -45,10 +45,10 @@ export const getTokenInMax = (
}
}
const inputTokenBalance = floorToDecimal(
mangoAccount.getTokenBalanceUi(inputBank),
inputBank.mintDecimals
const inputTokenBalance = new Decimal(
mangoAccount.getTokenBalanceUi(inputBank)
)
const maxAmountWithoutMargin = inputTokenBalance.gt(0)
? inputTokenBalance
: new Decimal(0)

View File

@ -69,8 +69,8 @@ const emptyWallet = new EmptyWallet(Keypair.generate())
const initMangoClient = (provider: AnchorProvider): MangoClient => {
return MangoClient.connect(provider, CLUSTER, MANGO_V4_ID[CLUSTER], {
// blockhashCommitment: 'confirmed',
prioritizationFee: 2000,
idsSource: 'get-program-accounts',
prioritizationFee: 2,
postSendTxCallback: ({ txid }: { txid: string }) => {
notify({
title: 'Transaction sent',