@shapeshiftoss/swapper 14.3.0 → 14.4.1
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/dist/api.d.ts +1 -1
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +3 -4
- package/dist/swappers/thorchain/ThorchainSwapper.js +10 -5
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.d.ts +4 -2
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.js +3 -3
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +9 -8
- package/dist/swappers/thorchain/types.d.ts +3 -3
- package/dist/swappers/thorchain/utils/constants.d.ts +1 -1
- package/dist/swappers/thorchain/utils/constants.js +2 -2
- package/dist/swappers/thorchain/utils/{ethereum → evm}/makeTradeTx.d.ts +2 -2
- package/dist/swappers/thorchain/utils/{ethereum → evm}/makeTradeTx.js +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/routerAbi.d.ts +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/routerAbi.js +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/routerCalldata.d.ts +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/routerCalldata.js +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/utils/getThorTxData.d.ts +0 -0
- package/dist/swappers/thorchain/utils/{ethereum → evm}/utils/getThorTxData.js +0 -0
- package/dist/swappers/thorchain/utils/txFeeHelpers/evmTxFees/getEvmTxFees.d.ts +9 -0
- package/dist/swappers/thorchain/utils/txFeeHelpers/{ethTxFees/getEthTxFees.js → evmTxFees/getEvmTxFees.js} +6 -13
- package/dist/swappers/thorchain/utils/txFeeHelpers/{btcTxFees/getBtcTxFees.d.ts → utxoTxFees/getUtxoTxFees.d.ts} +2 -2
- package/dist/swappers/thorchain/utils/txFeeHelpers/{btcTxFees/getBtcTxFees.js → utxoTxFees/getUtxoTxFees.js} +4 -4
- package/dist/swappers/utils/helpers/helpers.d.ts +3 -3
- package/dist/swappers/zrx/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.d.ts +0 -9
package/dist/api.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ declare type CommonTradeInput = {
|
|
|
84
84
|
};
|
|
85
85
|
export declare type EvmSupportedChainIds = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
86
86
|
export declare type CosmosSdkSupportedChainIds = KnownChainIds.CosmosMainnet | KnownChainIds.OsmosisMainnet | KnownChainIds.ThorchainMainnet;
|
|
87
|
-
export declare type
|
|
87
|
+
export declare type EvmSupportedChainAdapter = ethereum.ChainAdapter | avalanche.ChainAdapter;
|
|
88
88
|
export declare type CosmosSdkSupportedChainAdapters = cosmos.ChainAdapter | osmosis.ChainAdapter;
|
|
89
89
|
export declare type UtxoSupportedChainIds = KnownChainIds.BitcoinMainnet | KnownChainIds.DogecoinMainnet | KnownChainIds.LitecoinMainnet | KnownChainIds.BitcoinCashMainnet;
|
|
90
90
|
export declare type GetEvmTradeQuoteInput = CommonTradeInput & {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
3
|
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
4
|
-
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
5
4
|
import Web3 from 'web3';
|
|
6
|
-
import type { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
5
|
+
import type { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, EvmSupportedChainIds, ExecuteTradeInput, GetTradeQuoteInput, Swapper, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
7
6
|
import { SwapperName, SwapperType } from '../../api';
|
|
8
7
|
import { ThorchainSwapperDeps } from './types';
|
|
9
8
|
export * from './types';
|
|
@@ -22,8 +21,8 @@ export declare class ThorchainSwapper implements Swapper<ChainId> {
|
|
|
22
21
|
initialize(): Promise<void>;
|
|
23
22
|
getType(): SwapperType;
|
|
24
23
|
getUsdRate({ assetId }: Pick<Asset, 'assetId'>): Promise<string>;
|
|
25
|
-
approvalNeeded(input: ApprovalNeededInput<
|
|
26
|
-
approveInfinite(input: ApproveInfiniteInput<
|
|
24
|
+
approvalNeeded(input: ApprovalNeededInput<EvmSupportedChainIds>): Promise<ApprovalNeededOutput>;
|
|
25
|
+
approveInfinite(input: ApproveInfiniteInput<EvmSupportedChainIds>): Promise<string>;
|
|
27
26
|
approveAmount(): Promise<string>;
|
|
28
27
|
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
29
28
|
filterAssetIdsBySellable(): AssetId[];
|
|
@@ -36,6 +36,7 @@ class ThorchainSwapper {
|
|
|
36
36
|
[types_1.KnownChainIds.BitcoinCashMainnet]: true,
|
|
37
37
|
[types_1.KnownChainIds.CosmosMainnet]: true,
|
|
38
38
|
[types_1.KnownChainIds.ThorchainMainnet]: true,
|
|
39
|
+
[types_1.KnownChainIds.AvalancheMainnet]: true,
|
|
39
40
|
};
|
|
40
41
|
this.buySupportedChainIds = {
|
|
41
42
|
[types_1.KnownChainIds.EthereumMainnet]: true,
|
|
@@ -45,6 +46,7 @@ class ThorchainSwapper {
|
|
|
45
46
|
[types_1.KnownChainIds.BitcoinCashMainnet]: true,
|
|
46
47
|
[types_1.KnownChainIds.CosmosMainnet]: true,
|
|
47
48
|
[types_1.KnownChainIds.ThorchainMainnet]: true,
|
|
49
|
+
[types_1.KnownChainIds.AvalancheMainnet]: true,
|
|
48
50
|
};
|
|
49
51
|
this.supportedSellAssetIds = [caip_1.thorchainAssetId];
|
|
50
52
|
this.supportedBuyAssetIds = [caip_1.thorchainAssetId];
|
|
@@ -161,7 +163,7 @@ class ThorchainSwapper {
|
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
async getTradeTxs(tradeResult) {
|
|
164
|
-
var _a, _b, _c, _d
|
|
166
|
+
var _a, _b, _c, _d;
|
|
165
167
|
try {
|
|
166
168
|
const midgardTxid = tradeResult.tradeId.startsWith('0x')
|
|
167
169
|
? tradeResult.tradeId.slice(2)
|
|
@@ -179,12 +181,15 @@ class ThorchainSwapper {
|
|
|
179
181
|
code: api_1.SwapErrorTypes.TRADE_FAILED,
|
|
180
182
|
cause: data,
|
|
181
183
|
});
|
|
182
|
-
const standardBuyTxid = ((
|
|
183
|
-
|
|
184
|
-
:
|
|
184
|
+
const standardBuyTxid = (() => {
|
|
185
|
+
var _a, _b, _c;
|
|
186
|
+
const outCoinAsset = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.actions[0]) === null || _a === void 0 ? void 0 : _a.out[0]) === null || _b === void 0 ? void 0 : _b.coins[0]) === null || _c === void 0 ? void 0 : _c.asset;
|
|
187
|
+
const isEvmCoinAsset = (outCoinAsset === null || outCoinAsset === void 0 ? void 0 : outCoinAsset.startsWith('ETH.')) || (outCoinAsset === null || outCoinAsset === void 0 ? void 0 : outCoinAsset.startsWith('AVAX.'));
|
|
188
|
+
return isEvmCoinAsset ? `0x${buyTxid}` : buyTxid;
|
|
189
|
+
})().toLowerCase();
|
|
185
190
|
return {
|
|
186
191
|
sellTxid: tradeResult.tradeId,
|
|
187
|
-
buyTxid: standardBuyTxid
|
|
192
|
+
buyTxid: standardBuyTxid,
|
|
188
193
|
};
|
|
189
194
|
}
|
|
190
195
|
catch (e) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { BuildTradeInput } from '../../../api';
|
|
3
3
|
import { ThorchainSwapperDeps, ThorTrade } from '../types';
|
|
4
|
-
|
|
4
|
+
declare type BuildTradeArgs = {
|
|
5
5
|
deps: ThorchainSwapperDeps;
|
|
6
6
|
input: BuildTradeInput;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export declare const buildTrade: ({ deps, input }: BuildTradeArgs) => Promise<ThorTrade<ChainId>>;
|
|
9
|
+
export {};
|
|
@@ -8,8 +8,8 @@ const constants_1 = require("../../utils/constants");
|
|
|
8
8
|
const getTradeQuote_1 = require("../getThorTradeQuote/getTradeQuote");
|
|
9
9
|
const getThorTxData_1 = require("../utils/bitcoin/utils/getThorTxData");
|
|
10
10
|
const getCosmosTxData_1 = require("../utils/cosmos/getCosmosTxData");
|
|
11
|
-
const makeTradeTx_1 = require("../utils/
|
|
12
|
-
const buildTrade = async ({ deps, input
|
|
11
|
+
const makeTradeTx_1 = require("../utils/evm/makeTradeTx");
|
|
12
|
+
const buildTrade = async ({ deps, input }) => {
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
try {
|
|
15
15
|
const { buyAsset, receiveAddress: destinationAddress, sellAmountCryptoPrecision, sellAsset, bip44Params, slippage: slippageTolerance = constants_1.DEFAULT_SLIPPAGE, wallet, sendMax, } = input;
|
|
@@ -38,7 +38,7 @@ const buildTrade = async ({ deps, input, }) => {
|
|
|
38
38
|
buyAssetTradeFeeUsd: quote.feeData.buyAssetTradeFeeUsd,
|
|
39
39
|
});
|
|
40
40
|
return {
|
|
41
|
-
chainId:
|
|
41
|
+
chainId: sellAsset.chainId,
|
|
42
42
|
...quote,
|
|
43
43
|
receiveAddress: destinationAddress,
|
|
44
44
|
txData: ethTradeTx.txToSign,
|
|
@@ -12,8 +12,8 @@ const getInboundAddressDataForChain_1 = require("../utils/getInboundAddressDataF
|
|
|
12
12
|
const getTradeRate_1 = require("../utils/getTradeRate/getTradeRate");
|
|
13
13
|
const getUsdRate_1 = require("../utils/getUsdRate/getUsdRate");
|
|
14
14
|
const isRune_1 = require("../utils/isRune/isRune");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const getEvmTxFees_1 = require("../utils/txFeeHelpers/evmTxFees/getEvmTxFees");
|
|
16
|
+
const getUtxoTxFees_1 = require("../utils/txFeeHelpers/utxoTxFees/getUtxoTxFees");
|
|
17
17
|
const getThorTradeQuote = async ({ deps, input }) => {
|
|
18
18
|
const { sellAsset, buyAsset, sellAmountCryptoPrecision, bip44Params, chainId, receiveAddress, sendMax, } = input;
|
|
19
19
|
if (!bip44Params) {
|
|
@@ -64,12 +64,13 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
64
64
|
switch (chainNamespace) {
|
|
65
65
|
case caip_1.CHAIN_NAMESPACE.Evm:
|
|
66
66
|
return (async () => {
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const sellChainFeeAssetId = sellAdapter.getFeeAssetId();
|
|
68
|
+
const evmAddressData = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellChainFeeAssetId);
|
|
69
|
+
const router = evmAddressData === null || evmAddressData === void 0 ? void 0 : evmAddressData.router;
|
|
69
70
|
if (!router)
|
|
70
|
-
throw new api_1.SwapError(
|
|
71
|
-
const feeData = await (0,
|
|
72
|
-
|
|
71
|
+
throw new api_1.SwapError(`[getThorTradeQuote] No router address found for ${sellChainFeeAssetId}`);
|
|
72
|
+
const feeData = await (0, getEvmTxFees_1.getEvmTxFees)({
|
|
73
|
+
adapter: sellAdapter,
|
|
73
74
|
sellAssetReference,
|
|
74
75
|
buyAssetTradeFeeUsd,
|
|
75
76
|
});
|
|
@@ -91,7 +92,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
91
92
|
xpub: input.xpub,
|
|
92
93
|
buyAssetTradeFeeUsd,
|
|
93
94
|
});
|
|
94
|
-
const feeData = await (0,
|
|
95
|
+
const feeData = await (0, getUtxoTxFees_1.getUtxoTxFees)({
|
|
95
96
|
sellAmountCryptoPrecision,
|
|
96
97
|
vault,
|
|
97
98
|
opReturnData,
|
|
@@ -57,13 +57,13 @@ export interface BtcThorTrade<C extends ChainId> extends Trade<C> {
|
|
|
57
57
|
chainId: UtxoSupportedChainIds;
|
|
58
58
|
txData: BTCSignTx;
|
|
59
59
|
}
|
|
60
|
-
export interface
|
|
61
|
-
chainId: KnownChainIds.EthereumMainnet;
|
|
60
|
+
export interface EvmThorTrade<C extends ChainId> extends Trade<C> {
|
|
61
|
+
chainId: KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
62
62
|
txData: ETHSignTx;
|
|
63
63
|
}
|
|
64
64
|
export interface CosmosThorTrade<C extends ChainId> extends Trade<C> {
|
|
65
65
|
chainId: KnownChainIds.CosmosMainnet;
|
|
66
66
|
txData: CosmosSignTx;
|
|
67
67
|
}
|
|
68
|
-
export declare type ThorTrade<C extends ChainId> = BtcThorTrade<C> |
|
|
68
|
+
export declare type ThorTrade<C extends ChainId> = BtcThorTrade<C> | EvmThorTrade<C> | CosmosThorTrade<C>;
|
|
69
69
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const MAX_THORCHAIN_TRADE = "100000000000000000000000000";
|
|
2
2
|
export declare const MAX_ALLOWANCE = "100000000000000000000000000";
|
|
3
3
|
export declare const THOR_MINIMUM_PADDING = 1.2;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const THOR_EVM_GAS_LIMIT = "100000";
|
|
5
5
|
export declare const THORCHAIN_FIXED_PRECISION = 8;
|
|
6
6
|
export declare const THORCHAIN_AFFILIATE_NAME = "ss";
|
|
7
7
|
export declare const THORCHAIN_AFFILIATE_BIPS = "0";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.THORCHAIN_AFFILIATE_BIPS = exports.THORCHAIN_AFFILIATE_NAME = exports.THORCHAIN_FIXED_PRECISION = exports.
|
|
3
|
+
exports.THORCHAIN_AFFILIATE_BIPS = exports.THORCHAIN_AFFILIATE_NAME = exports.THORCHAIN_FIXED_PRECISION = exports.THOR_EVM_GAS_LIMIT = exports.THOR_MINIMUM_PADDING = exports.MAX_ALLOWANCE = exports.MAX_THORCHAIN_TRADE = void 0;
|
|
4
4
|
exports.MAX_THORCHAIN_TRADE = '100000000000000000000000000';
|
|
5
5
|
exports.MAX_ALLOWANCE = '100000000000000000000000000';
|
|
6
6
|
exports.THOR_MINIMUM_PADDING = 1.2;
|
|
7
|
-
exports.
|
|
7
|
+
exports.THOR_EVM_GAS_LIMIT = '100000'; // for sends of eth / erc20 into thorchain router
|
|
8
8
|
exports.THORCHAIN_FIXED_PRECISION = 8; // limit values are precision 8 regardless of the chain
|
|
9
9
|
exports.THORCHAIN_AFFILIATE_NAME = 'ss';
|
|
10
10
|
exports.THORCHAIN_AFFILIATE_BIPS = '0'; // affiliate fee in basis points (100 = 1%)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
|
-
import { ethereum } from '@shapeshiftoss/chain-adapters';
|
|
3
2
|
import { ETHSignTx, HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
4
3
|
import { BIP44Params } from '@shapeshiftoss/types';
|
|
4
|
+
import { EvmSupportedChainAdapter } from '../../../../api';
|
|
5
5
|
import type { ThorchainSwapperDeps } from '../../types';
|
|
6
6
|
declare type MakeTradeTxArgs = {
|
|
7
7
|
wallet: HDWallet;
|
|
@@ -10,7 +10,7 @@ declare type MakeTradeTxArgs = {
|
|
|
10
10
|
buyAsset: Asset;
|
|
11
11
|
sellAsset: Asset;
|
|
12
12
|
destinationAddress: string;
|
|
13
|
-
adapter:
|
|
13
|
+
adapter: EvmSupportedChainAdapter;
|
|
14
14
|
slippageTolerance: string;
|
|
15
15
|
deps: ThorchainSwapperDeps;
|
|
16
16
|
gasLimit: string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssetReference } from '@shapeshiftoss/caip';
|
|
2
|
+
import { EvmSupportedChainAdapter, EvmSupportedChainIds, QuoteFeeData } from '../../../../../api';
|
|
3
|
+
declare type GetEvmTxFeesArgs = {
|
|
4
|
+
adapter: EvmSupportedChainAdapter;
|
|
5
|
+
sellAssetReference: AssetReference | string;
|
|
6
|
+
buyAssetTradeFeeUsd: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const getEvmTxFees: ({ adapter, sellAssetReference, buyAssetTradeFeeUsd, }: GetEvmTxFeesArgs) => Promise<QuoteFeeData<EvmSupportedChainIds>>;
|
|
9
|
+
export {};
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getEvmTxFees = void 0;
|
|
4
4
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
6
5
|
const api_1 = require("../../../../../api");
|
|
7
6
|
const bignumber_1 = require("../../../../utils/bignumber");
|
|
8
7
|
const constants_1 = require("../../../../utils/constants");
|
|
9
8
|
const constants_2 = require("../../constants");
|
|
10
|
-
const
|
|
9
|
+
const getEvmTxFees = async ({ adapter, sellAssetReference, buyAssetTradeFeeUsd, }) => {
|
|
11
10
|
try {
|
|
12
|
-
const adapter = adapterManager.get(types_1.KnownChainIds.EthereumMainnet);
|
|
13
|
-
if (!adapter) {
|
|
14
|
-
throw new api_1.SwapError(`[getThorTxInfo] - No chain adapter found for ${types_1.KnownChainIds.EthereumMainnet}.`, {
|
|
15
|
-
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
16
|
-
details: { chainId: types_1.KnownChainIds.EthereumMainnet },
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
11
|
const gasFeeData = await adapter.getGasFeeData();
|
|
20
|
-
// this is a good value to cover all thortrades out of
|
|
12
|
+
// this is a good value to cover all thortrades out of EVMs
|
|
21
13
|
// in the future we may want to look at doing this more precisely and in a future-proof way
|
|
22
|
-
|
|
14
|
+
// TODO: calculate this dynamically
|
|
15
|
+
const gasLimit = constants_2.THOR_EVM_GAS_LIMIT;
|
|
23
16
|
const feeDataOptions = {
|
|
24
17
|
fast: {
|
|
25
18
|
txFee: (0, bignumber_1.bn)(gasLimit).times(gasFeeData[chain_adapters_1.FeeDataKey.Fast].gasPrice).toString(),
|
|
@@ -50,4 +43,4 @@ const getEthTxFees = async ({ adapterManager, sellAssetReference, buyAssetTradeF
|
|
|
50
43
|
throw new api_1.SwapError('[getThorTxInfo]', { cause: e, code: api_1.SwapErrorTypes.TRADE_QUOTE_FAILED });
|
|
51
44
|
}
|
|
52
45
|
};
|
|
53
|
-
exports.
|
|
46
|
+
exports.getEvmTxFees = getEvmTxFees;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UtxoBaseAdapter } from '@shapeshiftoss/chain-adapters';
|
|
2
2
|
import { QuoteFeeData, UtxoSupportedChainIds } from '../../../../../api';
|
|
3
|
-
declare type
|
|
3
|
+
declare type GetUtxoTxFeesInput = {
|
|
4
4
|
opReturnData: string;
|
|
5
5
|
vault: string;
|
|
6
6
|
sellAmountCryptoPrecision: string;
|
|
@@ -9,5 +9,5 @@ declare type GetBtcTxFeesInput = {
|
|
|
9
9
|
buyAssetTradeFeeUsd: string;
|
|
10
10
|
sendMax: boolean;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const getUtxoTxFees: ({ opReturnData, vault, sellAmountCryptoPrecision, sellAdapter, pubkey, buyAssetTradeFeeUsd, sendMax, }: GetUtxoTxFeesInput) => Promise<QuoteFeeData<UtxoSupportedChainIds>>;
|
|
13
13
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getUtxoTxFees = void 0;
|
|
4
4
|
const types_1 = require("@shapeshiftoss/types");
|
|
5
5
|
const api_1 = require("../../../../../api");
|
|
6
6
|
const bignumber_1 = require("../../../../utils/bignumber");
|
|
7
|
-
const
|
|
7
|
+
const getUtxoTxFees = async ({ opReturnData, vault, sellAmountCryptoPrecision, sellAdapter, pubkey, buyAssetTradeFeeUsd, sendMax, }) => {
|
|
8
8
|
try {
|
|
9
9
|
const feeDataOptions = await sellAdapter.getFeeData({
|
|
10
10
|
to: vault,
|
|
@@ -38,7 +38,7 @@ const getBtcTxFees = async ({ opReturnData, vault, sellAmountCryptoPrecision, se
|
|
|
38
38
|
catch (e) {
|
|
39
39
|
if (e instanceof api_1.SwapError)
|
|
40
40
|
throw e;
|
|
41
|
-
throw new api_1.SwapError('[
|
|
41
|
+
throw new api_1.SwapError('[getUtxoTxFees]', { cause: e, code: api_1.SwapErrorTypes.TRADE_QUOTE_FAILED });
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
exports.
|
|
44
|
+
exports.getUtxoTxFees = getUtxoTxFees;
|
|
@@ -2,10 +2,10 @@ import { Asset } from '@shapeshiftoss/asset-service';
|
|
|
2
2
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
3
|
import Web3 from 'web3';
|
|
4
4
|
import { AbiItem } from 'web3-utils';
|
|
5
|
-
import {
|
|
5
|
+
import { EvmSupportedChainAdapter, EvmSupportedChainIds, TradeQuote } from '../../../api';
|
|
6
6
|
import { BN } from '../bignumber';
|
|
7
7
|
export declare type IsApprovalRequiredArgs = {
|
|
8
|
-
adapter:
|
|
8
|
+
adapter: EvmSupportedChainAdapter;
|
|
9
9
|
receiveAddress: string;
|
|
10
10
|
allowanceContract: string;
|
|
11
11
|
sellAsset: Asset;
|
|
@@ -28,7 +28,7 @@ export declare type GetApproveContractDataArgs = {
|
|
|
28
28
|
declare type GrantAllowanceArgs<T extends EvmSupportedChainIds> = {
|
|
29
29
|
quote: TradeQuote<T>;
|
|
30
30
|
wallet: HDWallet;
|
|
31
|
-
adapter:
|
|
31
|
+
adapter: EvmSupportedChainAdapter;
|
|
32
32
|
erc20Abi: AbiItem[];
|
|
33
33
|
web3: Web3;
|
|
34
34
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
2
2
|
import type Web3 from 'web3';
|
|
3
|
-
import {
|
|
3
|
+
import { EvmSupportedChainAdapter, EvmSupportedChainIds, SwapSource, Trade } from '../../api';
|
|
4
4
|
export declare type ZrxCommonResponse = {
|
|
5
5
|
price: string;
|
|
6
6
|
gasPrice: string;
|
|
@@ -26,6 +26,6 @@ export declare type ZrxExecuteTradeInput<T extends EvmSupportedChainIds> = {
|
|
|
26
26
|
wallet: HDWallet;
|
|
27
27
|
};
|
|
28
28
|
export declare type ZrxSwapperDeps = {
|
|
29
|
-
adapter:
|
|
29
|
+
adapter: EvmSupportedChainAdapter;
|
|
30
30
|
web3: Web3;
|
|
31
31
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AssetReference } from '@shapeshiftoss/caip';
|
|
2
|
-
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
4
|
-
import { QuoteFeeData } from '../../../../../api';
|
|
5
|
-
export declare const getEthTxFees: ({ adapterManager, sellAssetReference, buyAssetTradeFeeUsd, }: {
|
|
6
|
-
adapterManager: ChainAdapterManager;
|
|
7
|
-
sellAssetReference: AssetReference | string;
|
|
8
|
-
buyAssetTradeFeeUsd: string;
|
|
9
|
-
}) => Promise<QuoteFeeData<KnownChainIds.EthereumMainnet>>;
|