mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-13 21:52:36 +03:00
networkFeeInFeeAsset / orionFeeInFeeAsset
This commit is contained in:
@@ -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
|
||||
// }
|
||||
// }
|
||||
```
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user