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

@@ -123,6 +123,7 @@ console.log(swapInfo);
console.log(fee);
// {
// route: 'pool',
// swapInfo: {
// id: 'e5d50b8e-ca82-4826-b454-3fa12b693c11',
// amountIn: 20,
@@ -149,9 +150,10 @@ console.log(fee);
// type: 'exactSpend'
// },
// fee: {
// assetName: 'ORN',
// assetAddress: '0xf223eca06261145b3287a0fefd8cfad371c7eb34',
// amount: '1.0247136357221697138126003277499197658871168'
// assetName: 'FTM',
// assetAddress: '0x0000000000000000000000000000000000000000',
// networkFeeInFeeAsset: '0.00073929546',
// protocolFeeInFeeAsset: undefined
// }
// }
```

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.15.1",
"version": "0.15.2",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

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,
},
};
}