Git Product home page Git Product logo

Comments (5)

PhABC avatar PhABC commented on June 11, 2024

Looking back at it, I think this is more of a sanity check to make sure decimals are accounted for. Someone could accidentally set up a really bad price when opening a new market for instance. I don't think the rounding error rational in the in-line comment is sound, the rounding error will not be more significant based on a small initial liquidity being added.

This requirement does prevent currencies that have smaller number of decimals and might be worth considering removing.

What do you think?

from niftyswap.

Agusx1211 avatar Agusx1211 commented on June 11, 2024

I think this is more of a sanity check to make sure decimals are accounted for. Someone could accidentally set up a really bad price when opening a new market for instance

I am not sure if I follow you there, when you first enter liquidity the UX should be taking care of the decimals, for example in Uniswap, adding 1 ETH of liquidity adds 10**18 WEI, the user can't add 1 WEI by mistake.

I think that the require is intended to protect the second liquidity provider, if a pool has 1 wei / 1 wei of liquidity the next provider is forced to maintain the 1:1 ratio, usually this is not a problem, because the pool should get arbitraged until the real ratio is reached, but when the liquidity is that low nobody can do any trade, so that doesn’t happens.

I market it as a low severity issue because it's only an inconvenience, it exists a simple fix if a "troll" starts to create pools with 1/1 liquidity. A contract could add liquidity to such pools and trade at the same time, enabling trades again.

Because it exists a simple fix, I would be comfortable tagging this as won’t-fix, but It would be a good idea to monitor pools in case one of these "trolls" appears.

from niftyswap.

PhABC avatar PhABC commented on June 11, 2024

Yeah, the trolling would be a bit annoying, but indeed one can add liquidity & trade to correct ratio in a single tx to correct the ratio. Good to keep track of indeed.

from niftyswap.

PhABC avatar PhABC commented on June 11, 2024

@Agusx1211 I was thinking about this, and what if someone adds a 10000 wei : 1 X as first liquidity, where X is a fungible tokens with many decimals (hence 1 is the lowest value possible). Now the "trolling" is truly effective since the ratio 10000/1 would need to be maintained for all future added liquidity. Are we certain that we can correct that ratio?

We would need to do a contract call like :

  niftyswapContract.addLiquidity(...);
  niftyswapContract.baseToToken(...);
  ...

So if ratio is 10000 A / 1 B we need to

  • Add 999000 A and 999 B giving you 10000000 A / 1000 B
  • Sell 99,000 B to get a 100,000 A / 100,000 B ratio
  • Remove liquidity

Now my main worry is under which scenario might it be impossible to get enough B liquidity.

What do you think @Agusx1211 ?

from niftyswap.

Agusx1211 avatar Agusx1211 commented on June 11, 2024

Fixing the ratio can also be done by performing a trade; I cannot think of any situation that cannot be fixed in a safe manner by using a contract.

Worst case scenario, the pool is left broken, and the exchange has to be re-deployed. Maybe the UI could raise a warning if a user tries to add liquidity to a pool with less than 100000000 base liquidity?

from niftyswap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.