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

prevent duplicate denoms #70

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ivmidable
Copy link

@ivmidable ivmidable commented Sep 15, 2022

This PR prevents token1 and token2 from being the same Denom and also refactors create_amm in integration tests to take in a Denom to make it easier to test for this behavior. two new tests were also added to make sure this fix works as expected. A AMM that allowed token1 and token2 to be the same token lost users around 31 million USD in the past.

https://slowmist.medium.com/detailed-analysis-of-the-31-million-monox-protocol-hack-574d8c44a9c8

@0xekez
Copy link
Collaborator

0xekez commented Sep 27, 2022

hey! thanks for the PR. i've also seen that medium article / exploit.

these contracts are not vulnerable to that problem afik. creating an AMM where both pools have the same denom will actually work as expected: you put denom in, you get denom - fees out.

i'd love to land a test that tests that case, but i'm not sure it's worth adding the additional validation to the contracts. in smart contract land, more code == more bugs. if the state that we're protecting against doesn't do anything unexpected i figure the best thing to do is to allow it. :)

will defer to @ben2x4 about if we'd like to land this whole thing (i think it looks good), but, again, if you'd like to just break this out into a test that tests the multiple denom case that would be a great contribution!

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