@pafi-dev/core 0.2.0 → 0.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/{chunk-O7LQKCBT.cjs → chunk-6I6K43RQ.cjs} +1 -1
- package/dist/chunk-6I6K43RQ.cjs.map +1 -0
- package/dist/{chunk-4QOWQQCH.cjs → chunk-L74CZAVQ.cjs} +1 -1
- package/dist/chunk-L74CZAVQ.cjs.map +1 -0
- package/dist/{chunk-37BBGXTS.js → chunk-UU72CX7E.js} +1 -1
- package/dist/{chunk-37BBGXTS.js.map → chunk-UU72CX7E.js.map} +1 -1
- package/dist/{chunk-DSCUHT3F.js → chunk-X4IXUTTD.js} +1 -1
- package/dist/chunk-X4IXUTTD.js.map +1 -0
- package/dist/contract/index.d.cts +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/eip712/index.d.cts +1 -1
- package/dist/eip712/index.d.ts +1 -1
- package/dist/index.cjs +349 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +742 -4
- package/dist/index.d.ts +742 -4
- package/dist/index.js +340 -2
- package/dist/index.js.map +1 -1
- package/dist/quoting/index.d.cts +1 -1
- package/dist/quoting/index.d.ts +1 -1
- package/dist/relay/index.cjs +2 -2
- package/dist/relay/index.d.cts +14 -1
- package/dist/relay/index.d.ts +14 -1
- package/dist/relay/index.js +1 -1
- package/dist/swap/index.cjs +2 -2
- package/dist/swap/index.d.cts +6 -1
- package/dist/swap/index.d.ts +6 -1
- package/dist/swap/index.js +1 -1
- package/dist/{types-CkRJzrZr.d.ts → types-BDOnH5Le.d.cts} +1 -1
- package/dist/{types-CkRJzrZr.d.cts → types-BDOnH5Le.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-4QOWQQCH.cjs.map +0 -1
- package/dist/chunk-DSCUHT3F.js.map +0 -1
- package/dist/chunk-O7LQKCBT.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -5,6 +5,38 @@ signing and verification, EIP-4361 (Sign-In with Ethereum) helpers,
|
|
|
5
5
|
contract ABIs, Relay calldata encoding, on-chain quoting, and swap
|
|
6
6
|
building.
|
|
7
7
|
|
|
8
|
+
## What's new in 0.3.0-alpha.0 — UserOp primitives (v1.4 preview)
|
|
9
|
+
|
|
10
|
+
Preview release adding the **sponsored UserOp building blocks** for
|
|
11
|
+
EIP-7702 + ERC-4337 flows. No breaking changes — all v0.2.x exports
|
|
12
|
+
remain. Additions:
|
|
13
|
+
|
|
14
|
+
- `userop/types.ts` — `UserOperation`, `PartialUserOperation`,
|
|
15
|
+
`Operation`, `ENTRY_POINT_V07` constant
|
|
16
|
+
- `userop/operations.ts` — `erc20TransferOp`, `erc20ApproveOp`,
|
|
17
|
+
`erc20BurnOp`, `rawCallOp`
|
|
18
|
+
- `userop/batchExecute.ts` — `encodeBatchExecute()` +
|
|
19
|
+
`BATCH_EXECUTOR_ABI` (EIP-7702 delegation target)
|
|
20
|
+
- `userop/buildUserOperation.ts` — `buildPartialUserOperation()` +
|
|
21
|
+
`assembleUserOperation()`
|
|
22
|
+
- `paymaster/` — `PaymasterConfig`, `SponsorshipScenario`, module-level
|
|
23
|
+
`setPaymasterConfig` / `getPaymasterConfig`
|
|
24
|
+
- `utils/checkEthAndBranch.ts` — decide sponsored-vs-normal path based
|
|
25
|
+
on the user's native balance
|
|
26
|
+
|
|
27
|
+
**Deprecated:** `buildSwapFromQuote`, `encodeMintAndSwap`,
|
|
28
|
+
`buildRelaySwapParams` — retired from the app-side flow. Still shipped
|
|
29
|
+
for v0.2.x consumers; removed in 2.0.
|
|
30
|
+
|
|
31
|
+
**Not yet ready** (blocked on SC team): `MintRequest` v2 + `BurnConsent`
|
|
32
|
+
EIP-712 builders. Comes in 0.3.0-beta.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add @pafi-dev/core@0.3.0-alpha.0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
8
40
|
**`@pafi-dev/core` is HTTP-client-free on purpose.** It covers only the
|
|
9
41
|
primitives that need a signer or a provider (or neither) — never the
|
|
10
42
|
HTTP wire. The HTTP contract (routes, request/response types) is owned
|
|
@@ -146,4 +146,4 @@ async function simulateSwap(client, routerAddress, commands, inputs, deadline, f
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
exports.checkAllowance = checkAllowance; exports.buildErc20ApprovalCalldata = buildErc20ApprovalCalldata; exports.buildPermit2ApprovalCalldata = buildPermit2ApprovalCalldata; exports.V4_SWAP = V4_SWAP; exports.SWAP_EXACT_IN = SWAP_EXACT_IN; exports.SETTLE_ALL = SETTLE_ALL; exports.TAKE_ALL = TAKE_ALL; exports.buildV4SwapInput = buildV4SwapInput; exports.buildUniversalRouterExecuteArgs = buildUniversalRouterExecuteArgs; exports.buildSwapFromQuote = buildSwapFromQuote; exports.simulateSwap = simulateSwap;
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
149
|
+
//# sourceMappingURL=chunk-6I6K43RQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-6I6K43RQ.cjs","../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/swap/simulate.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACTA,4BAAmC;AAKnC,MAAA,SAAsB,cAAA,CACpB,MAAA,EACA,KAAA,EACA,KAAA,EACA,OAAA,EACiB;AACjB,EAAA,OAAO,MAAA,CAAO,YAAA,CAAa;AAAA,IACzB,OAAA,EAAS,KAAA;AAAA,IACT,GAAA,EAAK,0BAAA;AAAA,IACL,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,KAAA,EAAO,OAAO;AAAA,EACvB,CAAC,CAAA;AACH;AAKO,SAAS,0BAAA,CACd,OAAA,EAC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AA,MACT,GAAA,EAAK,oCAAA;AAAA,MACL,YAAA,EAAc,SAAA;AAAA,MACd,IAAA,EAAM,CAAC,QAAA,EAAU,MAAA,EAAQ,QAAQ,CAAA;AAAA,MACjC,OAAA,EAAS;AAAA,IACX,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,YAAY,CAAA;AAAA,EACtC,EAAA,MAAA,CAAS,KAAA,EAAgB;AACvB,IAAA,MAAM,QAAA,EACJ,MAAA,WAAiB,MAAA,EAAQ,KAAA,CAAM,QAAA,EAAU,0BAAA;AAC3C,IAAA,MAAM,IAAI,sCAAA,CAAgB,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC3C;AACF;AHwFA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,4fAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-6I6K43RQ.cjs","sourcesContent":[null,"import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n *\n * @deprecated Since v1.4 — the Issuer App no longer handles swaps.\n * For the new PT→USDT batch call on PAFI Web (Scenario 4 with\n * EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).\n * This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n"]}
|
|
@@ -96,4 +96,4 @@ async function simulateMintAndSwap(client, relayAddress, mint, swap, from) {
|
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
exports.encodeExtData = encodeExtData; exports.decodeExtData = decodeExtData; exports.buildRelaySwapParams = buildRelaySwapParams; exports.encodeMintAndSwap = encodeMintAndSwap; exports.decodeMintAndSwap = decodeMintAndSwap; exports.simulateMintAndSwap = simulateMintAndSwap;
|
|
99
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-L74CZAVQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-L74CZAVQ.cjs","../src/relay/calldata.ts","../src/relay/simulate.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA;AACE;AACA;AACA;AACA;AAAA,4BACK;AASA,SAAS,aAAA,CAAc,YAAA,EAAsB,SAAA,EAAwB;AAC1E,EAAA,OAAO,uCAAA;AAAA,IACL,CAAC,EAAE,IAAA,EAAM,UAAU,CAAA,EAAG,EAAE,IAAA,EAAM,UAAU,CAAC,CAAA;AAAA,IACzC,CAAC,YAAA,EAAc,SAAS;AAAA,EAC1B,CAAA;AACF;AAKO,SAAS,aAAA,CAAc,OAAA,EAG5B;AACA,EAAA,MAAM,CAAC,YAAA,EAAc,SAAS,EAAA,EAAI,uCAAA;AAAA,IAChC,CAAC,EAAE,IAAA,EAAM,UAAU,CAAA,EAAG,EAAE,IAAA,EAAM,UAAU,CAAC,CAAA;AAAA,IACzC;AAAA,EACF,CAAA;AACA,EAAA,OAAO,EAAE,YAAA,EAAc,UAAU,CAAA;AACnC;AAgBO,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AA,CAAI,oBAAA;AAAA,QAC1B,GAAA,EAAK,GAAA,CAAI,GAAA;AAAA,QACT,WAAA,EAAa,GAAA,CAAI,WAAA;AAAA,QACjB,KAAA,EAAO,GAAA,CAAI,KAAA;AAAA,QACX,QAAA,EAAU,GAAA,CAAI;AAAA,MAChB,CAAA;AAAA,IACF,CAAA;AAAA,IACA,QAAA,EAAU,OAAA,CAAQ;AAAA,EACpB,CAAA;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,KAAK,CAAA;AACtB;AD9DA;AACA;AEhDA,MAAA,SAAsB,mBAAA,CACpB,MAAA,EACA,YAAA,EACA,IAAA,EACA,IAAA,EACA,IAAA,EAC2B;AAC3B,EAAA,IAAI;AACF,IAAA,MAAM,YAAA,EAAc,MAAM,MAAA,CAAO,mBAAA,CAAoB;AAAA,MACnD,OAAA,EAAS,YAAA;AAAA,MACT,GAAA,EAAK,0BAAA;AAAA,MACL,YAAA,EAAc,aAAA;AAAA,MACd,IAAA,EAAM,CAAC,IAAA,EAAM,IAAI,CAAA;AAAA,MACjB,OAAA,EAAS;AAAA,IACX,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,YAAY,CAAA;AAAA,EACtC,EAAA,MAAA,CAAS,KAAA,EAAgB;AACvB,IAAA,MAAM,QAAA,EACJ,MAAA,WAAiB,MAAA,EAAQ,KAAA,CAAM,QAAA,EAAU,0BAAA;AAC3C,IAAA,MAAM,IAAI,sCAAA,CAAgB,aAAA,EAAe,OAAO,CAAA;AAAA,EAClD;AACF;AF0CA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,mRAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-L74CZAVQ.cjs","sourcesContent":[null,"import {\n decodeFunctionData,\n encodeFunctionData,\n encodeAbiParameters,\n decodeAbiParameters,\n} from \"viem\";\nimport type { Hex } from \"viem\";\nimport { relayAbi } from \"../abi/relay\";\nimport type { MintParams, PathKey, SwapParams } from \"../types\";\n\n/**\n * Encode extData for ReceiverConsent and MintParams.\n * extData = abi.encode(uint256 minAmountOut, uint256 feeInUsdt)\n */\nexport function encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex {\n return encodeAbiParameters(\n [{ type: \"uint256\" }, { type: \"uint256\" }],\n [minAmountOut, feeInUsdt],\n );\n}\n\n/**\n * Decode extData back to { minAmountOut, feeInUsdt }.\n */\nexport function decodeExtData(extData: Hex): {\n minAmountOut: bigint;\n feeInUsdt: bigint;\n} {\n const [minAmountOut, feeInUsdt] = decodeAbiParameters(\n [{ type: \"uint256\" }, { type: \"uint256\" }],\n extData,\n );\n return { minAmountOut, feeInUsdt };\n}\n\n/**\n * Build SwapParams and extData from a quote result for Relay.mintAndSwap.\n *\n * @param quote - Quote result containing the path\n * @param minAmountOut - Minimum acceptable USDT output (caller applies slippage)\n * @param feeInUsdt - Fixed USDT fee for the relayer\n * @param deadline - Swap deadline (unix timestamp)\n *\n * @deprecated Since v1.4 — the `claimAndSwap` flow is retired. The\n * Issuer App now performs mint-only claims; swaps happen on PAFI Web.\n * For PT→USDT swap batch calls on PAFI Web, use\n * `buildSwapWithGasDeduction()` (v1.5). This helper is kept for legacy\n * consumers still on v0.2.x and will be removed in v2.0.\n */\nexport function buildRelaySwapParams(params: {\n quote: { path: PathKey[] };\n minAmountOut: bigint;\n feeInUsdt: bigint;\n deadline: bigint;\n}): { swapParams: SwapParams; extData: Hex } {\n return {\n swapParams: {\n path: params.quote.path,\n deadline: params.deadline,\n },\n extData: encodeExtData(params.minAmountOut, params.feeInUsdt),\n };\n}\n\n/**\n * Encode calldata for the legacy `Relayer.mintAndSwap()` function.\n *\n * @deprecated Since v1.4 — the `claimAndSwap` flow is retired. Use\n * `Relayer.mint()` instead (via `@pafi-dev/issuer` RelayService in v1.4).\n * Kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex {\n return encodeFunctionData({\n abi: relayAbi,\n functionName: \"mintAndSwap\",\n args: [mint, swap],\n });\n}\n\nexport function decodeMintAndSwap(calldata: Hex): {\n mint: MintParams;\n swap: SwapParams;\n} {\n const { args } = decodeFunctionData({\n abi: relayAbi,\n data: calldata,\n });\n\n const [rawMint, rawSwap] = args as [\n {\n pointToken: `0x${string}`;\n receiver: `0x${string}`;\n amount: bigint;\n deadline: bigint;\n minterSig: Hex;\n receiverSig: Hex;\n extData: Hex;\n },\n {\n path: ReadonlyArray<{\n intermediateCurrency: `0x${string}`;\n fee: number;\n tickSpacing: number;\n hooks: `0x${string}`;\n hookData: Hex;\n }>;\n deadline: bigint;\n },\n ];\n\n const mint: MintParams = {\n pointToken: rawMint.pointToken,\n receiver: rawMint.receiver,\n amount: rawMint.amount,\n deadline: rawMint.deadline,\n minterSig: rawMint.minterSig,\n receiverSig: rawMint.receiverSig,\n extData: rawMint.extData,\n };\n\n const swap: SwapParams = {\n path: rawSwap.path.map(\n (hop): PathKey => ({\n intermediateCurrency: hop.intermediateCurrency,\n fee: hop.fee,\n tickSpacing: hop.tickSpacing,\n hooks: hop.hooks,\n hookData: hop.hookData,\n }),\n ),\n deadline: rawSwap.deadline,\n };\n\n return { mint, swap };\n}\n","import type { Address, PublicClient } from \"viem\";\nimport { relayAbi } from \"../abi/relay\";\nimport type { MintParams, SwapParams } from \"../types\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a Relay.mintAndSwap call via eth_call (no gas spent).\n *\n * Runs the full flow — signature verification, minting, swap via PoolManager,\n * fee split — without submitting a transaction. If the simulation reverts,\n * throws a `SimulationError` with the revert reason.\n *\n * Call this AFTER both signatures are collected but BEFORE submitting the tx.\n *\n * @param client - viem PublicClient\n * @param relayAddress - Relay contract address\n * @param mint - MintParams (with real minterSig + receiverSig)\n * @param swap - SwapParams (path + deadline)\n * @param from - Address that will call mintAndSwap (the relayer)\n */\nexport async function simulateMintAndSwap(\n client: PublicClient,\n relayAddress: Address,\n mint: MintParams,\n swap: SwapParams,\n from: Address,\n): Promise<SimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: relayAddress,\n abi: relayAbi,\n functionName: \"mintAndSwap\",\n args: [mint, swap],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"mintAndSwap\", message);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/swap/simulate.ts"],"sourcesContent":["import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,0BAA0B;AAKnC,eAAsB,eACpB,QACA,OACA,OACA,SACiB;AACjB,SAAO,OAAO,aAAa;AAAA,IACzB,SAAS;AAAA,IACT,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,OAAO,OAAO;AAAA,EACvB,CAAC;AACH;AAKO,SAAS,2BACd,SACA,QACK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AQ,QAAQ;AAAA,MACjC,SAAS;AAAA,IACX,CAAC;AAED,WAAO,EAAE,SAAS,MAAM,YAAY;AAAA,EACtC,SAAS,OAAgB;AACvB,UAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,UAAM,IAAI,gBAAgB,QAAQ,OAAO;AAAA,EAC3C;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/swap/simulate.ts"],"sourcesContent":["import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n *\n * @deprecated Since v1.4 — the Issuer App no longer handles swaps.\n * For the new PT→USDT batch call on PAFI Web (Scenario 4 with\n * EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).\n * This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,0BAA0B;AAKnC,eAAsB,eACpB,QACA,OACA,OACA,SACiB;AACjB,SAAO,OAAO,aAAa;AAAA,IACzB,SAAS;AAAA,IACT,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC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AAA,MACT,KAAK;AAAA,MACL,cAAc;AAAA,MACd,MAAM,CAAC,UAAU,QAAQ,QAAQ;AAAA,MACjC,SAAS;AAAA,IACX,CAAC;AAED,WAAO,EAAE,SAAS,MAAM,YAAY;AAAA,EACtC,SAAS,OAAgB;AACvB,UAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,UAAM,IAAI,gBAAgB,QAAQ,OAAO;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/relay/calldata.ts","../src/relay/simulate.ts"],"sourcesContent":["import {\n decodeFunctionData,\n encodeFunctionData,\n encodeAbiParameters,\n decodeAbiParameters,\n} from \"viem\";\nimport type { Hex } from \"viem\";\nimport { relayAbi } from \"../abi/relay\";\nimport type { MintParams, PathKey, SwapParams } from \"../types\";\n\n/**\n * Encode extData for ReceiverConsent and MintParams.\n * extData = abi.encode(uint256 minAmountOut, uint256 feeInUsdt)\n */\nexport function encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex {\n return encodeAbiParameters(\n [{ type: \"uint256\" }, { type: \"uint256\" }],\n [minAmountOut, feeInUsdt],\n );\n}\n\n/**\n * Decode extData back to { minAmountOut, feeInUsdt }.\n */\nexport function decodeExtData(extData: Hex): {\n minAmountOut: bigint;\n feeInUsdt: bigint;\n} {\n const [minAmountOut, feeInUsdt] = decodeAbiParameters(\n [{ type: \"uint256\" }, { type: \"uint256\" }],\n extData,\n );\n return { minAmountOut, feeInUsdt };\n}\n\n/**\n * Build SwapParams and extData from a quote result for Relay.mintAndSwap.\n *\n * @param quote - Quote result containing the path\n * @param minAmountOut - Minimum acceptable USDT output (caller applies slippage)\n * @param feeInUsdt - Fixed USDT fee for the relayer\n * @param deadline - Swap deadline (unix timestamp)\n *\n * @deprecated Since v1.4 — the `claimAndSwap` flow is retired. The\n * Issuer App now performs mint-only claims; swaps happen on PAFI Web.\n * For PT→USDT swap batch calls on PAFI Web, use\n * `buildSwapWithGasDeduction()` (v1.5). This helper is kept for legacy\n * consumers still on v0.2.x and will be removed in v2.0.\n */\nexport function buildRelaySwapParams(params: {\n quote: { path: PathKey[] };\n minAmountOut: bigint;\n feeInUsdt: bigint;\n deadline: bigint;\n}): { swapParams: SwapParams; extData: Hex } {\n return {\n swapParams: {\n path: params.quote.path,\n deadline: params.deadline,\n },\n extData: encodeExtData(params.minAmountOut, params.feeInUsdt),\n };\n}\n\n/**\n * Encode calldata for the legacy `Relayer.mintAndSwap()` function.\n *\n * @deprecated Since v1.4 — the `claimAndSwap` flow is retired. Use\n * `Relayer.mint()` instead (via `@pafi-dev/issuer` RelayService in v1.4).\n * Kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex {\n return encodeFunctionData({\n abi: relayAbi,\n functionName: \"mintAndSwap\",\n args: [mint, swap],\n });\n}\n\nexport function decodeMintAndSwap(calldata: Hex): {\n mint: MintParams;\n swap: SwapParams;\n} {\n const { args } = decodeFunctionData({\n abi: relayAbi,\n data: calldata,\n });\n\n const [rawMint, rawSwap] = args as [\n {\n pointToken: `0x${string}`;\n receiver: `0x${string}`;\n amount: bigint;\n deadline: bigint;\n minterSig: Hex;\n receiverSig: Hex;\n extData: Hex;\n },\n {\n path: ReadonlyArray<{\n intermediateCurrency: `0x${string}`;\n fee: number;\n tickSpacing: number;\n hooks: `0x${string}`;\n hookData: Hex;\n }>;\n deadline: bigint;\n },\n ];\n\n const mint: MintParams = {\n pointToken: rawMint.pointToken,\n receiver: rawMint.receiver,\n amount: rawMint.amount,\n deadline: rawMint.deadline,\n minterSig: rawMint.minterSig,\n receiverSig: rawMint.receiverSig,\n extData: rawMint.extData,\n };\n\n const swap: SwapParams = {\n path: rawSwap.path.map(\n (hop): PathKey => ({\n intermediateCurrency: hop.intermediateCurrency,\n fee: hop.fee,\n tickSpacing: hop.tickSpacing,\n hooks: hop.hooks,\n hookData: hop.hookData,\n }),\n ),\n deadline: rawSwap.deadline,\n };\n\n return { mint, swap };\n}\n","import type { Address, PublicClient } from \"viem\";\nimport { relayAbi } from \"../abi/relay\";\nimport type { MintParams, SwapParams } from \"../types\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a Relay.mintAndSwap call via eth_call (no gas spent).\n *\n * Runs the full flow — signature verification, minting, swap via PoolManager,\n * fee split — without submitting a transaction. If the simulation reverts,\n * throws a `SimulationError` with the revert reason.\n *\n * Call this AFTER both signatures are collected but BEFORE submitting the tx.\n *\n * @param client - viem PublicClient\n * @param relayAddress - Relay contract address\n * @param mint - MintParams (with real minterSig + receiverSig)\n * @param swap - SwapParams (path + deadline)\n * @param from - Address that will call mintAndSwap (the relayer)\n */\nexport async function simulateMintAndSwap(\n client: PublicClient,\n relayAddress: Address,\n mint: MintParams,\n swap: SwapParams,\n from: Address,\n): Promise<SimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: relayAddress,\n abi: relayAbi,\n functionName: \"mintAndSwap\",\n args: [mint, swap],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"mintAndSwap\", message);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASA,SAAS,cAAc,cAAsB,WAAwB;AAC1E,SAAO;AAAA,IACL,CAAC,EAAE,MAAM,UAAU,GAAG,EAAE,MAAM,UAAU,CAAC;AAAA,IACzC,CAAC,cAAc,SAAS;AAAA,EAC1B;AACF;AAKO,SAAS,cAAc,SAG5B;AACA,QAAM,CAAC,cAAc,SAAS,IAAI;AAAA,IAChC,CAAC,EAAE,MAAM,UAAU,GAAG,EAAE,MAAM,UAAU,CAAC;AAAA,IACzC;AAAA,EACF;AACA,SAAO,EAAE,cAAc,UAAU;AACnC;AAgBO,SA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,YAAY;AAAA,EACtC,SAAS,OAAgB;AACvB,UAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,UAAM,IAAI,gBAAgB,eAAe,OAAO;AAAA,EAClD;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicClient, Address } from 'viem';
|
|
2
|
-
import { I as Issuer } from '../types-
|
|
2
|
+
import { I as Issuer } from '../types-BDOnH5Le.cjs';
|
|
3
3
|
|
|
4
4
|
declare function getMintRequestNonce(client: PublicClient, pointToken: Address, receiver: Address): Promise<bigint>;
|
|
5
5
|
declare function getReceiverConsentNonce(client: PublicClient, pointToken: Address, receiver: Address): Promise<bigint>;
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicClient, Address } from 'viem';
|
|
2
|
-
import { I as Issuer } from '../types-
|
|
2
|
+
import { I as Issuer } from '../types-BDOnH5Le.js';
|
|
3
3
|
|
|
4
4
|
declare function getMintRequestNonce(client: PublicClient, pointToken: Address, receiver: Address): Promise<bigint>;
|
|
5
5
|
declare function getReceiverConsentNonce(client: PublicClient, pointToken: Address, receiver: Address): Promise<bigint>;
|
package/dist/eip712/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, R as ReceiverConsent } from '../types-BDOnH5Le.cjs';
|
|
2
2
|
import { WalletClient, Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
4
|
declare function buildDomain(config: PointTokenDomainConfig): {
|
package/dist/eip712/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, R as ReceiverConsent } from '../types-BDOnH5Le.js';
|
|
2
2
|
import { WalletClient, Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
4
|
declare function buildDomain(config: PointTokenDomainConfig): {
|