@kayibal/fynd-client 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/dist/autogen.d.ts +17 -0
- package/dist/autogen.d.ts.map +1 -0
- package/dist/autogen.js +17 -0
- package/dist/autogen.js.map +1 -0
- package/dist/client-fee.d.ts +16 -0
- package/dist/client-fee.d.ts.map +1 -0
- package/dist/client-fee.js +50 -0
- package/dist/client-fee.js.map +1 -0
- package/dist/client.d.ts +224 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +498 -0
- package/dist/client.js.map +1 -0
- package/dist/error.d.ts +38 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +75 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping.d.ts +12 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +143 -0
- package/dist/mapping.js.map +1 -0
- package/dist/permit2.d.ts +26 -0
- package/dist/permit2.d.ts.map +1 -0
- package/dist/permit2.js +77 -0
- package/dist/permit2.js.map +1 -0
- package/dist/signing.d.ts +89 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +39 -0
- package/dist/signing.js.map +1 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/viem.d.ts +72 -0
- package/dist/viem.d.ts.map +1 -0
- package/dist/viem.js +93 -0
- package/dist/viem.js.map +1 -0
- package/package.json +28 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated TypeScript client for the fynd-rpc API.
|
|
3
|
+
* Do not make direct changes to this file.
|
|
4
|
+
* Re-generate by running: cargo run -- openapi > clients/openapi.json
|
|
5
|
+
* then: openapi-typescript clients/openapi.json -o clients/typescript/client/src/schema.d.ts
|
|
6
|
+
*/
|
|
7
|
+
import type { paths } from "./schema.js";
|
|
8
|
+
export type { components, operations, paths } from "./schema.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create a typed fynd-rpc API client.
|
|
11
|
+
*
|
|
12
|
+
* @param baseUrl - Base URL of the fynd-rpc server (e.g. "http://localhost:8080")
|
|
13
|
+
* @returns A typed fetch client bound to the fynd-rpc OpenAPI schema
|
|
14
|
+
*/
|
|
15
|
+
export declare function createFyndClient(baseUrl: string): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
16
|
+
export type FyndClient = ReturnType<typeof createFyndClient>;
|
|
17
|
+
//# sourceMappingURL=autogen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autogen.d.ts","sourceRoot":"","sources":["../src/autogen.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,gEAE/C;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/autogen.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated TypeScript client for the fynd-rpc API.
|
|
3
|
+
* Do not make direct changes to this file.
|
|
4
|
+
* Re-generate by running: cargo run -- openapi > clients/openapi.json
|
|
5
|
+
* then: openapi-typescript clients/openapi.json -o clients/typescript/client/src/schema.d.ts
|
|
6
|
+
*/
|
|
7
|
+
import createClient from "openapi-fetch";
|
|
8
|
+
/**
|
|
9
|
+
* Create a typed fynd-rpc API client.
|
|
10
|
+
*
|
|
11
|
+
* @param baseUrl - Base URL of the fynd-rpc server (e.g. "http://localhost:8080")
|
|
12
|
+
* @returns A typed fetch client bound to the fynd-rpc OpenAPI schema
|
|
13
|
+
*/
|
|
14
|
+
export function createFyndClient(baseUrl) {
|
|
15
|
+
return createClient({ baseUrl });
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=autogen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autogen.js","sourceRoot":"","sources":["../src/autogen.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,YAAY,CAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Address, ClientFeeParams, EncodingOptions, Hex } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Computes the EIP-712 signing hash for client fee params.
|
|
4
|
+
*
|
|
5
|
+
* Pass the returned hash to the fee receiver's signer, then set the
|
|
6
|
+
* 65-byte signature on the `ClientFeeParams` before passing to `withClientFee`.
|
|
7
|
+
*
|
|
8
|
+
* `routerAddress` is the TychoRouter contract address.
|
|
9
|
+
*/
|
|
10
|
+
export declare function clientFeeSigningHash(params: ClientFeeParams, chainId: number, routerAddress: Address): Hex;
|
|
11
|
+
/**
|
|
12
|
+
* Attach client fee configuration to encoding options.
|
|
13
|
+
* Validates that signature is present and exactly 65 bytes (130 hex chars + '0x' prefix).
|
|
14
|
+
*/
|
|
15
|
+
export declare function withClientFee(opts: EncodingOptions, params: ClientFeeParams): EncodingOptions;
|
|
16
|
+
//# sourceMappingURL=client-fee.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-fee.d.ts","sourceRoot":"","sources":["../src/client-fee.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAWjF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,OAAO,GACrB,GAAG,CAiBL;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,eAAe,GACtB,eAAe,CAUjB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { hashTypedData } from 'viem';
|
|
2
|
+
import { FyndError } from './error.js';
|
|
3
|
+
const CLIENT_FEE_TYPE = {
|
|
4
|
+
ClientFee: [
|
|
5
|
+
{ name: 'clientFeeBps', type: 'uint16' },
|
|
6
|
+
{ name: 'clientFeeReceiver', type: 'address' },
|
|
7
|
+
{ name: 'maxClientContribution', type: 'uint256' },
|
|
8
|
+
{ name: 'deadline', type: 'uint256' },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Computes the EIP-712 signing hash for client fee params.
|
|
13
|
+
*
|
|
14
|
+
* Pass the returned hash to the fee receiver's signer, then set the
|
|
15
|
+
* 65-byte signature on the `ClientFeeParams` before passing to `withClientFee`.
|
|
16
|
+
*
|
|
17
|
+
* `routerAddress` is the TychoRouter contract address.
|
|
18
|
+
*/
|
|
19
|
+
export function clientFeeSigningHash(params, chainId, routerAddress) {
|
|
20
|
+
return hashTypedData({
|
|
21
|
+
domain: {
|
|
22
|
+
name: 'TychoRouter',
|
|
23
|
+
version: '1',
|
|
24
|
+
chainId,
|
|
25
|
+
verifyingContract: routerAddress,
|
|
26
|
+
},
|
|
27
|
+
types: CLIENT_FEE_TYPE,
|
|
28
|
+
primaryType: 'ClientFee',
|
|
29
|
+
message: {
|
|
30
|
+
clientFeeBps: params.bps,
|
|
31
|
+
clientFeeReceiver: params.receiver,
|
|
32
|
+
maxClientContribution: params.maxContribution,
|
|
33
|
+
deadline: BigInt(params.deadline),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Attach client fee configuration to encoding options.
|
|
39
|
+
* Validates that signature is present and exactly 65 bytes (130 hex chars + '0x' prefix).
|
|
40
|
+
*/
|
|
41
|
+
export function withClientFee(opts, params) {
|
|
42
|
+
if (params.signature === undefined) {
|
|
43
|
+
throw FyndError.config('Client fee signature is required');
|
|
44
|
+
}
|
|
45
|
+
if (params.signature.length !== 132) {
|
|
46
|
+
throw FyndError.config(`Client fee signature must be exactly 65 bytes (132 hex chars), got ${String(params.signature.length)} chars`);
|
|
47
|
+
}
|
|
48
|
+
return { ...opts, clientFeeParams: params };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=client-fee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-fee.js","sourceRoot":"","sources":["../src/client-fee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,eAAe,GAAG;IACtB,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;QAC9C,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,EAAE;QAClD,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;KACtC;CACO,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAuB,EACvB,OAAe,EACf,aAAsB;IAEtB,OAAO,aAAa,CAAC;QACnB,MAAM,EAAE;YACN,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG;YACZ,OAAO;YACP,iBAAiB,EAAE,aAAa;SACjC;QACD,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE;YACP,YAAY,EAAE,MAAM,CAAC,GAAG;YACxB,iBAAiB,EAAE,MAAM,CAAC,QAAQ;YAClC,qBAAqB,EAAE,MAAM,CAAC,eAAe;YAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SAClC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAqB,EACrB,MAAuB;IAEvB,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,SAAS,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACpC,MAAM,SAAS,CAAC,MAAM,CACpB,sEAAsE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAC9G,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;AAC9C,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { type ApprovalPayload, type Eip1559Transaction, type ExecutionReceipt, type SettleOptions, type SignedApproval, type SignedSwap, type SwapPayload, type TxReceipt } from "./signing.js";
|
|
2
|
+
import type { Address, ApprovalParams, Hex, HealthStatus, InstanceInfo, Quote, QuoteParams } from "./types.js";
|
|
3
|
+
/** Minimal transaction receipt, compatible with viem and ethers receipts. */
|
|
4
|
+
export interface MinimalReceipt {
|
|
5
|
+
transactionHash: Hex;
|
|
6
|
+
/** 1 = success, 0 = reverted. */
|
|
7
|
+
status: number;
|
|
8
|
+
gasUsed: bigint;
|
|
9
|
+
effectiveGasPrice: bigint;
|
|
10
|
+
logs: Array<{
|
|
11
|
+
address: Address;
|
|
12
|
+
topics: readonly Hex[];
|
|
13
|
+
data: Hex;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Blockchain provider interface used by {@link FyndClient} for signing and execution.
|
|
18
|
+
*
|
|
19
|
+
* Use {@link viemProvider} to create one from a viem `PublicClient`.
|
|
20
|
+
*/
|
|
21
|
+
export interface EthProvider {
|
|
22
|
+
getTransactionCount(args: {
|
|
23
|
+
address: Address;
|
|
24
|
+
}): Promise<number>;
|
|
25
|
+
estimateFeesPerGas(): Promise<{
|
|
26
|
+
maxFeePerGas: bigint;
|
|
27
|
+
maxPriorityFeePerGas: bigint;
|
|
28
|
+
}>;
|
|
29
|
+
call(tx: Eip1559Transaction): Promise<{
|
|
30
|
+
data?: Hex;
|
|
31
|
+
}>;
|
|
32
|
+
estimateGas(tx: Eip1559Transaction): Promise<bigint>;
|
|
33
|
+
sendRawTransaction(rawTx: Hex): Promise<Hex>;
|
|
34
|
+
getTransactionReceipt(args: {
|
|
35
|
+
hash: Hex;
|
|
36
|
+
}): Promise<MinimalReceipt | null>;
|
|
37
|
+
readAllowance?(token: Address, owner: Address, spender: Address): Promise<bigint>;
|
|
38
|
+
/** Replay a mined transaction in its original block context to extract the revert reason. */
|
|
39
|
+
debugTraceTransaction?(hash: Hex): Promise<{
|
|
40
|
+
output: Hex;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/** Configuration for exponential backoff retry on transient quote errors. */
|
|
44
|
+
export interface RetryConfig {
|
|
45
|
+
/** Maximum number of attempts (default: 3). */
|
|
46
|
+
maxAttempts?: number;
|
|
47
|
+
/** Initial backoff delay in milliseconds (default: 100). */
|
|
48
|
+
initialBackoffMs?: number;
|
|
49
|
+
/** Maximum backoff delay in milliseconds (default: 2000). */
|
|
50
|
+
maxBackoffMs?: number;
|
|
51
|
+
}
|
|
52
|
+
/** Overrides for transaction parameters when building a swap or approval payload. */
|
|
53
|
+
export interface SigningHints {
|
|
54
|
+
/** Override the sender address (defaults to {@link FyndClientOptions.sender}). */
|
|
55
|
+
sender?: Address;
|
|
56
|
+
/** Override the nonce (defaults to on-chain pending nonce). */
|
|
57
|
+
nonce?: number;
|
|
58
|
+
/** Override `maxFeePerGas` (defaults to provider estimate). */
|
|
59
|
+
maxFeePerGas?: bigint;
|
|
60
|
+
/** Override `maxPriorityFeePerGas` (defaults to provider estimate). */
|
|
61
|
+
maxPriorityFeePerGas?: bigint;
|
|
62
|
+
/** Override gas limit (defaults to `eth_estimateGas`). */
|
|
63
|
+
gasLimit?: bigint;
|
|
64
|
+
/** When `true`, simulate the transaction via `eth_call` before returning. */
|
|
65
|
+
simulate?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Options for {@link FyndClient.executeSwap}. */
|
|
68
|
+
export interface ExecutionOptions {
|
|
69
|
+
/** When `true`, simulate execution without broadcasting a transaction. */
|
|
70
|
+
dryRun?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Configuration for constructing a {@link FyndClient}. */
|
|
73
|
+
export interface FyndClientOptions {
|
|
74
|
+
/** Base URL of the Fynd API (e.g. `"https://api.fynd.exchange"`). */
|
|
75
|
+
baseUrl: string;
|
|
76
|
+
/** EVM chain ID for transaction signing. */
|
|
77
|
+
chainId: number;
|
|
78
|
+
/** Default sender address, used when {@link SigningHints.sender} is not set. */
|
|
79
|
+
sender?: Address;
|
|
80
|
+
/** HTTP request timeout in milliseconds (default: 30000). */
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
retry?: RetryConfig;
|
|
83
|
+
/** Provider for reading chain state and simulating transactions. */
|
|
84
|
+
provider?: EthProvider;
|
|
85
|
+
/** Separate provider for broadcasting transactions; falls back to `provider`. */
|
|
86
|
+
submitProvider?: EthProvider;
|
|
87
|
+
/**
|
|
88
|
+
* When `true` (default), fetch the revert reason when a transaction reverts.
|
|
89
|
+
* Tries `debug_traceTransaction` first; falls back to `eth_call` with a warning.
|
|
90
|
+
* Set to `false` to skip the extra RPC call and throw a generic revert error.
|
|
91
|
+
*/
|
|
92
|
+
fetchRevertReason?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Client for the Fynd swap routing API.
|
|
96
|
+
*
|
|
97
|
+
* Provides methods to request quotes, build signable payloads, and execute
|
|
98
|
+
* signed swap transactions on-chain.
|
|
99
|
+
*
|
|
100
|
+
* Requires `provider` for building signable payloads and executing transactions.
|
|
101
|
+
* Optionally accepts a separate `submitProvider` for broadcasting (falls back to `provider`).
|
|
102
|
+
*/
|
|
103
|
+
export declare class FyndClient {
|
|
104
|
+
private readonly http;
|
|
105
|
+
private readonly options;
|
|
106
|
+
private infoPromise;
|
|
107
|
+
constructor(options: FyndClientOptions);
|
|
108
|
+
/**
|
|
109
|
+
* Requests a swap quote from the solver.
|
|
110
|
+
*
|
|
111
|
+
* Retries automatically on transient server errors (`TIMEOUT`, `QUEUE_FULL`,
|
|
112
|
+
* `SERVICE_OVERLOADED`, `STALE_DATA`, `NOT_READY`) using exponential backoff
|
|
113
|
+
* with jitter. Configure retry behavior via {@link FyndClientOptions.retry}
|
|
114
|
+
* (defaults: 3 attempts, 100ms initial backoff, 2s max backoff).
|
|
115
|
+
*
|
|
116
|
+
* Each request is subject to an HTTP timeout controlled by
|
|
117
|
+
* {@link FyndClientOptions.timeoutMs} (default: 30s).
|
|
118
|
+
*
|
|
119
|
+
* @throws {FyndError} With a server error code (`NO_ROUTE_FOUND`, `INSUFFICIENT_LIQUIDITY`, etc.) on non-retryable failures.
|
|
120
|
+
* @throws {FyndError} With code `HTTP` on network-level failures.
|
|
121
|
+
*/
|
|
122
|
+
quote(params: QuoteParams): Promise<Quote>;
|
|
123
|
+
private doQuote;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the solver's health status.
|
|
126
|
+
*
|
|
127
|
+
* Unlike {@link quote}, this method does not retry on transient errors.
|
|
128
|
+
*
|
|
129
|
+
* @throws {FyndError} With a server error code if the solver reports unhealthy.
|
|
130
|
+
* @throws {FyndError} With code `HTTP` on network-level failures.
|
|
131
|
+
*/
|
|
132
|
+
health(): Promise<HealthStatus>;
|
|
133
|
+
/**
|
|
134
|
+
* Fetches and caches static instance metadata from `GET /v1/info`.
|
|
135
|
+
*
|
|
136
|
+
* The result is cached for the lifetime of the client. On failure, the cache
|
|
137
|
+
* is cleared so the next call retries.
|
|
138
|
+
*
|
|
139
|
+
* @throws {FyndError} With a server error code on non-OK responses.
|
|
140
|
+
* @throws {FyndError} With code `HTTP` on network-level failures.
|
|
141
|
+
*/
|
|
142
|
+
info(): Promise<InstanceInfo>;
|
|
143
|
+
private fetchInfo;
|
|
144
|
+
/**
|
|
145
|
+
* Builds an unsigned EIP-1559 transaction payload from a quote, ready for wallet signing.
|
|
146
|
+
*
|
|
147
|
+
* Fetches the sender's nonce, current gas fees, and gas estimate from the provider
|
|
148
|
+
* unless overridden via {@link SigningHints}.
|
|
149
|
+
*
|
|
150
|
+
* The quote must include a `transaction` field (returned when `encodingOptions`
|
|
151
|
+
* is set in the quote request). The `to`, `value`, and `data` fields are read
|
|
152
|
+
* from `quote.transaction`.
|
|
153
|
+
*
|
|
154
|
+
* When `hints.simulate` is `true`, the transaction is executed via `eth_call`
|
|
155
|
+
* before returning. This catches reverts early but adds one RPC round-trip.
|
|
156
|
+
*
|
|
157
|
+
* @param quote - A quote obtained from {@link quote}. Must have `transaction` populated.
|
|
158
|
+
* @param hints - Optional overrides for nonce, gas fees, gas limit (defaults to `eth_estimateGas`), sender, and simulation.
|
|
159
|
+
* @throws {FyndError} With code `CONFIG` if `provider` or `sender` is not configured.
|
|
160
|
+
* @throws {FyndError} With code `CONFIG` if `quote.transaction` is absent (forgot `encodingOptions`).
|
|
161
|
+
* @throws {FyndError} With code `SIMULATE_FAILED` if `hints.simulate` is `true` and the `eth_call` reverts.
|
|
162
|
+
*/
|
|
163
|
+
swapPayload(quote: Quote, hints?: SigningHints): Promise<SwapPayload>;
|
|
164
|
+
private fyndSwapPayload;
|
|
165
|
+
/**
|
|
166
|
+
* Broadcasts a signed order on-chain and returns a handle to await settlement.
|
|
167
|
+
*
|
|
168
|
+
* Uses `submitProvider` if configured, otherwise falls back to `provider`.
|
|
169
|
+
* The signed transaction is serialized as an EIP-1559 envelope and sent via
|
|
170
|
+
* `eth_sendRawTransaction`.
|
|
171
|
+
*
|
|
172
|
+
* Call {@link ExecutionReceipt.settle} on the returned handle to poll for
|
|
173
|
+
* the transaction receipt. Settlement polling has a default timeout of
|
|
174
|
+
* {@link DEFAULT_SETTLE_TIMEOUT_MS} (120s), configurable via {@link SettleOptions.timeoutMs}.
|
|
175
|
+
* The settled result includes `gasCost` (gasUsed * effectiveGasPrice) and
|
|
176
|
+
* `settledAmount` (parsed from ERC-20/ERC-6909 Transfer logs to the receiver).
|
|
177
|
+
*
|
|
178
|
+
* When `dryRun` is `true`, the transaction is simulated via `eth_call` and
|
|
179
|
+
* `eth_estimateGas` without broadcasting. The returned `settle()` resolves
|
|
180
|
+
* immediately with estimated gas cost and decoded return data.
|
|
181
|
+
*
|
|
182
|
+
* @param order - A signed swap from {@link assembleSignedSwap}.
|
|
183
|
+
* @param options - Set `dryRun: true` to simulate without broadcasting.
|
|
184
|
+
* @throws {FyndError} With code `CONFIG` if no provider is configured.
|
|
185
|
+
* @throws {FyndError} With code `CONFIG` if the signature has an invalid v byte.
|
|
186
|
+
* @throws {FyndError} With code `SIMULATE_FAILED` when `dryRun` is `true` and the simulation reverts.
|
|
187
|
+
* @throws {FyndError} With code `EXECUTION_REVERTED` when the mined transaction reverts.
|
|
188
|
+
*/
|
|
189
|
+
executeSwap(order: SignedSwap, options?: ExecutionOptions): Promise<ExecutionReceipt>;
|
|
190
|
+
private serializeAndBroadcast;
|
|
191
|
+
private getRevertReason;
|
|
192
|
+
private pollForReceipt;
|
|
193
|
+
/**
|
|
194
|
+
* Builds an unsigned EIP-1559 `approve(spender, amount)` transaction for the given token,
|
|
195
|
+
* or `null` if the approval is not needed.
|
|
196
|
+
*
|
|
197
|
+
* Returns `null` immediately when `params.transferType` is `'none'`.
|
|
198
|
+
* When `params.checkAllowance` is `true`, reads the on-chain allowance first and returns
|
|
199
|
+
* `null` if it is already sufficient (skipping nonce and fee resolution).
|
|
200
|
+
*
|
|
201
|
+
* Fetches the spender address from `GET /v1/info` (cached after first call):
|
|
202
|
+
* `'transfer_from'` → router, `'transfer_from_permit2'` → Permit2.
|
|
203
|
+
* Reads nonce and gas fees from `provider` unless overridden via `hints`.
|
|
204
|
+
* Gas defaults to `hints.gasLimit ?? 65_000n`.
|
|
205
|
+
*
|
|
206
|
+
* @param params - Token, amount, transfer type, and optional allowance-check flag.
|
|
207
|
+
* @param hints - Optional overrides for sender, nonce, gas fees, and gas limit.
|
|
208
|
+
* @throws {FyndError} With code `CONFIG` if `provider` or `sender` is not configured.
|
|
209
|
+
* @throws {FyndError} With code `CONFIG` if `params.checkAllowance` is `true` and `provider.readAllowance` is absent.
|
|
210
|
+
*/
|
|
211
|
+
approval(params: ApprovalParams, hints?: SigningHints): Promise<ApprovalPayload | null>;
|
|
212
|
+
/**
|
|
213
|
+
* Broadcasts a signed ERC-20 approval and polls for inclusion.
|
|
214
|
+
*
|
|
215
|
+
* @param signedApproval - Signed approval from {@link approval} + wallet signature.
|
|
216
|
+
* @param options - Optional poll timeout (defaults to {@link DEFAULT_SETTLE_TIMEOUT_MS}).
|
|
217
|
+
* @throws {FyndError} With code `CONFIG` if no provider is configured.
|
|
218
|
+
* @throws {FyndError} With code `SETTLE_TIMEOUT` if the transaction does not confirm in time.
|
|
219
|
+
* @throws {FyndError} With code `EXECUTION_REVERTED` when the mined transaction reverts.
|
|
220
|
+
*/
|
|
221
|
+
executeApproval(signedApproval: SignedApproval, options?: SettleOptions): Promise<TxReceipt>;
|
|
222
|
+
private dryRunExecute;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAGrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAA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