@shapeshiftoss/swapper 16.0.2 → 17.0.0
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 +7 -9
- package/dist/manager/testData.d.ts +3 -3
- package/dist/swappers/osmosis/OsmosisSwapper.d.ts +4 -0
- package/dist/swappers/osmosis/utils/helpers.d.ts +3 -2
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +7 -3
- package/dist/swappers/thorchain/ThorchainSwapper.js +11 -7
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.js +4 -5
- package/dist/swappers/thorchain/{utils/cosmos → cosmossdk}/getCosmosTxData.d.ts +7 -7
- package/dist/swappers/thorchain/{utils/cosmos → cosmossdk}/getCosmosTxData.js +4 -4
- package/dist/swappers/thorchain/{utils/evm → evm}/makeTradeTx.d.ts +4 -3
- package/dist/swappers/thorchain/{utils/evm → evm}/makeTradeTx.js +1 -1
- package/dist/swappers/thorchain/{utils/evm → evm}/routerAbi.d.ts +0 -0
- package/dist/swappers/thorchain/{utils/evm → evm}/routerAbi.js +0 -0
- package/dist/swappers/thorchain/{utils/evm → evm}/routerCalldata.d.ts +0 -0
- package/dist/swappers/thorchain/{utils/evm → evm}/routerCalldata.js +0 -0
- package/dist/swappers/thorchain/{utils/evm → evm}/utils/getThorTxData.d.ts +1 -1
- package/dist/swappers/thorchain/{utils/evm → evm}/utils/getThorTxData.js +4 -4
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +1 -1
- package/dist/swappers/thorchain/types.d.ts +12 -13
- package/dist/swappers/thorchain/utils/txFeeHelpers/evmTxFees/getEvmTxFees.d.ts +5 -3
- package/dist/swappers/thorchain/utils/txFeeHelpers/utxoTxFees/getUtxoTxFees.d.ts +4 -3
- package/dist/swappers/thorchain/{utils/bitcoin → utxo}/utils/getThorTxData.d.ts +5 -5
- package/dist/swappers/thorchain/{utils/bitcoin → utxo}/utils/getThorTxData.js +4 -4
- package/dist/swappers/utils/helpers/helpers.d.ts +6 -5
- package/dist/swappers/utils/test-data/setupSwapQuote.d.ts +1 -1
- package/dist/swappers/zrx/ZrxSwapper.d.ts +6 -2
- package/dist/swappers/zrx/getZrxTradeQuote/getZrxTradeQuote.d.ts +3 -2
- package/dist/swappers/zrx/types.d.ts +5 -4
- package/dist/swappers/zrx/zrxApprovalNeeded/zrxApprovalNeeded.d.ts +3 -2
- package/dist/swappers/zrx/zrxApprove/zrxApprove.d.ts +4 -3
- package/dist/swappers/zrx/zrxBuildTrade/zrxBuildTrade.d.ts +3 -2
- package/dist/swappers/zrx/zrxExecuteTrade/zrxExecuteTrade.d.ts +3 -2
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import {
|
|
3
|
+
import { CosmosSdkChainId, EvmChainId, UtxoChainId } from '@shapeshiftoss/chain-adapters';
|
|
4
4
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
5
5
|
import { ChainSpecific, KnownChainIds, UtxoAccountType } from '@shapeshiftoss/types';
|
|
6
6
|
export declare const SwapError: {
|
|
@@ -63,6 +63,9 @@ declare type ChainSpecificQuoteFeeData<T extends ChainId> = ChainSpecific<T, {
|
|
|
63
63
|
[KnownChainIds.CosmosMainnet]: {
|
|
64
64
|
estimatedGas: string;
|
|
65
65
|
};
|
|
66
|
+
[KnownChainIds.ThorchainMainnet]: {
|
|
67
|
+
estimatedGas: string;
|
|
68
|
+
};
|
|
66
69
|
}>;
|
|
67
70
|
export declare type QuoteFeeData<T extends ChainId> = {
|
|
68
71
|
networkFeeCryptoBaseUnit: string;
|
|
@@ -97,19 +100,14 @@ declare type CommonTradeInput = {
|
|
|
97
100
|
receiveAddress: string;
|
|
98
101
|
accountNumber: number;
|
|
99
102
|
};
|
|
100
|
-
export declare type EvmSupportedChainIds = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet;
|
|
101
|
-
export declare type CosmosSdkSupportedChainIds = KnownChainIds.CosmosMainnet | KnownChainIds.OsmosisMainnet | KnownChainIds.ThorchainMainnet;
|
|
102
|
-
export declare type EvmSupportedChainAdapter = ethereum.ChainAdapter | avalanche.ChainAdapter | optimism.ChainAdapter;
|
|
103
|
-
export declare type CosmosSdkSupportedChainAdapters = cosmos.ChainAdapter | osmosis.ChainAdapter;
|
|
104
|
-
export declare type UtxoSupportedChainIds = KnownChainIds.BitcoinMainnet | KnownChainIds.DogecoinMainnet | KnownChainIds.LitecoinMainnet | KnownChainIds.BitcoinCashMainnet;
|
|
105
103
|
export declare type GetEvmTradeQuoteInput = CommonTradeInput & {
|
|
106
|
-
chainId:
|
|
104
|
+
chainId: EvmChainId;
|
|
107
105
|
};
|
|
108
106
|
export declare type GetCosmosSdkTradeQuoteInput = CommonTradeInput & {
|
|
109
|
-
chainId:
|
|
107
|
+
chainId: CosmosSdkChainId;
|
|
110
108
|
};
|
|
111
109
|
export declare type GetUtxoTradeQuoteInput = CommonTradeInput & {
|
|
112
|
-
chainId:
|
|
110
|
+
chainId: UtxoChainId;
|
|
113
111
|
accountType: UtxoAccountType;
|
|
114
112
|
accountNumber: number;
|
|
115
113
|
xpub: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
2
|
import { TradeQuote } from '../api';
|
|
3
3
|
import { CowSwapper, ThorchainSwapper, ZrxSwapper } from '../swappers';
|
|
4
|
-
export declare const getZrxEthereumSwapper: () => ZrxSwapper<import("../
|
|
5
|
-
export declare const getZrxAvalancheSwapper: () => ZrxSwapper<import("../
|
|
6
|
-
export declare const getZrxOptimismSwapper: () => ZrxSwapper<import("../
|
|
4
|
+
export declare const getZrxEthereumSwapper: () => ZrxSwapper<import("../swappers").ZrxSupportedChainId>;
|
|
5
|
+
export declare const getZrxAvalancheSwapper: () => ZrxSwapper<import("../swappers").ZrxSupportedChainId>;
|
|
6
|
+
export declare const getZrxOptimismSwapper: () => ZrxSwapper<import("../swappers").ZrxSupportedChainId>;
|
|
7
7
|
export declare const getCowSwapper: () => CowSwapper;
|
|
8
8
|
export declare const getThorchainSwapper: () => ThorchainSwapper;
|
|
9
9
|
export declare const tradeQuote: TradeQuote<KnownChainIds.EthereumMainnet>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
+
import { cosmos, osmosis } from '@shapeshiftoss/chain-adapters';
|
|
4
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
3
5
|
import { ApprovalNeededOutput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperName, SwapperType, Trade, TradeQuote, TradeTxs } from '../../api';
|
|
4
6
|
import { OsmosisTradeResult, OsmoSwapperDeps } from './utils/types';
|
|
7
|
+
export declare type OsmosisSupportedChainId = KnownChainIds.CosmosMainnet | KnownChainIds.OsmosisMainnet;
|
|
8
|
+
export declare type OsmosisSupportedChainAdapter = cosmos.ChainAdapter | osmosis.ChainAdapter;
|
|
5
9
|
export declare class OsmosisSwapper implements Swapper<ChainId> {
|
|
6
10
|
readonly name = SwapperName.Osmosis;
|
|
7
11
|
supportedAssetIds: string[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { osmosis } from '@shapeshiftoss/chain-adapters';
|
|
2
2
|
import { HDWallet, Osmosis } from '@shapeshiftoss/hdwallet-core';
|
|
3
|
-
import {
|
|
3
|
+
import { TradeResult } from '../../../api';
|
|
4
|
+
import { OsmosisSupportedChainAdapter } from '../OsmosisSwapper';
|
|
4
5
|
import { IbcTransferInput } from './types';
|
|
5
6
|
export interface SymbolDenomMapping {
|
|
6
7
|
OSMO: string;
|
|
@@ -21,7 +22,7 @@ export declare const getRateInfo: (sellAsset: string, buyAsset: string, sellAmou
|
|
|
21
22
|
buyAssetTradeFeeUsd: string;
|
|
22
23
|
buyAmountCryptoBaseUnit: string;
|
|
23
24
|
}>;
|
|
24
|
-
export declare const performIbcTransfer: (input: IbcTransferInput, adapter:
|
|
25
|
+
export declare const performIbcTransfer: (input: IbcTransferInput, adapter: OsmosisSupportedChainAdapter, wallet: HDWallet, blockBaseUrl: string, denom: string, sourceChannel: string, feeAmount: string, accountNumber: number, ibcAccountNumber: number, sequence: string, gas: string, feeDenom: string) => Promise<TradeResult>;
|
|
25
26
|
export declare const buildTradeTx: ({ osmoAddress, adapter, accountNumber, buyAssetDenom, sellAssetDenom, sellAmount, gas, wallet, }: {
|
|
26
27
|
osmoAddress: string;
|
|
27
28
|
adapter: osmosis.ChainAdapter;
|
|
@@ -1,11 +1,15 @@
|
|
|
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';
|
|
4
5
|
import Web3 from 'web3';
|
|
5
|
-
import type { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput,
|
|
6
|
+
import type { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
6
7
|
import { SwapperName, SwapperType } from '../../api';
|
|
7
8
|
import { ThorchainSwapperDeps } from './types';
|
|
8
9
|
export * from './types';
|
|
10
|
+
export declare type ThorUtxoSupportedChainId = KnownChainIds.BitcoinMainnet | KnownChainIds.DogecoinMainnet | KnownChainIds.LitecoinMainnet | KnownChainIds.BitcoinCashMainnet;
|
|
11
|
+
export declare type ThorEvmSupportedChainId = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
12
|
+
export declare type ThorCosmosSdkSupportedChainId = KnownChainIds.ThorchainMainnet | KnownChainIds.CosmosMainnet;
|
|
9
13
|
export declare class ThorchainSwapper implements Swapper<ChainId> {
|
|
10
14
|
readonly name = SwapperName.Thorchain;
|
|
11
15
|
private sellSupportedChainIds;
|
|
@@ -21,8 +25,8 @@ export declare class ThorchainSwapper implements Swapper<ChainId> {
|
|
|
21
25
|
initialize(): Promise<void>;
|
|
22
26
|
getType(): SwapperType;
|
|
23
27
|
getUsdRate({ assetId }: Pick<Asset, 'assetId'>): Promise<string>;
|
|
24
|
-
approvalNeeded(input: ApprovalNeededInput<
|
|
25
|
-
approveInfinite(input: ApproveInfiniteInput<
|
|
28
|
+
approvalNeeded(input: ApprovalNeededInput<ThorEvmSupportedChainId>): Promise<ApprovalNeededOutput>;
|
|
29
|
+
approveInfinite(input: ApproveInfiniteInput<ThorEvmSupportedChainId>): Promise<string>;
|
|
26
30
|
approveAmount(): Promise<string>;
|
|
27
31
|
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
28
32
|
filterAssetIdsBySellable(): AssetId[];
|
|
@@ -113,17 +113,19 @@ class ThorchainSwapper {
|
|
|
113
113
|
async executeTrade(args) {
|
|
114
114
|
try {
|
|
115
115
|
const { trade, wallet } = args;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const { chainNamespace, chainId } = (0, caip_1.fromAssetId)(trade.sellAsset.assetId);
|
|
117
|
+
const adapter = this.deps.adapterManager.get(chainId);
|
|
118
|
+
if (!adapter) {
|
|
118
119
|
throw new api_1.SwapError('[executeTrade]: no adapter for sell asset chain id', {
|
|
119
120
|
code: api_1.SwapErrorType.SIGN_AND_BROADCAST_FAILED,
|
|
120
|
-
details: { chainId
|
|
121
|
+
details: { chainId },
|
|
121
122
|
fn: 'executeTrade',
|
|
122
123
|
});
|
|
123
|
-
|
|
124
|
+
}
|
|
124
125
|
if (chainNamespace === caip_1.CHAIN_NAMESPACE.Evm) {
|
|
125
126
|
const evmAdapter = adapter;
|
|
126
|
-
const txToSign = trade
|
|
127
|
+
const txToSign = trade
|
|
128
|
+
.txData;
|
|
127
129
|
if (wallet.supportsBroadcast()) {
|
|
128
130
|
const tradeId = await evmAdapter.signAndBroadcastTransaction({ txToSign, wallet });
|
|
129
131
|
return { tradeId };
|
|
@@ -134,7 +136,8 @@ class ThorchainSwapper {
|
|
|
134
136
|
}
|
|
135
137
|
else if (chainNamespace === caip_1.CHAIN_NAMESPACE.Utxo) {
|
|
136
138
|
const signedTx = await adapter.signTransaction({
|
|
137
|
-
txToSign: trade
|
|
139
|
+
txToSign: trade
|
|
140
|
+
.txData,
|
|
138
141
|
wallet,
|
|
139
142
|
});
|
|
140
143
|
const txid = await adapter.broadcastTransaction(signedTx);
|
|
@@ -142,7 +145,8 @@ class ThorchainSwapper {
|
|
|
142
145
|
}
|
|
143
146
|
else if (chainNamespace === caip_1.CHAIN_NAMESPACE.CosmosSdk) {
|
|
144
147
|
const signedTx = await adapter.signTransaction({
|
|
145
|
-
txToSign: trade
|
|
148
|
+
txToSign: trade
|
|
149
|
+
.txData,
|
|
146
150
|
wallet,
|
|
147
151
|
});
|
|
148
152
|
const txid = await adapter.broadcastTransaction(signedTx);
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildTrade = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
6
5
|
const api_1 = require("../../../api");
|
|
7
6
|
const constants_1 = require("../../utils/constants");
|
|
7
|
+
const getCosmosTxData_1 = require("../cosmossdk/getCosmosTxData");
|
|
8
|
+
const makeTradeTx_1 = require("../evm/makeTradeTx");
|
|
8
9
|
const getTradeQuote_1 = require("../getThorTradeQuote/getTradeQuote");
|
|
9
|
-
const getThorTxData_1 = require("../
|
|
10
|
-
const getCosmosTxData_1 = require("../utils/cosmos/getCosmosTxData");
|
|
11
|
-
const makeTradeTx_1 = require("../utils/evm/makeTradeTx");
|
|
10
|
+
const getThorTxData_1 = require("../utxo/utils/getThorTxData");
|
|
12
11
|
const buildTrade = async ({ deps, input }) => {
|
|
13
12
|
var _a, _b, _c, _d;
|
|
14
13
|
try {
|
|
@@ -90,7 +89,7 @@ const buildTrade = async ({ deps, input }) => {
|
|
|
90
89
|
quote: quote,
|
|
91
90
|
});
|
|
92
91
|
return {
|
|
93
|
-
chainId:
|
|
92
|
+
chainId: sellAsset.chainId,
|
|
94
93
|
...quote,
|
|
95
94
|
receiveAddress: destinationAddress,
|
|
96
95
|
txData,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import {
|
|
3
|
+
import { CosmosSdkBaseAdapter } from '@shapeshiftoss/chain-adapters';
|
|
4
4
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import type { ThorchainSwapperDeps } from '
|
|
5
|
+
import { TradeQuote } from '../../../api';
|
|
6
|
+
import { ThorCosmosSdkSupportedChainId } from '../ThorchainSwapper';
|
|
7
|
+
import type { ThorchainSwapperDeps } from '../types';
|
|
8
8
|
declare type GetCosmosTxDataInput = {
|
|
9
9
|
accountNumber: number;
|
|
10
10
|
destinationAddress: string;
|
|
@@ -14,9 +14,9 @@ declare type GetCosmosTxDataInput = {
|
|
|
14
14
|
buyAsset: Asset;
|
|
15
15
|
slippageTolerance: string;
|
|
16
16
|
wallet: HDWallet;
|
|
17
|
-
quote: TradeQuote<
|
|
17
|
+
quote: TradeQuote<ThorCosmosSdkSupportedChainId>;
|
|
18
18
|
chainId: ChainId;
|
|
19
|
-
sellAdapter:
|
|
19
|
+
sellAdapter: CosmosSdkBaseAdapter<ThorCosmosSdkSupportedChainId>;
|
|
20
20
|
};
|
|
21
|
-
export declare const getCosmosTxData: (input: GetCosmosTxDataInput) => Promise<import("@shapeshiftoss/hdwallet-core").CosmosSignTx>;
|
|
21
|
+
export declare const getCosmosTxData: (input: GetCosmosTxDataInput) => Promise<import("@shapeshiftoss/hdwallet-core").CosmosSignTx | import("@shapeshiftoss/hdwallet-core").ThorchainSignTx>;
|
|
22
22
|
export {};
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCosmosTxData = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
6
|
-
const api_1 = require("
|
|
7
|
-
const getInboundAddressDataForChain_1 = require("../getInboundAddressDataForChain");
|
|
8
|
-
const getLimit_1 = require("../getLimit/getLimit");
|
|
9
|
-
const makeSwapMemo_1 = require("../makeSwapMemo/makeSwapMemo");
|
|
6
|
+
const api_1 = require("../../../api");
|
|
7
|
+
const getInboundAddressDataForChain_1 = require("../utils/getInboundAddressDataForChain");
|
|
8
|
+
const getLimit_1 = require("../utils/getLimit/getLimit");
|
|
9
|
+
const makeSwapMemo_1 = require("../utils/makeSwapMemo/makeSwapMemo");
|
|
10
10
|
const getCosmosTxData = async (input) => {
|
|
11
11
|
const { accountNumber, deps, destinationAddress, sellAmountCryptoBaseUnit, sellAsset, buyAsset, slippageTolerance, quote, wallet, sellAdapter, } = input;
|
|
12
12
|
const fromThorAsset = sellAsset.chainId == types_1.KnownChainIds.ThorchainMainnet;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
|
+
import { EvmBaseAdapter } from '@shapeshiftoss/chain-adapters';
|
|
2
3
|
import { ETHSignTx, HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
|
-
import {
|
|
4
|
-
import type { ThorchainSwapperDeps } from '
|
|
4
|
+
import { ThorEvmSupportedChainId } from '../ThorchainSwapper';
|
|
5
|
+
import type { ThorchainSwapperDeps } from '../types';
|
|
5
6
|
declare type MakeTradeTxArgs = {
|
|
6
7
|
wallet: HDWallet;
|
|
7
8
|
accountNumber: number;
|
|
@@ -9,7 +10,7 @@ declare type MakeTradeTxArgs = {
|
|
|
9
10
|
buyAsset: Asset;
|
|
10
11
|
sellAsset: Asset;
|
|
11
12
|
destinationAddress: string;
|
|
12
|
-
adapter:
|
|
13
|
+
adapter: EvmBaseAdapter<ThorEvmSupportedChainId>;
|
|
13
14
|
slippageTolerance: string;
|
|
14
15
|
deps: ThorchainSwapperDeps;
|
|
15
16
|
gasLimit: string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.makeTradeTx = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const web3_utils_1 = require("web3-utils");
|
|
6
|
-
const api_1 = require("
|
|
6
|
+
const api_1 = require("../../../api");
|
|
7
7
|
const getThorTxData_1 = require("./utils/getThorTxData");
|
|
8
8
|
const makeTradeTx = async ({ wallet, accountNumber, sellAmountCryptoBaseUnit, buyAsset, sellAsset, destinationAddress, adapter, maxFeePerGas, maxPriorityFeePerGas, gasPriceCryptoBaseUnit, slippageTolerance, deps, gasLimit, buyAssetTradeFeeUsd, }) => {
|
|
9
9
|
try {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getThorTxInfo = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
-
const api_1 = require("
|
|
6
|
-
const getInboundAddressDataForChain_1 = require("../../getInboundAddressDataForChain");
|
|
7
|
-
const getLimit_1 = require("../../getLimit/getLimit");
|
|
8
|
-
const makeSwapMemo_1 = require("../../makeSwapMemo/makeSwapMemo");
|
|
5
|
+
const api_1 = require("../../../../api");
|
|
6
|
+
const getInboundAddressDataForChain_1 = require("../../utils/getInboundAddressDataForChain");
|
|
7
|
+
const getLimit_1 = require("../../utils/getLimit/getLimit");
|
|
8
|
+
const makeSwapMemo_1 = require("../../utils/makeSwapMemo/makeSwapMemo");
|
|
9
9
|
const routerCalldata_1 = require("../routerCalldata");
|
|
10
10
|
const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmountCryptoBaseUnit, slippageTolerance, destinationAddress, buyAssetTradeFeeUsd, }) => {
|
|
11
11
|
try {
|
|
@@ -6,7 +6,6 @@ const api_1 = require("../../../api");
|
|
|
6
6
|
const bignumber_1 = require("../../utils/bignumber");
|
|
7
7
|
const constants_1 = require("../../utils/constants");
|
|
8
8
|
const constants_2 = require("../constants");
|
|
9
|
-
const getThorTxData_1 = require("../utils/bitcoin/utils/getThorTxData");
|
|
10
9
|
const constants_3 = require("../utils/constants");
|
|
11
10
|
const getInboundAddressDataForChain_1 = require("../utils/getInboundAddressDataForChain");
|
|
12
11
|
const getTradeRate_1 = require("../utils/getTradeRate/getTradeRate");
|
|
@@ -14,6 +13,7 @@ const getUsdRate_1 = require("../utils/getUsdRate/getUsdRate");
|
|
|
14
13
|
const isRune_1 = require("../utils/isRune/isRune");
|
|
15
14
|
const getEvmTxFees_1 = require("../utils/txFeeHelpers/evmTxFees/getEvmTxFees");
|
|
16
15
|
const getUtxoTxFees_1 = require("../utils/txFeeHelpers/utxoTxFees/getUtxoTxFees");
|
|
16
|
+
const getThorTxData_1 = require("../utxo/utils/getThorTxData");
|
|
17
17
|
const getSlippage_1 = require("./getSlippage");
|
|
18
18
|
const getThorTradeQuote = async ({ deps, input }) => {
|
|
19
19
|
const { sellAsset, buyAsset, sellAmountBeforeFeesCryptoBaseUnit: sellAmountCryptoBaseUnit, accountNumber, chainId, receiveAddress, sendMax, } = input;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import type { BTCSignTx, CosmosSignTx, ETHSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
4
|
-
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
|
+
import { ChainAdapterManager, SignTx } from '@shapeshiftoss/chain-adapters';
|
|
5
3
|
import type Web3 from 'web3';
|
|
6
|
-
import type { Trade
|
|
4
|
+
import type { Trade } from '../../api';
|
|
5
|
+
import { ThorCosmosSdkSupportedChainId, ThorEvmSupportedChainId, ThorUtxoSupportedChainId } from './ThorchainSwapper';
|
|
7
6
|
export declare type ThornodePoolResponse = {
|
|
8
7
|
LP_units: string;
|
|
9
8
|
asset: string;
|
|
@@ -57,17 +56,17 @@ export declare type ThorchainSwapperDeps = {
|
|
|
57
56
|
adapterManager: ChainAdapterManager;
|
|
58
57
|
web3: Web3;
|
|
59
58
|
};
|
|
60
|
-
export interface
|
|
61
|
-
chainId:
|
|
62
|
-
txData:
|
|
59
|
+
export interface UtxoThorTrade<C extends ChainId> extends Trade<C> {
|
|
60
|
+
chainId: ThorUtxoSupportedChainId;
|
|
61
|
+
txData: SignTx<ThorUtxoSupportedChainId>;
|
|
63
62
|
}
|
|
64
63
|
export interface EvmThorTrade<C extends ChainId> extends Trade<C> {
|
|
65
|
-
chainId:
|
|
66
|
-
txData:
|
|
64
|
+
chainId: ThorEvmSupportedChainId;
|
|
65
|
+
txData: SignTx<ThorEvmSupportedChainId>;
|
|
67
66
|
}
|
|
68
|
-
export interface
|
|
69
|
-
chainId:
|
|
70
|
-
txData:
|
|
67
|
+
export interface CosmosSdkThorTrade<C extends ChainId> extends Trade<C> {
|
|
68
|
+
chainId: ThorCosmosSdkSupportedChainId;
|
|
69
|
+
txData: SignTx<ThorCosmosSdkSupportedChainId>;
|
|
71
70
|
}
|
|
72
|
-
export declare type ThorTrade<C extends ChainId> =
|
|
71
|
+
export declare type ThorTrade<C extends ChainId> = UtxoThorTrade<C> | EvmThorTrade<C> | CosmosSdkThorTrade<C>;
|
|
73
72
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AssetReference } from '@shapeshiftoss/caip';
|
|
2
|
-
import {
|
|
2
|
+
import { EvmBaseAdapter } from '@shapeshiftoss/chain-adapters';
|
|
3
|
+
import { QuoteFeeData } from '../../../../../api';
|
|
4
|
+
import { ThorEvmSupportedChainId } from '../../../ThorchainSwapper';
|
|
3
5
|
declare type GetEvmTxFeesArgs = {
|
|
4
|
-
adapter:
|
|
6
|
+
adapter: EvmBaseAdapter<ThorEvmSupportedChainId>;
|
|
5
7
|
sellAssetReference: AssetReference | string;
|
|
6
8
|
buyAssetTradeFeeUsd: string;
|
|
7
9
|
};
|
|
8
|
-
export declare const getEvmTxFees: ({ adapter, sellAssetReference, buyAssetTradeFeeUsd, }: GetEvmTxFeesArgs) => Promise<QuoteFeeData<
|
|
10
|
+
export declare const getEvmTxFees: ({ adapter, sellAssetReference, buyAssetTradeFeeUsd, }: GetEvmTxFeesArgs) => Promise<QuoteFeeData<ThorEvmSupportedChainId>>;
|
|
9
11
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { UtxoBaseAdapter } from '@shapeshiftoss/chain-adapters';
|
|
2
|
-
import { QuoteFeeData
|
|
2
|
+
import { QuoteFeeData } from '../../../../../api';
|
|
3
|
+
import { ThorUtxoSupportedChainId } from '../../../ThorchainSwapper';
|
|
3
4
|
declare type GetUtxoTxFeesInput = {
|
|
4
5
|
opReturnData: string;
|
|
5
6
|
vault: string;
|
|
6
7
|
sellAmountCryptoBaseUnit: string;
|
|
7
|
-
sellAdapter: UtxoBaseAdapter<
|
|
8
|
+
sellAdapter: UtxoBaseAdapter<ThorUtxoSupportedChainId>;
|
|
8
9
|
pubkey: string;
|
|
9
10
|
buyAssetTradeFeeUsd: string;
|
|
10
11
|
sendMax: boolean;
|
|
11
12
|
};
|
|
12
|
-
export declare const getUtxoTxFees: ({ opReturnData, vault, sellAmountCryptoBaseUnit, sellAdapter, pubkey, buyAssetTradeFeeUsd, sendMax, }: GetUtxoTxFeesInput) => Promise<QuoteFeeData<
|
|
13
|
+
export declare const getUtxoTxFees: ({ opReturnData, vault, sellAmountCryptoBaseUnit, sellAdapter, pubkey, buyAssetTradeFeeUsd, sendMax, }: GetUtxoTxFeesInput) => Promise<QuoteFeeData<ThorUtxoSupportedChainId>>;
|
|
13
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
|
-
import type { ThorchainSwapperDeps } from '
|
|
3
|
-
declare type
|
|
2
|
+
import type { ThorchainSwapperDeps } from '../../types';
|
|
3
|
+
declare type GetThorTxInfoArgs = {
|
|
4
4
|
deps: ThorchainSwapperDeps;
|
|
5
5
|
sellAsset: Asset;
|
|
6
6
|
buyAsset: Asset;
|
|
@@ -10,11 +10,11 @@ declare type GetBtcThorTxInfoArgs = {
|
|
|
10
10
|
xpub: string;
|
|
11
11
|
buyAssetTradeFeeUsd: string;
|
|
12
12
|
};
|
|
13
|
-
declare type
|
|
13
|
+
declare type GetThorTxInfoReturn = Promise<{
|
|
14
14
|
opReturnData: string;
|
|
15
15
|
vault: string;
|
|
16
16
|
pubkey: string;
|
|
17
17
|
}>;
|
|
18
|
-
declare type
|
|
19
|
-
export declare const getThorTxInfo:
|
|
18
|
+
declare type GetThorTxInfo = (args: GetThorTxInfoArgs) => GetThorTxInfoReturn;
|
|
19
|
+
export declare const getThorTxInfo: GetThorTxInfo;
|
|
20
20
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getThorTxInfo = void 0;
|
|
4
|
-
const api_1 = require("
|
|
5
|
-
const getInboundAddressDataForChain_1 = require("../../getInboundAddressDataForChain");
|
|
6
|
-
const getLimit_1 = require("../../getLimit/getLimit");
|
|
7
|
-
const makeSwapMemo_1 = require("../../makeSwapMemo/makeSwapMemo");
|
|
4
|
+
const api_1 = require("../../../../api");
|
|
5
|
+
const getInboundAddressDataForChain_1 = require("../../utils/getInboundAddressDataForChain");
|
|
6
|
+
const getLimit_1 = require("../../utils/getLimit/getLimit");
|
|
7
|
+
const makeSwapMemo_1 = require("../../utils/makeSwapMemo/makeSwapMemo");
|
|
8
8
|
const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmountCryptoBaseUnit, slippageTolerance, destinationAddress, xpub, buyAssetTradeFeeUsd, }) => {
|
|
9
9
|
try {
|
|
10
10
|
const inboundAddress = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellAsset.assetId, false);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
|
+
import { EvmChainAdapter, EvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
2
3
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
4
|
import Web3 from 'web3';
|
|
4
5
|
import { AbiItem } from 'web3-utils';
|
|
5
|
-
import {
|
|
6
|
+
import { TradeQuote } from '../../../api';
|
|
6
7
|
import { BN } from '../bignumber';
|
|
7
8
|
export declare type IsApprovalRequiredArgs = {
|
|
8
|
-
adapter:
|
|
9
|
+
adapter: EvmChainAdapter;
|
|
9
10
|
receiveAddress: string;
|
|
10
11
|
allowanceContract: string;
|
|
11
12
|
sellAsset: Asset;
|
|
@@ -25,16 +26,16 @@ export declare type GetApproveContractDataArgs = {
|
|
|
25
26
|
spenderAddress: string;
|
|
26
27
|
contractAddress: string;
|
|
27
28
|
};
|
|
28
|
-
declare type GrantAllowanceArgs<T extends
|
|
29
|
+
declare type GrantAllowanceArgs<T extends EvmChainId> = {
|
|
29
30
|
quote: TradeQuote<T>;
|
|
30
31
|
wallet: HDWallet;
|
|
31
|
-
adapter:
|
|
32
|
+
adapter: EvmChainAdapter;
|
|
32
33
|
erc20Abi: AbiItem[];
|
|
33
34
|
web3: Web3;
|
|
34
35
|
};
|
|
35
36
|
export declare const getERC20Allowance: ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress, }: GetERC20AllowanceArgs) => Promise<any>;
|
|
36
37
|
export declare const isApprovalRequired: ({ adapter, receiveAddress, allowanceContract, sellAsset, sellAmountExcludeFeeCryptoBaseUnit, web3, erc20AllowanceAbi, }: IsApprovalRequiredArgs) => Promise<boolean>;
|
|
37
|
-
export declare const grantAllowance: <T extends
|
|
38
|
+
export declare const grantAllowance: <T extends import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet>({ quote, wallet, adapter, erc20Abi, web3, }: GrantAllowanceArgs<T>) => Promise<string>;
|
|
38
39
|
/**
|
|
39
40
|
* This function keeps 17 significant digits, so even if we try to trade 1 Billion of an
|
|
40
41
|
* ETH or ERC20, we still keep 7 decimal places.
|
|
@@ -17,7 +17,7 @@ export declare const setupBuildTrade: () => {
|
|
|
17
17
|
receiveAddress: string;
|
|
18
18
|
accountNumber: number;
|
|
19
19
|
} & {
|
|
20
|
-
chainId:
|
|
20
|
+
chainId: KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet;
|
|
21
21
|
} & {
|
|
22
22
|
slippage?: string | undefined;
|
|
23
23
|
wallet: HDWallet;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import {
|
|
3
|
+
import { avalanche, ethereum, optimism } from '@shapeshiftoss/chain-adapters';
|
|
4
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
5
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveAmountInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, GetEvmTradeQuoteInput, Swapper, SwapperName, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
6
|
import { ZrxExecuteTradeInput, ZrxSwapperDeps, ZrxTrade } from './types';
|
|
5
|
-
export declare
|
|
7
|
+
export declare type ZrxSupportedChainId = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet;
|
|
8
|
+
export declare type ZrxSupportedChainAdapter = ethereum.ChainAdapter | avalanche.ChainAdapter | optimism.ChainAdapter;
|
|
9
|
+
export declare class ZrxSwapper<T extends ZrxSupportedChainId> implements Swapper<T> {
|
|
6
10
|
readonly name = SwapperName.Zrx;
|
|
7
11
|
deps: ZrxSwapperDeps;
|
|
8
12
|
chainId: ChainId;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GetEvmTradeQuoteInput, TradeQuote } from '../../../api';
|
|
2
|
+
import { ZrxSupportedChainId } from '../ZrxSwapper';
|
|
3
|
+
export declare function getZrxTradeQuote<T extends ZrxSupportedChainId>(input: GetEvmTradeQuoteInput): Promise<TradeQuote<T>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
2
2
|
import type Web3 from 'web3';
|
|
3
|
-
import {
|
|
3
|
+
import { SwapSource, Trade } from '../../api';
|
|
4
|
+
import { ZrxSupportedChainAdapter, ZrxSupportedChainId } from './ZrxSwapper';
|
|
4
5
|
export declare type ZrxCommonResponse = {
|
|
5
6
|
price: string;
|
|
6
7
|
gasPrice: string;
|
|
@@ -17,15 +18,15 @@ export declare type ZrxQuoteResponse = ZrxCommonResponse & {
|
|
|
17
18
|
data: string;
|
|
18
19
|
gas: string;
|
|
19
20
|
};
|
|
20
|
-
export interface ZrxTrade<T extends
|
|
21
|
+
export interface ZrxTrade<T extends ZrxSupportedChainId> extends Trade<T> {
|
|
21
22
|
txData: string;
|
|
22
23
|
depositAddress: string;
|
|
23
24
|
}
|
|
24
|
-
export declare type ZrxExecuteTradeInput<T extends
|
|
25
|
+
export declare type ZrxExecuteTradeInput<T extends ZrxSupportedChainId> = {
|
|
25
26
|
trade: ZrxTrade<T>;
|
|
26
27
|
wallet: HDWallet;
|
|
27
28
|
};
|
|
28
29
|
export declare type ZrxSwapperDeps = {
|
|
29
|
-
adapter:
|
|
30
|
+
adapter: ZrxSupportedChainAdapter;
|
|
30
31
|
web3: Web3;
|
|
31
32
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { ApprovalNeededInput, ApprovalNeededOutput
|
|
1
|
+
import { ApprovalNeededInput, ApprovalNeededOutput } from '../../../api';
|
|
2
2
|
import { ZrxSwapperDeps } from '../types';
|
|
3
|
-
|
|
3
|
+
import { ZrxSupportedChainId } from '../ZrxSwapper';
|
|
4
|
+
export declare function zrxApprovalNeeded<T extends ZrxSupportedChainId>({ adapter, web3 }: ZrxSwapperDeps, { quote, wallet }: ApprovalNeededInput<T>): Promise<ApprovalNeededOutput>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApproveAmountInput, ApproveInfiniteInput
|
|
1
|
+
import { ApproveAmountInput, ApproveInfiniteInput } from '../../../api';
|
|
2
2
|
import { ZrxSwapperDeps } from '../types';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
3
|
+
import { ZrxSupportedChainId } from '../ZrxSwapper';
|
|
4
|
+
export declare function zrxApproveAmount<T extends ZrxSupportedChainId>(deps: ZrxSwapperDeps, args: ApproveAmountInput<T>): Promise<string>;
|
|
5
|
+
export declare function zrxApproveInfinite<T extends ZrxSupportedChainId>(deps: ZrxSwapperDeps, args: ApproveInfiniteInput<T>): Promise<string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { BuildTradeInput
|
|
1
|
+
import { BuildTradeInput } from '../../../api';
|
|
2
2
|
import { ZrxSwapperDeps, ZrxTrade } from '../types';
|
|
3
|
-
|
|
3
|
+
import { ZrxSupportedChainId } from '../ZrxSwapper';
|
|
4
|
+
export declare function zrxBuildTrade<T extends ZrxSupportedChainId>({ adapter, web3 }: ZrxSwapperDeps, input: BuildTradeInput): Promise<ZrxTrade<T>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TradeResult } from '../../../api';
|
|
2
2
|
import { ZrxExecuteTradeInput, ZrxSwapperDeps } from '../types';
|
|
3
|
-
|
|
3
|
+
import { ZrxSupportedChainId } from '../ZrxSwapper';
|
|
4
|
+
export declare function zrxExecuteTrade<T extends ZrxSupportedChainId>({ adapter }: ZrxSwapperDeps, { trade, wallet }: ZrxExecuteTradeInput<T>): Promise<TradeResult>;
|
package/package.json
CHANGED