@xchainjs/xchain-aggregator 2.0.28 → 2.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Network } from '@xchainjs/xchain-client';
2
2
  import { CachedValue, isSynthAsset, isTradeAsset, CryptoAmount, baseAmount, isSecuredAsset, assetToString, eqAsset, assetFromStringEx, assetFromString, isTokenAsset } from '@xchainjs/xchain-util';
3
3
  import { SwapSDK } from '@chainflip/sdk/swap';
4
+ import { assetUSDC, ThorchainCache, Thornode, ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
4
5
  import { AssetCacao, MAYAChain } from '@xchainjs/xchain-mayachain';
5
6
  import { MayachainAMM } from '@xchainjs/xchain-mayachain-amm';
6
7
  import { MayachainCache, Mayanode, MayachainQuery } from '@xchainjs/xchain-mayachain-query';
7
8
  import { AssetRuneNative as AssetRuneNative$1, THORChain } from '@xchainjs/xchain-thorchain';
8
9
  import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm';
9
- import { ThorchainCache, Thornode, ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
10
10
 
11
11
  /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -178,6 +178,7 @@ class ChainflipProtocol {
178
178
  }
179
179
  const outboundFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'EGRESS');
180
180
  const brokerFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'BROKER');
181
+ const networkFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'NETWORK');
181
182
  return {
182
183
  protocol: this.name,
183
184
  toAddress,
@@ -193,9 +194,10 @@ class ChainflipProtocol {
193
194
  errors: [],
194
195
  slipBasisPoints: 0,
195
196
  fees: {
196
- asset: params.destinationAsset,
197
+ asset: assetUSDC, // neworkFee & broker fee paid in usdc
198
+ networkFee: new CryptoAmount(baseAmount(networkFee ? networkFee.amount : 0, 6), assetUSDC),
197
199
  outboundFee: new CryptoAmount(baseAmount(outboundFee ? outboundFee.amount : 0, destAssetData.decimals), params.destinationAsset),
198
- affiliateFee: new CryptoAmount(baseAmount(brokerFee ? brokerFee.amount : 0, destAssetData.decimals), params.destinationAsset),
200
+ affiliateFee: new CryptoAmount(baseAmount(brokerFee ? brokerFee.amount : 0, 6), assetUSDC),
199
201
  },
200
202
  depositChannelId,
201
203
  };
@@ -216,7 +218,8 @@ class ChainflipProtocol {
216
218
  fees: {
217
219
  asset: params.destinationAsset,
218
220
  outboundFee: new CryptoAmount(baseAmount(0, destAssetData.decimals), params.destinationAsset),
219
- affiliateFee: new CryptoAmount(baseAmount(0, destAssetData.decimals), params.destinationAsset),
221
+ networkFee: new CryptoAmount(baseAmount(0, 6), assetUSDC),
222
+ affiliateFee: new CryptoAmount(baseAmount(0, 6), assetUSDC),
220
223
  },
221
224
  depositChannelId: undefined,
222
225
  };
package/lib/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  var xchainClient = require('@xchainjs/xchain-client');
4
4
  var xchainUtil = require('@xchainjs/xchain-util');
5
5
  var swap = require('@chainflip/sdk/swap');
6
+ var xchainThorchainQuery = require('@xchainjs/xchain-thorchain-query');
6
7
  var xchainMayachain = require('@xchainjs/xchain-mayachain');
7
8
  var xchainMayachainAmm = require('@xchainjs/xchain-mayachain-amm');
8
9
  var xchainMayachainQuery = require('@xchainjs/xchain-mayachain-query');
9
10
  var xchainThorchain = require('@xchainjs/xchain-thorchain');
10
11
  var xchainThorchainAmm = require('@xchainjs/xchain-thorchain-amm');
11
- var xchainThorchainQuery = require('@xchainjs/xchain-thorchain-query');
12
12
 
13
13
  /******************************************************************************
14
14
  Copyright (c) Microsoft Corporation.
@@ -180,6 +180,7 @@ class ChainflipProtocol {
180
180
  }
181
181
  const outboundFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'EGRESS');
182
182
  const brokerFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'BROKER');
183
+ const networkFee = selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.includedFees.find((fee) => fee.type === 'NETWORK');
183
184
  return {
184
185
  protocol: this.name,
185
186
  toAddress,
@@ -195,9 +196,10 @@ class ChainflipProtocol {
195
196
  errors: [],
196
197
  slipBasisPoints: 0,
197
198
  fees: {
198
- asset: params.destinationAsset,
199
+ asset: xchainThorchainQuery.assetUSDC, // neworkFee & broker fee paid in usdc
200
+ networkFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(networkFee ? networkFee.amount : 0, 6), xchainThorchainQuery.assetUSDC),
199
201
  outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(outboundFee ? outboundFee.amount : 0, destAssetData.decimals), params.destinationAsset),
200
- affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(brokerFee ? brokerFee.amount : 0, destAssetData.decimals), params.destinationAsset),
202
+ affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(brokerFee ? brokerFee.amount : 0, 6), xchainThorchainQuery.assetUSDC),
201
203
  },
202
204
  depositChannelId,
203
205
  };
@@ -218,7 +220,8 @@ class ChainflipProtocol {
218
220
  fees: {
219
221
  asset: params.destinationAsset,
220
222
  outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0, destAssetData.decimals), params.destinationAsset),
221
- affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0, destAssetData.decimals), params.destinationAsset),
223
+ networkFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0, 6), xchainThorchainQuery.assetUSDC),
224
+ affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0, 6), xchainThorchainQuery.assetUSDC),
222
225
  },
223
226
  depositChannelId: undefined,
224
227
  };
package/lib/types.d.ts CHANGED
@@ -15,6 +15,7 @@ type Fees = {
15
15
  asset: Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset;
16
16
  affiliateFee: CryptoAmount<Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset>;
17
17
  outboundFee: CryptoAmount<Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset>;
18
+ networkFee?: CryptoAmount<Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset>;
18
19
  };
19
20
  /**
20
21
  * Protocols supported by the Aggregator
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-aggregator",
3
3
  "description": "Protocol aggregator to make actions in different protocols",
4
- "version": "2.0.28",
4
+ "version": "2.0.29",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "module": "lib/index.esm.js",