@pafi-dev/core 0.5.22 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abi/index.cjs +3 -7
- package/dist/abi/index.cjs.map +1 -1
- package/dist/abi/index.js +6 -10
- package/dist/chunk-3QDZFDEL.cjs +223 -0
- package/dist/chunk-3QDZFDEL.cjs.map +1 -0
- package/dist/{chunk-Y2MZ7MKJ.js → chunk-6CXTFOIH.js} +196 -2
- package/dist/chunk-6CXTFOIH.js.map +1 -0
- package/dist/{chunk-R6OFGVMP.cjs → chunk-Q6WCDZXI.cjs} +196 -2
- package/dist/chunk-Q6WCDZXI.cjs.map +1 -0
- package/dist/{chunk-TXA4GK5C.js → chunk-UOKI5GG6.js} +87 -7
- package/dist/chunk-UOKI5GG6.js.map +1 -0
- package/dist/eip712/index.cjs +2 -3
- package/dist/eip712/index.cjs.map +1 -1
- package/dist/eip712/index.js +1 -2
- package/dist/index.cjs +205 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -48
- package/dist/index.d.ts +105 -48
- package/dist/index.js +186 -148
- package/dist/index.js.map +1 -1
- package/package.json +1 -31
- package/dist/chunk-2PIXFXA2.js +0 -135
- package/dist/chunk-2PIXFXA2.js.map +0 -1
- package/dist/chunk-CL3QSI4O.cjs +0 -65
- package/dist/chunk-CL3QSI4O.cjs.map +0 -1
- package/dist/chunk-DX73FB4P.cjs +0 -143
- package/dist/chunk-DX73FB4P.cjs.map +0 -1
- package/dist/chunk-IPXARZ6F.cjs +0 -135
- package/dist/chunk-IPXARZ6F.cjs.map +0 -1
- package/dist/chunk-JJ2LGENO.cjs +0 -373
- package/dist/chunk-JJ2LGENO.cjs.map +0 -1
- package/dist/chunk-KFWZRL7I.js +0 -65
- package/dist/chunk-KFWZRL7I.js.map +0 -1
- package/dist/chunk-L5UHQQVC.cjs +0 -136
- package/dist/chunk-L5UHQQVC.cjs.map +0 -1
- package/dist/chunk-R6OFGVMP.cjs.map +0 -1
- package/dist/chunk-TXA4GK5C.js.map +0 -1
- package/dist/chunk-VG23GIWQ.js +0 -373
- package/dist/chunk-VG23GIWQ.js.map +0 -1
- package/dist/chunk-WAFUL62X.js +0 -136
- package/dist/chunk-WAFUL62X.js.map +0 -1
- package/dist/chunk-X2JZFK4C.cjs +0 -87
- package/dist/chunk-X2JZFK4C.cjs.map +0 -1
- package/dist/chunk-Y2MZ7MKJ.js.map +0 -1
- package/dist/chunk-Y3HMGOYW.js +0 -87
- package/dist/chunk-Y3HMGOYW.js.map +0 -1
- package/dist/index-3C_HdEIm.d.cts +0 -227
- package/dist/index-DKtVEoRC.d.ts +0 -227
- package/dist/quoting/index.cjs +0 -19
- package/dist/quoting/index.cjs.map +0 -1
- package/dist/quoting/index.d.cts +0 -59
- package/dist/quoting/index.d.ts +0 -59
- package/dist/quoting/index.js +0 -19
- package/dist/quoting/index.js.map +0 -1
- package/dist/swap/index.cjs +0 -31
- package/dist/swap/index.cjs.map +0 -1
- package/dist/swap/index.d.cts +0 -3
- package/dist/swap/index.d.ts +0 -3
- package/dist/swap/index.js +0 -31
- package/dist/swap/index.js.map +0 -1
package/dist/index-DKtVEoRC.d.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Address, Hex, PublicClient } from 'viem';
|
|
2
|
-
import { Q as QuoteResult, d as PathKey } from './types-JyuXUM8C.js';
|
|
3
|
-
|
|
4
|
-
declare function checkAllowance(client: PublicClient, token: Address, owner: Address, spender: Address): Promise<bigint>;
|
|
5
|
-
/**
|
|
6
|
-
* Encode an ERC-20 approve(spender, amount) call.
|
|
7
|
-
*/
|
|
8
|
-
declare function buildErc20ApprovalCalldata(spender: Address, amount: bigint): Hex;
|
|
9
|
-
/**
|
|
10
|
-
* Encode a Permit2 approve(token, spender, amount, expiration) call.
|
|
11
|
-
*/
|
|
12
|
-
declare function buildPermit2ApprovalCalldata(token: Address, spender: Address, amount: bigint, expiration: number): Hex;
|
|
13
|
-
|
|
14
|
-
/** UniversalRouter command byte for V4 swap */
|
|
15
|
-
declare const V4_SWAP: 16;
|
|
16
|
-
declare const SWAP_EXACT_IN: 7;
|
|
17
|
-
declare const SETTLE_ALL: 12;
|
|
18
|
-
declare const TAKE_ALL: 15;
|
|
19
|
-
/**
|
|
20
|
-
* Build the calldata inputs[0] (the V4_SWAP command payload) for
|
|
21
|
-
* UniversalRouter.execute.
|
|
22
|
-
*
|
|
23
|
-
* Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL
|
|
24
|
-
*
|
|
25
|
-
* Encoding matches the Uniswap V4 SDK's V4Planner — each action's params
|
|
26
|
-
* are individually ABI-encoded, then wrapped together with the action bytes.
|
|
27
|
-
*/
|
|
28
|
-
declare function buildV4SwapInput(currencyIn: Address, path: PathKey[], amountIn: bigint, minAmountOut: bigint, outputCurrency: Address): Hex;
|
|
29
|
-
/**
|
|
30
|
-
* Build the full commands + inputs args for UniversalRouter.execute.
|
|
31
|
-
*/
|
|
32
|
-
declare function buildUniversalRouterExecuteArgs(currencyIn: Address, path: PathKey[], amountIn: bigint, minAmountOut: bigint, outputCurrency: Address): {
|
|
33
|
-
commands: Hex;
|
|
34
|
-
inputs: Hex[];
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Build UniversalRouter execute args from a quote result.
|
|
38
|
-
*
|
|
39
|
-
* Takes the output of `findBestQuote` / `quoteBestRoute` and produces
|
|
40
|
-
* ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.
|
|
41
|
-
*
|
|
42
|
-
* @param quote - Quote result containing the path
|
|
43
|
-
* @param currencyIn - Input token address
|
|
44
|
-
* @param currencyOut - Output token address
|
|
45
|
-
* @param amountIn - Exact input amount (same value passed to the quoter)
|
|
46
|
-
* @param minAmountOut - Minimum acceptable output (caller applies slippage)
|
|
47
|
-
*
|
|
48
|
-
* @deprecated Since v1.4 — the Issuer App no longer handles swaps.
|
|
49
|
-
* For the new PT→USDT batch call on PAFI Web (Scenario 4 with
|
|
50
|
-
* EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).
|
|
51
|
-
* This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.
|
|
52
|
-
*/
|
|
53
|
-
declare function buildSwapFromQuote(params: {
|
|
54
|
-
quote: QuoteResult;
|
|
55
|
-
currencyIn: Address;
|
|
56
|
-
currencyOut: Address;
|
|
57
|
-
amountIn: bigint;
|
|
58
|
-
minAmountOut: bigint;
|
|
59
|
-
}): {
|
|
60
|
-
commands: Hex;
|
|
61
|
-
inputs: Hex[];
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
interface SwapSimulationResult {
|
|
65
|
-
success: boolean;
|
|
66
|
-
gasEstimate: bigint;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).
|
|
70
|
-
*
|
|
71
|
-
* Runs the full V4 swap flow — token transfer via Permit2, swap via
|
|
72
|
-
* PoolManager, output settlement — without submitting a transaction.
|
|
73
|
-
* If the simulation reverts, throws a `SimulationError` with the reason.
|
|
74
|
-
*
|
|
75
|
-
* @param client - viem PublicClient
|
|
76
|
-
* @param routerAddress - UniversalRouter contract address
|
|
77
|
-
* @param commands - Packed command bytes (from buildSwapFromQuote)
|
|
78
|
-
* @param inputs - Encoded inputs per command (from buildSwapFromQuote)
|
|
79
|
-
* @param deadline - Unix timestamp after which the tx expires
|
|
80
|
-
* @param from - Address that will execute the swap
|
|
81
|
-
*/
|
|
82
|
-
declare function simulateSwap(client: PublicClient, routerAddress: Address, commands: Hex, inputs: Hex[], deadline: bigint, from: Address): Promise<SwapSimulationResult>;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* A single call inside a batch. `BatchExecutor.execute(Call[])` iterates
|
|
86
|
-
* and invokes each one. When the batch runs via EIP-7702 delegation,
|
|
87
|
-
* `msg.sender` for each call is the user's EOA.
|
|
88
|
-
*/
|
|
89
|
-
interface Operation {
|
|
90
|
-
target: Address;
|
|
91
|
-
value: bigint;
|
|
92
|
-
data: Hex;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Paymaster fields attached to a UserOperation. Populated by the
|
|
96
|
-
* Coinbase Paymaster (via PAFI Backend proxy) before the user signs.
|
|
97
|
-
*/
|
|
98
|
-
interface PaymasterFields {
|
|
99
|
-
paymaster: Address;
|
|
100
|
-
paymasterData: Hex;
|
|
101
|
-
paymasterVerificationGasLimit: bigint;
|
|
102
|
-
paymasterPostOpGasLimit: bigint;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Partial UserOp used during preparation — before paymaster fields are
|
|
106
|
-
* attached or the user signs.
|
|
107
|
-
*/
|
|
108
|
-
interface PartialUserOperation {
|
|
109
|
-
sender: Address;
|
|
110
|
-
nonce: bigint;
|
|
111
|
-
callData: Hex;
|
|
112
|
-
callGasLimit: bigint;
|
|
113
|
-
verificationGasLimit: bigint;
|
|
114
|
-
preVerificationGas: bigint;
|
|
115
|
-
maxFeePerGas: bigint;
|
|
116
|
-
maxPriorityFeePerGas: bigint;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Full ERC-4337 v0.7 UserOperation, ready for bundler submission.
|
|
120
|
-
*/
|
|
121
|
-
interface UserOperation extends PartialUserOperation {
|
|
122
|
-
paymaster: Address;
|
|
123
|
-
paymasterData: Hex;
|
|
124
|
-
paymasterVerificationGasLimit: bigint;
|
|
125
|
-
paymasterPostOpGasLimit: bigint;
|
|
126
|
-
signature: Hex;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Receipt returned by a bundler after a UserOp lands on-chain.
|
|
130
|
-
*/
|
|
131
|
-
interface UserOpReceipt {
|
|
132
|
-
userOpHash: Hex;
|
|
133
|
-
success: boolean;
|
|
134
|
-
txHash: Hex;
|
|
135
|
-
blockNumber: bigint;
|
|
136
|
-
gasUsed: bigint;
|
|
137
|
-
/** Effective gas cost paid (wei). */
|
|
138
|
-
actualGasCost: bigint;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Sentinel operation value used in tests + docs when `Operation.value`
|
|
142
|
-
* is irrelevant (ERC-20 transfers, for example).
|
|
143
|
-
*/
|
|
144
|
-
declare const ZERO_VALUE = 0n;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with gas fee
|
|
148
|
-
* deducted in PT from the user's balance.
|
|
149
|
-
*
|
|
150
|
-
* Builds an unsigned `PartialUserOperation` that packages up to four
|
|
151
|
-
* inner calls into a single `BatchExecutor.execute(calls[])`:
|
|
152
|
-
*
|
|
153
|
-
* 1. `PT.approve(Permit2, amountIn)` — grant Permit2 ERC-20 allowance
|
|
154
|
-
* 2. `Permit2.approve(PT, router, amountIn, deadline)` — authorize
|
|
155
|
-
* the UniversalRouter to pull PT via Permit2
|
|
156
|
-
* 3. `UniversalRouter.execute(commands, inputs, deadline)` — V4 swap
|
|
157
|
-
* PT → USDT; user receives ≥ `minAmountOut` USDT
|
|
158
|
-
* 4. `PT.transfer(feeRecipient, gasFeePt)` — pay the operator back
|
|
159
|
-
* for sponsoring the gas, in PT (omitted when `gasFeePt` is 0)
|
|
160
|
-
*
|
|
161
|
-
* The user's wallet must hold `amountIn + gasFeePt` PT before the
|
|
162
|
-
* UserOp runs. All inner calls execute atomically via EIP-7702
|
|
163
|
-
* delegation (`msg.sender = user`), so a reverting swap unwinds
|
|
164
|
-
* the approvals and fee transfer too.
|
|
165
|
-
*
|
|
166
|
-
* ## Fee model
|
|
167
|
-
*
|
|
168
|
-
* The gas fee is a separate `transfer` after the swap — it does NOT
|
|
169
|
-
* come out of the USDT output, because that output goes straight to
|
|
170
|
-
* the user's wallet with no intermediate hook.
|
|
171
|
-
*
|
|
172
|
-
* If the FE wants "user receives exactly X USDT after gas":
|
|
173
|
-
* 1. Quote PT→USDT for candidate `amountIn` values
|
|
174
|
-
* 2. Pick an `amountIn` where `minAmountOut ≈ X`
|
|
175
|
-
* 3. Separately compute `gasFeePt` from the operator's rate
|
|
176
|
-
* 4. Ensure user's PT balance ≥ `amountIn + gasFeePt`
|
|
177
|
-
*
|
|
178
|
-
* ## Order of operations
|
|
179
|
-
*
|
|
180
|
-
* Fee transfer is last so a reverting swap also refunds the fee
|
|
181
|
-
* (atomic batch revert semantics).
|
|
182
|
-
*/
|
|
183
|
-
interface BuildSwapWithGasDeductionParams {
|
|
184
|
-
/** User's EOA (with EIP-7702 delegation to BatchExecutor). */
|
|
185
|
-
userAddress: Address;
|
|
186
|
-
/** ERC-4337 account nonce — fetched from EntryPoint by the caller. */
|
|
187
|
-
aaNonce: bigint;
|
|
188
|
-
/** PT token address being swapped. */
|
|
189
|
-
pointTokenAddress: Address;
|
|
190
|
-
/** Destination currency (typically USDT). */
|
|
191
|
-
outputTokenAddress: Address;
|
|
192
|
-
/** UniversalRouter contract address (chain-specific). */
|
|
193
|
-
universalRouterAddress: Address;
|
|
194
|
-
/** PT units to swap. User's balance must be ≥ `amountIn + gasFeePt`. */
|
|
195
|
-
amountIn: bigint;
|
|
196
|
-
/**
|
|
197
|
-
* Minimum USDT to accept out of the swap. Caller applies slippage
|
|
198
|
-
* (typically ~0.5-1%) against a fresh quote. Sub-minimum swap reverts.
|
|
199
|
-
*/
|
|
200
|
-
minAmountOut: bigint;
|
|
201
|
-
/** V4 pool path for the swap. Single-hop = 1 PathKey. */
|
|
202
|
-
swapPath: PathKey[];
|
|
203
|
-
/** Unix seconds. After this, the router rejects the swap. */
|
|
204
|
-
deadline: bigint;
|
|
205
|
-
/** PT amount transferred to `feeRecipient` as gas fee recovery. */
|
|
206
|
-
gasFeePt: bigint;
|
|
207
|
-
/** Where the gas fee lands — typically the operator or fee collector. */
|
|
208
|
-
feeRecipient: Address;
|
|
209
|
-
/** Override ERC-4337 gas estimates. Defaults are conservative; tune down for cheaper UserOps. */
|
|
210
|
-
gasLimits?: {
|
|
211
|
-
callGasLimit?: bigint;
|
|
212
|
-
verificationGasLimit?: bigint;
|
|
213
|
-
preVerificationGas?: bigint;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Build an unsigned UserOp for Scenario 4. Returns a
|
|
218
|
-
* `PartialUserOperation` — caller attaches paymaster sponsorship (via
|
|
219
|
-
* `POST /api/paymaster/sponsor`), adds the user's UserOp-hash
|
|
220
|
-
* signature, and submits to the Bundler.
|
|
221
|
-
*
|
|
222
|
-
* @throws when `amountIn` or `gasFeePt` is not positive, or when
|
|
223
|
-
* `swapPath` is empty (at least one PathKey required).
|
|
224
|
-
*/
|
|
225
|
-
declare function buildSwapWithGasDeduction(params: BuildSwapWithGasDeductionParams): PartialUserOperation;
|
|
226
|
-
|
|
227
|
-
export { type BuildSwapWithGasDeductionParams as B, type Operation as O, type PartialUserOperation as P, type SwapSimulationResult as S, TAKE_ALL as T, type UserOperation as U, V4_SWAP as V, ZERO_VALUE as Z, type PaymasterFields as a, SETTLE_ALL as b, SWAP_EXACT_IN as c, type UserOpReceipt as d, buildErc20ApprovalCalldata as e, buildPermit2ApprovalCalldata as f, buildSwapFromQuote as g, buildSwapWithGasDeduction as h, buildUniversalRouterExecuteArgs as i, buildV4SwapInput as j, checkAllowance as k, simulateSwap as s };
|
package/dist/quoting/index.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkL5UHQQVCcjs = require('../chunk-L5UHQQVC.cjs');
|
|
9
|
-
require('../chunk-CL3QSI4O.cjs');
|
|
10
|
-
require('../chunk-X2JZFK4C.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.buildAllPaths = _chunkL5UHQQVCcjs.buildAllPaths; exports.combineRoutes = _chunkL5UHQQVCcjs.combineRoutes; exports.findBestQuote = _chunkL5UHQQVCcjs.findBestQuote; exports.quoteBestRoute = _chunkL5UHQQVCcjs.quoteBestRoute; exports.quoteExactInput = _chunkL5UHQQVCcjs.quoteExactInput; exports.quoteExactInputSingle = _chunkL5UHQQVCcjs.quoteExactInputSingle;
|
|
19
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/quoting/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,2WAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/quoting/index.cjs"}
|
package/dist/quoting/index.d.cts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Address, PublicClient } from 'viem';
|
|
2
|
-
import { P as PoolKey, d as PathKey, B as BestQuote, Q as QuoteResult } from '../types-JyuXUM8C.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Combine point-token-specific pools and common pools for a given chain.
|
|
6
|
-
* Point token pools are listed first so callers can prioritise them.
|
|
7
|
-
*/
|
|
8
|
-
declare function combineRoutes(chainId: number, pointTokenAddress: Address): PoolKey[];
|
|
9
|
-
/**
|
|
10
|
-
* Build all possible swap paths from `tokenIn` to `tokenOut` using the given
|
|
11
|
-
* pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).
|
|
12
|
-
*
|
|
13
|
-
* Supports both direct single-hop routes and multi-hop routes through
|
|
14
|
-
* intermediate tokens. Each pool is used at most once per path.
|
|
15
|
-
*
|
|
16
|
-
* @param pools - Available pools to route through
|
|
17
|
-
* @param tokenIn - Input token address
|
|
18
|
-
* @param tokenOut - Desired output token address
|
|
19
|
-
* @param maxHops - Maximum number of hops (default 3)
|
|
20
|
-
*/
|
|
21
|
-
declare function buildAllPaths(pools: PoolKey[], tokenIn: Address, tokenOut: Address, maxHops?: number): PathKey[][];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Quote exact-input for a multi-hop path.
|
|
25
|
-
*/
|
|
26
|
-
declare function quoteExactInput(client: PublicClient, quoterAddress: Address, exactCurrency: Address, path: PathKey[], exactAmount: bigint): Promise<QuoteResult>;
|
|
27
|
-
/**
|
|
28
|
-
* Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.
|
|
29
|
-
*/
|
|
30
|
-
declare function quoteExactInputSingle(client: PublicClient, quoterAddress: Address, poolKey: PoolKey, zeroForOne: boolean, exactAmount: bigint, hookData: `0x${string}`): Promise<{
|
|
31
|
-
amountOut: bigint;
|
|
32
|
-
gasEstimate: bigint;
|
|
33
|
-
}>;
|
|
34
|
-
/**
|
|
35
|
-
* Try multiple PathKey[] routes and return the best quote plus all results.
|
|
36
|
-
* Routes that fail (e.g. pool does not exist) are silently skipped.
|
|
37
|
-
*
|
|
38
|
-
* Uses viem multicall to batch all quotes into a single RPC call for speed.
|
|
39
|
-
*/
|
|
40
|
-
declare function quoteBestRoute(client: PublicClient, quoterAddress: Address, exactCurrency: Address, routes: PathKey[][], exactAmount: bigint): Promise<BestQuote>;
|
|
41
|
-
/**
|
|
42
|
-
* Find and quote the best swap route from `tokenIn` to `tokenOut`.
|
|
43
|
-
*
|
|
44
|
-
* Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all
|
|
45
|
-
* possible paths (up to `maxHops`), then quotes them all via a single
|
|
46
|
-
* multicall and returns the best result.
|
|
47
|
-
*
|
|
48
|
-
* @param client - viem PublicClient
|
|
49
|
-
* @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)
|
|
50
|
-
* @param tokenIn - Input token address
|
|
51
|
-
* @param tokenOut - Desired output token address
|
|
52
|
-
* @param exactAmount - Exact input amount
|
|
53
|
-
* @param pools - Additional pools to consider (e.g. point-token-specific)
|
|
54
|
-
* @param quoterAddress - Override the default V4 Quoter address for this chain
|
|
55
|
-
* @param maxHops - Maximum number of hops per path (default 3)
|
|
56
|
-
*/
|
|
57
|
-
declare function findBestQuote(client: PublicClient, chainId: number, tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
|
|
58
|
-
|
|
59
|
-
export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle };
|
package/dist/quoting/index.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Address, PublicClient } from 'viem';
|
|
2
|
-
import { P as PoolKey, d as PathKey, B as BestQuote, Q as QuoteResult } from '../types-JyuXUM8C.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Combine point-token-specific pools and common pools for a given chain.
|
|
6
|
-
* Point token pools are listed first so callers can prioritise them.
|
|
7
|
-
*/
|
|
8
|
-
declare function combineRoutes(chainId: number, pointTokenAddress: Address): PoolKey[];
|
|
9
|
-
/**
|
|
10
|
-
* Build all possible swap paths from `tokenIn` to `tokenOut` using the given
|
|
11
|
-
* pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).
|
|
12
|
-
*
|
|
13
|
-
* Supports both direct single-hop routes and multi-hop routes through
|
|
14
|
-
* intermediate tokens. Each pool is used at most once per path.
|
|
15
|
-
*
|
|
16
|
-
* @param pools - Available pools to route through
|
|
17
|
-
* @param tokenIn - Input token address
|
|
18
|
-
* @param tokenOut - Desired output token address
|
|
19
|
-
* @param maxHops - Maximum number of hops (default 3)
|
|
20
|
-
*/
|
|
21
|
-
declare function buildAllPaths(pools: PoolKey[], tokenIn: Address, tokenOut: Address, maxHops?: number): PathKey[][];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Quote exact-input for a multi-hop path.
|
|
25
|
-
*/
|
|
26
|
-
declare function quoteExactInput(client: PublicClient, quoterAddress: Address, exactCurrency: Address, path: PathKey[], exactAmount: bigint): Promise<QuoteResult>;
|
|
27
|
-
/**
|
|
28
|
-
* Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.
|
|
29
|
-
*/
|
|
30
|
-
declare function quoteExactInputSingle(client: PublicClient, quoterAddress: Address, poolKey: PoolKey, zeroForOne: boolean, exactAmount: bigint, hookData: `0x${string}`): Promise<{
|
|
31
|
-
amountOut: bigint;
|
|
32
|
-
gasEstimate: bigint;
|
|
33
|
-
}>;
|
|
34
|
-
/**
|
|
35
|
-
* Try multiple PathKey[] routes and return the best quote plus all results.
|
|
36
|
-
* Routes that fail (e.g. pool does not exist) are silently skipped.
|
|
37
|
-
*
|
|
38
|
-
* Uses viem multicall to batch all quotes into a single RPC call for speed.
|
|
39
|
-
*/
|
|
40
|
-
declare function quoteBestRoute(client: PublicClient, quoterAddress: Address, exactCurrency: Address, routes: PathKey[][], exactAmount: bigint): Promise<BestQuote>;
|
|
41
|
-
/**
|
|
42
|
-
* Find and quote the best swap route from `tokenIn` to `tokenOut`.
|
|
43
|
-
*
|
|
44
|
-
* Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all
|
|
45
|
-
* possible paths (up to `maxHops`), then quotes them all via a single
|
|
46
|
-
* multicall and returns the best result.
|
|
47
|
-
*
|
|
48
|
-
* @param client - viem PublicClient
|
|
49
|
-
* @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)
|
|
50
|
-
* @param tokenIn - Input token address
|
|
51
|
-
* @param tokenOut - Desired output token address
|
|
52
|
-
* @param exactAmount - Exact input amount
|
|
53
|
-
* @param pools - Additional pools to consider (e.g. point-token-specific)
|
|
54
|
-
* @param quoterAddress - Override the default V4 Quoter address for this chain
|
|
55
|
-
* @param maxHops - Maximum number of hops per path (default 3)
|
|
56
|
-
*/
|
|
57
|
-
declare function findBestQuote(client: PublicClient, chainId: number, tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
|
|
58
|
-
|
|
59
|
-
export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle };
|
package/dist/quoting/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildAllPaths,
|
|
3
|
-
combineRoutes,
|
|
4
|
-
findBestQuote,
|
|
5
|
-
quoteBestRoute,
|
|
6
|
-
quoteExactInput,
|
|
7
|
-
quoteExactInputSingle
|
|
8
|
-
} from "../chunk-WAFUL62X.js";
|
|
9
|
-
import "../chunk-KFWZRL7I.js";
|
|
10
|
-
import "../chunk-Y3HMGOYW.js";
|
|
11
|
-
export {
|
|
12
|
-
buildAllPaths,
|
|
13
|
-
combineRoutes,
|
|
14
|
-
findBestQuote,
|
|
15
|
-
quoteBestRoute,
|
|
16
|
-
quoteExactInput,
|
|
17
|
-
quoteExactInputSingle
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/swap/index.cjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunkJJ2LGENOcjs = require('../chunk-JJ2LGENO.cjs');
|
|
15
|
-
require('../chunk-IPXARZ6F.cjs');
|
|
16
|
-
require('../chunk-X2JZFK4C.cjs');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exports.SETTLE_ALL = _chunkJJ2LGENOcjs.SETTLE_ALL; exports.SWAP_EXACT_IN = _chunkJJ2LGENOcjs.SWAP_EXACT_IN; exports.TAKE_ALL = _chunkJJ2LGENOcjs.TAKE_ALL; exports.V4_SWAP = _chunkJJ2LGENOcjs.V4_SWAP; exports.buildErc20ApprovalCalldata = _chunkJJ2LGENOcjs.buildErc20ApprovalCalldata; exports.buildPermit2ApprovalCalldata = _chunkJJ2LGENOcjs.buildPermit2ApprovalCalldata; exports.buildSwapFromQuote = _chunkJJ2LGENOcjs.buildSwapFromQuote; exports.buildSwapWithGasDeduction = _chunkJJ2LGENOcjs.buildSwapWithGasDeduction; exports.buildUniversalRouterExecuteArgs = _chunkJJ2LGENOcjs.buildUniversalRouterExecuteArgs; exports.buildV4SwapInput = _chunkJJ2LGENOcjs.buildV4SwapInput; exports.checkAllowance = _chunkJJ2LGENOcjs.checkAllowance; exports.simulateSwap = _chunkJJ2LGENOcjs.simulateSwap;
|
|
31
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/swap/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,mxBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"}
|
package/dist/swap/index.d.cts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-3C_HdEIm.cjs';
|
|
2
|
-
import 'viem';
|
|
3
|
-
import '../types-JyuXUM8C.cjs';
|
package/dist/swap/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-DKtVEoRC.js';
|
|
2
|
-
import 'viem';
|
|
3
|
-
import '../types-JyuXUM8C.js';
|
package/dist/swap/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SETTLE_ALL,
|
|
3
|
-
SWAP_EXACT_IN,
|
|
4
|
-
TAKE_ALL,
|
|
5
|
-
V4_SWAP,
|
|
6
|
-
buildErc20ApprovalCalldata,
|
|
7
|
-
buildPermit2ApprovalCalldata,
|
|
8
|
-
buildSwapFromQuote,
|
|
9
|
-
buildSwapWithGasDeduction,
|
|
10
|
-
buildUniversalRouterExecuteArgs,
|
|
11
|
-
buildV4SwapInput,
|
|
12
|
-
checkAllowance,
|
|
13
|
-
simulateSwap
|
|
14
|
-
} from "../chunk-VG23GIWQ.js";
|
|
15
|
-
import "../chunk-2PIXFXA2.js";
|
|
16
|
-
import "../chunk-Y3HMGOYW.js";
|
|
17
|
-
export {
|
|
18
|
-
SETTLE_ALL,
|
|
19
|
-
SWAP_EXACT_IN,
|
|
20
|
-
TAKE_ALL,
|
|
21
|
-
V4_SWAP,
|
|
22
|
-
buildErc20ApprovalCalldata,
|
|
23
|
-
buildPermit2ApprovalCalldata,
|
|
24
|
-
buildSwapFromQuote,
|
|
25
|
-
buildSwapWithGasDeduction,
|
|
26
|
-
buildUniversalRouterExecuteArgs,
|
|
27
|
-
buildV4SwapInput,
|
|
28
|
-
checkAllowance,
|
|
29
|
-
simulateSwap
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=index.js.map
|
package/dist/swap/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|