networkFeeInFeeAsset / orionFeeInFeeAsset

This commit is contained in:
Aleksandr Kraiz
2022-08-25 15:13:13 +04:00
parent 8e4ee66fcc
commit ef60ed0f4a
3 changed files with 25 additions and 10 deletions

View File

@@ -106,13 +106,12 @@ export default async function getSwapInfo({
fee: {
assetName: nativeCryptocurrency,
assetAddress: ethers.constants.AddressZero,
amount: denormalizedTransactionCost.toString(),
networkFeeInFeeAsset: denormalizedTransactionCost.toString(),
protocolFeeInFeeAsset: undefined,
},
};
}
let feeAmount: string | undefined;
if (swapInfo.orderInfo) {
const [baseAssetName] = swapInfo.orderInfo.assetPair.split('-');
if (baseAssetName === undefined) throw new Error('Base asset name is undefined');
@@ -129,7 +128,10 @@ export default async function getSwapInfo({
const feePercent = feeAssets?.[feeAsset];
if (!feePercent) throw new Error(`Fee asset ${feeAsset} not available`);
const { totalFeeInFeeAsset } = utils.calculateFeeInFeeAsset(
const {
orionFeeInFeeAsset,
networkFeeInFeeAsset,
} = utils.calculateFeeInFeeAsset(
swapInfo.orderInfo.amount,
feeAssetPriceInOrn,
baseAssetPriceInOrn,
@@ -137,7 +139,17 @@ export default async function getSwapInfo({
gasPriceGwei,
feePercent,
);
feeAmount = totalFeeInFeeAsset;
return {
route,
swapInfo,
fee: {
assetName: feeAsset,
assetAddress: feeAssetAddress,
networkFeeInFeeAsset,
protocolFeeInFeeAsset: orionFeeInFeeAsset,
},
};
}
return {
@@ -146,7 +158,8 @@ export default async function getSwapInfo({
fee: {
assetName: feeAsset,
assetAddress: feeAssetAddress,
amount: feeAmount,
networkFeeInFeeAsset: undefined,
protocolFeeInFeeAsset: undefined,
},
};
}