New fetchWithValidation / introducing simpleFetch

This commit is contained in:
Aleksandr Kraiz
2022-05-10 11:44:09 +04:00
parent edc91ecefe
commit 883bcf928f
16 changed files with 350 additions and 117 deletions

View File

@@ -30,10 +30,13 @@ export default async function getBalance(
}
const assetContractBalance = await exchangeContract.getBalance(assetAddress, walletAddress);
const denormalizedAssetInContractBalance = utils.denormalizeNumber(assetContractBalance, INTERNAL_ORION_PRECISION);
const denormalizedAssetLockedBalance = await orionAggregator.getLockedBalance(walletAddress, asset);
const denormalizedAssetLockedBalanceResult = await orionAggregator.getLockedBalance(walletAddress, asset);
if (denormalizedAssetLockedBalanceResult.isErr()) {
throw new Error(denormalizedAssetLockedBalanceResult.error.message);
}
return {
exchange: denormalizedAssetInContractBalance.minus(denormalizedAssetLockedBalance[asset] ?? 0),
exchange: denormalizedAssetInContractBalance.minus(denormalizedAssetLockedBalanceResult.value[asset] ?? 0),
wallet: denormalizedAssetInWalletBalance,
};
}

View File

@@ -10,6 +10,6 @@ export { default as normalizeNumber } from './normalizeNumber';
export { default as getSwapPair } from './getSwapPair';
export { default as getSwapSide } from './getSwapSide';
export { default as HttpError } from './httpError';
// export { default as HttpError } from './httpError';
export * from './typeHelpers';