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

Pool Coin Decimal Truncation During Deposit #445

Closed
4 tasks
dongsam opened this issue Sep 29, 2021 · 0 comments · Fixed by #446
Closed
4 tasks

Pool Coin Decimal Truncation During Deposit #445

dongsam opened this issue Sep 29, 2021 · 0 comments · Fixed by #446
Assignees
Labels
bug Something isn't working

Comments

@dongsam
Copy link
Contributor

dongsam commented Sep 29, 2021

Summary of Bug

  • when the unit size of the pool coin is significantly large
  • when user deposits relatively small amount of coin into the liquidity pool

Version

Including v1.4.0, past versions.

Steps to Reproduce

Example

  • pool created with unit coin value $10
  • user deposits $19 amount of liquidity into the created pool
  • user's share should be 1.9 unit pool coin, but because of decimal truncation, user gets only 1 unit pool coin
  • user lost $9 amount of deposited coin because 1 unit pool coin value is only $10

Why It Happened?

  • reason why some of the pool unit coins have significantly large USD value?
    • because some of the pools were created with a large initial deposit
      • first depositor always get 1,000,000 pool unit coin
      • if the initial deposit is larger than $1M, then the pool unit coin will be larger than $1
  • we expected this risk when we designed the spec
  • but we couldn't forecast that actually, some users create pools with +$1M initial deposit

The pools that have these problems.

Solution

Refund of Decimal Part of the Deposit

  • we can calculate "maximum integer unit pool coin receivable" for each deposit request
  • the module receives the exact number of deposit coins with respect to the calculated number of unit pool coins, and the rest are refunded
  • with the refund feature, users are free from decimal truncation loss from receivable pool coin when they deposit liquidity

Patch Plan

  • we will steadily prepare this patch, accompanied with enough testing and simulation
  • if we can make time before Cosmos-SDK 0.44 upgrade, we will propose this into the upgrade
  • if we cannot make it, then this refund feature will be proposed to the next Gaia upgrade schedule

Param change

  • Apart from Patch, we plan to submit a parameter change proposal to increase the params.InitPoolCoinMintAmount to minimize this problem even if some users create pools with +$1M initial deposit in the future.

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@dongsam dongsam added the bug Something isn't working label Sep 29, 2021
@dongsam dongsam changed the title Pool Token Decimal Truncation During Deposit Pool Coin Decimal Truncation During Deposit Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants