1
1
'use client'
2
2
3
+ import { AnimatePresence , motion } from 'framer-motion'
3
4
import { useAtom } from 'jotai'
4
5
import range from 'lodash/range'
5
6
import { useCallback , useEffect , useMemo } from 'react'
6
7
import { isAddressEqual } from 'viem'
7
8
8
9
import { useQueryParams } from '@/app/earn-old/use-query-params'
9
10
import { tradeMachineAtom } from '@/app/store/trade-machine'
11
+ import { Receive } from '@/components/receive'
10
12
import { SelectTokenModal } from '@/components/swap/components/select-token-modal'
11
13
import { TransactionReviewModal } from '@/components/swap/components/transaction-review'
12
14
import { WarningType } from '@/components/swap/components/warning'
@@ -39,11 +41,13 @@ export function EarnWidget() {
39
41
indexToken,
40
42
inputToken,
41
43
inputTokens,
44
+ outputTokens,
42
45
inputTokenAmount,
43
46
inputValue,
44
47
isMinting,
45
48
onChangeInputTokenAmount,
46
49
onSelectInputToken,
50
+ onSelectOutputToken,
47
51
balances,
48
52
products,
49
53
outputToken,
@@ -60,6 +64,8 @@ export function EarnWidget() {
60
64
inputBalance,
61
65
inputBalanceFormatted,
62
66
isFetchingQuote,
67
+ ouputAmount,
68
+ outputAmountUsd,
63
69
resetData,
64
70
} = useFormattedEarnData ( )
65
71
@@ -73,6 +79,12 @@ export function EarnWidget() {
73
79
onClose : onCloseSelectInputToken ,
74
80
} = useDisclosure ( )
75
81
82
+ const {
83
+ isOpen : isSelectOutputTokenOpen ,
84
+ onOpen : onOpenSelectOutputToken ,
85
+ onClose : onCloseSelectOutputToken ,
86
+ } = useDisclosure ( )
87
+
76
88
const [ tradeState , sendTradeEvent ] = useAtom ( tradeMachineAtom )
77
89
78
90
const onClickBalance = useCallback ( ( ) => {
@@ -112,6 +124,30 @@ export function EarnWidget() {
112
124
onClickBalance = { onClickBalance }
113
125
onSelectToken = { ( ) => isMinting && onOpenSelectInputToken ( ) }
114
126
/>
127
+ < AnimatePresence mode = 'wait' >
128
+ { ! isMinting && (
129
+ < motion . div
130
+ initial = { { height : 0 , opacity : 0 } }
131
+ animate = { { height : 'auto' , opacity : 1 } }
132
+ exit = { { height : 0 , opacity : 0 } }
133
+ transition = { {
134
+ duration : 0.3 ,
135
+ height : { duration : 0.2 } ,
136
+ opacity : { duration : 0.2 } ,
137
+ } }
138
+ className = 'overflow-hidden'
139
+ >
140
+ < Receive
141
+ isLoading = { isFetchingQuote }
142
+ outputAmount = { ouputAmount }
143
+ outputAmountUsd = { outputAmountUsd }
144
+ selectedOutputToken = { outputToken }
145
+ onSelectToken = { onOpenSelectOutputToken }
146
+ />
147
+ </ motion . div >
148
+ ) }
149
+ </ AnimatePresence >
150
+
115
151
< Projection
116
152
isQuoteLoading = { isFetchingQuote }
117
153
amount = { inputValue }
@@ -170,6 +206,17 @@ export function EarnWidget() {
170
206
address = { address }
171
207
tokens = { inputTokens }
172
208
/>
209
+ < SelectTokenModal
210
+ isDarkMode = { true }
211
+ isOpen = { isSelectOutputTokenOpen }
212
+ onClose = { onCloseSelectOutputToken }
213
+ onSelectedToken = { ( tokenSymbol , chainId ) => {
214
+ onSelectOutputToken ( tokenSymbol , chainId )
215
+ onCloseSelectOutputToken ( )
216
+ } }
217
+ address = { address }
218
+ tokens = { outputTokens }
219
+ />
173
220
< TransactionReviewModal
174
221
isDarkMode
175
222
onClose = { ( ) => {
0 commit comments