Skip to content

Commit

Permalink
fix: refactor sol input handling in useWsolDeposit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Nov 4, 2024
1 parent 59a64df commit 135f13c
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ export const useWsolDeposit = () => {
);

const liquidity = quote.liquidityAmount.toString();
return {
solMax,
olasMax,
liquidity
};
return { solMax, olasMax, liquidity };
};

const checkIfNoEnoughOlas = async (whirlpoolTokenB, olasMax) => {
Expand All @@ -173,9 +169,14 @@ export const useWsolDeposit = () => {

const { whirlpoolTokenA, whirlpoolTokenB } = await getWhirlpoolData();

const solInputInLamport = BigInt(sol);
const quote = await getDepositIncreaseLiquidityQuote({ sol, slippage });
const { solMax, olasMax, solMaxInLamport } = await getDepositTransformedQuote(quote);
const solInputInLamportInBn = DecimalUtil.toBN(new Decimal(sol), 9);
const solInputInLamport = BigInt(solInputInLamportInBn.toString());

const quote = await getDepositIncreaseLiquidityQuote({
sol,
slippage,
});
const { solMax, olasMax } = await getDepositTransformedQuote(quote);

// OLAS associated token account MUST always exist when the person bonds
const tokenOwnerAccountB = await getAssociatedTokenAddress(
Expand Down Expand Up @@ -288,7 +289,7 @@ export const useWsolDeposit = () => {

try {
await program.methods
.deposit(quote.liquidityAmount, solInputInLamport, quote.tokenMaxB)
.deposit(quote.liquidityAmount, solInputInLamportInBn, quote.tokenMaxB)
.accounts({
position: POSITION,
positionMint: POSITION_MINT,
Expand Down

0 comments on commit 135f13c

Please sign in to comment.