@@ -72,13 +72,12 @@ export const SupplyModalContentWrapperSDK = (
7272 const wrappedTokenReserves = useWrappedTokens ( ) ;
7373 const { walletBalances } = useWalletBalances ( currentMarketData ) ;
7474 const { supplyCap : supplyCapUsage , debtCeiling : debtCeilingUsage } = useAssetCapsSDK ( ) ;
75- const { supplyReserves } = useAppDataContext ( ) ; //! with SDK
75+ const { supplyReserves } = useAppDataContext ( ) ;
7676 const { poolReserve, reserveUserState, marketUserState } = params ;
7777
7878 const wrappedToken = wrappedTokenReserves . find (
7979 ( r ) => r . tokenOut . underlyingAsset === params . underlyingAsset
8080 ) ;
81-
8281 const canSupplyAsWrappedToken =
8382 wrappedToken &&
8483 walletBalances [ wrappedToken . tokenIn . underlyingAsset . toLowerCase ( ) ] . amount !== '0' ;
@@ -153,15 +152,10 @@ export const SupplyModalContentSDK = React.memo(
153152 debtCeilingWarning,
154153 user,
155154 } : SupplyModalContentPropsSDK ) => {
156- // const { marketReferencePriceInUsd } = useAppDataContext();
157155 const { mainTxState : supplyTxState , gasLimit, txError } = useModalContext ( ) ;
158156 const { chainId, currentAccount } = useWeb3Context ( ) ;
159- const [ minRemainingBaseTokenBalance , currentMarketData , currentNetworkConfig ] = useRootStore (
160- useShallow ( ( state ) => [
161- state . poolComputed . minRemainingBaseTokenBalance ,
162- state . currentMarketData ,
163- state . currentNetworkConfig ,
164- ] )
157+ const [ currentMarketData , currentNetworkConfig ] = useRootStore (
158+ useShallow ( ( state ) => [ state . currentMarketData , state . currentNetworkConfig ] )
165159 ) ;
166160
167161 // states
@@ -175,12 +169,11 @@ export const SupplyModalContentSDK = React.memo(
175169 const supplyApy = poolReserve . supplyInfo . apy . value ;
176170
177171 // Calculate max amount to supply
178- const maxAmountToSupply = getMaxAmountAvailableToSupplySDK ( {
172+ const maxAmountToSupply = getMaxAmountAvailableToSupplySDK (
179173 walletBalance ,
180- reserve : poolReserve , // ReserveWithId del SDK
181- isNativeSelected : ! ! poolReserve . acceptsNative && supplyUnWrapped ,
182- minRemainingBaseTokenBalance,
183- } ) ;
174+ poolReserve ,
175+ underlyingAsset . toLowerCase ( )
176+ ) ;
184177
185178 const handleChange = ( value : string ) => {
186179 if ( value === '-1' ) {
@@ -230,17 +223,14 @@ export const SupplyModalContentSDK = React.memo(
230223 } ) ;
231224
232225 if ( result . isOk ( ) ) {
233- //!Debug
234- console . log ( 'healthFactorPreview result' , result . value ) ;
235226 setHfPreviewAfter ( result . value . after ?. toString ( ) ) ;
236227 } else {
237228 setHfPreviewAfter ( undefined ) ;
238229 }
239230 } catch ( error ) {
240- console . error ( 'healthFactorPreview failed' , error ) ;
241231 setHfPreviewAfter ( undefined ) ;
242232 }
243- } , 2000 ) ;
233+ } , 300 ) ;
244234
245235 return ( ) => clearTimeout ( timer ) ;
246236 } , [
@@ -343,7 +333,7 @@ export const SupplyModalContentSDK = React.memo(
343333 < DetailsHFLine
344334 visibleHfChange = { ! ! amount }
345335 healthFactor = { user ? user . healthFactor : '-1' }
346- futureHealthFactor = { hfPreviewAfter ?. toString ( ) }
336+ futureHealthFactor = { hfPreviewAfter ?. toString ( ) ? hfPreviewAfter . toString ( ) : '-1' }
347337 />
348338 </ TxModalDetails >
349339
@@ -372,9 +362,6 @@ export const SupplyWrappedTokenModalContentSDK = ({
372362 const { mainTxState : supplyTxState , gasLimit, txError } = useModalContext ( ) ;
373363 const { currentAccount } = useWeb3Context ( ) ;
374364 const { walletBalances } = useWalletBalances ( currentMarketData ) ;
375- const minRemainingBaseTokenBalance = useRootStore (
376- ( state ) => state . poolComputed . minRemainingBaseTokenBalance
377- ) ;
378365 const [ hfPreviewAfter , setHfPreviewAfter ] = useState < string | undefined > ( ) ;
379366 const supplyProtocolIncentives = mapAaveProtocolIncentives ( poolReserve . incentives , 'supply' ) ;
380367
@@ -421,12 +408,11 @@ export const SupplyWrappedTokenModalContentSDK = ({
421408 const supplyCap = poolReserve . supplyInfo . supplyCap . amount . value ;
422409 const totalLiquidity = poolReserve . supplyInfo . total . value ;
423410
424- const maxAmountToSupplyTokenOut = getMaxAmountAvailableToSupplySDK ( {
425- walletBalance : tokenOutBalance ,
426- reserve : poolReserve ,
427- isNativeSelected : false ,
428- minRemainingBaseTokenBalance,
429- } ) ;
411+ const maxAmountToSupplyTokenOut = getMaxAmountAvailableToSupplySDK (
412+ tokenOutBalance ,
413+ poolReserve ,
414+ poolReserve . underlyingToken . address
415+ ) ;
430416
431417 const tokenOutRemainingSupplyCap = remainingCap ( supplyCap , totalLiquidity ) ;
432418
@@ -512,10 +498,9 @@ export const SupplyWrappedTokenModalContentSDK = ({
512498 setHfPreviewAfter ( undefined ) ;
513499 }
514500 } catch ( error ) {
515- console . error ( 'healthFactorPreview failed' , error ) ;
516501 setHfPreviewAfter ( undefined ) ;
517502 }
518- } , 2000 ) ;
503+ } , 300 ) ;
519504
520505 return ( ) => clearTimeout ( timer ) ;
521506 } , [
0 commit comments