@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.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
erc20Abi,
|
|
3
|
+
permit2Abi,
|
|
4
|
+
pointTokenFactoryAbi,
|
|
5
|
+
universalRouterAbi,
|
|
6
|
+
v4QuoterAbi
|
|
7
|
+
} from "./chunk-6CXTFOIH.js";
|
|
4
8
|
import {
|
|
5
9
|
SPONSOR_AUTH_DOMAIN_NAME,
|
|
6
10
|
SPONSOR_AUTH_TYPES,
|
|
@@ -33,62 +37,6 @@ import {
|
|
|
33
37
|
mintingOracleAbi,
|
|
34
38
|
pointTokenAbi
|
|
35
39
|
} from "./chunk-5JZOJIBT.js";
|
|
36
|
-
import {
|
|
37
|
-
buildBurnRequestTypedData,
|
|
38
|
-
buildDomain,
|
|
39
|
-
buildMintRequestTypedData,
|
|
40
|
-
buildReceiverConsentTypedData,
|
|
41
|
-
signBurnRequest,
|
|
42
|
-
signMintRequest,
|
|
43
|
-
signReceiverConsent,
|
|
44
|
-
verifyBurnRequest,
|
|
45
|
-
verifyMintRequest,
|
|
46
|
-
verifyReceiverConsent
|
|
47
|
-
} from "./chunk-TXA4GK5C.js";
|
|
48
|
-
import {
|
|
49
|
-
buildAllPaths,
|
|
50
|
-
combineRoutes,
|
|
51
|
-
findBestQuote,
|
|
52
|
-
quoteBestRoute,
|
|
53
|
-
quoteExactInput,
|
|
54
|
-
quoteExactInputSingle
|
|
55
|
-
} from "./chunk-WAFUL62X.js";
|
|
56
|
-
import {
|
|
57
|
-
v4QuoterAbi
|
|
58
|
-
} from "./chunk-KFWZRL7I.js";
|
|
59
|
-
import {
|
|
60
|
-
ApiError,
|
|
61
|
-
BATCH_EXECUTOR_ABI,
|
|
62
|
-
ConfigurationError,
|
|
63
|
-
PafiSDKError,
|
|
64
|
-
SETTLE_ALL,
|
|
65
|
-
SWAP_EXACT_IN,
|
|
66
|
-
SigningError,
|
|
67
|
-
SimulationError,
|
|
68
|
-
TAKE_ALL,
|
|
69
|
-
V4_SWAP,
|
|
70
|
-
assembleUserOperation,
|
|
71
|
-
buildErc20ApprovalCalldata,
|
|
72
|
-
buildPartialUserOperation,
|
|
73
|
-
buildPermit2ApprovalCalldata,
|
|
74
|
-
buildSwapFromQuote,
|
|
75
|
-
buildSwapWithGasDeduction,
|
|
76
|
-
buildUniversalRouterExecuteArgs,
|
|
77
|
-
buildV4SwapInput,
|
|
78
|
-
checkAllowance,
|
|
79
|
-
decodeBatchExecuteCalls,
|
|
80
|
-
encodeBatchExecute,
|
|
81
|
-
erc20ApproveOp,
|
|
82
|
-
erc20BurnOp,
|
|
83
|
-
erc20TransferOp,
|
|
84
|
-
rawCallOp,
|
|
85
|
-
simulateSwap
|
|
86
|
-
} from "./chunk-VG23GIWQ.js";
|
|
87
|
-
import {
|
|
88
|
-
erc20Abi,
|
|
89
|
-
permit2Abi,
|
|
90
|
-
universalRouterAbi
|
|
91
|
-
} from "./chunk-2PIXFXA2.js";
|
|
92
40
|
import {
|
|
93
41
|
COMMON_POOLS,
|
|
94
42
|
COMMON_TOKENS,
|
|
@@ -99,16 +47,64 @@ import {
|
|
|
99
47
|
SUPPORTED_CHAINS,
|
|
100
48
|
UNIVERSAL_ROUTER_ADDRESSES,
|
|
101
49
|
V4_QUOTER_ADDRESSES,
|
|
50
|
+
buildBurnRequestTypedData,
|
|
51
|
+
buildDomain,
|
|
52
|
+
buildMintRequestTypedData,
|
|
53
|
+
buildReceiverConsentTypedData,
|
|
102
54
|
burnRequestTypes,
|
|
103
55
|
mintRequestTypes,
|
|
104
|
-
receiverConsentTypes
|
|
105
|
-
|
|
56
|
+
receiverConsentTypes,
|
|
57
|
+
signBurnRequest,
|
|
58
|
+
signMintRequest,
|
|
59
|
+
signReceiverConsent,
|
|
60
|
+
verifyBurnRequest,
|
|
61
|
+
verifyMintRequest,
|
|
62
|
+
verifyReceiverConsent
|
|
63
|
+
} from "./chunk-UOKI5GG6.js";
|
|
106
64
|
|
|
107
65
|
// src/index.ts
|
|
108
66
|
import { createPublicClient, http as http2 } from "viem";
|
|
109
67
|
|
|
68
|
+
// src/errors.ts
|
|
69
|
+
var PafiSDKError = class extends Error {
|
|
70
|
+
constructor(message) {
|
|
71
|
+
super(message);
|
|
72
|
+
this.name = "PafiSDKError";
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var ConfigurationError = class extends PafiSDKError {
|
|
76
|
+
constructor(message) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.name = "ConfigurationError";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var SigningError = class extends PafiSDKError {
|
|
82
|
+
constructor(message) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = "SigningError";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var SimulationError = class extends PafiSDKError {
|
|
88
|
+
constructor(operation, reason) {
|
|
89
|
+
super(`Simulation failed for ${operation}: ${reason}`);
|
|
90
|
+
this.operation = operation;
|
|
91
|
+
this.reason = reason;
|
|
92
|
+
this.name = "SimulationError";
|
|
93
|
+
}
|
|
94
|
+
operation;
|
|
95
|
+
reason;
|
|
96
|
+
};
|
|
97
|
+
var ApiError = class extends PafiSDKError {
|
|
98
|
+
constructor(message, status) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.status = status;
|
|
101
|
+
this.name = "ApiError";
|
|
102
|
+
}
|
|
103
|
+
status;
|
|
104
|
+
};
|
|
105
|
+
|
|
110
106
|
// src/perp/buildPerpDepositWithGasDeduction.ts
|
|
111
|
-
import { encodeFunctionData } from "viem";
|
|
107
|
+
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
112
108
|
|
|
113
109
|
// src/contracts/real/orderlyVault.ts
|
|
114
110
|
import { keccak256, encodePacked, encodeAbiParameters } from "viem";
|
|
@@ -199,6 +195,106 @@ var ORDERLY_VAULT_ABI = [
|
|
|
199
195
|
}
|
|
200
196
|
];
|
|
201
197
|
|
|
198
|
+
// src/userop/operations.ts
|
|
199
|
+
import { encodeFunctionData, erc20Abi as erc20Abi2, parseAbi } from "viem";
|
|
200
|
+
var ERC20_BURNABLE_ABI = parseAbi(["function burn(uint256 amount)"]);
|
|
201
|
+
function erc20TransferOp(token, to, amount) {
|
|
202
|
+
return {
|
|
203
|
+
target: token,
|
|
204
|
+
value: 0n,
|
|
205
|
+
data: encodeFunctionData({
|
|
206
|
+
abi: erc20Abi2,
|
|
207
|
+
functionName: "transfer",
|
|
208
|
+
args: [to, amount]
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function erc20ApproveOp(token, spender, amount) {
|
|
213
|
+
return {
|
|
214
|
+
target: token,
|
|
215
|
+
value: 0n,
|
|
216
|
+
data: encodeFunctionData({
|
|
217
|
+
abi: erc20Abi2,
|
|
218
|
+
functionName: "approve",
|
|
219
|
+
args: [spender, amount]
|
|
220
|
+
})
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function erc20BurnOp(token, amount) {
|
|
224
|
+
return {
|
|
225
|
+
target: token,
|
|
226
|
+
value: 0n,
|
|
227
|
+
data: encodeFunctionData({
|
|
228
|
+
abi: ERC20_BURNABLE_ABI,
|
|
229
|
+
functionName: "burn",
|
|
230
|
+
args: [amount]
|
|
231
|
+
})
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function rawCallOp(target, data, value = 0n) {
|
|
235
|
+
return { target, value, data };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/userop/batchExecute.ts
|
|
239
|
+
import { decodeFunctionData, encodeFunctionData as encodeFunctionData2, parseAbi as parseAbi2 } from "viem";
|
|
240
|
+
var BATCH_EXECUTOR_ABI = parseAbi2([
|
|
241
|
+
"function executeBatch((address target, uint256 value, bytes data)[] calls)"
|
|
242
|
+
]);
|
|
243
|
+
function encodeBatchExecute(operations) {
|
|
244
|
+
if (operations.length === 0) {
|
|
245
|
+
throw new Error("encodeBatchExecute: operations array must not be empty");
|
|
246
|
+
}
|
|
247
|
+
return encodeFunctionData2({
|
|
248
|
+
abi: BATCH_EXECUTOR_ABI,
|
|
249
|
+
functionName: "executeBatch",
|
|
250
|
+
args: [
|
|
251
|
+
operations.map((op) => ({
|
|
252
|
+
target: op.target,
|
|
253
|
+
value: op.value,
|
|
254
|
+
data: op.data
|
|
255
|
+
}))
|
|
256
|
+
]
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function decodeBatchExecuteCalls(callData) {
|
|
260
|
+
const { args } = decodeFunctionData({
|
|
261
|
+
abi: BATCH_EXECUTOR_ABI,
|
|
262
|
+
data: callData
|
|
263
|
+
});
|
|
264
|
+
return args[0].map((c) => ({
|
|
265
|
+
to: c.target,
|
|
266
|
+
data: c.data,
|
|
267
|
+
value: c.value.toString()
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/userop/buildUserOperation.ts
|
|
272
|
+
var DEFAULT_CALL_GAS_LIMIT = 500000n;
|
|
273
|
+
var DEFAULT_VERIFICATION_GAS_LIMIT = 150000n;
|
|
274
|
+
var DEFAULT_PRE_VERIFICATION_GAS = 50000n;
|
|
275
|
+
function buildPartialUserOperation(params) {
|
|
276
|
+
return {
|
|
277
|
+
sender: params.sender,
|
|
278
|
+
nonce: params.nonce,
|
|
279
|
+
callData: encodeBatchExecute(params.operations),
|
|
280
|
+
callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,
|
|
281
|
+
verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_VERIFICATION_GAS_LIMIT,
|
|
282
|
+
preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,
|
|
283
|
+
maxFeePerGas: params.feeOverrides?.maxFeePerGas ?? 0n,
|
|
284
|
+
maxPriorityFeePerGas: params.feeOverrides?.maxPriorityFeePerGas ?? 0n
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function assembleUserOperation(partial, paymaster, signature) {
|
|
288
|
+
return {
|
|
289
|
+
...partial,
|
|
290
|
+
paymaster: paymaster.paymaster,
|
|
291
|
+
paymasterData: paymaster.paymasterData,
|
|
292
|
+
paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,
|
|
293
|
+
paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,
|
|
294
|
+
signature
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
202
298
|
// src/perp/buildPerpDepositWithGasDeduction.ts
|
|
203
299
|
function buildPerpDepositWithGasDeduction(params) {
|
|
204
300
|
if (params.amount <= 0n) {
|
|
@@ -220,7 +316,7 @@ function buildPerpDepositWithGasDeduction(params) {
|
|
|
220
316
|
`buildPerpDepositWithGasDeduction: no Orderly Vault address for chainId ${params.chainId}`
|
|
221
317
|
);
|
|
222
318
|
}
|
|
223
|
-
const depositCallData =
|
|
319
|
+
const depositCallData = encodeFunctionData3({
|
|
224
320
|
abi: ORDERLY_VAULT_ABI,
|
|
225
321
|
functionName: "deposit",
|
|
226
322
|
args: [params.depositData]
|
|
@@ -248,7 +344,7 @@ function buildPerpDepositWithGasDeduction(params) {
|
|
|
248
344
|
}
|
|
249
345
|
|
|
250
346
|
// src/perp/buildPerpDepositViaRelay.ts
|
|
251
|
-
import { encodeFunctionData as
|
|
347
|
+
import { encodeFunctionData as encodeFunctionData4, erc20Abi as erc20Abi3 } from "viem";
|
|
252
348
|
var ORDERLY_RELAY_ABI = [
|
|
253
349
|
{
|
|
254
350
|
type: "function",
|
|
@@ -314,8 +410,8 @@ function buildPerpDepositViaRelay(params) {
|
|
|
314
410
|
operations.push({
|
|
315
411
|
target: params.pointTokenAddress,
|
|
316
412
|
value: 0n,
|
|
317
|
-
data:
|
|
318
|
-
abi:
|
|
413
|
+
data: encodeFunctionData4({
|
|
414
|
+
abi: erc20Abi3,
|
|
319
415
|
functionName: "transfer",
|
|
320
416
|
args: [params.gasFeePtRecipient, params.gasFeePt]
|
|
321
417
|
})
|
|
@@ -328,7 +424,7 @@ function buildPerpDepositViaRelay(params) {
|
|
|
328
424
|
params.request.totalAmount
|
|
329
425
|
)
|
|
330
426
|
);
|
|
331
|
-
const depositCallData =
|
|
427
|
+
const depositCallData = encodeFunctionData4({
|
|
332
428
|
abi: ORDERLY_RELAY_ABI,
|
|
333
429
|
functionName: "deposit",
|
|
334
430
|
args: [
|
|
@@ -657,7 +753,7 @@ async function sendWithPaymasterFallback(params) {
|
|
|
657
753
|
}
|
|
658
754
|
|
|
659
755
|
// src/fee/operatorFeeQuoter.ts
|
|
660
|
-
import { parseAbi } from "viem";
|
|
756
|
+
import { parseAbi as parseAbi3 } from "viem";
|
|
661
757
|
|
|
662
758
|
// src/subgraph/pools.ts
|
|
663
759
|
import { isAddress } from "viem";
|
|
@@ -784,7 +880,7 @@ function getContractAddresses(chainId) {
|
|
|
784
880
|
}
|
|
785
881
|
|
|
786
882
|
// src/fee/operatorFeeQuoter.ts
|
|
787
|
-
var CHAINLINK_ABI =
|
|
883
|
+
var CHAINLINK_ABI = parseAbi3([
|
|
788
884
|
"function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80)"
|
|
789
885
|
]);
|
|
790
886
|
var CHAINLINK_MAX_AGE_S = 3600n;
|
|
@@ -803,6 +899,27 @@ var POOL_PRICE_QUERY = `
|
|
|
803
899
|
var DEFAULT_GAS_UNITS = 500000n;
|
|
804
900
|
var DEFAULT_PREMIUM_BPS = 12e3;
|
|
805
901
|
var DEFAULT_USDT_DECIMALS = 6;
|
|
902
|
+
async function quoteOperatorFeeUsdt(config) {
|
|
903
|
+
const {
|
|
904
|
+
provider,
|
|
905
|
+
chainId,
|
|
906
|
+
gasUnits = DEFAULT_GAS_UNITS,
|
|
907
|
+
premiumBps = DEFAULT_PREMIUM_BPS,
|
|
908
|
+
usdtDecimals = DEFAULT_USDT_DECIMALS,
|
|
909
|
+
fallbackEthPriceUsd = 3e3
|
|
910
|
+
} = config;
|
|
911
|
+
const chainlinkFeedAddress = config.chainlinkFeedAddress ?? getContractAddresses(chainId).chainlinkEthUsd;
|
|
912
|
+
const gasPrice = await provider.getGasPrice();
|
|
913
|
+
const nativeCost = gasPrice * gasUnits;
|
|
914
|
+
const withPremium = nativeCost * BigInt(premiumBps) / 10000n;
|
|
915
|
+
const ethPrice8dec = await getEthPrice8dec(
|
|
916
|
+
provider,
|
|
917
|
+
chainlinkFeedAddress,
|
|
918
|
+
fallbackEthPriceUsd
|
|
919
|
+
);
|
|
920
|
+
const denomExp = 18 + 8 - usdtDecimals;
|
|
921
|
+
return withPremium * ethPrice8dec / 10n ** BigInt(denomExp);
|
|
922
|
+
}
|
|
806
923
|
async function quoteOperatorFeePt(config) {
|
|
807
924
|
const {
|
|
808
925
|
provider,
|
|
@@ -1035,8 +1152,6 @@ var PafiSDK = class {
|
|
|
1035
1152
|
// -------------------------------------------------------------------------
|
|
1036
1153
|
mint;
|
|
1037
1154
|
consent;
|
|
1038
|
-
swap;
|
|
1039
|
-
quote;
|
|
1040
1155
|
auth;
|
|
1041
1156
|
constructor(config) {
|
|
1042
1157
|
this._pointTokenAddress = config.pointTokenAddress;
|
|
@@ -1061,13 +1176,6 @@ var PafiSDK = class {
|
|
|
1061
1176
|
verify: this.verifyReceiverConsent.bind(this),
|
|
1062
1177
|
getNonce: this.getReceiverConsentNonce.bind(this)
|
|
1063
1178
|
};
|
|
1064
|
-
this.swap = {
|
|
1065
|
-
buildFromQuote: this.buildSwapFromQuote.bind(this),
|
|
1066
|
-
simulate: this.simulateSwap.bind(this)
|
|
1067
|
-
};
|
|
1068
|
-
this.quote = {
|
|
1069
|
-
findBest: this.findBestQuote.bind(this)
|
|
1070
|
-
};
|
|
1071
1179
|
this.auth = {
|
|
1072
1180
|
createLoginMessage: this.createLoginMessage.bind(this),
|
|
1073
1181
|
signMessage: this.signLoginMessage.bind(this)
|
|
@@ -1167,59 +1275,6 @@ var PafiSDK = class {
|
|
|
1167
1275
|
);
|
|
1168
1276
|
}
|
|
1169
1277
|
// -------------------------------------------------------------------------
|
|
1170
|
-
// Quoting — delegates to pure functions
|
|
1171
|
-
// -------------------------------------------------------------------------
|
|
1172
|
-
/**
|
|
1173
|
-
* Find the best swap route from `tokenIn` to `tokenOut`.
|
|
1174
|
-
* Merges `pools` with COMMON_POOLS for the configured chain, builds all
|
|
1175
|
-
* paths, and quotes via a single multicall RPC call.
|
|
1176
|
-
*/
|
|
1177
|
-
async findBestQuote(tokenIn, tokenOut, exactAmount, pools = [], quoterAddress, maxHops) {
|
|
1178
|
-
return findBestQuote(
|
|
1179
|
-
this.requireProvider(),
|
|
1180
|
-
this.requireChainId(),
|
|
1181
|
-
tokenIn,
|
|
1182
|
-
tokenOut,
|
|
1183
|
-
exactAmount,
|
|
1184
|
-
pools,
|
|
1185
|
-
quoterAddress,
|
|
1186
|
-
maxHops
|
|
1187
|
-
);
|
|
1188
|
-
}
|
|
1189
|
-
// -------------------------------------------------------------------------
|
|
1190
|
-
// Swap building — delegates to pure functions
|
|
1191
|
-
// -------------------------------------------------------------------------
|
|
1192
|
-
/**
|
|
1193
|
-
* Build UniversalRouter execute args from a quote result.
|
|
1194
|
-
* The caller provides `minAmountOut` after applying their own slippage.
|
|
1195
|
-
*/
|
|
1196
|
-
buildSwapFromQuote(params) {
|
|
1197
|
-
return buildSwapFromQuote(params);
|
|
1198
|
-
}
|
|
1199
|
-
// -------------------------------------------------------------------------
|
|
1200
|
-
// Simulation — dry-run via eth_call (no gas spent)
|
|
1201
|
-
// -------------------------------------------------------------------------
|
|
1202
|
-
/**
|
|
1203
|
-
* Simulate a UniversalRouter.execute swap call. Catches reverts (bad
|
|
1204
|
-
* approvals, insufficient balance, pool errors) before submitting.
|
|
1205
|
-
*
|
|
1206
|
-
* @param routerAddress - UniversalRouter contract address
|
|
1207
|
-
* @param commands - Packed command bytes (from buildSwapFromQuote)
|
|
1208
|
-
* @param inputs - Encoded inputs (from buildSwapFromQuote)
|
|
1209
|
-
* @param deadline - Unix timestamp
|
|
1210
|
-
* @param from - Address that will execute the swap
|
|
1211
|
-
*/
|
|
1212
|
-
async simulateSwap(routerAddress, commands, inputs, deadline, from) {
|
|
1213
|
-
return simulateSwap(
|
|
1214
|
-
this.requireProvider(),
|
|
1215
|
-
routerAddress,
|
|
1216
|
-
commands,
|
|
1217
|
-
inputs,
|
|
1218
|
-
deadline,
|
|
1219
|
-
from
|
|
1220
|
-
);
|
|
1221
|
-
}
|
|
1222
|
-
// -------------------------------------------------------------------------
|
|
1223
1278
|
// Auth — EIP-4361 login helpers (offline, stateless)
|
|
1224
1279
|
// -------------------------------------------------------------------------
|
|
1225
1280
|
async createLoginMessage(params) {
|
|
@@ -1267,47 +1322,34 @@ export {
|
|
|
1267
1322
|
pointTokenAbi as POINT_TOKEN_V2_ABI,
|
|
1268
1323
|
PafiSDK,
|
|
1269
1324
|
PafiSDKError,
|
|
1270
|
-
SETTLE_ALL,
|
|
1271
1325
|
SIMPLE_7702_IMPL_BASE_MAINNET,
|
|
1272
1326
|
SPONSOR_AUTH_DOMAIN_NAME,
|
|
1273
1327
|
SPONSOR_AUTH_TYPES,
|
|
1274
1328
|
SUPPORTED_CHAINS,
|
|
1275
|
-
SWAP_EXACT_IN,
|
|
1276
1329
|
SigningError,
|
|
1277
1330
|
SimulationError,
|
|
1278
|
-
TAKE_ALL,
|
|
1279
1331
|
TOKEN_HASHES,
|
|
1280
1332
|
UNIVERSAL_ROUTER_ADDRESSES,
|
|
1281
1333
|
V4_QUOTER_ADDRESSES,
|
|
1282
|
-
V4_SWAP,
|
|
1283
1334
|
ZERO_VALUE,
|
|
1284
1335
|
_resetPaymasterConfigForTests,
|
|
1285
1336
|
assembleUserOperation,
|
|
1286
|
-
buildAllPaths,
|
|
1287
1337
|
buildAndSignSponsorAuth,
|
|
1288
1338
|
buildBurnRequestTypedData,
|
|
1289
1339
|
buildDelegationUserOp,
|
|
1290
1340
|
buildDomain,
|
|
1291
1341
|
buildEip7702Authorization,
|
|
1292
|
-
buildErc20ApprovalCalldata,
|
|
1293
1342
|
buildMintRequestTypedData,
|
|
1294
1343
|
buildPartialUserOperation,
|
|
1295
|
-
buildPermit2ApprovalCalldata,
|
|
1296
1344
|
buildPerpDepositViaRelay,
|
|
1297
1345
|
buildPerpDepositWithGasDeduction,
|
|
1298
1346
|
buildReceiverConsentTypedData,
|
|
1299
1347
|
buildSponsorAuthDomain,
|
|
1300
1348
|
buildSponsorAuthTypedData,
|
|
1301
|
-
buildSwapFromQuote,
|
|
1302
|
-
buildSwapWithGasDeduction,
|
|
1303
|
-
buildUniversalRouterExecuteArgs,
|
|
1304
1349
|
buildUserOpTypedData,
|
|
1305
|
-
buildV4SwapInput,
|
|
1306
1350
|
burnRequestTypes,
|
|
1307
|
-
checkAllowance,
|
|
1308
1351
|
checkDelegation,
|
|
1309
1352
|
checkEthAndBranch,
|
|
1310
|
-
combineRoutes,
|
|
1311
1353
|
computeAccountId,
|
|
1312
1354
|
computeAuthorizationHash,
|
|
1313
1355
|
computeCallDataHash,
|
|
@@ -1322,7 +1364,6 @@ export {
|
|
|
1322
1364
|
erc20BurnOp,
|
|
1323
1365
|
erc20TransferOp,
|
|
1324
1366
|
fetchPafiPools,
|
|
1325
|
-
findBestQuote,
|
|
1326
1367
|
getAaNonce,
|
|
1327
1368
|
getBurnRequestNonce,
|
|
1328
1369
|
getContractAddresses,
|
|
@@ -1353,10 +1394,8 @@ export {
|
|
|
1353
1394
|
permit2Abi,
|
|
1354
1395
|
pointTokenAbi,
|
|
1355
1396
|
pointTokenFactoryAbi,
|
|
1356
|
-
quoteBestRoute,
|
|
1357
|
-
quoteExactInput,
|
|
1358
|
-
quoteExactInputSingle,
|
|
1359
1397
|
quoteOperatorFeePt,
|
|
1398
|
+
quoteOperatorFeeUsdt,
|
|
1360
1399
|
rawCallOp,
|
|
1361
1400
|
receiverConsentTypes,
|
|
1362
1401
|
sendWithPaymasterFallback,
|
|
@@ -1367,7 +1406,6 @@ export {
|
|
|
1367
1406
|
signMintRequest,
|
|
1368
1407
|
signReceiverConsent,
|
|
1369
1408
|
signSponsorAuth,
|
|
1370
|
-
simulateSwap,
|
|
1371
1409
|
splitAuthorizationSig,
|
|
1372
1410
|
universalRouterAbi,
|
|
1373
1411
|
v4QuoterAbi,
|