@shapeshiftoss/swapper 17.6.11 → 17.7.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/constants.js +16 -26
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/solana-utils/getUnsignedSolanaTransaction.js +4 -2
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +3 -1
- package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +14 -4
- package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +1 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +1 -1
- package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +7 -9
- package/dist/cjs/swappers/RelaySwapper/constant.js +3 -7
- package/dist/cjs/swappers/RelaySwapper/endpoints.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +12 -2
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +5 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +2 -1
- package/dist/cjs/tron-utils/getUnsignedTronTransaction.js +16 -0
- package/dist/cjs/types.d.ts +3 -6
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/utils.d.ts +3 -0
- package/dist/cjs/utils.js +9 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +0 -10
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/solana-utils/getUnsignedSolanaTransaction.js +3 -1
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +3 -1
- package/dist/esm/swappers/ChainflipSwapper/endpoints.js +14 -4
- package/dist/esm/swappers/ChainflipSwapper/types.d.ts +1 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +1 -1
- package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.js +7 -9
- package/dist/esm/swappers/RelaySwapper/constant.js +4 -8
- package/dist/esm/swappers/RelaySwapper/endpoints.js +2 -2
- package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +13 -3
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +5 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +2 -1
- package/dist/esm/tron-utils/getUnsignedTronTransaction.js +16 -0
- package/dist/esm/types.d.ts +3 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/utils.d.ts +3 -0
- package/dist/esm/utils.js +7 -2
- package/package.json +6 -7
- package/dist/cjs/swappers/JupiterSwapper/JupiterSwapper.d.ts +0 -2
- package/dist/cjs/swappers/JupiterSwapper/JupiterSwapper.js +0 -27
- package/dist/cjs/swappers/JupiterSwapper/endpoints.d.ts +0 -2
- package/dist/cjs/swappers/JupiterSwapper/endpoints.js +0 -15
- package/dist/cjs/swappers/JupiterSwapper/errorPatterns.d.ts +0 -15
- package/dist/cjs/swappers/JupiterSwapper/errorPatterns.js +0 -29
- package/dist/cjs/swappers/JupiterSwapper/idls/referral.d.ts +0 -739
- package/dist/cjs/swappers/JupiterSwapper/idls/referral.js +0 -741
- package/dist/cjs/swappers/JupiterSwapper/index.d.ts +0 -2
- package/dist/cjs/swappers/JupiterSwapper/index.js +0 -18
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeQuote.d.ts +0 -3
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +0 -223
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeRate.d.ts +0 -3
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeRate.js +0 -181
- package/dist/cjs/swappers/JupiterSwapper/utils/constants.d.ts +0 -9
- package/dist/cjs/swappers/JupiterSwapper/utils/constants.js +0 -14
- package/dist/cjs/swappers/JupiterSwapper/utils/helpers.d.ts +0 -56
- package/dist/cjs/swappers/JupiterSwapper/utils/helpers.js +0 -178
- package/dist/cjs/swappers/JupiterSwapper/utils/jupiterService.d.ts +0 -5
- package/dist/cjs/swappers/JupiterSwapper/utils/jupiterService.js +0 -15
- package/dist/esm/swappers/JupiterSwapper/JupiterSwapper.d.ts +0 -2
- package/dist/esm/swappers/JupiterSwapper/JupiterSwapper.js +0 -24
- package/dist/esm/swappers/JupiterSwapper/endpoints.d.ts +0 -2
- package/dist/esm/swappers/JupiterSwapper/endpoints.js +0 -12
- package/dist/esm/swappers/JupiterSwapper/errorPatterns.d.ts +0 -15
- package/dist/esm/swappers/JupiterSwapper/errorPatterns.js +0 -25
- package/dist/esm/swappers/JupiterSwapper/idls/referral.d.ts +0 -739
- package/dist/esm/swappers/JupiterSwapper/idls/referral.js +0 -738
- package/dist/esm/swappers/JupiterSwapper/index.d.ts +0 -2
- package/dist/esm/swappers/JupiterSwapper/index.js +0 -2
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeQuote.d.ts +0 -3
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +0 -219
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeRate.d.ts +0 -3
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeRate.js +0 -177
- package/dist/esm/swappers/JupiterSwapper/utils/constants.d.ts +0 -9
- package/dist/esm/swappers/JupiterSwapper/utils/constants.js +0 -11
- package/dist/esm/swappers/JupiterSwapper/utils/helpers.d.ts +0 -56
- package/dist/esm/swappers/JupiterSwapper/utils/helpers.js +0 -169
- package/dist/esm/swappers/JupiterSwapper/utils/jupiterService.d.ts +0 -5
- package/dist/esm/swappers/JupiterSwapper/utils/jupiterService.js +0 -12
package/dist/cjs/constants.js
CHANGED
|
@@ -20,23 +20,21 @@ const CowSwapper_1 = require("./swappers/CowSwapper/CowSwapper");
|
|
|
20
20
|
const endpoints_8 = require("./swappers/CowSwapper/endpoints");
|
|
21
21
|
const DebridgeSwapper_1 = require("./swappers/DebridgeSwapper");
|
|
22
22
|
const endpoints_9 = require("./swappers/DebridgeSwapper/endpoints");
|
|
23
|
-
const endpoints_10 = require("./swappers/
|
|
24
|
-
const JupiterSwapper_1 = require("./swappers/JupiterSwapper/JupiterSwapper");
|
|
25
|
-
const endpoints_11 = require("./swappers/MayachainSwapper/endpoints");
|
|
23
|
+
const endpoints_10 = require("./swappers/MayachainSwapper/endpoints");
|
|
26
24
|
const MayachainSwapper_1 = require("./swappers/MayachainSwapper/MayachainSwapper");
|
|
27
|
-
const
|
|
25
|
+
const endpoints_11 = require("./swappers/NearIntentsSwapper/endpoints");
|
|
28
26
|
const NearIntentsSwapper_1 = require("./swappers/NearIntentsSwapper/NearIntentsSwapper");
|
|
29
|
-
const
|
|
27
|
+
const endpoints_12 = require("./swappers/PortalsSwapper/endpoints");
|
|
30
28
|
const PortalsSwapper_1 = require("./swappers/PortalsSwapper/PortalsSwapper");
|
|
31
29
|
const RelaySwapper_1 = require("./swappers/RelaySwapper");
|
|
32
|
-
const
|
|
33
|
-
const
|
|
30
|
+
const endpoints_13 = require("./swappers/RelaySwapper/endpoints");
|
|
31
|
+
const endpoints_14 = require("./swappers/StonfiSwapper/endpoints");
|
|
34
32
|
const StonfiSwapper_1 = require("./swappers/StonfiSwapper/StonfiSwapper");
|
|
35
|
-
const
|
|
33
|
+
const endpoints_15 = require("./swappers/SunioSwapper/endpoints");
|
|
36
34
|
const SunioSwapper_1 = require("./swappers/SunioSwapper/SunioSwapper");
|
|
37
|
-
const
|
|
35
|
+
const endpoints_16 = require("./swappers/ThorchainSwapper/endpoints");
|
|
38
36
|
const ThorchainSwapper_1 = require("./swappers/ThorchainSwapper/ThorchainSwapper");
|
|
39
|
-
const
|
|
37
|
+
const endpoints_17 = require("./swappers/ZrxSwapper/endpoints");
|
|
40
38
|
const ZrxSwapper_1 = require("./swappers/ZrxSwapper/ZrxSwapper");
|
|
41
39
|
const types_1 = require("./types");
|
|
42
40
|
const utils_2 = require("./utils");
|
|
@@ -50,15 +48,15 @@ exports.QUOTE_TIMEOUT_ERROR = (0, utils_2.makeSwapErrorRight)({
|
|
|
50
48
|
exports.swappers = {
|
|
51
49
|
[types_1.SwapperName.Thorchain]: {
|
|
52
50
|
...ThorchainSwapper_1.thorchainSwapper,
|
|
53
|
-
...
|
|
51
|
+
...endpoints_16.thorchainApi,
|
|
54
52
|
},
|
|
55
53
|
[types_1.SwapperName.Mayachain]: {
|
|
56
54
|
...MayachainSwapper_1.mayachainSwapper,
|
|
57
|
-
...
|
|
55
|
+
...endpoints_10.mayachainApi,
|
|
58
56
|
},
|
|
59
57
|
[types_1.SwapperName.Zrx]: {
|
|
60
58
|
...ZrxSwapper_1.zrxSwapper,
|
|
61
|
-
...
|
|
59
|
+
...endpoints_17.zrxApi,
|
|
62
60
|
},
|
|
63
61
|
[types_1.SwapperName.CowSwap]: {
|
|
64
62
|
...CowSwapper_1.cowSwapper,
|
|
@@ -70,19 +68,15 @@ exports.swappers = {
|
|
|
70
68
|
},
|
|
71
69
|
[types_1.SwapperName.Portals]: {
|
|
72
70
|
...PortalsSwapper_1.portalsSwapper,
|
|
73
|
-
...
|
|
71
|
+
...endpoints_12.portalsApi,
|
|
74
72
|
},
|
|
75
73
|
[types_1.SwapperName.Chainflip]: {
|
|
76
74
|
...ChainflipSwapper_1.chainflipSwapper,
|
|
77
75
|
...endpoints_7.chainflipApi,
|
|
78
76
|
},
|
|
79
|
-
[types_1.SwapperName.Jupiter]: {
|
|
80
|
-
...JupiterSwapper_1.jupiterSwapper,
|
|
81
|
-
...endpoints_10.jupiterApi,
|
|
82
|
-
},
|
|
83
77
|
[types_1.SwapperName.Relay]: {
|
|
84
78
|
...RelaySwapper_1.relaySwapper,
|
|
85
|
-
...
|
|
79
|
+
...endpoints_13.relayApi,
|
|
86
80
|
},
|
|
87
81
|
[types_1.SwapperName.ButterSwap]: {
|
|
88
82
|
...ButterSwap_1.butterSwap,
|
|
@@ -94,7 +88,7 @@ exports.swappers = {
|
|
|
94
88
|
},
|
|
95
89
|
[types_1.SwapperName.NearIntents]: {
|
|
96
90
|
...NearIntentsSwapper_1.nearIntentsSwapper,
|
|
97
|
-
...
|
|
91
|
+
...endpoints_11.nearIntentsApi,
|
|
98
92
|
},
|
|
99
93
|
[types_1.SwapperName.Cetus]: {
|
|
100
94
|
...CetusSwapper_1.cetusSwapper,
|
|
@@ -102,7 +96,7 @@ exports.swappers = {
|
|
|
102
96
|
},
|
|
103
97
|
[types_1.SwapperName.Sunio]: {
|
|
104
98
|
...SunioSwapper_1.sunioSwapper,
|
|
105
|
-
...
|
|
99
|
+
...endpoints_15.sunioApi,
|
|
106
100
|
},
|
|
107
101
|
[types_1.SwapperName.Avnu]: {
|
|
108
102
|
...AvnuSwapper_1.avnuSwapper,
|
|
@@ -110,7 +104,7 @@ exports.swappers = {
|
|
|
110
104
|
},
|
|
111
105
|
[types_1.SwapperName.Stonfi]: {
|
|
112
106
|
...StonfiSwapper_1.stonfiSwapper,
|
|
113
|
-
...
|
|
107
|
+
...endpoints_14.stonfiApi,
|
|
114
108
|
},
|
|
115
109
|
[types_1.SwapperName.Across]: {
|
|
116
110
|
...AcrossSwapper_1.acrossSwapper,
|
|
@@ -158,8 +152,6 @@ const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
|
|
|
158
152
|
return DEFAULT_ARBITRUM_BRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
159
153
|
case types_1.SwapperName.Chainflip:
|
|
160
154
|
return DEFAULT_CHAINFLIP_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
161
|
-
case types_1.SwapperName.Jupiter:
|
|
162
|
-
throw new Error('Default slippage not supported by Jupiter');
|
|
163
155
|
case types_1.SwapperName.Relay:
|
|
164
156
|
throw new Error('Default slippage not supported by Relay');
|
|
165
157
|
case types_1.SwapperName.Across:
|
|
@@ -185,8 +177,6 @@ const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
|
|
|
185
177
|
exports.getDefaultSlippageDecimalPercentageForSwapper = getDefaultSlippageDecimalPercentageForSwapper;
|
|
186
178
|
const isAutoSlippageSupportedBySwapper = (swapperName) => {
|
|
187
179
|
switch (swapperName) {
|
|
188
|
-
case types_1.SwapperName.Jupiter:
|
|
189
|
-
return true;
|
|
190
180
|
case types_1.SwapperName.Relay:
|
|
191
181
|
case types_1.SwapperName.Across:
|
|
192
182
|
case types_1.SwapperName.Debridge:
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './swappers/ChainflipSwapper';
|
|
|
10
10
|
export * from './swappers/SunioSwapper';
|
|
11
11
|
export * from './swappers/CowSwapper';
|
|
12
12
|
export * from './swappers/DebridgeSwapper';
|
|
13
|
-
export * from './swappers/JupiterSwapper';
|
|
14
13
|
export * from './swappers/PortalsSwapper';
|
|
15
14
|
export * from './swappers/ThorchainSwapper';
|
|
16
15
|
export * from './swappers/MayachainSwapper';
|
package/dist/cjs/index.js
CHANGED
|
@@ -39,7 +39,6 @@ __exportStar(require("./swappers/ChainflipSwapper"), exports);
|
|
|
39
39
|
__exportStar(require("./swappers/SunioSwapper"), exports);
|
|
40
40
|
__exportStar(require("./swappers/CowSwapper"), exports);
|
|
41
41
|
__exportStar(require("./swappers/DebridgeSwapper"), exports);
|
|
42
|
-
__exportStar(require("./swappers/JupiterSwapper"), exports);
|
|
43
42
|
__exportStar(require("./swappers/PortalsSwapper"), exports);
|
|
44
43
|
__exportStar(require("./swappers/ThorchainSwapper"), exports);
|
|
45
44
|
__exportStar(require("./swappers/MayachainSwapper"), exports);
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUnsignedSolanaTransaction = void 0;
|
|
4
4
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
|
-
const JupiterSwapper_1 = require("../swappers/JupiterSwapper");
|
|
6
5
|
const utils_2 = require("../utils");
|
|
6
|
+
// Jupiter (and Relay which uses Jupiter under the hood) use 40% as a compute unit margin while
|
|
7
|
+
// calculating them, some TX reverts without this. For stability purposes we add 60% margin.
|
|
8
|
+
const COMPUTE_UNIT_MARGIN_MULTIPLIER = 1.6;
|
|
7
9
|
const getUnsignedSolanaTransaction = async ({ stepIndex, tradeQuote, from, assertGetSolanaChainAdapter, }) => {
|
|
8
10
|
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
9
11
|
throw new Error('Unable to execute a trade rate quote');
|
|
@@ -30,7 +32,7 @@ const getUnsignedSolanaTransaction = async ({ stepIndex, tradeQuote, from, asser
|
|
|
30
32
|
instructions: solanaInstructions,
|
|
31
33
|
// As always, as relay uses jupiter under the hood, we need to add the compute unit safety margin
|
|
32
34
|
computeUnitLimit: (0, utils_1.bnOrZero)(fast.chainSpecific.computeUnits)
|
|
33
|
-
.times(
|
|
35
|
+
.times(COMPUTE_UNIT_MARGIN_MULTIPLIER)
|
|
34
36
|
.toFixed(0),
|
|
35
37
|
computeUnitPrice: fast.chainSpecific.priorityFee,
|
|
36
38
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTradeQuote = void 0;
|
|
4
4
|
const avnu_sdk_1 = require("@avnu/avnu-sdk");
|
|
5
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
7
|
const monads_1 = require("@sniptt/monads");
|
|
7
8
|
const starknet_1 = require("starknet");
|
|
@@ -59,7 +60,8 @@ const getTradeQuote = async (input, deps) => {
|
|
|
59
60
|
takerAddress: normalizedSendAddress,
|
|
60
61
|
size: 1,
|
|
61
62
|
integratorFees: affiliateBps ? BigInt(affiliateBps) : undefined,
|
|
62
|
-
integratorFeeRecipient: (0, helpers_1.getTreasuryAddressFromChainId)(
|
|
63
|
+
integratorFeeRecipient: (0, helpers_1.getTreasuryAddressFromChainId)(caip_1.starknetChainId),
|
|
64
|
+
integratorName: 'shapeshift',
|
|
63
65
|
});
|
|
64
66
|
if (!quotes || quotes.length === 0) {
|
|
65
67
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -126,6 +126,9 @@ exports.chainflipApi = {
|
|
|
126
126
|
value,
|
|
127
127
|
chainSpecific: { from, tokenId },
|
|
128
128
|
});
|
|
129
|
+
// Chainflip deposit addresses are program-owned accounts that require more compute
|
|
130
|
+
// than a regular SOL transfer. Apply a safety margin to avoid "Computational budget exceeded".
|
|
131
|
+
const computeUnits = Math.ceil(Math.max(Number(fast.chainSpecific.computeUnits), 50_000) * 1.6);
|
|
129
132
|
return adapter.buildSendApiTransaction({
|
|
130
133
|
to,
|
|
131
134
|
from,
|
|
@@ -133,7 +136,7 @@ exports.chainflipApi = {
|
|
|
133
136
|
accountNumber,
|
|
134
137
|
chainSpecific: {
|
|
135
138
|
tokenId,
|
|
136
|
-
computeUnitLimit:
|
|
139
|
+
computeUnitLimit: String(computeUnits),
|
|
137
140
|
computeUnitPrice: fast.chainSpecific.priorityFee,
|
|
138
141
|
},
|
|
139
142
|
});
|
|
@@ -156,11 +159,16 @@ exports.chainflipApi = {
|
|
|
156
159
|
tokenId: (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId),
|
|
157
160
|
},
|
|
158
161
|
});
|
|
159
|
-
|
|
162
|
+
// Mirror the same compute budget boost as getUnsignedSolanaTransaction
|
|
163
|
+
// to avoid underquoting fees for Chainflip deposit addresses
|
|
164
|
+
const simulatedUnits = Number(fast.chainSpecific.computeUnits);
|
|
165
|
+
const boostedUnits = Math.ceil(Math.max(simulatedUnits, 50_000) * 1.6);
|
|
166
|
+
const ratio = simulatedUnits > 0 ? boostedUnits / simulatedUnits : 1;
|
|
167
|
+
return String(Math.ceil(Number(fast.txFee) * ratio));
|
|
160
168
|
},
|
|
161
169
|
checkTradeStatus: async ({ config, swap }) => {
|
|
162
170
|
const chainflipSwapId = swap?.metadata.chainflipSwapId;
|
|
163
|
-
if (
|
|
171
|
+
if (chainflipSwapId == null)
|
|
164
172
|
throw Error(`chainflipSwapId is required`);
|
|
165
173
|
const brokerUrl = config.VITE_CHAINFLIP_API_URL;
|
|
166
174
|
const apiKey = config.VITE_CHAINFLIP_API_KEY;
|
|
@@ -174,13 +182,14 @@ exports.chainflipApi = {
|
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
184
|
const { data: statusResponse } = maybeStatusResponse.unwrap();
|
|
177
|
-
const { status: { swapEgress }, } = statusResponse;
|
|
185
|
+
const { status: { swapEgress, swapId }, } = statusResponse;
|
|
178
186
|
// Assume no outbound Tx is a pending Tx
|
|
179
187
|
if (!swapEgress?.transactionReference) {
|
|
180
188
|
return {
|
|
181
189
|
buyTxHash: undefined,
|
|
182
190
|
status: unchained_client_1.TxStatus.Pending,
|
|
183
191
|
message: (0, getLatestChainflipStatusMessage_1.getLatestChainflipStatusMessage)(statusResponse),
|
|
192
|
+
chainflipSwapId: swapId ?? undefined,
|
|
184
193
|
};
|
|
185
194
|
}
|
|
186
195
|
// Assume as soon as we have an outbound Tx, the swap is complete.
|
|
@@ -189,6 +198,7 @@ exports.chainflipApi = {
|
|
|
189
198
|
buyTxHash: swapEgress.transactionReference,
|
|
190
199
|
status: unchained_client_1.TxStatus.Confirmed,
|
|
191
200
|
message: undefined,
|
|
201
|
+
chainflipSwapId: swapId ?? undefined,
|
|
192
202
|
};
|
|
193
203
|
},
|
|
194
204
|
};
|
|
@@ -3,6 +3,7 @@ import type { ChainflipBaasStatusSwap } from './models/ChainflipBaasStatusSwap';
|
|
|
3
3
|
export type ChainFlipStatus = {
|
|
4
4
|
status: {
|
|
5
5
|
state: 'waiting' | 'receiving' | 'swapping' | 'sending' | 'sent' | 'completed' | 'failed';
|
|
6
|
+
swapId?: string;
|
|
6
7
|
swap?: ChainflipBaasStatusSwap;
|
|
7
8
|
swapEgress?: ChainflipBaasStatusEgress;
|
|
8
9
|
};
|
|
@@ -13,7 +13,7 @@ export type DebridgeFetchQuoteParams = {
|
|
|
13
13
|
srcChainOrderAuthorityAddress?: string;
|
|
14
14
|
dstChainOrderAuthorityAddress?: string;
|
|
15
15
|
senderAddress?: string;
|
|
16
|
-
prependOperatingExpenses: 'true';
|
|
16
|
+
prependOperatingExpenses: 'true' | 'false';
|
|
17
17
|
affiliateFeePercent?: string;
|
|
18
18
|
affiliateFeeRecipient?: string;
|
|
19
19
|
};
|
|
@@ -60,7 +60,7 @@ async function getTrade({ input, deps, }) {
|
|
|
60
60
|
return input.receiveAddress;
|
|
61
61
|
})();
|
|
62
62
|
const affiliateFeePercent = (() => {
|
|
63
|
-
if (!(0, utils_1.isTreasuryChainId)(
|
|
63
|
+
if (!(0, utils_1.isTreasuryChainId)(sellAsset.chainId))
|
|
64
64
|
return undefined;
|
|
65
65
|
const bps = (0, utils_1.bnOrZero)(affiliateBps);
|
|
66
66
|
if (!bps.isFinite() || bps.lte(0))
|
|
@@ -71,10 +71,10 @@ async function getTrade({ input, deps, }) {
|
|
|
71
71
|
if (affiliateFeePercent === undefined)
|
|
72
72
|
return undefined;
|
|
73
73
|
try {
|
|
74
|
-
return (0, helpers_1.getTreasuryAddressFromChainId)(
|
|
74
|
+
return (0, helpers_1.getTreasuryAddressFromChainId)(sellAsset.chainId).toLowerCase();
|
|
75
75
|
}
|
|
76
76
|
catch (e) {
|
|
77
|
-
console.error(`[getTrade] Failed to get treasury address for chainId ${
|
|
77
|
+
console.error(`[getTrade] Failed to get treasury address for chainId ${sellAsset.chainId}, affiliate fee will not be applied`, e);
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
80
80
|
})();
|
|
@@ -107,7 +107,7 @@ async function getTrade({ input, deps, }) {
|
|
|
107
107
|
srcChainOrderAuthorityAddress: senderAddress,
|
|
108
108
|
dstChainOrderAuthorityAddress: recipientAddress,
|
|
109
109
|
senderAddress,
|
|
110
|
-
prependOperatingExpenses: '
|
|
110
|
+
prependOperatingExpenses: 'false',
|
|
111
111
|
affiliateFeePercent,
|
|
112
112
|
affiliateFeeRecipient,
|
|
113
113
|
}, deps.config);
|
|
@@ -122,9 +122,7 @@ async function getTrade({ input, deps, }) {
|
|
|
122
122
|
sellAsset,
|
|
123
123
|
buyAsset,
|
|
124
124
|
});
|
|
125
|
-
const
|
|
126
|
-
.plus((0, utils_1.bnOrZero)(quote.prependedOperatingExpenseCost))
|
|
127
|
-
.toFixed();
|
|
125
|
+
const fixFee = (0, utils_1.bnOrZero)(quote.fixFee).toFixed();
|
|
128
126
|
const buyAmountBeforeFeesCryptoBaseUnit = buyAmountAfterFeesCryptoBaseUnit;
|
|
129
127
|
const allowanceContract = (0, chain_adapters_1.isEvmChainId)(sellAsset.chainId) ? quote.tx.to : '';
|
|
130
128
|
const debridgeTransactionMetadata = {
|
|
@@ -158,10 +156,10 @@ async function getTrade({ input, deps, }) {
|
|
|
158
156
|
accountNumber,
|
|
159
157
|
feeData: {
|
|
160
158
|
networkFeeCryptoBaseUnit,
|
|
161
|
-
protocolFees: protocolFeeAssetIdForFees && (0, utils_1.bnOrZero)(
|
|
159
|
+
protocolFees: protocolFeeAssetIdForFees && (0, utils_1.bnOrZero)(fixFee).gt(0)
|
|
162
160
|
? {
|
|
163
161
|
[protocolFeeAssetIdForFees]: {
|
|
164
|
-
amountCryptoBaseUnit:
|
|
162
|
+
amountCryptoBaseUnit: fixFee,
|
|
165
163
|
asset: (0, utils_1.getBaseAsset)(sellAsset.chainId),
|
|
166
164
|
requiresBalance: true,
|
|
167
165
|
},
|
|
@@ -10,24 +10,19 @@ const viem_1 = require("viem");
|
|
|
10
10
|
const chains_1 = require("viem/chains");
|
|
11
11
|
const types_1 = require("../../types");
|
|
12
12
|
const types_2 = require("./utils/types");
|
|
13
|
+
// https://docs.relay.link/resources/supported-chains
|
|
13
14
|
exports.chainIdToRelayChainId = {
|
|
14
|
-
// https://docs.relay.link/resources/supported-chains
|
|
15
15
|
[caip_1.btcChainId]: 8253038,
|
|
16
16
|
[caip_1.ethChainId]: chains_1.mainnet.id,
|
|
17
17
|
[caip_1.arbitrumChainId]: chains_1.arbitrum.id,
|
|
18
18
|
[caip_1.baseChainId]: chains_1.base.id,
|
|
19
19
|
[caip_1.optimismChainId]: chains_1.optimism.id,
|
|
20
20
|
[caip_1.polygonChainId]: chains_1.polygon.id,
|
|
21
|
-
// https://docs.relay.link/resources/supported-chains
|
|
22
21
|
[caip_1.solanaChainId]: 792703809,
|
|
23
22
|
[caip_1.gnosisChainId]: chains_1.gnosis.id,
|
|
24
23
|
[caip_1.avalancheChainId]: chains_1.avalanche.id,
|
|
25
24
|
[caip_1.bscChainId]: chains_1.bsc.id,
|
|
26
|
-
|
|
27
|
-
// and the Relay indexer notification is never sent for non-EVM chains. This causes deposits to be
|
|
28
|
-
// untracked by Relay, resulting in stuck/lost funds. Re-enable once the Tron transaction building
|
|
29
|
-
// is verified to use the Relay quote calldata (depositErc20) correctly.
|
|
30
|
-
// [tronChainId]: 728126428,
|
|
25
|
+
[caip_1.tronChainId]: 728126428,
|
|
31
26
|
[caip_1.monadChainId]: chains_1.monad.id,
|
|
32
27
|
[caip_1.hyperEvmChainId]: chains_1.hyperEvm.id,
|
|
33
28
|
[caip_1.mantleChainId]: chains_1.mantle.id,
|
|
@@ -54,6 +49,7 @@ exports.chainIdToRelayChainId = {
|
|
|
54
49
|
[caip_1.modeChainId]: chains_1.mode.id,
|
|
55
50
|
[caip_1.soneiumChainId]: chains_1.soneium.id,
|
|
56
51
|
[caip_1.seiChainId]: chains_1.sei.id,
|
|
52
|
+
[caip_1.abstractChainId]: 2741,
|
|
57
53
|
};
|
|
58
54
|
var RelayStatusMessage;
|
|
59
55
|
(function (RelayStatusMessage) {
|
|
@@ -149,7 +149,7 @@ exports.relayApi = {
|
|
|
149
149
|
}
|
|
150
150
|
if (swap.metadata.relayTransactionMetadata &&
|
|
151
151
|
!txIndexingMap.has(swap.id) &&
|
|
152
|
-
|
|
152
|
+
constant_1.chainIdToRelayChainId[chainId] !== undefined) {
|
|
153
153
|
const relayTxParam = {
|
|
154
154
|
...swap.metadata.relayTransactionMetadata,
|
|
155
155
|
txHash,
|
|
@@ -486,13 +486,23 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
if ((0, types_2.isRelayQuoteTronItemData)(selectedItem.data)) {
|
|
489
|
+
const contractAddress = selectedItem.data.parameter?.contract_address;
|
|
490
|
+
const callData = selectedItem.data.parameter?.data;
|
|
491
|
+
const isTronToken = (0, utils_1.isToken)(sellAsset.assetId);
|
|
492
|
+
if (isTronToken && !contractAddress) {
|
|
493
|
+
throw new Error('Missing Relay Tron contract address');
|
|
494
|
+
}
|
|
495
|
+
if (isTronToken && !callData) {
|
|
496
|
+
throw new Error('Missing Relay Tron transaction data');
|
|
497
|
+
}
|
|
489
498
|
return {
|
|
490
|
-
allowanceContract: '',
|
|
499
|
+
allowanceContract: contractAddress ?? '',
|
|
491
500
|
solanaTransactionMetadata: undefined,
|
|
492
501
|
relayTransactionMetadata: {
|
|
493
502
|
relayId: quote.steps[0].requestId,
|
|
494
503
|
orderId,
|
|
495
|
-
to:
|
|
504
|
+
to: contractAddress,
|
|
505
|
+
data: callData,
|
|
496
506
|
},
|
|
497
507
|
};
|
|
498
508
|
}
|
|
@@ -227,6 +227,11 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
227
227
|
assetReference: caip_1.ASSET_REFERENCE.Sei,
|
|
228
228
|
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
229
229
|
};
|
|
230
|
+
case caip_1.CHAIN_REFERENCE.AbstractMainnet:
|
|
231
|
+
return {
|
|
232
|
+
assetReference: caip_1.ASSET_REFERENCE.Abstract,
|
|
233
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
234
|
+
};
|
|
230
235
|
default:
|
|
231
236
|
throw Error(`chainId '${relayToken.chainId}' not supported`);
|
|
232
237
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTradeQuote = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
5
|
const monads_1 = require("@sniptt/monads");
|
|
5
6
|
const omniston_sdk_1 = require("@ston-fi/omniston-sdk");
|
|
6
7
|
const types_1 = require("../../../types");
|
|
@@ -40,7 +41,7 @@ const getTradeQuote = async (input) => {
|
|
|
40
41
|
try {
|
|
41
42
|
const slippageBps = (0, helpers_2.slippageDecimalToBps)(slippageTolerancePercentageDecimal, constants_1.STONFI_DEFAULT_SLIPPAGE_BPS);
|
|
42
43
|
const referrerFeeBps = (0, helpers_2.affiliateBpsToNumber)(affiliateBps);
|
|
43
|
-
const tonTreasuryAddress = (0, helpers_1.getTreasuryAddressFromChainId)(
|
|
44
|
+
const tonTreasuryAddress = (0, helpers_1.getTreasuryAddressFromChainId)(caip_1.tonChainId);
|
|
44
45
|
const referrerAddress = (0, helpers_2.tonAddressToOmnistonAddress)(tonTreasuryAddress);
|
|
45
46
|
const quoteResult = await (0, helpers_2.waitForQuote)(omniston, {
|
|
46
47
|
settlementMethods: [omniston_sdk_1.SettlementMethod.SETTLEMENT_METHOD_SWAP],
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getUnsignedTronTransaction = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
|
+
const tronweb_1 = require("tronweb");
|
|
6
7
|
const utils_2 = require("../utils");
|
|
7
8
|
const getUnsignedTronTransaction = ({ stepIndex, tradeQuote, from, assertGetTronChainAdapter, }) => {
|
|
8
9
|
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
@@ -30,6 +31,21 @@ const getUnsignedTronTransaction = ({ stepIndex, tradeQuote, from, assertGetTron
|
|
|
30
31
|
args,
|
|
31
32
|
});
|
|
32
33
|
}
|
|
34
|
+
if (relayTransactionMetadata?.data) {
|
|
35
|
+
if (!relayTransactionMetadata.to) {
|
|
36
|
+
throw new Error('Missing Relay transaction destination address');
|
|
37
|
+
}
|
|
38
|
+
const to = tronweb_1.TronWeb.address.fromHex(relayTransactionMetadata.to);
|
|
39
|
+
const isNativeTron = sellAsset.assetId === caip_1.tronAssetId;
|
|
40
|
+
const value = isNativeTron ? step.sellAmountIncludingProtocolFeesCryptoBaseUnit : '0';
|
|
41
|
+
return adapter.buildCustomApiTx({
|
|
42
|
+
from,
|
|
43
|
+
to,
|
|
44
|
+
accountNumber,
|
|
45
|
+
data: relayTransactionMetadata.data,
|
|
46
|
+
value,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
33
49
|
const to = relayTransactionMetadata?.to ?? nearIntentsSpecific?.depositAddress;
|
|
34
50
|
if (!to)
|
|
35
51
|
throw new Error('Missing transaction destination address');
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { QuoteResponse } from '@jup-ag/api';
|
|
2
1
|
import type { AccountId, AssetId, ChainId, Nominal } from '@shapeshiftoss/caip';
|
|
3
2
|
import type { ChainAdapter, CosmosSdkChainAdapter, EvmChainAdapter, near, SignTx, solana, starknet, sui, ton, tron, UtxoChainAdapter } from '@shapeshiftoss/chain-adapters';
|
|
4
3
|
import type { HDWallet, SolanaSignTx, StarknetSignTx, SuiSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
@@ -41,7 +40,6 @@ export type SwapperConfig = {
|
|
|
41
40
|
VITE_CHAINFLIP_API_KEY: string;
|
|
42
41
|
VITE_CHAINFLIP_API_URL: string;
|
|
43
42
|
VITE_FEATURE_CHAINFLIP_SWAP_DCA: boolean;
|
|
44
|
-
VITE_JUPITER_API_URL: string;
|
|
45
43
|
VITE_RELAY_API_URL: string;
|
|
46
44
|
VITE_BEBOP_API_KEY: string;
|
|
47
45
|
VITE_NEAR_INTENTS_API_KEY: string;
|
|
@@ -62,7 +60,6 @@ export declare enum SwapperName {
|
|
|
62
60
|
ArbitrumBridge = "Arbitrum Bridge",
|
|
63
61
|
Portals = "Portals",
|
|
64
62
|
Chainflip = "Chainflip",
|
|
65
|
-
Jupiter = "Jupiter",
|
|
66
63
|
Relay = "Relay",
|
|
67
64
|
ButterSwap = "ButterSwap",
|
|
68
65
|
Bebop = "Bebop",
|
|
@@ -307,7 +304,6 @@ export type TradeQuoteStep = {
|
|
|
307
304
|
};
|
|
308
305
|
bebopSolanaSerializedTx?: string;
|
|
309
306
|
bebopQuoteId?: string;
|
|
310
|
-
jupiterQuoteResponse?: QuoteResponse;
|
|
311
307
|
solanaTransactionMetadata?: {
|
|
312
308
|
addressLookupTableAddresses: string[];
|
|
313
309
|
instructions?: TransactionInstruction[];
|
|
@@ -316,7 +312,7 @@ export type TradeQuoteStep = {
|
|
|
316
312
|
};
|
|
317
313
|
cowswapQuoteResponse?: OrderQuoteResponse;
|
|
318
314
|
chainflipSpecific?: {
|
|
319
|
-
chainflipSwapId?: number;
|
|
315
|
+
chainflipSwapId?: number | string;
|
|
320
316
|
chainflipDepositAddress?: string;
|
|
321
317
|
chainflipNumberOfChunks?: number;
|
|
322
318
|
chainflipChunkIntervalBlocks?: number;
|
|
@@ -446,7 +442,7 @@ export type SwapExecutionMetadata = {
|
|
|
446
442
|
inboundAddress?: string;
|
|
447
443
|
};
|
|
448
444
|
export type SwapperSpecificMetadata = {
|
|
449
|
-
chainflipSwapId: number | undefined;
|
|
445
|
+
chainflipSwapId: number | string | undefined;
|
|
450
446
|
nearIntentsSpecific?: {
|
|
451
447
|
depositAddress: string;
|
|
452
448
|
depositMemo?: string;
|
|
@@ -646,6 +642,7 @@ export type TradeStatus = {
|
|
|
646
642
|
relayerExplorerTxLink?: string | undefined;
|
|
647
643
|
message: string | [string, InterpolationOptions] | undefined;
|
|
648
644
|
actualBuyAmountCryptoBaseUnit?: string;
|
|
645
|
+
chainflipSwapId?: number | string;
|
|
649
646
|
};
|
|
650
647
|
export type TradeQuoteResult = Result<TradeQuote[], SwapErrorRight>;
|
|
651
648
|
export type TradeRateResult = Result<TradeRate[], SwapErrorRight>;
|
package/dist/cjs/types.js
CHANGED
|
@@ -11,7 +11,6 @@ var SwapperName;
|
|
|
11
11
|
SwapperName["ArbitrumBridge"] = "Arbitrum Bridge";
|
|
12
12
|
SwapperName["Portals"] = "Portals";
|
|
13
13
|
SwapperName["Chainflip"] = "Chainflip";
|
|
14
|
-
SwapperName["Jupiter"] = "Jupiter";
|
|
15
14
|
SwapperName["Relay"] = "Relay";
|
|
16
15
|
SwapperName["ButterSwap"] = "ButterSwap";
|
|
17
16
|
SwapperName["Bebop"] = "Bebop";
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -75,3 +75,6 @@ export declare const checkStarknetSwapStatus: ({ txHash, assertGetStarknetChainA
|
|
|
75
75
|
txHash: string;
|
|
76
76
|
assertGetStarknetChainAdapter: (chainId: ChainId) => starknet.ChainAdapter;
|
|
77
77
|
}) => Promise<TradeStatus>;
|
|
78
|
+
export declare class SolanaLogsError extends Error {
|
|
79
|
+
constructor(name: string);
|
|
80
|
+
}
|
package/dist/cjs/utils.js
CHANGED
|
@@ -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.checkStarknetSwapStatus = exports.checkSuiSwapStatus = exports.checkSolanaSwapStatus = exports.getExecutableTradeStep = exports.isExecutableTradeStep = exports.isExecutableTradeQuote = exports.getInputOutputRate = exports.checkEvmSwapStatus = exports.checkSafeTransactionStatus = exports.createDefaultStatusResponse = exports.executeTonTransaction = exports.executeStarknetTransaction = exports.executeNearTransaction = exports.executeSuiTransaction = exports.executeTronTransaction = exports.executeSolanaTransaction = exports.executeEvmTransaction = exports.getHopByIndex = exports.makeSwapperAxiosServiceMonadic = exports.AsyncResultOf = exports.createCache = exports.createTradeAmountTooSmallErr = exports.makeSwapErrorRight = void 0;
|
|
6
|
+
exports.SolanaLogsError = exports.checkStarknetSwapStatus = exports.checkSuiSwapStatus = exports.checkSolanaSwapStatus = exports.getExecutableTradeStep = exports.isExecutableTradeStep = exports.isExecutableTradeQuote = exports.getInputOutputRate = exports.checkEvmSwapStatus = exports.checkSafeTransactionStatus = exports.createDefaultStatusResponse = exports.executeTonTransaction = exports.executeStarknetTransaction = exports.executeNearTransaction = exports.executeSuiTransaction = exports.executeTronTransaction = exports.executeSolanaTransaction = exports.executeEvmTransaction = exports.getHopByIndex = exports.makeSwapperAxiosServiceMonadic = exports.AsyncResultOf = exports.createCache = exports.createTradeAmountTooSmallErr = exports.makeSwapErrorRight = void 0;
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
8
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
9
9
|
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
@@ -190,8 +190,7 @@ const checkEvmSwapStatus = async ({ txHash, chainId, address, assertGetEvmChainA
|
|
|
190
190
|
message: undefined,
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
catch
|
|
194
|
-
console.error(e);
|
|
193
|
+
catch {
|
|
195
194
|
return (0, exports.createDefaultStatusResponse)(txHash);
|
|
196
195
|
}
|
|
197
196
|
};
|
|
@@ -316,3 +315,10 @@ const checkStarknetSwapStatus = async ({ txHash, assertGetStarknetChainAdapter,
|
|
|
316
315
|
}
|
|
317
316
|
};
|
|
318
317
|
exports.checkStarknetSwapStatus = checkStarknetSwapStatus;
|
|
318
|
+
class SolanaLogsError extends Error {
|
|
319
|
+
constructor(name) {
|
|
320
|
+
super(name);
|
|
321
|
+
this.name = name;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
exports.SolanaLogsError = SolanaLogsError;
|