Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to stop and remove all liquidity in one tx and improve withdraw UX #704

Conversation

yvesfracari
Copy link
Contributor

This PR:

  • Add dialog asking if the user wants to remove all amm liquidity on disable it.
  • Add buttons with common withdraw pct.
  • Fix MAX withdraw rounding

Copy link

linear bot commented Jun 12, 2024

Copy link

vercel bot commented Jun 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
balancer-tools 🛑 Canceled (Inspect) Jun 13, 2024 2:20pm
chainlink-data-feeds-api 🛑 Canceled (Inspect) Jun 13, 2024 2:20pm
cow-amm-deployer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2024 2:20pm
cow-tools 🛑 Canceled (Inspect) Jun 13, 2024 2:20pm

Comment on lines 43 to 58
let amount0 = BigInt(0);
let amount1 = BigInt(0);
if (data.withdrawPct === 100) {
// avoid floating point arithmetic
amount0 = parseUnits(cowAmm.token0.balance, cowAmm.token0.decimals);
amount1 = parseUnits(cowAmm.token1.balance, cowAmm.token1.decimals);
} else {
amount0 = parseUnits(
String((Number(cowAmm.token0.balance) * data.withdrawPct) / 100),
cowAmm.token0.decimals
);
amount1 = parseUnits(
String((Number(cowAmm.token1.balance) * data.withdrawPct) / 100),
cowAmm.token1.decimals
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we do something like this?

const withdrawPct = BigInt(data.withdrawPct);
const hundred = BigInt(100);

// Parse the balances as BigNumber and then calculate the amounts
const balance0 = parseUnits(cowAmm.token0.balance, cowAmm.token0.decimals);
const balance1 = parseUnits(cowAmm.token1.balance, cowAmm.token1.decimals);

const amount0 = (balance0 * withdrawPct) / hundred;
const amount1 = (balance1 * withdrawPct) / hundred;

@yvesfracari yvesfracari force-pushed the pedro/cow-276-add-option-to-stop-and-remove-all-liquidity-in-one-tx branch from 7198262 to f2ea092 Compare June 13, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants