mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 12:45:50 +00:00
Refactor to make quality adjustment for XRP more clear
This commit is contained in:
@@ -8,8 +8,11 @@ const BigNumber = require('bignumber.js');
|
|||||||
|
|
||||||
function adjustQualityForXRP(quality: string, takerGetsCurrency: string,
|
function adjustQualityForXRP(quality: string, takerGetsCurrency: string,
|
||||||
takerPaysCurrency: string) {
|
takerPaysCurrency: string) {
|
||||||
const shift = (takerGetsCurrency === 'XRP' ? 6 : 0)
|
// quality = takerPays.value/takerGets.value
|
||||||
- (takerPaysCurrency === 'XRP' ? 6 : 0);
|
// using drops (1e-6 XRP) for XRP values
|
||||||
|
const numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0);
|
||||||
|
const denominatorShift = (takerGetsCurrency === 'XRP' ? -6 : 0);
|
||||||
|
const shift = numeratorShift - denominatorShift;
|
||||||
return shift === 0 ? quality :
|
return shift === 0 ? quality :
|
||||||
(new BigNumber(quality)).shift(shift).toString();
|
(new BigNumber(quality)).shift(shift).toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user