@1delta/trade-sdk 0.1.1 → 0.1.3

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.
Files changed (78) hide show
  1. package/README.md +12 -9
  2. package/dist/aggregator/fetchAggregatorTrade.d.ts +1 -3
  3. package/dist/aggregator/fetchAggregatorTrade.d.ts.map +1 -1
  4. package/dist/aggregator/fetchAggregatorTrade.js +2 -1
  5. package/dist/bridge/fetchBridgeTrade.d.ts +2 -2
  6. package/dist/bridge/fetchBridgeTrade.d.ts.map +1 -1
  7. package/dist/bridge/fetchBridgeTrade.js +1 -1
  8. package/dist/composedTrades/across/acrossWithSwap.d.ts +2 -2
  9. package/dist/composedTrades/across/acrossWithSwap.d.ts.map +1 -1
  10. package/dist/composedTrades/across/acrossWithSwap.js +47 -26
  11. package/dist/composedTrades/across/acrossWithSwaps.d.ts +2 -2
  12. package/dist/composedTrades/across/acrossWithSwaps.d.ts.map +1 -1
  13. package/dist/composedTrades/across/acrossWithSwaps.js +1 -1
  14. package/dist/composedTrades/across/calldata/createAcrossMessage.d.ts +5 -2
  15. package/dist/composedTrades/across/calldata/createAcrossMessage.d.ts.map +1 -1
  16. package/dist/composedTrades/across/calldata/createAcrossMessage.js +37 -4
  17. package/dist/composedTrades/axelar/axelarWithSwap.d.ts +2 -2
  18. package/dist/composedTrades/axelar/axelarWithSwap.d.ts.map +1 -1
  19. package/dist/composedTrades/axelar/axelarWithSwap.js +57 -34
  20. package/dist/composedTrades/axelar/axelarWithSwaps.d.ts +5 -0
  21. package/dist/composedTrades/axelar/axelarWithSwaps.d.ts.map +1 -0
  22. package/dist/composedTrades/axelar/{AxelarWithSwaps.js → axelarWithSwaps.js} +1 -1
  23. package/dist/composedTrades/axelar/squid/createSquidPayload.d.ts +22 -16
  24. package/dist/composedTrades/axelar/squid/createSquidPayload.d.ts.map +1 -1
  25. package/dist/composedTrades/axelar/squid/createSquidPayload.js +72 -46
  26. package/dist/composedTrades/axelar/squid/simpleSquidCall.d.ts +3 -0
  27. package/dist/composedTrades/axelar/squid/simpleSquidCall.d.ts.map +1 -0
  28. package/dist/composedTrades/axelar/squid/simpleSquidCall.js +47 -0
  29. package/dist/composedTrades/axelar/squid/types.d.ts +27 -0
  30. package/dist/composedTrades/axelar/squid/types.d.ts.map +1 -1
  31. package/dist/composedTrades/axelar/squid/types.js +7 -0
  32. package/dist/composedTrades/gaszip/gaszipWithSwaps.d.ts +2 -2
  33. package/dist/composedTrades/gaszip/gaszipWithSwaps.d.ts.map +1 -1
  34. package/dist/composedTrades/gaszip/gaszipWithSwaps.js +1 -1
  35. package/dist/composedTrades/index.d.ts +1 -1
  36. package/dist/composedTrades/index.js +1 -1
  37. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.d.ts +7 -0
  38. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.d.ts.map +1 -0
  39. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.js +17 -0
  40. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.d.ts +4 -0
  41. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.d.ts.map +1 -0
  42. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.js +19 -0
  43. package/dist/composedTrades/utils/fetchBridgeAndGasTrade.d.ts +2 -2
  44. package/dist/composedTrades/utils/fetchBridgeAndGasTrade.d.ts.map +1 -1
  45. package/dist/composedTrades/utils/multichainUtils.d.ts.map +1 -1
  46. package/dist/composedTrades/utils/multichainUtils.js +3 -3
  47. package/dist/composedTrades/utils/requireDeltaContracts.d.ts +5 -0
  48. package/dist/composedTrades/utils/requireDeltaContracts.d.ts.map +1 -0
  49. package/dist/composedTrades/utils/requireDeltaContracts.js +10 -0
  50. package/dist/core.d.ts +1 -2
  51. package/dist/core.d.ts.map +1 -1
  52. package/dist/core.js +6 -5
  53. package/dist/index.d.ts +5 -2
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +2 -2
  56. package/dist/initialize.d.ts +23 -0
  57. package/dist/initialize.d.ts.map +1 -1
  58. package/dist/initialize.js +25 -1
  59. package/dist/types/aggregatorInput.d.ts +3 -0
  60. package/dist/types/aggregatorInput.d.ts.map +1 -0
  61. package/dist/types/bridgeInput.d.ts +16 -18
  62. package/dist/types/bridgeInput.d.ts.map +1 -1
  63. package/dist/types/deltaCall.d.ts +32 -0
  64. package/dist/types/deltaCall.d.ts.map +1 -0
  65. package/dist/types/deltaCall.js +7 -0
  66. package/dist/types/destinationSwapData.d.ts +8 -0
  67. package/dist/types/destinationSwapData.d.ts.map +1 -0
  68. package/dist/types/destinationSwapData.js +1 -0
  69. package/dist/types/index.d.ts +3 -1
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/index.js +3 -1
  72. package/dist/utils/utils.js +1 -1
  73. package/package.json +6 -6
  74. package/dist/composedTrades/axelar/AxelarWithSwaps.d.ts +0 -5
  75. package/dist/composedTrades/axelar/AxelarWithSwaps.d.ts.map +0 -1
  76. package/dist/types/aggregator.d.ts +0 -11
  77. package/dist/types/aggregator.d.ts.map +0 -1
  78. /package/dist/types/{aggregator.js → aggregatorInput.js} +0 -0
package/README.md CHANGED
@@ -18,7 +18,7 @@ pnpm add @1delta/trade-sdk
18
18
  ## Basic Usage
19
19
 
20
20
  ```typescript
21
- import { initialize, fetchBridgeTrade, fetchAggregatorTrade } from '@1delta/trade-sdk';
21
+ import { initialize, fetchBridgeTrade, fetchAggregatorTrade, Bridge } from '@1delta/trade-sdk';
22
22
  import { WalletClient } from 'viem';
23
23
 
24
24
  // Initialize the SDK
@@ -34,13 +34,16 @@ const walletClient: WalletClient = /* your wallet client */;
34
34
  setWalletClient(walletClient);
35
35
 
36
36
  // Fetch a bridge trade
37
- const trade = await fetchBridgeTrade(bridge, {
38
- fromCurrency: fromToken,
39
- toCurrency: toToken,
40
- amount: '1000000000000000000', // 1.0 in wei
41
- receiver: '0x...',
42
- caller: '0x...',
43
- slippage: 0.5, // 0.5%
37
+ const trade = await fetchBridgeTrade({
38
+ bridge: Bridge.ACROSS,
39
+ input: {
40
+ fromCurrency: fromToken,
41
+ toCurrency: toToken,
42
+ amount: '1000000000000000000', // 1.0 in wei
43
+ receiver: '0x...',
44
+ caller: '0x...',
45
+ slippage: 0.5, // 0.5%
46
+ }
44
47
  });
45
48
  ```
46
49
 
@@ -54,7 +57,7 @@ Initializes the SDK with the given configuration.
54
57
 
55
58
  Sets the wallet client for transaction signing.
56
59
 
57
- ### `fetchBridgeTrade(bridge: Bridge, input: BridgeInput): Promise<GenericTrade>`
60
+ ### `fetchBridgeTrade(input: BridgeInput): Promise<GenericTrade>`
58
61
 
59
62
  Fetches a bridge trade quote.
60
63
 
@@ -1,6 +1,4 @@
1
1
  export * from './fetchAggregatorTrade';
2
- import { TradeAggregator } from '@1delta/aggregators';
3
- import { Bridge } from '@1delta/bridge-configs';
4
2
  import { AggregatorApiInput, GenericTrade, OneDeltaInput } from '@1delta/lib-utils';
5
- export declare const fetchAggregatorTrade: (aggregator: TradeAggregator | Bridge, input: AggregatorApiInput | OneDeltaInput, controller?: AbortController) => Promise<GenericTrade | undefined>;
3
+ export declare const fetchAggregatorTrade: (aggregator: string, input: AggregatorApiInput | OneDeltaInput, controller?: AbortController) => Promise<GenericTrade | undefined>;
6
4
  //# sourceMappingURL=fetchAggregatorTrade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAggregatorTrade.d.ts","sourceRoot":"","sources":["../../src/aggregator/fetchAggregatorTrade.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAGL,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAsB,MAAM,wBAAwB,CAAA;AACnE,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACd,MAAM,mBAAmB,CAAA;AAI1B,eAAO,MAAM,oBAAoB,GAC/B,YAAY,eAAe,GAAG,MAAM,EACpC,OAAO,kBAAkB,GAAG,aAAa,EACzC,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAgBlC,CAAA"}
1
+ {"version":3,"file":"fetchAggregatorTrade.d.ts","sourceRoot":"","sources":["../../src/aggregator/fetchAggregatorTrade.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AAMtC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACd,MAAM,mBAAmB,CAAA;AAK1B,eAAO,MAAM,oBAAoB,GAC/B,YAAY,MAAM,EAClB,OAAO,kBAAkB,GAAG,aAAa,EACzC,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAgBlC,CAAA"}
@@ -1,7 +1,8 @@
1
1
  export * from './fetchAggregatorTrade';
2
- import { fetchAggregatorTrade as fetchAggregatorTradeWithoutConfigs, getAvailableAggregators, } from '@1delta/aggregators';
2
+ import { fetchAggregatorTrade as fetchAggregatorTradeWithoutConfigs, } from '@1delta/aggregators';
3
3
  import { getSwapAggregators } from '@1delta/bridge-configs';
4
4
  import { fetchBridgeTrade } from '../bridge';
5
+ import { getAvailableAggregators } from './getAvailableAggregators';
5
6
  export const fetchAggregatorTrade = async (aggregator, input, controller) => {
6
7
  if (!getAvailableAggregators(input.chainId))
7
8
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import { Bridge } from '@1delta/bridge-configs';
2
2
  import { GenericTrade } from '@1delta/lib-utils';
3
- import { BridgeInput } from '../types';
4
- export declare const fetchBridgeTrade: (bridge: Bridge, input: BridgeInput, controller?: AbortController) => Promise<GenericTrade | undefined>;
3
+ import { BaseBridgeInput } from '../types';
4
+ export declare const fetchBridgeTrade: (bridge: Bridge, input: BaseBridgeInput, controller?: AbortController) => Promise<GenericTrade | undefined>;
5
5
  //# sourceMappingURL=fetchBridgeTrade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchBridgeTrade.d.ts","sourceRoot":"","sources":["../../src/bridge/fetchBridgeTrade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAU/C,OAAO,EAKL,YAAY,EAWb,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,OAAO,WAAW,EAClB,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAiMlC,CAAA"}
1
+ {"version":3,"file":"fetchBridgeTrade.d.ts","sourceRoot":"","sources":["../../src/bridge/fetchBridgeTrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAW/C,OAAO,EAKL,YAAY,EAWb,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,OAAO,eAAe,EACtB,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAiMlC,CAAA"}
@@ -1,6 +1,6 @@
1
- import { convertRawAmount } from '@1delta/aggregators';
2
1
  import { Bridge } from '@1delta/bridge-configs';
3
2
  import { buildTransactionData, getQuote, getRoute, getStatus, } from '@1delta/bridge-core';
3
+ import { convertRawAmount } from '@1delta/lib-utils';
4
4
  import { ChainType, ChainUtils, CurrencyHandler, isDirectlyPermittable, NATIVE_PLACEHOLDER, PermitShared, TradeType, } from '@1delta/lib-utils';
5
5
  export const fetchBridgeTrade = async (bridge, input, controller) => {
6
6
  const inputSlippage = input.slippage;
@@ -1,6 +1,6 @@
1
1
  import { GenericTrade, RawCurrency } from '@1delta/lib-utils';
2
- import { BridgeInput } from '../../types';
3
- export interface AcrossWithSwapInput extends BridgeInput {
2
+ import { BaseComposedInput } from '../../types';
3
+ export interface AcrossWithSwapInput extends BaseComposedInput {
4
4
  bridgeToCurrency: RawCurrency | undefined;
5
5
  }
6
6
  export declare const fetchAcrossTradeWithSwap: (input: AcrossWithSwapInput, controller?: AbortController) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"acrossWithSwap.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/across/acrossWithSwap.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EAKZ,WAAW,EAEZ,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAA;AAO1D,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAA;CAC1C;AAED,eAAO,MAAM,wBAAwB,GACnC,OAAO,mBAAmB,EAC1B,aAAa,eAAe,KAC3B,OAAO,CAAC;IAAE,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA6C/D,CAAA;AAED,eAAe,wBAAwB,CAAA"}
1
+ {"version":3,"file":"acrossWithSwap.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/across/acrossWithSwap.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EAKZ,WAAW,EAEZ,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAmB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAOhE,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAA;CAC1C;AAED,eAAO,MAAM,wBAAwB,GACnC,OAAO,mBAAmB,EAC1B,aAAa,eAAe,KAC3B,OAAO,CAAC;IAAE,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAgD/D,CAAA;AAED,eAAe,wBAAwB,CAAA"}
@@ -8,7 +8,8 @@ export const fetchAcrossTradeWithSwap = async (input, controller) => {
8
8
  throw new Error('BridgeToCurrency undefined');
9
9
  const toChainId = getSafeChainId(input.toCurrency?.chainId);
10
10
  const toTokenIsBridgeToken = CurrencyHandler.equal(input.bridgeToCurrency, CurrencyHandler.wrapped(input.toCurrency));
11
- if (toTokenIsBridgeToken) {
11
+ const needDestinationCalls = (input.additionalCalls?.length ?? 0) > 0 || !toTokenIsBridgeToken;
12
+ if (!needDestinationCalls) {
12
13
  const toTokenIsWNative = CurrencyHandler.isWNative(input.toCurrency);
13
14
  if (toTokenIsWNative) {
14
15
  // special case: to receive wrapped native receiver must be contract
@@ -28,7 +29,7 @@ export const fetchAcrossTradeWithSwap = async (input, controller) => {
28
29
  }
29
30
  }
30
31
  else {
31
- const acrossTrade = await fetchAcrossTradeWithDestinationSwap(input, controller);
32
+ const acrossTrade = await fetchAcrossTradeWithDestinationCalls(input, controller);
32
33
  return {
33
34
  trade: acrossTrade,
34
35
  receiver: getAcrossMulticallHandler(toChainId),
@@ -55,7 +56,7 @@ const fetchAcrossTradeWithSweep = async (input, controller) => {
55
56
  return undefined;
56
57
  return acrossTrade;
57
58
  };
58
- const fetchAcrossTradeWithDestinationSwap = async (input, controller) => {
59
+ const fetchAcrossTradeWithDestinationCalls = async (input, controller) => {
59
60
  if (!input.swapAmount)
60
61
  throw new Error('Swap amount undefined');
61
62
  if (!input.fromCurrency)
@@ -65,27 +66,43 @@ const fetchAcrossTradeWithDestinationSwap = async (input, controller) => {
65
66
  if (!input.bridgeToCurrency)
66
67
  throw new Error('BridgeToCurrency undefined');
67
68
  const toChainId = input.toCurrency.chainId;
69
+ const additionalCalls = input.additionalCalls ?? [];
70
+ const needsSwap = !CurrencyHandler.equal(input.bridgeToCurrency, input.toCurrency);
68
71
  const fetchSwapAndMessage = async (amount) => {
69
- const destinationSwapInput = {
70
- chainId: toChainId,
71
- tradeType: TradeType.EXACT_INPUT,
72
- fromCurrency: input.bridgeToCurrency,
73
- toCurrency: input.toCurrency,
74
- slippage: input.slippage,
75
- swapAmount: amount.toString(),
76
- txOrigin: getAcrossMulticallHandler(toChainId),
77
- caller: getAcrossMulticallHandler(toChainId),
78
- receiver: input.receiver,
79
- flashSwap: undefined,
80
- };
81
- const destinationSwapTrade = await fetchBestTrade(destinationSwapInput, controller);
82
- if (!destinationSwapTrade || !destinationSwapTrade.assemble)
83
- return undefined;
84
- const tx = await destinationSwapTrade.assemble();
85
- if (!tx?.EVM)
86
- return undefined;
87
- const message = createAcrossSwapMessage(getAcrossMulticallHandler(toChainId), destinationSwapTrade.inputAmount.currency.address, destinationSwapTrade.inputAmount.amount, destinationSwapTrade.target, [tx.EVM], input.receiver, [destinationSwapTrade.inputAmount.currency.address]);
88
- return { message, destinationSwapTrade };
72
+ if (needsSwap) {
73
+ // Handle destination swap case
74
+ const destinationSwapInput = {
75
+ chainId: toChainId,
76
+ tradeType: TradeType.EXACT_INPUT,
77
+ fromCurrency: input.bridgeToCurrency,
78
+ toCurrency: input.toCurrency,
79
+ slippage: input.slippage,
80
+ swapAmount: amount.toString(),
81
+ txOrigin: getAcrossMulticallHandler(toChainId),
82
+ caller: getAcrossMulticallHandler(toChainId),
83
+ receiver: input.receiver,
84
+ flashSwap: undefined,
85
+ };
86
+ const destinationSwapTrade = await fetchBestTrade(destinationSwapInput, controller);
87
+ if (!destinationSwapTrade || !destinationSwapTrade.assemble)
88
+ return undefined;
89
+ const tx = await destinationSwapTrade.assemble();
90
+ if (!tx?.EVM)
91
+ return undefined;
92
+ const message = createAcrossSwapMessage(getAcrossMulticallHandler(toChainId), toChainId, destinationSwapTrade.inputAmount.currency.address, destinationSwapTrade.outputAmount.currency.address, input.receiver, additionalCalls, {
93
+ tokenToApprove: destinationSwapTrade.inputAmount.currency.address,
94
+ amountToApprove: destinationSwapTrade.inputAmount.amount,
95
+ spender: destinationSwapTrade.target,
96
+ calls: [tx.EVM],
97
+ });
98
+ return { message, destinationSwapTrade };
99
+ }
100
+ else if (additionalCalls.length > 0) {
101
+ // Handle only destination calls case
102
+ const message = createAcrossSwapMessage(getAcrossMulticallHandler(toChainId), toChainId, undefined, input.bridgeToCurrency.address, input.receiver, additionalCalls);
103
+ return { message, destinationSwapTrade: undefined };
104
+ }
105
+ return undefined;
89
106
  };
90
107
  const destinationSwapAmount = normalizeDecimals(BigInt(input.swapAmount), input.fromCurrency.decimals, input.bridgeToCurrency.decimals);
91
108
  const swap = await fetchSwapAndMessage(destinationSwapAmount);
@@ -114,9 +131,13 @@ const fetchAcrossTradeWithDestinationSwap = async (input, controller) => {
114
131
  };
115
132
  return {
116
133
  ...updatedAcrossTrade,
117
- outputAmount: updatedSwap.destinationSwapTrade.outputAmount,
118
- outputAmountRealized: updatedSwap.destinationSwapTrade.outputAmountRealized,
119
- stringified: `${updatedAcrossTrade?.stringified}-${updatedSwap.destinationSwapTrade.stringified}`,
134
+ outputAmount: updatedSwap.destinationSwapTrade?.outputAmount ??
135
+ updatedAcrossTrade.outputAmount,
136
+ outputAmountRealized: updatedSwap.destinationSwapTrade?.outputAmountRealized ??
137
+ updatedAcrossTrade.outputAmountRealized,
138
+ stringified: updatedSwap.destinationSwapTrade
139
+ ? `${updatedAcrossTrade?.stringified}-${updatedSwap.destinationSwapTrade.stringified}`
140
+ : updatedAcrossTrade.stringified,
120
141
  refresh,
121
142
  };
122
143
  };
@@ -1,5 +1,5 @@
1
1
  import { GenericTrade, RawCurrency } from '@1delta/lib-utils';
2
- import { BridgeInput } from '../../types';
3
- export declare const fetchAcrossTradeWithSwaps: (input: BridgeInput, getCurrency: (chainId: string | undefined, tokenAddress: string | undefined) => RawCurrency | undefined, controller?: AbortController) => Promise<GenericTrade | undefined>;
2
+ import { BaseComposedInput } from '../../types';
3
+ export declare const fetchAcrossTradeWithSwaps: (input: BaseComposedInput, getCurrency: (chainId: string | undefined, tokenAddress: string | undefined) => RawCurrency | undefined, controller?: AbortController) => Promise<GenericTrade | undefined>;
4
4
  export default fetchAcrossTradeWithSwaps;
5
5
  //# sourceMappingURL=acrossWithSwaps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acrossWithSwaps.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/across/acrossWithSwaps.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EAOZ,WAAW,EAGZ,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAA;AAsB1D,eAAO,MAAM,yBAAyB,GACpC,OAAO,WAAW,EAClB,aAAa,CACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,KAC7B,WAAW,GAAG,SAAS,EAC5B,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAoKlC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
1
+ {"version":3,"file":"acrossWithSwaps.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/across/acrossWithSwaps.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EAOZ,WAAW,EAGZ,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAmB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAsBhE,eAAO,MAAM,yBAAyB,GACpC,OAAO,iBAAiB,EACxB,aAAa,CACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,KAC7B,WAAW,GAAG,SAAS,EAC5B,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAqKlC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { convertRawAmount } from '@1delta/aggregators';
1
+ import { convertRawAmount } from '@1delta/lib-utils';
2
2
  import { CurrencyHandler, getDeltaComposerProxyAddress, getForwarderAddress, getSafeChainId, minimumAmountOutFromTrade, nativeOnChain, splitSlippage, TradeType, } from '@1delta/lib-utils';
3
3
  import { createSwapAndBridgeCalldata } from '../utils/createSwapAndBridgeCalldata';
4
4
  import { fetchBestTrade, increaseAmountBySlippage, } from '../utils/multichainUtils';
@@ -1,5 +1,7 @@
1
- import { EvmGenericCallInfo } from '@1delta/lib-utils';
2
1
  import { Hex } from 'viem';
2
+ import { DeltaCall } from '../../../types/deltaCall';
3
+ import { DestinationSwapData } from '../../../types/destinationSwapData';
4
+ import { AcrossCall } from './types';
3
5
  /**
4
6
  * Creates the ABI-encoded `message` for a complete "Approve -> Execute -> Drain" sequence
5
7
  * using the Across MulticallHandler.
@@ -18,6 +20,7 @@ import { Hex } from 'viem';
18
20
  * @param fallbackAndDrainAddress - The single address that serves as both the safety net (fallback) and the destination for the drained tokens. This should be your wallet.
19
21
  * @returns The final, ABI-encoded `message` as a hex string (`Hex`).
20
22
  */
21
- export declare function createAcrossSwapMessage(multicallHandlerAddress: string, tokenToApprove: string, amountToApprove: bigint, spender: string, calls: EvmGenericCallInfo[], fallbackAndDrainAddress: string, tokensToDrain: string[]): Hex;
23
+ export declare function createAcrossSwapMessage(multicallHandlerAddress: string, chainId: string, inputToken: string | undefined, outputToken: string, refundAndDrainAddress: string, additionalCalls: DeltaCall[], destinationSwapData?: DestinationSwapData): Hex;
24
+ export declare function createAcrossSwapCalls(destinationSwapData: DestinationSwapData): AcrossCall[];
22
25
  export declare function createAcrossDrainMessage(multicallHandlerAddress: string, fallbackAndDrainAddress: string, tokensToDrain: string[]): Hex;
23
26
  //# sourceMappingURL=createAcrossMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAcrossMessage.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/across/calldata/createAcrossMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAA+B,GAAG,EAAY,MAAM,MAAM,CAAA;AAKjE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,uBAAuB,EAAE,MAAM,EAC/B,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,kBAAkB,EAAE,EAC3B,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,MAAM,EAAE,GACtB,GAAG,CAsCL;AAED,wBAAgB,wBAAwB,CACtC,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,MAAM,EAAE,GACtB,GAAG,CAWL"}
1
+ {"version":3,"file":"createAcrossMessage.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/across/calldata/createAcrossMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,GAAG,EAAY,MAAM,MAAM,CAAA;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAIxE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,uBAAuB,EAAE,MAAM,EAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,EAC7B,eAAe,EAAE,SAAS,EAAE,EAC5B,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,GAAG,CA0DL;AAED,wBAAgB,qBAAqB,CACnC,mBAAmB,EAAE,mBAAmB,GACvC,UAAU,EAAE,CA8Bd;AAED,wBAAgB,wBAAwB,CACtC,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,MAAM,EAAE,GACtB,GAAG,CAWL"}
@@ -1,4 +1,6 @@
1
1
  import { encodeFunctionData, parseAbi } from 'viem';
2
+ import { createDeltaComposerCalldata } from '../../utils/deltaComposeCall/createDeltaComposerCalldata';
3
+ import { requireDeltaContracts } from '../../utils/requireDeltaContracts';
2
4
  import { createAcrossMultiCallMessage } from './createAcrossMultiCallMessage';
3
5
  /**
4
6
  * Creates the ABI-encoded `message` for a complete "Approve -> Execute -> Drain" sequence
@@ -18,7 +20,40 @@ import { createAcrossMultiCallMessage } from './createAcrossMultiCallMessage';
18
20
  * @param fallbackAndDrainAddress - The single address that serves as both the safety net (fallback) and the destination for the drained tokens. This should be your wallet.
19
21
  * @returns The final, ABI-encoded `message` as a hex string (`Hex`).
20
22
  */
21
- export function createAcrossSwapMessage(multicallHandlerAddress, tokenToApprove, amountToApprove, spender, calls, fallbackAndDrainAddress, tokensToDrain) {
23
+ export function createAcrossSwapMessage(multicallHandlerAddress, chainId, inputToken, outputToken, refundAndDrainAddress, additionalCalls, destinationSwapData) {
24
+ const swapCalls = destinationSwapData
25
+ ? createAcrossSwapCalls(destinationSwapData)
26
+ : [];
27
+ if (additionalCalls.length === 0) {
28
+ // normal case: do calls and sweep to user
29
+ const tokensToDrain = inputToken ? [inputToken, outputToken] : [outputToken];
30
+ const drainCalls = createDrainCalls(multicallHandlerAddress, refundAndDrainAddress, tokensToDrain);
31
+ const allCalls = [...swapCalls, ...drainCalls];
32
+ return createAcrossMultiCallMessage(allCalls, refundAndDrainAddress);
33
+ }
34
+ else {
35
+ // composer case: do calls and continue in composer
36
+ const { forwarder } = requireDeltaContracts(chainId);
37
+ const tokensToDrain = inputToken ? [inputToken] : [];
38
+ const drainToUserCall = createDrainCalls(multicallHandlerAddress, refundAndDrainAddress, tokensToDrain);
39
+ const drainToForwarder = createDrainCalls(multicallHandlerAddress, forwarder, [outputToken]);
40
+ const deltaComposerCall = createDeltaComposerCalldata(chainId, [outputToken], refundAndDrainAddress, additionalCalls);
41
+ const callToComposer = {
42
+ target: deltaComposerCall.to,
43
+ callData: deltaComposerCall.calldata,
44
+ value: 0n,
45
+ };
46
+ const allCalls = [
47
+ ...swapCalls,
48
+ ...drainToUserCall,
49
+ ...drainToForwarder,
50
+ callToComposer,
51
+ ];
52
+ return createAcrossMultiCallMessage(allCalls, refundAndDrainAddress);
53
+ }
54
+ }
55
+ export function createAcrossSwapCalls(destinationSwapData) {
56
+ const { tokenToApprove, amountToApprove, spender, calls } = destinationSwapData;
22
57
  if (calls.some((call) => !call.to || !call.calldata)) {
23
58
  throw new Error('Invalid call data');
24
59
  }
@@ -40,9 +75,7 @@ export function createAcrossSwapMessage(multicallHandlerAddress, tokenToApprove,
40
75
  callData: call.calldata,
41
76
  value: BigInt(call.value ?? 0n),
42
77
  }));
43
- const drainCalls = createDrainCalls(multicallHandlerAddress, fallbackAndDrainAddress, tokensToDrain);
44
- const allCalls = [approveCall, ...middleCalls, ...drainCalls];
45
- return createAcrossMultiCallMessage(allCalls, fallbackAndDrainAddress);
78
+ return [approveCall, ...middleCalls];
46
79
  }
47
80
  export function createAcrossDrainMessage(multicallHandlerAddress, fallbackAndDrainAddress, tokensToDrain) {
48
81
  const drainCalls = createDrainCalls(multicallHandlerAddress, fallbackAndDrainAddress, tokensToDrain);
@@ -1,6 +1,6 @@
1
1
  import { GenericTrade, RawCurrency, useGeneralPricesCallbackType } from '@1delta/lib-utils';
2
- import { BridgeInput } from '../../types';
3
- export interface AxelarWithSwapInput extends BridgeInput {
2
+ import { BaseComposedInput } from '../../types';
3
+ export interface AxelarWithSwapInput extends BaseComposedInput {
4
4
  bridgeToCurrency: RawCurrency | undefined;
5
5
  }
6
6
  export declare const fetchAxelarTradeWithSwap: (input: AxelarWithSwapInput, getPrices: useGeneralPricesCallbackType, controller?: AbortController) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"axelarWithSwap.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/axelar/axelarWithSwap.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,YAAY,EAGZ,WAAW,EAEX,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAA;AAK1D,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAA;CAC1C;AAED,eAAO,MAAM,wBAAwB,GACnC,OAAO,mBAAmB,EAC1B,WAAW,4BAA4B,EACvC,aAAa,eAAe,KAC3B,OAAO,CAAC;IACT,KAAK,EAAE,YAAY,GAAG,SAAS,CAAA;IAC/B,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;IAClC,QAAQ,EAAE,MAAM,CAAA;CACjB,CA2CA,CAAA;AAED,eAAe,wBAAwB,CAAA"}
1
+ {"version":3,"file":"axelarWithSwap.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/axelar/axelarWithSwap.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,YAAY,EAGZ,WAAW,EAEX,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAGL,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAKpB,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAA;CAC1C;AAED,eAAO,MAAM,wBAAwB,GACnC,OAAO,mBAAmB,EAC1B,WAAW,4BAA4B,EACvC,aAAa,eAAe,KAC3B,OAAO,CAAC;IACT,KAAK,EAAE,YAAY,GAAG,SAAS,CAAA;IAC/B,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;IAClC,QAAQ,EAAE,MAAM,CAAA;CACjB,CA8CA,CAAA;AAED,eAAe,wBAAwB,CAAA"}
@@ -3,7 +3,7 @@ import { CurrencyHandler, normalizeDecimals, TradeType, } from '@1delta/lib-util
3
3
  import { fetchBridgeTrade } from '../../bridge/fetchBridgeTrade';
4
4
  import { fetchBridgeAndGasTrade } from '../utils/fetchBridgeAndGasTrade';
5
5
  import { fetchBestTrade } from '../utils/multichainUtils';
6
- import { createSquidSwapPayload } from './squid/createSquidPayload';
6
+ import { createSquidDestinationPayload } from './squid/createSquidPayload';
7
7
  export const fetchAxelarTradeWithSwap = async (input, getPrices, controller) => {
8
8
  if (!input.bridgeToCurrency)
9
9
  throw new Error('BridgeToCurrency undefined');
@@ -11,8 +11,9 @@ export const fetchAxelarTradeWithSwap = async (input, getPrices, controller) =>
11
11
  throw new Error('ToCurrency undefined');
12
12
  const toChainId = input.toCurrency.chainId;
13
13
  const toTokenIsBridgeToken = CurrencyHandler.equal(input.bridgeToCurrency, input.toCurrency);
14
+ const needDestinationCalls = (input.additionalCalls?.length ?? 0) > 0 || !toTokenIsBridgeToken;
14
15
  const squidRouter = await getRequiredSquidRouter(toChainId);
15
- if (toTokenIsBridgeToken) {
16
+ if (!needDestinationCalls) {
16
17
  // direct case
17
18
  const message = createSquidPayload(input.receiver);
18
19
  const bridgeAndGasTrade = await fetchBridgeAndGasTrade(Bridge.AXELAR, { ...input, message }, getPrices, controller);
@@ -23,8 +24,8 @@ export const fetchAxelarTradeWithSwap = async (input, getPrices, controller) =>
23
24
  };
24
25
  }
25
26
  else {
26
- // swap case
27
- const bridgeAndGasTrade = await fetchAxelarTradeWithDestinationSwap(input, getPrices, controller);
27
+ // destination calls case
28
+ const bridgeAndGasTrade = await fetchAxelarTradeWithDestinationCalls(input, getPrices, controller);
28
29
  return {
29
30
  trade: bridgeAndGasTrade?.bridgeTrade,
30
31
  gasTrade: bridgeAndGasTrade?.gasTrade,
@@ -33,7 +34,7 @@ export const fetchAxelarTradeWithSwap = async (input, getPrices, controller) =>
33
34
  }
34
35
  };
35
36
  export default fetchAxelarTradeWithSwap;
36
- const fetchAxelarTradeWithDestinationSwap = async (input, getPrices, controller) => {
37
+ const fetchAxelarTradeWithDestinationCalls = async (input, getPrices, controller) => {
37
38
  if (!input.swapAmount)
38
39
  throw new Error('Swap amount undefined');
39
40
  if (!input.fromCurrency)
@@ -44,30 +45,43 @@ const fetchAxelarTradeWithDestinationSwap = async (input, getPrices, controller)
44
45
  throw new Error('BridgeToCurrency undefined');
45
46
  const toChainId = input.toCurrency.chainId;
46
47
  const squidMulticall = await getRequiredSquidMulticaller(toChainId);
48
+ const additionalCalls = input.additionalCalls ?? [];
49
+ const needsSwap = !CurrencyHandler.equal(input.bridgeToCurrency, input.toCurrency);
47
50
  const fetchSwapAndMessage = async (amount) => {
48
- const destinationSwapInput = {
49
- chainId: toChainId,
50
- tradeType: TradeType.EXACT_INPUT,
51
- fromCurrency: input.bridgeToCurrency,
52
- toCurrency: input.toCurrency,
53
- slippage: input.slippage,
54
- swapAmount: amount.toString(),
55
- txOrigin: squidMulticall,
56
- caller: squidMulticall,
57
- receiver: squidMulticall,
58
- flashSwap: undefined,
59
- };
60
- const destinationSwapTrade = await fetchBestTrade(destinationSwapInput, controller);
61
- if (!destinationSwapTrade || !destinationSwapTrade.assemble)
62
- return undefined;
63
- const tx = await destinationSwapTrade.assemble();
64
- if (!tx?.EVM)
65
- return undefined;
66
- const message = createSquidSwapPayload(destinationSwapTrade.inputAmount.currency.address, destinationSwapTrade.inputAmount.amount, destinationSwapTrade.target, [tx.EVM], input.receiver, [
67
- destinationSwapTrade.inputAmount.currency.address,
68
- destinationSwapTrade.outputAmount.currency.address,
69
- ]);
70
- return { message, destinationSwapTrade };
51
+ if (needsSwap) {
52
+ // Handle destination swap case
53
+ const destinationSwapInput = {
54
+ chainId: toChainId,
55
+ tradeType: TradeType.EXACT_INPUT,
56
+ fromCurrency: input.bridgeToCurrency,
57
+ toCurrency: input.toCurrency,
58
+ slippage: input.slippage,
59
+ swapAmount: amount.toString(),
60
+ txOrigin: squidMulticall,
61
+ caller: squidMulticall,
62
+ receiver: squidMulticall,
63
+ flashSwap: undefined,
64
+ };
65
+ const destinationSwapTrade = await fetchBestTrade(destinationSwapInput, controller);
66
+ if (!destinationSwapTrade || !destinationSwapTrade.assemble)
67
+ return undefined;
68
+ const tx = await destinationSwapTrade.assemble();
69
+ if (!tx?.EVM)
70
+ return undefined;
71
+ const message = createSquidDestinationPayload(toChainId, destinationSwapTrade.inputAmount.currency.address, destinationSwapTrade.outputAmount.currency.address, input.receiver, additionalCalls, {
72
+ tokenToApprove: destinationSwapTrade.inputAmount.currency.address,
73
+ amountToApprove: destinationSwapTrade.inputAmount.amount,
74
+ spender: destinationSwapTrade.target,
75
+ calls: [tx.EVM],
76
+ });
77
+ return { message, destinationSwapTrade };
78
+ }
79
+ else if (additionalCalls.length > 0) {
80
+ // Handle only destination calls case
81
+ const message = createSquidDestinationPayload(toChainId, undefined, input.bridgeToCurrency.address, input.receiver, additionalCalls);
82
+ return { message, destinationSwapTrade: undefined };
83
+ }
84
+ return undefined;
71
85
  };
72
86
  const destinationSwapAmount = normalizeDecimals(BigInt(input.swapAmount), input.fromCurrency.decimals, input.bridgeToCurrency.decimals);
73
87
  const swap = await fetchSwapAndMessage(destinationSwapAmount);
@@ -83,9 +97,14 @@ const fetchAxelarTradeWithDestinationSwap = async (input, getPrices, controller)
83
97
  if (!bridgeAndGasTrade)
84
98
  return undefined;
85
99
  const { bridgeTrade, gasTrade } = bridgeAndGasTrade;
86
- const updatedSwap = await fetchSwapAndMessage(bridgeTrade.outputAmount.amount);
87
- if (!updatedSwap)
88
- return undefined;
100
+ // Only update swap if we actually need a swap
101
+ let updatedSwap = swap;
102
+ if (needsSwap) {
103
+ const newSwap = await fetchSwapAndMessage(bridgeTrade.outputAmount.amount);
104
+ if (!newSwap)
105
+ return undefined;
106
+ updatedSwap = newSwap;
107
+ }
89
108
  const updatedAxelarTrade = await fetchBridgeTrade(Bridge.AXELAR, { ...axelarInput, message: updatedSwap.message }, controller);
90
109
  if (!updatedAxelarTrade)
91
110
  return undefined;
@@ -98,9 +117,13 @@ const fetchAxelarTradeWithDestinationSwap = async (input, getPrices, controller)
98
117
  };
99
118
  const composedTrade = {
100
119
  ...updatedAxelarTrade,
101
- outputAmount: updatedSwap.destinationSwapTrade.outputAmount,
102
- outputAmountRealized: updatedSwap.destinationSwapTrade.outputAmountRealized,
103
- stringified: `${updatedAxelarTrade?.stringified}-${updatedSwap.destinationSwapTrade.stringified}`,
120
+ outputAmount: updatedSwap.destinationSwapTrade?.outputAmount ??
121
+ updatedAxelarTrade.outputAmount,
122
+ outputAmountRealized: updatedSwap.destinationSwapTrade?.outputAmountRealized ??
123
+ updatedAxelarTrade.outputAmountRealized,
124
+ stringified: updatedSwap.destinationSwapTrade
125
+ ? `${updatedAxelarTrade?.stringified}-${updatedSwap.destinationSwapTrade.stringified}`
126
+ : updatedAxelarTrade.stringified,
104
127
  refresh,
105
128
  };
106
129
  return { bridgeTrade: composedTrade, gasTrade };
@@ -0,0 +1,5 @@
1
+ import { GenericTrade, RawCurrency, useGeneralPricesCallbackType } from '@1delta/lib-utils';
2
+ import { BaseComposedInput } from '../../types';
3
+ export declare const fetchAxelarTradeWithSwaps: (input: BaseComposedInput, getCurrency: (chainId: string | undefined, tokenAddress: string | undefined) => RawCurrency | undefined, getPrices: useGeneralPricesCallbackType, controller?: AbortController) => Promise<GenericTrade | undefined>;
4
+ export default fetchAxelarTradeWithSwaps;
5
+ //# sourceMappingURL=axelarWithSwaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axelarWithSwaps.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/axelar/axelarWithSwaps.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EAMZ,WAAW,EAGX,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAmB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAmBhE,eAAO,MAAM,yBAAyB,GACpC,OAAO,iBAAiB,EACxB,aAAa,CACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,KAC7B,WAAW,GAAG,SAAS,EAC5B,WAAW,4BAA4B,EACvC,aAAa,eAAe,KAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CA8JlC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { convertRawAmount } from '@1delta/aggregators';
1
+ import { convertRawAmount } from '@1delta/lib-utils';
2
2
  import { CurrencyHandler, getDeltaComposerProxyAddress, getForwarderAddress, getSafeChainId, minimumAmountOutFromTrade, splitSlippage, TradeType, } from '@1delta/lib-utils';
3
3
  import { fetchBestTrade, increaseAmountBySlippage } from '../utils';
4
4
  import { createSwapAndBridgeCalldata } from '../utils/createSwapAndBridgeCalldata';
@@ -1,22 +1,28 @@
1
- import { EvmGenericCallInfo } from '@1delta/lib-utils';
2
1
  import { Hex } from 'viem';
2
+ import { DeltaCall } from '../../../types/deltaCall';
3
+ import { DestinationSwapData } from '../../../types/destinationSwapData';
3
4
  /**
4
- * Creates the final `payload` for a complete "Approve -> Execute -> Drain" sequence
5
- * using the Squid multicaller.
5
+ * Creates the final `payload` for a complete cross-chain swap using Squid.
6
6
  *
7
- * This is a high-level helper that orchestrates the entire flow:
8
- * 1. **TransferFrom** pull funds from caller to SquidMulticaller.
9
- * 1. **Approves** an ERC20 token for a spender.
10
- * 2. **Executes** a series of one or more "middle" calls (e.g., a swap).
11
- * 3. **Drains** the resulting tokens from the multicall contract back to a specified address.
7
+ * This function supports two main flows:
12
8
  *
13
- * @param tokenToApprove - The address of the ERC20 token to approve (the input token).
14
- * @param amountToApprove - The amount of the token to approve.
15
- * @param spender - The address that will spend the approved token (e.g., a DEX router).
16
- * @param calls - An array of generic call objects to execute after approval.
17
- * @param refundAndDrainAddress - The single address that serves as both the refund recipient (safety net) and the destination for the drained tokens.
18
- * @param tokensToDrain - An array of ERC20 token addresses expected as output from the middle calls.
19
- * @returns The final, ABI-encoded `payload` as a hex string (`Hex`).
9
+ * 1. **Normal Flow** (when no additional calls are provided):
10
+ * - Executes swap calls if destination swap data is provided
11
+ * - Drains all relevant tokens (input and output) to the refundAndDrainAddress
12
+ *
13
+ * 2. **Composer Flow** (when additional calls are provided):
14
+ * - Executes swap calls if destination swap data is provided
15
+ * - Drains input token (if any) to refundAndDrainAddress
16
+ * - Drains output token to the Delta Forwarder contract
17
+ * - Creates and appends a Delta Composer call to execute additional operations
18
+ *
19
+ * @param chainId - The ID of the destination chain
20
+ * @param inputToken - The address of the input token (optional)
21
+ * @param outputToken - The address of the output token
22
+ * @param refundAndDrainAddress - The address that receives refunds and drained tokens
23
+ * @param additionalCalls - Optional array of DeltaCall objects for the composer flow
24
+ * @param destinationSwapData - Optional swap data for destination chain swaps
25
+ * @returns The final, ABI-encoded `payload` as a hex string (`Hex`)
20
26
  */
21
- export declare function createSquidSwapPayload(tokenToApprove: string, amountToApprove: bigint, spender: string, calls: EvmGenericCallInfo[], refundAndDrainAddress: string, tokensToDrain: string[]): Hex;
27
+ export declare function createSquidDestinationPayload(chainId: string, inputToken: string | undefined, outputToken: string, refundAndDrainAddress: string, additionalCalls: DeltaCall[], destinationSwapData?: DestinationSwapData): Hex;
22
28
  //# sourceMappingURL=createSquidPayload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createSquidPayload.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/axelar/squid/createSquidPayload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAIL,GAAG,EAIJ,MAAM,MAAM,CAAA;AAiEb;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,kBAAkB,EAAE,EAC3B,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,MAAM,EAAE,GACtB,GAAG,CAqDL"}
1
+ {"version":3,"file":"createSquidPayload.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/axelar/squid/createSquidPayload.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,GAAG,EAAyB,MAAM,MAAM,CAAA;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AA0DxE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,EAC7B,eAAe,EAAE,SAAS,EAAE,EAC5B,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,GAAG,CA2DL"}