@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.
@@ -0,0 +1,12 @@
1
+ export type { Address, ApprovalParams, BackendKind, BlockInfo, ClientFeeParams, EncodingOptions, Hex, HealthStatus, InstanceInfo, Order, OrderSide, PermitDetails, PermitSingle, Quote, QuoteOptions, QuoteParams, Route, SolutionStatus, Swap, Transaction, UserTransferType, } from "./types.js";
2
+ export { FyndError } from "./error.js";
3
+ export type { ClientErrorCode, ErrorCode, ServerErrorCode } from "./error.js";
4
+ export type { ApprovalPayload, Eip1559Transaction, ExecutionReceipt, FyndPayload, PrimitiveSignature, SettledOrder, SettleOptions, SignedApproval, SignedSwap, SwapPayload, TxReceipt, } from "./signing.js";
5
+ export { approvalSigningHash, assembleSignedSwap, DEFAULT_SETTLE_TIMEOUT_MS, swapSigningHash } from "./signing.js";
6
+ export { permit2SigningHash, encodingOptions, withPermit2, withVaultFunds, } from "./permit2.js";
7
+ export { clientFeeSigningHash, withClientFee, } from "./client-fee.js";
8
+ export { FyndClient } from "./client.js";
9
+ export type { EthProvider, ExecutionOptions, FyndClientOptions, MinimalReceipt, RetryConfig, SigningHints, } from "./client.js";
10
+ export { viemProvider } from "./viem.js";
11
+ export type { ViemPublicClient } from "./viem.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,eAAe,EACf,GAAG,EACH,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,WAAW,EACX,KAAK,EACL,cAAc,EACd,IAAI,EACJ,WAAW,EACX,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9E,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { FyndError } from "./error.js";
2
+ export { approvalSigningHash, assembleSignedSwap, DEFAULT_SETTLE_TIMEOUT_MS, swapSigningHash } from "./signing.js";
3
+ export { permit2SigningHash, encodingOptions, withPermit2, withVaultFunds, } from "./permit2.js";
4
+ export { clientFeeSigningHash, withClientFee, } from "./client-fee.js";
5
+ export { FyndClient } from "./client.js";
6
+ export { viemProvider } from "./viem.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAevC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { components } from "./autogen.js";
2
+ import type { Address, HealthStatus, InstanceInfo, Quote, QuoteParams } from "./types.js";
3
+ type WireSolution = components["schemas"]["Quote"];
4
+ type WireSolutionRequest = components["schemas"]["QuoteRequest"];
5
+ type WireHealthStatus = components["schemas"]["HealthStatus"];
6
+ type WireInstanceInfo = components["schemas"]["InstanceInfo"];
7
+ export declare function toWireRequest(params: QuoteParams): WireSolutionRequest;
8
+ export declare function fromWireQuote(wire: WireSolution, tokenOut: Address, receiver: Address): Quote;
9
+ export declare function fromWireHealth(wire: WireHealthStatus): HealthStatus;
10
+ export declare function fromWireInstanceInfo(wire: WireInstanceInfo): InstanceInfo;
11
+ export {};
12
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EACR,OAAO,EAIP,YAAY,EAEZ,YAAY,EAGZ,KAAK,EACL,WAAW,EAId,MAAM,YAAY,CAAC;AAGpB,KAAK,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AACnD,KAAK,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AAEjE,KAAK,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AAC9D,KAAK,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AAW9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,mBAAmB,CA8BtE;AAED,wBAAgB,aAAa,CACzB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,GAClB,KAAK,CA4BP;AA4ED,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAOnE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAMzE"}
@@ -0,0 +1,143 @@
1
+ import { FyndError } from "./error.js";
2
+ export function toWireRequest(params) {
3
+ const wireOrder = {
4
+ token_in: params.order.tokenIn,
5
+ token_out: params.order.tokenOut,
6
+ amount: params.order.amount.toString(),
7
+ side: 'sell',
8
+ sender: params.order.sender,
9
+ // exactOptionalPropertyTypes: must omit undefined keys entirely
10
+ ...(params.order.receiver !== undefined ? { receiver: params.order.receiver } : {}),
11
+ };
12
+ const wireOptions = params.options !== undefined
13
+ ? {
14
+ ...(params.options.timeoutMs !== undefined
15
+ ? { timeout_ms: params.options.timeoutMs }
16
+ : {}),
17
+ ...(params.options.minResponses !== undefined
18
+ ? { min_responses: params.options.minResponses }
19
+ : {}),
20
+ ...(params.options.maxGas !== undefined
21
+ ? { max_gas: params.options.maxGas.toString() }
22
+ : {}),
23
+ ...(params.options.encodingOptions !== undefined
24
+ ? { encoding_options: toWireEncodingOptions(params.options.encodingOptions) }
25
+ : {}),
26
+ }
27
+ : undefined;
28
+ return {
29
+ orders: [wireOrder],
30
+ ...(wireOptions !== undefined ? { options: wireOptions } : {}),
31
+ };
32
+ }
33
+ export function fromWireQuote(wire, tokenOut, receiver) {
34
+ const orderSolution = wire.orders[0];
35
+ if (orderSolution === undefined) {
36
+ throw FyndError.config("server returned empty orders array");
37
+ }
38
+ const route = orderSolution.route !== null && orderSolution.route !== undefined
39
+ ? fromWireRoute(orderSolution.route)
40
+ : undefined;
41
+ const transaction = orderSolution.transaction !== null
42
+ && orderSolution.transaction !== undefined
43
+ ? fromWireTransaction(orderSolution.transaction)
44
+ : undefined;
45
+ const priceImpactBps = orderSolution.price_impact_bps ?? undefined;
46
+ return {
47
+ orderId: orderSolution.order_id,
48
+ status: orderSolution.status,
49
+ backend: 'fynd', // WireOrderQuote has no backend field; hardcoded per design
50
+ amountIn: BigInt(orderSolution.amount_in),
51
+ amountOut: BigInt(orderSolution.amount_out),
52
+ gasEstimate: BigInt(orderSolution.gas_estimate),
53
+ block: fromWireBlockInfo(orderSolution.block),
54
+ tokenOut,
55
+ receiver,
56
+ // exactOptionalPropertyTypes: spread optional fields only when defined
57
+ ...(route !== undefined ? { route } : {}),
58
+ ...(transaction !== undefined ? { transaction } : {}),
59
+ ...(priceImpactBps !== undefined ? { priceImpactBps } : {}),
60
+ };
61
+ }
62
+ function fromWireRoute(wire) {
63
+ return { swaps: wire.swaps.map(fromWireSwap) };
64
+ }
65
+ function fromWireSwap(wire) {
66
+ return {
67
+ poolId: wire.component_id,
68
+ protocol: wire.protocol,
69
+ tokenIn: wire.token_in,
70
+ tokenOut: wire.token_out,
71
+ amountIn: BigInt(wire.amount_in),
72
+ amountOut: BigInt(wire.amount_out),
73
+ gasEstimate: BigInt(wire.gas_estimate),
74
+ };
75
+ }
76
+ function fromWireBlockInfo(wire) {
77
+ return {
78
+ number: wire.number,
79
+ hash: wire.hash,
80
+ timestamp: wire.timestamp,
81
+ };
82
+ }
83
+ function toWireEncodingOptions(opts) {
84
+ return {
85
+ // Server deserializes slippage as a string despite OpenAPI declaring number.
86
+ slippage: opts.slippage.toString(),
87
+ ...(opts.transferType !== undefined && opts.transferType !== 'none' ? { transfer_type: opts.transferType } : {}),
88
+ ...(opts.permit !== undefined ? { permit: toWirePermitSingle(opts.permit) } : {}),
89
+ ...(opts.permit2Signature !== undefined
90
+ ? { permit2_signature: opts.permit2Signature }
91
+ : {}),
92
+ ...(opts.clientFeeParams !== undefined
93
+ ? { client_fee_params: toWireClientFeeParams(opts.clientFeeParams) }
94
+ : {}),
95
+ };
96
+ }
97
+ function toWireClientFeeParams(p) {
98
+ return {
99
+ bps: p.bps,
100
+ receiver: p.receiver,
101
+ max_contribution: p.maxContribution.toString(),
102
+ deadline: p.deadline,
103
+ signature: p.signature ?? '',
104
+ };
105
+ }
106
+ function toWirePermitSingle(permit) {
107
+ return {
108
+ details: toWirePermitDetails(permit.details),
109
+ spender: permit.spender,
110
+ sig_deadline: permit.sigDeadline.toString(),
111
+ };
112
+ }
113
+ function toWirePermitDetails(d) {
114
+ return {
115
+ token: d.token,
116
+ amount: d.amount.toString(),
117
+ expiration: d.expiration.toString(),
118
+ nonce: d.nonce.toString(),
119
+ };
120
+ }
121
+ function fromWireTransaction(wire) {
122
+ return {
123
+ to: wire.to,
124
+ value: BigInt(wire.value),
125
+ data: wire.data,
126
+ };
127
+ }
128
+ export function fromWireHealth(wire) {
129
+ return {
130
+ healthy: wire.healthy,
131
+ lastUpdateMs: wire.last_update_ms,
132
+ numSolverPools: wire.num_solver_pools,
133
+ ...(wire.gas_price_age_ms != null ? { gasPriceAgeMs: wire.gas_price_age_ms } : {}),
134
+ };
135
+ }
136
+ export function fromWireInstanceInfo(wire) {
137
+ return {
138
+ routerAddress: wire.router_address,
139
+ permit2Address: wire.permit2_address,
140
+ chainId: wire.chain_id,
141
+ };
142
+ }
143
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkCvC,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC7C,MAAM,SAAS,GAAc;QACzB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;QAC9B,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;QAChC,MAAM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CAAC;AAED,SAAS,mBAAmB,CAAC,IAAqB;IAC9C,OAAO;QACH,EAAE,EAAE,IAAI,CAAC,EAAa;QACtB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,EAAE,IAAI,CAAC,IAAW;KACzB,CAAC;AACN,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAsB;IACjD,OAAO;QACH,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,YAAY,EAAE,IAAI,CAAC,cAAc;QACjC,cAAc,EAAE,IAAI,CAAC,gBAAgB;QACrC,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrF,CAAC;AACN,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IACzD,OAAO;QACL,aAAa,EAAG,IAAI,CAAC,cAAyB;QAC9C,cAAc,EAAE,IAAI,CAAC,eAA0B;QAC/C,OAAO,EAAS,IAAI,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Address, EncodingOptions, Hex, PermitSingle } from './types.js';
2
+ /**
3
+ * Computes the EIP-712 signing hash for a Permit2 PermitSingle.
4
+ *
5
+ * Pass the returned hash to your signer's signMessage/signHash method,
6
+ * then supply the 65-byte signature to EncodingOptions.permit2Signature.
7
+ *
8
+ * The canonical Permit2 address across all chains is:
9
+ * 0x000000000022D473030F116dDEE9F6B43aC78BA3
10
+ */
11
+ export declare function permit2SigningHash(permit: PermitSingle, chainId: number, permit2Address: Address): Hex;
12
+ /**
13
+ * Create encoding options with slippage tolerance.
14
+ * Default transfer type is 'transfer_from'.
15
+ */
16
+ export declare function encodingOptions(slippage: number): EncodingOptions;
17
+ /**
18
+ * Add Permit2 authorization to encoding options.
19
+ * Validates that signature is exactly 65 bytes (130 hex chars + '0x' prefix).
20
+ */
21
+ export declare function withPermit2(opts: EncodingOptions, permit: PermitSingle, signature: Hex): EncodingOptions;
22
+ /**
23
+ * Set transfer type to 'use_vaults_funds' (funds already in router vault).
24
+ */
25
+ export declare function withVaultFunds(opts: EncodingOptions): EncodingOptions;
26
+ //# sourceMappingURL=permit2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permit2.d.ts","sourceRoot":"","sources":["../src/permit2.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoB9E;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,GACtB,GAAG,CAoBL;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEjE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,GAAG,GACb,eAAe,CAYjB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAErE"}
@@ -0,0 +1,77 @@
1
+ import { hashTypedData } from 'viem';
2
+ import { FyndError } from './error.js';
3
+ const PERMIT_DETAILS_TYPE = {
4
+ PermitDetails: [
5
+ { name: 'token', type: 'address' },
6
+ { name: 'amount', type: 'uint160' },
7
+ { name: 'expiration', type: 'uint48' },
8
+ { name: 'nonce', type: 'uint48' },
9
+ ],
10
+ };
11
+ const PERMIT_SINGLE_TYPE = {
12
+ PermitSingle: [
13
+ { name: 'details', type: 'PermitDetails' },
14
+ { name: 'spender', type: 'address' },
15
+ { name: 'sigDeadline', type: 'uint256' },
16
+ ],
17
+ ...PERMIT_DETAILS_TYPE,
18
+ };
19
+ /**
20
+ * Computes the EIP-712 signing hash for a Permit2 PermitSingle.
21
+ *
22
+ * Pass the returned hash to your signer's signMessage/signHash method,
23
+ * then supply the 65-byte signature to EncodingOptions.permit2Signature.
24
+ *
25
+ * The canonical Permit2 address across all chains is:
26
+ * 0x000000000022D473030F116dDEE9F6B43aC78BA3
27
+ */
28
+ export function permit2SigningHash(permit, chainId, permit2Address) {
29
+ return hashTypedData({
30
+ domain: {
31
+ name: 'Permit2',
32
+ chainId,
33
+ verifyingContract: permit2Address,
34
+ },
35
+ types: PERMIT_SINGLE_TYPE,
36
+ primaryType: 'PermitSingle',
37
+ message: {
38
+ details: {
39
+ token: permit.details.token,
40
+ amount: permit.details.amount,
41
+ expiration: Number(permit.details.expiration),
42
+ nonce: Number(permit.details.nonce),
43
+ },
44
+ spender: permit.spender,
45
+ sigDeadline: permit.sigDeadline,
46
+ },
47
+ });
48
+ }
49
+ /**
50
+ * Create encoding options with slippage tolerance.
51
+ * Default transfer type is 'transfer_from'.
52
+ */
53
+ export function encodingOptions(slippage) {
54
+ return { slippage, transferType: 'transfer_from' };
55
+ }
56
+ /**
57
+ * Add Permit2 authorization to encoding options.
58
+ * Validates that signature is exactly 65 bytes (130 hex chars + '0x' prefix).
59
+ */
60
+ export function withPermit2(opts, permit, signature) {
61
+ if (signature.length !== 132) {
62
+ throw FyndError.config(`Permit2 signature must be exactly 65 bytes (132 hex chars), got ${String(signature.length)} chars`);
63
+ }
64
+ return {
65
+ ...opts,
66
+ transferType: 'transfer_from_permit2',
67
+ permit,
68
+ permit2Signature: signature,
69
+ };
70
+ }
71
+ /**
72
+ * Set transfer type to 'use_vaults_funds' (funds already in router vault).
73
+ */
74
+ export function withVaultFunds(opts) {
75
+ return { ...opts, transferType: 'use_vaults_funds' };
76
+ }
77
+ //# sourceMappingURL=permit2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permit2.js","sourceRoot":"","sources":["../src/permit2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EA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;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,IAAqB,EACrB,MAAoB,EACpB,SAAc;IAEd,IAAI,SAAS,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC7B,MAAM,SAAS,CAAC,MAAM,CACpB,mEAAmE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CACpG,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,YAAY,EAAE,uBAAuB;QACrC,MAAM;QACN,gBAAgB,EAAE,SAAS;KAC5B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAqB;IAClD,OAAO,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,89 @@
1
+ import type { Address, Hex, Quote } from './types.js';
2
+ /** An unsigned EIP-1559 `approve(spender, amount)` transaction. */
3
+ export interface ApprovalPayload {
4
+ tx: Eip1559Transaction;
5
+ token: Address;
6
+ spender: Address;
7
+ amount: bigint;
8
+ }
9
+ /** A signed approval ready for {@link FyndClient.executeApproval}. */
10
+ export interface SignedApproval {
11
+ tx: Eip1559Transaction;
12
+ /** 65-byte hex signature over the EIP-1559 signing hash. */
13
+ signature: Hex;
14
+ }
15
+ /** Receipt for a mined transaction (gas cost only, no settled-amount). */
16
+ export interface TxReceipt {
17
+ txHash: Hex;
18
+ gasCost: bigint;
19
+ }
20
+ /** An unsigned EIP-1559 transaction ready for signing. */
21
+ export interface Eip1559Transaction {
22
+ chainId: number;
23
+ nonce: number;
24
+ maxFeePerGas: bigint;
25
+ maxPriorityFeePerGas: bigint;
26
+ gas: bigint;
27
+ to: Address;
28
+ value: bigint;
29
+ data: Hex;
30
+ }
31
+ /** Internal payload pairing a quote with its unsigned transaction. */
32
+ export interface FyndPayload {
33
+ /** Original quote; carries `tokenOut` and `receiver` needed for settlement parsing. */
34
+ quote: Quote;
35
+ tx: Eip1559Transaction;
36
+ }
37
+ /** Discriminated union of backend-specific swap payloads ready to be signed. */
38
+ export type SwapPayload = {
39
+ kind: 'fynd';
40
+ payload: FyndPayload;
41
+ };
42
+ /** A 65-byte ECDSA signature encoded as a hex string. */
43
+ export type PrimitiveSignature = `0x${string}`;
44
+ /** A swap payload paired with its cryptographic signature, ready for on-chain submission. */
45
+ export interface SignedSwap {
46
+ payload: SwapPayload;
47
+ signature: PrimitiveSignature;
48
+ }
49
+ /** Result of a settled (or dry-run) swap execution. */
50
+ export interface SettledOrder {
51
+ /** Transaction hash; absent for dry-run executions. */
52
+ txHash?: Hex;
53
+ /** Total output tokens received by the receiver, parsed from Transfer logs. */
54
+ settledAmount?: bigint;
55
+ /** Gas cost in wei (gasUsed * effectiveGasPrice, or estimated for dry-run). */
56
+ gasCost: bigint;
57
+ }
58
+ /** Options for waiting on transaction settlement. */
59
+ export interface SettleOptions {
60
+ /** Maximum time to wait for confirmation in milliseconds. Defaults to {@link DEFAULT_SETTLE_TIMEOUT_MS}. */
61
+ timeoutMs?: number;
62
+ }
63
+ /** Default timeout for {@link ExecutionReceipt.settle} (120 seconds). */
64
+ export declare const DEFAULT_SETTLE_TIMEOUT_MS = 120000;
65
+ /** Handle returned by {@link FyndClient.executeSwap} to await transaction settlement. */
66
+ export interface ExecutionReceipt {
67
+ /** Polls for the transaction receipt and returns the settled result.
68
+ * @throws {FyndError} With code `SETTLE_TIMEOUT` if the transaction does not confirm in time.
69
+ */
70
+ settle(options?: SettleOptions): Promise<SettledOrder>;
71
+ }
72
+ /**
73
+ * Computes the EIP-1559 signing hash for a swap payload.
74
+ *
75
+ * Equivalent to keccak256 of the unsigned serialized EIP-1559 transaction,
76
+ * which is the hash the signer must sign.
77
+ */
78
+ export declare function swapSigningHash(payload: SwapPayload): Hex;
79
+ /**
80
+ * Wraps a swap payload and signature into a {@link SignedSwap} without any I/O.
81
+ * Mirrors Rust's `SignedSwap::assemble`.
82
+ */
83
+ export declare function assembleSignedSwap(payload: SwapPayload, signature: PrimitiveSignature): SignedSwap;
84
+ /**
85
+ * Compute the EIP-1559 signing hash for an approval payload.
86
+ * Sign this and pass the result to {@link FyndClient.executeApproval} via {@link SignedApproval}.
87
+ */
88
+ export declare function approvalSigningHash(payload: ApprovalPayload): Hex;
89
+ //# sourceMappingURL=signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../src/signing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtD,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,kBAAkB,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,kBAAkB,CAAC;IACvB,4DAA4D;IAC5D,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,uFAAuF;IACvF,KAAK,EAAE,KAAK,CAAC;IACb,EAAE,EAAE,kBAAkB,CAAC;CACxB;AAED,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjE,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,KAAK,MAAM,EAAE,CAAC;AAE/C,6FAA6F;AAC7F,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAEjD,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACxD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,GAAG,CAczD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,kBAAkB,GAC5B,UAAU,CAEZ;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG,CAEjE"}
@@ -0,0 +1,39 @@
1
+ import { keccak256, serializeTransaction } from 'viem';
2
+ /** Default timeout for {@link ExecutionReceipt.settle} (120 seconds). */
3
+ export const DEFAULT_SETTLE_TIMEOUT_MS = 120000;
4
+ /**
5
+ * Computes the EIP-1559 signing hash for a swap payload.
6
+ *
7
+ * Equivalent to keccak256 of the unsigned serialized EIP-1559 transaction,
8
+ * which is the hash the signer must sign.
9
+ */
10
+ export function swapSigningHash(payload) {
11
+ const tx = payload.payload.tx;
12
+ const serialized = serializeTransaction({
13
+ type: 'eip1559',
14
+ chainId: tx.chainId,
15
+ nonce: tx.nonce,
16
+ maxFeePerGas: tx.maxFeePerGas,
17
+ maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
18
+ gas: tx.gas,
19
+ to: tx.to,
20
+ value: tx.value,
21
+ data: tx.data,
22
+ });
23
+ return keccak256(serialized);
24
+ }
25
+ /**
26
+ * Wraps a swap payload and signature into a {@link SignedSwap} without any I/O.
27
+ * Mirrors Rust's `SignedSwap::assemble`.
28
+ */
29
+ export function assembleSignedSwap(payload, signature) {
30
+ return { payload, signature };
31
+ }
32
+ /**
33
+ * Compute the EIP-1559 signing hash for an approval payload.
34
+ * Sign this and pass the result to {@link FyndClient.executeApproval} via {@link SignedApproval}.
35
+ */
36
+ export function approvalSigningHash(payload) {
37
+ return keccak256(serializeTransaction({ type: 'eip1559', ...payload.tx }));
38
+ }
39
+ //# sourceMappingURL=signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.js","sourceRoot":"","sources":["../src/signing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAuEvD,yEAAyE;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAO,CAAC;AAUjD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,oBAAoB,CAAC;QACtC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,KAAK,EAAE,EAAE,CAAC,KAAK;QACf,YAAY,EAAE,EAAE,CAAC,YAAY;QAC7B,oBAAoB,EAAE,EAAE,CAAC,oBAAoB;QAC7C,GAAG,EAAE,EAAE,CAAC,GAAG;QACX,EAAE,EAAE,EAAE,CAAC,EAAE;QACT,KAAK,EAAE,EAAE,CAAC,KAAK;QACf,IAAI,EAAE,EAAE,CAAC,IAAI;KACd,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAoB,EACpB,SAA6B;IAE7B,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,OAAO,SAAS,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAAQ,CAAC;AACpF,CAAC"}
@@ -0,0 +1,177 @@
1
+ /** Outcome status of a quote request. Must stay in sync with the server schema. */
2
+ export type SolutionStatus = 'success' | 'no_route_found' | 'insufficient_liquidity' | 'timeout' | 'not_ready';
3
+ /** Routing backend that produced a quote. */
4
+ export type BackendKind = 'fynd' | 'turbine';
5
+ /** EVM address as a hex string. */
6
+ export type Address = `0x${string}`;
7
+ /** Arbitrary hex-encoded bytes. */
8
+ export type Hex = `0x${string}`;
9
+ /** Order side. Currently only sell orders are supported. */
10
+ export type OrderSide = 'sell';
11
+ /** A swap order specifying input/output tokens, amount, and participants. */
12
+ export interface Order {
13
+ /** Token to sell. */
14
+ tokenIn: Address;
15
+ /** Token to receive. */
16
+ tokenOut: Address;
17
+ /** Amount of `tokenIn` to sell (in token base units). */
18
+ amount: bigint;
19
+ side: OrderSide;
20
+ /** Address that holds the input tokens and sends the transaction. */
21
+ sender: Address;
22
+ /** Address that receives output tokens. Defaults to `sender` if omitted. */
23
+ receiver?: Address;
24
+ }
25
+ /** How the router pulls input tokens from the sender. */
26
+ export type UserTransferType = 'transfer_from' | 'transfer_from_permit2' | 'use_vaults_funds' | 'none';
27
+ /** Uniswap Permit2 allowance details for a single token. */
28
+ export interface PermitDetails {
29
+ token: Address;
30
+ /** Maximum transferable amount (uint160). */
31
+ amount: bigint;
32
+ /** Unix timestamp after which the permit expires (uint48). */
33
+ expiration: bigint;
34
+ /** Permit2 nonce for this token/spender pair (uint48). */
35
+ nonce: bigint;
36
+ }
37
+ /** Uniswap Permit2 single-token permit, ready for EIP-712 signing. */
38
+ export interface PermitSingle {
39
+ details: PermitDetails;
40
+ /** Address authorized to spend tokens via Permit2. */
41
+ spender: Address;
42
+ /** Unix timestamp after which the signature is invalid. */
43
+ sigDeadline: bigint;
44
+ }
45
+ /** Client fee configuration for the Tycho Router.
46
+ *
47
+ * When provided, the router charges a fee in basis points on the swap output.
48
+ * The `signature` must be an EIP-712 signature by the `receiver` over the
49
+ * `ClientFee` typed data — compute the hash with `clientFeeSigningHash`.
50
+ */
51
+ export interface ClientFeeParams {
52
+ /** Fee in basis points (0–10,000). 100 = 1%. */
53
+ bps: number;
54
+ /** Address that receives the fee (also the required EIP-712 signer). */
55
+ receiver: Address;
56
+ /** Maximum subsidy from the client's vault balance. */
57
+ maxContribution: bigint;
58
+ /** Unix timestamp after which the signature is invalid. */
59
+ deadline: number;
60
+ /** 65-byte EIP-712 ECDSA signature by `receiver`. Set after signing. */
61
+ signature?: Hex;
62
+ }
63
+ /** Controls how the solver encodes the settlement transaction. */
64
+ export interface EncodingOptions {
65
+ /** Maximum acceptable slippage as a fraction (e.g. 0.01 for 1%). */
66
+ slippage: number;
67
+ /** How tokens are transferred to the router. Defaults to `'transfer_from'`. */
68
+ transferType?: UserTransferType;
69
+ /** Permit2 permit data; required when `transferType` is `'transfer_from_permit2'`. */
70
+ permit?: PermitSingle;
71
+ /** 65-byte Permit2 signature over the permit; required with `permit`. */
72
+ permit2Signature?: Hex;
73
+ /** Client fee configuration. When absent, no fee is charged. */
74
+ clientFeeParams?: ClientFeeParams;
75
+ }
76
+ /** An encoded on-chain transaction returned by the solver. */
77
+ export interface Transaction {
78
+ to: Address;
79
+ value: bigint;
80
+ data: Hex;
81
+ }
82
+ /** Optional parameters for a quote request. */
83
+ export interface QuoteOptions {
84
+ /** Server-side solver timeout in milliseconds. */
85
+ timeoutMs?: number;
86
+ /** Minimum number of solver responses to wait for before returning. */
87
+ minResponses?: number;
88
+ /** Maximum gas the solution may consume. */
89
+ maxGas?: bigint;
90
+ /** Encoding options; when set, the response includes a ready-to-sign transaction. */
91
+ encodingOptions?: EncodingOptions;
92
+ }
93
+ /** Input parameters for {@link FyndClient.quote}. */
94
+ export interface QuoteParams {
95
+ order: Order;
96
+ options?: QuoteOptions;
97
+ }
98
+ /** Block metadata at the time the quote was computed. */
99
+ export interface BlockInfo {
100
+ number: number;
101
+ hash: string;
102
+ /** Unix timestamp of the block (seconds). */
103
+ timestamp: number;
104
+ }
105
+ /** A single pool-level swap within a route. */
106
+ export interface Swap {
107
+ /** Unique pool identifier (wire name: `component_id`). */
108
+ poolId: string;
109
+ /** Protocol name (e.g. "uniswap_v3", "balancer_v2"). */
110
+ protocol: string;
111
+ tokenIn: Address;
112
+ tokenOut: Address;
113
+ amountIn: bigint;
114
+ amountOut: bigint;
115
+ gasEstimate: bigint;
116
+ }
117
+ /** An ordered sequence of swaps forming a complete routing path. */
118
+ export interface Route {
119
+ swaps: Swap[];
120
+ }
121
+ /** A solver quote containing the best route, amounts, and optional encoded transaction. */
122
+ export interface Quote {
123
+ orderId: string;
124
+ status: SolutionStatus;
125
+ backend: BackendKind;
126
+ route?: Route;
127
+ amountIn: bigint;
128
+ amountOut: bigint;
129
+ gasEstimate: bigint;
130
+ /** Price impact in basis points (1 bp = 0.01%). */
131
+ priceImpactBps?: number;
132
+ block: BlockInfo;
133
+ /** Output token address from the original order; used internally for settlement parsing. */
134
+ tokenOut: Address;
135
+ /** Receiver address; defaults to sender if not specified in the original order. */
136
+ receiver: Address;
137
+ /** Encoded transaction; present only when `encodingOptions` was set in the quote request. */
138
+ transaction?: Transaction;
139
+ }
140
+ /** Solver health status and readiness information. */
141
+ export interface HealthStatus {
142
+ healthy: boolean;
143
+ /** Milliseconds since the last state update. */
144
+ lastUpdateMs: number;
145
+ /** Number of liquidity pools tracked by the solver. */
146
+ numSolverPools: number;
147
+ gasPriceAgeMs?: number;
148
+ }
149
+ /** Static metadata about a Fynd server instance. */
150
+ export interface InstanceInfo {
151
+ routerAddress: Address;
152
+ permit2Address: Address;
153
+ chainId: number;
154
+ }
155
+ /** Parameters for {@link FyndClient.approval}. */
156
+ export interface ApprovalParams {
157
+ /** ERC-20 token to approve. */
158
+ token: Address;
159
+ /** Amount to approve (in token base units). */
160
+ amount: bigint;
161
+ /**
162
+ * Which contract to approve as spender.
163
+ *
164
+ * `'transfer_from'` → router contract (default).
165
+ * `'transfer_from_permit2'` → Permit2 contract.
166
+ * `'none'` → {@link FyndClient.approval} returns `null` immediately.
167
+ */
168
+ transferType?: UserTransferType;
169
+ /**
170
+ * When `true`, read on-chain allowance before building the transaction.
171
+ *
172
+ * If the allowance is already sufficient, {@link FyndClient.approval} returns `null`.
173
+ * Requires `provider.readAllowance` to be implemented.
174
+ */
175
+ checkAllowance?: boolean;
176
+ }
177
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,gBAAgB,GAChB,wBAAwB,GACxB,SAAS,GACT,WAAW,CAAC;AAEhB,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7C,mCAAmC;AACnC,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AACpC,mCAAmC;AACnC,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEhC,4DAA4D;AAC5D,MAAM,MAAM,SAAS,GAAG,MAA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,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,4FAA4F;IAC5F,QAAQ,EAAE,OAAO,CAAC;IAClB,mFAAmF;IACnF,QAAQ,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}