@shapeshiftoss/swapper 20.1.1 → 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/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/utils/helpers.js +4 -1
- package/dist/esm/utils/helpers.test.js +3 -0
- package/package.json +4 -4
- 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>>;
|
|
@@ -27,16 +27,15 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
|
|
|
27
27
|
approval_type: 'Standard',
|
|
28
28
|
skip_validation: 'true',
|
|
29
29
|
gasless: 'false',
|
|
30
|
+
// PMM fees are configured against our api key on Bebop's side, not sent per quote
|
|
30
31
|
source: 'shapeshift',
|
|
31
32
|
};
|
|
32
33
|
const jamParams = new URLSearchParams(baseParams);
|
|
33
34
|
const pmmParams = new URLSearchParams(baseParams);
|
|
35
|
+
// JAM settles the fee on-chain, so it still takes our bps and a recipient per quote
|
|
34
36
|
if (affiliateBps && affiliateBps !== '0') {
|
|
35
|
-
// JAM collects the fee on-chain and requires a recipient
|
|
36
37
|
jamParams.set('fee', affiliateBps);
|
|
37
38
|
jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)));
|
|
38
|
-
// PMM attributes the fee off-chain via source
|
|
39
|
-
pmmParams.set('fee', affiliateBps);
|
|
40
39
|
}
|
|
41
40
|
const service = bebopServiceFactory({ apiKey });
|
|
42
41
|
const [maybeJam, maybePmm] = await Promise.all([
|
|
@@ -77,7 +76,7 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
|
|
|
77
76
|
}));
|
|
78
77
|
}
|
|
79
78
|
};
|
|
80
|
-
export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal,
|
|
79
|
+
export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, apiKey, }) => {
|
|
81
80
|
try {
|
|
82
81
|
// Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
|
|
83
82
|
// always fails on-chain. Reject up front instead of returning an unexecutable quote.
|
|
@@ -101,11 +100,9 @@ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountInc
|
|
|
101
100
|
approval_type: 'Standard',
|
|
102
101
|
skip_validation: 'false',
|
|
103
102
|
gasless: 'true',
|
|
103
|
+
// Solana is PMM only, so its fees are configured against our api key on Bebop's side
|
|
104
104
|
source: 'shapeshift',
|
|
105
105
|
});
|
|
106
|
-
if (affiliateBps && affiliateBps !== '0') {
|
|
107
|
-
params.set('fee', affiliateBps);
|
|
108
|
-
}
|
|
109
106
|
const maybeResponse = await bebopServiceFactory({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
|
|
110
107
|
if (maybeResponse.isErr()) {
|
|
111
108
|
const err = maybeResponse.unwrapErr();
|
|
@@ -19,7 +19,6 @@ export const getBebopSolanaTradeContext = async ({ input, deps, takerAddress, re
|
|
|
19
19
|
takerAddress,
|
|
20
20
|
receiverAddress,
|
|
21
21
|
slippageTolerancePercentageDecimal,
|
|
22
|
-
affiliateBps,
|
|
23
22
|
apiKey: deps.config.VITE_BEBOP_API_KEY,
|
|
24
23
|
});
|
|
25
24
|
if (maybeBebopQuoteResponse.isErr())
|
|
@@ -2,7 +2,6 @@ import { getEvmTransactionFees, getUnsignedEvmTransaction } from '../../utils/ev
|
|
|
2
2
|
import { getSolanaTransactionFees } from '../../utils/solana/getSolanaTransactionFees.js';
|
|
3
3
|
import { getUnsignedSolanaTransaction } from '../../utils/solana/getUnsignedSolanaTransaction.js';
|
|
4
4
|
import { getTronTransactionFees, getUnsignedTronTransaction } from '../../utils/tron/index.js';
|
|
5
|
-
import { getUnsignedUtxoTransaction, getUtxoTransactionFees } from '../../utils/utxo/index.js';
|
|
6
5
|
import { checkTradeStatus } from './swapperApi/checkTradeStatus.js';
|
|
7
6
|
import { getTradeQuote } from './swapperApi/getTradeQuote.js';
|
|
8
7
|
import { getTradeRate } from './swapperApi/getTradeRate.js';
|
|
@@ -12,8 +11,6 @@ export const butterSwapApi = {
|
|
|
12
11
|
checkTradeStatus,
|
|
13
12
|
getEvmTransactionFees,
|
|
14
13
|
getUnsignedEvmTransaction,
|
|
15
|
-
getUnsignedUtxoTransaction,
|
|
16
|
-
getUtxoTransactionFees,
|
|
17
14
|
getUnsignedSolanaTransaction,
|
|
18
15
|
getSolanaTransactionFees,
|
|
19
16
|
getTronTransactionFees,
|
|
@@ -2,8 +2,7 @@ import { KnownChainIds } from '@shapeshiftoss/types';
|
|
|
2
2
|
import { bn } from '@shapeshiftoss/utils';
|
|
3
3
|
import { Ok } from '@sniptt/monads';
|
|
4
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
-
import {
|
|
6
|
-
import ethBtcRoute from '../test-data/eth-btc.json';
|
|
5
|
+
import { ETH, USDC_MAINNET, WETH } from '../../../utils/test-data/assets.js';
|
|
7
6
|
import { ROUTE_QUOTE } from '../test-data/routeQuote.js';
|
|
8
7
|
import { butterService } from '../utils/butterSwapService.js';
|
|
9
8
|
import { getTradeRate } from './getTradeRate.js';
|
|
@@ -59,51 +58,4 @@ describe('getTradeRate', () => {
|
|
|
59
58
|
const tradeRate = result.unwrap();
|
|
60
59
|
expect(tradeRate[0].rate).toBe('2296.409699');
|
|
61
60
|
});
|
|
62
|
-
it('should return a correct trade rate and steps for a multi-hop ETH->BTC route', async () => {
|
|
63
|
-
const deps = {
|
|
64
|
-
assetsById: { [ETH.assetId]: ETH, [BTC.assetId]: BTC },
|
|
65
|
-
assertGetChainAdapter: () => vi.fn(),
|
|
66
|
-
assertGetEvmChainAdapter: () => mockEvmChainAdapter,
|
|
67
|
-
assertGetUtxoChainAdapter: () => vi.fn(),
|
|
68
|
-
assertGetCosmosSdkChainAdapter: () => vi.fn(),
|
|
69
|
-
assertGetSolanaChainAdapter: () => vi.fn(),
|
|
70
|
-
assertGetTronChainAdapter: () => vi.fn(),
|
|
71
|
-
assertGetSuiChainAdapter: () => vi.fn(),
|
|
72
|
-
assertGetNearChainAdapter: () => vi.fn(),
|
|
73
|
-
assertGetStarknetChainAdapter: () => vi.fn(),
|
|
74
|
-
assertGetTonChainAdapter: () => vi.fn(),
|
|
75
|
-
config: {
|
|
76
|
-
VITE_BUTTERSWAP_CLIENT_ID: 'test',
|
|
77
|
-
},
|
|
78
|
-
mixPanel: undefined,
|
|
79
|
-
fetchIsSmartContractAddressQuery: vi.fn(),
|
|
80
|
-
};
|
|
81
|
-
const input = {
|
|
82
|
-
sellAsset: ETH,
|
|
83
|
-
buyAsset: BTC,
|
|
84
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit: bn(1).shiftedBy(18).toString(),
|
|
85
|
-
affiliateBps: '0',
|
|
86
|
-
allowMultiHop: true,
|
|
87
|
-
receiveAddress: '0x123',
|
|
88
|
-
accountNumber: undefined,
|
|
89
|
-
quoteOrRate: 'rate',
|
|
90
|
-
chainId: KnownChainIds.EthereumMainnet,
|
|
91
|
-
supportsEIP1559: false,
|
|
92
|
-
};
|
|
93
|
-
// Use the first route in the eth-btc.json data
|
|
94
|
-
vi.mocked(butterService.get).mockResolvedValue(Ok({ data: ethBtcRoute }));
|
|
95
|
-
const result = await getTradeRate(input, deps);
|
|
96
|
-
expect(result.isOk()).toBe(true);
|
|
97
|
-
const tradeRate = result.unwrap()[0];
|
|
98
|
-
expect(tradeRate).toBeDefined();
|
|
99
|
-
// The expected rate is dstChain.totalAmountOut / srcChain.totalAmountIn
|
|
100
|
-
expect(tradeRate.rate).toBe('0.02284418');
|
|
101
|
-
// Should have a single step
|
|
102
|
-
expect(tradeRate.steps).toBeDefined();
|
|
103
|
-
expect(tradeRate.steps.length).toBe(1);
|
|
104
|
-
// The step should have the correct rate
|
|
105
|
-
expect(tradeRate.steps[0]?.rate).toBe('0.02284418');
|
|
106
|
-
// The buyAmountAfterFeesCryptoBaseUnit of the step should match the output in base units
|
|
107
|
-
expect(tradeRate.steps[0]?.buyAmountAfterFeesCryptoBaseUnit).toBe('2284418'); // 0.02284418 BTC in base units
|
|
108
|
-
});
|
|
109
61
|
});
|
|
@@ -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.js';
|
|
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;
|
|
@@ -7,7 +7,6 @@ import { TradeQuoteError } from '../../../types.js';
|
|
|
7
7
|
import { makeNetworkFeeEstimationFailedErr, makeSwapErrorRight, makeTradeStepBuildFailedErr, } from '../../../utils/index.js';
|
|
8
8
|
import { getEvmNetworkFeeCryptoBaseUnit } from '../../../utils/evm/index.js';
|
|
9
9
|
import { getSolanaNetworkFeeCryptoBaseUnit, omitComputeBudgetInstructions, withComputeUnitLimit, } from '../../../utils/solana/index.js';
|
|
10
|
-
import { getUtxoNetworkFeeCryptoBaseUnit, UTXO_PLACEHOLDER_ADDRESS } from '../../../utils/utxo/index.js';
|
|
11
10
|
import { getProviderNetworkFeeCryptoBaseUnit } from './helpers.js';
|
|
12
11
|
// Jupiter swap legs can consume more units than simulated when pool state moves between
|
|
13
12
|
// simulation and landing (CLMM tick crossings), 1.4 matches Jupiter's dynamicComputeUnitLimit margin
|
|
@@ -66,56 +65,6 @@ export async function getButterSwapStepData(args) {
|
|
|
66
65
|
return Err(makeNetworkFeeEstimationFailedErr('getButterSwapStepData', error));
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
case CHAIN_NAMESPACE.Utxo: {
|
|
70
|
-
const adapter = deps.assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
71
|
-
const pubkey = 'xpub' in input ? input.xpub : undefined;
|
|
72
|
-
if (args.type === 'rate') {
|
|
73
|
-
const networkFeeCryptoBaseUnit = await (async () => {
|
|
74
|
-
try {
|
|
75
|
-
const { networkFeeCryptoBaseUnit } = await getUtxoNetworkFeeCryptoBaseUnit({
|
|
76
|
-
adapter,
|
|
77
|
-
pubkey,
|
|
78
|
-
to: input.sendAddress ?? UTXO_PLACEHOLDER_ADDRESS,
|
|
79
|
-
value: sellAmountCryptoBaseUnit,
|
|
80
|
-
});
|
|
81
|
-
return networkFeeCryptoBaseUnit;
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return getProviderNetworkFeeCryptoBaseUnit({ route, feeAsset });
|
|
85
|
-
}
|
|
86
|
-
})();
|
|
87
|
-
const stepData = { networkFeeCryptoBaseUnit };
|
|
88
|
-
return Ok(stepData);
|
|
89
|
-
}
|
|
90
|
-
const { buildTx } = args;
|
|
91
|
-
// opReturnData routes the bridge for BTC deposits
|
|
92
|
-
if (!buildTx.memo) {
|
|
93
|
-
return Err(makeSwapErrorRight({
|
|
94
|
-
message: '[getButterSwapStepData] Missing memo (opReturnData)',
|
|
95
|
-
code: TradeQuoteError.InvalidResponse,
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
const transactionData = {
|
|
99
|
-
type: 'utxo',
|
|
100
|
-
to: buildTx.to,
|
|
101
|
-
opReturnData: buildTx.memo,
|
|
102
|
-
value: sellAmountCryptoBaseUnit,
|
|
103
|
-
};
|
|
104
|
-
try {
|
|
105
|
-
const { networkFeeCryptoBaseUnit } = await getUtxoNetworkFeeCryptoBaseUnit({
|
|
106
|
-
adapter,
|
|
107
|
-
pubkey,
|
|
108
|
-
to: transactionData.to,
|
|
109
|
-
value: transactionData.value,
|
|
110
|
-
opReturnData: transactionData.opReturnData,
|
|
111
|
-
});
|
|
112
|
-
const stepData = { transactionData, networkFeeCryptoBaseUnit };
|
|
113
|
-
return Ok(stepData);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
return Err(makeNetworkFeeEstimationFailedErr('getButterSwapStepData', error));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
68
|
case CHAIN_NAMESPACE.Solana: {
|
|
120
69
|
const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
121
70
|
if (args.type === 'rate') {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { solanaChainId, tronChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
3
3
|
import { TradeQuoteError } from '../../../types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ETH, RUNE, WETH } from '../../../utils/test-data/assets.js';
|
|
5
5
|
import { ROUTE_QUOTE } from '../test-data/routeQuote.js';
|
|
6
6
|
import { getButterSwapStepData } from './getButterSwapStepData.js';
|
|
7
7
|
// The override path reads live chain state - resolve to no override so estimation exercises the
|
|
@@ -134,67 +134,6 @@ describe('getButterSwapStepData', () => {
|
|
|
134
134
|
expect(actual.unwrapErr().code).toBe(TradeQuoteError.NetworkFeeEstimationFailed);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
|
-
describe('utxo', () => {
|
|
138
|
-
const utxoAdapter = {
|
|
139
|
-
getFeeData: () => Promise.resolve({ fast: { txFee: '4200' } }),
|
|
140
|
-
httpProvider: {
|
|
141
|
-
getNetworkFees: () => Promise.resolve({ fast: { satsPerKiloByte: 10000 } }),
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
it('estimates off the default vsize for a rate with no pubkey', async () => {
|
|
145
|
-
const actual = await getButterSwapStepData({
|
|
146
|
-
type: 'rate',
|
|
147
|
-
input: {},
|
|
148
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
149
|
-
route,
|
|
150
|
-
sellAsset: BTC,
|
|
151
|
-
feeAsset: BTC,
|
|
152
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
153
|
-
spenderAddress: '',
|
|
154
|
-
});
|
|
155
|
-
// 10 sats/byte * 200 vbyte default
|
|
156
|
-
expect(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '2000' });
|
|
157
|
-
});
|
|
158
|
-
it('builds transaction data with the memo as op return data for a quote', async () => {
|
|
159
|
-
const actual = await getButterSwapStepData({
|
|
160
|
-
type: 'quote',
|
|
161
|
-
input: { xpub: 'zpub6qux' },
|
|
162
|
-
from: 'bc1qaddress',
|
|
163
|
-
buildTx: { ...evmBuildTx, to: 'bc1qbridge', memo: 'butter-memo' },
|
|
164
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
165
|
-
route,
|
|
166
|
-
sellAsset: BTC,
|
|
167
|
-
feeAsset: BTC,
|
|
168
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
169
|
-
spenderAddress: '',
|
|
170
|
-
});
|
|
171
|
-
expect(actual.unwrap()).toEqual({
|
|
172
|
-
networkFeeCryptoBaseUnit: '4200',
|
|
173
|
-
transactionData: {
|
|
174
|
-
type: 'utxo',
|
|
175
|
-
to: 'bc1qbridge',
|
|
176
|
-
opReturnData: 'butter-memo',
|
|
177
|
-
value: '100000',
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
it('errors when the quote is missing the memo the bridge routes on', async () => {
|
|
182
|
-
const actual = await getButterSwapStepData({
|
|
183
|
-
type: 'quote',
|
|
184
|
-
input: { xpub: 'zpub6qux' },
|
|
185
|
-
from: 'bc1qaddress',
|
|
186
|
-
buildTx: { ...evmBuildTx, to: 'bc1qbridge', memo: undefined },
|
|
187
|
-
deps: makeDeps({ utxo: utxoAdapter }),
|
|
188
|
-
route,
|
|
189
|
-
sellAsset: BTC,
|
|
190
|
-
feeAsset: BTC,
|
|
191
|
-
sellAmountCryptoBaseUnit: '100000',
|
|
192
|
-
spenderAddress: '',
|
|
193
|
-
});
|
|
194
|
-
expect(actual.isErr()).toBe(true);
|
|
195
|
-
expect(actual.unwrapErr().code).toBe(TradeQuoteError.InvalidResponse);
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
137
|
describe('solana', () => {
|
|
199
138
|
it('uses the provider fee for a rate, since swap instructions do not exist yet', async () => {
|
|
200
139
|
const assertGetSolanaChainAdapter = vi.fn();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { solanaChainId, tronChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
4
4
|
import { BigAmount, bnOrZero } from '@shapeshiftoss/utils';
|
|
@@ -17,7 +17,6 @@ const BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID = {
|
|
|
17
17
|
[avalanche.id]: KnownChainIds.AvalancheMainnet,
|
|
18
18
|
[robinhood.id]: KnownChainIds.RobinhoodMainnet,
|
|
19
19
|
1360108768460801: KnownChainIds.SolanaMainnet,
|
|
20
|
-
1360095883558913: KnownChainIds.BitcoinMainnet,
|
|
21
20
|
[tron.id]: KnownChainIds.TronMainnet,
|
|
22
21
|
};
|
|
23
22
|
const CHAIN_ID_TO_BUTTERSWAP_CHAIN_ID = Object.entries(BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID).reduce((acc, [butterSwapChainId, chainId]) => {
|
|
@@ -32,7 +31,6 @@ export const chainIdToButterSwapChainId = (chainId) => {
|
|
|
32
31
|
};
|
|
33
32
|
export const assertValidTrade = ({ sellAsset, }) => {
|
|
34
33
|
if (!isEvmChainId(sellAsset.chainId) &&
|
|
35
|
-
sellAsset.chainId !== btcChainId &&
|
|
36
34
|
sellAsset.chainId !== solanaChainId &&
|
|
37
35
|
sellAsset.chainId !== tronChainId) {
|
|
38
36
|
return Err(makeSwapErrorRight({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { arbitrumAssetId, avalancheAssetId, baseAssetId, bscAssetId, ethAssetId, fromAssetId, gnosisAssetId, katanaAssetId, monadAssetId, optimismAssetId, plasmaAssetId, polygonAssetId, } from '@shapeshiftoss/caip';
|
|
2
2
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
3
|
-
import { DAO_TREASURY_ARBITRUM, DAO_TREASURY_AVALANCHE, DAO_TREASURY_BASE, DAO_TREASURY_BITCOIN, DAO_TREASURY_BOB, DAO_TREASURY_BSC, DAO_TREASURY_ETHEREUM_MAINNET, DAO_TREASURY_GNOSIS, DAO_TREASURY_HYPEREVM, DAO_TREASURY_MONAD, DAO_TREASURY_OPTIMISM, DAO_TREASURY_POLYGON, DAO_TREASURY_SOLANA, DAO_TREASURY_STARKNET, DAO_TREASURY_TON, isTreasuryChainId, } from '@shapeshiftoss/utils';
|
|
3
|
+
import { DAO_TREASURY_ARBITRUM, DAO_TREASURY_AVALANCHE, DAO_TREASURY_BASE, DAO_TREASURY_BITCOIN, DAO_TREASURY_BOB, DAO_TREASURY_BSC, DAO_TREASURY_ETHEREUM_MAINNET, DAO_TREASURY_GNOSIS, DAO_TREASURY_HYPEREVM, DAO_TREASURY_MEGAETH, DAO_TREASURY_MONAD, DAO_TREASURY_OPTIMISM, DAO_TREASURY_PLASMA, DAO_TREASURY_POLYGON, DAO_TREASURY_ROBINHOOD, DAO_TREASURY_SOLANA, DAO_TREASURY_STARKNET, DAO_TREASURY_TON, isTreasuryChainId, } from '@shapeshiftoss/utils';
|
|
4
4
|
import { SwapperName } from '../types.js';
|
|
5
5
|
// Deadline for providers without their own expiry - short enough to keep priced amounts honest
|
|
6
6
|
export const FALLBACK_QUOTE_DEADLINE_MS = 60_000;
|
|
@@ -62,6 +62,9 @@ const DAO_TREASURY_BY_CHAIN_ID = {
|
|
|
62
62
|
[KnownChainIds.MonadMainnet]: DAO_TREASURY_MONAD,
|
|
63
63
|
[KnownChainIds.HyperEvmMainnet]: DAO_TREASURY_HYPEREVM,
|
|
64
64
|
[KnownChainIds.BobMainnet]: DAO_TREASURY_BOB,
|
|
65
|
+
[KnownChainIds.RobinhoodMainnet]: DAO_TREASURY_ROBINHOOD,
|
|
66
|
+
[KnownChainIds.PlasmaMainnet]: DAO_TREASURY_PLASMA,
|
|
67
|
+
[KnownChainIds.MegaEthMainnet]: DAO_TREASURY_MEGAETH,
|
|
65
68
|
};
|
|
66
69
|
export const getTreasuryAddressFromChainId = (chainId) => {
|
|
67
70
|
const maybeTreasuryChainId = isTreasuryChainId(chainId) ? chainId : undefined;
|
|
@@ -20,6 +20,9 @@ describe('getTreasuryAddressFromChainId', () => {
|
|
|
20
20
|
[KnownChainIds.MonadMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
21
21
|
[KnownChainIds.HyperEvmMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
22
22
|
[KnownChainIds.BobMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
23
|
+
[KnownChainIds.RobinhoodMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
24
|
+
[KnownChainIds.PlasmaMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
25
|
+
[KnownChainIds.MegaEthMainnet]: '0xF5AA59151bE6515C4Ca68A0282CF68B3eA4846fC',
|
|
23
26
|
[KnownChainIds.BitcoinMainnet]: 'bc1q9xrjfet2a05r3jvsxx66rru7pysevk5dvqasdw9eeea3rfqlk33qr4hghh',
|
|
24
27
|
[KnownChainIds.SolanaMainnet]: 'FxXyPB5RH4uHLPPJR5H89zGwZp19juBetmRwrxfsLj2j',
|
|
25
28
|
[KnownChainIds.StarknetMainnet]: '0x07ac2252f2da7cbf085e7a5ddc1318243aa818607cdd430dd2e17dd5d487606a',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.2.0",
|
|
4
4
|
"repository": "https://github.com/shapeshift/web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"@shapeshiftoss/caip": "^8.17.0",
|
|
54
54
|
"@shapeshiftoss/chain-adapters": "^11.5.1",
|
|
55
55
|
"@shapeshiftoss/contracts": "^1.0.7",
|
|
56
|
-
"@shapeshiftoss/
|
|
56
|
+
"@shapeshiftoss/hdwallet-core": "^1.62.41",
|
|
57
57
|
"@shapeshiftoss/types": "^9.0.1",
|
|
58
|
-
"@shapeshiftoss/
|
|
59
|
-
"@shapeshiftoss/
|
|
58
|
+
"@shapeshiftoss/unchained-client": "^10.14.11",
|
|
59
|
+
"@shapeshiftoss/utils": "^1.3.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/lodash": "^4.14.178",
|