@shapeshiftoss/swapper 15.6.0 → 15.8.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 +4 -3
- package/dist/api.js +1 -0
- package/dist/manager/testData.d.ts +1 -0
- package/dist/manager/testData.js +9 -1
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +1 -1
- package/dist/swappers/thorchain/types.d.ts +1 -1
- package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.js +1 -1
- package/dist/swappers/utils/test-data/assets.d.ts +1 -0
- package/dist/swappers/utils/test-data/assets.js +16 -1
- package/dist/swappers/zrx/ZrxSwapper.d.ts +1 -1
- package/dist/swappers/zrx/ZrxSwapper.js +2 -0
- package/dist/swappers/zrx/utils/helpers/helpers.js +8 -4
- 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 { avalanche, cosmos, ethereum, osmosis } from '@shapeshiftoss/chain-adapters';
|
|
3
|
+
import { avalanche, cosmos, ethereum, optimism, osmosis } 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: {
|
|
@@ -91,9 +91,9 @@ declare type CommonTradeInput = {
|
|
|
91
91
|
receiveAddress: string;
|
|
92
92
|
accountNumber: number;
|
|
93
93
|
};
|
|
94
|
-
export declare type EvmSupportedChainIds = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
94
|
+
export declare type EvmSupportedChainIds = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet;
|
|
95
95
|
export declare type CosmosSdkSupportedChainIds = KnownChainIds.CosmosMainnet | KnownChainIds.OsmosisMainnet | KnownChainIds.ThorchainMainnet;
|
|
96
|
-
export declare type EvmSupportedChainAdapter = ethereum.ChainAdapter | avalanche.ChainAdapter;
|
|
96
|
+
export declare type EvmSupportedChainAdapter = ethereum.ChainAdapter | avalanche.ChainAdapter | optimism.ChainAdapter;
|
|
97
97
|
export declare type CosmosSdkSupportedChainAdapters = cosmos.ChainAdapter | osmosis.ChainAdapter;
|
|
98
98
|
export declare type UtxoSupportedChainIds = KnownChainIds.BitcoinMainnet | KnownChainIds.DogecoinMainnet | KnownChainIds.LitecoinMainnet | KnownChainIds.BitcoinCashMainnet;
|
|
99
99
|
export declare type GetEvmTradeQuoteInput = CommonTradeInput & {
|
|
@@ -174,6 +174,7 @@ export declare enum SwapperName {
|
|
|
174
174
|
export declare enum SwapperType {
|
|
175
175
|
ZrxEthereum = "0xEthereum",
|
|
176
176
|
ZrxAvalanche = "0xAvalanche",
|
|
177
|
+
ZrxOptimism = "0xOptimism",
|
|
177
178
|
Thorchain = "Thorchain",
|
|
178
179
|
Osmosis = "Osmosis",
|
|
179
180
|
CowSwap = "CoW Swap",
|
package/dist/api.js
CHANGED
|
@@ -16,6 +16,7 @@ var SwapperType;
|
|
|
16
16
|
(function (SwapperType) {
|
|
17
17
|
SwapperType["ZrxEthereum"] = "0xEthereum";
|
|
18
18
|
SwapperType["ZrxAvalanche"] = "0xAvalanche";
|
|
19
|
+
SwapperType["ZrxOptimism"] = "0xOptimism";
|
|
19
20
|
SwapperType["Thorchain"] = "Thorchain";
|
|
20
21
|
SwapperType["Osmosis"] = "Osmosis";
|
|
21
22
|
SwapperType["CowSwap"] = "CoW Swap";
|
|
@@ -3,6 +3,7 @@ import { TradeQuote } from '../api';
|
|
|
3
3
|
import { CowSwapper, ThorchainSwapper, ZrxSwapper } from '../swappers';
|
|
4
4
|
export declare const getZrxEthereumSwapper: () => ZrxSwapper<import("../api").EvmSupportedChainIds>;
|
|
5
5
|
export declare const getZrxAvalancheSwapper: () => ZrxSwapper<import("../api").EvmSupportedChainIds>;
|
|
6
|
+
export declare const getZrxOptimismSwapper: () => ZrxSwapper<import("../api").EvmSupportedChainIds>;
|
|
6
7
|
export declare const getCowSwapper: () => CowSwapper;
|
|
7
8
|
export declare const getThorchainSwapper: () => ThorchainSwapper;
|
|
8
9
|
export declare const tradeQuote: TradeQuote<KnownChainIds.EthereumMainnet>;
|
package/dist/manager/testData.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.badTradeQuote = exports.goodTradeQuote = exports.tradeQuote = exports.getThorchainSwapper = exports.getCowSwapper = exports.getZrxAvalancheSwapper = exports.getZrxEthereumSwapper = void 0;
|
|
3
|
+
exports.badTradeQuote = exports.goodTradeQuote = exports.tradeQuote = exports.getThorchainSwapper = exports.getCowSwapper = exports.getZrxOptimismSwapper = exports.getZrxAvalancheSwapper = exports.getZrxEthereumSwapper = void 0;
|
|
4
4
|
const types_1 = require("@shapeshiftoss/types");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const swappers_1 = require("../swappers");
|
|
@@ -21,6 +21,14 @@ const zrxAvalancheSwapperDeps = {
|
|
|
21
21
|
};
|
|
22
22
|
const getZrxAvalancheSwapper = () => new swappers_1.ZrxSwapper(zrxAvalancheSwapperDeps);
|
|
23
23
|
exports.getZrxAvalancheSwapper = getZrxAvalancheSwapper;
|
|
24
|
+
const zrxOptimismSwapperDeps = {
|
|
25
|
+
web3: {},
|
|
26
|
+
adapter: {
|
|
27
|
+
getChainId: () => types_1.KnownChainIds.OptimismMainnet,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const getZrxOptimismSwapper = () => new swappers_1.ZrxSwapper(zrxOptimismSwapperDeps);
|
|
31
|
+
exports.getZrxOptimismSwapper = getZrxOptimismSwapper;
|
|
24
32
|
const cowSwapperDeps = {
|
|
25
33
|
apiUrl: 'https://api.cow.fi/mainnet/api/',
|
|
26
34
|
adapter: {
|
|
@@ -71,7 +71,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
71
71
|
case caip_1.CHAIN_NAMESPACE.Evm:
|
|
72
72
|
return (async () => {
|
|
73
73
|
const sellChainFeeAssetId = sellAdapter.getFeeAssetId();
|
|
74
|
-
const evmAddressData = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellChainFeeAssetId);
|
|
74
|
+
const evmAddressData = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellChainFeeAssetId, false);
|
|
75
75
|
const router = evmAddressData === null || evmAddressData === void 0 ? void 0 : evmAddressData.router;
|
|
76
76
|
if (!router)
|
|
77
77
|
throw new api_1.SwapError(`[getThorTradeQuote] No router address found for ${sellChainFeeAssetId}`);
|
|
@@ -62,7 +62,7 @@ export interface BtcThorTrade<C extends ChainId> extends Trade<C> {
|
|
|
62
62
|
txData: BTCSignTx;
|
|
63
63
|
}
|
|
64
64
|
export interface EvmThorTrade<C extends ChainId> extends Trade<C> {
|
|
65
|
-
chainId: KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
65
|
+
chainId: KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet;
|
|
66
66
|
txData: ETHSignTx;
|
|
67
67
|
}
|
|
68
68
|
export interface CosmosThorTrade<C extends ChainId> extends Trade<C> {
|
|
@@ -7,7 +7,7 @@ const getLimit_1 = require("../../getLimit/getLimit");
|
|
|
7
7
|
const makeSwapMemo_1 = require("../../makeSwapMemo/makeSwapMemo");
|
|
8
8
|
const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmountCryptoBaseUnit, slippageTolerance, destinationAddress, xpub, buyAssetTradeFeeUsd, }) => {
|
|
9
9
|
try {
|
|
10
|
-
const inboundAddress = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellAsset.assetId);
|
|
10
|
+
const inboundAddress = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellAsset.assetId, false);
|
|
11
11
|
const vault = inboundAddress === null || inboundAddress === void 0 ? void 0 : inboundAddress.address;
|
|
12
12
|
if (!vault)
|
|
13
13
|
throw new api_1.SwapError(`[getThorTxInfo]: vault not found for asset`, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RUNE = exports.AVAX = exports.USDC = exports.UNSUPPORTED = exports.ETH = exports.WBTC = exports.FOX = exports.WETH = exports.BTC = void 0;
|
|
3
|
+
exports.RUNE = exports.OPTIMISM = exports.AVAX = exports.USDC = exports.UNSUPPORTED = exports.ETH = exports.WBTC = exports.FOX = exports.WETH = exports.BTC = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
exports.BTC = {
|
|
6
6
|
assetId: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
|
@@ -98,6 +98,21 @@ exports.AVAX = {
|
|
|
98
98
|
explorerAddressLink: 'https://snowtrace.io/address/',
|
|
99
99
|
explorerTxLink: 'https://snowtrace.io/tx/',
|
|
100
100
|
};
|
|
101
|
+
exports.OPTIMISM = {
|
|
102
|
+
assetId: caip_1.optimismAssetId,
|
|
103
|
+
chainId: caip_1.optimismChainId,
|
|
104
|
+
name: 'Ethereum',
|
|
105
|
+
networkName: 'Optimism',
|
|
106
|
+
symbol: 'ETH',
|
|
107
|
+
precision: 18,
|
|
108
|
+
color: '#5C6BC0',
|
|
109
|
+
networkColor: '#FC0424',
|
|
110
|
+
icon: 'https://assets.coincap.io/assets/icons/256/eth.png',
|
|
111
|
+
networkIcon: 'https://assets.coingecko.com/coins/images/25244/thumb/Optimism.png?1660904599',
|
|
112
|
+
explorer: 'https://optimistic.etherscan.io',
|
|
113
|
+
explorerAddressLink: 'https://optimistic.etherscan.io/address/',
|
|
114
|
+
explorerTxLink: 'https://optimistic.etherscan.io/tx/',
|
|
115
|
+
};
|
|
101
116
|
exports.RUNE = {
|
|
102
117
|
assetId: caip_1.thorchainAssetId,
|
|
103
118
|
chainId: caip_1.thorchainChainId,
|
|
@@ -7,7 +7,7 @@ export declare class ZrxSwapper<T extends EvmSupportedChainIds> implements Swapp
|
|
|
7
7
|
deps: ZrxSwapperDeps;
|
|
8
8
|
chainId: ChainId;
|
|
9
9
|
constructor(deps: ZrxSwapperDeps);
|
|
10
|
-
getType(): SwapperType.ZrxEthereum | SwapperType.ZrxAvalanche;
|
|
10
|
+
getType(): SwapperType.ZrxEthereum | SwapperType.ZrxAvalanche | SwapperType.ZrxOptimism;
|
|
11
11
|
buildTrade(args: BuildTradeInput): Promise<ZrxTrade<T>>;
|
|
12
12
|
getTradeQuote(input: GetEvmTradeQuoteInput): Promise<TradeQuote<T>>;
|
|
13
13
|
getUsdRate(input: Asset): Promise<string>;
|
|
@@ -23,6 +23,8 @@ class ZrxSwapper {
|
|
|
23
23
|
return api_1.SwapperType.ZrxEthereum;
|
|
24
24
|
case types_1.KnownChainIds.AvalancheMainnet:
|
|
25
25
|
return api_1.SwapperType.ZrxAvalanche;
|
|
26
|
+
case types_1.KnownChainIds.OptimismMainnet:
|
|
27
|
+
return api_1.SwapperType.ZrxOptimism;
|
|
26
28
|
default:
|
|
27
29
|
throw new api_1.SwapError('[getType]', {
|
|
28
30
|
code: api_1.SwapErrorType.UNSUPPORTED_CHAIN,
|
|
@@ -8,11 +8,12 @@ const bignumber_1 = require("../../../utils/bignumber");
|
|
|
8
8
|
const zrxService_1 = require("../zrxService");
|
|
9
9
|
const baseUrlFromChainId = (chainId) => {
|
|
10
10
|
switch (chainId) {
|
|
11
|
-
case types_1.KnownChainIds.EthereumMainnet:
|
|
11
|
+
case types_1.KnownChainIds.EthereumMainnet:
|
|
12
12
|
return 'https://api.0x.org/';
|
|
13
|
-
}
|
|
14
13
|
case types_1.KnownChainIds.AvalancheMainnet:
|
|
15
14
|
return 'https://avalanche.api.0x.org/';
|
|
15
|
+
case types_1.KnownChainIds.OptimismMainnet:
|
|
16
|
+
return 'https://optimism.api.0x.org/';
|
|
16
17
|
default:
|
|
17
18
|
throw new api_1.SwapError(`baseUrlFromChainId] - Unsupported chainId: ${chainId}`, {
|
|
18
19
|
code: api_1.SwapErrorType.UNSUPPORTED_CHAIN,
|
|
@@ -22,11 +23,12 @@ const baseUrlFromChainId = (chainId) => {
|
|
|
22
23
|
exports.baseUrlFromChainId = baseUrlFromChainId;
|
|
23
24
|
const usdcContractFromChainId = (chainId) => {
|
|
24
25
|
switch (chainId) {
|
|
25
|
-
case types_1.KnownChainIds.EthereumMainnet:
|
|
26
|
+
case types_1.KnownChainIds.EthereumMainnet:
|
|
26
27
|
return '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
|
|
27
|
-
}
|
|
28
28
|
case types_1.KnownChainIds.AvalancheMainnet:
|
|
29
29
|
return '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e';
|
|
30
|
+
case types_1.KnownChainIds.OptimismMainnet:
|
|
31
|
+
return '0x7f5c764cbc14f9669b88837ca1490cca17c31607';
|
|
30
32
|
default:
|
|
31
33
|
throw new api_1.SwapError(`usdcContractFromChainId] - Unsupported chainId: ${chainId}`, {
|
|
32
34
|
code: api_1.SwapErrorType.UNSUPPORTED_CHAIN,
|
|
@@ -41,6 +43,8 @@ const isNativeEvmAsset = (assetId) => {
|
|
|
41
43
|
return assetId === caip_1.ethAssetId;
|
|
42
44
|
case types_1.KnownChainIds.AvalancheMainnet:
|
|
43
45
|
return assetId === caip_1.avalancheAssetId;
|
|
46
|
+
case types_1.KnownChainIds.OptimismMainnet:
|
|
47
|
+
return assetId === caip_1.optimismAssetId;
|
|
44
48
|
default:
|
|
45
49
|
return false;
|
|
46
50
|
}
|
package/package.json
CHANGED