@pafi-dev/core 0.3.0-beta.1 → 0.3.0-beta.11
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 +99 -1118
- package/dist/abi/index.cjs +2 -6
- package/dist/abi/index.cjs.map +1 -1
- package/dist/abi/index.d.cts +1 -286
- package/dist/abi/index.d.ts +1 -286
- package/dist/abi/index.js +1 -5
- package/dist/{chunk-R4L66ZR5.js → chunk-73CQTNLB.js} +10 -1
- package/dist/chunk-73CQTNLB.js.map +1 -0
- package/dist/{chunk-5YH4D7QF.js → chunk-7UBO7DY5.js} +1 -1
- package/dist/{chunk-FGKLDKJK.cjs → chunk-ALCWYDVG.cjs} +1 -1
- package/dist/{chunk-FGKLDKJK.cjs.map → chunk-ALCWYDVG.cjs.map} +1 -1
- package/dist/{chunk-X3I5XWAR.cjs → chunk-CQCSQPWG.cjs} +2 -15
- package/dist/chunk-CQCSQPWG.cjs.map +1 -0
- package/dist/{chunk-CWP4PFOP.cjs → chunk-DMW67WBU.cjs} +11 -2
- package/dist/chunk-DMW67WBU.cjs.map +1 -0
- package/dist/{chunk-C4ZDYG4D.js → chunk-DUY7Z2AI.js} +48 -6
- package/dist/chunk-DUY7Z2AI.js.map +1 -0
- package/dist/{chunk-CXFUP2YK.cjs → chunk-EDR5SFJN.cjs} +46 -6
- package/dist/chunk-EDR5SFJN.cjs.map +1 -0
- package/dist/{chunk-FIKTQR7H.js → chunk-I2P3TIP7.js} +2 -2
- package/dist/{chunk-BNTVOKYT.cjs → chunk-KJKDLD7N.cjs} +51 -9
- package/dist/chunk-KJKDLD7N.cjs.map +1 -0
- package/dist/{chunk-VQSRCMMK.js → chunk-QGO6X6LG.js} +2 -15
- package/dist/chunk-QGO6X6LG.js.map +1 -0
- package/dist/{chunk-IK4UK7KT.js → chunk-W23EJNYG.js} +44 -4
- package/dist/chunk-W23EJNYG.js.map +1 -0
- package/dist/{chunk-CAE2BVKI.cjs → chunk-Z2V525IS.cjs} +6 -6
- package/dist/{chunk-CAE2BVKI.cjs.map → chunk-Z2V525IS.cjs.map} +1 -1
- package/dist/contract/index.cjs +2 -5
- package/dist/contract/index.cjs.map +1 -1
- package/dist/contract/index.d.cts +2 -4
- package/dist/contract/index.d.ts +2 -4
- package/dist/contract/index.js +1 -4
- package/dist/eip712/index.cjs +9 -3
- package/dist/eip712/index.cjs.map +1 -1
- package/dist/eip712/index.d.cts +44 -2
- package/dist/eip712/index.d.ts +44 -2
- package/dist/eip712/index.js +8 -2
- package/dist/{index-CNALKsH1.d.ts → index-B06IJlHe.d.ts} +1 -1
- package/dist/{index-BpUYHGu3.d.cts → index-B7pGBych.d.cts} +1 -1
- package/dist/index.cjs +434 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +905 -411
- package/dist/index.d.ts +905 -411
- package/dist/index.js +447 -260
- package/dist/index.js.map +1 -1
- package/dist/quoting/index.cjs +3 -3
- package/dist/quoting/index.d.cts +1 -1
- package/dist/quoting/index.d.ts +1 -1
- package/dist/quoting/index.js +2 -2
- package/dist/swap/index.cjs +2 -3
- package/dist/swap/index.cjs.map +1 -1
- package/dist/swap/index.d.cts +2 -2
- package/dist/swap/index.d.ts +2 -2
- package/dist/swap/index.js +1 -2
- package/dist/{types-BDOnH5Le.d.cts → types-b5_Tokjl.d.cts} +8 -17
- package/dist/{types-BDOnH5Le.d.ts → types-b5_Tokjl.d.ts} +8 -17
- package/package.json +1 -1
- package/dist/chunk-27V32VNM.cjs +0 -370
- package/dist/chunk-27V32VNM.cjs.map +0 -1
- package/dist/chunk-4RYBJLF3.js +0 -370
- package/dist/chunk-4RYBJLF3.js.map +0 -1
- package/dist/chunk-5QJZT7VB.cjs +0 -46
- package/dist/chunk-5QJZT7VB.cjs.map +0 -1
- package/dist/chunk-BNTVOKYT.cjs.map +0 -1
- package/dist/chunk-C4ZDYG4D.js.map +0 -1
- package/dist/chunk-CWP4PFOP.cjs.map +0 -1
- package/dist/chunk-CXFUP2YK.cjs.map +0 -1
- package/dist/chunk-IK4UK7KT.js.map +0 -1
- package/dist/chunk-L74CZAVQ.cjs +0 -99
- package/dist/chunk-L74CZAVQ.cjs.map +0 -1
- package/dist/chunk-P56TUGTS.js +0 -46
- package/dist/chunk-P56TUGTS.js.map +0 -1
- package/dist/chunk-R4L66ZR5.js.map +0 -1
- package/dist/chunk-VQSRCMMK.js.map +0 -1
- package/dist/chunk-X3I5XWAR.cjs.map +0 -1
- package/dist/chunk-X4IXUTTD.js +0 -99
- package/dist/chunk-X4IXUTTD.js.map +0 -1
- package/dist/relay/index.cjs +0 -19
- package/dist/relay/index.cjs.map +0 -1
- package/dist/relay/index.d.cts +0 -75
- package/dist/relay/index.d.ts +0 -75
- package/dist/relay/index.js +0 -19
- package/dist/relay/index.js.map +0 -1
- /package/dist/{chunk-5YH4D7QF.js.map → chunk-7UBO7DY5.js.map} +0 -0
- /package/dist/{chunk-FIKTQR7H.js.map → chunk-I2P3TIP7.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
2
|
-
import { P as PoolKey, C as ChainConfig, a as
|
|
3
|
-
export { I as Issuer } from './types-
|
|
4
|
-
export { erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi,
|
|
5
|
-
export { buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signMintRequest, signReceiverConsent, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
|
|
6
|
-
|
|
7
|
-
export { buildRelaySwapParams, decodeExtData, decodeMintAndSwap, encodeExtData, encodeMintAndSwap, simulateMintAndSwap } from './relay/index.js';
|
|
8
|
-
export { getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, getUsdt, isActiveIssuer, isMinter, verifyMintCap } from './contract/index.js';
|
|
2
|
+
import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification, B as BestQuote, Q as QuoteResult } from './types-b5_Tokjl.js';
|
|
3
|
+
export { c as BurnRequest, I as Issuer, d as PathKey } from './types-b5_Tokjl.js';
|
|
4
|
+
export { erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.js';
|
|
5
|
+
export { buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
|
|
6
|
+
export { getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, isActiveIssuer, isMinter, verifyMintCap } from './contract/index.js';
|
|
9
7
|
export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle } from './quoting/index.js';
|
|
10
|
-
import {
|
|
11
|
-
export { B as BuildSwapWithGasDeductionParams, E as ENTRY_POINT_V07, a as PaymasterFields, b as SETTLE_ALL, c as SWAP_EXACT_IN, T as TAKE_ALL, d as UserOpReceipt, V as V4_SWAP, Z as ZERO_VALUE, 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-
|
|
8
|
+
import { P as PartialUserOperation, O as Operation, U as UserOperation, S as SwapSimulationResult } from './index-B06IJlHe.js';
|
|
9
|
+
export { B as BuildSwapWithGasDeductionParams, E as ENTRY_POINT_V07, a as PaymasterFields, b as SETTLE_ALL, c as SWAP_EXACT_IN, T as TAKE_ALL, d as UserOpReceipt, V as V4_SWAP, Z as ZERO_VALUE, 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-B06IJlHe.js';
|
|
12
10
|
import { LoginMessageParams } from './auth/index.js';
|
|
13
11
|
export { VerifyLoginResult, createLoginMessage, parseLoginMessage, verifyLoginMessage } from './auth/index.js';
|
|
14
12
|
|
|
@@ -27,6 +25,21 @@ declare const mintRequestTypes: {
|
|
|
27
25
|
readonly type: "uint256";
|
|
28
26
|
}];
|
|
29
27
|
};
|
|
28
|
+
declare const burnRequestTypes: {
|
|
29
|
+
readonly BurnRequest: readonly [{
|
|
30
|
+
readonly name: "from";
|
|
31
|
+
readonly type: "address";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "amount";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "nonce";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "deadline";
|
|
40
|
+
readonly type: "uint256";
|
|
41
|
+
}];
|
|
42
|
+
};
|
|
30
43
|
declare const receiverConsentTypes: {
|
|
31
44
|
readonly ReceiverConsent: readonly [{
|
|
32
45
|
readonly name: "onBehalfOf";
|
|
@@ -74,6 +87,256 @@ declare class ApiError extends PafiSDKError {
|
|
|
74
87
|
constructor(message: string, status?: number | undefined);
|
|
75
88
|
}
|
|
76
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Orderly Network Vault — entrypoint for **perp deposit** flow on
|
|
92
|
+
* Base mainnet (Scenario 3).
|
|
93
|
+
*
|
|
94
|
+
* Source of truth for addresses + integration:
|
|
95
|
+
* https://orderly.network/docs/build-on-omnichain/addresses#base
|
|
96
|
+
*
|
|
97
|
+
* ## Architecture
|
|
98
|
+
*
|
|
99
|
+
* User wallet (Base)
|
|
100
|
+
* │ 1. USDC.approve(vault, amount)
|
|
101
|
+
* │ 2. vault.deposit{value: layerZeroFee}({
|
|
102
|
+
* │ accountId, brokerHash, tokenHash, tokenAmount
|
|
103
|
+
* │ })
|
|
104
|
+
* ▼
|
|
105
|
+
* OrderlyVault (Base)
|
|
106
|
+
* │ — locks USDC, emits LayerZero message
|
|
107
|
+
* ▼
|
|
108
|
+
* Orderly chain (off-chain matching engine)
|
|
109
|
+
* │ — credits the user's perp account
|
|
110
|
+
* ▼
|
|
111
|
+
* User can now place perp orders via Orderly REST/WS API
|
|
112
|
+
*
|
|
113
|
+
* **Important:** `value` is required and is the LayerZero cross-chain
|
|
114
|
+
* fee (paid in native ETH on Base). Quote it via
|
|
115
|
+
* `vault.getDepositFee(user, data)` BEFORE calling deposit. Fees vary
|
|
116
|
+
* with destination chain congestion.
|
|
117
|
+
*
|
|
118
|
+
* ## Sponsored vs direct
|
|
119
|
+
*
|
|
120
|
+
* Coinbase Paymaster sponsors GAS, not `msg.value`. So even on the
|
|
121
|
+
* sponsored path the user MUST hold enough native ETH on Base to cover
|
|
122
|
+
* `getDepositFee()` (typically ~0.0002 ETH at quiet times).
|
|
123
|
+
*/
|
|
124
|
+
/** Orderly Vault on Base mainnet (EIP-55 checksum). */
|
|
125
|
+
declare const ORDERLY_VAULT_BASE_MAINNET: Address;
|
|
126
|
+
/**
|
|
127
|
+
* Per-chain registry of the Orderly Vault. Add chains here as Orderly
|
|
128
|
+
* deploys them.
|
|
129
|
+
*/
|
|
130
|
+
declare const ORDERLY_VAULT_ADDRESSES: Record<number, Address>;
|
|
131
|
+
/**
|
|
132
|
+
* Pre-computed broker hashes — `keccak256(abi.encodePacked(brokerId))`.
|
|
133
|
+
* Add new brokers as they launch.
|
|
134
|
+
*
|
|
135
|
+
* Reference: https://orderly.network/docs/build-on-omnichain/user-flows/accountId
|
|
136
|
+
*/
|
|
137
|
+
declare const BROKER_HASHES: {
|
|
138
|
+
/** Default partner broker on Base — most commonly whitelisted. */
|
|
139
|
+
readonly woofi_pro: `0x${string}`;
|
|
140
|
+
/** Orderly's own white-label broker. */
|
|
141
|
+
readonly orderly: `0x${string}`;
|
|
142
|
+
/** LogX. */
|
|
143
|
+
readonly logx: `0x${string}`;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Pre-computed token hashes — `keccak256(abi.encodePacked(tokenSymbol))`.
|
|
147
|
+
* The hash maps to the actual ERC-20 address on each chain via
|
|
148
|
+
* `vault.getAllowedToken(tokenHash)`.
|
|
149
|
+
*
|
|
150
|
+
* Note: Orderly canonicalises by symbol (USDC, not "USD Coin").
|
|
151
|
+
*/
|
|
152
|
+
declare const TOKEN_HASHES: {
|
|
153
|
+
readonly USDC: `0x${string}`;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Compute Orderly's `accountId` — uniquely identifies a user+broker
|
|
157
|
+
* tuple. Matches the off-chain formula used by the Orderly SDK so
|
|
158
|
+
* deposits + future REST API calls reference the same account.
|
|
159
|
+
*
|
|
160
|
+
* accountId = keccak256(abi.encode(user, brokerHash))
|
|
161
|
+
*
|
|
162
|
+
* Note `abi.encode` (not `encodePacked`) — uses 32-byte left-padding.
|
|
163
|
+
*/
|
|
164
|
+
declare function computeAccountId(user: Address, brokerHash: Hex): Hex;
|
|
165
|
+
/**
|
|
166
|
+
* Minimal Orderly Vault ABI — just the functions PAFI needs for
|
|
167
|
+
* Scenario 3 (perp deposit). Full ABI is on Orderly's docs site.
|
|
168
|
+
*/
|
|
169
|
+
declare const ORDERLY_VAULT_ABI: readonly [{
|
|
170
|
+
readonly type: "function";
|
|
171
|
+
readonly name: "deposit";
|
|
172
|
+
readonly stateMutability: "payable";
|
|
173
|
+
readonly inputs: readonly [{
|
|
174
|
+
readonly name: "data";
|
|
175
|
+
readonly type: "tuple";
|
|
176
|
+
readonly components: readonly [{
|
|
177
|
+
readonly name: "accountId";
|
|
178
|
+
readonly type: "bytes32";
|
|
179
|
+
}, {
|
|
180
|
+
readonly name: "brokerHash";
|
|
181
|
+
readonly type: "bytes32";
|
|
182
|
+
}, {
|
|
183
|
+
readonly name: "tokenHash";
|
|
184
|
+
readonly type: "bytes32";
|
|
185
|
+
}, {
|
|
186
|
+
readonly name: "tokenAmount";
|
|
187
|
+
readonly type: "uint128";
|
|
188
|
+
}];
|
|
189
|
+
}];
|
|
190
|
+
readonly outputs: readonly [];
|
|
191
|
+
}, {
|
|
192
|
+
readonly type: "function";
|
|
193
|
+
readonly name: "getDepositFee";
|
|
194
|
+
readonly stateMutability: "view";
|
|
195
|
+
readonly inputs: readonly [{
|
|
196
|
+
readonly name: "user";
|
|
197
|
+
readonly type: "address";
|
|
198
|
+
}, {
|
|
199
|
+
readonly name: "data";
|
|
200
|
+
readonly type: "tuple";
|
|
201
|
+
readonly components: readonly [{
|
|
202
|
+
readonly name: "accountId";
|
|
203
|
+
readonly type: "bytes32";
|
|
204
|
+
}, {
|
|
205
|
+
readonly name: "brokerHash";
|
|
206
|
+
readonly type: "bytes32";
|
|
207
|
+
}, {
|
|
208
|
+
readonly name: "tokenHash";
|
|
209
|
+
readonly type: "bytes32";
|
|
210
|
+
}, {
|
|
211
|
+
readonly name: "tokenAmount";
|
|
212
|
+
readonly type: "uint128";
|
|
213
|
+
}];
|
|
214
|
+
}];
|
|
215
|
+
readonly outputs: readonly [{
|
|
216
|
+
readonly name: "";
|
|
217
|
+
readonly type: "uint256";
|
|
218
|
+
}];
|
|
219
|
+
}, {
|
|
220
|
+
readonly type: "function";
|
|
221
|
+
readonly name: "getAllowedBroker";
|
|
222
|
+
readonly stateMutability: "view";
|
|
223
|
+
readonly inputs: readonly [{
|
|
224
|
+
readonly name: "brokerHash";
|
|
225
|
+
readonly type: "bytes32";
|
|
226
|
+
}];
|
|
227
|
+
readonly outputs: readonly [{
|
|
228
|
+
readonly name: "";
|
|
229
|
+
readonly type: "bool";
|
|
230
|
+
}];
|
|
231
|
+
}, {
|
|
232
|
+
readonly type: "function";
|
|
233
|
+
readonly name: "getAllowedToken";
|
|
234
|
+
readonly stateMutability: "view";
|
|
235
|
+
readonly inputs: readonly [{
|
|
236
|
+
readonly name: "tokenHash";
|
|
237
|
+
readonly type: "bytes32";
|
|
238
|
+
}];
|
|
239
|
+
readonly outputs: readonly [{
|
|
240
|
+
readonly name: "";
|
|
241
|
+
readonly type: "address";
|
|
242
|
+
}];
|
|
243
|
+
}];
|
|
244
|
+
/** Struct mirror of `IOrderlyVault.VaultDepositFE` for type-safe builders. */
|
|
245
|
+
interface VaultDepositFE {
|
|
246
|
+
accountId: Hex;
|
|
247
|
+
brokerHash: Hex;
|
|
248
|
+
tokenHash: Hex;
|
|
249
|
+
/** uint128 — USDC has 6 decimals. */
|
|
250
|
+
tokenAmount: bigint;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* v1.5 — Scenario 3: deposit USDC from the user's wallet into the
|
|
255
|
+
* Orderly perp Vault on Base mainnet.
|
|
256
|
+
*
|
|
257
|
+
* Builds a `PartialUserOperation` packaging the 2 inner calls:
|
|
258
|
+
*
|
|
259
|
+
* 1. `USDC.approve(orderlyVault, amount)` — let the Vault pull USDC
|
|
260
|
+
* 2. `OrderlyVault.deposit{value: layerZeroFee}(VaultDepositFE)` —
|
|
261
|
+
* transfer USDC into the Vault + emit a LayerZero message that
|
|
262
|
+
* credits the user's perp account on the Orderly chain
|
|
263
|
+
*
|
|
264
|
+
* ## ⚠️ Native ETH constraint
|
|
265
|
+
*
|
|
266
|
+
* Coinbase Paymaster sponsors GAS, **not `msg.value`**. The LayerZero
|
|
267
|
+
* cross-chain fee MUST come from the user's own native ETH balance on
|
|
268
|
+
* Base — even when the rest of the UserOp is sponsored.
|
|
269
|
+
*
|
|
270
|
+
* Quote the fee BEFORE calling this builder via:
|
|
271
|
+
*
|
|
272
|
+
* const fee = await client.readContract({
|
|
273
|
+
* address: orderlyVault,
|
|
274
|
+
* abi: ORDERLY_VAULT_ABI,
|
|
275
|
+
* functionName: 'getDepositFee',
|
|
276
|
+
* args: [user, depositData],
|
|
277
|
+
* });
|
|
278
|
+
*
|
|
279
|
+
* If `user.eth < fee`, surface this error to the FE so the user can
|
|
280
|
+
* top up before retrying — the Vault `deposit{value: 0}` call will
|
|
281
|
+
* revert otherwise.
|
|
282
|
+
*
|
|
283
|
+
* ## Why no PT/USDC fee deduction?
|
|
284
|
+
*
|
|
285
|
+
* Unlike Scenario 1/2/4 which deduct an operator fee in PT/USDC inside
|
|
286
|
+
* the batch, perp deposit doesn't append a fee transfer because:
|
|
287
|
+
*
|
|
288
|
+
* - User is paying Orderly's LayerZero fee directly via `msg.value`
|
|
289
|
+
* - There's no PAFI-specific operator cost on top — Orderly handles
|
|
290
|
+
* the off-chain accounting once the LayerZero message lands
|
|
291
|
+
*
|
|
292
|
+
* If we want to charge a PAFI service fee on top later, append a
|
|
293
|
+
* `USDC.transfer(feeRecipient, fee)` op — same pattern as the swap
|
|
294
|
+
* builder.
|
|
295
|
+
*/
|
|
296
|
+
interface BuildPerpDepositWithGasDeductionParams {
|
|
297
|
+
/** User EOA (will be `msg.sender` via EIP-7702 delegation). */
|
|
298
|
+
userAddress: Address;
|
|
299
|
+
/** ERC-4337 account nonce — fetched from EntryPoint by the caller. */
|
|
300
|
+
aaNonce: bigint;
|
|
301
|
+
/** Chain ID for Orderly Vault address resolution. */
|
|
302
|
+
chainId: number;
|
|
303
|
+
/**
|
|
304
|
+
* Override Orderly Vault address (e.g. for fork tests). Defaults to
|
|
305
|
+
* `ORDERLY_VAULT_ADDRESSES[chainId]`.
|
|
306
|
+
*/
|
|
307
|
+
vaultAddress?: Address;
|
|
308
|
+
/**
|
|
309
|
+
* USDC ERC-20 address — the actual token Orderly accepts. Caller
|
|
310
|
+
* resolves this via `vault.getAllowedToken(TOKEN_HASHES.USDC)` so we
|
|
311
|
+
* don't hardcode the wrong USDC variant (native vs bridged).
|
|
312
|
+
*/
|
|
313
|
+
usdcAddress: Address;
|
|
314
|
+
/** USDC amount to deposit (uint128, 6 decimals). */
|
|
315
|
+
amount: bigint;
|
|
316
|
+
/**
|
|
317
|
+
* Pre-built `VaultDepositFE` struct — caller computes accountId via
|
|
318
|
+
* `computeAccountId(user, brokerHash)` and supplies tokenHash.
|
|
319
|
+
*/
|
|
320
|
+
depositData: VaultDepositFE;
|
|
321
|
+
/**
|
|
322
|
+
* LayerZero fee in wei — from `vault.getDepositFee(user, data)`.
|
|
323
|
+
* Becomes the `msg.value` on the `deposit()` call. User MUST hold
|
|
324
|
+
* ≥ this much native ETH or the call reverts.
|
|
325
|
+
*/
|
|
326
|
+
layerZeroFee: bigint;
|
|
327
|
+
gasLimits?: {
|
|
328
|
+
callGasLimit?: bigint;
|
|
329
|
+
verificationGasLimit?: bigint;
|
|
330
|
+
preVerificationGas?: bigint;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Build an unsigned UserOp for Scenario 3. Returns a
|
|
335
|
+
* `PartialUserOperation` — caller attaches paymaster sponsorship for
|
|
336
|
+
* gas + the user's UserOp-hash signature, then submits to the Bundler.
|
|
337
|
+
*/
|
|
338
|
+
declare function buildPerpDepositWithGasDeduction(params: BuildPerpDepositWithGasDeductionParams): PartialUserOperation;
|
|
339
|
+
|
|
77
340
|
/**
|
|
78
341
|
* Build an ERC-20 `transfer(to, amount)` operation. Used inside a batch
|
|
79
342
|
* to move fee tokens from the user to the fee recipient atomically with
|
|
@@ -276,238 +539,393 @@ interface CheckEthAndBranchParams {
|
|
|
276
539
|
declare function checkEthAndBranch(params: CheckEthAndBranchParams): Promise<SubmissionPath>;
|
|
277
540
|
|
|
278
541
|
/**
|
|
279
|
-
*
|
|
542
|
+
* Parse the implementation address out of an EIP-7702 delegation designator.
|
|
543
|
+
*
|
|
544
|
+
* Returns `null` when:
|
|
545
|
+
* - `code` is undefined / empty / `"0x"` (plain EOA, no code)
|
|
546
|
+
* - `code` does not contain the EIP-7702 magic prefix (regular contract)
|
|
547
|
+
*
|
|
548
|
+
* @param code - bytecode returned by `eth_getCode` / `client.getCode()`
|
|
549
|
+
* @returns the 20-byte implementation address (checksummed), or `null`
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* const code = await client.getCode({ address });
|
|
553
|
+
* const impl = parseEip7702DelegatedAddress(code);
|
|
554
|
+
* // null → not delegated
|
|
555
|
+
* // '0x7702cb554e6bFb442cb743A7dF23154544a7176C' → delegated to BatchExecutor
|
|
556
|
+
*/
|
|
557
|
+
declare function parseEip7702DelegatedAddress(code: Hex | string | null | undefined): Address | null;
|
|
558
|
+
/**
|
|
559
|
+
* Read the EIP-7702 delegation status of an EOA from the chain.
|
|
560
|
+
*
|
|
561
|
+
* @param client - viem PublicClient (any provider — only `eth_getCode` is called)
|
|
562
|
+
* @param address - EOA address to inspect
|
|
563
|
+
* @returns the implementation address the EOA is delegated to, or `null`
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* const impl = await checkDelegation(publicClient, userAddress);
|
|
567
|
+
* if (impl === null) {
|
|
568
|
+
* // show "Setup Wallet" button
|
|
569
|
+
* } else {
|
|
570
|
+
* // EOA already delegated; safe to send UserOps
|
|
571
|
+
* }
|
|
572
|
+
*/
|
|
573
|
+
declare function checkDelegation(client: PublicClient, address: Address): Promise<Address | null>;
|
|
574
|
+
/**
|
|
575
|
+
* Return `true` when the EOA at `address` is currently delegated to `target`.
|
|
576
|
+
*
|
|
577
|
+
* Useful for asserting that the delegation points specifically at the expected
|
|
578
|
+
* BatchExecutor rather than some other implementation (e.g. old deployment).
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* import { BATCH_EXECUTOR_ADDRESS_BASE_MAINNET } from '@pafi-dev/core';
|
|
582
|
+
* const ok = await isDelegatedTo(client, userAddress, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET);
|
|
583
|
+
*/
|
|
584
|
+
declare function isDelegatedTo(client: PublicClient, address: Address, target: Address): Promise<boolean>;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Parameters for building a delegation-only UserOperation.
|
|
588
|
+
*
|
|
589
|
+
* This UserOp carries no calldata — its sole purpose is to anchor the
|
|
590
|
+
* EIP-7702 authorization (signed externally via `signAuthorization`) into
|
|
591
|
+
* a sponsored transaction so the user doesn't need native ETH to delegate.
|
|
592
|
+
*/
|
|
593
|
+
interface BuildDelegationUserOpParams {
|
|
594
|
+
/** User EOA to delegate. */
|
|
595
|
+
userAddress: Address;
|
|
596
|
+
/** ERC-4337 account nonce — fetched from EntryPoint. Pass 0n on first ever op. */
|
|
597
|
+
aaNonce: bigint;
|
|
598
|
+
gasLimits?: {
|
|
599
|
+
callGasLimit?: bigint;
|
|
600
|
+
verificationGasLimit?: bigint;
|
|
601
|
+
preVerificationGas?: bigint;
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Build the minimal `PartialUserOperation` used to sponsor the one-time
|
|
606
|
+
* EIP-7702 delegation.
|
|
607
|
+
*
|
|
608
|
+
* The caller must:
|
|
609
|
+
* 1. Sign the EIP-7702 authorization via `signAuthorization()` (Privy hook).
|
|
610
|
+
* 2. Pass the authorization as `authorization` alongside `calls` (or alone)
|
|
611
|
+
* to `smartClient.sendTransaction()`.
|
|
612
|
+
*
|
|
613
|
+
* The permissionless SDK + Pimlico bundler handle the rest: they detect the
|
|
614
|
+
* `authorization` field and submit an EIP-7702 type-4 transaction that sets
|
|
615
|
+
* the EOA's bytecode to `0xef0100<batchExecutorAddress>`.
|
|
616
|
+
*
|
|
617
|
+
* This builder is a convenience wrapper — in practice you can also pass
|
|
618
|
+
* `{ to: userAddress, value: 0n, data: '0x', authorization }` directly to
|
|
619
|
+
* `smartClient.sendTransaction()` without calling this function at all.
|
|
620
|
+
* Use it when you need a `PartialUserOperation` struct for inspection or
|
|
621
|
+
* custom paymaster flows.
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* // Typical flow — no need to call this builder directly:
|
|
625
|
+
* const nonce = await publicClient.getTransactionCount({ address, blockTag: 'pending' });
|
|
626
|
+
* const authorization = await signAuthorization({ contractAddress: BATCH_EXECUTOR, chainId: 8453, nonce });
|
|
627
|
+
* const txHash = await smartClient.sendTransaction({
|
|
628
|
+
* to: address,
|
|
629
|
+
* value: 0n,
|
|
630
|
+
* data: '0x',
|
|
631
|
+
* authorization,
|
|
632
|
+
* paymasterContext: { sponsorshipPolicyId },
|
|
633
|
+
* });
|
|
634
|
+
*/
|
|
635
|
+
declare function buildDelegationUserOp(params: BuildDelegationUserOpParams): PartialUserOperation;
|
|
636
|
+
/**
|
|
637
|
+
* Fetch the AA nonce for a user EOA from the EntryPoint v0.7.
|
|
638
|
+
*
|
|
639
|
+
* Convenience helper so callers don't need to import the EntryPoint ABI
|
|
640
|
+
* themselves when building the delegation UserOp.
|
|
641
|
+
*
|
|
642
|
+
* @param client - viem PublicClient
|
|
643
|
+
* @param userAddress - EOA to query
|
|
644
|
+
* @returns bigint nonce (0n on first-ever UserOp)
|
|
645
|
+
*/
|
|
646
|
+
declare function getAaNonce(client: PublicClient, userAddress: Address): Promise<bigint>;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Real `PointToken` ABI — matches the contract deployed on Base mainnet
|
|
650
|
+
* (POINT at `0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e`). Sourced from
|
|
651
|
+
* the Solidity contract shipped by the SC team 2026-04-21.
|
|
652
|
+
*
|
|
653
|
+
* ## Mint — two paths
|
|
280
654
|
*
|
|
281
|
-
*
|
|
655
|
+
* Path 1 — Direct (whitelisted minter):
|
|
656
|
+
* mint(address to, uint256 amount)
|
|
657
|
+
* - msg.sender must be in minters[]
|
|
658
|
+
* - Used by off-chain services that hold a minter key
|
|
282
659
|
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
660
|
+
* Path 2 — Sig-gated (gasless, v1.4 sponsored flow):
|
|
661
|
+
* mint(address to, uint256 amount, uint256 deadline, bytes minterSig)
|
|
662
|
+
* - msg.sender MUST equal `to` (the receiver)
|
|
663
|
+
* - minterSig is an EIP-712 MintRequest signature from a whitelisted minter
|
|
664
|
+
* - Consumes `mintRequestNonces[to]`
|
|
665
|
+
* - This is the path v1.4 uses: issuer backend signs, user submits
|
|
666
|
+
* via EIP-7702 + Coinbase Paymaster
|
|
290
667
|
*
|
|
291
|
-
*
|
|
292
|
-
* - Verify user + issuer EIP-712 signatures against `request`
|
|
293
|
-
* - Mint `request.amount` PT to `request.to`
|
|
294
|
-
* - Atomic transfer `feeAmount` from `request.to` → `feeRecipient`
|
|
295
|
-
* (net mint = `amount - feeAmount`)
|
|
296
|
-
* - Increment the on-chain nonce to prevent replay
|
|
668
|
+
* ## Burn — mirror structure
|
|
297
669
|
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
670
|
+
* Path 1: burn(address from, uint256 amount) — whitelisted burner
|
|
671
|
+
* Path 2: burn(address from, uint256 amount, uint256 deadline, bytes burnerSig)
|
|
672
|
+
* — msg.sender must equal `from`, burnerSig from whitelisted burner,
|
|
673
|
+
* consumes `burnRequestNonces[from]`
|
|
301
674
|
*
|
|
302
|
-
*
|
|
675
|
+
* Either burn path emits `Transfer(from → 0x0)` so BurnIndexer semantics
|
|
676
|
+
* don't depend on which path was taken.
|
|
677
|
+
*
|
|
678
|
+
* ## EIP-712 type hashes (from contract source)
|
|
679
|
+
*
|
|
680
|
+
* MintRequest(address to,uint256 amount,uint256 nonce,uint256 deadline)
|
|
681
|
+
* BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline)
|
|
682
|
+
*
|
|
683
|
+
* Domain: EIP-712 standard — name = ERC-20 token name, version = "1",
|
|
684
|
+
* chainId, verifyingContract = this PointToken address.
|
|
303
685
|
*/
|
|
304
|
-
declare const
|
|
686
|
+
declare const POINT_TOKEN_ABI: readonly [{
|
|
305
687
|
readonly name: "mint";
|
|
306
688
|
readonly type: "function";
|
|
307
689
|
readonly stateMutability: "nonpayable";
|
|
308
690
|
readonly inputs: readonly [{
|
|
309
|
-
readonly type: "
|
|
310
|
-
readonly
|
|
311
|
-
readonly type: "address";
|
|
312
|
-
readonly name: "to";
|
|
313
|
-
}, {
|
|
314
|
-
readonly type: "uint256";
|
|
315
|
-
readonly name: "amount";
|
|
316
|
-
}, {
|
|
317
|
-
readonly type: "uint256";
|
|
318
|
-
readonly name: "feeAmount";
|
|
319
|
-
}, {
|
|
320
|
-
readonly type: "address";
|
|
321
|
-
readonly name: "feeRecipient";
|
|
322
|
-
}, {
|
|
323
|
-
readonly type: "uint256";
|
|
324
|
-
readonly name: "nonce";
|
|
325
|
-
}, {
|
|
326
|
-
readonly type: "uint256";
|
|
327
|
-
readonly name: "deadline";
|
|
328
|
-
}, {
|
|
329
|
-
readonly type: "bytes";
|
|
330
|
-
readonly name: "extData";
|
|
331
|
-
}];
|
|
332
|
-
readonly name: "request";
|
|
333
|
-
}, {
|
|
334
|
-
readonly type: "tuple";
|
|
335
|
-
readonly components: readonly [{
|
|
336
|
-
readonly type: "uint8";
|
|
337
|
-
readonly name: "v";
|
|
338
|
-
}, {
|
|
339
|
-
readonly type: "bytes32";
|
|
340
|
-
readonly name: "r";
|
|
341
|
-
}, {
|
|
342
|
-
readonly type: "bytes32";
|
|
343
|
-
readonly name: "s";
|
|
344
|
-
}];
|
|
345
|
-
readonly name: "userSig";
|
|
691
|
+
readonly type: "address";
|
|
692
|
+
readonly name: "to";
|
|
346
693
|
}, {
|
|
347
|
-
readonly type: "
|
|
348
|
-
readonly
|
|
349
|
-
readonly type: "uint8";
|
|
350
|
-
readonly name: "v";
|
|
351
|
-
}, {
|
|
352
|
-
readonly type: "bytes32";
|
|
353
|
-
readonly name: "r";
|
|
354
|
-
}, {
|
|
355
|
-
readonly type: "bytes32";
|
|
356
|
-
readonly name: "s";
|
|
357
|
-
}];
|
|
358
|
-
readonly name: "issuerSig";
|
|
694
|
+
readonly type: "uint256";
|
|
695
|
+
readonly name: "amount";
|
|
359
696
|
}];
|
|
360
697
|
readonly outputs: readonly [];
|
|
361
698
|
}, {
|
|
362
|
-
readonly name: "
|
|
699
|
+
readonly name: "mint";
|
|
363
700
|
readonly type: "function";
|
|
364
|
-
readonly stateMutability: "
|
|
365
|
-
readonly inputs: readonly [{
|
|
366
|
-
readonly type: "address";
|
|
367
|
-
readonly name: "user";
|
|
368
|
-
}];
|
|
369
|
-
readonly outputs: readonly [{
|
|
370
|
-
readonly type: "uint256";
|
|
371
|
-
}];
|
|
372
|
-
}, {
|
|
373
|
-
readonly name: "Minted";
|
|
374
|
-
readonly type: "event";
|
|
701
|
+
readonly stateMutability: "nonpayable";
|
|
375
702
|
readonly inputs: readonly [{
|
|
376
703
|
readonly type: "address";
|
|
377
|
-
readonly name: "
|
|
378
|
-
readonly indexed: true;
|
|
704
|
+
readonly name: "to";
|
|
379
705
|
}, {
|
|
380
706
|
readonly type: "uint256";
|
|
381
707
|
readonly name: "amount";
|
|
382
708
|
}, {
|
|
383
709
|
readonly type: "uint256";
|
|
384
|
-
readonly name: "
|
|
385
|
-
}, {
|
|
386
|
-
readonly type: "address";
|
|
387
|
-
readonly name: "feeRecipient";
|
|
388
|
-
readonly indexed: true;
|
|
710
|
+
readonly name: "deadline";
|
|
389
711
|
}, {
|
|
390
|
-
readonly type: "
|
|
391
|
-
readonly name: "
|
|
712
|
+
readonly type: "bytes";
|
|
713
|
+
readonly name: "minterSig";
|
|
392
714
|
}];
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
* Calldata function selector for `mint((...),(...),(...))` as encoded
|
|
396
|
-
* by viem against {@link MOCK_RELAYER_V2_ABI}. Callers compare against
|
|
397
|
-
* this to sanity-check decoded UserOp inner calls.
|
|
398
|
-
*
|
|
399
|
-
* Recompute when the real ABI lands — almost certainly differs.
|
|
400
|
-
*/
|
|
401
|
-
declare const MOCK_RELAYER_V2_MINT_SELECTOR: "0xMOCKED__";
|
|
402
|
-
/**
|
|
403
|
-
* Struct shape that matches {@link MOCK_RELAYER_V2_ABI}. Exported so
|
|
404
|
-
* builders can accept a typed input without `as const` gymnastics.
|
|
405
|
-
*/
|
|
406
|
-
interface MockMintRequestV2 {
|
|
407
|
-
to: Address;
|
|
408
|
-
amount: bigint;
|
|
409
|
-
feeAmount: bigint;
|
|
410
|
-
feeRecipient: Address;
|
|
411
|
-
nonce: bigint;
|
|
412
|
-
deadline: bigint;
|
|
413
|
-
extData: `0x${string}`;
|
|
414
|
-
}
|
|
415
|
-
interface MockSignatureStruct {
|
|
416
|
-
v: number;
|
|
417
|
-
r: `0x${string}`;
|
|
418
|
-
s: `0x${string}`;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* ⚠️ MOCK — `PointToken` v1.4 burn surface.
|
|
423
|
-
*
|
|
424
|
-
* Two variants mocked — SC team will pick ONE before stable; the other
|
|
425
|
-
* gets deleted during Phase B swap.
|
|
426
|
-
*
|
|
427
|
-
* Variant A (simpler, most likely):
|
|
428
|
-
* burn(uint256 amount)
|
|
429
|
-
* - burns from `msg.sender`
|
|
430
|
-
* - caller handles authorization (the user is `msg.sender` via
|
|
431
|
-
* EIP-7702 delegation, so `msg.sender == user`)
|
|
432
|
-
*
|
|
433
|
-
* Variant B (signature-based, if SC prefers explicit consent on-chain):
|
|
434
|
-
* burnWithSig(BurnConsent consent, Signature sig)
|
|
435
|
-
* - verifies EIP-712 signature before burning
|
|
436
|
-
* - used when the caller isn't the user (e.g. a relayer burns on
|
|
437
|
-
* behalf of the user)
|
|
438
|
-
*
|
|
439
|
-
* Either way the ERC-20 emits `Transfer(from, address(0), amount)` so
|
|
440
|
-
* `BurnIndexer` semantics don't change.
|
|
441
|
-
*/
|
|
442
|
-
declare const MOCK_POINT_TOKEN_V2_ABI: readonly [{
|
|
715
|
+
readonly outputs: readonly [];
|
|
716
|
+
}, {
|
|
443
717
|
readonly name: "burn";
|
|
444
718
|
readonly type: "function";
|
|
445
719
|
readonly stateMutability: "nonpayable";
|
|
446
720
|
readonly inputs: readonly [{
|
|
721
|
+
readonly type: "address";
|
|
722
|
+
readonly name: "from";
|
|
723
|
+
}, {
|
|
447
724
|
readonly type: "uint256";
|
|
448
725
|
readonly name: "amount";
|
|
449
726
|
}];
|
|
450
727
|
readonly outputs: readonly [];
|
|
451
728
|
}, {
|
|
452
|
-
readonly name: "
|
|
729
|
+
readonly name: "burn";
|
|
453
730
|
readonly type: "function";
|
|
454
731
|
readonly stateMutability: "nonpayable";
|
|
455
732
|
readonly inputs: readonly [{
|
|
456
|
-
readonly type: "
|
|
457
|
-
readonly
|
|
458
|
-
readonly type: "address";
|
|
459
|
-
readonly name: "user";
|
|
460
|
-
}, {
|
|
461
|
-
readonly type: "address";
|
|
462
|
-
readonly name: "pointToken";
|
|
463
|
-
}, {
|
|
464
|
-
readonly type: "uint256";
|
|
465
|
-
readonly name: "amount";
|
|
466
|
-
}, {
|
|
467
|
-
readonly type: "uint256";
|
|
468
|
-
readonly name: "nonce";
|
|
469
|
-
}, {
|
|
470
|
-
readonly type: "uint256";
|
|
471
|
-
readonly name: "deadline";
|
|
472
|
-
}];
|
|
473
|
-
readonly name: "consent";
|
|
733
|
+
readonly type: "address";
|
|
734
|
+
readonly name: "from";
|
|
474
735
|
}, {
|
|
475
|
-
readonly type: "
|
|
476
|
-
readonly
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
readonly type: "bytes32";
|
|
484
|
-
readonly name: "s";
|
|
485
|
-
}];
|
|
486
|
-
readonly name: "sig";
|
|
736
|
+
readonly type: "uint256";
|
|
737
|
+
readonly name: "amount";
|
|
738
|
+
}, {
|
|
739
|
+
readonly type: "uint256";
|
|
740
|
+
readonly name: "deadline";
|
|
741
|
+
}, {
|
|
742
|
+
readonly type: "bytes";
|
|
743
|
+
readonly name: "burnerSig";
|
|
487
744
|
}];
|
|
488
745
|
readonly outputs: readonly [];
|
|
489
746
|
}, {
|
|
490
|
-
readonly name: "
|
|
747
|
+
readonly name: "minters";
|
|
491
748
|
readonly type: "function";
|
|
492
749
|
readonly stateMutability: "view";
|
|
493
750
|
readonly inputs: readonly [{
|
|
494
751
|
readonly type: "address";
|
|
495
|
-
readonly name: "
|
|
752
|
+
readonly name: "account";
|
|
753
|
+
}];
|
|
754
|
+
readonly outputs: readonly [{
|
|
755
|
+
readonly type: "bool";
|
|
756
|
+
}];
|
|
757
|
+
}, {
|
|
758
|
+
readonly name: "burners";
|
|
759
|
+
readonly type: "function";
|
|
760
|
+
readonly stateMutability: "view";
|
|
761
|
+
readonly inputs: readonly [{
|
|
762
|
+
readonly type: "address";
|
|
763
|
+
readonly name: "account";
|
|
764
|
+
}];
|
|
765
|
+
readonly outputs: readonly [{
|
|
766
|
+
readonly type: "bool";
|
|
767
|
+
}];
|
|
768
|
+
}, {
|
|
769
|
+
readonly name: "addMinter";
|
|
770
|
+
readonly type: "function";
|
|
771
|
+
readonly stateMutability: "nonpayable";
|
|
772
|
+
readonly inputs: readonly [{
|
|
773
|
+
readonly type: "address";
|
|
774
|
+
readonly name: "minter";
|
|
775
|
+
}];
|
|
776
|
+
readonly outputs: readonly [];
|
|
777
|
+
}, {
|
|
778
|
+
readonly name: "removeMinter";
|
|
779
|
+
readonly type: "function";
|
|
780
|
+
readonly stateMutability: "nonpayable";
|
|
781
|
+
readonly inputs: readonly [{
|
|
782
|
+
readonly type: "address";
|
|
783
|
+
readonly name: "minter";
|
|
784
|
+
}];
|
|
785
|
+
readonly outputs: readonly [];
|
|
786
|
+
}, {
|
|
787
|
+
readonly name: "addBurner";
|
|
788
|
+
readonly type: "function";
|
|
789
|
+
readonly stateMutability: "nonpayable";
|
|
790
|
+
readonly inputs: readonly [{
|
|
791
|
+
readonly type: "address";
|
|
792
|
+
readonly name: "burner";
|
|
793
|
+
}];
|
|
794
|
+
readonly outputs: readonly [];
|
|
795
|
+
}, {
|
|
796
|
+
readonly name: "removeBurner";
|
|
797
|
+
readonly type: "function";
|
|
798
|
+
readonly stateMutability: "nonpayable";
|
|
799
|
+
readonly inputs: readonly [{
|
|
800
|
+
readonly type: "address";
|
|
801
|
+
readonly name: "burner";
|
|
802
|
+
}];
|
|
803
|
+
readonly outputs: readonly [];
|
|
804
|
+
}, {
|
|
805
|
+
readonly name: "mintRequestNonces";
|
|
806
|
+
readonly type: "function";
|
|
807
|
+
readonly stateMutability: "view";
|
|
808
|
+
readonly inputs: readonly [{
|
|
809
|
+
readonly type: "address";
|
|
810
|
+
readonly name: "receiver";
|
|
496
811
|
}];
|
|
497
812
|
readonly outputs: readonly [{
|
|
498
813
|
readonly type: "uint256";
|
|
499
814
|
}];
|
|
500
815
|
}, {
|
|
501
|
-
readonly name: "
|
|
816
|
+
readonly name: "burnRequestNonces";
|
|
502
817
|
readonly type: "function";
|
|
503
818
|
readonly stateMutability: "view";
|
|
504
819
|
readonly inputs: readonly [{
|
|
505
820
|
readonly type: "address";
|
|
506
|
-
readonly name: "
|
|
821
|
+
readonly name: "from";
|
|
507
822
|
}];
|
|
508
823
|
readonly outputs: readonly [{
|
|
509
824
|
readonly type: "uint256";
|
|
510
825
|
}];
|
|
826
|
+
}, {
|
|
827
|
+
readonly name: "mintingOracle";
|
|
828
|
+
readonly type: "function";
|
|
829
|
+
readonly stateMutability: "view";
|
|
830
|
+
readonly inputs: readonly [];
|
|
831
|
+
readonly outputs: readonly [{
|
|
832
|
+
readonly type: "address";
|
|
833
|
+
}];
|
|
834
|
+
}, {
|
|
835
|
+
readonly name: "setMintingOracle";
|
|
836
|
+
readonly type: "function";
|
|
837
|
+
readonly stateMutability: "nonpayable";
|
|
838
|
+
readonly inputs: readonly [{
|
|
839
|
+
readonly type: "address";
|
|
840
|
+
readonly name: "_mintingOracle";
|
|
841
|
+
}];
|
|
842
|
+
readonly outputs: readonly [];
|
|
843
|
+
}, {
|
|
844
|
+
readonly name: "issuer";
|
|
845
|
+
readonly type: "function";
|
|
846
|
+
readonly stateMutability: "view";
|
|
847
|
+
readonly inputs: readonly [];
|
|
848
|
+
readonly outputs: readonly [{
|
|
849
|
+
readonly type: "address";
|
|
850
|
+
}];
|
|
851
|
+
}, {
|
|
852
|
+
readonly name: "balanceOf";
|
|
853
|
+
readonly type: "function";
|
|
854
|
+
readonly stateMutability: "view";
|
|
855
|
+
readonly inputs: readonly [{
|
|
856
|
+
readonly type: "address";
|
|
857
|
+
readonly name: "account";
|
|
858
|
+
}];
|
|
859
|
+
readonly outputs: readonly [{
|
|
860
|
+
readonly type: "uint256";
|
|
861
|
+
}];
|
|
862
|
+
}, {
|
|
863
|
+
readonly name: "totalSupply";
|
|
864
|
+
readonly type: "function";
|
|
865
|
+
readonly stateMutability: "view";
|
|
866
|
+
readonly inputs: readonly [];
|
|
867
|
+
readonly outputs: readonly [{
|
|
868
|
+
readonly type: "uint256";
|
|
869
|
+
}];
|
|
870
|
+
}, {
|
|
871
|
+
readonly name: "name";
|
|
872
|
+
readonly type: "function";
|
|
873
|
+
readonly stateMutability: "view";
|
|
874
|
+
readonly inputs: readonly [];
|
|
875
|
+
readonly outputs: readonly [{
|
|
876
|
+
readonly type: "string";
|
|
877
|
+
}];
|
|
878
|
+
}, {
|
|
879
|
+
readonly name: "symbol";
|
|
880
|
+
readonly type: "function";
|
|
881
|
+
readonly stateMutability: "view";
|
|
882
|
+
readonly inputs: readonly [];
|
|
883
|
+
readonly outputs: readonly [{
|
|
884
|
+
readonly type: "string";
|
|
885
|
+
}];
|
|
886
|
+
}, {
|
|
887
|
+
readonly name: "decimals";
|
|
888
|
+
readonly type: "function";
|
|
889
|
+
readonly stateMutability: "view";
|
|
890
|
+
readonly inputs: readonly [];
|
|
891
|
+
readonly outputs: readonly [{
|
|
892
|
+
readonly type: "uint8";
|
|
893
|
+
}];
|
|
894
|
+
}, {
|
|
895
|
+
readonly name: "DOMAIN_SEPARATOR";
|
|
896
|
+
readonly type: "function";
|
|
897
|
+
readonly stateMutability: "view";
|
|
898
|
+
readonly inputs: readonly [];
|
|
899
|
+
readonly outputs: readonly [{
|
|
900
|
+
readonly type: "bytes32";
|
|
901
|
+
}];
|
|
902
|
+
}, {
|
|
903
|
+
readonly name: "eip712Domain";
|
|
904
|
+
readonly type: "function";
|
|
905
|
+
readonly stateMutability: "view";
|
|
906
|
+
readonly inputs: readonly [];
|
|
907
|
+
readonly outputs: readonly [{
|
|
908
|
+
readonly type: "bytes1";
|
|
909
|
+
readonly name: "fields";
|
|
910
|
+
}, {
|
|
911
|
+
readonly type: "string";
|
|
912
|
+
readonly name: "name";
|
|
913
|
+
}, {
|
|
914
|
+
readonly type: "string";
|
|
915
|
+
readonly name: "version";
|
|
916
|
+
}, {
|
|
917
|
+
readonly type: "uint256";
|
|
918
|
+
readonly name: "chainId";
|
|
919
|
+
}, {
|
|
920
|
+
readonly type: "address";
|
|
921
|
+
readonly name: "verifyingContract";
|
|
922
|
+
}, {
|
|
923
|
+
readonly type: "bytes32";
|
|
924
|
+
readonly name: "salt";
|
|
925
|
+
}, {
|
|
926
|
+
readonly type: "uint256[]";
|
|
927
|
+
readonly name: "extensions";
|
|
928
|
+
}];
|
|
511
929
|
}, {
|
|
512
930
|
readonly name: "Transfer";
|
|
513
931
|
readonly type: "event";
|
|
@@ -523,236 +941,360 @@ declare const MOCK_POINT_TOKEN_V2_ABI: readonly [{
|
|
|
523
941
|
readonly type: "uint256";
|
|
524
942
|
readonly name: "value";
|
|
525
943
|
}];
|
|
944
|
+
}, {
|
|
945
|
+
readonly name: "MinterAdded";
|
|
946
|
+
readonly type: "event";
|
|
947
|
+
readonly inputs: readonly [{
|
|
948
|
+
readonly type: "address";
|
|
949
|
+
readonly name: "minter";
|
|
950
|
+
readonly indexed: true;
|
|
951
|
+
}];
|
|
952
|
+
}, {
|
|
953
|
+
readonly name: "MinterRemoved";
|
|
954
|
+
readonly type: "event";
|
|
955
|
+
readonly inputs: readonly [{
|
|
956
|
+
readonly type: "address";
|
|
957
|
+
readonly name: "minter";
|
|
958
|
+
readonly indexed: true;
|
|
959
|
+
}];
|
|
960
|
+
}, {
|
|
961
|
+
readonly name: "BurnerAdded";
|
|
962
|
+
readonly type: "event";
|
|
963
|
+
readonly inputs: readonly [{
|
|
964
|
+
readonly type: "address";
|
|
965
|
+
readonly name: "burner";
|
|
966
|
+
readonly indexed: true;
|
|
967
|
+
}];
|
|
968
|
+
}, {
|
|
969
|
+
readonly name: "BurnerRemoved";
|
|
970
|
+
readonly type: "event";
|
|
971
|
+
readonly inputs: readonly [{
|
|
972
|
+
readonly type: "address";
|
|
973
|
+
readonly name: "burner";
|
|
974
|
+
readonly indexed: true;
|
|
975
|
+
}];
|
|
976
|
+
}, {
|
|
977
|
+
readonly name: "MintingOracleUpdated";
|
|
978
|
+
readonly type: "event";
|
|
979
|
+
readonly inputs: readonly [{
|
|
980
|
+
readonly type: "address";
|
|
981
|
+
readonly name: "mintingOracle";
|
|
982
|
+
readonly indexed: true;
|
|
983
|
+
}];
|
|
526
984
|
}];
|
|
527
985
|
|
|
528
986
|
/**
|
|
529
|
-
*
|
|
987
|
+
* BatchExecutor delegation target addresses.
|
|
988
|
+
*
|
|
989
|
+
* ## Status
|
|
530
990
|
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
991
|
+
* Base mainnet: points at **Coinbase Smart Wallet v2**
|
|
992
|
+
* (`0x7702cb554e6bFb442cb743A7dF23154544a7176C`). Coinbase publishes
|
|
993
|
+
* this as the canonical EIP-7702 delegation target on Base — every
|
|
994
|
+
* user that wants gas sponsorship via Coinbase Paymaster delegates to
|
|
995
|
+
* this single contract. One contract, all issuers.
|
|
535
996
|
*
|
|
536
|
-
*
|
|
537
|
-
* `../../userop/batchExecute.ts` — that's the real one, unchanged
|
|
538
|
-
* by the mock swap. Only the **address** is mocked here.
|
|
997
|
+
* Base Sepolia: placeholder; Sepolia is not in active use for PAFI.
|
|
539
998
|
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
999
|
+
* The ABI (`execute(Call[])`) is exported from
|
|
1000
|
+
* `../../userop/batchExecute.ts` and works against the Coinbase
|
|
1001
|
+
* contract without change — Coinbase Smart Wallet v2 implements the
|
|
1002
|
+
* same call-array signature we already use.
|
|
542
1003
|
*/
|
|
543
|
-
declare const
|
|
544
|
-
declare const
|
|
1004
|
+
declare const BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA: Address;
|
|
1005
|
+
declare const BATCH_EXECUTOR_ADDRESS_BASE_MAINNET: Address;
|
|
545
1006
|
|
|
546
1007
|
/**
|
|
547
|
-
*
|
|
1008
|
+
* Per-chain deployed contract addresses — v1.4 flow.
|
|
1009
|
+
*
|
|
1010
|
+
* ## Status (2026-04-22)
|
|
548
1011
|
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
1012
|
+
* Base mainnet (8453): **all real**. BatchExecutor now points at the
|
|
1013
|
+
* canonical Coinbase Smart Wallet v2 contract which PAFI reuses as the
|
|
1014
|
+
* EIP-7702 delegation target (no per-app deploy required — one
|
|
1015
|
+
* contract, every issuer).
|
|
552
1016
|
*
|
|
553
|
-
*
|
|
554
|
-
* a mainnet address here get a `0x...DEAD` placeholder which will
|
|
555
|
-
* revert at contract-level. That's the point: prod refuses to run
|
|
556
|
-
* on mocks.
|
|
1017
|
+
* Base Sepolia (84532): entire row is placeholder — not in active use.
|
|
557
1018
|
*
|
|
558
|
-
*
|
|
559
|
-
* - 8453 Base mainnet
|
|
560
|
-
* - 84532 Base Sepolia
|
|
1019
|
+
* ## What lives where
|
|
561
1020
|
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
1021
|
+
* pointToken — live POINT instance (clone of PointToken impl)
|
|
1022
|
+
* batchExecutor — EIP-7702 delegation target (Coinbase Smart Wallet v2)
|
|
1023
|
+
* usdt — MockERC20 used by Uniswap pools
|
|
1024
|
+
* issuerRegistry — registry of all issuers on this chain
|
|
1025
|
+
* mintingOracle — per-issuer mint cap enforcer
|
|
1026
|
+
* pafiHook — Uniswap V4 hook enforcing the 10% PT→USDT fee
|
|
1027
|
+
*
|
|
1028
|
+
* PointTokenFactory + PointToken implementation addresses live in
|
|
1029
|
+
* separate exports below — they're only needed at provisioning /
|
|
1030
|
+
* observability time, not in the hot mint/burn path, so excluded from
|
|
1031
|
+
* the per-chain bundle.
|
|
567
1032
|
*/
|
|
568
1033
|
interface ContractAddresses {
|
|
569
|
-
relayerV2: Address;
|
|
570
1034
|
pointToken: Address;
|
|
571
1035
|
batchExecutor: Address;
|
|
572
1036
|
usdt: Address;
|
|
573
1037
|
issuerRegistry: Address;
|
|
574
1038
|
mintingOracle: Address;
|
|
1039
|
+
/**
|
|
1040
|
+
* Uniswap V4 hook that enforces the 10% fee on PT→USDT swaps
|
|
1041
|
+
* (USDT→PT is free). FE reads this to build `PoolKey.hooks` when
|
|
1042
|
+
* constructing a swap; quoters + routers need it to resolve the
|
|
1043
|
+
* correct pool.
|
|
1044
|
+
*/
|
|
1045
|
+
pafiHook: Address;
|
|
575
1046
|
}
|
|
576
|
-
declare const
|
|
1047
|
+
declare const CONTRACT_ADDRESSES: Record<number, ContractAddresses>;
|
|
1048
|
+
/**
|
|
1049
|
+
* PointTokenFactory address — separate from `ContractAddresses` because
|
|
1050
|
+
* it's only used at provisioning time (issuer onboard + token creation),
|
|
1051
|
+
* not in the hot mint/burn path.
|
|
1052
|
+
*/
|
|
1053
|
+
declare const POINT_TOKEN_FACTORY_ADDRESSES: Record<number, Address>;
|
|
1054
|
+
/**
|
|
1055
|
+
* PointToken implementation address — the EIP-1167 clone target used
|
|
1056
|
+
* by PointTokenFactory. Exposed for observability / proxy verification;
|
|
1057
|
+
* consumers should never call this directly.
|
|
1058
|
+
*/
|
|
1059
|
+
declare const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address>;
|
|
577
1060
|
/**
|
|
578
1061
|
* Lookup helper — throws if the chain isn't in the map so callers fail
|
|
579
1062
|
* loudly on misconfiguration instead of silently using `undefined`.
|
|
580
1063
|
*/
|
|
581
|
-
declare function
|
|
1064
|
+
declare function getContractAddresses(chainId: number): ContractAddresses;
|
|
582
1065
|
|
|
583
1066
|
/**
|
|
584
|
-
*
|
|
1067
|
+
* Public contract surface for `@pafi-dev/core/contracts`.
|
|
1068
|
+
*
|
|
1069
|
+
* Consumers import ABIs + per-chain addresses from this module. EIP-712
|
|
1070
|
+
* helpers (`signMintRequest`, `signBurnRequest`, etc.) live under
|
|
1071
|
+
* `./eip712/` and are re-exported from the package root — not duplicated
|
|
1072
|
+
* here.
|
|
1073
|
+
*
|
|
1074
|
+
* ## v1.4 flow — no Relayer, sig-gated mint/burn
|
|
585
1075
|
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
1076
|
+
* Relayer contract dropped. Users call `PointToken.mint(to, amount,
|
|
1077
|
+
* deadline, minterSig)` directly via an EIP-7702 delegated UserOp —
|
|
1078
|
+
* `msg.sender == user == to`. `minterSig` is an EIP-712 `MintRequest`
|
|
1079
|
+
* signed off-chain by the issuer's minter signer (HSM/KMS). Mirror
|
|
1080
|
+
* structure on the burn side with `BurnRequest` + `burn(from, amount,
|
|
1081
|
+
* deadline, burnerSig)`.
|
|
588
1082
|
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
1083
|
+
* Exports:
|
|
1084
|
+
* - `POINT_TOKEN_V2_ABI` — full mint + burn + admin surface
|
|
1085
|
+
* - `BATCH_EXECUTOR_*` — EIP-7702 delegation target (ABI real,
|
|
1086
|
+
* address still placeholder on all
|
|
1087
|
+
* chains until SC delivers)
|
|
1088
|
+
* - `CONTRACT_ADDRESSES` — per-chain map (real on 8453 except
|
|
1089
|
+
* `batchExecutor` — pending SC)
|
|
1090
|
+
* - `POINT_TOKEN_FACTORY_ADDRESSES`, `POINT_TOKEN_IMPL_ADDRESSES`
|
|
1091
|
+
* — provisioning / observability helpers
|
|
592
1092
|
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* below stay stable — only `MOCK_MINT_REQUEST_V2_TYPES` changes.
|
|
1093
|
+
* Status: all real except BatchExecutor address (single remaining
|
|
1094
|
+
* placeholder, flagged inline in `real/addresses.ts`).
|
|
596
1095
|
*/
|
|
597
|
-
|
|
598
|
-
readonly MintRequest: readonly [{
|
|
599
|
-
readonly name: "to";
|
|
600
|
-
readonly type: "address";
|
|
601
|
-
}, {
|
|
602
|
-
readonly name: "amount";
|
|
603
|
-
readonly type: "uint256";
|
|
604
|
-
}, {
|
|
605
|
-
readonly name: "feeAmount";
|
|
606
|
-
readonly type: "uint256";
|
|
607
|
-
}, {
|
|
608
|
-
readonly name: "feeRecipient";
|
|
609
|
-
readonly type: "address";
|
|
610
|
-
}, {
|
|
611
|
-
readonly name: "nonce";
|
|
612
|
-
readonly type: "uint256";
|
|
613
|
-
}, {
|
|
614
|
-
readonly name: "deadline";
|
|
615
|
-
readonly type: "uint256";
|
|
616
|
-
}, {
|
|
617
|
-
readonly name: "extData";
|
|
618
|
-
readonly type: "bytes";
|
|
619
|
-
}];
|
|
620
|
-
};
|
|
1096
|
+
|
|
621
1097
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
1098
|
+
* Signature struct — kept for consumers that want the tuple form.
|
|
1099
|
+
* Most v1.4 paths pass `bytes` (serialized signature) directly to the
|
|
1100
|
+
* contract; this struct is only needed if you're manually splitting
|
|
1101
|
+
* for other on-chain verifiers.
|
|
625
1102
|
*/
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
};
|
|
633
|
-
types: {
|
|
634
|
-
readonly MintRequest: readonly [{
|
|
635
|
-
readonly name: "to";
|
|
636
|
-
readonly type: "address";
|
|
637
|
-
}, {
|
|
638
|
-
readonly name: "amount";
|
|
639
|
-
readonly type: "uint256";
|
|
640
|
-
}, {
|
|
641
|
-
readonly name: "feeAmount";
|
|
642
|
-
readonly type: "uint256";
|
|
643
|
-
}, {
|
|
644
|
-
readonly name: "feeRecipient";
|
|
645
|
-
readonly type: "address";
|
|
646
|
-
}, {
|
|
647
|
-
readonly name: "nonce";
|
|
648
|
-
readonly type: "uint256";
|
|
649
|
-
}, {
|
|
650
|
-
readonly name: "deadline";
|
|
651
|
-
readonly type: "uint256";
|
|
652
|
-
}, {
|
|
653
|
-
readonly name: "extData";
|
|
654
|
-
readonly type: "bytes";
|
|
655
|
-
}];
|
|
656
|
-
};
|
|
657
|
-
primaryType: "MintRequest";
|
|
658
|
-
message: MockMintRequestV2;
|
|
659
|
-
};
|
|
1103
|
+
interface SignatureStruct {
|
|
1104
|
+
v: number;
|
|
1105
|
+
r: `0x${string}`;
|
|
1106
|
+
s: `0x${string}`;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
660
1109
|
/**
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
1110
|
+
* Options for opening a PAFI Web modal — passed through by all adapters.
|
|
1111
|
+
* Web-only fields (width/height/windowName) are ignored by mobile
|
|
1112
|
+
* adapters that can't resize a system in-app browser.
|
|
664
1113
|
*/
|
|
665
|
-
|
|
1114
|
+
interface ModalOpenOptions {
|
|
1115
|
+
/** Web popup pixel width. Default 900. Ignored on mobile. */
|
|
1116
|
+
width?: number;
|
|
1117
|
+
/** Web popup pixel height. Default 700. Ignored on mobile. */
|
|
1118
|
+
height?: number;
|
|
1119
|
+
/**
|
|
1120
|
+
* `window.open()` target name. Same name across calls re-uses an
|
|
1121
|
+
* already-open popup. Default: `"pafi-web"`. Web-only.
|
|
1122
|
+
*/
|
|
1123
|
+
windowName?: string;
|
|
1124
|
+
/**
|
|
1125
|
+
* Called when the modal closes — either user-initiated (clicked
|
|
1126
|
+
* close, swiped down on mobile) or programmatically via `handle.close()`.
|
|
1127
|
+
*/
|
|
1128
|
+
onClose?: () => void;
|
|
1129
|
+
/**
|
|
1130
|
+
* Called when the opened window posts a message back to the parent
|
|
1131
|
+
* via `window.opener.postMessage(data, origin)`. PAFI Web uses this
|
|
1132
|
+
* to signal "swap complete" / "perp deposit complete" back to the
|
|
1133
|
+
* issuer app without needing a redirect.
|
|
1134
|
+
*
|
|
1135
|
+
* `origin` is the posting window's origin — caller MUST verify it
|
|
1136
|
+
* matches the expected PAFI Web host before trusting `data`.
|
|
1137
|
+
*/
|
|
1138
|
+
onMessage?: (data: unknown, origin: string) => void;
|
|
1139
|
+
/**
|
|
1140
|
+
* Allowed origins for `onMessage` — messages from other origins are
|
|
1141
|
+
* silently dropped. Pass the PAFI Web host(s), e.g.
|
|
1142
|
+
* `["https://app.pacificfinance.org", "https://app-dev.pacificfinance.org"]`.
|
|
1143
|
+
*
|
|
1144
|
+
* Default: empty (all messages rejected). Set explicitly for security.
|
|
1145
|
+
*/
|
|
1146
|
+
allowedOrigins?: string[];
|
|
1147
|
+
}
|
|
666
1148
|
/**
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* being verified).
|
|
1149
|
+
* Handle to an open PAFI Web modal. Methods are no-ops when the modal
|
|
1150
|
+
* has already closed — safe to call without tracking state yourself.
|
|
670
1151
|
*/
|
|
671
|
-
|
|
672
|
-
|
|
1152
|
+
interface PafiWebModalHandle {
|
|
1153
|
+
/** True when the modal is still open. */
|
|
1154
|
+
readonly isOpen: boolean;
|
|
1155
|
+
/** Close the modal. Fires `onClose` if the callback was supplied. */
|
|
1156
|
+
close(): void;
|
|
1157
|
+
/** Bring the modal to focus (web popup only; mobile ignores). */
|
|
1158
|
+
focus(): void;
|
|
1159
|
+
/**
|
|
1160
|
+
* Post a message INTO the modal — useful for ping/pong handshakes
|
|
1161
|
+
* with PAFI Web. The modal page must be on the same origin or
|
|
1162
|
+
* explicitly listen for the message.
|
|
1163
|
+
*/
|
|
1164
|
+
postMessage(data: unknown): void;
|
|
1165
|
+
}
|
|
673
1166
|
/**
|
|
674
|
-
*
|
|
1167
|
+
* Adapter that knows how to open a URL in the right UX for the host
|
|
1168
|
+
* platform. Callers register one via `setPafiWebModalAdapter()`; if
|
|
1169
|
+
* none is registered, the core module falls back to `openWebPopup()`
|
|
1170
|
+
* (if `window` is present) or throws (in Node / React Native without
|
|
1171
|
+
* an adapter set).
|
|
675
1172
|
*
|
|
676
|
-
*
|
|
1173
|
+
* ## Mobile adapter example (React Native)
|
|
677
1174
|
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
* - A relayer calling `PointToken.burnWithSig(...)` (Variant B)
|
|
682
|
-
* - The paymaster-proxy-sponsored UserOp calling `PointToken.burn(...)`
|
|
683
|
-
* with msg.sender = user via EIP-7702 (Variant A)
|
|
1175
|
+
* ```ts
|
|
1176
|
+
* import { setPafiWebModalAdapter } from '@pafi-dev/core';
|
|
1177
|
+
* import InAppBrowser from 'react-native-inappbrowser-reborn';
|
|
684
1178
|
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
1179
|
+
* setPafiWebModalAdapter({
|
|
1180
|
+
* async open(url, options) {
|
|
1181
|
+
* const result = await InAppBrowser.open(url, {
|
|
1182
|
+
* // iOS: SFSafariViewController
|
|
1183
|
+
* dismissButtonStyle: 'close',
|
|
1184
|
+
* preferredBarTintColor: '#1a1a1a',
|
|
1185
|
+
* preferredControlTintColor: 'white',
|
|
1186
|
+
* // Android: Chrome Custom Tab
|
|
1187
|
+
* toolbarColor: '#1a1a1a',
|
|
1188
|
+
* secondaryToolbarColor: 'black',
|
|
1189
|
+
* });
|
|
1190
|
+
* options?.onClose?.();
|
|
1191
|
+
* return {
|
|
1192
|
+
* isOpen: false,
|
|
1193
|
+
* close: () => InAppBrowser.close(),
|
|
1194
|
+
* focus: () => {},
|
|
1195
|
+
* postMessage: () => {},
|
|
1196
|
+
* };
|
|
1197
|
+
* },
|
|
1198
|
+
* });
|
|
1199
|
+
* ```
|
|
687
1200
|
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
1201
|
+
* ## Expo adapter example
|
|
1202
|
+
*
|
|
1203
|
+
* ```ts
|
|
1204
|
+
* import * as WebBrowser from 'expo-web-browser';
|
|
1205
|
+
*
|
|
1206
|
+
* setPafiWebModalAdapter({
|
|
1207
|
+
* async open(url, options) {
|
|
1208
|
+
* await WebBrowser.openBrowserAsync(url);
|
|
1209
|
+
* options?.onClose?.();
|
|
1210
|
+
* return { isOpen: false, close: WebBrowser.dismissBrowser, focus: () => {}, postMessage: () => {} };
|
|
1211
|
+
* },
|
|
1212
|
+
* });
|
|
1213
|
+
* ```
|
|
690
1214
|
*/
|
|
691
|
-
interface
|
|
692
|
-
|
|
693
|
-
pointToken: Address;
|
|
694
|
-
amount: bigint;
|
|
695
|
-
nonce: bigint;
|
|
696
|
-
deadline: bigint;
|
|
1215
|
+
interface PafiWebModalAdapter {
|
|
1216
|
+
open(url: string, options?: ModalOpenOptions): PafiWebModalHandle | Promise<PafiWebModalHandle>;
|
|
697
1217
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Web browser popup adapter. Opens the given URL in a centered
|
|
1221
|
+
* `window.open()` popup, polls for close, and optionally forwards
|
|
1222
|
+
* `postMessage` events back to the caller.
|
|
1223
|
+
*
|
|
1224
|
+
* Runtime requirement: `window.open` must exist. Throws if called
|
|
1225
|
+
* under Node / SSR / React Native — use `setPafiWebModalAdapter()` to
|
|
1226
|
+
* provide a platform-specific adapter in those environments.
|
|
1227
|
+
*
|
|
1228
|
+
* ## Popup blocking
|
|
1229
|
+
*
|
|
1230
|
+
* Browsers block `window.open()` unless it happens inside a user
|
|
1231
|
+
* gesture (click handler). Callers MUST wire this into a direct click
|
|
1232
|
+
* handler — wrapping it in a `setTimeout` or async await before the
|
|
1233
|
+
* open call will trigger the blocker.
|
|
1234
|
+
*/
|
|
1235
|
+
declare function openWebPopup(url: string, options?: ModalOpenOptions): PafiWebModalHandle;
|
|
1236
|
+
/**
|
|
1237
|
+
* The web popup packaged as a {@link PafiWebModalAdapter} so callers
|
|
1238
|
+
* can register it explicitly (e.g. in a test harness).
|
|
1239
|
+
*/
|
|
1240
|
+
declare const webPopupAdapter: PafiWebModalAdapter;
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* Register the adapter used by `openPafiWebModal()`. Typically called
|
|
1244
|
+
* once during app initialization — mobile apps register a
|
|
1245
|
+
* SFSafariViewController / Chrome Custom Tabs adapter, desktop apps
|
|
1246
|
+
* can leave it unset (web popup is the default).
|
|
1247
|
+
*
|
|
1248
|
+
* Pass `null` to unregister and fall back to the default.
|
|
1249
|
+
*/
|
|
1250
|
+
declare function setPafiWebModalAdapter(adapter: PafiWebModalAdapter | null): void;
|
|
1251
|
+
/**
|
|
1252
|
+
* Return the currently registered adapter, or `null` when none is set.
|
|
1253
|
+
* Useful for tests that want to snapshot-and-restore the adapter.
|
|
1254
|
+
*/
|
|
1255
|
+
declare function getPafiWebModalAdapter(): PafiWebModalAdapter | null;
|
|
1256
|
+
/**
|
|
1257
|
+
* Open PAFI Web in the host platform's appropriate UX:
|
|
1258
|
+
*
|
|
1259
|
+
* - Browser (window.open): centered popup, 900×700 by default
|
|
1260
|
+
* - React Native (with adapter registered): SFSafariViewController
|
|
1261
|
+
* / Chrome Custom Tabs via `react-native-inappbrowser-reborn` or
|
|
1262
|
+
* `expo-web-browser`
|
|
1263
|
+
* - Desktop (with adapter registered): custom BrowserWindow / new tab
|
|
1264
|
+
*
|
|
1265
|
+
* Resolution order:
|
|
1266
|
+
* 1. If an adapter was registered via `setPafiWebModalAdapter()`, use it.
|
|
1267
|
+
* 2. Else if `window.open` is available, use the built-in web popup.
|
|
1268
|
+
* 3. Else throw with a clear error pointing at the adapter registry.
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* ```ts
|
|
1272
|
+
* // User clicks "Trade on PAFI" button
|
|
1273
|
+
* button.addEventListener('click', async () => {
|
|
1274
|
+
* const modal = await openPafiWebModal('https://app.pacificfinance.org', {
|
|
1275
|
+
* allowedOrigins: ['https://app.pacificfinance.org'],
|
|
1276
|
+
* onMessage: (data, origin) => {
|
|
1277
|
+
* if (typeof data === 'object' && data && 'txHash' in data) {
|
|
1278
|
+
* console.log('Swap confirmed:', data.txHash);
|
|
1279
|
+
* modal.close();
|
|
1280
|
+
* }
|
|
1281
|
+
* },
|
|
1282
|
+
* onClose: () => {
|
|
1283
|
+
* console.log('User closed modal');
|
|
1284
|
+
* },
|
|
1285
|
+
* });
|
|
1286
|
+
* });
|
|
1287
|
+
* ```
|
|
1288
|
+
*/
|
|
1289
|
+
declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Promise<PafiWebModalHandle>;
|
|
746
1290
|
|
|
747
1291
|
declare class PafiSDK {
|
|
748
1292
|
private _pointTokenAddress?;
|
|
749
|
-
private _relayContractAddress?;
|
|
750
1293
|
private _signer?;
|
|
751
1294
|
private _provider?;
|
|
752
1295
|
private _chainId?;
|
|
753
1296
|
constructor(config: PafiSDKConfig);
|
|
754
1297
|
setPointTokenAddress(address: Address): void;
|
|
755
|
-
setRelayContractAddress(address: Address): void;
|
|
756
1298
|
setSigner(signer: WalletClient): void;
|
|
757
1299
|
setProvider(provider: PublicClient): void;
|
|
758
1300
|
private requirePointToken;
|
|
@@ -760,10 +1302,6 @@ declare class PafiSDK {
|
|
|
760
1302
|
private requireSigner;
|
|
761
1303
|
private requireChainId;
|
|
762
1304
|
getDomain(): Promise<PointTokenDomainConfig>;
|
|
763
|
-
/**
|
|
764
|
-
* Build the EIP-712 typed data for a MintRequest.
|
|
765
|
-
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
766
|
-
*/
|
|
767
1305
|
buildMintRequestTypedData(message: MintRequest): Promise<{
|
|
768
1306
|
domain: {
|
|
769
1307
|
name: string;
|
|
@@ -789,10 +1327,6 @@ declare class PafiSDK {
|
|
|
789
1327
|
primaryType: "MintRequest";
|
|
790
1328
|
message: MintRequest;
|
|
791
1329
|
}>;
|
|
792
|
-
/**
|
|
793
|
-
* Build the EIP-712 typed data for a ReceiverConsent.
|
|
794
|
-
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
795
|
-
*/
|
|
796
1330
|
buildReceiverConsentTypedData(message: ReceiverConsent): Promise<{
|
|
797
1331
|
domain: {
|
|
798
1332
|
name: string;
|
|
@@ -830,11 +1364,6 @@ declare class PafiSDK {
|
|
|
830
1364
|
verifyReceiverConsent(message: ReceiverConsent, signature: Hex, expectedReceiver: Address): Promise<SignatureVerification>;
|
|
831
1365
|
getMintRequestNonce(receiver: Address): Promise<bigint>;
|
|
832
1366
|
getReceiverConsentNonce(receiver: Address): Promise<bigint>;
|
|
833
|
-
encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex;
|
|
834
|
-
decodeMintAndSwap(calldata: Hex): {
|
|
835
|
-
mint: MintParams;
|
|
836
|
-
swap: SwapParams;
|
|
837
|
-
};
|
|
838
1367
|
/**
|
|
839
1368
|
* Find the best swap route from `tokenIn` to `tokenOut`.
|
|
840
1369
|
* Merges `pools` with COMMON_POOLS for the configured chain, builds all
|
|
@@ -855,36 +1384,6 @@ declare class PafiSDK {
|
|
|
855
1384
|
commands: Hex;
|
|
856
1385
|
inputs: Hex[];
|
|
857
1386
|
};
|
|
858
|
-
/**
|
|
859
|
-
* Build Relay SwapParams + extData from a quote result.
|
|
860
|
-
* Returns ready-to-use args for `Relay.mintAndSwap`.
|
|
861
|
-
*/
|
|
862
|
-
buildRelaySwapParams(params: {
|
|
863
|
-
quote: {
|
|
864
|
-
path: PathKey[];
|
|
865
|
-
};
|
|
866
|
-
minAmountOut: bigint;
|
|
867
|
-
feeInUsdt: bigint;
|
|
868
|
-
deadline: bigint;
|
|
869
|
-
}): {
|
|
870
|
-
swapParams: SwapParams;
|
|
871
|
-
extData: Hex;
|
|
872
|
-
};
|
|
873
|
-
/**
|
|
874
|
-
* Encode extData for ReceiverConsent and MintParams.
|
|
875
|
-
* extData = abi.encode(minAmountOut, feeInUsdt)
|
|
876
|
-
*/
|
|
877
|
-
encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex;
|
|
878
|
-
/**
|
|
879
|
-
* Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,
|
|
880
|
-
* expired deadlines, insufficient mint cap, pool errors) before submitting.
|
|
881
|
-
*
|
|
882
|
-
* @param relayAddress - Relay contract address
|
|
883
|
-
* @param mint - MintParams with real signatures
|
|
884
|
-
* @param swap - SwapParams (path + deadline)
|
|
885
|
-
* @param from - Relayer address that will submit the tx
|
|
886
|
-
*/
|
|
887
|
-
simulateMintAndSwap(relayAddress: Address, mint: MintParams, swap: SwapParams, from: Address): Promise<SimulationResult>;
|
|
888
1387
|
/**
|
|
889
1388
|
* Simulate a UniversalRouter.execute swap call. Catches reverts (bad
|
|
890
1389
|
* approvals, insufficient balance, pool errors) before submitting.
|
|
@@ -896,14 +1395,9 @@ declare class PafiSDK {
|
|
|
896
1395
|
* @param from - Address that will execute the swap
|
|
897
1396
|
*/
|
|
898
1397
|
simulateSwap(routerAddress: Address, commands: Hex, inputs: Hex[], deadline: bigint, from: Address): Promise<SwapSimulationResult>;
|
|
899
|
-
/**
|
|
900
|
-
* Build an EIP-4361 login message for the current signer + chain. The
|
|
901
|
-
* caller supplies the issuer-specific fields (domain, nonce, uri); the SDK
|
|
902
|
-
* fills in the wallet address and chain id from its own config.
|
|
903
|
-
*/
|
|
904
1398
|
createLoginMessage(params: Omit<LoginMessageParams, "address" | "chainId">): Promise<string>;
|
|
905
1399
|
/** Sign a login message string with the current signer (personal_sign) */
|
|
906
1400
|
signLoginMessage(message: string): Promise<Hex>;
|
|
907
1401
|
}
|
|
908
1402
|
|
|
909
|
-
export { ApiError, BATCH_EXECUTOR_ABI,
|
|
1403
|
+
export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|