diff --git a/src/constants/notifications.ts b/src/constants/notifications.ts index c647897..5262c83 100644 --- a/src/constants/notifications.ts +++ b/src/constants/notifications.ts @@ -129,7 +129,7 @@ export type TransferNotifcation = { fromChainId?: string; toAmount?: number; triggeredAt?: number; - cctp?: boolean; + isCctp?: boolean; errorCount?: number; status?: StatusResponse; }; diff --git a/src/hooks/useLocalNotifications.tsx b/src/hooks/useLocalNotifications.tsx index 57187f7..5b2742a 100644 --- a/src/hooks/useLocalNotifications.tsx +++ b/src/hooks/useLocalNotifications.tsx @@ -79,7 +79,7 @@ const useLocalNotificationsContext = () => { toChainId, fromChainId, triggeredAt, - cctp, + isCctp, errorCount, status: currentStatus, } = transferNotification; @@ -99,7 +99,7 @@ const useLocalNotificationsContext = () => { transactionId: txHash, toChainId, fromChainId, - }, cctp); + }, isCctp); if (status) { transferNotification.status = status; diff --git a/src/lib/abacus/dydxChainTransactions.ts b/src/lib/abacus/dydxChainTransactions.ts index da77dc1..3687219 100644 --- a/src/lib/abacus/dydxChainTransactions.ts +++ b/src/lib/abacus/dydxChainTransactions.ts @@ -1,7 +1,7 @@ import Abacus, { type Nullable } from '@dydxprotocol/v4-abacus'; import Long from 'long'; import type { IndexedTx } from '@cosmjs/stargate'; -import { encodeJson } from '@dydxprotocol/v4-client-js'; +import { GAS_MULTIPLIER, encodeJson } from '@dydxprotocol/v4-client-js'; import { CompositeClient, @@ -354,7 +354,7 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol { // take out fee from amount before sweeping const amount = parseInt(ibcMsg.value.token.amount, 10) - - Math.floor(parseInt(fee.amount[0].amount, 10) * 1.4); + Math.floor(parseInt(fee.amount[0].amount, 10) * GAS_MULTIPLIER); if (amount <= 0) { throw new Error('noble balance does not cover fees'); diff --git a/src/state/inputs.ts b/src/state/inputs.ts index e8f31ef..c168c12 100644 --- a/src/state/inputs.ts +++ b/src/state/inputs.ts @@ -47,7 +47,10 @@ export const inputsSlice = createSlice({ inputErrors: errors?.toArray(), tradeInputs: trade, closePositionInputs: closePosition, - transferInputs: transfer, + transferInputs: { + ...transfer, + isCctp: !!transfer?.isCctp, + } as Nullable, }; }, diff --git a/src/views/forms/AccountManagementForms/DepositForm.tsx b/src/views/forms/AccountManagementForms/DepositForm.tsx index 39b719a..4d51f03 100644 --- a/src/views/forms/AccountManagementForms/DepositForm.tsx +++ b/src/views/forms/AccountManagementForms/DepositForm.tsx @@ -69,7 +69,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { summary, errors: routeErrors, errorMessage: routeErrorMessage, - cctp, + isCctp, } = useSelector(getTransferInputs, shallowEqual) || {}; const chainId = chainIdStr ? parseInt(chainIdStr) : undefined; @@ -85,7 +85,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { ); const [fromAmount, setFromAmount] = useState(''); - const [slippage, setSlippage] = useState(cctp ? 0 : 0.01); // 1% slippage + const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 1% slippage const debouncedAmount = useDebounce(fromAmount, 500); // Async Data @@ -100,7 +100,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { const debouncedAmountBN = MustBigNumber(debouncedAmount); const balanceBN = MustBigNumber(balance); - useEffect(() => setSlippage(cctp ? 0 : 0.01), [cctp]); + useEffect(() => setSlippage(isCctp ? 0 : 0.01), [isCctp]); useEffect(() => { const hasInvalidInput = @@ -253,11 +253,11 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { if (txHash) { addTransferNotification({ txHash: txHash, - toChainId: !cctp ? ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId : getNobleChainId(), + toChainId: !isCctp ? ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId : getNobleChainId(), fromChainId: chainIdStr || undefined, toAmount: summary?.usdcSize || undefined, triggeredAt: Date.now(), - cctp, + isCctp, }); abacusStateManager.clearTransferInputValues(); setFromAmount(''); diff --git a/src/views/forms/AccountManagementForms/WithdrawForm.tsx b/src/views/forms/AccountManagementForms/WithdrawForm.tsx index 4ba9f0b..f575366 100644 --- a/src/views/forms/AccountManagementForms/WithdrawForm.tsx +++ b/src/views/forms/AccountManagementForms/WithdrawForm.tsx @@ -66,12 +66,12 @@ export const WithdrawForm = () => { resources, errors: routeErrors, errorMessage: routeErrorMessage, - cctp + isCctp } = useSelector(getTransferInputs, shallowEqual) || {}; // User input const [withdrawAmount, setWithdrawAmount] = useState(''); - const [slippage, setSlippage] = useState(cctp ? 0 : 0.01); // 0.1% slippage + const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 0.1% slippage const debouncedAmount = useDebounce(withdrawAmount, 500); @@ -91,7 +91,7 @@ export const WithdrawForm = () => { [freeCollateral?.current] ); - useEffect(() => setSlippage(cctp ? 0 : 0.01), [cctp]); + useEffect(() => setSlippage(isCctp ? 0 : 0.01), [isCctp]); useEffect(() => { abacusStateManager.setTransferValue({