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

Convert coin with same gasCoin produce strange behavior #294

Open
shrpne opened this issue Feb 19, 2020 · 0 comments
Open

Convert coin with same gasCoin produce strange behavior #294

shrpne opened this issue Feb 19, 2020 · 0 comments

Comments

@shrpne
Copy link
Member

shrpne commented Feb 19, 2020

What I do
I have on the balance: 30685.413253185071200896 BANANATEST
For the 0.1 MNT fee I plan to spend 38.956518155931433038 BANANATEST
So I will sell only 30646.456735029139767858, to leave enough for comission

I send TX:
{ nonce: '129',
chainId: '2',
gasPrice: '1',
gasCoin: 'BANANATEST',
type: '0x02',
data:
{ coinToSell: 'BANANATEST',
valueToSell: '30646.456735029139767858',
coinToBuy: 'MNT',
minimumValueToBuy: '0' },
payload: '',
}
https://minter-node-1.testnet.minter.network/send_transaction?tx=0xf87e818102018a42414e414e415445535402a3e28a42414e414e41544553548a067d59060c9f4d7282328a4d4e540000000000000080808001b845f8431ca01d568386460de1dd40a7c73084a84be68bbf4696aea0208530d3bae2ccf47e4ba059cb6cbfb12e56d7f5f4f8c367a76a867aff09afca15e8d61a7ef4cf7e0d26be
The error occurs: 30685.4691828209 BANANATEST required to proceed such TX

It is 0.055929635828799104 BANANATEST more than I have (0.000143569521334670 MNT equivalent)

What happens
Such calculation occurs in the blockchain:

  1. Sell 30646.456735029139767858 BANANATEST, write down new coin parameters
  2. Sell BANANATEST to pay fee taking into account new coin price

What's wrong with it

What we can do
Sell COIN first to calculate fee, than sell COIN to calculate resulting amount

  • It looks more intuitive
  • Calculating fee will be easy
  • No need to fix estimation API method (though I'm not sure it is fixable with current behavior)
  • Calculating fee first will produce very little coin price change, so we can even ignore such price change in the UI when calculating estimation of received coins
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

No branches or pull requests

1 participant