-
Notifications
You must be signed in to change notification settings - Fork 44
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
UNITS_PER_CURRENCY to be fetched from db #1054
Comments
I added #1058 as a quick fix. A more permanent/dynamic solution would be to fetch these values from the database, but I think we can lower the priority of this to after testnet/before mainnet. |
This issue is about removing https://github.com/ExchangeUnion/xud/blob/master/lib/utils/UnitConverter.ts#L1 and replacing it with https://github.com/ExchangeUnion/xud/blob/master/lib/utils/UnitConverter.ts#L42 to avoid any hardcoded decimals. Bumping prio here since this should be the last piece missing to close #1888 |
This commit makes two significant changes. 1. It uses the new `bigint` type - supported as of node LTS v14 - for internal representations of the base "units" of any currencies/tokens. ETH wei, having 10^18 units per ether, can exceed the capacity of javascript's `number` type and lead to unexpected rounding or scientific notation when converting to string that has required hacky workarounds. Using `bigint` gives us native integer support for base tokens for all tokens, regardless of how many decimal places they can be split into. 2. It reads the aforementioned decimal places from the database for every token. Previously, we hardcoded the units per tokens for a handful of known ERC20 tokens. Adding other currencies to be supported by xud would have required a code change. Now, new tokens can be supported with changes to the database via rpc calls, without requiring code updates. Closes #1054. Closes #1888.
This commit makes two significant changes. 1. It uses the new `bigint` type - supported as of node LTS v14 - for internal representations of the base "units" of any currencies/tokens. ETH wei, having 10^18 units per ether, can exceed the capacity of javascript's `number` type and lead to unexpected rounding or scientific notation when converting to string that has required hacky workarounds. Using `bigint` gives us native integer support for base tokens for all tokens, regardless of how many decimal places they can be split into. 2. It reads the aforementioned decimal places from the database for every token. Previously, we hardcoded the units per tokens for a handful of known ERC20 tokens. Adding other currencies to be supported by xud would have required a code change. Now, new tokens can be supported with changes to the database via rpc calls, without requiring code updates. Closes #1054. Closes #1888.
Reported by @offerm :
Trying to swap LTC/DAI. Failed.
I see this in the log
note the
makerAmount":null
diving into the code I found this:
Clearly DAI is missing. Also addcurrency can't be really used like that.
Not sure I understand why WETH has 10**10 units per currency.
The text was updated successfully, but these errors were encountered: