Skip to content

Commit

Permalink
feat: update WsolDeposit component to display bridged token amount wi…
Browse files Browse the repository at this point in the history
…th unit and refactor token amount fetching logic
  • Loading branch information
mohandast52 committed Nov 6, 2024
1 parent eaf3c1c commit 15feb5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const WsolDeposit = () => {
{
key: '1',
estimated: `${estimatedOutput} WSOL-OLAS LP`,
bridgedTokenAmount: bridgedTokenAmountValue,
bridgedTokenAmount: `${bridgedTokenAmountValue} WSOL-OLAS LP`,
},
]}
bordered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useWallet } from '@solana/wallet-adapter-react';
import { SystemProgram, Transaction } from '@solana/web3.js';
import Decimal from 'decimal.js';
import Link from 'next/link';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';

import { notifyError, notifySuccess } from '@autonolas/frontend-library';

Expand Down Expand Up @@ -125,7 +125,7 @@ export const useWsolDeposit = () => {
const customGetOrCreateAssociatedTokenAccount = useGetOrCreateAssociatedTokenAccount();
const program = new Program(idl, PROGRAM_ID, anchorProvider);

useEffect(() => {
const getLatestBridgeTokenAmount = useCallback(async () => {
if (!svmWalletPublicKey) return;
if (!connection) return;

Expand All @@ -137,6 +137,10 @@ export const useWsolDeposit = () => {
});
}, [connection, svmWalletPublicKey]);

useEffect(() => {
getLatestBridgeTokenAmount();
}, [getLatestBridgeTokenAmount]);

const getDepositIncreaseLiquidityQuote = async ({ sol, slippage }) => {
const { whirlpoolData, whirlpoolTokenA, whirlpoolTokenB } = await getWhirlpoolData();
const slippageTolerance = Percentage.fromDecimal(new Decimal(slippage));
Expand Down Expand Up @@ -330,6 +334,8 @@ export const useWsolDeposit = () => {
return null;
}

await getLatestBridgeTokenAmount(); // refetch bridged token amount

return quote.liquidityAmount.toString();
};

Expand Down

0 comments on commit 15feb5a

Please sign in to comment.