@shapeshiftoss/swapper 18.1.0 → 19.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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/swappers/AcrossSwapper/constant.js +2 -1
- package/dist/cjs/swappers/AcrossSwapper/endpoints.js +1 -1
- package/dist/cjs/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +2 -1
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +6 -3
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.js +5 -1
- package/dist/cjs/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +1 -1
- package/dist/cjs/swappers/AcrossSwapper/utils/getAcrossTradeContext.d.ts +1 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getAcrossTradeContext.js +1 -0
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +3 -1
- package/dist/cjs/swappers/AvnuSwapper/utils/getAvnuTradeContext.d.ts +1 -0
- package/dist/cjs/swappers/AvnuSwapper/utils/getAvnuTradeContext.js +1 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +5 -2
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +2 -1
- package/dist/cjs/swappers/BebopSwapper/types.d.ts +2 -2
- package/dist/cjs/swappers/BebopSwapper/types.js +2 -0
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopTradeContext.d.ts +1 -0
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopTradeContext.js +1 -0
- package/dist/cjs/swappers/BebopSwapper/utils/helpers.d.ts +1 -1
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/ButterSwap/utils/helpers.js +10 -8
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/ChainflipSwapper/constants.d.ts +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/constants.js +3 -1
- package/dist/cjs/swappers/ChainflipSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -0
- package/dist/cjs/swappers/DebridgeSwapper/constant.js +10 -8
- package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +3 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -0
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +11 -0
- package/dist/cjs/swappers/RelaySwapper/constant.js +4 -3
- package/dist/cjs/swappers/RelaySwapper/endpoints.js +6 -2
- package/dist/cjs/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getLatestRelayStatusMessage.js +3 -1
- package/dist/cjs/swappers/RelaySwapper/utils/notifyTransactionIndexing.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/relayService.d.ts +6 -3
- package/dist/cjs/swappers/RelaySwapper/utils/relayService.js +3 -1
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +5 -0
- package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +2 -2
- package/dist/cjs/swappers/StonfiSwapper/endpoints.js +40 -14
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/cjs/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +2 -0
- package/dist/cjs/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +2 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +2 -0
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +1 -0
- package/dist/cjs/swappers/ZrxSwapper/types.d.ts +1 -1
- package/dist/cjs/swappers/ZrxSwapper/types.js +1 -0
- package/dist/cjs/swappers/ZrxSwapper/utils/constants.js +1 -0
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers.d.ts +1 -1
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers.js +5 -0
- package/dist/cjs/types.d.ts +3 -0
- package/dist/cjs/utils/helpers.d.ts +2 -0
- package/dist/cjs/utils/helpers.js +14 -1
- package/dist/cjs/utils/helpers.test.js +17 -0
- package/dist/cjs/utils/test-data/setupSwapQuote.js +1 -0
- package/dist/cjs/utils/thorchain/getThorL1TradeQuote.js +3 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/swappers/AcrossSwapper/constant.js +4 -3
- package/dist/esm/swappers/AcrossSwapper/endpoints.js +2 -2
- package/dist/esm/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +2 -1
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +6 -3
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.js +3 -0
- package/dist/esm/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +2 -2
- package/dist/esm/swappers/AcrossSwapper/utils/getAcrossTradeContext.d.ts +1 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getAcrossTradeContext.js +2 -1
- package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +3 -1
- package/dist/esm/swappers/AvnuSwapper/utils/getAvnuTradeContext.d.ts +1 -0
- package/dist/esm/swappers/AvnuSwapper/utils/getAvnuTradeContext.js +2 -1
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +3 -0
- package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +2 -1
- package/dist/esm/swappers/BebopSwapper/types.d.ts +2 -2
- package/dist/esm/swappers/BebopSwapper/types.js +2 -0
- package/dist/esm/swappers/BebopSwapper/utils/getBebopTradeContext.d.ts +1 -0
- package/dist/esm/swappers/BebopSwapper/utils/getBebopTradeContext.js +2 -1
- package/dist/esm/swappers/BebopSwapper/utils/helpers.d.ts +1 -1
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +2 -0
- package/dist/esm/swappers/ButterSwap/utils/helpers.js +10 -8
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/esm/swappers/ChainflipSwapper/constants.d.ts +1 -0
- package/dist/esm/swappers/ChainflipSwapper/constants.js +2 -0
- package/dist/esm/swappers/ChainflipSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -0
- package/dist/esm/swappers/DebridgeSwapper/constant.js +11 -9
- package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +3 -1
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -0
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +12 -1
- package/dist/esm/swappers/RelaySwapper/constant.js +6 -5
- package/dist/esm/swappers/RelaySwapper/endpoints.js +7 -3
- package/dist/esm/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +2 -0
- package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.js +2 -2
- package/dist/esm/swappers/RelaySwapper/utils/getLatestRelayStatusMessage.js +3 -1
- package/dist/esm/swappers/RelaySwapper/utils/notifyTransactionIndexing.js +2 -2
- package/dist/esm/swappers/RelaySwapper/utils/relayService.d.ts +6 -3
- package/dist/esm/swappers/RelaySwapper/utils/relayService.js +1 -0
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +5 -0
- package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +2 -2
- package/dist/esm/swappers/StonfiSwapper/endpoints.js +41 -15
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +2 -0
- package/dist/esm/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +2 -0
- package/dist/esm/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +2 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +2 -0
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +2 -1
- package/dist/esm/swappers/ZrxSwapper/types.d.ts +1 -1
- package/dist/esm/swappers/ZrxSwapper/types.js +1 -0
- package/dist/esm/swappers/ZrxSwapper/utils/constants.js +1 -0
- package/dist/esm/swappers/ZrxSwapper/utils/helpers.d.ts +1 -1
- package/dist/esm/swappers/ZrxSwapper/utils/helpers.js +5 -0
- package/dist/esm/types.d.ts +3 -0
- package/dist/esm/utils/helpers.d.ts +2 -0
- package/dist/esm/utils/helpers.js +12 -0
- package/dist/esm/utils/helpers.test.js +18 -1
- package/dist/esm/utils/test-data/setupSwapQuote.js +1 -0
- package/dist/esm/utils/thorchain/getThorL1TradeQuote.js +3 -0
- package/package.json +5 -5
|
@@ -31,7 +31,8 @@ exports.chainIdToAcrossChainId = {
|
|
|
31
31
|
// Across uses a custom Solana chain ID
|
|
32
32
|
[caip_1.solanaChainId]: 34268394551451,
|
|
33
33
|
[caip_1.scrollChainId]: chains_1.scroll.id,
|
|
34
|
-
[caip_1.megaethChainId]:
|
|
34
|
+
[caip_1.megaethChainId]: chains_1.megaeth.id,
|
|
35
|
+
[caip_1.robinhoodChainId]: chains_1.robinhood.id,
|
|
35
36
|
};
|
|
36
37
|
exports.acrossChainIdToChainId = (0, invert_1.default)(exports.chainIdToAcrossChainId);
|
|
37
38
|
exports.ACROSS_SUPPORTED_CHAIN_IDS = Object.keys(exports.chainIdToAcrossChainId);
|
|
@@ -36,7 +36,7 @@ exports.acrossApi = {
|
|
|
36
36
|
return sourceTxStatus;
|
|
37
37
|
txHash = sourceTxStatus.buyTxHash ?? txHash;
|
|
38
38
|
}
|
|
39
|
-
const maybeStatusResponse = await acrossService_1.acrossService.get(`${config.VITE_ACROSS_API_URL}/deposit/status?depositTxnRef=${txHash}
|
|
39
|
+
const maybeStatusResponse = await acrossService_1.acrossService.get(`${config.VITE_ACROSS_API_URL}/deposit/status?depositTxnRef=${txHash}`, (0, acrossService_1.getAcrossRequestConfig)(config));
|
|
40
40
|
if (maybeStatusResponse.isErr()) {
|
|
41
41
|
return {
|
|
42
42
|
buyTxHash: undefined,
|
|
@@ -19,7 +19,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
19
19
|
});
|
|
20
20
|
if (maybeContext.isErr())
|
|
21
21
|
return (0, monads_1.Err)(maybeContext.unwrapErr());
|
|
22
|
-
const { tradeCommon, stepCommon, protocolFees, stepDataArgs } = maybeContext.unwrap();
|
|
22
|
+
const { tradeCommon, stepCommon, protocolFees, stepDataArgs, deadline } = maybeContext.unwrap();
|
|
23
23
|
const maybeStepData = await (0, getAcrossStepData_1.getAcrossStepData)({ ...stepDataArgs, type: 'quote', input });
|
|
24
24
|
if (maybeStepData.isErr())
|
|
25
25
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
@@ -27,6 +27,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
27
27
|
const tradeQuote = {
|
|
28
28
|
...tradeCommon,
|
|
29
29
|
quoteOrRate: 'quote',
|
|
30
|
+
deadline,
|
|
30
31
|
receiveAddress,
|
|
31
32
|
steps: [
|
|
32
33
|
{
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { SwapperConfig } from '../../../types';
|
|
1
3
|
export declare const acrossService: {
|
|
2
|
-
get: <T = any>(url: string, config?:
|
|
3
|
-
post: <T_1 = any>(url: string, data: any, config?:
|
|
4
|
-
delete: <T_2 = any>(url: string, data: any, config?:
|
|
4
|
+
get: <T = any>(url: string, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../types").SwapErrorRight>>;
|
|
5
|
+
post: <T_1 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../types").SwapErrorRight>>;
|
|
6
|
+
delete: <T_2 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../types").SwapErrorRight>>;
|
|
5
7
|
};
|
|
8
|
+
export declare const getAcrossRequestConfig: (config: SwapperConfig) => AxiosRequestConfig | undefined;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.acrossService = void 0;
|
|
6
|
+
exports.getAcrossRequestConfig = exports.acrossService = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const utils_1 = require("../../../utils");
|
|
9
9
|
const axiosConfig = {
|
|
@@ -15,3 +15,7 @@ const axiosConfig = {
|
|
|
15
15
|
};
|
|
16
16
|
const acrossServiceBase = axios_1.default.create(axiosConfig);
|
|
17
17
|
exports.acrossService = (0, utils_1.makeSwapperAxiosServiceMonadic)(acrossServiceBase);
|
|
18
|
+
const getAcrossRequestConfig = (config) => config.VITE_ACROSS_API_KEY
|
|
19
|
+
? { headers: { Authorization: `Bearer ${config.VITE_ACROSS_API_KEY}` } }
|
|
20
|
+
: undefined;
|
|
21
|
+
exports.getAcrossRequestConfig = getAcrossRequestConfig;
|
|
@@ -22,6 +22,6 @@ const fetchAcrossTrade = (params, config) => {
|
|
|
22
22
|
if (params.slippage)
|
|
23
23
|
searchParams.set('slippage', params.slippage);
|
|
24
24
|
const url = `${config.VITE_ACROSS_API_URL}/swap/approval?${searchParams.toString()}`;
|
|
25
|
-
return acrossService_1.acrossService.get(url);
|
|
25
|
+
return acrossService_1.acrossService.get(url, (0, acrossService_1.getAcrossRequestConfig)(config));
|
|
26
26
|
};
|
|
27
27
|
exports.fetchAcrossTrade = fetchAcrossTrade;
|
|
@@ -7,6 +7,7 @@ type AcrossTradeContext = {
|
|
|
7
7
|
stepCommon: Omit<TradeStepCommon, 'feeData'>;
|
|
8
8
|
protocolFees: QuoteFeeData['protocolFees'];
|
|
9
9
|
stepDataArgs: Omit<GetAcrossStepDataArgs, 'type' | 'input'>;
|
|
10
|
+
deadline: number;
|
|
10
11
|
};
|
|
11
12
|
export declare const getAcrossTradeContext: ({ input, deps, depositor, recipient, }: {
|
|
12
13
|
input: AcrossTradeQuoteInput | AcrossTradeRateInput;
|
|
@@ -178,6 +178,7 @@ const getAcrossTradeContext = async ({ input, deps, depositor, recipient, }) =>
|
|
|
178
178
|
fallbackNetworkFeeCryptoBaseUnit: quote.fees.originGas.amount,
|
|
179
179
|
deps,
|
|
180
180
|
},
|
|
181
|
+
deadline: (0, helpers_1.normalizeEpochToMs)(quote.quoteExpiryTimestamp),
|
|
181
182
|
});
|
|
182
183
|
};
|
|
183
184
|
exports.getAcrossTradeContext = getAcrossTradeContext;
|
|
@@ -4,6 +4,7 @@ exports.getTradeQuote = exports.getTradeQuoteWithWallet = void 0;
|
|
|
4
4
|
const hdwallet_core_1 = require("@shapeshiftoss/hdwallet-core");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
7
8
|
const getArbitrumBridgeStepData_1 = require("../utils/getArbitrumBridgeStepData");
|
|
8
9
|
const getArbitrumBridgeTradeContext_1 = require("../utils/getArbitrumBridgeTradeContext");
|
|
9
10
|
const getTradeQuoteWithWallet = async (inputWithWallet, deps) => {
|
|
@@ -36,6 +37,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
36
37
|
const tradeQuote = {
|
|
37
38
|
...tradeCommon,
|
|
38
39
|
quoteOrRate: 'quote',
|
|
40
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
39
41
|
receiveAddress,
|
|
40
42
|
steps: [
|
|
41
43
|
{
|
|
@@ -5,6 +5,7 @@ const monads_1 = require("@sniptt/monads");
|
|
|
5
5
|
const starknet_1 = require("starknet");
|
|
6
6
|
const types_1 = require("../../../types");
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
8
9
|
const getAvnuTradeContext_1 = require("../utils/getAvnuTradeContext");
|
|
9
10
|
const getTradeQuote = async (input, deps) => {
|
|
10
11
|
const { sellAsset, accountNumber } = input;
|
|
@@ -20,7 +21,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
20
21
|
const maybeContext = await (0, getAvnuTradeContext_1.getAvnuTradeContext)({ input, takerAddress: normalizedSendAddress });
|
|
21
22
|
if (maybeContext.isErr())
|
|
22
23
|
return (0, monads_1.Err)(maybeContext.unwrapErr());
|
|
23
|
-
const { tradeCommon, stepCommon, protocolFees, quoteId, sellTokenAddress } = maybeContext.unwrap();
|
|
24
|
+
const { tradeCommon, stepCommon, protocolFees, quoteId, sellTokenAddress, deadline } = maybeContext.unwrap();
|
|
24
25
|
const adapter = deps.assertGetStarknetChainAdapter(sellAsset.chainId);
|
|
25
26
|
const feeData = await adapter.getFeeData({
|
|
26
27
|
to: normalizedReceiveAddress,
|
|
@@ -35,6 +36,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
35
36
|
...tradeCommon,
|
|
36
37
|
receiveAddress: normalizedReceiveAddress,
|
|
37
38
|
quoteOrRate: 'quote',
|
|
39
|
+
deadline: deadline ?? Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
38
40
|
steps: [
|
|
39
41
|
{
|
|
40
42
|
...stepCommon,
|
|
@@ -6,6 +6,7 @@ type AvnuTradeContext = {
|
|
|
6
6
|
protocolFees: QuoteFeeData['protocolFees'];
|
|
7
7
|
quoteId: string;
|
|
8
8
|
sellTokenAddress: string;
|
|
9
|
+
deadline: number | undefined;
|
|
9
10
|
};
|
|
10
11
|
export declare const getAvnuTradeContext: ({ input, takerAddress, }: {
|
|
11
12
|
input: GetStarknetTradeQuoteInput | GetStarknetTradeRateInput;
|
|
@@ -93,6 +93,7 @@ const getAvnuTradeContext = async ({ input, takerAddress, }) => {
|
|
|
93
93
|
protocolFees,
|
|
94
94
|
quoteId: bestQuote.quoteId,
|
|
95
95
|
sellTokenAddress,
|
|
96
|
+
deadline: bestQuote.expiry ? (0, helpers_1.normalizeEpochToMs)(bestQuote.expiry) : undefined,
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
catch (error) {
|
|
@@ -4,8 +4,9 @@ exports.getBebopSolanaTradeQuote = void 0;
|
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const types_1 = require("../../../types");
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
7
8
|
const getBebopSolanaTradeContext_1 = require("../utils/getBebopSolanaTradeContext");
|
|
8
|
-
const
|
|
9
|
+
const helpers_2 = require("../utils/helpers");
|
|
9
10
|
const getBebopSolanaTradeQuote = async (input, deps) => {
|
|
10
11
|
const { accountNumber } = input;
|
|
11
12
|
const maybeAddresses = (0, utils_1.assertQuoteAddresses)(input);
|
|
@@ -21,7 +22,7 @@ const getBebopSolanaTradeQuote = async (input, deps) => {
|
|
|
21
22
|
if (maybeContext.isErr())
|
|
22
23
|
return (0, monads_1.Err)(maybeContext.unwrapErr());
|
|
23
24
|
const { tradeCommon, stepCommon, response } = maybeContext.unwrap();
|
|
24
|
-
if (!(0,
|
|
25
|
+
if (!(0, helpers_2.isBebopSolanaTxSafe)(response.solana_tx, sendAddress)) {
|
|
25
26
|
return (0, monads_1.Err)((0, utils_1.makeSwapErrorRight)({
|
|
26
27
|
message: 'Bebop signer index mismatch - taker not at expected position',
|
|
27
28
|
code: types_1.TradeQuoteError.NoRouteFound,
|
|
@@ -30,6 +31,8 @@ const getBebopSolanaTradeQuote = async (input, deps) => {
|
|
|
30
31
|
const tradeQuote = {
|
|
31
32
|
...tradeCommon,
|
|
32
33
|
quoteOrRate: 'quote',
|
|
34
|
+
// The sealed multi-signer tx is blockhash-pinned, so the provider expiry governs
|
|
35
|
+
deadline: (0, helpers_1.normalizeEpochToMs)(response.expiry),
|
|
33
36
|
receiveAddress,
|
|
34
37
|
steps: [
|
|
35
38
|
{
|
|
@@ -20,7 +20,7 @@ const getBebopTradeQuote = async (input, deps) => {
|
|
|
20
20
|
});
|
|
21
21
|
if (maybeContext.isErr())
|
|
22
22
|
return (0, monads_1.Err)(maybeContext.unwrapErr());
|
|
23
|
-
const { tradeCommon, stepCommon, stepDataArgs } = maybeContext.unwrap();
|
|
23
|
+
const { tradeCommon, stepCommon, stepDataArgs, deadline } = maybeContext.unwrap();
|
|
24
24
|
const maybeStepData = await (0, getBebopStepData_1.getBebopStepData)({ ...stepDataArgs, type: 'quote', input });
|
|
25
25
|
if (maybeStepData.isErr())
|
|
26
26
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
@@ -28,6 +28,7 @@ const getBebopTradeQuote = async (input, deps) => {
|
|
|
28
28
|
const tradeQuote = {
|
|
29
29
|
...tradeCommon,
|
|
30
30
|
quoteOrRate: 'quote',
|
|
31
|
+
deadline,
|
|
31
32
|
receiveAddress,
|
|
32
33
|
steps: [
|
|
33
34
|
{
|
|
@@ -3,8 +3,8 @@ import type { Address, Hex } from 'viem';
|
|
|
3
3
|
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput } from '../../types';
|
|
4
4
|
export type BebopTradeQuoteInput = GetEvmTradeQuoteInput | GetSolanaTradeQuoteInput;
|
|
5
5
|
export type BebopTradeRateInput = GetEvmTradeRateInput | GetSolanaTradeRateInput;
|
|
6
|
-
export declare const bebopSupportedEvmChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet];
|
|
7
|
-
export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.SolanaMainnet];
|
|
6
|
+
export declare const bebopSupportedEvmChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.RobinhoodMainnet];
|
|
7
|
+
export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.RobinhoodMainnet, KnownChainIds.SolanaMainnet];
|
|
8
8
|
export type BebopSupportedChainId = (typeof bebopSupportedChainIds)[number];
|
|
9
9
|
export type BebopMetadata = {
|
|
10
10
|
name: 'bebop';
|
|
@@ -10,6 +10,7 @@ exports.bebopSupportedEvmChainIds = [
|
|
|
10
10
|
types_1.KnownChainIds.AvalancheMainnet,
|
|
11
11
|
types_1.KnownChainIds.OptimismMainnet,
|
|
12
12
|
types_1.KnownChainIds.BnbSmartChainMainnet,
|
|
13
|
+
types_1.KnownChainIds.RobinhoodMainnet,
|
|
13
14
|
];
|
|
14
15
|
exports.bebopSupportedChainIds = [
|
|
15
16
|
...exports.bebopSupportedEvmChainIds,
|
|
@@ -23,6 +24,7 @@ exports.chainIdToBebopChain = {
|
|
|
23
24
|
[types_1.KnownChainIds.AvalancheMainnet]: 'avalanche',
|
|
24
25
|
[types_1.KnownChainIds.OptimismMainnet]: 'optimism',
|
|
25
26
|
[types_1.KnownChainIds.BnbSmartChainMainnet]: 'bsc',
|
|
27
|
+
[types_1.KnownChainIds.RobinhoodMainnet]: 'robinhood',
|
|
26
28
|
[types_1.KnownChainIds.SolanaMainnet]: 'solana',
|
|
27
29
|
};
|
|
28
30
|
exports.BEBOP_NATIVE_MARKER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
@@ -6,6 +6,7 @@ type BebopTradeContext = {
|
|
|
6
6
|
tradeCommon: TradeCommon;
|
|
7
7
|
stepCommon: Omit<TradeStepCommon, 'feeData'>;
|
|
8
8
|
stepDataArgs: Omit<GetBebopStepDataArgs, 'type' | 'input'>;
|
|
9
|
+
deadline: number;
|
|
9
10
|
};
|
|
10
11
|
export declare const getBebopTradeContext: ({ input, deps, from, receiver, }: {
|
|
11
12
|
input: GetEvmTradeQuoteInput | GetEvmTradeRateInput;
|
|
@@ -2,7 +2,7 @@ import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
|
2
2
|
import type { Asset } from '@shapeshiftoss/types';
|
|
3
3
|
export declare const assetIdToBebopToken: (assetId: AssetId) => string;
|
|
4
4
|
export declare const assetIdToBebopSolanaToken: (assetId: AssetId) => string;
|
|
5
|
-
export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet;
|
|
5
|
+
export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet | import("@shapeshiftoss/types").KnownChainIds.RobinhoodMainnet;
|
|
6
6
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
7
7
|
buyAsset: Asset;
|
|
8
8
|
sellAsset: Asset;
|
|
@@ -4,6 +4,7 @@ exports.getBobGatewayTradeQuote = void 0;
|
|
|
4
4
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
7
8
|
const getBobGatewayStepData_1 = require("../utils/getBobGatewayStepData");
|
|
8
9
|
const getBobGatewayTradeContext_1 = require("../utils/getBobGatewayTradeContext");
|
|
9
10
|
const getBobGatewayTradeQuote = async (input, deps) => {
|
|
@@ -36,6 +37,7 @@ const getBobGatewayTradeQuote = async (input, deps) => {
|
|
|
36
37
|
const tradeQuote = {
|
|
37
38
|
...tradeCommon,
|
|
38
39
|
quoteOrRate: 'quote',
|
|
40
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
39
41
|
receiveAddress,
|
|
40
42
|
steps: [
|
|
41
43
|
{
|
|
@@ -7,6 +7,7 @@ const monads_1 = require("@sniptt/monads");
|
|
|
7
7
|
const constants_1 = require("../../../constants");
|
|
8
8
|
const types_1 = require("../../../types");
|
|
9
9
|
const utils_2 = require("../../../utils");
|
|
10
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
10
11
|
const getButterSwapStepData_1 = require("../utils/getButterSwapStepData");
|
|
11
12
|
const getButterSwapTradeContext_1 = require("../utils/getButterSwapTradeContext");
|
|
12
13
|
const xhr_1 = require("../xhr");
|
|
@@ -62,6 +63,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
62
63
|
const tradeQuote = {
|
|
63
64
|
...tradeCommon,
|
|
64
65
|
quoteOrRate: 'quote',
|
|
66
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
65
67
|
receiveAddress,
|
|
66
68
|
steps: [
|
|
67
69
|
{
|
|
@@ -6,20 +6,22 @@ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
|
6
6
|
const types_1 = require("@shapeshiftoss/types");
|
|
7
7
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
8
8
|
const monads_1 = require("@sniptt/monads");
|
|
9
|
+
const chains_1 = require("viem/chains");
|
|
9
10
|
const types_2 = require("../../../types");
|
|
10
11
|
const utils_2 = require("../../../utils");
|
|
11
12
|
// https://docs.butternetwork.io/butter-swap-integration/butter-api-for-routing/get-supportedchainlist#butter-chain-id-explanation
|
|
12
13
|
const BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
[chains_1.mainnet.id]: types_1.KnownChainIds.EthereumMainnet,
|
|
15
|
+
[chains_1.polygon.id]: types_1.KnownChainIds.PolygonMainnet,
|
|
16
|
+
[chains_1.bsc.id]: types_1.KnownChainIds.BnbSmartChainMainnet,
|
|
17
|
+
[chains_1.arbitrum.id]: types_1.KnownChainIds.ArbitrumMainnet,
|
|
18
|
+
[chains_1.optimism.id]: types_1.KnownChainIds.OptimismMainnet,
|
|
19
|
+
[chains_1.base.id]: types_1.KnownChainIds.BaseMainnet,
|
|
20
|
+
[chains_1.avalanche.id]: types_1.KnownChainIds.AvalancheMainnet,
|
|
21
|
+
[chains_1.robinhood.id]: types_1.KnownChainIds.RobinhoodMainnet,
|
|
20
22
|
1360108768460801: types_1.KnownChainIds.SolanaMainnet,
|
|
21
23
|
1360095883558913: types_1.KnownChainIds.BitcoinMainnet,
|
|
22
|
-
|
|
24
|
+
[chains_1.tron.id]: types_1.KnownChainIds.TronMainnet,
|
|
23
25
|
};
|
|
24
26
|
const CHAIN_ID_TO_BUTTERSWAP_CHAIN_ID = Object.entries(BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID).reduce((acc, [butterSwapChainId, chainId]) => {
|
|
25
27
|
acc[chainId] = Number(butterSwapChainId);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTradeQuote = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
6
7
|
const getCetusStepData_1 = require("./getCetusStepData");
|
|
7
8
|
const getCetusTradeContext_1 = require("./getCetusTradeContext");
|
|
8
9
|
const getTradeQuote = async (input, deps) => {
|
|
@@ -27,6 +28,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
27
28
|
const tradeQuote = {
|
|
28
29
|
...tradeCommon,
|
|
29
30
|
quoteOrRate: 'quote',
|
|
31
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
30
32
|
receiveAddress,
|
|
31
33
|
steps: [
|
|
32
34
|
{
|
|
@@ -5,6 +5,7 @@ import type { SwapSource } from '../../types';
|
|
|
5
5
|
import { ChainflipNetwork } from './types';
|
|
6
6
|
export declare const CHAINFLIP_REGULAR_QUOTE: "regular";
|
|
7
7
|
export declare const CHAINFLIP_DCA_QUOTE: "dca";
|
|
8
|
+
export declare const CHAINFLIP_CHANNEL_DEADLINE_MS: number;
|
|
8
9
|
export declare const ChainflipSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BitcoinMainnet, KnownChainIds.SolanaMainnet, KnownChainIds.TronMainnet];
|
|
9
10
|
export type ChainflipSupportedChainId = (typeof ChainflipSupportedChainIds)[number];
|
|
10
11
|
export declare const ChainflipSupportedAssetIdsByChainId: Partial<Record<KnownChainIds, AssetId[]>>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChainflipStatusMessage = exports.usdcAsset = exports.CHAINFLIP_DCA_BOOST_SWAP_SOURCE = exports.CHAINFLIP_DCA_SWAP_SOURCE = exports.CHAINFLIP_BOOST_SWAP_SOURCE = exports.CHAINFLIP_SWAP_SOURCE = exports.chainIdToChainflipNetwork = exports.ChainflipSupportedAssetIdsByChainId = exports.ChainflipSupportedChainIds = exports.CHAINFLIP_DCA_QUOTE = exports.CHAINFLIP_REGULAR_QUOTE = void 0;
|
|
3
|
+
exports.ChainflipStatusMessage = exports.usdcAsset = exports.CHAINFLIP_DCA_BOOST_SWAP_SOURCE = exports.CHAINFLIP_DCA_SWAP_SOURCE = exports.CHAINFLIP_BOOST_SWAP_SOURCE = exports.CHAINFLIP_SWAP_SOURCE = exports.chainIdToChainflipNetwork = exports.ChainflipSupportedAssetIdsByChainId = exports.ChainflipSupportedChainIds = exports.CHAINFLIP_CHANNEL_DEADLINE_MS = exports.CHAINFLIP_DCA_QUOTE = exports.CHAINFLIP_REGULAR_QUOTE = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
6
6
|
const types_2 = require("../../types");
|
|
7
7
|
const types_3 = require("./types");
|
|
8
8
|
exports.CHAINFLIP_REGULAR_QUOTE = 'regular';
|
|
9
9
|
exports.CHAINFLIP_DCA_QUOTE = 'dca';
|
|
10
|
+
// Deposit channels stay open ~24h - 6h keeps a 4x margin against depositing to an expired channel
|
|
11
|
+
exports.CHAINFLIP_CHANNEL_DEADLINE_MS = 6 * 60 * 60 * 1000;
|
|
10
12
|
exports.ChainflipSupportedChainIds = [
|
|
11
13
|
types_1.KnownChainIds.EthereumMainnet,
|
|
12
14
|
types_1.KnownChainIds.ArbitrumMainnet,
|
|
@@ -4,6 +4,7 @@ exports.getTradeQuote = void 0;
|
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const types_1 = require("../../../types");
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const getChainflipStepData_1 = require("../utils/getChainflipStepData");
|
|
8
9
|
const getChainflipTradeContexts_1 = require("../utils/getChainflipTradeContexts");
|
|
9
10
|
const helpers_1 = require("../utils/helpers");
|
|
@@ -69,6 +70,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
69
70
|
tradeQuotes.push({
|
|
70
71
|
...tradeCommon,
|
|
71
72
|
quoteOrRate: 'quote',
|
|
73
|
+
deadline: Date.now() + constants_1.CHAINFLIP_CHANNEL_DEADLINE_MS,
|
|
72
74
|
receiveAddress,
|
|
73
75
|
steps: [
|
|
74
76
|
{
|
|
@@ -7,28 +7,30 @@ exports.DEFAULT_DEBRIDGE_USER_ADDRESS = exports.DEFAULT_DEBRIDGE_TOKEN_ADDRESS =
|
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
8
|
const invert_1 = __importDefault(require("lodash/invert"));
|
|
9
9
|
const viem_1 = require("viem");
|
|
10
|
+
const chains_1 = require("viem/chains");
|
|
10
11
|
exports.chainIdToDebridgeChainId = {
|
|
11
|
-
[caip_1.ethChainId]:
|
|
12
|
-
[caip_1.optimismChainId]:
|
|
13
|
-
[caip_1.bscChainId]:
|
|
12
|
+
[caip_1.ethChainId]: chains_1.mainnet.id,
|
|
13
|
+
[caip_1.optimismChainId]: chains_1.optimism.id,
|
|
14
|
+
[caip_1.bscChainId]: chains_1.bsc.id,
|
|
14
15
|
[caip_1.gnosisChainId]: 100000002,
|
|
15
|
-
[caip_1.polygonChainId]:
|
|
16
|
+
[caip_1.polygonChainId]: chains_1.polygon.id,
|
|
16
17
|
[caip_1.monadChainId]: 100000030,
|
|
17
18
|
[caip_1.hyperEvmChainId]: 100000022,
|
|
18
19
|
[caip_1.seiChainId]: 100000027,
|
|
19
|
-
[caip_1.baseChainId]:
|
|
20
|
+
[caip_1.baseChainId]: chains_1.base.id,
|
|
20
21
|
[caip_1.plasmaChainId]: 100000028,
|
|
21
|
-
[caip_1.arbitrumChainId]:
|
|
22
|
-
[caip_1.avalancheChainId]:
|
|
22
|
+
[caip_1.arbitrumChainId]: chains_1.arbitrum.id,
|
|
23
|
+
[caip_1.avalancheChainId]: chains_1.avalanche.id,
|
|
23
24
|
[caip_1.mantleChainId]: 100000023,
|
|
24
25
|
[caip_1.cronosChainId]: 100000019,
|
|
25
26
|
[caip_1.berachainChainId]: 100000020,
|
|
26
|
-
[caip_1.lineaChainId]:
|
|
27
|
+
[caip_1.lineaChainId]: chains_1.linea.id,
|
|
27
28
|
[caip_1.bobChainId]: 100000021,
|
|
28
29
|
[caip_1.sonicChainId]: 100000014,
|
|
29
30
|
[caip_1.storyChainId]: 100000013,
|
|
30
31
|
[caip_1.flowEvmChainId]: 100000009,
|
|
31
32
|
[caip_1.megaethChainId]: 100000031,
|
|
33
|
+
[caip_1.robinhoodChainId]: chains_1.robinhood.id,
|
|
32
34
|
};
|
|
33
35
|
exports.debridgeChainIdToChainId = (0, invert_1.default)(exports.chainIdToDebridgeChainId);
|
|
34
36
|
exports.DEBRIDGE_SUPPORTED_CHAIN_IDS = Object.keys(exports.chainIdToDebridgeChainId);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTradeQuote = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
6
7
|
const getDebridgeStepData_1 = require("../utils/getDebridgeStepData");
|
|
7
8
|
const getDebridgeTradeContext_1 = require("../utils/getDebridgeTradeContext");
|
|
8
9
|
const getTradeQuote = async (input, deps) => {
|
|
@@ -26,6 +27,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
26
27
|
const tradeQuote = {
|
|
27
28
|
...tradeCommon,
|
|
28
29
|
quoteOrRate: 'quote',
|
|
30
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
29
31
|
receiveAddress,
|
|
30
32
|
steps: [
|
|
31
33
|
{
|
|
@@ -166,7 +166,9 @@ exports.nearIntentsApi = {
|
|
|
166
166
|
const message = (0, helpers_1.getNearIntentsStatusMessage)(statusResponse.status);
|
|
167
167
|
// Extract buyTxHash from destination chain transactions
|
|
168
168
|
const buyTxHash = statusResponse.swapDetails?.destinationChainTxHashes?.[0]?.hash;
|
|
169
|
-
|
|
169
|
+
// amountOut is only meaningful destination-denominated on terminal success - in-flight and
|
|
170
|
+
// refund states may carry settlement-internal or refund values
|
|
171
|
+
const actualBuyAmountCryptoBaseUnit = statusResponse.status === 'SUCCESS' ? statusResponse.swapDetails?.amountOut : undefined;
|
|
170
172
|
return {
|
|
171
173
|
status: txStatus,
|
|
172
174
|
buyTxHash,
|
|
@@ -48,9 +48,16 @@ const getTradeQuote = async (input, deps) => {
|
|
|
48
48
|
if (maybeStepData.isErr())
|
|
49
49
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
50
50
|
const { transactionData, networkFeeCryptoBaseUnit } = maybeStepData.unwrap();
|
|
51
|
+
const requestDeadlineMs = Date.parse(quoteRequest.deadline);
|
|
52
|
+
const responseDeadlineMs = Date.parse(quote.deadline ?? '');
|
|
51
53
|
const tradeQuote = {
|
|
52
54
|
...tradeCommon,
|
|
53
55
|
quoteOrRate: 'quote',
|
|
56
|
+
// Deposits mined after our requested refund deadline refund instead of executing as quoted;
|
|
57
|
+
// the response deadline (when the deposit address goes inactive, ~72h) only binds if tighter
|
|
58
|
+
deadline: Number.isFinite(responseDeadlineMs)
|
|
59
|
+
? Math.min(requestDeadlineMs, responseDeadlineMs)
|
|
60
|
+
: requestDeadlineMs,
|
|
54
61
|
receiveAddress,
|
|
55
62
|
steps: [
|
|
56
63
|
{
|
|
@@ -128,9 +128,20 @@ const getPortalsTradeQuote = async (input, deps) => {
|
|
|
128
128
|
if (maybeStepData.isErr())
|
|
129
129
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
130
130
|
const { transactionData, networkFeeCryptoBaseUnit } = maybeStepData.unwrap();
|
|
131
|
+
// Nullable in practice (live validated orders return null) - numeric or ISO when supplied
|
|
132
|
+
const expiryMs = (() => {
|
|
133
|
+
if (!orderContext.expiry)
|
|
134
|
+
return undefined;
|
|
135
|
+
const numeric = Number(orderContext.expiry);
|
|
136
|
+
if (Number.isFinite(numeric))
|
|
137
|
+
return (0, helpers_1.normalizeEpochToMs)(numeric);
|
|
138
|
+
const parsed = Date.parse(orderContext.expiry);
|
|
139
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
140
|
+
})();
|
|
131
141
|
const tradeQuote = {
|
|
132
142
|
...tradeCommon,
|
|
133
143
|
quoteOrRate: 'quote',
|
|
144
|
+
deadline: expiryMs ?? Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
134
145
|
receiveAddress,
|
|
135
146
|
steps: [
|
|
136
147
|
{
|
|
@@ -22,12 +22,12 @@ exports.chainIdToRelayChainId = {
|
|
|
22
22
|
[caip_1.gnosisChainId]: chains_1.gnosis.id,
|
|
23
23
|
[caip_1.avalancheChainId]: chains_1.avalanche.id,
|
|
24
24
|
[caip_1.bscChainId]: chains_1.bsc.id,
|
|
25
|
-
[caip_1.tronChainId]:
|
|
25
|
+
[caip_1.tronChainId]: chains_1.tron.id,
|
|
26
26
|
[caip_1.monadChainId]: chains_1.monad.id,
|
|
27
27
|
[caip_1.hyperEvmChainId]: chains_1.hyperEvm.id,
|
|
28
28
|
[caip_1.mantleChainId]: chains_1.mantle.id,
|
|
29
29
|
[caip_1.inkChainId]: chains_1.ink.id,
|
|
30
|
-
[caip_1.megaethChainId]:
|
|
30
|
+
[caip_1.megaethChainId]: chains_1.megaeth.id,
|
|
31
31
|
[caip_1.plasmaChainId]: chains_1.plasma.id,
|
|
32
32
|
[caip_1.katanaChainId]: chains_1.katana.id,
|
|
33
33
|
[caip_1.etherealChainId]: 5064014,
|
|
@@ -49,7 +49,8 @@ exports.chainIdToRelayChainId = {
|
|
|
49
49
|
[caip_1.modeChainId]: chains_1.mode.id,
|
|
50
50
|
[caip_1.soneiumChainId]: chains_1.soneium.id,
|
|
51
51
|
[caip_1.seiChainId]: chains_1.sei.id,
|
|
52
|
-
[caip_1.abstractChainId]:
|
|
52
|
+
[caip_1.abstractChainId]: chains_1.abstract.id,
|
|
53
|
+
[caip_1.robinhoodChainId]: chains_1.robinhood.id,
|
|
53
54
|
};
|
|
54
55
|
var RelayStatusMessage;
|
|
55
56
|
(function (RelayStatusMessage) {
|
|
@@ -64,7 +64,7 @@ exports.relayApi = {
|
|
|
64
64
|
// relay.link tracks the swap by its origin chain transaction
|
|
65
65
|
const swapperTxId = txHash;
|
|
66
66
|
const swapperTxLink = `https://relay.link/transaction/${txHash}`;
|
|
67
|
-
const maybeStatusResponse = await relayService_1.relayService.get(`${config.VITE_RELAY_API_URL}/intents/status/
|
|
67
|
+
const maybeStatusResponse = await relayService_1.relayService.get(`${config.VITE_RELAY_API_URL}/intents/status/v3?requestId=${relayMetadata.relayId}`, (0, relayService_1.getRelayRequestConfig)(config));
|
|
68
68
|
if (maybeStatusResponse.isErr()) {
|
|
69
69
|
return {
|
|
70
70
|
buyTxHash: undefined,
|
|
@@ -79,9 +79,13 @@ exports.relayApi = {
|
|
|
79
79
|
switch (statusResponse.status) {
|
|
80
80
|
case 'success':
|
|
81
81
|
return unchained_client_1.TxStatus.Confirmed;
|
|
82
|
+
case 'waiting':
|
|
83
|
+
case 'delayed':
|
|
82
84
|
case 'pending':
|
|
85
|
+
case 'depositing':
|
|
86
|
+
case 'submitted':
|
|
83
87
|
return unchained_client_1.TxStatus.Pending;
|
|
84
|
-
case '
|
|
88
|
+
case 'failure':
|
|
85
89
|
case 'refund':
|
|
86
90
|
return unchained_client_1.TxStatus.Failed;
|
|
87
91
|
default:
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTradeQuote = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
6
7
|
const getRelayStepData_1 = require("../utils/getRelayStepData");
|
|
7
8
|
const getRelayTradeContext_1 = require("../utils/getRelayTradeContext");
|
|
8
9
|
const getTradeQuote = async (input, deps, relayChainMap) => {
|
|
@@ -45,6 +46,7 @@ const getTradeQuote = async (input, deps, relayChainMap) => {
|
|
|
45
46
|
const tradeQuote = {
|
|
46
47
|
...tradeCommon,
|
|
47
48
|
quoteOrRate: 'quote',
|
|
49
|
+
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
48
50
|
receiveAddress,
|
|
49
51
|
steps,
|
|
50
52
|
};
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchRelayTrade = void 0;
|
|
4
4
|
const relayService_1 = require("./relayService");
|
|
5
5
|
const fetchRelayTrade = async (params, config) => {
|
|
6
|
-
return await relayService_1.relayService.post(`${config.VITE_RELAY_API_URL}/quote/v2`, params);
|
|
6
|
+
return await relayService_1.relayService.post(`${config.VITE_RELAY_API_URL}/quote/v2`, params, (0, relayService_1.getRelayRequestConfig)(config));
|
|
7
7
|
};
|
|
8
8
|
exports.fetchRelayTrade = fetchRelayTrade;
|
|
@@ -10,10 +10,12 @@ const getLatestRelayStatusMessage = (status) => {
|
|
|
10
10
|
case statusValue === 'delayed':
|
|
11
11
|
return constant_1.RelayStatusMessage.Retrying;
|
|
12
12
|
case statusValue === 'pending':
|
|
13
|
+
case statusValue === 'depositing':
|
|
14
|
+
case statusValue === 'submitted':
|
|
13
15
|
return constant_1.RelayStatusMessage.DepositDetected;
|
|
14
16
|
case statusValue === 'success':
|
|
15
17
|
return constant_1.RelayStatusMessage.SwapComplete;
|
|
16
|
-
case statusValue === '
|
|
18
|
+
case statusValue === 'failure':
|
|
17
19
|
return constant_1.RelayStatusMessage.SwapFailed;
|
|
18
20
|
default:
|
|
19
21
|
return 'Unknown status';
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.notifyTransactionIndexing = void 0;
|
|
4
4
|
const relayService_1 = require("./relayService");
|
|
5
5
|
const notifyTransactionIndexing = async (params, config) => {
|
|
6
|
-
return await relayService_1.relayService.post(`${config.VITE_RELAY_API_URL}/transactions/single`, params);
|
|
6
|
+
return await relayService_1.relayService.post(`${config.VITE_RELAY_API_URL}/transactions/single`, params, (0, relayService_1.getRelayRequestConfig)(config));
|
|
7
7
|
};
|
|
8
8
|
exports.notifyTransactionIndexing = notifyTransactionIndexing;
|