-
Notifications
You must be signed in to change notification settings - Fork 0
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
Proper units (Wei, Tokens, Ratio) #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great one in general! A few semantic suggestions/questions
-
instead of
Tokens.parse(string)
wouldn't be better:
Tokens(string|number|BN|Tokens)
It's the defacto constructor standard inbn.js
andBigNumber
(although it doesn't mean it's the best way.. ) -
Percent
is not really percent.. Should it bePpm
? -
Tokens.of(number)
,Percent.of(number)
andWei.of(number)
:.of
reads a bit weird for me. not sure what would be better. Idea:.Wei.fromEth
,Ppm.fromPercent
andTokens.fromDecimal
?- allow
.of(number | string )
?
I don't consider this a good practice: if you meant to parse a string, a type error should be thrown if you pass in anything else. Also, other parameters may be added later, which may not make sense for other types (e.g. base).
Started off with (Btw, I was considering
A more verbose form would make readability worse in test cases (plenty of constants there).
same as above, with even more confusion ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix ts lint errors!
@rszaloki is there a build target to run the linter? Or if it’s some other process, could you please add it to the README? |
@szerintedmi @rszaloki Fixed some linter warnings. Some others I happen to disagree with :) |
* staging: Proper units (Wei, Tokens, Ratio) (#59) # Conflicts: # src/Exchange.ts # src/constants.ts
No description provided.