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

Withdraw liquidity #2959

Merged
merged 16 commits into from
Oct 10, 2024
Merged

Withdraw liquidity #2959

merged 16 commits into from
Oct 10, 2024

Conversation

sipec
Copy link
Member

@sipec sipec commented Oct 10, 2024

No description provided.

@sipec sipec requested a review from mantikoros October 10, 2024 21:35
Copy link

vercel bot commented Oct 10, 2024

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

Name Status Preview Comments Updated (UTC)
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 11:29pm
prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 11:29pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 11:29pm

Copy link
Collaborator

@mantikoros mantikoros left a comment

Choose a reason for hiding this comment

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

Mostly good. I think the ratioMax stuff is not right, but otherwise LGTM.

backend/api/src/on-update-liquidity-provision.ts Outdated Show resolved Hide resolved
toId: auth.uid,
category: 'REMOVE_SUBSIDY',
amount: totalAmount,
token: contract.token === 'CASH' ? 'CASH' : 'M$',
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just contract.token

Copy link
Member Author

Choose a reason for hiding this comment

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

contract.token is type 'CASH' | 'MANA'

let error = ''

if (newPool.YES < MINIMUM_LIQUIDITY || newPool.NO < MINIMUM_LIQUIDITY) {
error = 'below minimum'
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't really use this style of error handling (versus throwing an exception) anywhere else on the backend to my knowledge...

Copy link
Member Author

@sipec sipec Oct 10, 2024

Choose a reason for hiding this comment

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

this function is also used on the frontend and I want it to still return what the pool values would be even if it is below 100


const z = FRACTION_OF_POOL_MIN
const { YES: y, NO: n } = pool
const ratioMax = (n * z + y * z - Math.min(y, n)) / (2 * z - 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this right? if x=y=100, then this value is negative, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't really understand why we need a ratio limit if we already have a limit on the number of shares in the liquidity pool.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, after playing around with the maniswap calculator a bit more, I'm convinced that extreme ratios are fine so I removed the restriction

@sipec sipec merged commit 14ed6eb into main Oct 10, 2024
6 checks passed
@sipec sipec deleted the withdraw-liquidity branch October 10, 2024 23:31
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