diff --git a/components/asset/FloatingPool/FloatingPoolInfo/index.tsx b/components/asset/FloatingPool/FloatingPoolInfo/index.tsx index 8f5f3e499..aa64b315d 100644 --- a/components/asset/FloatingPool/FloatingPoolInfo/index.tsx +++ b/components/asset/FloatingPool/FloatingPoolInfo/index.tsx @@ -105,9 +105,11 @@ const FloatingPoolInfo: FC = ({ symbol }) => { ))} ), - tooltipTitle: t( - 'This APR assumes a constant price for the EXA token during the vesting period of the esEXA reward', - ), + ...(depositRewards.some((r) => r.assetSymbol === 'esEXA') && { + tooltipTitle: t( + 'This APR assumes a constant price for the EXA token during the vesting period of the esEXA reward', + ), + }), }, ] : []), @@ -122,9 +124,11 @@ const FloatingPoolInfo: FC = ({ symbol }) => { ))} ), - tooltipTitle: t( - 'This APR assumes a constant price for the EXA token during the vesting period of the esEXA reward', - ), + ...(borrowRewards.some((r) => r.assetSymbol === 'esEXA') && { + tooltipTitle: t( + 'This APR assumes a constant price for the EXA token during the vesting period of the esEXA reward', + ), + }), }, ] : []), diff --git a/components/operations/BorrowAtMaturity/index.tsx b/components/operations/BorrowAtMaturity/index.tsx index 12d7cae73..1ae4ae877 100644 --- a/components/operations/BorrowAtMaturity/index.tsx +++ b/components/operations/BorrowAtMaturity/index.tsx @@ -143,7 +143,7 @@ const BorrowAtMaturity: FC = ({ children }) => { 1 ? t('Approve') : translateOperation('borrowAtMaturity', { capitalize: true }) } diff --git a/hooks/useBorrowAtMaturity.ts b/hooks/useBorrowAtMaturity.ts index 32ce8f0de..255387e1d 100644 --- a/hooks/useBorrowAtMaturity.ts +++ b/hooks/useBorrowAtMaturity.ts @@ -57,6 +57,7 @@ export default (): BorrowAtMaturity => { const { accountData, marketAccount } = useAccountData(symbol); const [fixedRate, setFixedRate] = useState(); + const [fixedFee, setFixedFee] = useState(); const healthFactor = useHealthFactor(); const minBorrowRate = useMemo(() => { @@ -88,7 +89,16 @@ export default (): BorrowAtMaturity => { const previewGasCost = useCallback( async (quantity: string): Promise => { - if (!marketAccount || !walletAddress || !marketContract || !ETHRouterContract || !date || !quantity || !opts) + if ( + !marketAccount || + !walletAddress || + !marketContract || + !ETHRouterContract || + !date || + !quantity || + !opts || + !fixedFee + ) return; if (await needsApproval(quantity)) { @@ -96,7 +106,8 @@ export default (): BorrowAtMaturity => { } const amount = parseUnits(quantity, marketAccount.decimals); - const maxAmount = (amount * slippage) / WAD; + const maxAmount = ((amount + fixedFee) * slippage) / WAD; + if (marketAccount.assetSymbol === 'WETH') { const sim = await ETHRouterContract.simulate.borrowAtMaturity([date, amount, maxAmount], opts); return estimate(sim.request); @@ -116,6 +127,7 @@ export default (): BorrowAtMaturity => { date, opts, needsApproval, + fixedFee, slippage, estimate, approveEstimateGas, @@ -190,10 +202,10 @@ export default (): BorrowAtMaturity => { }); } - if (!marketAccount || !date || !qty || !walletAddress || !opts) return; + if (!marketAccount || !date || !qty || !walletAddress || !opts || !fixedFee) return; const amount = parseUnits(qty, marketAccount.decimals); - const maxAmount = (amount * slippage) / WAD; + const maxAmount = ((amount + fixedFee) * slippage) / WAD; let hash; try { @@ -267,14 +279,15 @@ export default (): BorrowAtMaturity => { qty, walletAddress, opts, + fixedFee, + setErrorData, t, + setTx, + symbol, ETHRouterContract, marketContract, receiver, - setErrorData, - setTx, handleOperationError, - symbol, ]); const updateAPR = useCallback(async () => { @@ -296,8 +309,10 @@ export default (): BorrowAtMaturity => { const fixedAPR = ((rate - WAD) * 31_536_000n) / (date - currentTimestamp); setFixedRate(fixedAPR); + setFixedFee(finalAssets - initialAssets); } catch (error) { setFixedRate(undefined); + setFixedFee(undefined); } } else { setFixedRate(minBorrowRate); diff --git a/hooks/useDepositAtMaturity.ts b/hooks/useDepositAtMaturity.ts index 7ce21a181..16b55699b 100644 --- a/hooks/useDepositAtMaturity.ts +++ b/hooks/useDepositAtMaturity.ts @@ -57,6 +57,7 @@ export default (): DepositAtMaturity => { const handleOperationError = useHandleOperationError(); const [fixedRate, setFixedRate] = useState(); + const [fixedFee, setFixedFee] = useState(); const [gtMaxYield, setGtMaxYield] = useState(false); const walletBalance = useBalance(symbol, assetContract?.address); @@ -82,7 +83,8 @@ export default (): DepositAtMaturity => { !date || !quantity || (walletBalance && parseFloat(quantity) > parseFloat(walletBalance)) || - !opts + !opts || + !fixedFee ) return; @@ -91,7 +93,7 @@ export default (): DepositAtMaturity => { } const amount = parseUnits(quantity, marketAccount.decimals); - const minAmount = (amount * slippage) / WAD; + const minAmount = ((amount + fixedFee) * slippage) / WAD; if (marketAccount.assetSymbol === 'WETH') { const sim = await ETHRouterContract.simulate.depositAtMaturity([date, minAmount], { @@ -109,14 +111,15 @@ export default (): DepositAtMaturity => { return estimate(sim.request); }, [ - opts, marketAccount, walletAddress, marketContract, ETHRouterContract, date, walletBalance, + opts, needsApproval, + fixedFee, slippage, estimate, approveEstimateGas, @@ -166,13 +169,23 @@ export default (): DepositAtMaturity => { ); const deposit = useCallback(async () => { - if (!marketAccount || !date || !qty || !ETHRouterContract || !marketContract || !walletAddress || !opts) return; + if ( + !marketAccount || + !date || + !qty || + !ETHRouterContract || + !marketContract || + !walletAddress || + !opts || + !fixedFee + ) + return; let hash; setIsLoadingOp(true); try { const amount = parseUnits(qty, marketAccount.decimals); - const minAmount = (amount * slippage) / WAD; + const minAmount = ((amount + fixedFee) * slippage) / WAD; if (marketAccount.assetSymbol === 'WETH') { const args = [date, minAmount] as const; const gasEstimation = await ETHRouterContract.estimateGas.depositAtMaturity(args, { @@ -235,12 +248,13 @@ export default (): DepositAtMaturity => { marketContract, walletAddress, opts, + fixedFee, setIsLoadingOp, slippage, setTx, + symbol, setErrorData, handleOperationError, - symbol, ]); const handleSubmitAction = useCallback(async () => { @@ -273,8 +287,10 @@ export default (): DepositAtMaturity => { const fixedAPR = ((rate - WAD) * 31_536_000n) / (date - currentTimestamp); setFixedRate(fixedAPR); + setFixedFee(finalAssets - initialAssets); } catch (error) { setFixedRate(undefined); + setFixedFee(undefined); } } else { setFixedRate(depositRate); diff --git a/public/img/exaTokens/exaUSDC.e.svg b/public/img/exaTokens/exaUSDC.e.svg new file mode 100644 index 000000000..7ab265b98 --- /dev/null +++ b/public/img/exaTokens/exaUSDC.e.svg @@ -0,0 +1 @@ + \ No newline at end of file