@lendasat/lendaswap-sdk-pure 0.2.24 → 0.2.26

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 (153) hide show
  1. package/dist/arkade-network.d.ts +8 -0
  2. package/dist/arkade-network.d.ts.map +1 -0
  3. package/dist/arkade-network.js +40 -0
  4. package/dist/arkade-network.js.map +1 -0
  5. package/dist/arkade.d.ts.map +1 -1
  6. package/dist/arkade.js +2 -9
  7. package/dist/arkade.js.map +1 -1
  8. package/dist/cctp/constants.d.ts.map +1 -1
  9. package/dist/cctp/constants.js +4 -0
  10. package/dist/cctp/constants.js.map +1 -1
  11. package/dist/cctp/fee.d.ts +49 -0
  12. package/dist/cctp/fee.d.ts.map +1 -0
  13. package/dist/cctp/fee.js +70 -0
  14. package/dist/cctp/fee.js.map +1 -0
  15. package/dist/cctp/index.d.ts +2 -1
  16. package/dist/cctp/index.d.ts.map +1 -1
  17. package/dist/cctp/index.js +2 -1
  18. package/dist/cctp/index.js.map +1 -1
  19. package/dist/cctp/utils.d.ts +15 -0
  20. package/dist/cctp/utils.d.ts.map +1 -1
  21. package/dist/cctp/utils.js +41 -0
  22. package/dist/cctp/utils.js.map +1 -1
  23. package/dist/cctp-bridge/bridge.d.ts +62 -0
  24. package/dist/cctp-bridge/bridge.d.ts.map +1 -0
  25. package/dist/cctp-bridge/bridge.js +74 -0
  26. package/dist/cctp-bridge/bridge.js.map +1 -0
  27. package/dist/cctp-bridge/index.d.ts +17 -0
  28. package/dist/cctp-bridge/index.d.ts.map +1 -0
  29. package/dist/cctp-bridge/index.js +16 -0
  30. package/dist/cctp-bridge/index.js.map +1 -0
  31. package/dist/cctp-inbound/approveAndBurn.d.ts +68 -0
  32. package/dist/cctp-inbound/approveAndBurn.d.ts.map +1 -0
  33. package/dist/cctp-inbound/approveAndBurn.js +95 -0
  34. package/dist/cctp-inbound/approveAndBurn.js.map +1 -0
  35. package/dist/cctp-inbound/burn.d.ts +51 -0
  36. package/dist/cctp-inbound/burn.d.ts.map +1 -0
  37. package/dist/cctp-inbound/burn.js +66 -0
  38. package/dist/cctp-inbound/burn.js.map +1 -0
  39. package/dist/cctp-inbound/chainMap.d.ts +48 -0
  40. package/dist/cctp-inbound/chainMap.d.ts.map +1 -0
  41. package/dist/cctp-inbound/chainMap.js +103 -0
  42. package/dist/cctp-inbound/chainMap.js.map +1 -0
  43. package/dist/cctp-inbound/client.d.ts +1573 -0
  44. package/dist/cctp-inbound/client.d.ts.map +1 -0
  45. package/dist/cctp-inbound/client.js +117 -0
  46. package/dist/cctp-inbound/client.js.map +1 -0
  47. package/dist/cctp-inbound/eip2612.d.ts +77 -0
  48. package/dist/cctp-inbound/eip2612.d.ts.map +1 -0
  49. package/dist/cctp-inbound/eip2612.js +95 -0
  50. package/dist/cctp-inbound/eip2612.js.map +1 -0
  51. package/dist/cctp-inbound/evmSignerAdapter.d.ts +25 -0
  52. package/dist/cctp-inbound/evmSignerAdapter.d.ts.map +1 -0
  53. package/dist/cctp-inbound/evmSignerAdapter.js +50 -0
  54. package/dist/cctp-inbound/evmSignerAdapter.js.map +1 -0
  55. package/dist/cctp-inbound/fundSwap.d.ts +94 -0
  56. package/dist/cctp-inbound/fundSwap.d.ts.map +1 -0
  57. package/dist/cctp-inbound/fundSwap.js +90 -0
  58. package/dist/cctp-inbound/fundSwap.js.map +1 -0
  59. package/dist/cctp-inbound/index.d.ts +35 -0
  60. package/dist/cctp-inbound/index.d.ts.map +1 -0
  61. package/dist/cctp-inbound/index.js +33 -0
  62. package/dist/cctp-inbound/index.js.map +1 -0
  63. package/dist/cctp-inbound/permit2.d.ts +33 -0
  64. package/dist/cctp-inbound/permit2.d.ts.map +1 -0
  65. package/dist/cctp-inbound/permit2.js +32 -0
  66. package/dist/cctp-inbound/permit2.js.map +1 -0
  67. package/dist/cctp-inbound/preflight.d.ts +36 -0
  68. package/dist/cctp-inbound/preflight.d.ts.map +1 -0
  69. package/dist/cctp-inbound/preflight.js +67 -0
  70. package/dist/cctp-inbound/preflight.js.map +1 -0
  71. package/dist/cctp-inbound/smartAccount.d.ts +1518 -0
  72. package/dist/cctp-inbound/smartAccount.d.ts.map +1 -0
  73. package/dist/cctp-inbound/smartAccount.js +117 -0
  74. package/dist/cctp-inbound/smartAccount.js.map +1 -0
  75. package/dist/cctp-inbound/submit.d.ts +75 -0
  76. package/dist/cctp-inbound/submit.d.ts.map +1 -0
  77. package/dist/cctp-inbound/submit.js +126 -0
  78. package/dist/cctp-inbound/submit.js.map +1 -0
  79. package/dist/cctp-inbound/types.d.ts +30 -0
  80. package/dist/cctp-inbound/types.d.ts.map +1 -0
  81. package/dist/cctp-inbound/types.js +5 -0
  82. package/dist/cctp-inbound/types.js.map +1 -0
  83. package/dist/cctp-inbound/userOp.d.ts +93 -0
  84. package/dist/cctp-inbound/userOp.d.ts.map +1 -0
  85. package/dist/cctp-inbound/userOp.js +151 -0
  86. package/dist/cctp-inbound/userOp.js.map +1 -0
  87. package/dist/client.d.ts +166 -6
  88. package/dist/client.d.ts.map +1 -1
  89. package/dist/client.js +565 -32
  90. package/dist/client.js.map +1 -1
  91. package/dist/create/arkade.d.ts.map +1 -1
  92. package/dist/create/arkade.js +21 -19
  93. package/dist/create/arkade.js.map +1 -1
  94. package/dist/create/bitcoin.d.ts.map +1 -1
  95. package/dist/create/bitcoin.js +17 -15
  96. package/dist/create/bitcoin.js.map +1 -1
  97. package/dist/create/evm-to-arkade.d.ts.map +1 -1
  98. package/dist/create/evm-to-arkade.js +2 -0
  99. package/dist/create/evm-to-arkade.js.map +1 -1
  100. package/dist/create/evm-to-bitcoin.d.ts.map +1 -1
  101. package/dist/create/evm-to-bitcoin.js +2 -0
  102. package/dist/create/evm-to-bitcoin.js.map +1 -1
  103. package/dist/create/evm-to-lightning.d.ts.map +1 -1
  104. package/dist/create/evm-to-lightning.js +6 -3
  105. package/dist/create/evm-to-lightning.js.map +1 -1
  106. package/dist/create/lightning.d.ts.map +1 -1
  107. package/dist/create/lightning.js +17 -15
  108. package/dist/create/lightning.js.map +1 -1
  109. package/dist/create/types.d.ts +40 -0
  110. package/dist/create/types.d.ts.map +1 -1
  111. package/dist/delegate.d.ts.map +1 -1
  112. package/dist/delegate.js +2 -31
  113. package/dist/delegate.js.map +1 -1
  114. package/dist/evm/wallet.d.ts +16 -0
  115. package/dist/evm/wallet.d.ts.map +1 -1
  116. package/dist/evm/wallet.js.map +1 -1
  117. package/dist/generated/api.d.ts +408 -2
  118. package/dist/generated/api.d.ts.map +1 -1
  119. package/dist/index.d.ts +3 -2
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +4 -2
  122. package/dist/index.js.map +1 -1
  123. package/dist/redeem/arkade.d.ts.map +1 -1
  124. package/dist/redeem/arkade.js +4 -43
  125. package/dist/redeem/arkade.js.map +1 -1
  126. package/dist/redeem/gasless.d.ts +16 -0
  127. package/dist/redeem/gasless.d.ts.map +1 -1
  128. package/dist/redeem/gasless.js +3 -1
  129. package/dist/redeem/gasless.js.map +1 -1
  130. package/dist/refund/arkade.d.ts.map +1 -1
  131. package/dist/refund/arkade.js +3 -39
  132. package/dist/refund/arkade.js.map +1 -1
  133. package/dist/refund/{collab.d.ts → collab-arkade-evm.d.ts} +6 -6
  134. package/dist/refund/collab-arkade-evm.d.ts.map +1 -0
  135. package/dist/refund/{collab.js → collab-arkade-evm.js} +6 -38
  136. package/dist/refund/collab-arkade-evm.js.map +1 -0
  137. package/dist/refund/collab-arkade-lightning.d.ts +59 -0
  138. package/dist/refund/collab-arkade-lightning.d.ts.map +1 -0
  139. package/dist/refund/collab-arkade-lightning.js +208 -0
  140. package/dist/refund/collab-arkade-lightning.js.map +1 -0
  141. package/dist/refund/index.d.ts +3 -2
  142. package/dist/refund/index.d.ts.map +1 -1
  143. package/dist/refund/index.js +3 -2
  144. package/dist/refund/index.js.map +1 -1
  145. package/dist/tokens.d.ts +18 -0
  146. package/dist/tokens.d.ts.map +1 -1
  147. package/dist/tokens.js +43 -7
  148. package/dist/tokens.js.map +1 -1
  149. package/dist/version.d.ts +2 -2
  150. package/dist/version.js +1 -1
  151. package/package.json +27 -2
  152. package/dist/refund/collab.d.ts.map +0 -1
  153. package/dist/refund/collab.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Source-chain USDC approve + burn for the CCTP-inbound flow.
3
+ *
4
+ * Handles the full source-chain leg in one call:
5
+ * 1. Read current allowance via `EvmSigner.call`. If < `amount`,
6
+ * send an `approve` and wait for its receipt.
7
+ * 2. Call `TokenMessenger.depositForBurn(...)` with `mintRecipient`
8
+ * and `destinationCaller` both pinned to the caller's
9
+ * smart-account address.
10
+ * 3. Return the tx hashes.
11
+ *
12
+ * Takes the SDK's `EvmSigner` so the same signer used for direct
13
+ * Permit2 swaps (wagmi, Privy, raw key via the `evm/wallet` adapter)
14
+ * also powers the CCTP flow.
15
+ */
16
+ import type { Address, Hex } from "viem";
17
+ import type { EvmSigner } from "../evm/wallet.js";
18
+ export interface ApproveAndBurnParams {
19
+ /** SDK signer bound to the source chain. */
20
+ signer: EvmSigner;
21
+ /** USDC amount in smallest units (6 decimals). */
22
+ amount: bigint;
23
+ /** USDC contract address on the source chain. */
24
+ usdcAddress: Address;
25
+ /** CCTP destination domain id (3 = Arbitrum mainnet). */
26
+ destinationDomain: number;
27
+ /**
28
+ * The address that will both (a) receive the minted USDC on the
29
+ * destination chain and (b) be the sole caller allowed to submit
30
+ * `receiveMessage`. For the CCTP-inbound settlement flow this is
31
+ * the caller's Kernel smart-account address.
32
+ */
33
+ smartAccountAddress: Address;
34
+ /**
35
+ * Max CCTPv2 fast-transfer fee in USDC units, from the IRIS fee API.
36
+ * The caller is responsible for fetching this — typical value is
37
+ * ~1/10000 of the amount.
38
+ */
39
+ maxFee: bigint;
40
+ /**
41
+ * CCTP finality threshold. Defaults to fast transfer (1000).
42
+ * Use 2000 for standard (cheaper, ~13 minutes) transfers.
43
+ */
44
+ minFinalityThreshold?: number;
45
+ /**
46
+ * Override the TokenMessenger contract address. Defaults to the
47
+ * canonical CCTPv2 deployment shared across all EVM chains.
48
+ */
49
+ tokenMessengerAddress?: Address;
50
+ /**
51
+ * When `true`, always send `approve` even if existing allowance is
52
+ * sufficient. Defaults to `false` to avoid unnecessary txs.
53
+ */
54
+ forceApprove?: boolean;
55
+ }
56
+ export interface ApproveAndBurnResult {
57
+ /** Tx hash of the USDC approval; omitted when the existing allowance was sufficient. */
58
+ approveTxHash?: Hex;
59
+ /** Tx hash of the `depositForBurn` call. */
60
+ burnTxHash: Hex;
61
+ }
62
+ /**
63
+ * Approve USDC to the TokenMessenger (if needed) then burn it for the
64
+ * cross-chain transfer. Returns the tx hashes. Does NOT wait for the
65
+ * burn receipt — the caller pairs this with `waitForAttestation`.
66
+ */
67
+ export declare function approveAndBurn(params: ApproveAndBurnParams): Promise<ApproveAndBurnResult>;
68
+ //# sourceMappingURL=approveAndBurn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approveAndBurn.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/approveAndBurn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMlD,MAAM,WAAW,oBAAoB;IACnC,4CAA4C;IAC5C,MAAM,EAAE,SAAS,CAAC;IAClB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC;IACrB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,wFAAwF;IACxF,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,GAAG,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAoE/B"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Source-chain USDC approve + burn for the CCTP-inbound flow.
3
+ *
4
+ * Handles the full source-chain leg in one call:
5
+ * 1. Read current allowance via `EvmSigner.call`. If < `amount`,
6
+ * send an `approve` and wait for its receipt.
7
+ * 2. Call `TokenMessenger.depositForBurn(...)` with `mintRecipient`
8
+ * and `destinationCaller` both pinned to the caller's
9
+ * smart-account address.
10
+ * 3. Return the tx hashes.
11
+ *
12
+ * Takes the SDK's `EvmSigner` so the same signer used for direct
13
+ * Permit2 swaps (wagmi, Privy, raw key via the `evm/wallet` adapter)
14
+ * also powers the CCTP flow.
15
+ */
16
+ import { encodeFunctionData, erc20Abi, parseAbi } from "viem";
17
+ import { FINALITY_FAST, TOKEN_MESSENGER_V2 } from "../cctp/constants.js";
18
+ import { addressToBytes32 } from "../cctp/utils.js";
19
+ const TOKEN_MESSENGER_ABI = parseAbi([
20
+ "function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold) external returns (uint64)",
21
+ ]);
22
+ /**
23
+ * Approve USDC to the TokenMessenger (if needed) then burn it for the
24
+ * cross-chain transfer. Returns the tx hashes. Does NOT wait for the
25
+ * burn receipt — the caller pairs this with `waitForAttestation`.
26
+ */
27
+ export async function approveAndBurn(params) {
28
+ const { signer, amount, usdcAddress, destinationDomain, smartAccountAddress, maxFee, minFinalityThreshold = FINALITY_FAST, tokenMessengerAddress = TOKEN_MESSENGER_V2, forceApprove = false, } = params;
29
+ // 1. Allowance check — skip `approve` if the user already granted
30
+ // enough USDC to the TokenMessenger. Saves a tx + signature
31
+ // prompt on repeat swaps.
32
+ let approveTxHash;
33
+ const needsApprove = forceApprove ||
34
+ !(await hasEnoughAllowance({
35
+ signer,
36
+ usdcAddress,
37
+ spender: tokenMessengerAddress,
38
+ minAmount: amount,
39
+ }));
40
+ if (needsApprove) {
41
+ approveTxHash = (await signer.sendTransaction({
42
+ to: usdcAddress,
43
+ data: encodeFunctionData({
44
+ abi: erc20Abi,
45
+ functionName: "approve",
46
+ args: [tokenMessengerAddress, amount],
47
+ }),
48
+ }));
49
+ // Wait for the approve to mine — otherwise depositForBurn sees a
50
+ // stale allowance and reverts.
51
+ const receipt = await signer.waitForReceipt(approveTxHash);
52
+ if (receipt.status !== "success") {
53
+ throw new Error(`USDC approve reverted: tx ${approveTxHash}`);
54
+ }
55
+ }
56
+ // 2. Burn. `mintRecipient` and `destinationCaller` both pinned to
57
+ // the smart-account address:
58
+ // - Destination USDC mints into the smart account (not the EOA).
59
+ // - Only that account can call `receiveMessage` on the
60
+ // destination chain → blocks front-runners from drawing gas
61
+ // from our paymaster via a racing UserOp.
62
+ const recipientBytes32 = addressToBytes32(smartAccountAddress);
63
+ const burnTxHash = (await signer.sendTransaction({
64
+ to: tokenMessengerAddress,
65
+ data: encodeFunctionData({
66
+ abi: TOKEN_MESSENGER_ABI,
67
+ functionName: "depositForBurn",
68
+ args: [
69
+ amount,
70
+ destinationDomain,
71
+ recipientBytes32,
72
+ usdcAddress,
73
+ recipientBytes32,
74
+ maxFee,
75
+ minFinalityThreshold,
76
+ ],
77
+ }),
78
+ }));
79
+ return { approveTxHash, burnTxHash };
80
+ }
81
+ /** ERC-20 `allowance(owner, spender)` read via `EvmSigner.call`. */
82
+ async function hasEnoughAllowance(args) {
83
+ const { signer, usdcAddress, spender, minAmount } = args;
84
+ const data = encodeFunctionData({
85
+ abi: erc20Abi,
86
+ functionName: "allowance",
87
+ args: [signer.address, spender],
88
+ });
89
+ const result = await signer.call({ to: usdcAddress, data });
90
+ // `allowance` returns uint256 — 32 bytes, big-endian hex.
91
+ const hex = result.replace(/^0x/, "") || "0";
92
+ const current = BigInt(`0x${hex}`);
93
+ return current >= minAmount;
94
+ }
95
+ //# sourceMappingURL=approveAndBurn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approveAndBurn.js","sourceRoot":"","sources":["../../src/cctp-inbound/approveAndBurn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACnC,+MAA+M;CAChN,CAAC,CAAC;AAgDH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B;IAE5B,MAAM,EACJ,MAAM,EACN,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,MAAM,EACN,oBAAoB,GAAG,aAAa,EACpC,qBAAqB,GAAG,kBAA6B,EACrD,YAAY,GAAG,KAAK,GACrB,GAAG,MAAM,CAAC;IAEX,kEAAkE;IAClE,+DAA+D;IAC/D,6BAA6B;IAC7B,IAAI,aAA8B,CAAC;IACnC,MAAM,YAAY,GAChB,YAAY;QACZ,CAAC,CAAC,MAAM,kBAAkB,CAAC;YACzB,MAAM;YACN,WAAW;YACX,OAAO,EAAE,qBAAqB;YAC9B,SAAS,EAAE,MAAM;SAClB,CAAC,CAAC,CAAC;IAEN,IAAI,YAAY,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC;YAC5C,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,kBAAkB,CAAC;gBACvB,GAAG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AAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,0DAA0D;IAC1D,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACnC,OAAO,OAAO,IAAI,SAAS,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Source-chain burn calldata for the CCTP-inbound flow.
3
+ *
4
+ * Encodes `TokenMessenger.depositForBurn(...)` on CCTPv2. The user submits
5
+ * this tx on the source chain (e.g. Optimism, Base); the resulting CCTP
6
+ * message lets our backend's Multicall3 tx on Arbitrum call
7
+ * `receiveMessage` to mint USDC to the SDK-derived Arbitrum address.
8
+ *
9
+ * Note: we intentionally use the plain `depositForBurn` (no hook), with
10
+ * `destinationCaller = bytes32(0)` so anyone can call `receiveMessage`.
11
+ * The HTLC-locking logic lives on the Arbitrum side inside the multicall,
12
+ * not in a CCTP hook.
13
+ */
14
+ /** Parameters for `depositForBurn` on CCTPv2 TokenMessenger. */
15
+ export interface DepositForBurnParams {
16
+ /** USDC amount in smallest units (6 decimals). */
17
+ amount: bigint;
18
+ /** CCTP destination domain ID (e.g. 3 = Arbitrum). */
19
+ destinationDomain: number;
20
+ /**
21
+ * Destination address the USDC will be minted to. Accepts either a 20-byte
22
+ * EVM address (will be left-padded to bytes32) or a pre-padded bytes32 hex.
23
+ */
24
+ mintRecipient: string;
25
+ /** Source-chain USDC contract address. */
26
+ burnToken: string;
27
+ /**
28
+ * Bytes32-encoded address allowed to call `receiveMessage` on destination.
29
+ * Defaults to `bytes32(0)` — unrestricted, required for our backend-
30
+ * submitted multicall flow.
31
+ */
32
+ destinationCaller?: string;
33
+ /**
34
+ * Maximum CCTPv2 fast-transfer fee in USDC units (from IRIS fee API).
35
+ * Ignored if `minFinalityThreshold` is ≥ standard.
36
+ */
37
+ maxFee: bigint;
38
+ /**
39
+ * Finality threshold: `FINALITY_FAST` (1000) for fast transfers,
40
+ * `FINALITY_STANDARD` (2000) for slow. Defaults to fast.
41
+ */
42
+ minFinalityThreshold?: number;
43
+ }
44
+ /**
45
+ * Encodes the `depositForBurn` call data for CCTPv2 TokenMessenger.
46
+ *
47
+ * Returns a 0x-prefixed hex string ready to submit as a tx's `data` field
48
+ * against the source chain's TokenMessenger address.
49
+ */
50
+ export declare function encodeDepositForBurn(params: DepositForBurnParams): string;
51
+ //# sourceMappingURL=burn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/burn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAyBzE"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Source-chain burn calldata for the CCTP-inbound flow.
3
+ *
4
+ * Encodes `TokenMessenger.depositForBurn(...)` on CCTPv2. The user submits
5
+ * this tx on the source chain (e.g. Optimism, Base); the resulting CCTP
6
+ * message lets our backend's Multicall3 tx on Arbitrum call
7
+ * `receiveMessage` to mint USDC to the SDK-derived Arbitrum address.
8
+ *
9
+ * Note: we intentionally use the plain `depositForBurn` (no hook), with
10
+ * `destinationCaller = bytes32(0)` so anyone can call `receiveMessage`.
11
+ * The HTLC-locking logic lives on the Arbitrum side inside the multicall,
12
+ * not in a CCTP hook.
13
+ */
14
+ import { keccak_256 } from "@noble/hashes/sha3.js";
15
+ import { bytesToHex } from "@noble/hashes/utils.js";
16
+ import { FINALITY_FAST } from "../cctp/constants.js";
17
+ import { addressToBytes32 } from "../cctp/utils.js";
18
+ /**
19
+ * Encodes the `depositForBurn` call data for CCTPv2 TokenMessenger.
20
+ *
21
+ * Returns a 0x-prefixed hex string ready to submit as a tx's `data` field
22
+ * against the source chain's TokenMessenger address.
23
+ */
24
+ export function encodeDepositForBurn(params) {
25
+ const destinationCaller = params.destinationCaller ??
26
+ "0x0000000000000000000000000000000000000000000000000000000000000000";
27
+ const minFinalityThreshold = params.minFinalityThreshold ?? FINALITY_FAST;
28
+ // depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32)
29
+ const selector = keccak256Hex("depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32)").slice(0, 10);
30
+ const mintRecipientBytes32 = ensureBytes32(params.mintRecipient);
31
+ const destinationCallerBytes32 = ensureBytes32(destinationCaller);
32
+ const encoded = selector +
33
+ encodeUint256(params.amount) +
34
+ encodeUint256(BigInt(params.destinationDomain)) +
35
+ stripHex(mintRecipientBytes32) +
36
+ encodeAddress(params.burnToken) +
37
+ stripHex(destinationCallerBytes32) +
38
+ encodeUint256(params.maxFee) +
39
+ encodeUint256(BigInt(minFinalityThreshold));
40
+ return encoded;
41
+ }
42
+ function ensureBytes32(value) {
43
+ const clean = value.replace(/^0x/, "");
44
+ if (clean.length === 64) {
45
+ return `0x${clean.toLowerCase()}`;
46
+ }
47
+ if (clean.length === 40) {
48
+ return addressToBytes32(value);
49
+ }
50
+ throw new Error(`Invalid mintRecipient/destinationCaller: expected 20-byte address or 32-byte hex, got ${clean.length / 2} bytes`);
51
+ }
52
+ function keccak256Hex(input) {
53
+ return `0x${bytesToHex(keccak_256(new TextEncoder().encode(input)))}`;
54
+ }
55
+ function encodeUint256(value) {
56
+ if (value < 0n)
57
+ throw new Error("uint256 cannot be negative");
58
+ return value.toString(16).padStart(64, "0");
59
+ }
60
+ function encodeAddress(address) {
61
+ return address.replace(/^0x/, "").toLowerCase().padStart(64, "0");
62
+ }
63
+ function stripHex(value) {
64
+ return value.replace(/^0x/, "").toLowerCase();
65
+ }
66
+ //# sourceMappingURL=burn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn.js","sourceRoot":"","sources":["../../src/cctp-inbound/burn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiCpD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,MAAM,iBAAiB,GACrB,MAAM,CAAC,iBAAiB;QACxB,oEAAoE,CAAC;IACvE,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,IAAI,aAAa,CAAC;IAE1E,wEAAwE;IACxE,MAAM,QAAQ,GAAG,YAAY,CAC3B,uEAAuE,CACxE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEf,MAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,wBAAwB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAElE,MAAM,OAAO,GACX,QAAQ;QACR,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QAC5B,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/C,QAAQ,CAAC,oBAAoB,CAAC;QAC9B,aAAa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,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Map EVM chain IDs to CCTPv2 source-chain metadata (domain + USDC
3
+ * address) for the consuming side of the CCTP-inbound flow.
4
+ *
5
+ * Callers pass `signer.chainId`; the SDK derives the CCTP domain +
6
+ * the source-chain USDC address from that alone, so the public API
7
+ * doesn't need a redundant "sourceChain" string.
8
+ */
9
+ import type { Chain, Hex } from "viem";
10
+ import { type CctpChainName } from "../cctp/constants.js";
11
+ /** Canonical EVM chain id → CCTP chain name. */
12
+ export declare const CHAIN_ID_TO_CCTP_NAME: Record<number, CctpChainName>;
13
+ /**
14
+ * EVM chain ids the Lendaswap backend accepts directly as a swap
15
+ * source via Permit2 — these chains are also CCTP-supported, but
16
+ * we never route them through CCTP since a direct-Permit2 funding
17
+ * is cheaper and faster.
18
+ */
19
+ export declare const DIRECT_SOURCE_CHAIN_IDS: ReadonlySet<number>;
20
+ /**
21
+ * `true` when `chainId` is a CCTP-supported source that the backend
22
+ * does NOT accept directly — i.e. funding a swap from this chain
23
+ * requires a CCTP hop to Arbitrum before the HTLC is created.
24
+ */
25
+ export declare function isCctpOnlySource(chainId: number): boolean;
26
+ /**
27
+ * Look up CCTPv2 domain id + native USDC address for a given chain id.
28
+ * Throws with a clear error if the chain is unsupported.
29
+ */
30
+ export declare function cctpMetaForChainId(chainId: number): {
31
+ name: CctpChainName;
32
+ domain: number;
33
+ usdc: Hex;
34
+ };
35
+ /**
36
+ * Map of CCTP source chain id → viem `Chain` object. Mirrors
37
+ * [`CHAIN_ID_TO_CCTP_NAME`] — keep them in lockstep when adding chains.
38
+ *
39
+ * Exposed so browser consumers (wagmi, viem clients) don't have to maintain
40
+ * their own parallel mapping; tree-shakable so non-browser consumers don't
41
+ * pay the bundle cost.
42
+ */
43
+ export declare const CCTP_VIEM_CHAINS: Record<number, Chain>;
44
+ /** Look up the viem `Chain` for a CCTP source chain id, or `undefined`. */
45
+ export declare function getCctpViemChain(chainId: number): Chain | undefined;
46
+ /** Look up the viem `Chain` for a CCTP source chain name, or `undefined`. */
47
+ export declare function getCctpViemChainByName(name: string): Chain | undefined;
48
+ //# sourceMappingURL=chainMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chainMap.d.ts","sourceRoot":"","sources":["../../src/cctp-inbound/chainMap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAiBvC,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAE9B,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAgB/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAItD,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IACnD,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAkBA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAelD,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAEnE;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAKtE"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Map EVM chain IDs to CCTPv2 source-chain metadata (domain + USDC
3
+ * address) for the consuming side of the CCTP-inbound flow.
4
+ *
5
+ * Callers pass `signer.chainId`; the SDK derives the CCTP domain +
6
+ * the source-chain USDC address from that alone, so the public API
7
+ * doesn't need a redundant "sourceChain" string.
8
+ */
9
+ import { arbitrum, avalanche, base, hyperEvm, ink, linea, mainnet, monad, optimism, polygon, sei, sonic, unichain, worldchain, } from "viem/chains";
10
+ import { CCTP_DOMAINS, USDC_ADDRESSES, } from "../cctp/constants.js";
11
+ /** Canonical EVM chain id → CCTP chain name. */
12
+ export const CHAIN_ID_TO_CCTP_NAME = {
13
+ 1: "Ethereum",
14
+ 10: "Optimism",
15
+ 130: "Unichain",
16
+ 137: "Polygon",
17
+ 146: "Sonic",
18
+ 1329: "Sei",
19
+ 8453: "Base",
20
+ 42161: "Arbitrum",
21
+ 43114: "Avalanche",
22
+ 59144: "Linea",
23
+ 480: "World Chain",
24
+ 57073: "Ink",
25
+ 999: "HyperEVM",
26
+ 143: "Monad",
27
+ // Solana lands later (non-EVM, needs a different signer path).
28
+ };
29
+ /**
30
+ * EVM chain ids the Lendaswap backend accepts directly as a swap
31
+ * source via Permit2 — these chains are also CCTP-supported, but
32
+ * we never route them through CCTP since a direct-Permit2 funding
33
+ * is cheaper and faster.
34
+ */
35
+ export const DIRECT_SOURCE_CHAIN_IDS = new Set([
36
+ 1, // Ethereum
37
+ 137, // Polygon
38
+ 42161, // Arbitrum
39
+ ]);
40
+ /**
41
+ * `true` when `chainId` is a CCTP-supported source that the backend
42
+ * does NOT accept directly — i.e. funding a swap from this chain
43
+ * requires a CCTP hop to Arbitrum before the HTLC is created.
44
+ */
45
+ export function isCctpOnlySource(chainId) {
46
+ return (chainId in CHAIN_ID_TO_CCTP_NAME && !DIRECT_SOURCE_CHAIN_IDS.has(chainId));
47
+ }
48
+ /**
49
+ * Look up CCTPv2 domain id + native USDC address for a given chain id.
50
+ * Throws with a clear error if the chain is unsupported.
51
+ */
52
+ export function cctpMetaForChainId(chainId) {
53
+ const name = CHAIN_ID_TO_CCTP_NAME[chainId];
54
+ if (!name) {
55
+ throw new Error(`Chain id ${chainId} is not a supported CCTP source chain. Supported ids: ${Object.keys(CHAIN_ID_TO_CCTP_NAME).join(", ")}.`);
56
+ }
57
+ const usdc = USDC_ADDRESSES[name];
58
+ if (!usdc) {
59
+ throw new Error(`CCTP chain ${name} has no native USDC address in the SDK registry.`);
60
+ }
61
+ return {
62
+ name,
63
+ domain: CCTP_DOMAINS[name],
64
+ usdc: usdc,
65
+ };
66
+ }
67
+ /**
68
+ * Map of CCTP source chain id → viem `Chain` object. Mirrors
69
+ * [`CHAIN_ID_TO_CCTP_NAME`] — keep them in lockstep when adding chains.
70
+ *
71
+ * Exposed so browser consumers (wagmi, viem clients) don't have to maintain
72
+ * their own parallel mapping; tree-shakable so non-browser consumers don't
73
+ * pay the bundle cost.
74
+ */
75
+ export const CCTP_VIEM_CHAINS = {
76
+ 1: mainnet,
77
+ 10: optimism,
78
+ 130: unichain,
79
+ 137: polygon,
80
+ 146: sonic,
81
+ 1329: sei,
82
+ 8453: base,
83
+ 42161: arbitrum,
84
+ 43114: avalanche,
85
+ 59144: linea,
86
+ 480: worldchain,
87
+ 57073: ink,
88
+ 999: hyperEvm,
89
+ 143: monad,
90
+ };
91
+ /** Look up the viem `Chain` for a CCTP source chain id, or `undefined`. */
92
+ export function getCctpViemChain(chainId) {
93
+ return CCTP_VIEM_CHAINS[chainId];
94
+ }
95
+ /** Look up the viem `Chain` for a CCTP source chain name, or `undefined`. */
96
+ export function getCctpViemChainByName(name) {
97
+ for (const [chainId, chainName] of Object.entries(CHAIN_ID_TO_CCTP_NAME)) {
98
+ if (chainName === name)
99
+ return CCTP_VIEM_CHAINS[Number(chainId)];
100
+ }
101
+ return undefined;
102
+ }
103
+ //# sourceMappingURL=chainMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chainMap.js","sourceRoot":"","sources":["../../src/cctp-inbound/chainMap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,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