Skip to content

Commit

Permalink
Update removeLiquidityRecovery to use bptAmount from input
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoguerios committed Jul 30, 2024
1 parent f64866f commit 85729cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ export class RemoveLiquidityComposableStable implements RemoveLiquidityBase {
totalShares: formatEther(totalShares) as HumanAmount,
};

const { tokenAmounts, bptAmount } = calculateProportionalAmounts(
const { tokenAmounts } = calculateProportionalAmounts(
poolStateWithBalances,
input.bptIn,
);
const bptToken = new Token(
input.chainId,
bptAmount.address,
bptAmount.decimals,
const bptToken = new Token(input.chainId, poolState.address, 18);
const bptIn = TokenAmount.fromRawAmount(
bptToken,
input.bptIn.rawAmount,
);
const bptIn = TokenAmount.fromRawAmount(bptToken, bptAmount.rawAmount);
const bptIndex = poolState.tokens.findIndex(
(t) => t.address === poolState.address,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,15 @@ export class RemoveLiquidityStable implements RemoveLiquidityBase {
totalShares: formatEther(totalShares) as HumanAmount,
};

const { tokenAmounts, bptAmount } = calculateProportionalAmounts(
const { tokenAmounts } = calculateProportionalAmounts(
poolStateWithBalances,
input.bptIn,
);
const bptToken = new Token(
input.chainId,
bptAmount.address,
bptAmount.decimals,
const bptToken = new Token(input.chainId, poolState.address, 18);
const bptIn = TokenAmount.fromRawAmount(
bptToken,
input.bptIn.rawAmount,
);
const bptIn = TokenAmount.fromRawAmount(bptToken, bptAmount.rawAmount);
const amountsOut = tokenAmounts.map((amountIn) =>
TokenAmount.fromRawAmount(
new Token(input.chainId, amountIn.address, amountIn.decimals),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,15 @@ export class RemoveLiquidityWeighted implements RemoveLiquidityBase {
totalShares: formatEther(totalShares) as HumanAmount,
};

const { tokenAmounts, bptAmount } = calculateProportionalAmounts(
const { tokenAmounts } = calculateProportionalAmounts(
poolStateWithBalances,
input.bptIn,
);
const bptToken = new Token(
input.chainId,
bptAmount.address,
bptAmount.decimals,
const bptToken = new Token(input.chainId, poolState.address, 18);
const bptIn = TokenAmount.fromRawAmount(
bptToken,
input.bptIn.rawAmount,
);
const bptIn = TokenAmount.fromRawAmount(bptToken, bptAmount.rawAmount);
const amountsOut = tokenAmounts.map((amount, i) =>
TokenAmount.fromRawAmount(sortedTokens[i], amount.rawAmount),
);
Expand Down

0 comments on commit 85729cc

Please sign in to comment.