@shapeshiftoss/swapper 20.1.0 → 20.2.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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +1 -2
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +4 -7
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopSolanaTradeContext.js +0 -1
- package/dist/cjs/swappers/ButterSwap/ButterSwap.js +0 -3
- package/dist/cjs/swappers/ButterSwap/endpoints.js +0 -3
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.test.js +0 -51
- package/dist/cjs/swappers/ButterSwap/types.d.ts +3 -3
- package/dist/cjs/swappers/ButterSwap/utils/getButterSwapStepData.js +0 -51
- package/dist/cjs/swappers/ButterSwap/utils/getButterSwapStepData.test.js +0 -61
- package/dist/cjs/swappers/ButterSwap/utils/helpers.js +0 -2
- package/dist/cjs/swappers/ZrxSwapper/utils/fetchFromZrx.js +1 -1
- package/dist/cjs/utils/helpers.js +3 -0
- package/dist/cjs/utils/helpers.test.js +3 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +1 -2
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +4 -7
- package/dist/esm/swappers/BebopSwapper/utils/getBebopSolanaTradeContext.js +0 -1
- package/dist/esm/swappers/ButterSwap/ButterSwap.js +0 -3
- package/dist/esm/swappers/ButterSwap/endpoints.js +0 -3
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.test.js +1 -49
- package/dist/esm/swappers/ButterSwap/types.d.ts +3 -3
- package/dist/esm/swappers/ButterSwap/utils/getButterSwapStepData.js +0 -51
- package/dist/esm/swappers/ButterSwap/utils/getButterSwapStepData.test.js +1 -62
- package/dist/esm/swappers/ButterSwap/utils/helpers.js +1 -3
- package/dist/esm/swappers/ZrxSwapper/utils/fetchFromZrx.js +1 -1
- package/dist/esm/utils/helpers.js +4 -1
- package/dist/esm/utils/helpers.test.js +3 -0
- package/package.json +6 -6
- package/dist/cjs/swappers/ButterSwap/test-data/eth-btc.json +0 -461
- package/dist/esm/swappers/ButterSwap/test-data/eth-btc.json +0 -461
|
@@ -13,13 +13,12 @@ export declare const fetchBebopQuote: ({ buyAsset, sellAsset, sellAmountIncludin
|
|
|
13
13
|
affiliateBps?: string | undefined;
|
|
14
14
|
apiKey: string;
|
|
15
15
|
}) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
|
|
16
|
-
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal,
|
|
16
|
+
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, apiKey, }: {
|
|
17
17
|
buyAsset: Asset;
|
|
18
18
|
sellAsset: Asset;
|
|
19
19
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
20
20
|
takerAddress: string;
|
|
21
21
|
receiverAddress: string;
|
|
22
22
|
slippageTolerancePercentageDecimal: string;
|
|
23
|
-
affiliateBps?: string | undefined;
|
|
24
23
|
apiKey: string;
|
|
25
24
|
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
@@ -30,16 +30,15 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
|
|
|
30
30
|
approval_type: 'Standard',
|
|
31
31
|
skip_validation: 'true',
|
|
32
32
|
gasless: 'false',
|
|
33
|
+
// PMM fees are configured against our api key on Bebop's side, not sent per quote
|
|
33
34
|
source: 'shapeshift',
|
|
34
35
|
};
|
|
35
36
|
const jamParams = new URLSearchParams(baseParams);
|
|
36
37
|
const pmmParams = new URLSearchParams(baseParams);
|
|
38
|
+
// JAM settles the fee on-chain, so it still takes our bps and a recipient per quote
|
|
37
39
|
if (affiliateBps && affiliateBps !== '0') {
|
|
38
|
-
// JAM collects the fee on-chain and requires a recipient
|
|
39
40
|
jamParams.set('fee', affiliateBps);
|
|
40
41
|
jamParams.set('fee_recipient', (0, viem_1.getAddress)((0, helpers_1.getTreasuryAddressFromChainId)(buyAsset.chainId)));
|
|
41
|
-
// PMM attributes the fee off-chain via source
|
|
42
|
-
pmmParams.set('fee', affiliateBps);
|
|
43
42
|
}
|
|
44
43
|
const service = (0, bebopService_1.bebopServiceFactory)({ apiKey });
|
|
45
44
|
const [maybeJam, maybePmm] = await Promise.all([
|
|
@@ -81,7 +80,7 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
|
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
exports.fetchBebopQuote = fetchBebopQuote;
|
|
84
|
-
const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal,
|
|
83
|
+
const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, apiKey, }) => {
|
|
85
84
|
try {
|
|
86
85
|
// Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
|
|
87
86
|
// always fails on-chain. Reject up front instead of returning an unexecutable quote.
|
|
@@ -105,11 +104,9 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
|
|
|
105
104
|
approval_type: 'Standard',
|
|
106
105
|
skip_validation: 'false',
|
|
107
106
|
gasless: 'true',
|
|
107
|
+
// Solana is PMM only, so its fees are configured against our api key on Bebop's side
|
|
108
108
|
source: 'shapeshift',
|
|
109
109
|
});
|
|
110
|
-
if (affiliateBps && affiliateBps !== '0') {
|
|
111
|
-
params.set('fee', affiliateBps);
|
|
112
|
-
}
|
|
113
110
|
const maybeResponse = await (0, bebopService_1.bebopServiceFactory)({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
|
|
114
111
|
if (maybeResponse.isErr()) {
|
|
115
112
|
const err = maybeResponse.unwrapErr();
|
|
@@ -22,7 +22,6 @@ const getBebopSolanaTradeContext = async ({ input, deps, takerAddress, receiverA
|
|
|
22
22
|
takerAddress,
|
|
23
23
|
receiverAddress,
|
|
24
24
|
slippageTolerancePercentageDecimal,
|
|
25
|
-
affiliateBps,
|
|
26
25
|
apiKey: deps.config.VITE_BEBOP_API_KEY,
|
|
27
26
|
});
|
|
28
27
|
if (maybeBebopQuoteResponse.isErr())
|
|
@@ -6,7 +6,4 @@ exports.butterSwap = {
|
|
|
6
6
|
executeEvmTransaction: utils_1.executeEvmTransaction,
|
|
7
7
|
executeSolanaTransaction: utils_1.executeSolanaTransaction,
|
|
8
8
|
executeTronTransaction: utils_1.executeTronTransaction,
|
|
9
|
-
executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => {
|
|
10
|
-
return signAndBroadcastTransaction(txToSign);
|
|
11
|
-
},
|
|
12
9
|
};
|
|
@@ -5,7 +5,6 @@ const evm_1 = require("../../utils/evm");
|
|
|
5
5
|
const getSolanaTransactionFees_1 = require("../../utils/solana/getSolanaTransactionFees");
|
|
6
6
|
const getUnsignedSolanaTransaction_1 = require("../../utils/solana/getUnsignedSolanaTransaction");
|
|
7
7
|
const tron_1 = require("../../utils/tron");
|
|
8
|
-
const utxo_1 = require("../../utils/utxo");
|
|
9
8
|
const checkTradeStatus_1 = require("./swapperApi/checkTradeStatus");
|
|
10
9
|
const getTradeQuote_1 = require("./swapperApi/getTradeQuote");
|
|
11
10
|
const getTradeRate_1 = require("./swapperApi/getTradeRate");
|
|
@@ -15,8 +14,6 @@ exports.butterSwapApi = {
|
|
|
15
14
|
checkTradeStatus: checkTradeStatus_1.checkTradeStatus,
|
|
16
15
|
getEvmTransactionFees: evm_1.getEvmTransactionFees,
|
|
17
16
|
getUnsignedEvmTransaction: evm_1.getUnsignedEvmTransaction,
|
|
18
|
-
getUnsignedUtxoTransaction: utxo_1.getUnsignedUtxoTransaction,
|
|
19
|
-
getUtxoTransactionFees: utxo_1.getUtxoTransactionFees,
|
|
20
17
|
getUnsignedSolanaTransaction: getUnsignedSolanaTransaction_1.getUnsignedSolanaTransaction,
|
|
21
18
|
getSolanaTransactionFees: getSolanaTransactionFees_1.getSolanaTransactionFees,
|
|
22
19
|
getTronTransactionFees: tron_1.getTronTransactionFees,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const types_1 = require("@shapeshiftoss/types");
|
|
7
4
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
8
5
|
const monads_1 = require("@sniptt/monads");
|
|
9
6
|
const vitest_1 = require("vitest");
|
|
10
7
|
const assets_1 = require("../../../utils/test-data/assets");
|
|
11
|
-
const eth_btc_json_1 = __importDefault(require("../test-data/eth-btc.json"));
|
|
12
8
|
const routeQuote_1 = require("../test-data/routeQuote");
|
|
13
9
|
const butterSwapService_1 = require("../utils/butterSwapService");
|
|
14
10
|
const getTradeRate_1 = require("./getTradeRate");
|
|
@@ -64,51 +60,4 @@ const mockEvmChainAdapter = {
|
|
|
64
60
|
const tradeRate = result.unwrap();
|
|
65
61
|
(0, vitest_1.expect)(tradeRate[0].rate).toBe('2296.409699');
|
|
66
62
|
});
|
|
67
|
-
(0, vitest_1.it)('should return a correct trade rate and steps for a multi-hop ETH->BTC route', async () => {
|
|
68
|
-
const deps = {
|
|
69
|
-
assetsById: { [assets_1.ETH.assetId]: assets_1.ETH, [assets_1.BTC.assetId]: assets_1.BTC },
|
|
70
|
-
assertGetChainAdapter: () => vitest_1.vi.fn(),
|
|
71
|
-
assertGetEvmChainAdapter: () => mockEvmChainAdapter,
|
|
72
|
-
assertGetUtxoChainAdapter: () => vitest_1.vi.fn(),
|
|
73
|
-
assertGetCosmosSdkChainAdapter: () => vitest_1.vi.fn(),
|
|
74
|
-
assertGetSolanaChainAdapter: () => vitest_1.vi.fn(),
|
|
75
|
-
assertGetTronChainAdapter: () => vitest_1.vi.fn(),
|
|
76
|
-
assertGetSuiChainAdapter: () => vitest_1.vi.fn(),
|
|
77
|
-
assertGetNearChainAdapter: () => vitest_1.vi.fn(),
|
|
78
|
-
assertGetStarknetChainAdapter: () => vitest_1.vi.fn(),
|
|
79
|
-
assertGetTonChainAdapter: () => vitest_1.vi.fn(),
|
|
80
|
-
config: {
|
|
81
|
-
VITE_BUTTERSWAP_CLIENT_ID: 'test',
|
|
82
|
-
},
|
|
83
|
-
mixPanel: undefined,
|
|
84
|
-
fetchIsSmartContractAddressQuery: vitest_1.vi.fn(),
|
|
85
|
-
};
|
|
86
|
-
const input = {
|
|
87
|
-
sellAsset: assets_1.ETH,
|
|
88
|
-
buyAsset: assets_1.BTC,
|
|
89
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit: (0, utils_1.bn)(1).shiftedBy(18).toString(),
|
|
90
|
-
affiliateBps: '0',
|
|
91
|
-
allowMultiHop: true,
|
|
92
|
-
receiveAddress: '0x123',
|
|
93
|
-
accountNumber: undefined,
|
|
94
|
-
quoteOrRate: 'rate',
|
|
95
|
-
chainId: types_1.KnownChainIds.EthereumMainnet,
|
|
96
|
-
supportsEIP1559: false,
|
|
97
|
-
};
|
|
98
|
-
// Use the first route in the eth-btc.json data
|
|
99
|
-
vitest_1.vi.mocked(butterSwapService_1.butterService.get).mockResolvedValue((0, monads_1.Ok)({ data: eth_btc_json_1.default }));
|
|
100
|
-
const result = await (0, getTradeRate_1.getTradeRate)(input, deps);
|
|
101
|
-
(0, vitest_1.expect)(result.isOk()).toBe(true);
|
|
102
|
-
const tradeRate = result.unwrap()[0];
|
|
103
|
-
(0, vitest_1.expect)(tradeRate).toBeDefined();
|
|
104
|
-
// The expected rate is dstChain.totalAmountOut / srcChain.totalAmountIn
|
|
105
|
-
(0, vitest_1.expect)(tradeRate.rate).toBe('0.02284418');
|
|
106
|
-
// Should have a single step
|
|
107
|
-
(0, vitest_1.expect)(tradeRate.steps).toBeDefined();
|
|
108
|
-
(0, vitest_1.expect)(tradeRate.steps.length).toBe(1);
|
|
109
|
-
// The step should have the correct rate
|
|
110
|
-
(0, vitest_1.expect)(tradeRate.steps[0]?.rate).toBe('0.02284418');
|
|
111
|
-
// The buyAmountAfterFeesCryptoBaseUnit of the step should match the output in base units
|
|
112
|
-
(0, vitest_1.expect)(tradeRate.steps[0]?.buyAmountAfterFeesCryptoBaseUnit).toBe('2284418'); // 0.02284418 BTC in base units
|
|
113
|
-
});
|
|
114
63
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
|
-
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput
|
|
3
|
-
export type ButterSwapTradeQuoteInput = GetEvmTradeQuoteInput |
|
|
4
|
-
export type ButterSwapTradeRateInput = GetEvmTradeRateInput |
|
|
2
|
+
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput } from '../../types';
|
|
3
|
+
export type ButterSwapTradeQuoteInput = GetEvmTradeQuoteInput | GetSolanaTradeQuoteInput | GetTronTradeQuoteInput;
|
|
4
|
+
export type ButterSwapTradeRateInput = GetEvmTradeRateInput | GetSolanaTradeRateInput | GetTronTradeRateInput;
|
|
5
5
|
export type ButterSwapTransactionMetadata = {
|
|
6
6
|
to: string;
|
|
7
7
|
data: string;
|
|
@@ -10,7 +10,6 @@ const types_1 = require("../../../types");
|
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
11
|
const evm_1 = require("../../../utils/evm");
|
|
12
12
|
const solana_1 = require("../../../utils/solana");
|
|
13
|
-
const utxo_1 = require("../../../utils/utxo");
|
|
14
13
|
const helpers_1 = require("./helpers");
|
|
15
14
|
// Jupiter swap legs can consume more units than simulated when pool state moves between
|
|
16
15
|
// simulation and landing (CLMM tick crossings), 1.4 matches Jupiter's dynamicComputeUnitLimit margin
|
|
@@ -69,56 +68,6 @@ async function getButterSwapStepData(args) {
|
|
|
69
68
|
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getButterSwapStepData', error));
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
case caip_1.CHAIN_NAMESPACE.Utxo: {
|
|
73
|
-
const adapter = deps.assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
74
|
-
const pubkey = 'xpub' in input ? input.xpub : undefined;
|
|
75
|
-
if (args.type === 'rate') {
|
|
76
|
-
const networkFeeCryptoBaseUnit = await (async () => {
|
|
77
|
-
try {
|
|
78
|
-
const { networkFeeCryptoBaseUnit } = await (0, utxo_1.getUtxoNetworkFeeCryptoBaseUnit)({
|
|
79
|
-
adapter,
|
|
80
|
-
pubkey,
|
|
81
|
-
to: input.sendAddress ?? utxo_1.UTXO_PLACEHOLDER_ADDRESS,
|
|
82
|
-
value: sellAmountCryptoBaseUnit,
|
|
83
|
-
});
|
|
84
|
-
return networkFeeCryptoBaseUnit;
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
return (0, helpers_1.getProviderNetworkFeeCryptoBaseUnit)({ route, feeAsset });
|
|
88
|
-
}
|
|
89
|
-
})();
|
|
90
|
-
const stepData = { networkFeeCryptoBaseUnit };
|
|
91
|
-
return (0, monads_1.Ok)(stepData);
|
|
92
|
-
}
|
|
93
|
-
const { buildTx } = args;
|
|
94
|
-
// opReturnData routes the bridge for BTC deposits
|
|
95
|
-
if (!buildTx.memo) {
|
|
96
|
-
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
97
|
-
message: '[getButterSwapStepData] Missing memo (opReturnData)',
|
|
98
|
-
code: types_1.TradeQuoteError.InvalidResponse,
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
const transactionData = {
|
|
102
|
-
type: 'utxo',
|
|
103
|
-
to: buildTx.to,
|
|
104
|
-
opReturnData: buildTx.memo,
|
|
105
|
-
value: sellAmountCryptoBaseUnit,
|
|
106
|
-
};
|
|
107
|
-
try {
|
|
108
|
-
const { networkFeeCryptoBaseUnit } = await (0, utxo_1.getUtxoNetworkFeeCryptoBaseUnit)({
|
|
109
|
-
adapter,
|
|
110
|
-
pubkey,
|
|
111
|
-
to: transactionData.to,
|
|
112
|
-
value: transactionData.value,
|
|
113
|
-
opReturnData: transactionData.opReturnData,
|
|
114
|
-
});
|
|
115
|
-
const stepData = { transactionData, networkFeeCryptoBaseUnit };
|
|
116
|
-
return (0, monads_1.Ok)(stepData);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getButterSwapStepData', error));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
71
|
case caip_1.CHAIN_NAMESPACE.Solana: {
|
|
123
72
|
const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
124
73
|
if (args.type === 'rate') {
|
|
@@ -136,67 +136,6 @@ const evmQuoteInput = { supportsEIP1559: false };
|
|
|
136
136
|
(0, vitest_1.expect)(actual.unwrapErr().code).toBe(types_1.TradeQuoteError.NetworkFeeEstimationFailed);
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
|
-
(0, vitest_1.describe)('utxo', () => {
|
|
140
|
-
const utxoAdapter = {
|
|
141
|
-
getFeeData: () => Promise.resolve({ fast: { txFee: '4200' } }),
|
|
142
|
-
httpProvider: {
|
|
143
|
-
getNetworkFees: () => Promise.resolve({ fast: { satsPerKiloByte: 10000 } }),
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
(0, vitest_1.it)('estimates off the default vsize for a rate with no pubkey', async () => {
|
|
147
|
-
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
148
|
-
type: 'rate',
|
|
149
|
-
input: {},
|
|
150
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
151
|
-
route,
|
|
152
|
-
sellAsset: assets_1.BTC,
|
|
153
|
-
feeAsset: assets_1.BTC,
|
|
154
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
155
|
-
spenderAddress: '',
|
|
156
|
-
});
|
|
157
|
-
// 10 sats/byte * 200 vbyte default
|
|
158
|
-
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '2000' });
|
|
159
|
-
});
|
|
160
|
-
(0, vitest_1.it)('builds transaction data with the memo as op return data for a quote', async () => {
|
|
161
|
-
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
162
|
-
type: 'quote',
|
|
163
|
-
input: { xpub: 'zpub6qux' },
|
|
164
|
-
from: 'bc1qaddress',
|
|
165
|
-
buildTx: { ...evmBuildTx, to: 'bc1qbridge', memo: 'butter-memo' },
|
|
166
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
167
|
-
route,
|
|
168
|
-
sellAsset: assets_1.BTC,
|
|
169
|
-
feeAsset: assets_1.BTC,
|
|
170
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
171
|
-
spenderAddress: '',
|
|
172
|
-
});
|
|
173
|
-
(0, vitest_1.expect)(actual.unwrap()).toEqual({
|
|
174
|
-
networkFeeCryptoBaseUnit: '4200',
|
|
175
|
-
transactionData: {
|
|
176
|
-
type: 'utxo',
|
|
177
|
-
to: 'bc1qbridge',
|
|
178
|
-
opReturnData: 'butter-memo',
|
|
179
|
-
value: '100000',
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
(0, vitest_1.it)('errors when the quote is missing the memo the bridge routes on', async () => {
|
|
184
|
-
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
185
|
-
type: 'quote',
|
|
186
|
-
input: { xpub: 'zpub6qux' },
|
|
187
|
-
from: 'bc1qaddress',
|
|
188
|
-
buildTx: { ...evmBuildTx, to: 'bc1qbridge', memo: undefined },
|
|
189
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
190
|
-
route,
|
|
191
|
-
sellAsset: assets_1.BTC,
|
|
192
|
-
feeAsset: assets_1.BTC,
|
|
193
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
194
|
-
spenderAddress: '',
|
|
195
|
-
});
|
|
196
|
-
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
197
|
-
(0, vitest_1.expect)(actual.unwrapErr().code).toBe(types_1.TradeQuoteError.InvalidResponse);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
139
|
(0, vitest_1.describe)('solana', () => {
|
|
201
140
|
(0, vitest_1.it)('uses the provider fee for a rate, since swap instructions do not exist yet', async () => {
|
|
202
141
|
const assertGetSolanaChainAdapter = vitest_1.vi.fn();
|
|
@@ -20,7 +20,6 @@ const BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID = {
|
|
|
20
20
|
[chains_1.avalanche.id]: types_1.KnownChainIds.AvalancheMainnet,
|
|
21
21
|
[chains_1.robinhood.id]: types_1.KnownChainIds.RobinhoodMainnet,
|
|
22
22
|
1360108768460801: types_1.KnownChainIds.SolanaMainnet,
|
|
23
|
-
1360095883558913: types_1.KnownChainIds.BitcoinMainnet,
|
|
24
23
|
[chains_1.tron.id]: types_1.KnownChainIds.TronMainnet,
|
|
25
24
|
};
|
|
26
25
|
const CHAIN_ID_TO_BUTTERSWAP_CHAIN_ID = Object.entries(BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID).reduce((acc, [butterSwapChainId, chainId]) => {
|
|
@@ -37,7 +36,6 @@ const chainIdToButterSwapChainId = (chainId) => {
|
|
|
37
36
|
exports.chainIdToButterSwapChainId = chainIdToButterSwapChainId;
|
|
38
37
|
const assertValidTrade = ({ sellAsset, }) => {
|
|
39
38
|
if (!(0, chain_adapters_1.isEvmChainId)(sellAsset.chainId) &&
|
|
40
|
-
sellAsset.chainId !== caip_1.btcChainId &&
|
|
41
39
|
sellAsset.chainId !== caip_1.solanaChainId &&
|
|
42
40
|
sellAsset.chainId !== caip_1.tronChainId) {
|
|
43
41
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -30,7 +30,7 @@ const fetchFromZrx = async ({ quoteOrRate, buyAsset, sellAsset, sellAmountInclud
|
|
|
30
30
|
swapFeeToken: (0, helpers_2.assetIdToZrxToken)(buyAsset.assetId),
|
|
31
31
|
slippageBps: (0, utils_1.convertDecimalPercentageToBasisPoints)(slippageTolerancePercentageDecimal).toNumber(),
|
|
32
32
|
swapFeeRecipient: maybeTreasuryAddress,
|
|
33
|
-
|
|
33
|
+
tradeSurplusRecipient: maybeTreasuryAddress, // Where trade surplus is sent
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
if (maybeZrxPriceResponse.isErr()) {
|
|
@@ -68,6 +68,9 @@ const DAO_TREASURY_BY_CHAIN_ID = {
|
|
|
68
68
|
[types_1.KnownChainIds.MonadMainnet]: utils_1.DAO_TREASURY_MONAD,
|
|
69
69
|
[types_1.KnownChainIds.HyperEvmMainnet]: utils_1.DAO_TREASURY_HYPEREVM,
|
|
70
70
|
[types_1.KnownChainIds.BobMainnet]: utils_1.DAO_TREASURY_BOB,
|
|
71
|
+
[types_1.KnownChainIds.RobinhoodMainnet]: utils_1.DAO_TREASURY_ROBINHOOD,
|
|
72
|
+
[types_1.KnownChainIds.PlasmaMainnet]: utils_1.DAO_TREASURY_PLASMA,
|
|
73
|
+
[types_1.KnownChainIds.MegaEthMainnet]: utils_1.DAO_TREASURY_MEGAETH,
|
|
71
74
|
};
|
|
72
75
|
const getTreasuryAddressFromChainId = (chainId) => {
|
|
73
76
|
const maybeTreasuryChainId = (0, utils_1.isTreasuryChainId)(chainId) ? chainId : undefined;
|
|
@@ -22,6 +22,9 @@ const helpers_1 = require("./helpers");
|
|
|
22
22
|
[types_1.KnownChainIds.MonadMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
23
23
|
[types_1.KnownChainIds.HyperEvmMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
24
24
|
[types_1.KnownChainIds.BobMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
25
|
+
[types_1.KnownChainIds.RobinhoodMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
26
|
+
[types_1.KnownChainIds.PlasmaMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
27
|
+
[types_1.KnownChainIds.MegaEthMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
25
28
|
[types_1.KnownChainIds.BitcoinMainnet]: 'bc1q9xrjfet2a05r3jvsxx66rru7pysevk5dvqasdw9eeea3rfqlk33qr4hghh',
|
|
26
29
|
[types_1.KnownChainIds.SolanaMainnet]: 'FxXyPB5RH4uHLPPJR5H89zGwZp19juBetmRwrxfsLj2j',
|
|
27
30
|
[types_1.KnownChainIds.StarknetMainnet]: '0x07ac2252f2da7cbf085e7a5ddc1318243aa818607cdd430dd2e17dd5d487606a',
|