@pafi-dev/core 0.7.0 → 0.7.2
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 +1 -0
- package/dist/abi/index.cjs.map +1 -1
- package/dist/abi/index.js +1 -0
- package/dist/auth/index.cjs +5 -2
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +10 -1
- package/dist/auth/index.d.ts +10 -1
- package/dist/auth/index.js +4 -1
- package/dist/{chunk-RZDG6SRR.cjs → chunk-5254AG3Z.cjs} +36 -5
- package/dist/chunk-5254AG3Z.cjs.map +1 -0
- package/dist/{chunk-QGXJLLKF.js → chunk-6UX2IFA2.js} +34 -3
- package/dist/chunk-6UX2IFA2.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +11 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/{chunk-3QDZFDEL.cjs → chunk-M5ULOZ3A.cjs} +3 -3
- package/dist/chunk-M5ULOZ3A.cjs.map +1 -0
- package/dist/{chunk-UOKI5GG6.js → chunk-WJSIB5GF.js} +2 -2
- package/dist/chunk-WJSIB5GF.js.map +1 -0
- package/dist/contract/index.cjs +1 -0
- package/dist/contract/index.cjs.map +1 -1
- package/dist/contract/index.d.cts +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +1 -0
- package/dist/eip712/index.cjs +3 -2
- package/dist/eip712/index.cjs.map +1 -1
- package/dist/eip712/index.d.cts +10 -5
- package/dist/eip712/index.d.ts +10 -5
- package/dist/eip712/index.js +2 -1
- package/dist/index.cjs +112 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -19
- package/dist/index.d.ts +126 -19
- package/dist/index.js +93 -18
- package/dist/index.js.map +1 -1
- package/dist/{types-JyuXUM8C.d.cts → types-BAkmxgVo.d.cts} +10 -0
- package/dist/{types-JyuXUM8C.d.ts → types-BAkmxgVo.d.ts} +10 -0
- package/package.json +1 -1
- package/dist/chunk-3QDZFDEL.cjs.map +0 -1
- package/dist/chunk-QGXJLLKF.js.map +0 -1
- package/dist/chunk-RZDG6SRR.cjs.map +0 -1
- package/dist/chunk-UOKI5GG6.js.map +0 -1
package/dist/eip712/index.d.cts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, c as BurnRequest, R as ReceiverConsent } from '../types-
|
|
1
|
+
import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, c as BurnRequest, R as ReceiverConsent } from '../types-BAkmxgVo.cjs';
|
|
2
2
|
import { WalletClient, Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Build the EIP-712 domain struct from a PointToken config. Uses
|
|
6
|
+
* `config.version` when supplied; defaults to `"1"` for back-compat.
|
|
7
|
+
* v0.7.1 — see SDK_CORE_TRADING_AUDIT.md H8.
|
|
8
|
+
*/
|
|
4
9
|
declare function buildDomain(config: PointTokenDomainConfig): {
|
|
5
10
|
name: string;
|
|
6
|
-
version:
|
|
11
|
+
version: string;
|
|
7
12
|
chainId: number;
|
|
8
13
|
verifyingContract: `0x${string}`;
|
|
9
14
|
};
|
|
@@ -16,7 +21,7 @@ declare function buildDomain(config: PointTokenDomainConfig): {
|
|
|
16
21
|
declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, message: MintRequest): {
|
|
17
22
|
domain: {
|
|
18
23
|
name: string;
|
|
19
|
-
version:
|
|
24
|
+
version: string;
|
|
20
25
|
chainId: number;
|
|
21
26
|
verifyingContract: `0x${string}`;
|
|
22
27
|
};
|
|
@@ -58,7 +63,7 @@ declare function verifyMintRequest(domain: PointTokenDomainConfig, message: Mint
|
|
|
58
63
|
declare function buildBurnRequestTypedData(domain: PointTokenDomainConfig, message: BurnRequest): {
|
|
59
64
|
domain: {
|
|
60
65
|
name: string;
|
|
61
|
-
version:
|
|
66
|
+
version: string;
|
|
62
67
|
chainId: number;
|
|
63
68
|
verifyingContract: `0x${string}`;
|
|
64
69
|
};
|
|
@@ -91,7 +96,7 @@ declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: Burn
|
|
|
91
96
|
declare function buildReceiverConsentTypedData(domain: PointTokenDomainConfig, message: ReceiverConsent): {
|
|
92
97
|
domain: {
|
|
93
98
|
name: string;
|
|
94
|
-
version:
|
|
99
|
+
version: string;
|
|
95
100
|
chainId: number;
|
|
96
101
|
verifyingContract: `0x${string}`;
|
|
97
102
|
};
|
package/dist/eip712/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, c as BurnRequest, R as ReceiverConsent } from '../types-
|
|
1
|
+
import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, c as BurnRequest, R as ReceiverConsent } from '../types-BAkmxgVo.js';
|
|
2
2
|
import { WalletClient, Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Build the EIP-712 domain struct from a PointToken config. Uses
|
|
6
|
+
* `config.version` when supplied; defaults to `"1"` for back-compat.
|
|
7
|
+
* v0.7.1 — see SDK_CORE_TRADING_AUDIT.md H8.
|
|
8
|
+
*/
|
|
4
9
|
declare function buildDomain(config: PointTokenDomainConfig): {
|
|
5
10
|
name: string;
|
|
6
|
-
version:
|
|
11
|
+
version: string;
|
|
7
12
|
chainId: number;
|
|
8
13
|
verifyingContract: `0x${string}`;
|
|
9
14
|
};
|
|
@@ -16,7 +21,7 @@ declare function buildDomain(config: PointTokenDomainConfig): {
|
|
|
16
21
|
declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, message: MintRequest): {
|
|
17
22
|
domain: {
|
|
18
23
|
name: string;
|
|
19
|
-
version:
|
|
24
|
+
version: string;
|
|
20
25
|
chainId: number;
|
|
21
26
|
verifyingContract: `0x${string}`;
|
|
22
27
|
};
|
|
@@ -58,7 +63,7 @@ declare function verifyMintRequest(domain: PointTokenDomainConfig, message: Mint
|
|
|
58
63
|
declare function buildBurnRequestTypedData(domain: PointTokenDomainConfig, message: BurnRequest): {
|
|
59
64
|
domain: {
|
|
60
65
|
name: string;
|
|
61
|
-
version:
|
|
66
|
+
version: string;
|
|
62
67
|
chainId: number;
|
|
63
68
|
verifyingContract: `0x${string}`;
|
|
64
69
|
};
|
|
@@ -91,7 +96,7 @@ declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: Burn
|
|
|
91
96
|
declare function buildReceiverConsentTypedData(domain: PointTokenDomainConfig, message: ReceiverConsent): {
|
|
92
97
|
domain: {
|
|
93
98
|
name: string;
|
|
94
|
-
version:
|
|
99
|
+
version: string;
|
|
95
100
|
chainId: number;
|
|
96
101
|
verifyingContract: `0x${string}`;
|
|
97
102
|
};
|
package/dist/eip712/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -17,7 +17,8 @@ var _chunkQ6WCDZXIcjs = require('./chunk-Q6WCDZXI.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var _chunk5254AG3Zcjs = require('./chunk-5254AG3Z.cjs');
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
@@ -60,12 +61,25 @@ var _chunkLRHY7GORcjs = require('./chunk-LRHY7GOR.cjs');
|
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
|
|
63
|
-
var
|
|
64
|
+
var _chunkM5ULOZ3Acjs = require('./chunk-M5ULOZ3A.cjs');
|
|
65
|
+
require('./chunk-JEQ2X3Z6.cjs');
|
|
64
66
|
|
|
65
67
|
// src/index.ts
|
|
66
68
|
var _viem = require('viem');
|
|
67
69
|
|
|
68
70
|
// src/errors.ts
|
|
71
|
+
var PafiSdkError = (_class = class extends Error {
|
|
72
|
+
/**
|
|
73
|
+
* `true` when the FE should consider a retry safe — typically because
|
|
74
|
+
* the failure is transient.
|
|
75
|
+
*/
|
|
76
|
+
__init() {this.safeToRetry = false}
|
|
77
|
+
|
|
78
|
+
constructor(message) {
|
|
79
|
+
super(message);_class.prototype.__init.call(this);;
|
|
80
|
+
this.name = new.target.name;
|
|
81
|
+
}
|
|
82
|
+
}, _class);
|
|
69
83
|
var PafiSDKError = class extends Error {
|
|
70
84
|
constructor(message) {
|
|
71
85
|
super(message);
|
|
@@ -102,6 +116,27 @@ var ApiError = class extends PafiSDKError {
|
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
};
|
|
119
|
+
var OracleStaleError = (_class2 = class extends PafiSdkError {
|
|
120
|
+
__init2() {this.httpStatus = "service_unavailable"}
|
|
121
|
+
__init3() {this.code = "ORACLE_STALE"}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
constructor(source, reason) {
|
|
125
|
+
super(`Oracle ${source} unavailable: ${reason}`);_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);;
|
|
126
|
+
this.source = source;
|
|
127
|
+
this.reason = reason;
|
|
128
|
+
}
|
|
129
|
+
}, _class2);
|
|
130
|
+
var ValidationError = (_class3 = class extends PafiSdkError {
|
|
131
|
+
__init4() {this.httpStatus = "unprocessable"}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
constructor(code, message, details) {
|
|
135
|
+
super(message);_class3.prototype.__init4.call(this);;
|
|
136
|
+
this.code = code;
|
|
137
|
+
this.details = details;
|
|
138
|
+
}
|
|
139
|
+
}, _class3);
|
|
105
140
|
|
|
106
141
|
// src/perp/buildPerpDepositWithGasDeduction.ts
|
|
107
142
|
|
|
@@ -504,7 +539,7 @@ function buildUserOpTypedData(userOp, chainId) {
|
|
|
504
539
|
name: "ERC4337",
|
|
505
540
|
version: "1",
|
|
506
541
|
chainId,
|
|
507
|
-
verifyingContract:
|
|
542
|
+
verifyingContract: _chunkM5ULOZ3Acjs.ENTRY_POINT_V08
|
|
508
543
|
},
|
|
509
544
|
types: PACKED_USER_OPERATION_TYPES,
|
|
510
545
|
primaryType: "PackedUserOperation",
|
|
@@ -594,11 +629,9 @@ function parseEip7702DelegatedAddress(code) {
|
|
|
594
629
|
if (!code || code === "0x" || code === "0x0") return null;
|
|
595
630
|
const normalized = code.toLowerCase();
|
|
596
631
|
const magic = EIP7702_MAGIC.toLowerCase();
|
|
597
|
-
|
|
598
|
-
if (
|
|
599
|
-
|
|
600
|
-
if (raw.length !== 40) return null;
|
|
601
|
-
return `0x${raw}`;
|
|
632
|
+
if (!normalized.startsWith(magic)) return null;
|
|
633
|
+
if (normalized.length !== magic.length + 40) return null;
|
|
634
|
+
return `0x${normalized.slice(magic.length)}`;
|
|
602
635
|
}
|
|
603
636
|
async function checkDelegation(client, address) {
|
|
604
637
|
const code = await client.getCode({ address });
|
|
@@ -647,7 +680,7 @@ async function getAaNonce(client, userAddress) {
|
|
|
647
680
|
}
|
|
648
681
|
];
|
|
649
682
|
return client.readContract({
|
|
650
|
-
address:
|
|
683
|
+
address: _chunkM5ULOZ3Acjs.ENTRY_POINT_V08,
|
|
651
684
|
abi: NONCE_ABI,
|
|
652
685
|
functionName: "getNonce",
|
|
653
686
|
args: [userAddress, 0n]
|
|
@@ -727,9 +760,24 @@ function createPafiProxyTransport(params) {
|
|
|
727
760
|
}
|
|
728
761
|
|
|
729
762
|
// src/transport/paymasterFallback.ts
|
|
763
|
+
var PAYMASTER_HTTP_STATUSES = /* @__PURE__ */ new Set([401, 403, 429, 503]);
|
|
764
|
+
var PAYMASTER_PATTERNS = [
|
|
765
|
+
/\bAA3[1-4]\b/i,
|
|
766
|
+
/\bpaymaster\b/i,
|
|
767
|
+
/\bsponsorship\b/i,
|
|
768
|
+
/\bpm_\w+/i,
|
|
769
|
+
/\brate ?limit\b/i,
|
|
770
|
+
/\bunauthorized\b/i
|
|
771
|
+
];
|
|
730
772
|
function isPaymasterError(err) {
|
|
731
|
-
|
|
732
|
-
|
|
773
|
+
if (err == null || typeof err !== "object") return false;
|
|
774
|
+
const e = err;
|
|
775
|
+
const status = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(e.status, () => ( e.statusCode)), () => ( _optionalChain([e, 'access', _30 => _30.response, 'optionalAccess', _31 => _31.status]))), () => ( _optionalChain([e, 'access', _32 => _32.cause, 'optionalAccess', _33 => _33.status])));
|
|
776
|
+
if (typeof status === "number" && PAYMASTER_HTTP_STATUSES.has(status)) {
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
const msg = _nullishCoalesce(e.message, () => ( String(err)));
|
|
780
|
+
return PAYMASTER_PATTERNS.some((re) => re.test(msg));
|
|
733
781
|
}
|
|
734
782
|
async function sendWithPaymasterFallback(params) {
|
|
735
783
|
const { primaryClient, fallbackClient, txParams, txParamsFallback, onFallback } = params;
|
|
@@ -737,8 +785,8 @@ async function sendWithPaymasterFallback(params) {
|
|
|
737
785
|
return await primaryClient.sendTransaction(txParams);
|
|
738
786
|
} catch (err) {
|
|
739
787
|
if (isPaymasterError(err) && fallbackClient) {
|
|
740
|
-
const msg = _nullishCoalesce(_optionalChain([err, 'optionalAccess',
|
|
741
|
-
_optionalChain([onFallback, 'optionalCall',
|
|
788
|
+
const msg = _nullishCoalesce(_optionalChain([err, 'optionalAccess', _34 => _34.message]), () => ( String(err)));
|
|
789
|
+
_optionalChain([onFallback, 'optionalCall', _35 => _35(msg)]);
|
|
742
790
|
return await fallbackClient.sendTransaction(_nullishCoalesce(txParamsFallback, () => ( txParams)));
|
|
743
791
|
}
|
|
744
792
|
throw err;
|
|
@@ -796,7 +844,7 @@ async function fetchPafiPools(_chainId, pointTokenAddress, subgraphUrl = PAFI_SU
|
|
|
796
844
|
);
|
|
797
845
|
return [];
|
|
798
846
|
}
|
|
799
|
-
const pool = _optionalChain([json, 'access',
|
|
847
|
+
const pool = _optionalChain([json, 'access', _36 => _36.data, 'optionalAccess', _37 => _37.pafiToken, 'optionalAccess', _38 => _38.pool]);
|
|
800
848
|
if (!pool) return [];
|
|
801
849
|
if (!_viem.isAddress.call(void 0, pool.hooks) || !_viem.isAddress.call(void 0, pool.token0.id) || !_viem.isAddress.call(void 0, pool.token1.id) || !Number.isFinite(Number(pool.feeTier)) || !Number.isFinite(Number(pool.tickSpacing))) {
|
|
802
850
|
console.error("[fetchPafiPools] invalid pool data in subgraph response \u2014 skipping");
|
|
@@ -889,6 +937,13 @@ var POOL_PRICE_QUERY = `
|
|
|
889
937
|
}
|
|
890
938
|
}
|
|
891
939
|
`;
|
|
940
|
+
var SCENARIO_GAS_UNITS = {
|
|
941
|
+
mint: 500000n,
|
|
942
|
+
burn: 500000n,
|
|
943
|
+
swap: 700000n,
|
|
944
|
+
"perp-deposit": 800000n,
|
|
945
|
+
delegate: 200000n
|
|
946
|
+
};
|
|
892
947
|
var DEFAULT_GAS_UNITS = 500000n;
|
|
893
948
|
var DEFAULT_PREMIUM_BPS = 12e3;
|
|
894
949
|
var DEFAULT_USDT_DECIMALS = 6;
|
|
@@ -896,9 +951,11 @@ async function quoteOperatorFeeUsdt(config) {
|
|
|
896
951
|
const {
|
|
897
952
|
provider,
|
|
898
953
|
chainId,
|
|
899
|
-
|
|
954
|
+
scenario = "mint",
|
|
955
|
+
gasUnits = _nullishCoalesce(SCENARIO_GAS_UNITS[scenario], () => ( DEFAULT_GAS_UNITS)),
|
|
900
956
|
premiumBps = DEFAULT_PREMIUM_BPS,
|
|
901
957
|
usdtDecimals = DEFAULT_USDT_DECIMALS,
|
|
958
|
+
allowStaleFallback = false,
|
|
902
959
|
fallbackEthPriceUsd = 3e3
|
|
903
960
|
} = config;
|
|
904
961
|
const chainlinkFeedAddress = _nullishCoalesce(config.chainlinkFeedAddress, () => ( getContractAddresses(chainId).chainlinkEthUsd));
|
|
@@ -908,7 +965,7 @@ async function quoteOperatorFeeUsdt(config) {
|
|
|
908
965
|
const ethPrice8dec = await getEthPrice8dec(
|
|
909
966
|
provider,
|
|
910
967
|
chainlinkFeedAddress,
|
|
911
|
-
fallbackEthPriceUsd
|
|
968
|
+
allowStaleFallback ? fallbackEthPriceUsd : null
|
|
912
969
|
);
|
|
913
970
|
const denomExp = 18 + 8 - usdtDecimals;
|
|
914
971
|
return withPremium * ethPrice8dec / 10n ** BigInt(denomExp);
|
|
@@ -918,10 +975,12 @@ async function quoteOperatorFeePt(config) {
|
|
|
918
975
|
provider,
|
|
919
976
|
chainId,
|
|
920
977
|
pointTokenAddress,
|
|
921
|
-
|
|
978
|
+
scenario = "mint",
|
|
979
|
+
gasUnits = _nullishCoalesce(SCENARIO_GAS_UNITS[scenario], () => ( DEFAULT_GAS_UNITS)),
|
|
922
980
|
premiumBps = DEFAULT_PREMIUM_BPS,
|
|
923
981
|
subgraphUrl = PAFI_SUBGRAPH_URL,
|
|
924
982
|
usdtDecimals = DEFAULT_USDT_DECIMALS,
|
|
983
|
+
allowStaleFallback = false,
|
|
925
984
|
fallbackEthPriceUsd = 3e3,
|
|
926
985
|
fallbackPtPriceUsdt = 0.1,
|
|
927
986
|
fetchImpl = globalThis.fetch
|
|
@@ -931,12 +990,16 @@ async function quoteOperatorFeePt(config) {
|
|
|
931
990
|
const nativeCost = gasPrice * gasUnits;
|
|
932
991
|
const withPremium = nativeCost * BigInt(premiumBps) / 10000n;
|
|
933
992
|
const [ethPrice8dec, ptPerUsdt18dec] = await Promise.all([
|
|
934
|
-
getEthPrice8dec(
|
|
993
|
+
getEthPrice8dec(
|
|
994
|
+
provider,
|
|
995
|
+
chainlinkFeedAddress,
|
|
996
|
+
allowStaleFallback ? fallbackEthPriceUsd : null
|
|
997
|
+
),
|
|
935
998
|
getPtPerUsdt18dec(
|
|
936
999
|
fetchImpl,
|
|
937
1000
|
subgraphUrl,
|
|
938
1001
|
pointTokenAddress,
|
|
939
|
-
fallbackPtPriceUsdt
|
|
1002
|
+
allowStaleFallback ? fallbackPtPriceUsdt : null
|
|
940
1003
|
)
|
|
941
1004
|
]);
|
|
942
1005
|
return withPremium * ethPrice8dec * ptPerUsdt18dec / 10n ** 26n;
|
|
@@ -957,9 +1020,13 @@ async function getEthPrice8dec(provider, feed, fallback) {
|
|
|
957
1020
|
}
|
|
958
1021
|
return answer;
|
|
959
1022
|
} catch (err) {
|
|
1023
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1024
|
+
if (fallback === null) {
|
|
1025
|
+
throw new OracleStaleError("chainlink", reason);
|
|
1026
|
+
}
|
|
960
1027
|
console.warn(
|
|
961
|
-
"[
|
|
962
|
-
|
|
1028
|
+
"[quoteOperatorFee] Chainlink unavailable, using opt-in fallback:",
|
|
1029
|
+
reason
|
|
963
1030
|
);
|
|
964
1031
|
return BigInt(Math.round(fallback * 1e8));
|
|
965
1032
|
}
|
|
@@ -976,10 +1043,10 @@ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fall
|
|
|
976
1043
|
});
|
|
977
1044
|
if (!response.ok) throw new Error(`subgraph HTTP ${response.status}`);
|
|
978
1045
|
const json = await response.json();
|
|
979
|
-
if (_optionalChain([json, 'access',
|
|
1046
|
+
if (_optionalChain([json, 'access', _39 => _39.errors, 'optionalAccess', _40 => _40.length])) {
|
|
980
1047
|
throw new Error(json.errors.map((e) => e.message).join("; "));
|
|
981
1048
|
}
|
|
982
|
-
const pool = _optionalChain([json, 'access',
|
|
1049
|
+
const pool = _optionalChain([json, 'access', _41 => _41.data, 'optionalAccess', _42 => _42.pafiToken, 'optionalAccess', _43 => _43.pool]);
|
|
983
1050
|
if (!pool) throw new Error("pafiToken or pool not found");
|
|
984
1051
|
const isPtToken0 = pool.token0.id.toLowerCase() === pointTokenAddress.toLowerCase();
|
|
985
1052
|
const priceStr = isPtToken0 ? pool.token0Price : pool.token1Price;
|
|
@@ -992,9 +1059,13 @@ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fall
|
|
|
992
1059
|
}
|
|
993
1060
|
return 10n ** 24n / raw;
|
|
994
1061
|
} catch (err) {
|
|
1062
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1063
|
+
if (fallbackPtPriceUsdt === null) {
|
|
1064
|
+
throw new OracleStaleError("subgraph", reason);
|
|
1065
|
+
}
|
|
995
1066
|
console.warn(
|
|
996
|
-
"[quoteOperatorFeePt] subgraph unavailable, using fallback:",
|
|
997
|
-
|
|
1067
|
+
"[quoteOperatorFeePt] subgraph unavailable, using opt-in fallback:",
|
|
1068
|
+
reason
|
|
998
1069
|
);
|
|
999
1070
|
const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
|
|
1000
1071
|
return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
|
|
@@ -1024,8 +1095,8 @@ function openWebPopup(url, options = {}) {
|
|
|
1024
1095
|
const width = _nullishCoalesce(options.width, () => ( DEFAULT_WIDTH));
|
|
1025
1096
|
const height = _nullishCoalesce(options.height, () => ( DEFAULT_HEIGHT));
|
|
1026
1097
|
const name = _nullishCoalesce(options.windowName, () => ( DEFAULT_NAME));
|
|
1027
|
-
const screenW = _nullishCoalesce(_optionalChain([window, 'access',
|
|
1028
|
-
const screenH = _nullishCoalesce(_optionalChain([window, 'access',
|
|
1098
|
+
const screenW = _nullishCoalesce(_optionalChain([window, 'access', _44 => _44.screen, 'optionalAccess', _45 => _45.availWidth]), () => ( window.innerWidth));
|
|
1099
|
+
const screenH = _nullishCoalesce(_optionalChain([window, 'access', _46 => _46.screen, 'optionalAccess', _47 => _47.availHeight]), () => ( window.innerHeight));
|
|
1029
1100
|
const left = Math.max(0, Math.floor((screenW - width) / 2));
|
|
1030
1101
|
const top = Math.max(0, Math.floor((screenH - height) / 2));
|
|
1031
1102
|
const features = [
|
|
@@ -1058,7 +1129,7 @@ function openWebPopup(url, options = {}) {
|
|
|
1058
1129
|
window.removeEventListener("message", messageListener);
|
|
1059
1130
|
messageListener = null;
|
|
1060
1131
|
}
|
|
1061
|
-
_optionalChain([options, 'access',
|
|
1132
|
+
_optionalChain([options, 'access', _48 => _48.onClose, 'optionalCall', _49 => _49()]);
|
|
1062
1133
|
};
|
|
1063
1134
|
pollId = setInterval(() => {
|
|
1064
1135
|
if (popup.closed) {
|
|
@@ -1228,27 +1299,27 @@ var PafiSDK = class {
|
|
|
1228
1299
|
// -------------------------------------------------------------------------
|
|
1229
1300
|
async buildMintRequestTypedData(message) {
|
|
1230
1301
|
const domain = await this.getDomain();
|
|
1231
|
-
return
|
|
1302
|
+
return _chunkM5ULOZ3Acjs.buildMintRequestTypedData.call(void 0, domain, message);
|
|
1232
1303
|
}
|
|
1233
1304
|
async buildReceiverConsentTypedData(message) {
|
|
1234
1305
|
const domain = await this.getDomain();
|
|
1235
|
-
return
|
|
1306
|
+
return _chunkM5ULOZ3Acjs.buildReceiverConsentTypedData.call(void 0, domain, message);
|
|
1236
1307
|
}
|
|
1237
1308
|
async signMintRequest(message) {
|
|
1238
1309
|
const domain = await this.getDomain();
|
|
1239
|
-
return
|
|
1310
|
+
return _chunkM5ULOZ3Acjs.signMintRequest.call(void 0, this.requireSigner(), domain, message);
|
|
1240
1311
|
}
|
|
1241
1312
|
async verifyMintRequest(message, signature, expectedMinter) {
|
|
1242
1313
|
const domain = await this.getDomain();
|
|
1243
|
-
return
|
|
1314
|
+
return _chunkM5ULOZ3Acjs.verifyMintRequest.call(void 0, domain, message, signature, expectedMinter);
|
|
1244
1315
|
}
|
|
1245
1316
|
async signReceiverConsent(message) {
|
|
1246
1317
|
const domain = await this.getDomain();
|
|
1247
|
-
return
|
|
1318
|
+
return _chunkM5ULOZ3Acjs.signReceiverConsent.call(void 0, this.requireSigner(), domain, message);
|
|
1248
1319
|
}
|
|
1249
1320
|
async verifyReceiverConsent(message, signature, expectedReceiver) {
|
|
1250
1321
|
const domain = await this.getDomain();
|
|
1251
|
-
return
|
|
1322
|
+
return _chunkM5ULOZ3Acjs.verifyReceiverConsent.call(void 0, domain, message, signature, expectedReceiver);
|
|
1252
1323
|
}
|
|
1253
1324
|
// -------------------------------------------------------------------------
|
|
1254
1325
|
// Contract reads
|
|
@@ -1277,7 +1348,7 @@ var PafiSDK = class {
|
|
|
1277
1348
|
if (!account) {
|
|
1278
1349
|
throw new ConfigurationError("signer has no account attached");
|
|
1279
1350
|
}
|
|
1280
|
-
return
|
|
1351
|
+
return _chunk5254AG3Zcjs.createLoginMessage.call(void 0, { ...params, address: account.address, chainId });
|
|
1281
1352
|
}
|
|
1282
1353
|
/** Sign a login message string with the current signer (personal_sign) */
|
|
1283
1354
|
async signLoginMessage(message) {
|
|
@@ -1409,5 +1480,9 @@ var PafiSDK = class {
|
|
|
1409
1480
|
|
|
1410
1481
|
|
|
1411
1482
|
|
|
1412
|
-
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
exports.ApiError = ApiError; exports.BATCH_EXECUTOR_7702_IMPL = BATCH_EXECUTOR_7702_IMPL; exports.BATCH_EXECUTOR_ABI = BATCH_EXECUTOR_ABI; exports.BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = BATCH_EXECUTOR_ADDRESS_BASE_MAINNET; exports.BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA; exports.BROKER_HASHES = BROKER_HASHES; exports.COMMON_POOLS = _chunkM5ULOZ3Acjs.COMMON_POOLS; exports.COMMON_TOKENS = _chunkM5ULOZ3Acjs.COMMON_TOKENS; exports.CONTRACT_ADDRESSES = CONTRACT_ADDRESSES; exports.ConfigurationError = ConfigurationError; exports.DUMMY_SIGNATURE_V07 = DUMMY_SIGNATURE_V07; exports.ENTRY_POINT_V07 = _chunkM5ULOZ3Acjs.ENTRY_POINT_V07; exports.ENTRY_POINT_V08 = _chunkM5ULOZ3Acjs.ENTRY_POINT_V08; exports.ORDERLY_RELAY_ABI = ORDERLY_RELAY_ABI; exports.ORDERLY_VAULT_ABI = ORDERLY_VAULT_ABI; exports.ORDERLY_VAULT_ADDRESSES = ORDERLY_VAULT_ADDRESSES; exports.ORDERLY_VAULT_BASE_MAINNET = ORDERLY_VAULT_BASE_MAINNET; exports.OracleStaleError = OracleStaleError; exports.PAFI_SUBGRAPH_URL = PAFI_SUBGRAPH_URL; exports.PERMIT2_ADDRESS = _chunkM5ULOZ3Acjs.PERMIT2_ADDRESS; exports.POINT_TOKEN_FACTORY_ADDRESSES = POINT_TOKEN_FACTORY_ADDRESSES; exports.POINT_TOKEN_IMPL_ADDRESSES = POINT_TOKEN_IMPL_ADDRESSES; exports.POINT_TOKEN_POOLS = _chunkM5ULOZ3Acjs.POINT_TOKEN_POOLS; exports.POINT_TOKEN_V2_ABI = _chunkLRHY7GORcjs.pointTokenAbi; exports.PafiSDK = PafiSDK; exports.PafiSDKError = PafiSDKError; exports.PafiSdkError = PafiSdkError; exports.SIMPLE_7702_IMPL_BASE_MAINNET = SIMPLE_7702_IMPL_BASE_MAINNET; exports.SPONSOR_AUTH_DOMAIN_NAME = _chunk5254AG3Zcjs.SPONSOR_AUTH_DOMAIN_NAME; exports.SPONSOR_AUTH_TYPES = _chunk5254AG3Zcjs.SPONSOR_AUTH_TYPES; exports.SUPPORTED_CHAINS = _chunkM5ULOZ3Acjs.SUPPORTED_CHAINS; exports.SigningError = SigningError; exports.SimulationError = SimulationError; exports.TOKEN_HASHES = TOKEN_HASHES; exports.UNIVERSAL_ROUTER_ADDRESSES = _chunkM5ULOZ3Acjs.UNIVERSAL_ROUTER_ADDRESSES; exports.V4_QUOTER_ADDRESSES = _chunkM5ULOZ3Acjs.V4_QUOTER_ADDRESSES; exports.ValidationError = ValidationError; exports.ZERO_VALUE = ZERO_VALUE; exports._resetPaymasterConfigForTests = _resetPaymasterConfigForTests; exports.assembleUserOperation = assembleUserOperation; exports.buildAndSignSponsorAuth = _chunk5254AG3Zcjs.buildAndSignSponsorAuth; exports.buildBurnRequestTypedData = _chunkM5ULOZ3Acjs.buildBurnRequestTypedData; exports.buildDelegationUserOp = buildDelegationUserOp; exports.buildDomain = _chunkM5ULOZ3Acjs.buildDomain; exports.buildEip7702Authorization = buildEip7702Authorization; exports.buildMintRequestTypedData = _chunkM5ULOZ3Acjs.buildMintRequestTypedData; exports.buildPartialUserOperation = buildPartialUserOperation; exports.buildPerpDepositViaRelay = buildPerpDepositViaRelay; exports.buildPerpDepositWithGasDeduction = buildPerpDepositWithGasDeduction; exports.buildReceiverConsentTypedData = _chunkM5ULOZ3Acjs.buildReceiverConsentTypedData; exports.buildSponsorAuthDomain = _chunk5254AG3Zcjs.buildSponsorAuthDomain; exports.buildSponsorAuthTypedData = _chunk5254AG3Zcjs.buildSponsorAuthTypedData; exports.buildUserOpTypedData = buildUserOpTypedData; exports.burnRequestTypes = _chunkM5ULOZ3Acjs.burnRequestTypes; exports.checkDelegation = checkDelegation; exports.checkEthAndBranch = checkEthAndBranch; exports.computeAccountId = computeAccountId; exports.computeAuthorizationHash = computeAuthorizationHash; exports.computeCallDataHash = _chunk5254AG3Zcjs.computeCallDataHash; exports.computeUserOpHash = computeUserOpHash; exports.createLoginMessage = _chunk5254AG3Zcjs.createLoginMessage; exports.createPafiProxyTransport = createPafiProxyTransport; exports.decodeBatchExecuteCalls = decodeBatchExecuteCalls; exports.detectDelegateImpl = detectDelegateImpl; exports.encodeBatchExecute = encodeBatchExecute; exports.erc20Abi = _chunkQ6WCDZXIcjs.erc20Abi; exports.erc20ApproveOp = erc20ApproveOp; exports.erc20BurnOp = erc20BurnOp; exports.erc20TransferOp = erc20TransferOp; exports.fetchPafiPools = fetchPafiPools; exports.generateSponsorAuthNonce = _chunk5254AG3Zcjs.generateSponsorAuthNonce; exports.getAaNonce = getAaNonce; exports.getBurnRequestNonce = _chunkCLPRSQT2cjs.getBurnRequestNonce; exports.getContractAddresses = getContractAddresses; exports.getDummySignatureFor7702 = getDummySignatureFor7702; exports.getIssuer = _chunkCLPRSQT2cjs.getIssuer2; exports.getMintRequestNonce = _chunkCLPRSQT2cjs.getMintRequestNonce; exports.getPafiWebModalAdapter = getPafiWebModalAdapter; exports.getPaymasterConfig = getPaymasterConfig; exports.getPointTokenBalance = _chunkCLPRSQT2cjs.getPointTokenBalance; exports.getPointTokenIssuer = _chunkCLPRSQT2cjs.getPointTokenIssuer; exports.getPointTokenIssuerAddress = _chunkCLPRSQT2cjs.getIssuer; exports.getReceiverConsentNonce = _chunkCLPRSQT2cjs.getReceiverConsentNonce; exports.getTokenName = _chunkCLPRSQT2cjs.getTokenName; exports.isActiveIssuer = _chunkCLPRSQT2cjs.isActiveIssuer; exports.isDelegatedTo = isDelegatedTo; exports.isDelegatedToTarget = isDelegatedToTarget; exports.isMinter = _chunkCLPRSQT2cjs.isMinter; exports.isPaymasterConfigured = isPaymasterConfigured; exports.isPaymasterError = isPaymasterError; exports.issuerRegistryAbi = _chunkLRHY7GORcjs.issuerRegistryAbi; exports.issuerRegistryGetIssuerFlatAbi = _chunkCLPRSQT2cjs.issuerRegistryGetIssuerFlatAbi; exports.mintRequestTypes = _chunkM5ULOZ3Acjs.mintRequestTypes; exports.mintingOracleAbi = _chunkLRHY7GORcjs.mintingOracleAbi; exports.openPafiWebModal = openPafiWebModal; exports.openWebPopup = openWebPopup; exports.parseEip7702DelegatedAddress = parseEip7702DelegatedAddress; exports.parseLoginMessage = _chunk5254AG3Zcjs.parseLoginMessage; exports.permit2Abi = _chunkQ6WCDZXIcjs.permit2Abi; exports.pointTokenAbi = _chunkLRHY7GORcjs.pointTokenAbi; exports.pointTokenFactoryAbi = _chunkQ6WCDZXIcjs.pointTokenFactoryAbi; exports.quoteOperatorFeePt = quoteOperatorFeePt; exports.quoteOperatorFeeUsdt = quoteOperatorFeeUsdt; exports.rawCallOp = rawCallOp; exports.receiverConsentTypes = _chunkM5ULOZ3Acjs.receiverConsentTypes; exports.sendWithPaymasterFallback = sendWithPaymasterFallback; exports.serializeUserOpToJsonRpc = serializeUserOpToJsonRpc; exports.setPafiWebModalAdapter = setPafiWebModalAdapter; exports.setPaymasterConfig = setPaymasterConfig; exports.signBurnRequest = _chunkM5ULOZ3Acjs.signBurnRequest; exports.signMintRequest = _chunkM5ULOZ3Acjs.signMintRequest; exports.signReceiverConsent = _chunkM5ULOZ3Acjs.signReceiverConsent; exports.signSponsorAuth = _chunk5254AG3Zcjs.signSponsorAuth; exports.splitAuthorizationSig = splitAuthorizationSig; exports.universalRouterAbi = _chunkQ6WCDZXIcjs.universalRouterAbi; exports.v4QuoterAbi = _chunkQ6WCDZXIcjs.v4QuoterAbi; exports.verifyBurnRequest = _chunkM5ULOZ3Acjs.verifyBurnRequest; exports.verifyLoginMessage = _chunk5254AG3Zcjs.verifyLoginMessage; exports.verifyMintCap = _chunkCLPRSQT2cjs.verifyMintCap; exports.verifyMintRequest = _chunkM5ULOZ3Acjs.verifyMintRequest; exports.verifyReceiverConsent = _chunkM5ULOZ3Acjs.verifyReceiverConsent; exports.verifySponsorAuth = _chunk5254AG3Zcjs.verifySponsorAuth; exports.webPopupAdapter = webPopupAdapter;
|
|
1413
1488
|
//# sourceMappingURL=index.cjs.map
|