2017-08-24 08:53:59 +00:00
|
|
|
import without from 'lodash/without';
|
2017-09-25 02:06:28 +00:00
|
|
|
import { combineAndUpper } from 'utils/formatters';
|
2017-08-24 08:53:59 +00:00
|
|
|
import { ALL_CRYPTO_KIND_OPTIONS } from '.';
|
|
|
|
|
|
|
|
export const buildDestinationAmount = (
|
|
|
|
originAmount,
|
|
|
|
originKind,
|
|
|
|
destinationKind,
|
|
|
|
bityRates
|
|
|
|
) => {
|
2017-09-25 02:06:28 +00:00
|
|
|
const pairName = combineAndUpper(originKind, destinationKind);
|
|
|
|
const bityRate = bityRates[pairName];
|
2017-08-24 08:53:59 +00:00
|
|
|
return originAmount !== null ? originAmount * bityRate : null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const buildDestinationKind = (
|
|
|
|
originKind: string,
|
|
|
|
destinationKind: string
|
|
|
|
): string => {
|
|
|
|
if (originKind === destinationKind) {
|
|
|
|
return without(ALL_CRYPTO_KIND_OPTIONS, originKind)[0];
|
|
|
|
} else {
|
|
|
|
return destinationKind;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const buildOriginKind = (
|
|
|
|
originKind: string,
|
|
|
|
destinationKind: string
|
|
|
|
): string => {
|
|
|
|
if (originKind === destinationKind) {
|
|
|
|
return without(ALL_CRYPTO_KIND_OPTIONS, destinationKind)[0];
|
|
|
|
} else {
|
|
|
|
return originKind;
|
|
|
|
}
|
|
|
|
};
|