@pafi-dev/core 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +11 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -505,14 +505,20 @@ interface BuildPerpDepositViaRelayParams {
|
|
|
505
505
|
/** Deposit request (token, receiver, brokerHash, totalAmount, maxFee). */
|
|
506
506
|
request: OrderlyRelayDepositRequest;
|
|
507
507
|
/**
|
|
508
|
-
* Optional
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
508
|
+
* Optional USDC (input-token) gas-fee transfer prepended to the batch.
|
|
509
|
+
* The user holds USDC at the start of the batch, so the fee comes out
|
|
510
|
+
* of the same input token — no second-token requirement. Set both
|
|
511
|
+
* `gasFeeUsdcRecipient` and `gasFeeUsdc` together for sponsored
|
|
512
|
+
* flows (PAFI gas reimbursement). Pass `0n` / `undefined` for the
|
|
513
|
+
* fallback path where the user pays ERC-4337 gas in ETH directly.
|
|
514
|
+
*
|
|
515
|
+
* v0.7 — input-token fee position rule: user holds USDC BEFORE
|
|
516
|
+
* deposit (token-availability), so charge there. Replaces the old
|
|
517
|
+
* `gasFeePt` / `gasFeePtRecipient` / `pointTokenAddress` triple from
|
|
518
|
+
* v0.6.
|
|
512
519
|
*/
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
gasFeePtRecipient?: Address;
|
|
520
|
+
gasFeeUsdc?: bigint;
|
|
521
|
+
gasFeeUsdcRecipient?: Address;
|
|
516
522
|
gasLimits?: {
|
|
517
523
|
callGasLimit?: bigint;
|
|
518
524
|
verificationGasLimit?: bigint;
|
|
@@ -522,10 +528,14 @@ interface BuildPerpDepositViaRelayParams {
|
|
|
522
528
|
/**
|
|
523
529
|
* Build a UserOp for Orderly perp deposit via the PAFI Relay.
|
|
524
530
|
*
|
|
525
|
-
* Sponsored ops: `[
|
|
526
|
-
* Fallback ops: `[
|
|
531
|
+
* Sponsored ops: `[USDC.transfer(feeRecipient, gasFeeUsdc), USDC.approve(relay, total), Relay.deposit(req)]`
|
|
532
|
+
* Fallback ops: `[ USDC.approve(relay, total), Relay.deposit(req)]`
|
|
527
533
|
*
|
|
528
534
|
* No `msg.value` — the Relay covers LayerZero out of its own ETH reserve.
|
|
535
|
+
*
|
|
536
|
+
* Fee position rule: user holds USDC at start of batch → fee transfer
|
|
537
|
+
* runs FIRST in the same token. User must hold `totalAmount + gasFeeUsdc`
|
|
538
|
+
* USDC; net deposit to Orderly is `totalAmount - relayTokenFee`.
|
|
529
539
|
*/
|
|
530
540
|
declare function buildPerpDepositViaRelay(params: BuildPerpDepositViaRelayParams): PartialUserOperation;
|
|
531
541
|
|
package/dist/index.d.ts
CHANGED
|
@@ -505,14 +505,20 @@ interface BuildPerpDepositViaRelayParams {
|
|
|
505
505
|
/** Deposit request (token, receiver, brokerHash, totalAmount, maxFee). */
|
|
506
506
|
request: OrderlyRelayDepositRequest;
|
|
507
507
|
/**
|
|
508
|
-
* Optional
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
508
|
+
* Optional USDC (input-token) gas-fee transfer prepended to the batch.
|
|
509
|
+
* The user holds USDC at the start of the batch, so the fee comes out
|
|
510
|
+
* of the same input token — no second-token requirement. Set both
|
|
511
|
+
* `gasFeeUsdcRecipient` and `gasFeeUsdc` together for sponsored
|
|
512
|
+
* flows (PAFI gas reimbursement). Pass `0n` / `undefined` for the
|
|
513
|
+
* fallback path where the user pays ERC-4337 gas in ETH directly.
|
|
514
|
+
*
|
|
515
|
+
* v0.7 — input-token fee position rule: user holds USDC BEFORE
|
|
516
|
+
* deposit (token-availability), so charge there. Replaces the old
|
|
517
|
+
* `gasFeePt` / `gasFeePtRecipient` / `pointTokenAddress` triple from
|
|
518
|
+
* v0.6.
|
|
512
519
|
*/
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
gasFeePtRecipient?: Address;
|
|
520
|
+
gasFeeUsdc?: bigint;
|
|
521
|
+
gasFeeUsdcRecipient?: Address;
|
|
516
522
|
gasLimits?: {
|
|
517
523
|
callGasLimit?: bigint;
|
|
518
524
|
verificationGasLimit?: bigint;
|
|
@@ -522,10 +528,14 @@ interface BuildPerpDepositViaRelayParams {
|
|
|
522
528
|
/**
|
|
523
529
|
* Build a UserOp for Orderly perp deposit via the PAFI Relay.
|
|
524
530
|
*
|
|
525
|
-
* Sponsored ops: `[
|
|
526
|
-
* Fallback ops: `[
|
|
531
|
+
* Sponsored ops: `[USDC.transfer(feeRecipient, gasFeeUsdc), USDC.approve(relay, total), Relay.deposit(req)]`
|
|
532
|
+
* Fallback ops: `[ USDC.approve(relay, total), Relay.deposit(req)]`
|
|
527
533
|
*
|
|
528
534
|
* No `msg.value` — the Relay covers LayerZero out of its own ETH reserve.
|
|
535
|
+
*
|
|
536
|
+
* Fee position rule: user holds USDC at start of batch → fee transfer
|
|
537
|
+
* runs FIRST in the same token. User must hold `totalAmount + gasFeeUsdc`
|
|
538
|
+
* USDC; net deposit to Orderly is `totalAmount - relayTokenFee`.
|
|
529
539
|
*/
|
|
530
540
|
declare function buildPerpDepositViaRelay(params: BuildPerpDepositViaRelayParams): PartialUserOperation;
|
|
531
541
|
|
package/dist/index.js
CHANGED
|
@@ -344,7 +344,7 @@ function buildPerpDepositWithGasDeduction(params) {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
// src/perp/buildPerpDepositViaRelay.ts
|
|
347
|
-
import { encodeFunctionData as encodeFunctionData4
|
|
347
|
+
import { encodeFunctionData as encodeFunctionData4 } from "viem";
|
|
348
348
|
var ORDERLY_RELAY_ABI = [
|
|
349
349
|
{
|
|
350
350
|
type: "function",
|
|
@@ -396,26 +396,19 @@ function buildPerpDepositViaRelay(params) {
|
|
|
396
396
|
throw new Error("buildPerpDepositViaRelay: relayAddress required");
|
|
397
397
|
}
|
|
398
398
|
const operations = [];
|
|
399
|
-
if (params.
|
|
400
|
-
if (!params.
|
|
399
|
+
if (params.gasFeeUsdc && params.gasFeeUsdc > 0n) {
|
|
400
|
+
if (!params.gasFeeUsdcRecipient) {
|
|
401
401
|
throw new Error(
|
|
402
|
-
"buildPerpDepositViaRelay:
|
|
402
|
+
"buildPerpDepositViaRelay: gasFeeUsdcRecipient required when gasFeeUsdc > 0"
|
|
403
403
|
);
|
|
404
404
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
value: 0n,
|
|
413
|
-
data: encodeFunctionData4({
|
|
414
|
-
abi: erc20Abi3,
|
|
415
|
-
functionName: "transfer",
|
|
416
|
-
args: [params.gasFeePtRecipient, params.gasFeePt]
|
|
417
|
-
})
|
|
418
|
-
});
|
|
405
|
+
operations.push(
|
|
406
|
+
erc20TransferOp(
|
|
407
|
+
params.request.token,
|
|
408
|
+
params.gasFeeUsdcRecipient,
|
|
409
|
+
params.gasFeeUsdc
|
|
410
|
+
)
|
|
411
|
+
);
|
|
419
412
|
}
|
|
420
413
|
operations.push(
|
|
421
414
|
erc20ApproveOp(
|