mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
networkFeeInFeeAsset / orionFeeInFeeAsset
This commit is contained in:
@@ -123,6 +123,7 @@ console.log(swapInfo);
|
|||||||
console.log(fee);
|
console.log(fee);
|
||||||
|
|
||||||
// {
|
// {
|
||||||
|
// route: 'pool',
|
||||||
// swapInfo: {
|
// swapInfo: {
|
||||||
// id: 'e5d50b8e-ca82-4826-b454-3fa12b693c11',
|
// id: 'e5d50b8e-ca82-4826-b454-3fa12b693c11',
|
||||||
// amountIn: 20,
|
// amountIn: 20,
|
||||||
@@ -149,9 +150,10 @@ console.log(fee);
|
|||||||
// type: 'exactSpend'
|
// type: 'exactSpend'
|
||||||
// },
|
// },
|
||||||
// fee: {
|
// fee: {
|
||||||
// assetName: 'ORN',
|
// assetName: 'FTM',
|
||||||
// assetAddress: '0xf223eca06261145b3287a0fefd8cfad371c7eb34',
|
// assetAddress: '0x0000000000000000000000000000000000000000',
|
||||||
// amount: '1.0247136357221697138126003277499197658871168'
|
// networkFeeInFeeAsset: '0.00073929546',
|
||||||
|
// protocolFeeInFeeAsset: undefined
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.15.1",
|
"version": "0.15.2",
|
||||||
"description": "Orion Protocol SDK",
|
"description": "Orion Protocol SDK",
|
||||||
"main": "./lib/esm/index.js",
|
"main": "./lib/esm/index.js",
|
||||||
"module": "./lib/esm/index.js",
|
"module": "./lib/esm/index.js",
|
||||||
|
|||||||
@@ -106,13 +106,12 @@ export default async function getSwapInfo({
|
|||||||
fee: {
|
fee: {
|
||||||
assetName: nativeCryptocurrency,
|
assetName: nativeCryptocurrency,
|
||||||
assetAddress: ethers.constants.AddressZero,
|
assetAddress: ethers.constants.AddressZero,
|
||||||
amount: denormalizedTransactionCost.toString(),
|
networkFeeInFeeAsset: denormalizedTransactionCost.toString(),
|
||||||
|
protocolFeeInFeeAsset: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let feeAmount: string | undefined;
|
|
||||||
|
|
||||||
if (swapInfo.orderInfo) {
|
if (swapInfo.orderInfo) {
|
||||||
const [baseAssetName] = swapInfo.orderInfo.assetPair.split('-');
|
const [baseAssetName] = swapInfo.orderInfo.assetPair.split('-');
|
||||||
if (baseAssetName === undefined) throw new Error('Base asset name is undefined');
|
if (baseAssetName === undefined) throw new Error('Base asset name is undefined');
|
||||||
@@ -129,7 +128,10 @@ export default async function getSwapInfo({
|
|||||||
const feePercent = feeAssets?.[feeAsset];
|
const feePercent = feeAssets?.[feeAsset];
|
||||||
if (!feePercent) throw new Error(`Fee asset ${feeAsset} not available`);
|
if (!feePercent) throw new Error(`Fee asset ${feeAsset} not available`);
|
||||||
|
|
||||||
const { totalFeeInFeeAsset } = utils.calculateFeeInFeeAsset(
|
const {
|
||||||
|
orionFeeInFeeAsset,
|
||||||
|
networkFeeInFeeAsset,
|
||||||
|
} = utils.calculateFeeInFeeAsset(
|
||||||
swapInfo.orderInfo.amount,
|
swapInfo.orderInfo.amount,
|
||||||
feeAssetPriceInOrn,
|
feeAssetPriceInOrn,
|
||||||
baseAssetPriceInOrn,
|
baseAssetPriceInOrn,
|
||||||
@@ -137,7 +139,17 @@ export default async function getSwapInfo({
|
|||||||
gasPriceGwei,
|
gasPriceGwei,
|
||||||
feePercent,
|
feePercent,
|
||||||
);
|
);
|
||||||
feeAmount = totalFeeInFeeAsset;
|
|
||||||
|
return {
|
||||||
|
route,
|
||||||
|
swapInfo,
|
||||||
|
fee: {
|
||||||
|
assetName: feeAsset,
|
||||||
|
assetAddress: feeAssetAddress,
|
||||||
|
networkFeeInFeeAsset,
|
||||||
|
protocolFeeInFeeAsset: orionFeeInFeeAsset,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -146,7 +158,8 @@ export default async function getSwapInfo({
|
|||||||
fee: {
|
fee: {
|
||||||
assetName: feeAsset,
|
assetName: feeAsset,
|
||||||
assetAddress: feeAssetAddress,
|
assetAddress: feeAssetAddress,
|
||||||
amount: feeAmount,
|
networkFeeInFeeAsset: undefined,
|
||||||
|
protocolFeeInFeeAsset: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user