@pafi-dev/core 0.1.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/README.md +1157 -0
- package/dist/abi/index.cjs +31 -0
- package/dist/abi/index.cjs.map +1 -0
- package/dist/abi/index.d.cts +2479 -0
- package/dist/abi/index.d.ts +2479 -0
- package/dist/abi/index.js +31 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/auth/index.cjs +11 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +60 -0
- package/dist/auth/index.d.ts +60 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/chunk-27V32VNM.cjs +370 -0
- package/dist/chunk-27V32VNM.cjs.map +1 -0
- package/dist/chunk-2PIXFXA2.js +135 -0
- package/dist/chunk-2PIXFXA2.js.map +1 -0
- package/dist/chunk-37BBGXTS.js +149 -0
- package/dist/chunk-37BBGXTS.js.map +1 -0
- package/dist/chunk-4QOWQQCH.cjs +99 -0
- package/dist/chunk-4QOWQQCH.cjs.map +1 -0
- package/dist/chunk-4RYBJLF3.js +370 -0
- package/dist/chunk-4RYBJLF3.js.map +1 -0
- package/dist/chunk-5QJZT7VB.cjs +46 -0
- package/dist/chunk-5QJZT7VB.cjs.map +1 -0
- package/dist/chunk-5YH4D7QF.js +467 -0
- package/dist/chunk-5YH4D7QF.js.map +1 -0
- package/dist/chunk-BNTVOKYT.cjs +101 -0
- package/dist/chunk-BNTVOKYT.cjs.map +1 -0
- package/dist/chunk-C4ZDYG4D.js +101 -0
- package/dist/chunk-C4ZDYG4D.js.map +1 -0
- package/dist/chunk-CAE2BVKI.cjs +136 -0
- package/dist/chunk-CAE2BVKI.cjs.map +1 -0
- package/dist/chunk-CL3QSI4O.cjs +65 -0
- package/dist/chunk-CL3QSI4O.cjs.map +1 -0
- package/dist/chunk-CWP4PFOP.cjs +72 -0
- package/dist/chunk-CWP4PFOP.cjs.map +1 -0
- package/dist/chunk-DSCUHT3F.js +99 -0
- package/dist/chunk-DSCUHT3F.js.map +1 -0
- package/dist/chunk-FGKLDKJK.cjs +467 -0
- package/dist/chunk-FGKLDKJK.cjs.map +1 -0
- package/dist/chunk-FIKTQR7H.js +136 -0
- package/dist/chunk-FIKTQR7H.js.map +1 -0
- package/dist/chunk-FXNG4G22.js +2041 -0
- package/dist/chunk-FXNG4G22.js.map +1 -0
- package/dist/chunk-GWLEEXM4.cjs +163 -0
- package/dist/chunk-GWLEEXM4.cjs.map +1 -0
- package/dist/chunk-IPXARZ6F.cjs +135 -0
- package/dist/chunk-IPXARZ6F.cjs.map +1 -0
- package/dist/chunk-KFWZRL7I.js +65 -0
- package/dist/chunk-KFWZRL7I.js.map +1 -0
- package/dist/chunk-KW6M5FXY.js +129 -0
- package/dist/chunk-KW6M5FXY.js.map +1 -0
- package/dist/chunk-MEREIEE4.cjs +129 -0
- package/dist/chunk-MEREIEE4.cjs.map +1 -0
- package/dist/chunk-O4SMTUOY.js +163 -0
- package/dist/chunk-O4SMTUOY.js.map +1 -0
- package/dist/chunk-O7LQKCBT.cjs +149 -0
- package/dist/chunk-O7LQKCBT.cjs.map +1 -0
- package/dist/chunk-P56TUGTS.js +46 -0
- package/dist/chunk-P56TUGTS.js.map +1 -0
- package/dist/chunk-R4L66ZR5.js +72 -0
- package/dist/chunk-R4L66ZR5.js.map +1 -0
- package/dist/chunk-S2XRFFP3.cjs +2041 -0
- package/dist/chunk-S2XRFFP3.cjs.map +1 -0
- package/dist/contract/index.cjs +27 -0
- package/dist/contract/index.cjs.map +1 -0
- package/dist/contract/index.d.cts +18 -0
- package/dist/contract/index.d.ts +18 -0
- package/dist/contract/index.js +27 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/eip712/index.cjs +20 -0
- package/dist/eip712/index.cjs.map +1 -0
- package/dist/eip712/index.d.cts +83 -0
- package/dist/eip712/index.d.ts +83 -0
- package/dist/eip712/index.js +20 -0
- package/dist/eip712/index.js.map +1 -0
- package/dist/index.cjs +412 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +239 -0
- package/dist/index.d.ts +239 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/dist/quoting/index.cjs +19 -0
- package/dist/quoting/index.cjs.map +1 -0
- package/dist/quoting/index.d.cts +59 -0
- package/dist/quoting/index.d.ts +59 -0
- package/dist/quoting/index.js +19 -0
- package/dist/quoting/index.js.map +1 -0
- package/dist/relay/index.cjs +19 -0
- package/dist/relay/index.cjs.map +1 -0
- package/dist/relay/index.d.cts +62 -0
- package/dist/relay/index.d.ts +62 -0
- package/dist/relay/index.js +19 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/swap/index.cjs +29 -0
- package/dist/swap/index.cjs.map +1 -0
- package/dist/swap/index.d.cts +79 -0
- package/dist/swap/index.d.ts +79 -0
- package/dist/swap/index.js +29 -0
- package/dist/swap/index.js.map +1 -0
- package/dist/types-CkRJzrZr.d.cts +98 -0
- package/dist/types-CkRJzrZr.d.ts +98 -0
- package/package.json +114 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Address, WalletClient, PublicClient, Hex } from 'viem';
|
|
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, c as MintParams, d as SwapParams, B as BestQuote, Q as QuoteResult, e as PathKey } from './types-CkRJzrZr.cjs';
|
|
3
|
+
export { I as Issuer } from './types-CkRJzrZr.cjs';
|
|
4
|
+
export { erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, relayAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.cjs';
|
|
5
|
+
export { buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signMintRequest, signReceiverConsent, verifyMintRequest, verifyReceiverConsent } from './eip712/index.cjs';
|
|
6
|
+
import { SimulationResult } from './relay/index.cjs';
|
|
7
|
+
export { buildRelaySwapParams, decodeExtData, decodeMintAndSwap, encodeExtData, encodeMintAndSwap, simulateMintAndSwap } from './relay/index.cjs';
|
|
8
|
+
export { getIssuer, getMintRequestNonce, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, getUsdt, isActiveIssuer, isMinter, verifyMintCap } from './contract/index.cjs';
|
|
9
|
+
export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle } from './quoting/index.cjs';
|
|
10
|
+
import { SwapSimulationResult } from './swap/index.cjs';
|
|
11
|
+
export { SETTLE_ALL, SWAP_EXACT_IN, TAKE_ALL, V4_SWAP, buildErc20ApprovalCalldata, buildPermit2ApprovalCalldata, buildSwapFromQuote, buildUniversalRouterExecuteArgs, buildV4SwapInput, checkAllowance, simulateSwap } from './swap/index.cjs';
|
|
12
|
+
import { LoginMessageParams } from './auth/index.cjs';
|
|
13
|
+
export { VerifyLoginResult, createLoginMessage, parseLoginMessage, verifyLoginMessage } from './auth/index.cjs';
|
|
14
|
+
|
|
15
|
+
declare const mintRequestTypes: {
|
|
16
|
+
readonly MintRequest: readonly [{
|
|
17
|
+
readonly name: "to";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "amount";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "nonce";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "deadline";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}];
|
|
29
|
+
};
|
|
30
|
+
declare const receiverConsentTypes: {
|
|
31
|
+
readonly ReceiverConsent: readonly [{
|
|
32
|
+
readonly name: "onBehalfOf";
|
|
33
|
+
readonly type: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "originalReceiver";
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "amount";
|
|
39
|
+
readonly type: "uint256";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "nonce";
|
|
42
|
+
readonly type: "uint256";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "deadline";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "extData";
|
|
48
|
+
readonly type: "bytes";
|
|
49
|
+
}];
|
|
50
|
+
};
|
|
51
|
+
declare const SUPPORTED_CHAINS: Record<number, ChainConfig>;
|
|
52
|
+
declare const V4_QUOTER_ADDRESSES: Record<number, Address>;
|
|
53
|
+
declare const UNIVERSAL_ROUTER_ADDRESSES: Record<number, Address>;
|
|
54
|
+
declare const COMMON_TOKENS: Record<number, Record<string, Address>>;
|
|
55
|
+
declare const COMMON_POOLS: Record<number, PoolKey[]>;
|
|
56
|
+
declare const POINT_TOKEN_POOLS: Record<number, Record<Address, PoolKey[]>>;
|
|
57
|
+
|
|
58
|
+
declare class PafiSDKError extends Error {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
declare class ConfigurationError extends PafiSDKError {
|
|
62
|
+
constructor(message: string);
|
|
63
|
+
}
|
|
64
|
+
declare class SigningError extends PafiSDKError {
|
|
65
|
+
constructor(message: string);
|
|
66
|
+
}
|
|
67
|
+
declare class SimulationError extends PafiSDKError {
|
|
68
|
+
operation: string;
|
|
69
|
+
reason: string;
|
|
70
|
+
constructor(operation: string, reason: string);
|
|
71
|
+
}
|
|
72
|
+
declare class ApiError extends PafiSDKError {
|
|
73
|
+
status?: number | undefined;
|
|
74
|
+
constructor(message: string, status?: number | undefined);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class PafiSDK {
|
|
78
|
+
private _pointTokenAddress?;
|
|
79
|
+
private _relayContractAddress?;
|
|
80
|
+
private _signer?;
|
|
81
|
+
private _provider?;
|
|
82
|
+
private _chainId?;
|
|
83
|
+
constructor(config: PafiSDKConfig);
|
|
84
|
+
setPointTokenAddress(address: Address): void;
|
|
85
|
+
setRelayContractAddress(address: Address): void;
|
|
86
|
+
setSigner(signer: WalletClient): void;
|
|
87
|
+
setProvider(provider: PublicClient): void;
|
|
88
|
+
private requirePointToken;
|
|
89
|
+
private requireProvider;
|
|
90
|
+
private requireSigner;
|
|
91
|
+
private requireChainId;
|
|
92
|
+
getDomain(): Promise<PointTokenDomainConfig>;
|
|
93
|
+
/**
|
|
94
|
+
* Build the EIP-712 typed data for a MintRequest.
|
|
95
|
+
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
96
|
+
*/
|
|
97
|
+
buildMintRequestTypedData(message: MintRequest): Promise<{
|
|
98
|
+
domain: {
|
|
99
|
+
name: string;
|
|
100
|
+
version: "1";
|
|
101
|
+
chainId: number;
|
|
102
|
+
verifyingContract: `0x${string}`;
|
|
103
|
+
};
|
|
104
|
+
types: {
|
|
105
|
+
readonly MintRequest: readonly [{
|
|
106
|
+
readonly name: "to";
|
|
107
|
+
readonly type: "address";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "amount";
|
|
110
|
+
readonly type: "uint256";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "nonce";
|
|
113
|
+
readonly type: "uint256";
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "deadline";
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
}];
|
|
118
|
+
};
|
|
119
|
+
primaryType: "MintRequest";
|
|
120
|
+
message: MintRequest;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Build the EIP-712 typed data for a ReceiverConsent.
|
|
124
|
+
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
125
|
+
*/
|
|
126
|
+
buildReceiverConsentTypedData(message: ReceiverConsent): Promise<{
|
|
127
|
+
domain: {
|
|
128
|
+
name: string;
|
|
129
|
+
version: "1";
|
|
130
|
+
chainId: number;
|
|
131
|
+
verifyingContract: `0x${string}`;
|
|
132
|
+
};
|
|
133
|
+
types: {
|
|
134
|
+
readonly ReceiverConsent: readonly [{
|
|
135
|
+
readonly name: "onBehalfOf";
|
|
136
|
+
readonly type: "address";
|
|
137
|
+
}, {
|
|
138
|
+
readonly name: "originalReceiver";
|
|
139
|
+
readonly type: "address";
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "amount";
|
|
142
|
+
readonly type: "uint256";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "nonce";
|
|
145
|
+
readonly type: "uint256";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "deadline";
|
|
148
|
+
readonly type: "uint256";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "extData";
|
|
151
|
+
readonly type: "bytes";
|
|
152
|
+
}];
|
|
153
|
+
};
|
|
154
|
+
primaryType: "ReceiverConsent";
|
|
155
|
+
message: ReceiverConsent;
|
|
156
|
+
}>;
|
|
157
|
+
signMintRequest(message: MintRequest): Promise<EIP712Signature>;
|
|
158
|
+
verifyMintRequest(message: MintRequest, signature: Hex, expectedMinter: Address): Promise<SignatureVerification>;
|
|
159
|
+
signReceiverConsent(message: ReceiverConsent): Promise<EIP712Signature>;
|
|
160
|
+
verifyReceiverConsent(message: ReceiverConsent, signature: Hex, expectedReceiver: Address): Promise<SignatureVerification>;
|
|
161
|
+
getMintRequestNonce(receiver: Address): Promise<bigint>;
|
|
162
|
+
getReceiverConsentNonce(receiver: Address): Promise<bigint>;
|
|
163
|
+
encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex;
|
|
164
|
+
decodeMintAndSwap(calldata: Hex): {
|
|
165
|
+
mint: MintParams;
|
|
166
|
+
swap: SwapParams;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Find the best swap route from `tokenIn` to `tokenOut`.
|
|
170
|
+
* Merges `pools` with COMMON_POOLS for the configured chain, builds all
|
|
171
|
+
* paths, and quotes via a single multicall RPC call.
|
|
172
|
+
*/
|
|
173
|
+
findBestQuote(tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
|
|
174
|
+
/**
|
|
175
|
+
* Build UniversalRouter execute args from a quote result.
|
|
176
|
+
* The caller provides `minAmountOut` after applying their own slippage.
|
|
177
|
+
*/
|
|
178
|
+
buildSwapFromQuote(params: {
|
|
179
|
+
quote: QuoteResult;
|
|
180
|
+
currencyIn: Address;
|
|
181
|
+
currencyOut: Address;
|
|
182
|
+
amountIn: bigint;
|
|
183
|
+
minAmountOut: bigint;
|
|
184
|
+
}): {
|
|
185
|
+
commands: Hex;
|
|
186
|
+
inputs: Hex[];
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Build Relay SwapParams + extData from a quote result.
|
|
190
|
+
* Returns ready-to-use args for `Relay.mintAndSwap`.
|
|
191
|
+
*/
|
|
192
|
+
buildRelaySwapParams(params: {
|
|
193
|
+
quote: {
|
|
194
|
+
path: PathKey[];
|
|
195
|
+
};
|
|
196
|
+
minAmountOut: bigint;
|
|
197
|
+
feeInUsdt: bigint;
|
|
198
|
+
deadline: bigint;
|
|
199
|
+
}): {
|
|
200
|
+
swapParams: SwapParams;
|
|
201
|
+
extData: Hex;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Encode extData for ReceiverConsent and MintParams.
|
|
205
|
+
* extData = abi.encode(minAmountOut, feeInUsdt)
|
|
206
|
+
*/
|
|
207
|
+
encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex;
|
|
208
|
+
/**
|
|
209
|
+
* Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,
|
|
210
|
+
* expired deadlines, insufficient mint cap, pool errors) before submitting.
|
|
211
|
+
*
|
|
212
|
+
* @param relayAddress - Relay contract address
|
|
213
|
+
* @param mint - MintParams with real signatures
|
|
214
|
+
* @param swap - SwapParams (path + deadline)
|
|
215
|
+
* @param from - Relayer address that will submit the tx
|
|
216
|
+
*/
|
|
217
|
+
simulateMintAndSwap(relayAddress: Address, mint: MintParams, swap: SwapParams, from: Address): Promise<SimulationResult>;
|
|
218
|
+
/**
|
|
219
|
+
* Simulate a UniversalRouter.execute swap call. Catches reverts (bad
|
|
220
|
+
* approvals, insufficient balance, pool errors) before submitting.
|
|
221
|
+
*
|
|
222
|
+
* @param routerAddress - UniversalRouter contract address
|
|
223
|
+
* @param commands - Packed command bytes (from buildSwapFromQuote)
|
|
224
|
+
* @param inputs - Encoded inputs (from buildSwapFromQuote)
|
|
225
|
+
* @param deadline - Unix timestamp
|
|
226
|
+
* @param from - Address that will execute the swap
|
|
227
|
+
*/
|
|
228
|
+
simulateSwap(routerAddress: Address, commands: Hex, inputs: Hex[], deadline: bigint, from: Address): Promise<SwapSimulationResult>;
|
|
229
|
+
/**
|
|
230
|
+
* Build an EIP-4361 login message for the current signer + chain. The
|
|
231
|
+
* caller supplies the issuer-specific fields (domain, nonce, uri); the SDK
|
|
232
|
+
* fills in the wallet address and chain id from its own config.
|
|
233
|
+
*/
|
|
234
|
+
createLoginMessage(params: Omit<LoginMessageParams, "address" | "chainId">): Promise<string>;
|
|
235
|
+
/** Sign a login message string with the current signer (personal_sign) */
|
|
236
|
+
signLoginMessage(message: string): Promise<Hex>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export { ApiError, BestQuote, COMMON_POOLS, COMMON_TOKENS, ChainConfig, ConfigurationError, EIP712Signature, LoginMessageParams, MintParams, MintRequest, POINT_TOKEN_POOLS, PafiSDK, PafiSDKConfig, PafiSDKError, PathKey, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, SignatureVerification, SigningError, SimulationError, SimulationResult, SwapParams, SwapSimulationResult, UNIVERSAL_ROUTER_ADDRESSES, V4_QUOTER_ADDRESSES, mintRequestTypes, receiverConsentTypes };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Address, WalletClient, PublicClient, Hex } from 'viem';
|
|
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, c as MintParams, d as SwapParams, B as BestQuote, Q as QuoteResult, e as PathKey } from './types-CkRJzrZr.js';
|
|
3
|
+
export { I as Issuer } from './types-CkRJzrZr.js';
|
|
4
|
+
export { erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, relayAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.js';
|
|
5
|
+
export { buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signMintRequest, signReceiverConsent, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
|
|
6
|
+
import { SimulationResult } from './relay/index.js';
|
|
7
|
+
export { buildRelaySwapParams, decodeExtData, decodeMintAndSwap, encodeExtData, encodeMintAndSwap, simulateMintAndSwap } from './relay/index.js';
|
|
8
|
+
export { getIssuer, getMintRequestNonce, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, getUsdt, isActiveIssuer, isMinter, verifyMintCap } from './contract/index.js';
|
|
9
|
+
export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle } from './quoting/index.js';
|
|
10
|
+
import { SwapSimulationResult } from './swap/index.js';
|
|
11
|
+
export { SETTLE_ALL, SWAP_EXACT_IN, TAKE_ALL, V4_SWAP, buildErc20ApprovalCalldata, buildPermit2ApprovalCalldata, buildSwapFromQuote, buildUniversalRouterExecuteArgs, buildV4SwapInput, checkAllowance, simulateSwap } from './swap/index.js';
|
|
12
|
+
import { LoginMessageParams } from './auth/index.js';
|
|
13
|
+
export { VerifyLoginResult, createLoginMessage, parseLoginMessage, verifyLoginMessage } from './auth/index.js';
|
|
14
|
+
|
|
15
|
+
declare const mintRequestTypes: {
|
|
16
|
+
readonly MintRequest: readonly [{
|
|
17
|
+
readonly name: "to";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "amount";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "nonce";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "deadline";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}];
|
|
29
|
+
};
|
|
30
|
+
declare const receiverConsentTypes: {
|
|
31
|
+
readonly ReceiverConsent: readonly [{
|
|
32
|
+
readonly name: "onBehalfOf";
|
|
33
|
+
readonly type: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "originalReceiver";
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "amount";
|
|
39
|
+
readonly type: "uint256";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "nonce";
|
|
42
|
+
readonly type: "uint256";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "deadline";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "extData";
|
|
48
|
+
readonly type: "bytes";
|
|
49
|
+
}];
|
|
50
|
+
};
|
|
51
|
+
declare const SUPPORTED_CHAINS: Record<number, ChainConfig>;
|
|
52
|
+
declare const V4_QUOTER_ADDRESSES: Record<number, Address>;
|
|
53
|
+
declare const UNIVERSAL_ROUTER_ADDRESSES: Record<number, Address>;
|
|
54
|
+
declare const COMMON_TOKENS: Record<number, Record<string, Address>>;
|
|
55
|
+
declare const COMMON_POOLS: Record<number, PoolKey[]>;
|
|
56
|
+
declare const POINT_TOKEN_POOLS: Record<number, Record<Address, PoolKey[]>>;
|
|
57
|
+
|
|
58
|
+
declare class PafiSDKError extends Error {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
declare class ConfigurationError extends PafiSDKError {
|
|
62
|
+
constructor(message: string);
|
|
63
|
+
}
|
|
64
|
+
declare class SigningError extends PafiSDKError {
|
|
65
|
+
constructor(message: string);
|
|
66
|
+
}
|
|
67
|
+
declare class SimulationError extends PafiSDKError {
|
|
68
|
+
operation: string;
|
|
69
|
+
reason: string;
|
|
70
|
+
constructor(operation: string, reason: string);
|
|
71
|
+
}
|
|
72
|
+
declare class ApiError extends PafiSDKError {
|
|
73
|
+
status?: number | undefined;
|
|
74
|
+
constructor(message: string, status?: number | undefined);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class PafiSDK {
|
|
78
|
+
private _pointTokenAddress?;
|
|
79
|
+
private _relayContractAddress?;
|
|
80
|
+
private _signer?;
|
|
81
|
+
private _provider?;
|
|
82
|
+
private _chainId?;
|
|
83
|
+
constructor(config: PafiSDKConfig);
|
|
84
|
+
setPointTokenAddress(address: Address): void;
|
|
85
|
+
setRelayContractAddress(address: Address): void;
|
|
86
|
+
setSigner(signer: WalletClient): void;
|
|
87
|
+
setProvider(provider: PublicClient): void;
|
|
88
|
+
private requirePointToken;
|
|
89
|
+
private requireProvider;
|
|
90
|
+
private requireSigner;
|
|
91
|
+
private requireChainId;
|
|
92
|
+
getDomain(): Promise<PointTokenDomainConfig>;
|
|
93
|
+
/**
|
|
94
|
+
* Build the EIP-712 typed data for a MintRequest.
|
|
95
|
+
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
96
|
+
*/
|
|
97
|
+
buildMintRequestTypedData(message: MintRequest): Promise<{
|
|
98
|
+
domain: {
|
|
99
|
+
name: string;
|
|
100
|
+
version: "1";
|
|
101
|
+
chainId: number;
|
|
102
|
+
verifyingContract: `0x${string}`;
|
|
103
|
+
};
|
|
104
|
+
types: {
|
|
105
|
+
readonly MintRequest: readonly [{
|
|
106
|
+
readonly name: "to";
|
|
107
|
+
readonly type: "address";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "amount";
|
|
110
|
+
readonly type: "uint256";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "nonce";
|
|
113
|
+
readonly type: "uint256";
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "deadline";
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
}];
|
|
118
|
+
};
|
|
119
|
+
primaryType: "MintRequest";
|
|
120
|
+
message: MintRequest;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Build the EIP-712 typed data for a ReceiverConsent.
|
|
124
|
+
* Pass the result to any external signer (Privy, WalletConnect, etc.).
|
|
125
|
+
*/
|
|
126
|
+
buildReceiverConsentTypedData(message: ReceiverConsent): Promise<{
|
|
127
|
+
domain: {
|
|
128
|
+
name: string;
|
|
129
|
+
version: "1";
|
|
130
|
+
chainId: number;
|
|
131
|
+
verifyingContract: `0x${string}`;
|
|
132
|
+
};
|
|
133
|
+
types: {
|
|
134
|
+
readonly ReceiverConsent: readonly [{
|
|
135
|
+
readonly name: "onBehalfOf";
|
|
136
|
+
readonly type: "address";
|
|
137
|
+
}, {
|
|
138
|
+
readonly name: "originalReceiver";
|
|
139
|
+
readonly type: "address";
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "amount";
|
|
142
|
+
readonly type: "uint256";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "nonce";
|
|
145
|
+
readonly type: "uint256";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "deadline";
|
|
148
|
+
readonly type: "uint256";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "extData";
|
|
151
|
+
readonly type: "bytes";
|
|
152
|
+
}];
|
|
153
|
+
};
|
|
154
|
+
primaryType: "ReceiverConsent";
|
|
155
|
+
message: ReceiverConsent;
|
|
156
|
+
}>;
|
|
157
|
+
signMintRequest(message: MintRequest): Promise<EIP712Signature>;
|
|
158
|
+
verifyMintRequest(message: MintRequest, signature: Hex, expectedMinter: Address): Promise<SignatureVerification>;
|
|
159
|
+
signReceiverConsent(message: ReceiverConsent): Promise<EIP712Signature>;
|
|
160
|
+
verifyReceiverConsent(message: ReceiverConsent, signature: Hex, expectedReceiver: Address): Promise<SignatureVerification>;
|
|
161
|
+
getMintRequestNonce(receiver: Address): Promise<bigint>;
|
|
162
|
+
getReceiverConsentNonce(receiver: Address): Promise<bigint>;
|
|
163
|
+
encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex;
|
|
164
|
+
decodeMintAndSwap(calldata: Hex): {
|
|
165
|
+
mint: MintParams;
|
|
166
|
+
swap: SwapParams;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Find the best swap route from `tokenIn` to `tokenOut`.
|
|
170
|
+
* Merges `pools` with COMMON_POOLS for the configured chain, builds all
|
|
171
|
+
* paths, and quotes via a single multicall RPC call.
|
|
172
|
+
*/
|
|
173
|
+
findBestQuote(tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
|
|
174
|
+
/**
|
|
175
|
+
* Build UniversalRouter execute args from a quote result.
|
|
176
|
+
* The caller provides `minAmountOut` after applying their own slippage.
|
|
177
|
+
*/
|
|
178
|
+
buildSwapFromQuote(params: {
|
|
179
|
+
quote: QuoteResult;
|
|
180
|
+
currencyIn: Address;
|
|
181
|
+
currencyOut: Address;
|
|
182
|
+
amountIn: bigint;
|
|
183
|
+
minAmountOut: bigint;
|
|
184
|
+
}): {
|
|
185
|
+
commands: Hex;
|
|
186
|
+
inputs: Hex[];
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Build Relay SwapParams + extData from a quote result.
|
|
190
|
+
* Returns ready-to-use args for `Relay.mintAndSwap`.
|
|
191
|
+
*/
|
|
192
|
+
buildRelaySwapParams(params: {
|
|
193
|
+
quote: {
|
|
194
|
+
path: PathKey[];
|
|
195
|
+
};
|
|
196
|
+
minAmountOut: bigint;
|
|
197
|
+
feeInUsdt: bigint;
|
|
198
|
+
deadline: bigint;
|
|
199
|
+
}): {
|
|
200
|
+
swapParams: SwapParams;
|
|
201
|
+
extData: Hex;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Encode extData for ReceiverConsent and MintParams.
|
|
205
|
+
* extData = abi.encode(minAmountOut, feeInUsdt)
|
|
206
|
+
*/
|
|
207
|
+
encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex;
|
|
208
|
+
/**
|
|
209
|
+
* Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,
|
|
210
|
+
* expired deadlines, insufficient mint cap, pool errors) before submitting.
|
|
211
|
+
*
|
|
212
|
+
* @param relayAddress - Relay contract address
|
|
213
|
+
* @param mint - MintParams with real signatures
|
|
214
|
+
* @param swap - SwapParams (path + deadline)
|
|
215
|
+
* @param from - Relayer address that will submit the tx
|
|
216
|
+
*/
|
|
217
|
+
simulateMintAndSwap(relayAddress: Address, mint: MintParams, swap: SwapParams, from: Address): Promise<SimulationResult>;
|
|
218
|
+
/**
|
|
219
|
+
* Simulate a UniversalRouter.execute swap call. Catches reverts (bad
|
|
220
|
+
* approvals, insufficient balance, pool errors) before submitting.
|
|
221
|
+
*
|
|
222
|
+
* @param routerAddress - UniversalRouter contract address
|
|
223
|
+
* @param commands - Packed command bytes (from buildSwapFromQuote)
|
|
224
|
+
* @param inputs - Encoded inputs (from buildSwapFromQuote)
|
|
225
|
+
* @param deadline - Unix timestamp
|
|
226
|
+
* @param from - Address that will execute the swap
|
|
227
|
+
*/
|
|
228
|
+
simulateSwap(routerAddress: Address, commands: Hex, inputs: Hex[], deadline: bigint, from: Address): Promise<SwapSimulationResult>;
|
|
229
|
+
/**
|
|
230
|
+
* Build an EIP-4361 login message for the current signer + chain. The
|
|
231
|
+
* caller supplies the issuer-specific fields (domain, nonce, uri); the SDK
|
|
232
|
+
* fills in the wallet address and chain id from its own config.
|
|
233
|
+
*/
|
|
234
|
+
createLoginMessage(params: Omit<LoginMessageParams, "address" | "chainId">): Promise<string>;
|
|
235
|
+
/** Sign a login message string with the current signer (personal_sign) */
|
|
236
|
+
signLoginMessage(message: string): Promise<Hex>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export { ApiError, BestQuote, COMMON_POOLS, COMMON_TOKENS, ChainConfig, ConfigurationError, EIP712Signature, LoginMessageParams, MintParams, MintRequest, POINT_TOKEN_POOLS, PafiSDK, PafiSDKConfig, PafiSDKError, PathKey, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, SignatureVerification, SigningError, SimulationError, SimulationResult, SwapParams, SwapSimulationResult, UNIVERSAL_ROUTER_ADDRESSES, V4_QUOTER_ADDRESSES, mintRequestTypes, receiverConsentTypes };
|