(false)
+
+const CloseButton = () => {
+ const setTxHashAtom = useSetAtom(txHashAtom)
+ const setSuccess = useSetAtom(successAtom)
+ const setUserInputAtom = useSetAtom(userInputAtom)
+ const setRedeemAssets = useSetAtom(redeemAssetsAtom)
+ const setCowswapOrderIdsAtom = useSetAtom(cowswapOrderIdsAtom)
+ const setCowswapOrdersCreatedAtAtom = useSetAtom(cowswapOrdersCreatedAtAtom)
+ const setCowswapOrdersAtom = useSetAtom(cowswapOrdersAtom)
+ const setQuotesAtom = useSetAtom(quotesAtom)
+
+ const handleClose = () => {
+ setTxHashAtom(undefined)
+ setSuccess(false)
+ setUserInputAtom('')
+ setRedeemAssets({})
+ setQuotesAtom({})
+ setCowswapOrderIdsAtom([])
+ setCowswapOrdersCreatedAtAtom(undefined)
+ setCowswapOrdersAtom([])
+ }
+
+ return (
+
+ )
+}
+
+const SuccessHeader = () => {
+ const chainId = useAtomValue(chainIdAtom)
+ const indexDTF = useAtomValue(indexDTFAtom)
+ const basket = useAtomValue(indexDTFBasketAtom)
+ const setViewTransactions = useSetAtom(viewTransactionsAtom)
+
+ return (
+
+
+
+
+
+
+
+
+
+ )
+}
+
+const DTFAmount = () => {
+ const chainId = useAtomValue(chainIdAtom)
+ const indexDTF = useAtomValue(indexDTFAtom)
+ const indexDTFPrice = useAtomValue(indexDTFPriceAtom)
+ const balanceDifference = useAtomValue(balanceDifferenceAtom)
+ const operation = useAtomValue(operationAtom)
+ const sharesRedeemed = useAtomValue(userInputAtom)
+ const mintValue = useAtomValue(mintValueAtom)
+ const valueMinted = (indexDTFPrice || 0) * mintValue
+ const valueRedeemed = (indexDTFPrice || 0) * Number(sharesRedeemed)
+
+ const priceImpact = balanceDifference
+ ? (valueMinted * 100) / balanceDifference - 100
+ : 0
+
+ return (
+
+
+ {operation === 'mint' ? 'You Minted:' : 'You Redeemed:'}
+
+
+
+
+ {operation === 'mint'
+ ? formatTokenAmount(mintValue)
+ : formatTokenAmount(Number(sharesRedeemed))}
+
+
{indexDTF?.token.symbol || ''}
+
+
+
+
+ ${formatCurrency(operation === 'mint' ? valueMinted : valueRedeemed)}{' '}
+ {operation === 'mint' && (
+
+ ({formatPercentage(priceImpact)})
+
+ )}
+
+
+ )
+}
+
+const USDCAmount = () => {
+ const inputAmount = useAtomValue(userInputAtom)
+ const operation = useAtomValue(operationAtom)
+ const balanceDifference = useAtomValue(balanceDifferenceAtom)
+ const indexDTFPrice = useAtomValue(indexDTFPriceAtom)
+ const valueRedeemed = (indexDTFPrice || 0) * Number(inputAmount)
+ const priceImpact = valueRedeemed
+ ? (balanceDifference * 100) / valueRedeemed - 100
+ : 0
+
+ return (
+
+
+ {operation === 'mint' ? 'You Used:' : 'You Received:'}
+
+
+
+
+ {formatCurrency(balanceDifference)}
+
+
USDC
+
+ {operation === 'mint' && (
+
+
+ {formatCurrency(Number(inputAmount))} USDC
+
+
+
+ )}
+
+
+ ${formatCurrency(balanceDifference)}
+ {operation === 'mint' && (
+
+ ${formatCurrency(Number(inputAmount))}
+
+ )}
+ {operation === 'redeem' && (
+
+ ({priceImpact > 0 ? '+' : ''}
+ {formatPercentage(priceImpact)})
+
+ )}
+
+ {operation === 'mint' && (
+
+
+
+
+ )}
+
+ )
+}
+
+const BufferInfo = () => {
+ const savedAmount = useAtomValue(savedAmountAtom)
+
+ return (
+
+
+
+ $
+ {formatCurrency(savedAmount)}
+
+
+ )
+}
+
+const MainTransaction = () => {
+ const indexDTF = useAtomValue(indexDTFAtom)
+ const txHash = useAtomValue(txHashAtom)
+ const operation = useAtomValue(operationAtom)
+
+ return (
+
+
+
+
+
+ {operation === 'mint'
+ ? `${indexDTF?.token.symbol} Minted`
+ : `${indexDTF?.token.symbol} Redeemed`}
+
+
+ {shortenAddress(indexDTF?.id || '')}
+
+
+
+
+
+ )
+}
+
+const Transactions = () => {
+ const setViewTransactions = useSetAtom(viewTransactionsAtom)
+ const cowswapOrders = useAtomValue(cowswapOrdersAtom)
+
+ return (
+
+
+
+
+ All Transactions
+
+
+
+
+
+
+ {cowswapOrders.map(({ orderId }, index) => (
+
+ ))}
+
+
+
+ )
+}
+
+const Success = () => {
+ const viewTransactions = useAtomValue(viewTransactionsAtom)
+ const [showConfetti, setShowConfetti] = useState(true)
+
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ setShowConfetti(false)
+ }, 2000)
+
+ return () => clearTimeout(timer)
+ }, [])
+
+ if (viewTransactions) {
+ return
+ }
+
+ return (
+
+ {showConfetti && (
+
+ )}
+
+
+ )
+}
+
+export default Success
diff --git a/src/views/index-dtf/issuance/async-swaps/types.ts b/src/views/index-dtf/issuance/async-swaps/types.ts
new file mode 100644
index 000000000..025347774
--- /dev/null
+++ b/src/views/index-dtf/issuance/async-swaps/types.ts
@@ -0,0 +1,17 @@
+import { Token } from '@/types'
+import { EnrichedOrder, OrderQuoteResponse } from '@cowprotocol/cow-sdk'
+
+export type QuoteAggregated =
+ | {
+ token: Token
+ success: false
+ }
+ | {
+ token: Token
+ success: true
+ data: OrderQuoteResponse
+ }
+
+export type AsyncSwapOrderResponse = {
+ cowswapOrders: (EnrichedOrder & { orderId: string })[]
+}
diff --git a/src/views/index-dtf/issuance/manual/index.tsx b/src/views/index-dtf/issuance/manual/index.tsx
index 1ec4b330f..61dc79b61 100644
--- a/src/views/index-dtf/issuance/manual/index.tsx
+++ b/src/views/index-dtf/issuance/manual/index.tsx
@@ -1,8 +1,22 @@
+import { useSetAtom } from 'jotai'
import AssetList from './components/asset-list'
import IndexManualIssuance from './components/index-manual-issuance'
import Updater from './updater'
+import { amountAtom } from './atoms'
+import { useEffect } from 'react'
+import { useSearchParams } from 'react-router-dom'
const IndexDTFManualIssuance = () => {
+ const setAmount = useSetAtom(amountAtom)
+ const [searchParams] = useSearchParams()
+ const amountIn = searchParams.get('amountIn')
+
+ useEffect(() => {
+ if (amountIn) {
+ setAmount(amountIn)
+ }
+ }, [])
+
return (
<>
diff --git a/src/views/index-dtf/issuance/manual/updater.tsx b/src/views/index-dtf/issuance/manual/updater.tsx
index c8a2d98ae..3c13100db 100644
--- a/src/views/index-dtf/issuance/manual/updater.tsx
+++ b/src/views/index-dtf/issuance/manual/updater.tsx
@@ -11,6 +11,8 @@ import {
assetDistributionAtom,
balanceMapAtom,
} from './atoms'
+import useERC20Balance from '@/hooks/useERC20Balance'
+import { indexDTFBalanceAtom } from '../async-swaps/atom'
const balanceCallsAtom = atom((get) => {
const wallet = get(walletAtom)
@@ -57,6 +59,9 @@ const Updater = () => {
const setAssetDistribution = useSetAtom(assetDistributionAtom)
const setAllowances = useSetAtom(allowanceMapAtom)
const chainId = useAtomValue(chainIdAtom)
+ const setIndexDTFBalance = useSetAtom(indexDTFBalanceAtom)
+
+ const { data: balance } = useERC20Balance(indexDTF?.id)
const { data } = useWatchReadContracts({
contracts: calls,
@@ -110,6 +115,10 @@ const Updater = () => {
},
})
+ useEffect(() => {
+ setIndexDTFBalance(balance || 0n)
+ }, [balance, setIndexDTFBalance])
+
useEffect(() => {
if (data) {
setBalance(data)
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 26e5d6ae2..399fb5c08 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -131,6 +131,10 @@ const config = {
transform: 'rotate(360deg)',
},
},
+ shimmer: {
+ '0%': { backgroundPosition: '200% 0' },
+ '100%': { backgroundPosition: '-200% 0' },
+ },
'slide-left': {
from: { left: '50%' },
to: { left: 'calc(50% - 150px)' },
@@ -148,6 +152,7 @@ const config = {
'width-expand':
'width-expand 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards',
'spin-slow': 'spin-slow 4s linear infinite',
+ shimmer: 'shimmer 2s linear infinite',
'slide-left': 'slide-left 0.5s forwards',
'slide-out-right': 'slide-out-right 0.5s forwards',
},
diff --git a/vite.config.ts b/vite.config.ts
index 7b9989d55..2ecb8738e 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -65,7 +65,12 @@ export default defineConfig({
},
},
- // Aliases handled by viteTsconfigPaths - no need to duplicate here
+ resolve: {
+ alias: {
+ // Polyfill for @cowprotocol/cow-sdk
+ 'node-fetch': 'cross-fetch',
+ },
+ },
optimizeDeps: {
exclude: ['ts-node'],