@shapeshiftoss/swapper 19.0.0 → 20.1.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/exactOutputFiltering.test.d.ts +1 -0
- package/dist/cjs/exactOutputFiltering.test.js +70 -0
- package/dist/cjs/swapper.d.ts +3 -3
- package/dist/cjs/swapper.js +29 -6
- package/dist/cjs/swappers/AcrossSwapper/utils/getAcrossStepData.d.ts +1 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getAcrossStepData.js +2 -2
- package/dist/cjs/swappers/AcrossSwapper/utils/getAcrossTradeContext.js +1 -0
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopStepData.d.ts +1 -0
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopStepData.js +2 -2
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopTradeContext.js +1 -0
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +5 -1
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +11 -2
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.d.ts +2 -1
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.js +2 -1
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +2 -1
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +2 -1
- package/dist/cjs/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/checkTradeStatus.test.d.ts +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/checkTradeStatus.test.js +48 -0
- package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +5 -2
- package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +3 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/getDebridgeStepData.d.ts +1 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/getDebridgeStepData.js +2 -2
- package/dist/cjs/swappers/DebridgeSwapper/utils/getDebridgeTradeContext.js +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/NearIntentsSwapper.js +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/checkTradeStatus.test.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/checkTradeStatus.test.js +52 -0
- package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -1
- package/dist/cjs/swappers/NearIntentsSwapper/constants.js +4 -3
- package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +4 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.d.ts +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +14 -9
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.d.ts +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +14 -9
- package/dist/cjs/swappers/NearIntentsSwapper/types.d.ts +3 -1
- package/dist/cjs/swappers/NearIntentsSwapper/utils/exactOutput.test.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/exactOutput.test.js +61 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/getNearIntentsTradeContext.d.ts +2 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/getNearIntentsTradeContext.js +4 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers.d.ts +5 -5
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers.js +30 -26
- package/dist/cjs/swappers/NearIntentsSwapper/utils/quoteDeadline.test.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/quoteDeadline.test.js +28 -0
- package/dist/cjs/swappers/PortalsSwapper/endpoints.js +51 -47
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +1 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +1 -1
- package/dist/cjs/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.d.ts +0 -1
- package/dist/cjs/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.js +3 -6
- package/dist/cjs/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.js +6 -3
- package/dist/cjs/swappers/PortalsSwapper/utils/fetchSquidStatus.d.ts +0 -1
- package/dist/cjs/swappers/PortalsSwapper/utils/fetchSquidStatus.js +1 -8
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsStepData.d.ts +1 -0
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsStepData.js +16 -8
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsStepData.test.d.ts +1 -0
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsStepData.test.js +70 -0
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsTradeContext.d.ts +3 -2
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsTradeContext.js +34 -16
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsTradeContext.test.d.ts +1 -0
- package/dist/cjs/swappers/PortalsSwapper/utils/getPortalsTradeContext.test.js +93 -0
- package/dist/cjs/swappers/RelaySwapper/endpoints.js +9 -18
- package/dist/cjs/swappers/RelaySwapper/getTradeQuote/getTradeQuote.d.ts +2 -1
- package/dist/cjs/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +5 -2
- package/dist/cjs/swappers/RelaySwapper/getTradeRate/getTradeRate.d.ts +2 -1
- package/dist/cjs/swappers/RelaySwapper/getTradeRate/getTradeRate.js +5 -2
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayTradeContext.d.ts +2 -2
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayTradeContext.js +22 -10
- package/dist/cjs/swappers/RelaySwapper/utils/helpers.d.ts +2 -2
- package/dist/cjs/swappers/RelaySwapper/utils/relayStatus.d.ts +8 -0
- package/dist/cjs/swappers/RelaySwapper/utils/relayStatus.js +39 -0
- package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +18 -1
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.d.ts +1 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.js +2 -2
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTradeContext.js +6 -1
- package/dist/cjs/swappers/ThorchainSwapper/generated/generatedThorLongtailTokens.json +1 -0
- package/dist/cjs/types.d.ts +21 -2
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/cowswap/index.d.ts +4 -1
- package/dist/cjs/utils/cowswap/index.js +5 -1
- package/dist/cjs/utils/helpers.d.ts +9 -0
- package/dist/cjs/utils/helpers.js +23 -1
- package/dist/cjs/utils/helpers.test.js +41 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/exactOutputFiltering.test.d.ts +1 -0
- package/dist/esm/exactOutputFiltering.test.js +68 -0
- package/dist/esm/swapper.d.ts +3 -3
- package/dist/esm/swapper.js +29 -6
- package/dist/esm/swappers/AcrossSwapper/utils/getAcrossStepData.d.ts +1 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getAcrossStepData.js +2 -2
- package/dist/esm/swappers/AcrossSwapper/utils/getAcrossTradeContext.js +1 -0
- package/dist/esm/swappers/BebopSwapper/utils/getBebopStepData.d.ts +1 -0
- package/dist/esm/swappers/BebopSwapper/utils/getBebopStepData.js +2 -2
- package/dist/esm/swappers/BebopSwapper/utils/getBebopTradeContext.js +1 -0
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +5 -1
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +11 -2
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.d.ts +2 -1
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.js +2 -1
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +2 -1
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +2 -1
- package/dist/esm/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
- package/dist/esm/swappers/ChainflipSwapper/checkTradeStatus.test.d.ts +1 -0
- package/dist/esm/swappers/ChainflipSwapper/checkTradeStatus.test.js +46 -0
- package/dist/esm/swappers/ChainflipSwapper/endpoints.js +5 -2
- package/dist/esm/swappers/ChainflipSwapper/types.d.ts +3 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/getDebridgeStepData.d.ts +1 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/getDebridgeStepData.js +2 -2
- package/dist/esm/swappers/DebridgeSwapper/utils/getDebridgeTradeContext.js +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/NearIntentsSwapper.js +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/checkTradeStatus.test.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/checkTradeStatus.test.js +50 -0
- package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -1
- package/dist/esm/swappers/NearIntentsSwapper/constants.js +3 -2
- package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +6 -3
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.d.ts +2 -1
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -3
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.d.ts +2 -1
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +7 -3
- package/dist/esm/swappers/NearIntentsSwapper/types.d.ts +3 -1
- package/dist/esm/swappers/NearIntentsSwapper/utils/exactOutput.test.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/exactOutput.test.js +59 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/getNearIntentsTradeContext.d.ts +2 -2
- package/dist/esm/swappers/NearIntentsSwapper/utils/getNearIntentsTradeContext.js +4 -2
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers.d.ts +5 -5
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers.js +32 -28
- package/dist/esm/swappers/NearIntentsSwapper/utils/quoteDeadline.test.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/quoteDeadline.test.js +26 -0
- package/dist/esm/swappers/PortalsSwapper/endpoints.js +53 -49
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +1 -1
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +1 -1
- package/dist/esm/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.d.ts +0 -1
- package/dist/esm/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.js +2 -4
- package/dist/esm/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.js +6 -3
- package/dist/esm/swappers/PortalsSwapper/utils/fetchSquidStatus.d.ts +0 -1
- package/dist/esm/swappers/PortalsSwapper/utils/fetchSquidStatus.js +0 -6
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsStepData.d.ts +1 -0
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsStepData.js +13 -5
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsStepData.test.d.ts +1 -0
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsStepData.test.js +68 -0
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsTradeContext.d.ts +3 -2
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsTradeContext.js +35 -17
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsTradeContext.test.d.ts +1 -0
- package/dist/esm/swappers/PortalsSwapper/utils/getPortalsTradeContext.test.js +91 -0
- package/dist/esm/swappers/RelaySwapper/endpoints.js +11 -20
- package/dist/esm/swappers/RelaySwapper/getTradeQuote/getTradeQuote.d.ts +2 -1
- package/dist/esm/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +3 -1
- package/dist/esm/swappers/RelaySwapper/getTradeRate/getTradeRate.d.ts +2 -1
- package/dist/esm/swappers/RelaySwapper/getTradeRate/getTradeRate.js +3 -1
- package/dist/esm/swappers/RelaySwapper/utils/getRelayTradeContext.d.ts +2 -2
- package/dist/esm/swappers/RelaySwapper/utils/getRelayTradeContext.js +23 -11
- package/dist/esm/swappers/RelaySwapper/utils/helpers.d.ts +2 -2
- package/dist/esm/swappers/RelaySwapper/utils/relayStatus.d.ts +8 -0
- package/dist/esm/swappers/RelaySwapper/utils/relayStatus.js +32 -0
- package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +18 -1
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.d.ts +1 -0
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.js +2 -2
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTradeContext.js +6 -1
- package/dist/esm/swappers/ThorchainSwapper/generated/generatedThorLongtailTokens.json +1 -0
- package/dist/esm/types.d.ts +21 -2
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils/cowswap/index.d.ts +4 -1
- package/dist/esm/utils/cowswap/index.js +3 -0
- package/dist/esm/utils/helpers.d.ts +9 -0
- package/dist/esm/utils/helpers.js +20 -0
- package/dist/esm/utils/helpers.test.js +42 -1
- package/package.json +6 -6
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTradeQuote = void 0;
|
|
3
|
+
exports.getExactOutputTradeQuote = 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 types_1 = require("../types");
|
|
7
8
|
const getNearIntentsStepData_1 = require("../utils/getNearIntentsStepData");
|
|
8
9
|
const getNearIntentsTradeContext_1 = require("../utils/getNearIntentsTradeContext");
|
|
9
|
-
const
|
|
10
|
+
const helpers_2 = require("../utils/helpers");
|
|
10
11
|
const oneClickService_1 = require("../utils/oneClickService");
|
|
11
|
-
const
|
|
12
|
-
const { sellAsset, buyAsset, accountNumber, affiliateBps
|
|
12
|
+
const getQuote = async (input, deps) => {
|
|
13
|
+
const { sellAsset, buyAsset, accountNumber, affiliateBps } = input;
|
|
13
14
|
const addresses = (0, utils_1.assertQuoteAddresses)(input);
|
|
14
15
|
if (addresses.isErr())
|
|
15
16
|
return (0, monads_1.Err)(addresses.unwrapErr());
|
|
16
17
|
const { sendAddress, receiveAddress } = addresses.unwrap();
|
|
17
18
|
(0, oneClickService_1.initializeOneClickService)(deps.config.VITE_NEAR_INTENTS_API_KEY);
|
|
18
|
-
const
|
|
19
|
+
const amount = (0, helpers_1.getTradeAmount)(input);
|
|
20
|
+
const maybeAssets = await (0, helpers_2.resolveNearIntentsAssets)({ sellAsset, buyAsset });
|
|
19
21
|
if (maybeAssets.isErr())
|
|
20
22
|
return (0, monads_1.Err)(maybeAssets.unwrapErr());
|
|
21
23
|
const { originAsset, destinationAsset } = maybeAssets.unwrap();
|
|
22
|
-
const quoteRequest = (0,
|
|
24
|
+
const quoteRequest = (0, helpers_2.buildNearIntentsQuoteRequest)({
|
|
23
25
|
originAsset,
|
|
24
26
|
destinationAsset,
|
|
25
|
-
|
|
27
|
+
amount,
|
|
26
28
|
slippageTolerancePercentageDecimal: input.slippageTolerancePercentageDecimal,
|
|
27
29
|
affiliateBps,
|
|
28
30
|
refundTo: sendAddress,
|
|
29
31
|
recipient: receiveAddress,
|
|
30
32
|
refundType: types_1.QuoteRequest.refundType.ORIGIN_CHAIN,
|
|
31
33
|
recipientType: types_1.QuoteRequest.recipientType.DESTINATION_CHAIN,
|
|
32
|
-
deadline: (0,
|
|
34
|
+
deadline: (0, helpers_2.getNearIntentsQuoteDeadline)({ sellAsset, buyAsset }),
|
|
33
35
|
});
|
|
34
|
-
const maybeQuoteResponse = await (0,
|
|
36
|
+
const maybeQuoteResponse = await (0, helpers_2.fetchNearIntentsQuote)({ quoteRequest, sellAsset });
|
|
35
37
|
if (maybeQuoteResponse.isErr())
|
|
36
38
|
return (0, monads_1.Err)(maybeQuoteResponse.unwrapErr());
|
|
37
39
|
const { quote } = maybeQuoteResponse.unwrap();
|
|
@@ -75,4 +77,7 @@ const getTradeQuote = async (input, deps) => {
|
|
|
75
77
|
};
|
|
76
78
|
return (0, monads_1.Ok)([tradeQuote]);
|
|
77
79
|
};
|
|
80
|
+
const getTradeQuote = (input, deps) => getQuote(input, deps);
|
|
78
81
|
exports.getTradeQuote = getTradeQuote;
|
|
82
|
+
const getExactOutputTradeQuote = (input, deps) => getQuote(input, deps);
|
|
83
|
+
exports.getExactOutputTradeQuote = getExactOutputTradeQuote;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Result } from '@sniptt/monads';
|
|
2
2
|
import type { SwapErrorRight, SwapperDeps, TradeRate } from '../../../types';
|
|
3
|
-
import type { NearIntentsTradeRateInput } from '../types';
|
|
3
|
+
import type { NearIntentsExactOutputTradeRateInput, NearIntentsTradeRateInput } from '../types';
|
|
4
4
|
export declare const getTradeRate: (input: NearIntentsTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate[], SwapErrorRight>>;
|
|
5
|
+
export declare const getExactOutputTradeRate: (input: NearIntentsExactOutputTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate[], SwapErrorRight>>;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTradeRate = void 0;
|
|
3
|
+
exports.getExactOutputTradeRate = exports.getTradeRate = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
|
+
const helpers_1 = require("../../../utils/helpers");
|
|
5
6
|
const types_1 = require("../types");
|
|
6
7
|
const getNearIntentsStepData_1 = require("../utils/getNearIntentsStepData");
|
|
7
8
|
const getNearIntentsTradeContext_1 = require("../utils/getNearIntentsTradeContext");
|
|
8
|
-
const
|
|
9
|
+
const helpers_2 = require("../utils/helpers");
|
|
9
10
|
const oneClickService_1 = require("../utils/oneClickService");
|
|
10
|
-
const
|
|
11
|
-
const { accountNumber, sellAsset, buyAsset, affiliateBps,
|
|
11
|
+
const getRate = async (input, deps) => {
|
|
12
|
+
const { accountNumber, sellAsset, buyAsset, affiliateBps, receiveAddress, sendAddress } = input;
|
|
12
13
|
(0, oneClickService_1.initializeOneClickService)(deps.config.VITE_NEAR_INTENTS_API_KEY);
|
|
13
|
-
const
|
|
14
|
+
const amount = (0, helpers_1.getTradeAmount)(input);
|
|
15
|
+
const maybeAssets = await (0, helpers_2.resolveNearIntentsAssets)({ sellAsset, buyAsset });
|
|
14
16
|
if (maybeAssets.isErr())
|
|
15
17
|
return (0, monads_1.Err)(maybeAssets.unwrapErr());
|
|
16
18
|
const { originAsset, destinationAsset } = maybeAssets.unwrap();
|
|
17
|
-
const quoteRequest = (0,
|
|
19
|
+
const quoteRequest = (0, helpers_2.buildNearIntentsQuoteRequest)({
|
|
18
20
|
originAsset,
|
|
19
21
|
destinationAsset,
|
|
20
|
-
|
|
22
|
+
amount,
|
|
21
23
|
slippageTolerancePercentageDecimal: input.slippageTolerancePercentageDecimal,
|
|
22
24
|
affiliateBps,
|
|
23
25
|
refundTo: sendAddress ?? 'check-price',
|
|
@@ -28,9 +30,9 @@ const getTradeRate = async (input, deps) => {
|
|
|
28
30
|
recipientType: sendAddress
|
|
29
31
|
? types_1.QuoteRequest.recipientType.DESTINATION_CHAIN
|
|
30
32
|
: types_1.QuoteRequest.recipientType.INTENTS,
|
|
31
|
-
deadline: (0,
|
|
33
|
+
deadline: (0, helpers_2.getNearIntentsQuoteDeadline)({ sellAsset, buyAsset }),
|
|
32
34
|
});
|
|
33
|
-
const maybeQuoteResponse = await (0,
|
|
35
|
+
const maybeQuoteResponse = await (0, helpers_2.fetchNearIntentsQuote)({ quoteRequest, sellAsset });
|
|
34
36
|
if (maybeQuoteResponse.isErr())
|
|
35
37
|
return (0, monads_1.Err)(maybeQuoteResponse.unwrapErr());
|
|
36
38
|
const { quote } = maybeQuoteResponse.unwrap();
|
|
@@ -61,4 +63,7 @@ const getTradeRate = async (input, deps) => {
|
|
|
61
63
|
};
|
|
62
64
|
return (0, monads_1.Ok)([tradeRate]);
|
|
63
65
|
};
|
|
66
|
+
const getTradeRate = (input, deps) => getRate(input, deps);
|
|
64
67
|
exports.getTradeRate = getTradeRate;
|
|
68
|
+
const getExactOutputTradeRate = (input, deps) => getRate(input, deps);
|
|
69
|
+
exports.getExactOutputTradeRate = getExactOutputTradeRate;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
|
-
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetNearTradeQuoteInput, GetNearTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput, GetStarknetTradeQuoteInput, GetStarknetTradeRateInput, GetSuiTradeQuoteInput, GetSuiTradeRateInput, GetTonTradeQuoteInput, GetTonTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput, GetUtxoTradeQuoteInput, GetUtxoTradeRateInput } from '../../types';
|
|
2
|
+
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetNearTradeQuoteInput, GetNearTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput, GetStarknetTradeQuoteInput, GetStarknetTradeRateInput, GetSuiTradeQuoteInput, GetSuiTradeRateInput, GetTonTradeQuoteInput, GetTonTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput, GetUtxoTradeQuoteInput, GetUtxoTradeRateInput, WithExactBuyAmount } from '../../types';
|
|
3
3
|
export type NearIntentsTradeQuoteInput = GetEvmTradeQuoteInput | GetUtxoTradeQuoteInput | GetSolanaTradeQuoteInput | GetTronTradeQuoteInput | GetSuiTradeQuoteInput | GetStarknetTradeQuoteInput | GetNearTradeQuoteInput | GetTonTradeQuoteInput;
|
|
4
4
|
export type NearIntentsTradeRateInput = GetEvmTradeRateInput | GetUtxoTradeRateInput | GetSolanaTradeRateInput | GetTronTradeRateInput | GetSuiTradeRateInput | GetStarknetTradeRateInput | GetNearTradeRateInput | GetTonTradeRateInput;
|
|
5
|
+
export type NearIntentsExactOutputTradeQuoteInput = WithExactBuyAmount<NearIntentsTradeQuoteInput>;
|
|
6
|
+
export type NearIntentsExactOutputTradeRateInput = WithExactBuyAmount<NearIntentsTradeRateInput>;
|
|
5
7
|
export type NearIntentsMetadata = {
|
|
6
8
|
name: 'nearIntents';
|
|
7
9
|
depositAddress: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
const BASE_ARGS = {
|
|
7
|
+
originAsset: 'nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near',
|
|
8
|
+
destinationAsset: 'nep141:btc.omft.near',
|
|
9
|
+
amount: { direction: 'exactIn', cryptoBaseUnit: '65000000' },
|
|
10
|
+
slippageTolerancePercentageDecimal: '0.01',
|
|
11
|
+
affiliateBps: '10',
|
|
12
|
+
refundTo: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
13
|
+
recipient: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4',
|
|
14
|
+
refundType: types_1.QuoteRequest.refundType.ORIGIN_CHAIN,
|
|
15
|
+
recipientType: types_1.QuoteRequest.recipientType.DESTINATION_CHAIN,
|
|
16
|
+
deadline: '2026-08-10T23:59:00.000Z',
|
|
17
|
+
};
|
|
18
|
+
const EXACT_OUTPUT_AMOUNT = {
|
|
19
|
+
direction: 'exactOut',
|
|
20
|
+
cryptoBaseUnit: '100000',
|
|
21
|
+
};
|
|
22
|
+
(0, vitest_1.describe)('buildNearIntentsQuoteRequest', () => {
|
|
23
|
+
(0, vitest_1.describe)('exact input', () => {
|
|
24
|
+
(0, vitest_1.it)('requests EXACT_INPUT with the sell amount', () => {
|
|
25
|
+
const request = (0, helpers_1.buildNearIntentsQuoteRequest)(BASE_ARGS);
|
|
26
|
+
(0, vitest_1.expect)(request.swapType).toEqual(types_1.QuoteRequest.swapType.EXACT_INPUT);
|
|
27
|
+
(0, vitest_1.expect)(request.amount).toEqual('65000000');
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)('passes the requested slippage through untouched', () => {
|
|
30
|
+
const request = (0, helpers_1.buildNearIntentsQuoteRequest)({
|
|
31
|
+
...BASE_ARGS,
|
|
32
|
+
slippageTolerancePercentageDecimal: '0',
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.expect)(request.slippageTolerance).toEqual(0);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
(0, vitest_1.describe)('exact output', () => {
|
|
38
|
+
(0, vitest_1.it)('requests EXACT_OUTPUT with the buy amount', () => {
|
|
39
|
+
const request = (0, helpers_1.buildNearIntentsQuoteRequest)({ ...BASE_ARGS, amount: EXACT_OUTPUT_AMOUNT });
|
|
40
|
+
(0, vitest_1.expect)(request.swapType).toEqual(types_1.QuoteRequest.swapType.EXACT_OUTPUT);
|
|
41
|
+
(0, vitest_1.expect)(request.amount).toEqual('100000');
|
|
42
|
+
});
|
|
43
|
+
// A tighter band is the user's call - the failure mode is a refund, not a loss
|
|
44
|
+
(0, vitest_1.it)('passes a requested zero slippage through untouched, as exact input does', () => {
|
|
45
|
+
const request = (0, helpers_1.buildNearIntentsQuoteRequest)({
|
|
46
|
+
...BASE_ARGS,
|
|
47
|
+
amount: EXACT_OUTPUT_AMOUNT,
|
|
48
|
+
slippageTolerancePercentageDecimal: '0',
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.expect)(request.slippageTolerance).toEqual(0);
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.it)('honours a requested slippage', () => {
|
|
53
|
+
const request = (0, helpers_1.buildNearIntentsQuoteRequest)({
|
|
54
|
+
...BASE_ARGS,
|
|
55
|
+
amount: EXACT_OUTPUT_AMOUNT,
|
|
56
|
+
slippageTolerancePercentageDecimal: '0.05',
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.expect)(request.slippageTolerance).toEqual(500);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import type { Result } from '@sniptt/monads';
|
|
3
3
|
import type { QuoteFeeData, SwapErrorRight, SwapperDeps, TradeCommon, TradeStepCommon } from '../../../types';
|
|
4
|
-
import type { NearIntentsTradeQuoteInput, NearIntentsTradeRateInput, QuoteResponse } from '../types';
|
|
4
|
+
import type { NearIntentsExactOutputTradeQuoteInput, NearIntentsExactOutputTradeRateInput, NearIntentsTradeQuoteInput, NearIntentsTradeRateInput, QuoteResponse } from '../types';
|
|
5
5
|
type NearIntentsTradeContext = {
|
|
6
6
|
tradeCommon: TradeCommon;
|
|
7
7
|
stepCommon: Omit<TradeStepCommon, 'feeData'>;
|
|
@@ -14,7 +14,7 @@ type NearIntentsTradeContext = {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export declare const getNearIntentsTradeContext: ({ input, deps, quote, }: {
|
|
17
|
-
input: NearIntentsTradeQuoteInput | NearIntentsTradeRateInput;
|
|
17
|
+
input: NearIntentsTradeQuoteInput | NearIntentsTradeRateInput | NearIntentsExactOutputTradeQuoteInput | NearIntentsExactOutputTradeRateInput;
|
|
18
18
|
deps: SwapperDeps;
|
|
19
19
|
quote: QuoteResponse['quote'];
|
|
20
20
|
}) => Result<NearIntentsTradeContext, SwapErrorRight>;
|
|
@@ -10,7 +10,7 @@ const types_1 = require("../../../types");
|
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
11
|
const affiliateFee_1 = require("../../../utils/affiliateFee");
|
|
12
12
|
const getNearIntentsTradeContext = ({ input, deps, quote, }) => {
|
|
13
|
-
const { sellAsset, buyAsset, affiliateBps,
|
|
13
|
+
const { sellAsset, buyAsset, affiliateBps, slippageTolerancePercentageDecimal } = input;
|
|
14
14
|
if (!quote.depositAddress)
|
|
15
15
|
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getNearIntentsTradeContext'));
|
|
16
16
|
const rate = (0, utils_2.getInputOutputRate)({
|
|
@@ -19,11 +19,13 @@ const getNearIntentsTradeContext = ({ input, deps, quote, }) => {
|
|
|
19
19
|
sellAsset,
|
|
20
20
|
buyAsset,
|
|
21
21
|
});
|
|
22
|
+
const isExactOutput = 'buyAmountCryptoBaseUnit' in input;
|
|
22
23
|
return (0, monads_1.Ok)({
|
|
23
24
|
tradeCommon: {
|
|
24
25
|
id: (0, uuid_1.v4)(),
|
|
25
26
|
rate,
|
|
26
27
|
swapperName: types_1.SwapperName.NearIntents,
|
|
28
|
+
isExactOutput,
|
|
27
29
|
affiliateBps,
|
|
28
30
|
slippageTolerancePercentageDecimal: slippageTolerancePercentageDecimal ??
|
|
29
31
|
(0, constants_1.getDefaultSlippageDecimalPercentageForSwapper)(types_1.SwapperName.NearIntents),
|
|
@@ -54,7 +56,7 @@ const getNearIntentsTradeContext = ({ input, deps, quote, }) => {
|
|
|
54
56
|
stepDataArgs: {
|
|
55
57
|
deps,
|
|
56
58
|
sellAsset,
|
|
57
|
-
sellAmountCryptoBaseUnit:
|
|
59
|
+
sellAmountCryptoBaseUnit: quote.amountIn,
|
|
58
60
|
depositAddress: quote.depositAddress,
|
|
59
61
|
},
|
|
60
62
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import { TxStatus } from '@shapeshiftoss/unchained-client';
|
|
3
3
|
import type { Result } from '@sniptt/monads';
|
|
4
|
-
import type { SwapErrorRight } from '../../../types';
|
|
4
|
+
import type { SwapErrorRight, TradeAmount } from '../../../types';
|
|
5
5
|
import type { GetExecutionStatusResponse, QuoteResponse } from '../types';
|
|
6
6
|
import { QuoteRequest } from '../types';
|
|
7
7
|
export declare const getNearIntentsAsset: ({ nearNetwork, contractAddress, }: {
|
|
@@ -17,13 +17,13 @@ export declare const resolveNearIntentsAssets: ({ sellAsset, buyAsset, }: {
|
|
|
17
17
|
destinationAsset: string;
|
|
18
18
|
}, SwapErrorRight>>;
|
|
19
19
|
export declare const getNearIntentsQuoteDeadline: ({ sellAsset, buyAsset, }: {
|
|
20
|
-
sellAsset: Asset
|
|
21
|
-
buyAsset: Asset
|
|
20
|
+
sellAsset: Pick<Asset, 'chainId'>;
|
|
21
|
+
buyAsset: Pick<Asset, 'chainId'>;
|
|
22
22
|
}) => string;
|
|
23
|
-
export declare const buildNearIntentsQuoteRequest: ({ originAsset, destinationAsset,
|
|
23
|
+
export declare const buildNearIntentsQuoteRequest: ({ originAsset, destinationAsset, amount, slippageTolerancePercentageDecimal, affiliateBps, refundTo, recipient, refundType, recipientType, deadline, }: {
|
|
24
24
|
originAsset: string;
|
|
25
25
|
destinationAsset: string;
|
|
26
|
-
|
|
26
|
+
amount: TradeAmount;
|
|
27
27
|
slippageTolerancePercentageDecimal: string | undefined;
|
|
28
28
|
affiliateBps: string;
|
|
29
29
|
refundTo: string;
|
|
@@ -126,37 +126,41 @@ const resolveNearIntentsAssets = async ({ sellAsset, buyAsset, }) => {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
exports.resolveNearIntentsAssets = resolveNearIntentsAssets;
|
|
129
|
-
|
|
129
|
+
const isUtxoChainId = (chainId) => (0, caip_1.fromChainId)(chainId).chainNamespace === caip_1.CHAIN_NAMESPACE.Utxo;
|
|
130
130
|
const getNearIntentsQuoteDeadline = ({ sellAsset, buyAsset, }) => {
|
|
131
|
-
const deadlineMs = sellAsset.chainId
|
|
132
|
-
? constants_1.
|
|
131
|
+
const deadlineMs = isUtxoChainId(sellAsset.chainId) || isUtxoChainId(buyAsset.chainId)
|
|
132
|
+
? constants_1.UTXO_QUOTE_DEADLINE_MS
|
|
133
133
|
: constants_1.DEFAULT_QUOTE_DEADLINE_MS;
|
|
134
134
|
return new Date(Date.now() + deadlineMs).toISOString();
|
|
135
135
|
};
|
|
136
136
|
exports.getNearIntentsQuoteDeadline = getNearIntentsQuoteDeadline;
|
|
137
|
-
const buildNearIntentsQuoteRequest = ({ originAsset, destinationAsset,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
137
|
+
const buildNearIntentsQuoteRequest = ({ originAsset, destinationAsset, amount, slippageTolerancePercentageDecimal, affiliateBps, refundTo, recipient, refundType, recipientType, deadline, }) => {
|
|
138
|
+
return {
|
|
139
|
+
dry: false,
|
|
140
|
+
swapType: amount.direction === 'exactOut'
|
|
141
|
+
? types_2.QuoteRequest.swapType.EXACT_OUTPUT
|
|
142
|
+
: types_2.QuoteRequest.swapType.EXACT_INPUT,
|
|
143
|
+
slippageTolerance: slippageTolerancePercentageDecimal
|
|
144
|
+
? (0, utils_1.bnOrZero)(slippageTolerancePercentageDecimal).times(10000).toNumber()
|
|
145
|
+
: constants_1.DEFAULT_SLIPPAGE_BPS,
|
|
146
|
+
originAsset,
|
|
147
|
+
destinationAsset,
|
|
148
|
+
amount: amount.cryptoBaseUnit,
|
|
149
|
+
depositType: types_2.QuoteRequest.depositType.ORIGIN_CHAIN,
|
|
150
|
+
refundTo,
|
|
151
|
+
refundType,
|
|
152
|
+
recipient,
|
|
153
|
+
recipientType,
|
|
154
|
+
deadline,
|
|
155
|
+
referral: 'shapeshift',
|
|
156
|
+
appFees: [
|
|
157
|
+
{
|
|
158
|
+
recipient: utils_1.DAO_TREASURY_NEAR,
|
|
159
|
+
fee: Number(affiliateBps),
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
};
|
|
160
164
|
exports.buildNearIntentsQuoteRequest = buildNearIntentsQuoteRequest;
|
|
161
165
|
// One retry loop for the SDK's flaky WebSocket transport; maps provider errors to swap errors
|
|
162
166
|
const fetchNearIntentsQuote = async ({ quoteRequest, sellAsset, }) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const asset = (chainId) => ({ chainId });
|
|
8
|
+
(0, vitest_1.describe)('getNearIntentsQuoteDeadline', () => {
|
|
9
|
+
(0, vitest_1.beforeEach)(() => {
|
|
10
|
+
vitest_1.vi.useFakeTimers();
|
|
11
|
+
vitest_1.vi.setSystemTime(new Date('2026-09-10T22:00:00.000Z'));
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.afterEach)(() => {
|
|
14
|
+
vitest_1.vi.useRealTimers();
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('gives a utxo sell leg the long deadline', () => {
|
|
17
|
+
(0, vitest_1.expect)(Date.parse((0, helpers_1.getNearIntentsQuoteDeadline)({ sellAsset: asset(caip_1.btcChainId), buyAsset: asset(caip_1.ethChainId) }))).toBe(Date.now() + constants_1.UTXO_QUOTE_DEADLINE_MS);
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('gives a utxo buy leg the long deadline, on any utxo chain', () => {
|
|
20
|
+
(0, vitest_1.expect)(Date.parse((0, helpers_1.getNearIntentsQuoteDeadline)({ sellAsset: asset(caip_1.ethChainId), buyAsset: asset(caip_1.dogeChainId) }))).toBe(Date.now() + constants_1.UTXO_QUOTE_DEADLINE_MS);
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.it)('gives everything else the default deadline', () => {
|
|
23
|
+
(0, vitest_1.expect)(Date.parse((0, helpers_1.getNearIntentsQuoteDeadline)({
|
|
24
|
+
sellAsset: asset(caip_1.ethChainId),
|
|
25
|
+
buyAsset: asset(caip_1.solanaChainId),
|
|
26
|
+
}))).toBe(Date.now() + constants_1.DEFAULT_QUOTE_DEADLINE_MS);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -4,17 +4,29 @@ exports.portalsApi = void 0;
|
|
|
4
4
|
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const evm_1 = require("../../utils/evm");
|
|
7
|
+
const relayStatus_1 = require("../RelaySwapper/utils/relayStatus");
|
|
7
8
|
const getPortalsTradeQuote_1 = require("./getPortalsTradeQuote/getPortalsTradeQuote");
|
|
8
9
|
const getPortalsTradeRate_1 = require("./getPortalsTradeRate/getPortalsTradeRate");
|
|
9
10
|
const fetchAxelarscanStatus_1 = require("./utils/fetchAxelarscanStatus");
|
|
10
11
|
const fetchSquidStatus_1 = require("./utils/fetchSquidStatus");
|
|
12
|
+
const bridgeStatusToTxStatus = (status) => {
|
|
13
|
+
switch (status) {
|
|
14
|
+
case 'confirmed':
|
|
15
|
+
return unchained_client_1.TxStatus.Confirmed;
|
|
16
|
+
case 'failed':
|
|
17
|
+
return unchained_client_1.TxStatus.Failed;
|
|
18
|
+
case 'pending':
|
|
19
|
+
default:
|
|
20
|
+
return unchained_client_1.TxStatus.Pending;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
11
23
|
exports.portalsApi = {
|
|
12
24
|
getTradeQuote: (input, deps) => (0, getPortalsTradeQuote_1.getPortalsTradeQuote)(input, deps),
|
|
13
25
|
getTradeRate: (input, deps) => (0, getPortalsTradeRate_1.getPortalsTradeRate)(input, deps),
|
|
14
26
|
getEvmTransactionFees: evm_1.getEvmTransactionFees,
|
|
15
27
|
getUnsignedEvmTransaction: evm_1.getUnsignedEvmTransaction,
|
|
16
28
|
checkTradeStatus: async (input) => {
|
|
17
|
-
const { txHash, chainId, swap, assertGetEvmChainAdapter, address, fetchIsSmartContractAddressQuery, } = input;
|
|
29
|
+
const { txHash, chainId, swap, config, assertGetEvmChainAdapter, address, fetchIsSmartContractAddressQuery, } = input;
|
|
18
30
|
const isCrossChain = Boolean(swap && swap.sellAsset.chainId !== swap.buyAsset?.chainId);
|
|
19
31
|
if (!isCrossChain) {
|
|
20
32
|
return (0, utils_1.checkEvmSwapStatus)({
|
|
@@ -42,64 +54,56 @@ exports.portalsApi = {
|
|
|
42
54
|
if (sourceTxStatus.status === unchained_client_1.TxStatus.Failed) {
|
|
43
55
|
return sourceTxStatus;
|
|
44
56
|
}
|
|
57
|
+
const relayResult = await (0, relayStatus_1.fetchRelayRequestByTxHash)(txHash, config);
|
|
58
|
+
if (relayResult.isOk()) {
|
|
59
|
+
const relayRequest = relayResult.unwrap();
|
|
60
|
+
if (relayRequest) {
|
|
61
|
+
const relayTxStatus = (0, relayStatus_1.relayStatusToTxStatus)(relayRequest.status);
|
|
62
|
+
const txStatus = relayTxStatus === unchained_client_1.TxStatus.Unknown ? unchained_client_1.TxStatus.Pending : relayTxStatus;
|
|
63
|
+
return {
|
|
64
|
+
status: txStatus,
|
|
65
|
+
buyTxHash: relayRequest.data?.outTxs?.[0]?.hash,
|
|
66
|
+
message: txStatus === unchained_client_1.TxStatus.Failed
|
|
67
|
+
? (0, relayStatus_1.getRelayRequestFailureMessage)(relayRequest)
|
|
68
|
+
: txStatus === unchained_client_1.TxStatus.Confirmed
|
|
69
|
+
? undefined
|
|
70
|
+
: 'Bridge in progress',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
45
74
|
const axelarscanResult = await (0, fetchAxelarscanStatus_1.fetchAxelarscanBridgeStatus)(txHash);
|
|
46
|
-
if (
|
|
75
|
+
if (axelarscanResult.isOk()) {
|
|
76
|
+
const bridgeStatus = axelarscanResult.unwrap();
|
|
77
|
+
if (bridgeStatus) {
|
|
78
|
+
const txStatus = bridgeStatusToTxStatus(bridgeStatus.status);
|
|
79
|
+
return {
|
|
80
|
+
status: txStatus,
|
|
81
|
+
buyTxHash: bridgeStatus.destinationTxHash,
|
|
82
|
+
message: txStatus === unchained_client_1.TxStatus.Pending
|
|
83
|
+
? 'Bridge in progress'
|
|
84
|
+
: txStatus === unchained_client_1.TxStatus.Failed
|
|
85
|
+
? bridgeStatus.errorMessage
|
|
86
|
+
: undefined,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (swap) {
|
|
47
91
|
const squidResult = await (0, fetchSquidStatus_1.fetchSquidBridgeStatus)(txHash, swap.sellAsset.chainId, swap.buyAsset.chainId);
|
|
48
92
|
if (squidResult.isOk()) {
|
|
49
93
|
const squidStatus = squidResult.unwrap();
|
|
50
|
-
const squidTxStatus = (
|
|
51
|
-
switch (squidStatus.status) {
|
|
52
|
-
case 'confirmed':
|
|
53
|
-
return unchained_client_1.TxStatus.Confirmed;
|
|
54
|
-
case 'failed':
|
|
55
|
-
return unchained_client_1.TxStatus.Failed;
|
|
56
|
-
case 'pending':
|
|
57
|
-
default:
|
|
58
|
-
return unchained_client_1.TxStatus.Pending;
|
|
59
|
-
}
|
|
60
|
-
})();
|
|
94
|
+
const squidTxStatus = bridgeStatusToTxStatus(squidStatus.status);
|
|
61
95
|
return {
|
|
62
96
|
status: squidTxStatus,
|
|
63
97
|
buyTxHash: squidStatus.destinationTxHash,
|
|
64
|
-
swapperTxLink: (0, fetchSquidStatus_1.getSquidTrackingLink)(txHash, squidStatus, swap.sellAsset.explorerTxLink, swap.buyAsset.explorerTxLink),
|
|
65
98
|
message: squidTxStatus === unchained_client_1.TxStatus.Pending ? 'Cross-chain swap in progress' : undefined,
|
|
66
99
|
};
|
|
67
100
|
}
|
|
68
|
-
return {
|
|
69
|
-
status: unchained_client_1.TxStatus.Pending,
|
|
70
|
-
buyTxHash: undefined,
|
|
71
|
-
swapperTxLink: (0, fetchAxelarscanStatus_1.getAxelarscanTrackingLink)(txHash),
|
|
72
|
-
message: 'Bridge status check failed - track manually',
|
|
73
|
-
};
|
|
74
101
|
}
|
|
75
|
-
|
|
76
|
-
if (!bridgeStatus) {
|
|
77
|
-
return {
|
|
78
|
-
status: unchained_client_1.TxStatus.Pending,
|
|
79
|
-
buyTxHash: undefined,
|
|
80
|
-
message: 'Cross-chain swap in progress',
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const txStatus = (() => {
|
|
84
|
-
switch (bridgeStatus.status) {
|
|
85
|
-
case 'confirmed':
|
|
86
|
-
return unchained_client_1.TxStatus.Confirmed;
|
|
87
|
-
case 'failed':
|
|
88
|
-
return unchained_client_1.TxStatus.Failed;
|
|
89
|
-
case 'pending':
|
|
90
|
-
default:
|
|
91
|
-
return unchained_client_1.TxStatus.Pending;
|
|
92
|
-
}
|
|
93
|
-
})();
|
|
102
|
+
// No indexer knows the tx yet - the bridge may not have picked it up, so keep polling
|
|
94
103
|
return {
|
|
95
|
-
status:
|
|
96
|
-
buyTxHash:
|
|
97
|
-
|
|
98
|
-
message: txStatus === unchained_client_1.TxStatus.Pending
|
|
99
|
-
? 'Bridge in progress'
|
|
100
|
-
: txStatus === unchained_client_1.TxStatus.Failed
|
|
101
|
-
? bridgeStatus.errorMessage
|
|
102
|
-
: undefined,
|
|
104
|
+
status: unchained_client_1.TxStatus.Pending,
|
|
105
|
+
buyTxHash: undefined,
|
|
106
|
+
message: 'Cross-chain swap in progress',
|
|
103
107
|
};
|
|
104
108
|
},
|
|
105
109
|
};
|
|
@@ -6,4 +6,3 @@ export type AxelarscanBridgeStatus = {
|
|
|
6
6
|
errorMessage?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const fetchAxelarscanBridgeStatus: (sourceTxHash: string) => Promise<Result<AxelarscanBridgeStatus | undefined, SwapErrorRight>>;
|
|
9
|
-
export declare const getAxelarscanTrackingLink: (sourceTxHash: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchAxelarscanBridgeStatus = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
6
|
const fetchAxelarscanBridgeStatus = async (sourceTxHash) => {
|
|
@@ -16,9 +16,8 @@ const fetchAxelarscanBridgeStatus = async (sourceTxHash) => {
|
|
|
16
16
|
return (0, monads_1.Ok)(undefined);
|
|
17
17
|
}
|
|
18
18
|
const bridgeData = data.data[0];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
bridgeData.express_executed?.transactionHash;
|
|
19
|
+
// `call` is the origin call, so only the executed hashes identify the destination leg
|
|
20
|
+
const destinationTxHash = bridgeData.executed?.transaction_hash || bridgeData.express_executed?.transactionHash;
|
|
22
21
|
const isCompleted = bridgeData.status === 'executed' ||
|
|
23
22
|
bridgeData.status === 'destination_executed' ||
|
|
24
23
|
bridgeData.status === 'express_executed' ||
|
|
@@ -48,5 +47,3 @@ const fetchAxelarscanBridgeStatus = async (sourceTxHash) => {
|
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
49
|
exports.fetchAxelarscanBridgeStatus = fetchAxelarscanBridgeStatus;
|
|
51
|
-
const getAxelarscanTrackingLink = (sourceTxHash) => `https://axelarscan.io/gmp/${sourceTxHash}`;
|
|
52
|
-
exports.getAxelarscanTrackingLink = getAxelarscanTrackingLink;
|
|
@@ -23,9 +23,11 @@ const fetchPortalsTradeOrder = async ({ sender, inputToken, inputAmount, outputT
|
|
|
23
23
|
validate: validate.toString(),
|
|
24
24
|
});
|
|
25
25
|
if (!autoSlippage) {
|
|
26
|
-
|
|
26
|
+
// Portals API expects a string with at most 2 decimal places
|
|
27
|
+
params.append('slippageTolerancePercentage', slippageTolerancePercentage.toFixed(2));
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
// Portals defaults to their own partner fee when this is omitted - always send it, zero included
|
|
30
|
+
if (feePercentage !== undefined) {
|
|
29
31
|
params.append('feePercentage', feePercentage.toString());
|
|
30
32
|
}
|
|
31
33
|
try {
|
|
@@ -52,7 +54,8 @@ const fetchPortalsTradeEstimate = async ({ inputToken, inputAmount, outputToken,
|
|
|
52
54
|
outputToken,
|
|
53
55
|
});
|
|
54
56
|
if (slippageTolerancePercentage !== undefined) {
|
|
55
|
-
|
|
57
|
+
// Portals API expects a string with at most 2 decimal places
|
|
58
|
+
params.append('slippageTolerancePercentage', slippageTolerancePercentage.toFixed(2));
|
|
56
59
|
}
|
|
57
60
|
try {
|
|
58
61
|
const response = await axios_1.default.get(url, { params });
|
|
@@ -6,4 +6,3 @@ export type SquidBridgeStatus = {
|
|
|
6
6
|
destinationTxHash?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const fetchSquidBridgeStatus: (sourceTxHash: string, sourceChainId: ChainId, destinationChainId: ChainId) => Promise<Result<SquidBridgeStatus, SwapErrorRight>>;
|
|
9
|
-
export declare const getSquidTrackingLink: (sourceTxHash: string, squidStatus: SquidBridgeStatus, sellAssetExplorerTxLink: string, buyAssetExplorerTxLink: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchSquidBridgeStatus = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
@@ -48,10 +48,3 @@ const fetchSquidBridgeStatus = async (sourceTxHash, sourceChainId, destinationCh
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
exports.fetchSquidBridgeStatus = fetchSquidBridgeStatus;
|
|
51
|
-
const getSquidTrackingLink = (sourceTxHash, squidStatus, sellAssetExplorerTxLink, buyAssetExplorerTxLink) => {
|
|
52
|
-
if (squidStatus.status === 'confirmed' && squidStatus.destinationTxHash) {
|
|
53
|
-
return `${buyAssetExplorerTxLink}${squidStatus.destinationTxHash}`;
|
|
54
|
-
}
|
|
55
|
-
return `${sellAssetExplorerTxLink}${sourceTxHash}`;
|
|
56
|
-
};
|
|
57
|
-
exports.getSquidTrackingLink = getSquidTrackingLink;
|
|
@@ -3,6 +3,7 @@ import type { StepDataArgs, SwapErrorRight, TxBuildData } from '../../../types';
|
|
|
3
3
|
import type { PortalsTx } from './fetchPortalsTradeOrder';
|
|
4
4
|
type BaseArgs = {
|
|
5
5
|
tx: PortalsTx;
|
|
6
|
+
sellAmountCryptoBaseUnit: string;
|
|
6
7
|
spenderAddress: string;
|
|
7
8
|
};
|
|
8
9
|
export type GetPortalsStepDataArgs = StepDataArgs<BaseArgs, {
|