@1delta/trade-sdk 0.1.2 → 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 (54) hide show
  1. package/dist/bridge/fetchBridgeTrade.d.ts.map +1 -1
  2. package/dist/bridge/fetchBridgeTrade.js +1 -1
  3. package/dist/composedTrades/across/acrossWithSwap.d.ts +2 -2
  4. package/dist/composedTrades/across/acrossWithSwap.d.ts.map +1 -1
  5. package/dist/composedTrades/across/acrossWithSwap.js +47 -26
  6. package/dist/composedTrades/across/acrossWithSwaps.d.ts +2 -2
  7. package/dist/composedTrades/across/acrossWithSwaps.d.ts.map +1 -1
  8. package/dist/composedTrades/across/acrossWithSwaps.js +1 -1
  9. package/dist/composedTrades/across/calldata/createAcrossMessage.d.ts +5 -2
  10. package/dist/composedTrades/across/calldata/createAcrossMessage.d.ts.map +1 -1
  11. package/dist/composedTrades/across/calldata/createAcrossMessage.js +37 -4
  12. package/dist/composedTrades/axelar/axelarWithSwap.d.ts +2 -2
  13. package/dist/composedTrades/axelar/axelarWithSwap.d.ts.map +1 -1
  14. package/dist/composedTrades/axelar/axelarWithSwap.js +2 -5
  15. package/dist/composedTrades/axelar/axelarWithSwaps.d.ts +2 -2
  16. package/dist/composedTrades/axelar/axelarWithSwaps.d.ts.map +1 -1
  17. package/dist/composedTrades/axelar/axelarWithSwaps.js +1 -1
  18. package/dist/composedTrades/axelar/squid/createSquidPayload.d.ts +22 -24
  19. package/dist/composedTrades/axelar/squid/createSquidPayload.d.ts.map +1 -1
  20. package/dist/composedTrades/axelar/squid/createSquidPayload.js +54 -20
  21. package/dist/composedTrades/gaszip/gaszipWithSwaps.js +1 -1
  22. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.d.ts +7 -0
  23. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.d.ts.map +1 -0
  24. package/dist/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.js +17 -0
  25. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.d.ts +4 -0
  26. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.d.ts.map +1 -0
  27. package/dist/composedTrades/utils/deltaComposeCall/toComposerCall.js +19 -0
  28. package/dist/composedTrades/utils/requireDeltaContracts.d.ts +5 -0
  29. package/dist/composedTrades/utils/requireDeltaContracts.d.ts.map +1 -0
  30. package/dist/composedTrades/utils/requireDeltaContracts.js +10 -0
  31. package/dist/index.d.ts +5 -5
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/initialize.d.ts +23 -0
  35. package/dist/initialize.d.ts.map +1 -1
  36. package/dist/initialize.js +25 -1
  37. package/dist/types/aggregatorInput.d.ts +3 -0
  38. package/dist/types/aggregatorInput.d.ts.map +1 -0
  39. package/dist/types/bridgeInput.d.ts +9 -9
  40. package/dist/types/bridgeInput.d.ts.map +1 -1
  41. package/dist/types/deltaCall.d.ts +32 -0
  42. package/dist/types/deltaCall.d.ts.map +1 -0
  43. package/dist/types/deltaCall.js +7 -0
  44. package/dist/types/destinationSwapData.d.ts +8 -0
  45. package/dist/types/destinationSwapData.d.ts.map +1 -0
  46. package/dist/types/destinationSwapData.js +1 -0
  47. package/dist/types/index.d.ts +3 -1
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/index.js +3 -1
  50. package/dist/utils/utils.js +1 -1
  51. package/package.json +4 -4
  52. package/dist/types/aggregator.d.ts +0 -11
  53. package/dist/types/aggregator.d.ts.map +0 -1
  54. /package/dist/types/{aggregator.js → aggregatorInput.js} +0 -0
@@ -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,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
+ {"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 { BaseBridgeInput } from '../../types';
3
- export interface AcrossWithSwapInput extends BaseBridgeInput {
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,eAAe,EAAE,MAAM,aAAa,CAAA;AAO9D,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,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 { BaseBridgeInput } from '../../types';
3
- export declare const fetchAcrossTradeWithSwaps: (input: BaseBridgeInput, 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,eAAe,EAAE,MAAM,aAAa,CAAA;AAsB9D,eAAO,MAAM,yBAAyB,GACpC,OAAO,eAAe,EACtB,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 { BaseAxelarComposedInput } from '../../types';
3
- export interface AxelarWithSwapInput extends BaseAxelarComposedInput {
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,EAEL,uBAAuB,EAExB,MAAM,aAAa,CAAA;AAKpB,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,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"}
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"}
@@ -68,10 +68,7 @@ const fetchAxelarTradeWithDestinationCalls = async (input, getPrices, controller
68
68
  const tx = await destinationSwapTrade.assemble();
69
69
  if (!tx?.EVM)
70
70
  return undefined;
71
- const message = createSquidDestinationPayload(input.receiver, [
72
- destinationSwapTrade.inputAmount.currency.address,
73
- destinationSwapTrade.outputAmount.currency.address,
74
- ], additionalCalls, {
71
+ const message = createSquidDestinationPayload(toChainId, destinationSwapTrade.inputAmount.currency.address, destinationSwapTrade.outputAmount.currency.address, input.receiver, additionalCalls, {
75
72
  tokenToApprove: destinationSwapTrade.inputAmount.currency.address,
76
73
  amountToApprove: destinationSwapTrade.inputAmount.amount,
77
74
  spender: destinationSwapTrade.target,
@@ -81,7 +78,7 @@ const fetchAxelarTradeWithDestinationCalls = async (input, getPrices, controller
81
78
  }
82
79
  else if (additionalCalls.length > 0) {
83
80
  // Handle only destination calls case
84
- const message = createSquidDestinationPayload(input.receiver, [input.bridgeToCurrency.address], additionalCalls);
81
+ const message = createSquidDestinationPayload(toChainId, undefined, input.bridgeToCurrency.address, input.receiver, additionalCalls);
85
82
  return { message, destinationSwapTrade: undefined };
86
83
  }
87
84
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import { GenericTrade, RawCurrency, useGeneralPricesCallbackType } from '@1delta/lib-utils';
2
- import { BaseAxelarComposedInput } from '../../types';
3
- export declare const fetchAxelarTradeWithSwaps: (input: BaseAxelarComposedInput, getCurrency: (chainId: string | undefined, tokenAddress: string | undefined) => RawCurrency | undefined, getPrices: useGeneralPricesCallbackType, controller?: AbortController) => Promise<GenericTrade | undefined>;
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
4
  export default fetchAxelarTradeWithSwaps;
5
5
  //# sourceMappingURL=axelarWithSwaps.d.ts.map
@@ -1 +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,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAmBtE,eAAO,MAAM,yBAAyB,GACpC,OAAO,uBAAuB,EAC9B,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
+ {"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,30 +1,28 @@
1
- import { EvmGenericCallInfo } from '@1delta/lib-utils';
2
1
  import { Hex } from 'viem';
3
- import { SimpleSquidCall } from './types';
2
+ import { DeltaCall } from '../../../types/deltaCall';
3
+ import { DestinationSwapData } from '../../../types/destinationSwapData';
4
4
  /**
5
- * Creates the final `payload` for a complete "Approve -> Execute -> Drain" sequence
6
- * using the Squid multicaller.
5
+ * Creates the final `payload` for a complete cross-chain swap using Squid.
7
6
  *
8
- * This is a high-level helper that orchestrates the entire flow:
9
- * 1. **TransferFrom** pull funds from caller to SquidMulticaller.
10
- * 1. **Approves** an ERC20 token for a spender.
11
- * 2. **Executes** a series of one or more "middle" calls (e.g., a swap).
12
- * 3. **Drains** the resulting tokens from the multicall contract back to a specified address.
7
+ * This function supports two main flows:
13
8
  *
14
- * @param tokenToApprove - The address of the ERC20 token to approve (the input token).
15
- * @param amountToApprove - The amount of the token to approve.
16
- * @param spender - The address that will spend the approved token (e.g., a DEX router).
17
- * @param calls - An array of generic call objects to execute after approval.
18
- * @param refundAndDrainAddress - The single address that serves as both the refund recipient (safety net) and the destination for the drained tokens.
19
- * @param tokensToDrain - An array of ERC20 token addresses expected as output from the middle calls.
20
- * @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`)
21
26
  */
22
- export declare function createSquidDestinationPayload(refundAndDrainAddress: string, tokensToDrain: string[], additionalCalls: SimpleSquidCall[], destinationSwapData?: DestinationSwapData): Hex;
23
- interface DestinationSwapData {
24
- tokenToApprove: string;
25
- amountToApprove: bigint;
26
- spender: string;
27
- calls: EvmGenericCallInfo[];
28
- }
29
- export {};
27
+ export declare function createSquidDestinationPayload(chainId: string, inputToken: string | undefined, outputToken: string, refundAndDrainAddress: string, additionalCalls: DeltaCall[], destinationSwapData?: DestinationSwapData): Hex;
30
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,EAA+B,GAAG,EAAyB,MAAM,MAAM,CAAA;AAG9E,OAAO,EAAE,eAAe,EAAuB,MAAM,SAAS,CAAA;AAsD9D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,MAAM,EAAE,EACvB,eAAe,EAAE,eAAe,EAAE,EAClC,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,GAAG,CAYL;AAED,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,kBAAkB,EAAE,CAAA;CAC5B"}
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"}
@@ -1,5 +1,8 @@
1
1
  import { createSquidPayload } from '@1delta/bridge-configs';
2
+ import { CurrencyHandler } from '@1delta/lib-utils';
2
3
  import { encodeFunctionData, parseAbi, zeroAddress } from 'viem';
4
+ import { createDeltaComposerCalldata } from '../../utils/deltaComposeCall/createDeltaComposerCalldata';
5
+ import { requireDeltaContracts } from '../../utils/requireDeltaContracts';
3
6
  import { toSquidCall } from './simpleSquidCall';
4
7
  import { SimpleSquidCallType } from './types';
5
8
  /**
@@ -44,35 +47,66 @@ function createSquidDrainCalls(receiverAddress, tokensToDrain) {
44
47
  return drainCalls;
45
48
  }
46
49
  /**
47
- * Creates the final `payload` for a complete "Approve -> Execute -> Drain" sequence
48
- * using the Squid multicaller.
50
+ * Creates the final `payload` for a complete cross-chain swap using Squid.
49
51
  *
50
- * This is a high-level helper that orchestrates the entire flow:
51
- * 1. **TransferFrom** pull funds from caller to SquidMulticaller.
52
- * 1. **Approves** an ERC20 token for a spender.
53
- * 2. **Executes** a series of one or more "middle" calls (e.g., a swap).
54
- * 3. **Drains** the resulting tokens from the multicall contract back to a specified address.
52
+ * This function supports two main flows:
55
53
  *
56
- * @param tokenToApprove - The address of the ERC20 token to approve (the input token).
57
- * @param amountToApprove - The amount of the token to approve.
58
- * @param spender - The address that will spend the approved token (e.g., a DEX router).
59
- * @param calls - An array of generic call objects to execute after approval.
60
- * @param refundAndDrainAddress - The single address that serves as both the refund recipient (safety net) and the destination for the drained tokens.
61
- * @param tokensToDrain - An array of ERC20 token addresses expected as output from the middle calls.
62
- * @returns The final, ABI-encoded `payload` as a hex string (`Hex`).
54
+ * 1. **Normal Flow** (when no additional calls are provided):
55
+ * - Executes swap calls if destination swap data is provided
56
+ * - Drains all relevant tokens (input and output) to the refundAndDrainAddress
57
+ *
58
+ * 2. **Composer Flow** (when additional calls are provided):
59
+ * - Executes swap calls if destination swap data is provided
60
+ * - Drains input token (if any) to refundAndDrainAddress
61
+ * - Drains output token to the Delta Forwarder contract
62
+ * - Creates and appends a Delta Composer call to execute additional operations
63
+ *
64
+ * @param chainId - The ID of the destination chain
65
+ * @param inputToken - The address of the input token (optional)
66
+ * @param outputToken - The address of the output token
67
+ * @param refundAndDrainAddress - The address that receives refunds and drained tokens
68
+ * @param additionalCalls - Optional array of DeltaCall objects for the composer flow
69
+ * @param destinationSwapData - Optional swap data for destination chain swaps
70
+ * @returns The final, ABI-encoded `payload` as a hex string (`Hex`)
63
71
  */
64
- export function createSquidDestinationPayload(refundAndDrainAddress, tokensToDrain, additionalCalls, destinationSwapData) {
72
+ export function createSquidDestinationPayload(chainId, inputToken, outputToken, refundAndDrainAddress, additionalCalls, destinationSwapData) {
65
73
  const swapCalls = destinationSwapData
66
74
  ? createSquidSwapCalls(destinationSwapData)
67
75
  : [];
68
- const drainCalls = createSquidDrainCalls(refundAndDrainAddress, tokensToDrain);
69
- const allCalls = [...swapCalls, ...additionalCalls, ...drainCalls];
70
- const allSquidCalls = allCalls.map((call) => toSquidCall(call));
71
- return createSquidPayload(refundAndDrainAddress, allSquidCalls);
76
+ if (additionalCalls.length === 0) {
77
+ // normal case: do calls and sweep to user
78
+ const tokensToDrain = inputToken ? [inputToken, outputToken] : [outputToken];
79
+ const drainCalls = createSquidDrainCalls(refundAndDrainAddress, tokensToDrain);
80
+ const allCalls = [...swapCalls, ...drainCalls];
81
+ const allSquidCalls = allCalls.map((call) => toSquidCall(call));
82
+ return createSquidPayload(refundAndDrainAddress, allSquidCalls);
83
+ }
84
+ else {
85
+ // composer case: do calls and continue in composer
86
+ const { forwarder } = requireDeltaContracts(chainId);
87
+ const tokensToDrain = inputToken ? [inputToken] : [];
88
+ const drainToUserCall = createSquidDrainCalls(refundAndDrainAddress, tokensToDrain);
89
+ const drainToForwarder = CurrencyHandler.isNativeAddress(outputToken, chainId)
90
+ ? []
91
+ : createSquidDrainCalls(forwarder, [outputToken]);
92
+ const deltaComposerCall = createDeltaComposerCalldata(chainId, [outputToken], refundAndDrainAddress, additionalCalls);
93
+ const callToComposer = {
94
+ callType: SimpleSquidCallType.FULL_NATIVE_BALANCE,
95
+ target: deltaComposerCall.to,
96
+ callData: deltaComposerCall.calldata,
97
+ };
98
+ const allCalls = [
99
+ ...swapCalls,
100
+ ...drainToUserCall,
101
+ ...drainToForwarder,
102
+ callToComposer,
103
+ ];
104
+ const allSquidCalls = allCalls.map((call) => toSquidCall(call));
105
+ return createSquidPayload(refundAndDrainAddress, allSquidCalls);
106
+ }
72
107
  }
73
108
  function createSquidSwapCalls(destinationSwapData) {
74
109
  const { tokenToApprove, amountToApprove, spender, calls } = destinationSwapData;
75
- console.log('Axelar destinationSwapData', destinationSwapData);
76
110
  if (calls.some((call) => !call.to || !call.calldata)) {
77
111
  throw new Error('Invalid call data');
78
112
  }
@@ -1,5 +1,5 @@
1
- import { convertRawAmount } from '@1delta/aggregators';
2
1
  import { Bridge } from '@1delta/bridge-configs';
2
+ import { convertRawAmount } from '@1delta/lib-utils';
3
3
  import { CurrencyHandler, getDeltaComposerProxyAddress, getForwarderAddress, getSafeChainId, minimumAmountOutFromTrade, nativeOnChain, splitSlippage, TradeType, } from '@1delta/lib-utils';
4
4
  import { fetchBridgeTrade } from '../../bridge';
5
5
  import { createSwapAndBridgeCalldata } from '../utils/createSwapAndBridgeCalldata';
@@ -0,0 +1,7 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { DeltaCall } from '../../../types/deltaCall';
3
+ export declare const createDeltaComposerCalldata: (chainId: string, tokensToSweep: string[], receiver: string, calls: DeltaCall[]) => {
4
+ calldata: Hex;
5
+ to: Address;
6
+ };
7
+ //# sourceMappingURL=createDeltaComposerCalldata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDeltaComposerCalldata.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/utils/deltaComposeCall/createDeltaComposerCalldata.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAIpD,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,eAAe,MAAM,EAAE,EACvB,UAAU,MAAM,EAChB,OAAO,SAAS,EAAE,KACjB;IACD,QAAQ,EAAE,GAAG,CAAA;IACb,EAAE,EAAE,OAAO,CAAA;CA6BZ,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { encodeExternalCall, encodeSweep, SweepType } from '@1delta/calldatalib';
2
+ import { encodeComposerCompose, packCommands } from '@1delta/lib-utils';
3
+ import { requireDeltaContracts } from '../requireDeltaContracts';
4
+ import { toComposerCall } from './toComposerCall';
5
+ export const createDeltaComposerCalldata = (chainId, tokensToSweep, receiver, calls) => {
6
+ const { forwarder, composer } = requireDeltaContracts(chainId);
7
+ const commands = calls.map((call) => toComposerCall(call));
8
+ // sweep tokens at the end
9
+ for (const tokenAddress of tokensToSweep) {
10
+ const sweepCall = encodeSweep(tokenAddress, receiver, 0n, SweepType.VALIDATE);
11
+ commands.push(sweepCall);
12
+ }
13
+ const calldata = encodeComposerCompose(packCommands([
14
+ encodeExternalCall(forwarder, 0n, true, packCommands(commands)),
15
+ ]));
16
+ return { calldata, to: composer };
17
+ };
@@ -0,0 +1,4 @@
1
+ import { Hex } from 'viem';
2
+ import { DeltaCall } from '../../../types/deltaCall';
3
+ export declare function toComposerCall(call: DeltaCall): Hex;
4
+ //# sourceMappingURL=toComposerCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toComposerCall.d.ts","sourceRoot":"","sources":["../../../../src/composedTrades/utils/deltaComposeCall/toComposerCall.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,GAAG,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAiB,MAAM,0BAA0B,CAAA;AAEnE,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,GAAG,CAiCnD"}
@@ -0,0 +1,19 @@
1
+ import { encodeExternalCall, encodeExternalCallWithReplace, encodeSweep, SweepType, } from '@1delta/calldatalib';
2
+ import { DeltaCallType } from '../../../types/deltaCall';
3
+ export function toComposerCall(call) {
4
+ switch (call.callType) {
5
+ case DeltaCallType.FULL_TOKEN_BALANCE: {
6
+ const replaceOffset = 32 * call.balanceOfInjectIndex;
7
+ return encodeExternalCallWithReplace(call.target, call.value ?? 0n, false, call.tokenAddress, replaceOffset, call.callData);
8
+ }
9
+ case DeltaCallType.FULL_NATIVE_BALANCE: {
10
+ return encodeExternalCall(call.target, 0n, true, call.callData);
11
+ }
12
+ case DeltaCallType.SWEEP_WITH_VALIDATION: {
13
+ return encodeSweep(call.tokenAddress, call.receiver, call.limit, SweepType.VALIDATE);
14
+ }
15
+ default: {
16
+ return encodeExternalCall(call.target, call.value ?? 0n, false, call.callData);
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,5 @@
1
+ export declare const requireDeltaContracts: (fromChainId: string) => {
2
+ forwarder: string;
3
+ composer: string;
4
+ };
5
+ //# sourceMappingURL=requireDeltaContracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireDeltaContracts.d.ts","sourceRoot":"","sources":["../../../src/composedTrades/utils/requireDeltaContracts.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,GAAI,aAAa,MAAM;;;CAQxD,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { getDeltaComposerProxyAddress, getForwarderAddress, } from '@1delta/lib-utils';
2
+ export const requireDeltaContracts = (fromChainId) => {
3
+ const forwarder = getForwarderAddress(fromChainId);
4
+ if (!forwarder)
5
+ throw new Error('Forwarder contract not found');
6
+ const composer = getDeltaComposerProxyAddress(fromChainId);
7
+ if (!composer)
8
+ throw new Error('Composer proxy contract not found');
9
+ return { forwarder, composer };
10
+ };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { fetchAggregatorTrade, getAvailableAggregators } from './aggregator';
2
2
  export { fetchBridgeTrade as fetchBridgeTradeWithoutComposed } from './bridge';
3
- export type { SimpleSquidCall, SimpleSquidCallType, } from './composedTrades/axelar/squid/types';
4
3
  export * from './core';
5
4
  export * from './initialize';
6
- export type { BridgeInput } from './types';
5
+ export type { BridgeInput, DeltaCall, DeltaCallType } from './types';
7
6
  export { TradeAggregator } from '@1delta/aggregators';
8
- export { Bridge } from '@1delta/bridge-configs';
9
- export { getStatus as getBridgeStatus } from '@1delta/bridge-core';
10
- export type { useGeneralPricesCallbackType } from '@1delta/lib-utils';
7
+ export { Bridge, getBridges, getCowSwapSlippage, getSwapAggregators, } from '@1delta/bridge-configs';
8
+ export type { Params as BridgeParams, Status as BridgeStatus, } from '@1delta/bridge-core';
9
+ export { getBridgeIcon, getStatus as getBridgeStatus, } from '@1delta/bridge-core';
10
+ export type { AggregatorApiInput, useGeneralPricesCallbackType, } from '@1delta/lib-utils';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,gBAAgB,IAAI,+BAA+B,EAAE,MAAM,UAAU,CAAA;AAC9E,YAAY,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,qCAAqC,CAAA;AAC5C,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAClE,YAAY,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,gBAAgB,IAAI,+BAA+B,EAAE,MAAM,UAAU,CAAA;AAC9E,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EACL,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,MAAM,IAAI,YAAY,EACtB,MAAM,IAAI,YAAY,GACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,aAAa,EACb,SAAS,IAAI,eAAe,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -3,5 +3,5 @@ export { fetchBridgeTrade as fetchBridgeTradeWithoutComposed } from './bridge';
3
3
  export * from './core';
4
4
  export * from './initialize';
5
5
  export { TradeAggregator } from '@1delta/aggregators';
6
- export { Bridge } from '@1delta/bridge-configs';
7
- export { getStatus as getBridgeStatus } from '@1delta/bridge-core';
6
+ export { Bridge, getBridges, getCowSwapSlippage, getSwapAggregators, } from '@1delta/bridge-configs';
7
+ export { getBridgeIcon, getStatus as getBridgeStatus, } from '@1delta/bridge-core';
@@ -5,7 +5,30 @@ type SdkConfig = {
5
5
  loadSquidData: boolean;
6
6
  load1deltaConfigs: boolean;
7
7
  };
8
+ /**
9
+ * Initializes the 1Delta SDK with the provided configuration.
10
+ * This function sets up the production environment flag, loads bridge configurations,
11
+ * initializes chain data, and caches Squid chains based on the provided configuration.
12
+ *
13
+ * @async
14
+ * @param {SdkConfig} config - The configuration object for initializing the SDK
15
+ * @param {boolean} config.isProductionEnv - Whether the environment is production
16
+ * @param {boolean} config.loadChainData - Whether to initialize chain data.
17
+ * When using outside of the 1delta UI, set this to true to load required chain data.
18
+ * @param {boolean} config.loadSquidData - Whether to fetch and cache Squid chains data.
19
+ * When using outside of the 1delta UI, set this to true to load Squid data.
20
+ * @param {boolean} config.load1deltaConfigs - Whether to load and register 1Delta bridge configurations.
21
+ * When using outside of the 1delta UI, set this to true to load bridge configs.
22
+ * @returns {Promise<void>} A promise that resolves when initialization is complete
23
+ *
24
+ * @note When using this SDK outside of the 1delta UI, you should set all parameters to `true`
25
+ * as the data loading is handled by the 1delta UI itself in that context.
26
+ */
8
27
  export declare const initialize: (config: SdkConfig) => Promise<void>;
28
+ /**
29
+ * Sets the wallet client for the SDK and configures bridge settings.
30
+ * This is required for CowSwap functionality to work properly.
31
+ */
9
32
  export declare const setWalletClient: (walletClient: WalletClient) => void;
10
33
  export {};
11
34
  //# sourceMappingURL=initialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAInC,KAAK,SAAS,GAAG;IACf,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,QAAQ,SAAS,KAAG,OAAO,CAAC,IAAI,CAKhE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,YAAY,SAEzD,CAAA"}
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAInC,KAAK,SAAS,GAAG;IACf,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,GAAU,QAAQ,SAAS,KAAG,OAAO,CAAC,IAAI,CAMhE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,cAAc,YAAY,SAEzD,CAAA"}
@@ -1,7 +1,26 @@
1
1
  import { fetchAndCacheSquidChains, getAllBridgeConfigs, setWalletClient as setWalletClientBridgeConfigs, } from '@1delta/bridge-configs';
2
2
  import { registerConfig } from '@1delta/bridge-core';
3
- import { setIsProduction } from '@1delta/lib-utils';
3
+ import { cleanupExpiredCache, setIsProduction } from '@1delta/lib-utils';
4
4
  import { inititalizeChainData } from './data/chainData';
5
+ /**
6
+ * Initializes the 1Delta SDK with the provided configuration.
7
+ * This function sets up the production environment flag, loads bridge configurations,
8
+ * initializes chain data, and caches Squid chains based on the provided configuration.
9
+ *
10
+ * @async
11
+ * @param {SdkConfig} config - The configuration object for initializing the SDK
12
+ * @param {boolean} config.isProductionEnv - Whether the environment is production
13
+ * @param {boolean} config.loadChainData - Whether to initialize chain data.
14
+ * When using outside of the 1delta UI, set this to true to load required chain data.
15
+ * @param {boolean} config.loadSquidData - Whether to fetch and cache Squid chains data.
16
+ * When using outside of the 1delta UI, set this to true to load Squid data.
17
+ * @param {boolean} config.load1deltaConfigs - Whether to load and register 1Delta bridge configurations.
18
+ * When using outside of the 1delta UI, set this to true to load bridge configs.
19
+ * @returns {Promise<void>} A promise that resolves when initialization is complete
20
+ *
21
+ * @note When using this SDK outside of the 1delta UI, you should set all parameters to `true`
22
+ * as the data loading is handled by the 1delta UI itself in that context.
23
+ */
5
24
  export const initialize = async (config) => {
6
25
  setIsProduction(config.isProductionEnv);
7
26
  if (config.load1deltaConfigs)
@@ -10,7 +29,12 @@ export const initialize = async (config) => {
10
29
  await inititalizeChainData();
11
30
  if (config.loadSquidData)
12
31
  await fetchAndCacheSquidChains();
32
+ cleanupExpiredCache();
13
33
  };
34
+ /**
35
+ * Sets the wallet client for the SDK and configures bridge settings.
36
+ * This is required for CowSwap functionality to work properly.
37
+ */
14
38
  export const setWalletClient = (walletClient) => {
15
39
  setWalletClientBridgeConfigs(walletClient);
16
40
  };
@@ -0,0 +1,3 @@
1
+ import { AggregatorApiInput, OneDeltaInput } from '@1delta/lib-utils';
2
+ export type AggregatorInput = AggregatorApiInput | OneDeltaInput;
3
+ //# sourceMappingURL=aggregatorInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregatorInput.d.ts","sourceRoot":"","sources":["../../src/types/aggregatorInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAErE,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,aAAa,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Bridge } from '@1delta/bridge-configs';
2
2
  import { RawCurrency, TradeType } from '@1delta/lib-utils';
3
- import { SimpleSquidCall } from '../composedTrades/axelar/squid/types';
3
+ import { DeltaCall } from './deltaCall';
4
4
  export interface BaseBridgeInput {
5
5
  slippage: number;
6
6
  tradeType: TradeType;
@@ -14,17 +14,17 @@ export interface BaseBridgeInput {
14
14
  usePermit?: boolean;
15
15
  destinationGasLimit?: bigint;
16
16
  }
17
- export interface BaseAxelarComposedInput extends BaseBridgeInput {
18
- additionalCalls?: SimpleSquidCall[];
19
- }
20
- interface AxelarComposedInput {
21
- bridge: Bridge.AXELAR;
22
- input: BaseAxelarComposedInput;
17
+ export interface BaseComposedInput extends BaseBridgeInput {
18
+ additionalCalls?: DeltaCall[];
23
19
  }
20
+ type ComposedInput = {
21
+ bridge: Bridge.ACROSS | Bridge.AXELAR;
22
+ input: BaseComposedInput;
23
+ };
24
24
  interface DefaultBridgeInput extends BaseBridgeInput {
25
- bridge: Exclude<Bridge, Bridge.AXELAR>;
25
+ bridge: Exclude<Bridge, Bridge.AXELAR | Bridge.ACROSS>;
26
26
  input: BaseBridgeInput;
27
27
  }
28
- export type BridgeInput = AxelarComposedInput | DefaultBridgeInput;
28
+ export type BridgeInput = ComposedInput | DefaultBridgeInput;
29
29
  export {};
30
30
  //# sourceMappingURL=bridgeInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridgeInput.d.ts","sourceRoot":"","sources":["../../src/types/bridgeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AAEtE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,EAAE,WAAW,GAAG,SAAS,CAAA;IACrC,UAAU,EAAE,WAAW,GAAG,SAAS,CAAA;IACnC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,eAAe,CAAC,EAAE,eAAe,EAAE,CAAA;CACpC;AAED,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAA;IACrB,KAAK,EAAE,uBAAuB,CAAA;CAC/B;AAED,UAAU,kBAAmB,SAAQ,eAAe;IAClD,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACtC,KAAK,EAAE,eAAe,CAAA;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,CAAA"}
1
+ {"version":3,"file":"bridgeInput.d.ts","sourceRoot":"","sources":["../../src/types/bridgeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,EAAE,WAAW,GAAG,SAAS,CAAA;IACrC,UAAU,EAAE,WAAW,GAAG,SAAS,CAAA;IACnC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,eAAe,CAAC,EAAE,SAAS,EAAE,CAAA;CAC9B;AAED,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IACrC,KAAK,EAAE,iBAAiB,CAAA;CACzB,CAAA;AAED,UAAU,kBAAmB,SAAQ,eAAe;IAClD,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IACtD,KAAK,EAAE,eAAe,CAAA;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,kBAAkB,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { Hex } from 'viem';
2
+ export declare enum DeltaCallType {
3
+ DEFAULT = 0,
4
+ FULL_TOKEN_BALANCE = 1,
5
+ FULL_NATIVE_BALANCE = 2,
6
+ SWEEP_WITH_VALIDATION = 3
7
+ }
8
+ interface BaseCall {
9
+ target: string;
10
+ value?: bigint;
11
+ callData: Hex;
12
+ }
13
+ interface FullTokenBalanceCall extends BaseCall {
14
+ callType: DeltaCallType.FULL_TOKEN_BALANCE;
15
+ tokenAddress: string;
16
+ balanceOfInjectIndex: number;
17
+ }
18
+ interface FullNativeBalanceCall extends Omit<BaseCall, 'value'> {
19
+ callType: DeltaCallType.FULL_NATIVE_BALANCE;
20
+ }
21
+ interface SweepWithValidationCall {
22
+ callType: DeltaCallType.SWEEP_WITH_VALIDATION;
23
+ tokenAddress: string;
24
+ limit: bigint;
25
+ receiver: string;
26
+ }
27
+ interface DefaultCall extends BaseCall {
28
+ callType: DeltaCallType.DEFAULT;
29
+ }
30
+ export type DeltaCall = FullTokenBalanceCall | FullNativeBalanceCall | SweepWithValidationCall | DefaultCall;
31
+ export {};
32
+ //# sourceMappingURL=deltaCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deltaCall.d.ts","sourceRoot":"","sources":["../../src/types/deltaCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE1B,oBAAY,aAAa;IACvB,OAAO,IAAI;IACX,kBAAkB,IAAI;IACtB,mBAAmB,IAAI;IACvB,qBAAqB,IAAI;CAC1B;AAED,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,GAAG,CAAA;CACd;AAED,UAAU,oBAAqB,SAAQ,QAAQ;IAC7C,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAA;IAC1C,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAED,UAAU,qBAAsB,SAAQ,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC7D,QAAQ,EAAE,aAAa,CAAC,mBAAmB,CAAA;CAC5C;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAA;IAC7C,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,WAAY,SAAQ,QAAQ;IACpC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAA;CAChC;AAED,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,uBAAuB,GACvB,WAAW,CAAA"}
@@ -0,0 +1,7 @@
1
+ export var DeltaCallType;
2
+ (function (DeltaCallType) {
3
+ DeltaCallType[DeltaCallType["DEFAULT"] = 0] = "DEFAULT";
4
+ DeltaCallType[DeltaCallType["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
5
+ DeltaCallType[DeltaCallType["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
6
+ DeltaCallType[DeltaCallType["SWEEP_WITH_VALIDATION"] = 3] = "SWEEP_WITH_VALIDATION";
7
+ })(DeltaCallType || (DeltaCallType = {}));
@@ -0,0 +1,8 @@
1
+ import { EvmGenericCallInfo } from '@1delta/lib-utils';
2
+ export interface DestinationSwapData {
3
+ tokenToApprove: string;
4
+ amountToApprove: bigint;
5
+ spender: string;
6
+ calls: EvmGenericCallInfo[];
7
+ }
8
+ //# sourceMappingURL=destinationSwapData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destinationSwapData.d.ts","sourceRoot":"","sources":["../../src/types/destinationSwapData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,kBAAkB,EAAE,CAAA;CAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,5 @@
1
- export * from './aggregator';
1
+ export * from './aggregatorInput';
2
2
  export * from './bridgeInput';
3
+ export * from './deltaCall';
4
+ export * from './destinationSwapData';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA"}
@@ -1,2 +1,4 @@
1
- export * from './aggregator';
1
+ export * from './aggregatorInput';
2
2
  export * from './bridgeInput';
3
+ export * from './deltaCall';
4
+ export * from './destinationSwapData';
@@ -1,4 +1,4 @@
1
- import { convertRawAmount, convertTokenAmount } from '@1delta/aggregators';
1
+ import { convertRawAmount, convertTokenAmount } from '@1delta/lib-utils';
2
2
  import { CurrencyHandler, skimToBigNumber, TradeType, } from '@1delta/lib-utils';
3
3
  import { formatUnits } from 'viem';
4
4
  export const emptyAggregatorInput = {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@1delta/trade-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "1Delta Trade SDK for handling cross-chain swaps and bridges",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "1deltaDAO",
8
8
  "license": "UNLICENSED",
9
9
  "dependencies": {
10
- "@1delta/calldatalib": "^0.0.42",
10
+ "@1delta/calldatalib": "^0.0.46",
11
11
  "viem": "^2.33.0",
12
12
  "@1delta/data-sdk": "^0.0.8",
13
- "@1delta/bridge-configs": "0.1.2",
14
- "@1delta/aggregators": "0.1.2",
13
+ "@1delta/aggregators": "0.1.3",
14
+ "@1delta/bridge-configs": "0.1.3",
15
15
  "@1delta/bridge-core": "0.1.1",
16
16
  "@1delta/lib-utils": "0.1.3"
17
17
  },
@@ -1,11 +0,0 @@
1
- import { AggregatorApiInput, GenericTrade, OneDeltaInput, RawCurrency, RawCurrencyAmount } from '@1delta/lib-utils';
2
- export type AggregatorState = GenericTrade;
3
- export type AggregatorInput = AggregatorApiInput | OneDeltaInput;
4
- export type MultiSwapAggregatorApiInput = Omit<AggregatorApiInput, 'swapAmount' | 'fromCurrency' | 'chainId'> & {
5
- swapAmounts: string[];
6
- fromCurrencies: RawCurrency[];
7
- parsedAmount: RawCurrencyAmount | undefined;
8
- destinationGasToSwap: bigint;
9
- };
10
- export type AggregatorApiValueSetter = (params: AggregatorApiInput) => void;
11
- //# sourceMappingURL=aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG,YAAY,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,aAAa,CAAA;AAEhE,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,kBAAkB,EAClB,YAAY,GAAG,cAAc,GAAG,SAAS,CAC1C,GAAG;IACF,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,cAAc,EAAE,WAAW,EAAE,CAAA;IAC7B,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAA;IAC3C,oBAAoB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA"}