-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: add NIM - CRC swap #502
base: master
Are you sure you want to change the base?
Changes from 5 commits
eefcb03
c31d7a9
f79c400
cb20092
b6ebfd4
3565cb4
d0fbade
9533950
c337d49
2fab399
653c15d
02ec1a9
c5a352b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const CrcConstants = { // eslint-disable-line no-unused-vars | ||
CENTS_PER_COIN: 100, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Historically, CRC did in fact have cents but those are not in circulation anymore. Are the amounts in request types in CRC cents or CRC? Until seeing this line, I assumed CRC, but in any case, a comment should be added in Are fractional CRC amounts also displayed in the UI? In that case, I don't think we should do so, except for exchange rates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we added the wallet exchange logic, all Oasis fiat was in EUR. Now the wallet uses multiple / 100 conversions from cents to coins. See here for an example. To keep things simple in the Wallet PR, I used 2 decimal places for the CRC, which Jeff confirmed is valid, though less common. This gives us more precision and is still a correct format while keeping the PR as simple as possible without breaking changes for EUR swaps. Let me know your thoughts on this trade-off. |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* global CrcConstants */ | ||
|
||
class CrcUtils { // eslint-disable-line no-unused-vars | ||
/** | ||
* @param {number} coins CRC amount in decimal | ||
* @returns {number} Number of CRC cents | ||
*/ | ||
static coinsToCents(coins) { | ||
return Math.round(coins * CrcConstants.CENTS_PER_COIN); | ||
} | ||
|
||
/** | ||
* @param {number} cents Number of CRC cents | ||
* @returns {number} CRC count in decimal | ||
*/ | ||
static centsToCoins(cents) { | ||
return cents / CrcConstants.CENTS_PER_COIN; | ||
} | ||
} | ||
Comment on lines
+1
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, these should be combined with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have all the assets under |
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.