@quip.network/quip-swap-sdk 0.1.0-beta.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/LICENSE +235 -0
- package/README.md +124 -0
- package/dist/index.d.ts +3136 -0
- package/dist/index.js +2596 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3136 @@
|
|
|
1
|
+
import { Address, Hex, PublicClient, Abi, BlockNumber, BlockTag, Log, Hash, TransactionReceipt, WalletClient } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core protocol types mirroring `src/TermsLib.sol` and
|
|
5
|
+
* `src/interfaces/IOmnibus.sol` exactly.
|
|
6
|
+
*
|
|
7
|
+
* Every Solidity integer (`uint256`, token ids, amounts, chain ids,
|
|
8
|
+
* timestamps, fees) is represented as `bigint` — never `number` — because
|
|
9
|
+
* `uint256` exceeds `Number.MAX_SAFE_INTEGER`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The type of asset in a swap leg.
|
|
14
|
+
*
|
|
15
|
+
* Mirrors the Solidity `enum AssetType` (encoded as `uint8` in the ABI).
|
|
16
|
+
* The numeric values MUST match the Solidity declaration order — they are
|
|
17
|
+
* part of the terms digest, so a mismatch breaks hash agreement with the
|
|
18
|
+
* contract.
|
|
19
|
+
*
|
|
20
|
+
* @see TermsLib (enum AssetType)
|
|
21
|
+
*/
|
|
22
|
+
declare enum AssetType {
|
|
23
|
+
/** Native chain currency (ETH on mainnet, etc.). */
|
|
24
|
+
Native = 0,
|
|
25
|
+
/** An ERC-20 fungible token. */
|
|
26
|
+
ERC20 = 1,
|
|
27
|
+
/** An ERC-721 non-fungible token (one specific token id). */
|
|
28
|
+
ERC721 = 2,
|
|
29
|
+
/** An ERC-1155 semi-fungible token (a quantity of one token id). */
|
|
30
|
+
ERC1155 = 3
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Lifecycle state of a hashlock in the Omnibus contract.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors the Solidity `enum LockState`. Valid transitions (enforced
|
|
36
|
+
* on-chain by `Omnibus._advanceLockTo`):
|
|
37
|
+
*
|
|
38
|
+
* ```text
|
|
39
|
+
* Unused -> Free (first same-chain commit)
|
|
40
|
+
* Unused -> Committed (cross-chain local commit)
|
|
41
|
+
* Free -> Committed (second same-chain commit, other side)
|
|
42
|
+
* Free -> Spent (reclaim of a half-committed same-chain swap)
|
|
43
|
+
* Committed -> Spent (claim or reclaim)
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see IOmnibus (enum LockState), Omnibus._advanceLockTo
|
|
47
|
+
*/
|
|
48
|
+
declare enum LockState {
|
|
49
|
+
/** Default — the lock has never been used. */
|
|
50
|
+
Unused = 0,
|
|
51
|
+
/** Same-chain only: one party has committed, waiting for the counterparty. */
|
|
52
|
+
Free = 1,
|
|
53
|
+
/** Ready for claim (same-chain: both committed; cross-chain: the single local commit). */
|
|
54
|
+
Committed = 2,
|
|
55
|
+
/** Terminal — claimed or reclaimed. */
|
|
56
|
+
Spent = 3
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An asset to be transferred as part of a swap.
|
|
60
|
+
*
|
|
61
|
+
* Mirrors the Solidity `struct Asset` field-for-field. All four fields are
|
|
62
|
+
* part of the terms digest, so canonical field values matter: two assets
|
|
63
|
+
* that move the same tokens but differ in any field produce different
|
|
64
|
+
* digests and therefore different swaps.
|
|
65
|
+
*
|
|
66
|
+
* @see TermsLib (struct Asset)
|
|
67
|
+
*/
|
|
68
|
+
interface Asset {
|
|
69
|
+
/** The kind of asset; encoded as `uint8` in the ABI. */
|
|
70
|
+
readonly assetType: AssetType;
|
|
71
|
+
/** Token contract address; MUST be the zero address for {@link AssetType.Native}. */
|
|
72
|
+
readonly target: Address;
|
|
73
|
+
/**
|
|
74
|
+
* Token id; used by ERC-721 and ERC-1155 and MUST be `0n` for Native and
|
|
75
|
+
* ERC-20 (the contract rejects a non-zero id for ERC-20 with
|
|
76
|
+
* `InvalidERC20Asset`). Token id `0n` is explicitly VALID for ERC-721 and
|
|
77
|
+
* ERC-1155.
|
|
78
|
+
*/
|
|
79
|
+
readonly id: bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Quantity in the token's base units (wei for native). MUST be greater
|
|
82
|
+
* than zero for every asset type — including ERC-721, where the SDK
|
|
83
|
+
* canonicalizes the value to `1n` (see {@link erc721Asset}).
|
|
84
|
+
*/
|
|
85
|
+
readonly amount: bigint;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The terms for a single party (one "leg") of an Omnibus swap.
|
|
89
|
+
*
|
|
90
|
+
* Mirrors the Solidity `struct Terms` field-for-field. A swap consists of
|
|
91
|
+
* two `Terms` whose lifecycle timestamps strictly interleave (see
|
|
92
|
+
* {@link validateTermPairing}); the side with the earlier
|
|
93
|
+
* `commitmentDeadline` is the PROPOSER and commits first.
|
|
94
|
+
*
|
|
95
|
+
* @see TermsLib (struct Terms)
|
|
96
|
+
*/
|
|
97
|
+
interface Terms {
|
|
98
|
+
/**
|
|
99
|
+
* The chain id where THIS side's assets are held and escrowed. The two
|
|
100
|
+
* sides may name different chains (cross-chain swap) or the same chain
|
|
101
|
+
* (same-chain swap). Must be non-zero.
|
|
102
|
+
*/
|
|
103
|
+
readonly chainId: bigint;
|
|
104
|
+
/**
|
|
105
|
+
* The address that receives this side's own assets back if the swap is
|
|
106
|
+
* reclaimed instead of claimed. Must be non-zero.
|
|
107
|
+
*/
|
|
108
|
+
readonly reclaimRecipient: Address;
|
|
109
|
+
/**
|
|
110
|
+
* The address that receives the COUNTERPARTY's assets when the swap is
|
|
111
|
+
* claimed — not this side's own assets. Must be non-zero.
|
|
112
|
+
*/
|
|
113
|
+
readonly recipient: Address;
|
|
114
|
+
/**
|
|
115
|
+
* Unix timestamp (seconds) at and after which this side may no longer
|
|
116
|
+
* commit. Also the instant the counterparty-taker's commit window opens
|
|
117
|
+
* when this side proposes. Must be non-zero.
|
|
118
|
+
*/
|
|
119
|
+
readonly commitmentDeadline: bigint;
|
|
120
|
+
/**
|
|
121
|
+
* Unix timestamp (seconds) at and after which claiming gated by this
|
|
122
|
+
* side's claim schedule is forbidden. Must be strictly greater than
|
|
123
|
+
* `commitmentDeadline`.
|
|
124
|
+
*/
|
|
125
|
+
readonly claimDeadline: bigint;
|
|
126
|
+
/**
|
|
127
|
+
* Unix timestamp (seconds) at and after which this side's escrowed assets
|
|
128
|
+
* may be reclaimed to `reclaimRecipient`. Must be strictly greater than
|
|
129
|
+
* `claimDeadline`.
|
|
130
|
+
*/
|
|
131
|
+
readonly reclaimRelease: bigint;
|
|
132
|
+
/** The assets this side escrows. Must be non-empty and each asset valid. */
|
|
133
|
+
readonly assets: readonly Asset[];
|
|
134
|
+
}
|
|
135
|
+
/** A 32-byte hex value (`0x` + 64 hex chars), e.g. a secret, lock, or digest. */
|
|
136
|
+
type Hex32 = Hex;
|
|
137
|
+
/**
|
|
138
|
+
* A freshly generated hashlock pair.
|
|
139
|
+
*
|
|
140
|
+
* Secrecy lifecycle:
|
|
141
|
+
* - `lock` may be shared freely — it is published on-chain at commit time.
|
|
142
|
+
* - `secret` MUST remain private until the holder claims; the `Claim` event
|
|
143
|
+
* reveals it publicly.
|
|
144
|
+
* - Revealing the secret early lets anyone in the proposer-claim window
|
|
145
|
+
* claim, compromising a cross-chain flow.
|
|
146
|
+
* - Losing the secret makes claiming impossible; the assets can then only
|
|
147
|
+
* be recovered via reclaim after `reclaimRelease`.
|
|
148
|
+
*/
|
|
149
|
+
interface SecretLockPair {
|
|
150
|
+
/** The 32-byte preimage. Keep private until claim. */
|
|
151
|
+
readonly secret: Hex32;
|
|
152
|
+
/** `keccak256(secret)` — safe to share. */
|
|
153
|
+
readonly lock: Hex32;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Stable machine-readable SDK error codes.
|
|
158
|
+
*
|
|
159
|
+
* Codes prefixed with contract semantics (e.g. `CONTRACT_REVERT`) wrap an
|
|
160
|
+
* on-chain revert; the rest are produced by SDK-side preflight validation
|
|
161
|
+
* BEFORE any transaction is sent. SDK validation mirrors but never replaces
|
|
162
|
+
* contract enforcement.
|
|
163
|
+
*/
|
|
164
|
+
type QuipSwapErrorCode = 'ZERO_AMOUNT' | 'INVALID_NATIVE_ASSET' | 'INVALID_ERC20_ASSET' | 'INVALID_ERC721_ASSET' | 'INVALID_ERC1155_ASSET' | 'INVALID_ASSET_TYPE' | 'EMPTY_ASSETS' | 'ZERO_ADDRESS_RECIPIENT' | 'ZERO_DEADLINE' | 'DISORDERED_DEADLINES' | 'ZERO_CHAIN_ID' | 'INVALID_RANGE' | 'WINDOW_VIOLATED' | 'INVALID_HEX32' | 'CHAIN_ID_MISMATCH' | 'NOT_QUIP_WALLET' | 'MISSING_WALLET_CLIENT' | 'MISSING_ACCOUNT' | 'TERMS_NOT_ON_CHAIN' | 'INVALID_LOCK_STATE' | 'TERMS_ALREADY_POSTED' | 'GAS_ESTIMATION_FAILED' | 'BALANCE_TOO_LOW' | 'SECRET_HOLDER_NOT_PROPOSER' | 'INSUFFICIENT_BUFFER' | 'UNKNOWN_DEPLOYMENT' | 'TRANSACTION_REVERTED' | 'EVENT_NOT_FOUND' | 'CONTRACT_REVERT';
|
|
165
|
+
/**
|
|
166
|
+
* Structured details carried by every {@link QuipSwapError}.
|
|
167
|
+
*/
|
|
168
|
+
interface QuipSwapErrorDetails {
|
|
169
|
+
/** Stable machine-readable code; safe to branch on. */
|
|
170
|
+
readonly code: QuipSwapErrorCode;
|
|
171
|
+
/** Human-readable explanation with remediation guidance. */
|
|
172
|
+
readonly message: string;
|
|
173
|
+
/**
|
|
174
|
+
* The decoded Solidity custom-error name (e.g. `CallerNotQuipWallet`,
|
|
175
|
+
* `WindowViolated`) when the error wraps an on-chain revert and the error
|
|
176
|
+
* was decodable from the Omnibus ABI.
|
|
177
|
+
*/
|
|
178
|
+
readonly contractErrorName?: string;
|
|
179
|
+
/** The original underlying error (e.g. the Viem error), never discarded. */
|
|
180
|
+
readonly cause?: unknown;
|
|
181
|
+
/** Additional structured context (offending values, window bounds, ...). */
|
|
182
|
+
readonly details?: unknown;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The error class thrown by every SDK function.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* try {
|
|
190
|
+
* await client.commit({lock, party, counterparty})
|
|
191
|
+
* } catch (err) {
|
|
192
|
+
* if (err instanceof QuipSwapError && err.code === 'CONTRACT_REVERT') {
|
|
193
|
+
* // a contract revert; err.contractErrorName names the Solidity error
|
|
194
|
+
* // (e.g. 'IncorrectNativeAmountReceived', 'CallerNotQuipWallet')
|
|
195
|
+
* }
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
declare class QuipSwapError extends Error implements QuipSwapErrorDetails {
|
|
200
|
+
readonly name = "QuipSwapError";
|
|
201
|
+
readonly code: QuipSwapErrorCode;
|
|
202
|
+
readonly contractErrorName?: string;
|
|
203
|
+
readonly cause?: unknown;
|
|
204
|
+
readonly details?: unknown;
|
|
205
|
+
constructor(args: QuipSwapErrorDetails);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Extracts the decoded Solidity custom-error name from a Viem error, if any.
|
|
209
|
+
*
|
|
210
|
+
* Viem decodes custom errors against the contract ABI during
|
|
211
|
+
* `simulateContract` / `readContract`; this helper walks the error chain
|
|
212
|
+
* (structured decoding — no parsing of human-readable strings) and returns
|
|
213
|
+
* e.g. `"CallerNotQuipWallet"` or `"WindowViolated"`.
|
|
214
|
+
*
|
|
215
|
+
* @param error - Any error thrown by a Viem contract action.
|
|
216
|
+
* @returns The custom error name, or `undefined` when the revert could not
|
|
217
|
+
* be decoded (e.g. an out-of-ABI token error with no registered ABI).
|
|
218
|
+
*/
|
|
219
|
+
declare function extractContractErrorName(error: unknown): string | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Wraps an error thrown by a Viem contract action into a
|
|
222
|
+
* {@link QuipSwapError} with code `CONTRACT_REVERT`, preserving the original
|
|
223
|
+
* error in `cause` and the decoded custom-error name (when available) in
|
|
224
|
+
* `contractErrorName`.
|
|
225
|
+
*
|
|
226
|
+
* @param error - The original error thrown by Viem.
|
|
227
|
+
* @param context - Short description of the operation that failed.
|
|
228
|
+
* @returns A `QuipSwapError` wrapping the original error.
|
|
229
|
+
*/
|
|
230
|
+
declare function wrapContractError(error: unknown, context: string): QuipSwapError;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Builds a native-currency asset (ETH or the chain's equivalent).
|
|
234
|
+
*
|
|
235
|
+
* Canonical fields enforced — mirrors the contract's native-asset rule:
|
|
236
|
+
* `target` must be the zero address and `id` must be `0`, otherwise the
|
|
237
|
+
* contract reverts with `InvalidNativeAsset`.
|
|
238
|
+
*
|
|
239
|
+
* @param amount - Amount of native currency in wei; must be `> 0n`.
|
|
240
|
+
* @returns A canonical, frozen `Asset` with `assetType: Native`.
|
|
241
|
+
* @throws QuipSwapError `ZERO_AMOUNT` if `amount` is zero or negative.
|
|
242
|
+
* @see TermsLib.validateAsset
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const oneEth = nativeAsset(10n ** 18n)
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
declare function nativeAsset(amount: bigint): Asset;
|
|
249
|
+
/**
|
|
250
|
+
* Builds an ERC-20 asset.
|
|
251
|
+
*
|
|
252
|
+
* The id is fixed at `0n`: the contract REJECTS a non-zero id for ERC-20
|
|
253
|
+
* with `InvalidERC20Asset` (the id field is meaningless for fungible
|
|
254
|
+
* tokens but is still hashed into the terms digest).
|
|
255
|
+
*
|
|
256
|
+
* @param target - The ERC-20 token contract address; must be non-zero.
|
|
257
|
+
* @param amount - Token amount in the token's base units; must be `> 0n`.
|
|
258
|
+
* @returns A canonical, frozen `Asset` with `assetType: ERC20` and `id: 0n`.
|
|
259
|
+
* @throws QuipSwapError `INVALID_ERC20_ASSET` if `target` is the zero address
|
|
260
|
+
* or not a valid address; `ZERO_AMOUNT` if `amount <= 0n`.
|
|
261
|
+
* @see TermsLib.validateAsset
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const usdc = erc20Asset('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1_000_000n)
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function erc20Asset(target: Address, amount: bigint): Asset;
|
|
268
|
+
/**
|
|
269
|
+
* Builds an ERC-721 asset for one specific NFT.
|
|
270
|
+
*
|
|
271
|
+
* Token id `0n` is explicitly VALID — do not pre-filter it out; the
|
|
272
|
+
* contract permits id 0 for ERC-721 (see the comment in
|
|
273
|
+
* `TermsLib.validateAsset`).
|
|
274
|
+
*
|
|
275
|
+
* SDK-STRICTER-THAN-CONTRACT: the amount is canonicalized to `1n`. The
|
|
276
|
+
* contract only enforces `amount != 0`, but the amount is hashed into the
|
|
277
|
+
* terms digest while the transfer always moves exactly the one NFT
|
|
278
|
+
* identified by `tokenId` — so two different amounts would yield two
|
|
279
|
+
* different digests describing the same effective transfer. Canonicalizing
|
|
280
|
+
* to `1n` (matching the repository's `AssetHelper.makeERC721`) prevents
|
|
281
|
+
* that ambiguity. Validation of externally supplied assets
|
|
282
|
+
* ({@link validateAsset}) follows the contract and accepts any non-zero
|
|
283
|
+
* amount.
|
|
284
|
+
*
|
|
285
|
+
* @param target - The ERC-721 token contract address; must be non-zero.
|
|
286
|
+
* @param tokenId - The NFT's token id; `0n` is valid.
|
|
287
|
+
* @returns A canonical, frozen `Asset` with `assetType: ERC721` and `amount: 1n`.
|
|
288
|
+
* @throws QuipSwapError `INVALID_ERC721_ASSET` if `target` is the zero
|
|
289
|
+
* address or not a valid address.
|
|
290
|
+
* @see TermsLib.validateAsset
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* const punk = erc721Asset('0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB', 42n)
|
|
294
|
+
* // punk.amount === 1n always
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
declare function erc721Asset(target: Address, tokenId: bigint): Asset;
|
|
298
|
+
/**
|
|
299
|
+
* Builds an ERC-1155 asset (a quantity of one token id).
|
|
300
|
+
*
|
|
301
|
+
* Token id `0n` is explicitly VALID, mirroring the contract.
|
|
302
|
+
*
|
|
303
|
+
* @param target - The ERC-1155 token contract address; must be non-zero.
|
|
304
|
+
* @param tokenId - The token id; `0n` is valid.
|
|
305
|
+
* @param amount - Quantity of the token id; must be `> 0n`.
|
|
306
|
+
* @returns A canonical, frozen `Asset` with `assetType: ERC1155`.
|
|
307
|
+
* @throws QuipSwapError `INVALID_ERC1155_ASSET` if `target` is invalid;
|
|
308
|
+
* `ZERO_AMOUNT` if `amount <= 0n`.
|
|
309
|
+
* @see TermsLib.validateAsset
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* const gameItems = erc1155Asset('0x495f947276749Ce646f68AC8c248420045cb7b5e', 7n, 25n)
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
declare function erc1155Asset(target: Address, tokenId: bigint, amount: bigint): Asset;
|
|
316
|
+
/**
|
|
317
|
+
* Validates an asset object received from an untrusted source (JSON, an
|
|
318
|
+
* API, a database, another application).
|
|
319
|
+
*
|
|
320
|
+
* This is a faithful transcription of `TermsLib.validateAsset`:
|
|
321
|
+
*
|
|
322
|
+
* ```solidity
|
|
323
|
+
* if (asset.amount == 0) revert ZeroAmount();
|
|
324
|
+
* if (isNative && (!isZeroTarget || !isZeroId)) revert InvalidNativeAsset();
|
|
325
|
+
* if (isERC20 && (isZeroTarget || !isZeroId)) revert InvalidERC20Asset();
|
|
326
|
+
* // ERC721/ERC1155 token id 0 is valid; only a zero target is rejected
|
|
327
|
+
* if (isERC721 && isZeroTarget) revert InvalidERC721Asset();
|
|
328
|
+
* if (isERC1155 && isZeroTarget) revert InvalidERC1155Asset();
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* Unlike {@link erc721Asset}, this accepts any non-zero ERC-721 amount,
|
|
332
|
+
* matching the contract exactly (validation must not be stricter than the
|
|
333
|
+
* contract for objects that may already exist in committed terms).
|
|
334
|
+
*
|
|
335
|
+
* @param asset - The asset to validate.
|
|
336
|
+
* @throws QuipSwapError `ZERO_AMOUNT` | `INVALID_NATIVE_ASSET` |
|
|
337
|
+
* `INVALID_ERC20_ASSET` | `INVALID_ERC721_ASSET` | `INVALID_ERC1155_ASSET`
|
|
338
|
+
* | `INVALID_ASSET_TYPE`, each naming the matching contract error.
|
|
339
|
+
* @see TermsLib.validateAsset
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* validateAsset(JSON.parse(payload, bigintReviver)) // throws on bad input
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
declare function validateAsset(asset: Asset): void;
|
|
346
|
+
/**
|
|
347
|
+
* Sums the native amounts in a side's terms — the amount of wei the
|
|
348
|
+
* committer must escrow (before the commitment fee).
|
|
349
|
+
*
|
|
350
|
+
* Transcribes `TermsLib.totalNative`: only assets with
|
|
351
|
+
* `assetType === Native` contribute; all other types are ignored.
|
|
352
|
+
*
|
|
353
|
+
* The exact commit transaction value is
|
|
354
|
+
* `totalNative(party) + commitmentFee`, checked by the contract for strict
|
|
355
|
+
* equality (`IncorrectNativeAmountReceived`) — see
|
|
356
|
+
* {@link OmnibusClient.commit}, which re-reads the fee immediately before
|
|
357
|
+
* simulating.
|
|
358
|
+
*
|
|
359
|
+
* @param terms - The side's terms (only `assets` is read).
|
|
360
|
+
* @returns The sum of all native-asset amounts in wei (`0n` when none).
|
|
361
|
+
* @see TermsLib.totalNative
|
|
362
|
+
* @example
|
|
363
|
+
* ```ts
|
|
364
|
+
* totalNative({...terms, assets: [nativeAsset(5n), erc20Asset(token, 100n)]}) // 5n
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
declare function totalNative(terms: Pick<Terms, 'assets'>): bigint;
|
|
368
|
+
|
|
369
|
+
/** Input shape for {@link createTerms}; identical to {@link Terms}. */
|
|
370
|
+
interface CreateTermsArgs {
|
|
371
|
+
/** Chain id where this side's assets live; must be `> 0n`. */
|
|
372
|
+
readonly chainId: bigint;
|
|
373
|
+
/** Receives this side's own assets on reclaim; non-zero. */
|
|
374
|
+
readonly reclaimRecipient: Address;
|
|
375
|
+
/** Receives the COUNTERPARTY's assets on claim; non-zero. */
|
|
376
|
+
readonly recipient: Address;
|
|
377
|
+
/** Unix seconds; commitment forbidden at/after this instant; non-zero. */
|
|
378
|
+
readonly commitmentDeadline: bigint;
|
|
379
|
+
/** Unix seconds; strictly after `commitmentDeadline`. */
|
|
380
|
+
readonly claimDeadline: bigint;
|
|
381
|
+
/** Unix seconds; strictly after `claimDeadline`. */
|
|
382
|
+
readonly reclaimRelease: bigint;
|
|
383
|
+
/** Non-empty list of structurally valid assets. */
|
|
384
|
+
readonly assets: readonly Asset[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Builds and validates a {@link Terms} object.
|
|
388
|
+
*
|
|
389
|
+
* The returned object is frozen (including a defensive copy of the asset
|
|
390
|
+
* array) so later mutation of caller-supplied inputs cannot desynchronize a
|
|
391
|
+
* digest already shared with a counterparty.
|
|
392
|
+
*
|
|
393
|
+
* @param args - The seven Terms fields; see {@link CreateTermsArgs} for
|
|
394
|
+
* units and constraints.
|
|
395
|
+
* @returns A frozen, structurally valid `Terms`.
|
|
396
|
+
* @throws QuipSwapError - every code listed on {@link validateTerms}.
|
|
397
|
+
* @see TermsLib.validateTerms
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* const terms = createTerms({
|
|
401
|
+
* chainId: 8453n,
|
|
402
|
+
* reclaimRecipient: wallet,
|
|
403
|
+
* recipient: wallet,
|
|
404
|
+
* commitmentDeadline: now + 600n,
|
|
405
|
+
* claimDeadline: now + 1800n,
|
|
406
|
+
* reclaimRelease: now + 3600n,
|
|
407
|
+
* assets: [nativeAsset(10n ** 18n)],
|
|
408
|
+
* })
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
declare function createTerms(args: CreateTermsArgs): Terms;
|
|
412
|
+
/**
|
|
413
|
+
* Structurally validates one side's terms.
|
|
414
|
+
*
|
|
415
|
+
* Exact transcription of `TermsLib.validateTerms`:
|
|
416
|
+
*
|
|
417
|
+
* ```solidity
|
|
418
|
+
* if (terms.assets.length == 0) revert EmptyAssets();
|
|
419
|
+
* if (reclaimRecipient == 0 || recipient == 0) revert ZeroAddressRecipient();
|
|
420
|
+
* if (terms.commitmentDeadline == 0) revert ZeroDeadline();
|
|
421
|
+
* if (!(commitmentDeadline < claimDeadline && claimDeadline < reclaimRelease))
|
|
422
|
+
* revert DisordedDeadlines();
|
|
423
|
+
* enforceNonZeroChainId(terms); validateAssets(terms);
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* Deliberately does NOT check that deadlines are in the future: freshness
|
|
427
|
+
* is enforced per-action by the half-open windows
|
|
428
|
+
* (see {@link validateCommitWindow}). The taker legitimately commits AFTER
|
|
429
|
+
* the proposer's commitment deadline has elapsed — `Omnibus.commit`
|
|
430
|
+
* validates BOTH sides' terms, so a freshness check here would wrongly
|
|
431
|
+
* reject the proposer's already-elapsed deadline during the taker's commit.
|
|
432
|
+
*
|
|
433
|
+
* @param terms - The terms to validate (e.g. parsed from JSON or an API).
|
|
434
|
+
* @throws QuipSwapError `EMPTY_ASSETS` | `ZERO_ADDRESS_RECIPIENT` |
|
|
435
|
+
* `ZERO_DEADLINE` | `DISORDERED_DEADLINES` | `ZERO_CHAIN_ID`, plus every
|
|
436
|
+
* asset-level code from {@link validateAsset}.
|
|
437
|
+
* @see TermsLib.validateTerms
|
|
438
|
+
* @example
|
|
439
|
+
* ```ts
|
|
440
|
+
* validateTerms(termsFromCounterparty) // throws before any tx is built
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
declare function validateTerms(terms: Terms): void;
|
|
444
|
+
/**
|
|
445
|
+
* Validates that two sides' lifecycle timestamps strictly interleave.
|
|
446
|
+
*
|
|
447
|
+
* Exact transcription of `TermsLib.validateTermPairing`. Exactly one of
|
|
448
|
+
* the two chains must hold (every comparison strict — equal timestamps
|
|
449
|
+
* anywhere are rejected):
|
|
450
|
+
*
|
|
451
|
+
* ```text
|
|
452
|
+
* A proposes: A.commitmentDeadline < B.commitmentDeadline < A.claimDeadline
|
|
453
|
+
* < B.claimDeadline < A.reclaimRelease < B.reclaimRelease
|
|
454
|
+
* B proposes: the same chain with A and B swapped
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* The proposer is the side with the smaller `commitmentDeadline` and
|
|
458
|
+
* commits first. The interleaving is what bounds each side's risk — in a
|
|
459
|
+
* cross-chain swap it guarantees the taker a reaction buffer after the
|
|
460
|
+
* secret is revealed (see {@link validateCrossChainSchedule}).
|
|
461
|
+
*
|
|
462
|
+
* @param a - One side's terms.
|
|
463
|
+
* @param b - The other side's terms.
|
|
464
|
+
* @throws QuipSwapError `DISORDERED_DEADLINES` when neither interleaving
|
|
465
|
+
* holds (contract: DisordedDeadlines).
|
|
466
|
+
* @see TermsLib.validateTermPairing
|
|
467
|
+
* @example
|
|
468
|
+
* ```ts
|
|
469
|
+
* validateTermPairing(aliceTerms, bobTerms) // throws if the schedule is invalid
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
declare function validateTermPairing(a: Terms, b: Terms): void;
|
|
473
|
+
/**
|
|
474
|
+
* Identifies which side of a pairing proposed.
|
|
475
|
+
*
|
|
476
|
+
* Transcribes `TermsLib.proposedByParty`: the proposer is the side with
|
|
477
|
+
* the smaller `commitmentDeadline` (it commits first). Only meaningful
|
|
478
|
+
* after {@link validateTermPairing} has passed, which guarantees the
|
|
479
|
+
* commitment deadlines are strictly ordered and never equal.
|
|
480
|
+
*
|
|
481
|
+
* @param party - The first side's terms.
|
|
482
|
+
* @param counterparty - The second side's terms.
|
|
483
|
+
* @returns `'party'` if `party` proposed, `'counterparty'` otherwise.
|
|
484
|
+
* @see TermsLib.proposedByParty
|
|
485
|
+
* @example
|
|
486
|
+
* ```ts
|
|
487
|
+
* if (proposedBy(mine, theirs) === 'party') {
|
|
488
|
+
* // I commit first, in [0, mine.commitmentDeadline)
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
declare function proposedBy(party: Terms, counterparty: Terms): 'party' | 'counterparty';
|
|
493
|
+
|
|
494
|
+
/** `type(uint256).max` — the open upper bound of the reclaim window. */
|
|
495
|
+
declare const MAX_UINT256: bigint;
|
|
496
|
+
/**
|
|
497
|
+
* A half-open time window `[lower, upper)` in Unix seconds.
|
|
498
|
+
*/
|
|
499
|
+
interface TimeWindow {
|
|
500
|
+
/** Inclusive lower bound (Unix seconds). */
|
|
501
|
+
readonly lower: bigint;
|
|
502
|
+
/** EXCLUSIVE upper bound (Unix seconds); `MAX_UINT256` means unbounded. */
|
|
503
|
+
readonly upper: bigint;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Asserts `timestamp` lies within the half-open window `[lower, upper)`.
|
|
507
|
+
*
|
|
508
|
+
* Exact transcription of `TermsLib.enforceWithin`:
|
|
509
|
+
*
|
|
510
|
+
* ```solidity
|
|
511
|
+
* if (lower >= upper) revert InvalidRange();
|
|
512
|
+
* if (lower > timestamp || upper <= timestamp) revert WindowViolated();
|
|
513
|
+
* ```
|
|
514
|
+
*
|
|
515
|
+
* The upper bound is EXCLUSIVE: `timestamp === upper` is rejected.
|
|
516
|
+
*
|
|
517
|
+
* @param lower - Inclusive lower bound (Unix seconds).
|
|
518
|
+
* @param upper - Exclusive upper bound (Unix seconds).
|
|
519
|
+
* @param timestamp - The instant to test (pass the chain's `block.timestamp`).
|
|
520
|
+
* @throws QuipSwapError `INVALID_RANGE` when `lower >= upper` (degenerate
|
|
521
|
+
* window — contract: InvalidRange); `WINDOW_VIOLATED` when the timestamp
|
|
522
|
+
* is before `lower` or at/after `upper` (contract: WindowViolated).
|
|
523
|
+
* @see TermsLib.enforceWithin
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* enforceWithin(0n, 1000n, 999n) // ok
|
|
527
|
+
* enforceWithin(0n, 1000n, 1000n) // throws WINDOW_VIOLATED (upper exclusive)
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
declare function enforceWithin(lower: bigint, upper: bigint, timestamp: bigint): void;
|
|
531
|
+
/**
|
|
532
|
+
* Non-throwing variant of {@link enforceWithin}.
|
|
533
|
+
*
|
|
534
|
+
* @param window - The half-open window to test.
|
|
535
|
+
* @param timestamp - The instant to test (Unix seconds).
|
|
536
|
+
* @returns `true` iff `window.lower <= timestamp < window.upper` and the
|
|
537
|
+
* window is non-degenerate.
|
|
538
|
+
*/
|
|
539
|
+
declare function isWithinWindow(window: TimeWindow, timestamp: bigint): boolean;
|
|
540
|
+
/**
|
|
541
|
+
* The proposer's commit window: `[0, proposer.commitmentDeadline)`.
|
|
542
|
+
*
|
|
543
|
+
* Enforced by `Omnibus.commit` via
|
|
544
|
+
* `enforceWithin(0, party.commitmentDeadline, block.timestamp)` on the
|
|
545
|
+
* proposer path.
|
|
546
|
+
*
|
|
547
|
+
* @param proposer - The proposer's terms (the side with the earlier `commitmentDeadline`).
|
|
548
|
+
* @returns The half-open commit window for the proposer.
|
|
549
|
+
* @see Omnibus.commit
|
|
550
|
+
*/
|
|
551
|
+
declare function proposerCommitWindow(proposer: Terms): TimeWindow;
|
|
552
|
+
/**
|
|
553
|
+
* The taker's commit window:
|
|
554
|
+
* `[proposer.commitmentDeadline, taker.commitmentDeadline)`.
|
|
555
|
+
*
|
|
556
|
+
* The taker can only commit AFTER the proposer's commitment deadline has
|
|
557
|
+
* elapsed — enforced by `Omnibus.commit` via
|
|
558
|
+
* `enforceWithin(counterparty.commitmentDeadline, party.commitmentDeadline, block.timestamp)`.
|
|
559
|
+
* A taker commit attempted while the proposer's window is still open
|
|
560
|
+
* reverts with `WindowViolated`.
|
|
561
|
+
*
|
|
562
|
+
* @param taker - The taker's terms.
|
|
563
|
+
* @param proposer - The proposer's terms.
|
|
564
|
+
* @returns The half-open commit window for the taker.
|
|
565
|
+
* @see Omnibus.commit
|
|
566
|
+
*/
|
|
567
|
+
declare function takerCommitWindow(taker: Terms, proposer: Terms): TimeWindow;
|
|
568
|
+
/**
|
|
569
|
+
* The proposer's claim window:
|
|
570
|
+
* `[taker.commitmentDeadline, proposer.claimDeadline)`.
|
|
571
|
+
*
|
|
572
|
+
* Enforced by `Omnibus.claim` when the claimant role is the proposer:
|
|
573
|
+
* `enforceWithin(counterparty.commitmentDeadline, party.claimDeadline, block.timestamp)`.
|
|
574
|
+
*
|
|
575
|
+
* @param proposer - The proposer's terms.
|
|
576
|
+
* @param taker - The taker's terms.
|
|
577
|
+
* @returns The half-open claim window for the proposer (secret holder).
|
|
578
|
+
* @see Omnibus.claim
|
|
579
|
+
*/
|
|
580
|
+
declare function proposerClaimWindow(proposer: Terms, taker: Terms): TimeWindow;
|
|
581
|
+
/**
|
|
582
|
+
* The taker's claim window:
|
|
583
|
+
* `[proposer.claimDeadline, proposer.reclaimRelease)`.
|
|
584
|
+
*
|
|
585
|
+
* Enforced by `Omnibus.claim` when the claimant role is the taker:
|
|
586
|
+
* `enforceWithin(counterparty.claimDeadline, counterparty.reclaimRelease, block.timestamp)`
|
|
587
|
+
* (the counterparty is the proposer on this path). The width of this
|
|
588
|
+
* window, `proposer.reclaimRelease - proposer.claimDeadline`, is the
|
|
589
|
+
* taker's post-reveal reaction buffer in a cross-chain swap.
|
|
590
|
+
*
|
|
591
|
+
* @param proposer - The proposer's terms (the claim is gated on the PROPOSER's schedule).
|
|
592
|
+
* @returns The half-open claim window for the taker.
|
|
593
|
+
* @see Omnibus.claim
|
|
594
|
+
*/
|
|
595
|
+
declare function takerClaimWindow(proposer: Terms): TimeWindow;
|
|
596
|
+
/**
|
|
597
|
+
* The reclaim window for one leg: `[leg.reclaimRelease, +infinity)`.
|
|
598
|
+
*
|
|
599
|
+
* Enforced by `Omnibus.reclaim` via
|
|
600
|
+
* `enforceWithin(party.reclaimRelease, type(uint256).max, block.timestamp)`.
|
|
601
|
+
* Reclaim never closes once open.
|
|
602
|
+
*
|
|
603
|
+
* @param leg - The terms of the leg being reclaimed.
|
|
604
|
+
* @returns The half-open reclaim window (upper bound `MAX_UINT256`).
|
|
605
|
+
* @see Omnibus.reclaim
|
|
606
|
+
*/
|
|
607
|
+
declare function reclaimWindow(leg: Terms): TimeWindow;
|
|
608
|
+
/**
|
|
609
|
+
* Validates that `currentTimestamp` lies inside the commit window for the
|
|
610
|
+
* role `party` plays in the pairing — exactly the check `Omnibus.commit`
|
|
611
|
+
* performs:
|
|
612
|
+
*
|
|
613
|
+
* - `party` is the proposer: `[0, party.commitmentDeadline)`
|
|
614
|
+
* - `party` is the taker: `[counterparty.commitmentDeadline, party.commitmentDeadline)`
|
|
615
|
+
*
|
|
616
|
+
* @param party - The committing side's terms.
|
|
617
|
+
* @param counterparty - The other side's terms.
|
|
618
|
+
* @param currentTimestamp - The chain's current `block.timestamp` (Unix
|
|
619
|
+
* seconds) — pass an explicit value; this helper never reads a clock.
|
|
620
|
+
* @throws QuipSwapError `WINDOW_VIOLATED` | `INVALID_RANGE` as in
|
|
621
|
+
* {@link enforceWithin}.
|
|
622
|
+
* @see Omnibus.commit
|
|
623
|
+
* @example
|
|
624
|
+
* ```ts
|
|
625
|
+
* const block = await publicClient.getBlock()
|
|
626
|
+
* validateCommitWindow(myTerms, theirTerms, block.timestamp)
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
declare function validateCommitWindow(party: Terms, counterparty: Terms, currentTimestamp: bigint): void;
|
|
630
|
+
/**
|
|
631
|
+
* Validates that `currentTimestamp` lies inside the claim window for the
|
|
632
|
+
* role `party` plays — exactly the check `Omnibus.claim` performs:
|
|
633
|
+
*
|
|
634
|
+
* - `party` is the proposer: `[counterparty.commitmentDeadline, party.claimDeadline)`
|
|
635
|
+
* - `party` is the taker: `[counterparty.claimDeadline, counterparty.reclaimRelease)`
|
|
636
|
+
*
|
|
637
|
+
* @param party - The claimant role's terms (the side the claimant acts for).
|
|
638
|
+
* @param counterparty - The other side's terms (the leg being claimed).
|
|
639
|
+
* @param currentTimestamp - The chain's current `block.timestamp` (Unix seconds).
|
|
640
|
+
* @throws QuipSwapError `WINDOW_VIOLATED` | `INVALID_RANGE` as in
|
|
641
|
+
* {@link enforceWithin}.
|
|
642
|
+
* @see Omnibus.claim
|
|
643
|
+
*/
|
|
644
|
+
declare function validateClaimWindow(party: Terms, counterparty: Terms, currentTimestamp: bigint): void;
|
|
645
|
+
/**
|
|
646
|
+
* Validates that `currentTimestamp` has reached the reclaim window of the
|
|
647
|
+
* leg being reclaimed — exactly the check `Omnibus.reclaim` performs:
|
|
648
|
+
* `[party.reclaimRelease, type(uint256).max)`.
|
|
649
|
+
*
|
|
650
|
+
* @param party - The terms of the leg being reclaimed.
|
|
651
|
+
* @param currentTimestamp - The chain's current `block.timestamp` (Unix seconds).
|
|
652
|
+
* @throws QuipSwapError `WINDOW_VIOLATED` when the release has not elapsed.
|
|
653
|
+
* @see Omnibus.reclaim
|
|
654
|
+
*/
|
|
655
|
+
declare function validateReclaimWindow(party: Terms, currentTimestamp: bigint): void;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The ABI parameter description of the `Asset[]` array — the SINGLE source
|
|
659
|
+
* of truth for the Asset tuple shape in the SDK. `assetType` is a Solidity
|
|
660
|
+
* enum, encoded as `uint8` in the ABI.
|
|
661
|
+
*
|
|
662
|
+
* @see TermsLib (struct Asset)
|
|
663
|
+
*/
|
|
664
|
+
declare const assetArrayAbiParameter: {
|
|
665
|
+
readonly name: "assets";
|
|
666
|
+
readonly type: "tuple[]";
|
|
667
|
+
readonly components: readonly [{
|
|
668
|
+
readonly name: "assetType";
|
|
669
|
+
readonly type: "uint8";
|
|
670
|
+
}, {
|
|
671
|
+
readonly name: "target";
|
|
672
|
+
readonly type: "address";
|
|
673
|
+
}, {
|
|
674
|
+
readonly name: "id";
|
|
675
|
+
readonly type: "uint256";
|
|
676
|
+
}, {
|
|
677
|
+
readonly name: "amount";
|
|
678
|
+
readonly type: "uint256";
|
|
679
|
+
}];
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* The ABI parameter description of the full `Terms` tuple — the SINGLE
|
|
683
|
+
* source of truth for the Terms shape. Used to decode the `Commitment`
|
|
684
|
+
* event's `party` field back into a typed {@link Terms}.
|
|
685
|
+
*
|
|
686
|
+
* Note: {@link digestTerms} does NOT use this tuple — the contract hashes
|
|
687
|
+
* `abi.encode(field1, ..., field7)` (seven separate top-level values), not
|
|
688
|
+
* `abi.encode(struct)`; for a single dynamic struct argument those two
|
|
689
|
+
* encodings differ by a leading offset word.
|
|
690
|
+
*
|
|
691
|
+
* @see TermsLib (struct Terms), IOmnibus.Commitment
|
|
692
|
+
*/
|
|
693
|
+
declare const termsAbiParameter: {
|
|
694
|
+
readonly name: "terms";
|
|
695
|
+
readonly type: "tuple";
|
|
696
|
+
readonly components: readonly [{
|
|
697
|
+
readonly name: "chainId";
|
|
698
|
+
readonly type: "uint256";
|
|
699
|
+
}, {
|
|
700
|
+
readonly name: "reclaimRecipient";
|
|
701
|
+
readonly type: "address";
|
|
702
|
+
}, {
|
|
703
|
+
readonly name: "recipient";
|
|
704
|
+
readonly type: "address";
|
|
705
|
+
}, {
|
|
706
|
+
readonly name: "commitmentDeadline";
|
|
707
|
+
readonly type: "uint256";
|
|
708
|
+
}, {
|
|
709
|
+
readonly name: "claimDeadline";
|
|
710
|
+
readonly type: "uint256";
|
|
711
|
+
}, {
|
|
712
|
+
readonly name: "reclaimRelease";
|
|
713
|
+
readonly type: "uint256";
|
|
714
|
+
}, {
|
|
715
|
+
readonly name: "assets";
|
|
716
|
+
readonly type: "tuple[]";
|
|
717
|
+
readonly components: readonly [{
|
|
718
|
+
readonly name: "assetType";
|
|
719
|
+
readonly type: "uint8";
|
|
720
|
+
}, {
|
|
721
|
+
readonly name: "target";
|
|
722
|
+
readonly type: "address";
|
|
723
|
+
}, {
|
|
724
|
+
readonly name: "id";
|
|
725
|
+
readonly type: "uint256";
|
|
726
|
+
}, {
|
|
727
|
+
readonly name: "amount";
|
|
728
|
+
readonly type: "uint256";
|
|
729
|
+
}];
|
|
730
|
+
}];
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Computes the digest of a single side's terms.
|
|
734
|
+
*
|
|
735
|
+
* Exact transcription of `TermsLib.digestTerms`:
|
|
736
|
+
*
|
|
737
|
+
* ```solidity
|
|
738
|
+
* digest = EfficientHashLib.hash( // keccak256(bytes)
|
|
739
|
+
* abi.encode(
|
|
740
|
+
* terms.chainId, terms.reclaimRecipient, terms.recipient,
|
|
741
|
+
* terms.commitmentDeadline, terms.claimDeadline, terms.reclaimRelease,
|
|
742
|
+
* terms.assets
|
|
743
|
+
* )
|
|
744
|
+
* );
|
|
745
|
+
* ```
|
|
746
|
+
*
|
|
747
|
+
* Standard (head/tail) ABI encoding of SEVEN top-level values — not packed
|
|
748
|
+
* encoding, and not the encoding of a single `Terms` struct. The asset
|
|
749
|
+
* order matters: reordering assets changes the digest.
|
|
750
|
+
*
|
|
751
|
+
* @param terms - The side's terms.
|
|
752
|
+
* @returns The 32-byte digest used for `posted` tracking and canonical ordering.
|
|
753
|
+
* @see TermsLib.digestTerms
|
|
754
|
+
* @example
|
|
755
|
+
* ```ts
|
|
756
|
+
* const digest = digestTerms(aliceTerms)
|
|
757
|
+
* const isPosted = await client.posted(lock, digest)
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
declare function digestTerms(terms: Terms): Hex32;
|
|
761
|
+
/**
|
|
762
|
+
* Computes the canonical digest of a terms pair, identical regardless of
|
|
763
|
+
* which side is passed first.
|
|
764
|
+
*
|
|
765
|
+
* Exact transcription of `TermsLib.digestTermsCanonically`:
|
|
766
|
+
* 1. Digest each side independently with {@link digestTerms}.
|
|
767
|
+
* 2. Compare the two digests as unsigned 256-bit integers — NOT as strings
|
|
768
|
+
* (string comparison is locale/casing-sensitive and does not match
|
|
769
|
+
* Solidity's `uint256(a) < uint256(b)`).
|
|
770
|
+
* 3. Concatenate the raw 32-byte values, smaller digest first.
|
|
771
|
+
* 4. keccak256 the 64-byte concatenation (matching
|
|
772
|
+
* `EfficientHashLib.hash(bytes32, bytes32)`).
|
|
773
|
+
*
|
|
774
|
+
* This is the value stored in `Omnibus.termsHash[lock]`; both chains of a
|
|
775
|
+
* cross-chain swap must derive it identically.
|
|
776
|
+
*
|
|
777
|
+
* @param party - One side's terms (order does not matter).
|
|
778
|
+
* @param counterparty - The other side's terms.
|
|
779
|
+
* @returns The canonical 32-byte digest of the pair.
|
|
780
|
+
* @see TermsLib.digestTermsCanonically
|
|
781
|
+
* @example
|
|
782
|
+
* ```ts
|
|
783
|
+
* digestTermsCanonically(a, b) === digestTermsCanonically(b, a) // always true
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
declare function digestTermsCanonically(party: Terms, counterparty: Terms): Hex32;
|
|
787
|
+
/**
|
|
788
|
+
* Derives the hashlock from a secret.
|
|
789
|
+
*
|
|
790
|
+
* Exact transcription of `Omnibus._generateLock`: keccak256 over the raw
|
|
791
|
+
* 32-byte secret (matching `EfficientHashLib.hash(bytes32)` — no length
|
|
792
|
+
* prefix, no ABI encoding).
|
|
793
|
+
*
|
|
794
|
+
* @param secret - A 32-byte hex preimage (`0x` + 64 hex chars). Validated
|
|
795
|
+
* before hashing — externally supplied secrets of the wrong length would
|
|
796
|
+
* otherwise silently produce a lock that can never be claimed.
|
|
797
|
+
* @returns The 32-byte lock, `keccak256(secret)`.
|
|
798
|
+
* @throws QuipSwapError `INVALID_HEX32` if `secret` is not exactly 32 bytes
|
|
799
|
+
* of valid hex.
|
|
800
|
+
* @see Omnibus._generateLock
|
|
801
|
+
* @example
|
|
802
|
+
* ```ts
|
|
803
|
+
* const lock = generateLock('0x' + '11'.repeat(32) as Hex32)
|
|
804
|
+
* ```
|
|
805
|
+
*/
|
|
806
|
+
declare function generateLock(secret: Hex32): Hex32;
|
|
807
|
+
/**
|
|
808
|
+
* Asserts a value is exactly 32 bytes of valid hex (`0x` + 64 hex chars).
|
|
809
|
+
*
|
|
810
|
+
* @param value - The value to check.
|
|
811
|
+
* @param label - Name used in the error message (e.g. `"secret"`, `"lock"`).
|
|
812
|
+
* @throws QuipSwapError `INVALID_HEX32` when malformed or the wrong length.
|
|
813
|
+
*/
|
|
814
|
+
declare function assertHex32(value: string, label: string): asserts value is Hex32;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Generates a fresh 32-byte secret and its lock.
|
|
818
|
+
*
|
|
819
|
+
* Uses `crypto.getRandomValues` (the runtime's CSPRNG — available in
|
|
820
|
+
* browsers, Node.js >= 19, and Bun). Never uses `Math.random()`,
|
|
821
|
+
* timestamps, counters, or any other predictable source: a guessable
|
|
822
|
+
* secret lets an attacker claim the counterparty's escrowed assets.
|
|
823
|
+
*
|
|
824
|
+
* @returns A {@link SecretLockPair} where `lock === generateLock(secret)`.
|
|
825
|
+
* Keep `secret` private until claim; `lock` is safe to share.
|
|
826
|
+
* @see Omnibus._generateLock
|
|
827
|
+
* @example
|
|
828
|
+
* ```ts
|
|
829
|
+
* const {secret, lock} = generateSecret()
|
|
830
|
+
* // share `lock` with the counterparty; keep `secret` private
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
declare function generateSecret(): SecretLockPair;
|
|
834
|
+
/**
|
|
835
|
+
* Validates an externally supplied secret and derives its lock.
|
|
836
|
+
*
|
|
837
|
+
* Use this instead of {@link generateLock} when the secret comes from
|
|
838
|
+
* storage or another process and you want the validated pair back.
|
|
839
|
+
*
|
|
840
|
+
* @param secret - A 0x-prefixed 32-byte hex string.
|
|
841
|
+
* @returns The validated {@link SecretLockPair}.
|
|
842
|
+
* @throws QuipSwapError `INVALID_HEX32` if the secret is malformed or not
|
|
843
|
+
* exactly 32 bytes (the error never echoes the supplied value).
|
|
844
|
+
* @example
|
|
845
|
+
* ```ts
|
|
846
|
+
* const pair = secretToPair(loadSecretFromVault())
|
|
847
|
+
* ```
|
|
848
|
+
*/
|
|
849
|
+
declare function secretToPair(secret: string): SecretLockPair;
|
|
850
|
+
|
|
851
|
+
/** A verified Omnibus deployment on one chain. */
|
|
852
|
+
interface OmnibusDeployment {
|
|
853
|
+
/** The chain id the deployment lives on. */
|
|
854
|
+
readonly chainId: bigint;
|
|
855
|
+
/** The Omnibus singleton address on that chain. */
|
|
856
|
+
readonly omnibusAddress: Address;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* The canonical CREATE3 Omnibus address, sourced from `address.json`.
|
|
860
|
+
*
|
|
861
|
+
* CREATE3 (via the canonical Deployer contract) derives the address from
|
|
862
|
+
* (Deployer contract, salt) — both chain-independent — so a single Omnibus
|
|
863
|
+
* deployed via `script/DeployOmnibus.s.sol` has the SAME address on every
|
|
864
|
+
* chain.
|
|
865
|
+
*
|
|
866
|
+
* ⚠️ Currently the zero PLACEHOLDER (`address.json`). To activate: set
|
|
867
|
+
* `omnibusAddress` in `address.json` to the real deployed address, run
|
|
868
|
+
* `make verify-omnibus` (offline: confirms it matches the predicted
|
|
869
|
+
* (Deployer, salt) address), confirm on-chain that the correct Omnibus sits
|
|
870
|
+
* there for each target chain (CREATE3 addresses ignore init code, so
|
|
871
|
+
* semantic verification is mandatory), and add those chain ids to `chains`.
|
|
872
|
+
* No code change required.
|
|
873
|
+
*/
|
|
874
|
+
declare const OMNIBUS_CREATE3_ADDRESS: Address;
|
|
875
|
+
/**
|
|
876
|
+
* Built-in verified deployments, keyed by chain id. Derived from
|
|
877
|
+
* {@link OMNIBUS_CREATE3_ADDRESS} + {@link VERIFIED_DEPLOYMENT_CHAINS} so
|
|
878
|
+
* there is a single source of truth. EMPTY until the placeholder address is
|
|
879
|
+
* replaced and chains are enabled (identical behavior to the prior empty
|
|
880
|
+
* registry while empty).
|
|
881
|
+
*/
|
|
882
|
+
declare const knownDeployments: ReadonlyMap<bigint, OmnibusDeployment>;
|
|
883
|
+
/**
|
|
884
|
+
* Resolves the Omnibus address for a chain.
|
|
885
|
+
*
|
|
886
|
+
* Resolution order: an explicit `override` wins; otherwise the built-in
|
|
887
|
+
* {@link knownDeployments} registry is consulted.
|
|
888
|
+
*
|
|
889
|
+
* @param chainId - The target chain id.
|
|
890
|
+
* @param override - Optional application-supplied deployment for this chain.
|
|
891
|
+
* @returns The resolved deployment.
|
|
892
|
+
* @throws QuipSwapError `UNKNOWN_DEPLOYMENT` when no verified deployment
|
|
893
|
+
* exists and no override was provided, or when the override is malformed
|
|
894
|
+
* or names a different chain.
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* const {omnibusAddress} = resolveDeployment(8453n, {
|
|
898
|
+
* chainId: 8453n,
|
|
899
|
+
* omnibusAddress: '0x...', // your verified deployment
|
|
900
|
+
* })
|
|
901
|
+
* ```
|
|
902
|
+
*/
|
|
903
|
+
declare function resolveDeployment(chainId: bigint, override?: OmnibusDeployment): OmnibusDeployment;
|
|
904
|
+
|
|
905
|
+
/** Default gas-limit safety multiplier: a 20% margin over the node's estimate. */
|
|
906
|
+
declare const DEFAULT_GAS_MULTIPLIER = 1.2;
|
|
907
|
+
/** Multiplier floor; anything below 1.0 risks out-of-gas by construction. */
|
|
908
|
+
declare const MIN_GAS_MULTIPLIER = 1;
|
|
909
|
+
/** Multiplier ceiling; caps the damage of a misconfigured value. */
|
|
910
|
+
declare const MAX_GAS_MULTIPLIER = 2;
|
|
911
|
+
/**
|
|
912
|
+
* Per-transaction options accepted by every write method (`commit`,
|
|
913
|
+
* `claim`, `reclaim`, and all `admin.*` writes). All fields optional;
|
|
914
|
+
* everything unset falls back to viem's automatic behavior.
|
|
915
|
+
*/
|
|
916
|
+
interface TxOptions {
|
|
917
|
+
/**
|
|
918
|
+
* Explicit gas limit. When set, THREE things are skipped: (a) gas
|
|
919
|
+
* estimation, (b) the safety multiplier, and (c) the pre-submission
|
|
920
|
+
* revert check — because `estimateContractGas` is also what catches a
|
|
921
|
+
* would-be revert before broadcast, and it does not run. The protocol
|
|
922
|
+
* preflights still run, but a call that would revert is signed and
|
|
923
|
+
* broadcast anyway and burns its gas. Use an explicit `gas` only when the
|
|
924
|
+
* call is known to succeed (e.g. replaying a previously simulated call)
|
|
925
|
+
* and you accept on-chain revert risk; leave `gas` unset to keep the
|
|
926
|
+
* revert check, and use {@link TxOptions.gasMultiplier} if you only want
|
|
927
|
+
* to tune the buffer.
|
|
928
|
+
*/
|
|
929
|
+
readonly gas?: bigint;
|
|
930
|
+
/**
|
|
931
|
+
* Gas-limit safety multiplier: `gas = floor(estimate * multiplier)`,
|
|
932
|
+
* computed with bigint-safe 3-decimal math (never a bigint×float
|
|
933
|
+
* multiplication). Defaults to {@link DEFAULT_GAS_MULTIPLIER}; clamped
|
|
934
|
+
* to [{@link MIN_GAS_MULTIPLIER}, {@link MAX_GAS_MULTIPLIER}];
|
|
935
|
+
* non-finite values fall back to the MIN (no buffer).
|
|
936
|
+
*/
|
|
937
|
+
readonly gasMultiplier?: number;
|
|
938
|
+
/** EIP-1559 total fee ceiling per gas, in wei (exclusive with `gasPrice`). */
|
|
939
|
+
readonly maxFeePerGas?: bigint;
|
|
940
|
+
/** EIP-1559 priority tip per gas, in wei (exclusive with `gasPrice`). */
|
|
941
|
+
readonly maxPriorityFeePerGas?: bigint;
|
|
942
|
+
/** Legacy gas price, in wei, for non-EIP-1559 chains (exclusive with the two fields above). */
|
|
943
|
+
readonly gasPrice?: bigint;
|
|
944
|
+
/** Pin the transaction nonce; by default viem fetches the next nonce. */
|
|
945
|
+
readonly nonce?: number;
|
|
946
|
+
/**
|
|
947
|
+
* Skips the stage-1 BALANCE preflight ONLY (the bare-call-value check
|
|
948
|
+
* that runs before gas estimation; see {@link preflightBalanceCheck}).
|
|
949
|
+
* The protocol preflights (windows, pairing, chain id, lock state) ALWAYS
|
|
950
|
+
* run — they are correctness checks, not robustness checks.
|
|
951
|
+
*/
|
|
952
|
+
readonly skipPreflightChecks?: boolean;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Resolves the effective gas multiplier from {@link TxOptions}.
|
|
956
|
+
*
|
|
957
|
+
* Rules (deterministic, inspectable by tests and callers):
|
|
958
|
+
* - unset → {@link DEFAULT_GAS_MULTIPLIER}
|
|
959
|
+
* - non-finite (`NaN`, `±Infinity`) → {@link MIN_GAS_MULTIPLIER} (no buffer)
|
|
960
|
+
* - otherwise clamped into [{@link MIN_GAS_MULTIPLIER}, {@link MAX_GAS_MULTIPLIER}]
|
|
961
|
+
*
|
|
962
|
+
* @param opts - The caller's transaction options (only `gasMultiplier` is read).
|
|
963
|
+
* @returns The clamped multiplier that {@link applyGasMultiplier} will use.
|
|
964
|
+
*/
|
|
965
|
+
declare function resolveGasMultiplier(opts?: TxOptions): number;
|
|
966
|
+
/**
|
|
967
|
+
* Applies the resolved safety multiplier to a gas estimate.
|
|
968
|
+
*
|
|
969
|
+
* Bigint-safe and deterministic: the multiplier is rounded to exactly
|
|
970
|
+
* 3 decimal places by integer scaling — a bigint is never multiplied by a
|
|
971
|
+
* float, so large estimates cannot pick up float round-trip drift:
|
|
972
|
+
*
|
|
973
|
+
* ```ts
|
|
974
|
+
* const scaled = Math.round(multiplier * 1000)
|
|
975
|
+
* gas = (estimate * BigInt(scaled)) / 1000n
|
|
976
|
+
* ```
|
|
977
|
+
*
|
|
978
|
+
* @param estimate - The node's gas estimate (from `estimateContractGas`).
|
|
979
|
+
* @param opts - Transaction options; see {@link resolveGasMultiplier}.
|
|
980
|
+
* @returns The buffered gas limit, `floor(estimate * multiplier)`.
|
|
981
|
+
*/
|
|
982
|
+
declare function applyGasMultiplier(estimate: bigint, opts?: TxOptions): bigint;
|
|
983
|
+
/**
|
|
984
|
+
* The fee fields forwarded to `writeContract` — containing ONLY the fields
|
|
985
|
+
* the caller explicitly set, so viem's automatic fee pricing keeps working
|
|
986
|
+
* for everything unset. `undefined` fee fields are never passed through.
|
|
987
|
+
*/
|
|
988
|
+
interface FeeOverrides {
|
|
989
|
+
readonly maxFeePerGas?: bigint;
|
|
990
|
+
readonly maxPriorityFeePerGas?: bigint;
|
|
991
|
+
readonly gasPrice?: bigint;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Builds the {@link FeeOverrides} object from caller options.
|
|
995
|
+
*
|
|
996
|
+
* @param opts - Transaction options.
|
|
997
|
+
* @returns An object with only the explicitly-set fee fields present.
|
|
998
|
+
*/
|
|
999
|
+
declare function buildFeeOverrides(opts?: TxOptions): FeeOverrides;
|
|
1000
|
+
/** The contract call being prepared (the exact params `estimateContractGas` receives). */
|
|
1001
|
+
interface PrepareTxContractParams {
|
|
1002
|
+
readonly address: Address;
|
|
1003
|
+
readonly abi: Abi;
|
|
1004
|
+
readonly functionName: string;
|
|
1005
|
+
readonly args?: readonly unknown[];
|
|
1006
|
+
/** Native value attached to the call (payable functions only). */
|
|
1007
|
+
readonly value?: bigint;
|
|
1008
|
+
/** The sender address — estimation and the balance preflight both use it. */
|
|
1009
|
+
readonly account: Address;
|
|
1010
|
+
}
|
|
1011
|
+
/** Arguments for {@link prepareTx}. */
|
|
1012
|
+
interface PrepareTxArgs {
|
|
1013
|
+
readonly publicClient: PublicClient;
|
|
1014
|
+
readonly contractParams: PrepareTxContractParams;
|
|
1015
|
+
/**
|
|
1016
|
+
* The total native value the sender must pay for the call itself, in wei
|
|
1017
|
+
* — for commit exactly `totalNative(party) + commitmentFee`; `0n` for
|
|
1018
|
+
* claim/reclaim/admin. The balance preflight checks this bare value only
|
|
1019
|
+
* (gas funding is deliberately not preflighted — see
|
|
1020
|
+
* {@link preflightBalanceCheck}); value-less calls skip the check.
|
|
1021
|
+
*/
|
|
1022
|
+
readonly totalValue: bigint;
|
|
1023
|
+
readonly opts?: TxOptions;
|
|
1024
|
+
}
|
|
1025
|
+
/** The prepared transaction fields, ready to spread into `writeContract`. */
|
|
1026
|
+
interface PreparedTx {
|
|
1027
|
+
/** The gas limit to submit with (buffered unless `opts.gas` was set). */
|
|
1028
|
+
readonly gas: bigint;
|
|
1029
|
+
/** Only the caller's explicitly-set fee fields (see {@link FeeOverrides}). */
|
|
1030
|
+
readonly fees: FeeOverrides;
|
|
1031
|
+
/** Present only when the caller pinned a nonce. */
|
|
1032
|
+
readonly nonce?: number;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Throws `BALANCE_TOO_LOW` if the account's balance is below `required`.
|
|
1036
|
+
*
|
|
1037
|
+
* No-op when `required <= 0n` — value-less calls (claim/reclaim/admin)
|
|
1038
|
+
* have no balance preflight; their send-time funds failures are mapped to
|
|
1039
|
+
* `BALANCE_TOO_LOW` in `submitWrite` (see client.ts). Only the bare call
|
|
1040
|
+
* value is checked: gas funding is deliberately NOT preflighted (it is the
|
|
1041
|
+
* wallet application's concern in the WalletConnect flow).
|
|
1042
|
+
*
|
|
1043
|
+
* @param publicClient - The Viem public client to read the balance through.
|
|
1044
|
+
* @param account - The sender whose balance is checked.
|
|
1045
|
+
* @param required - The native value (wei) the call itself must carry.
|
|
1046
|
+
* @throws QuipSwapError `BALANCE_TOO_LOW` (with `{required, balance}` in
|
|
1047
|
+
* details) when the balance cannot cover `required`.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function preflightBalanceCheck(publicClient: PublicClient, account: Address, required: bigint): Promise<void>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Prepares a write: balance preflight, then gas estimation (or an explicit
|
|
1052
|
+
* limit) with the safety multiplier.
|
|
1053
|
+
*
|
|
1054
|
+
* Stage order:
|
|
1055
|
+
* 1. **Balance preflight** (unless `opts.skipPreflightChecks`) — BEFORE
|
|
1056
|
+
* estimation, bare `totalValue` only ({@link preflightBalanceCheck}).
|
|
1057
|
+
* Running it first fixes a masking bug by construction: any sender
|
|
1058
|
+
* reaching estimation already covers the value, and viem attaches no
|
|
1059
|
+
* gas price to `eth_estimateGas`, so the node cannot fail estimation on
|
|
1060
|
+
* funds — insufficient funds can no longer masquerade as
|
|
1061
|
+
* `GAS_ESTIMATION_FAILED`.
|
|
1062
|
+
* 2. **Gas** — explicit `opts.gas` is used verbatim (no estimation, no
|
|
1063
|
+
* multiplier, and therefore NO pre-submission revert check). Otherwise
|
|
1064
|
+
* `publicClient.estimateContractGas` runs the call node-side, so a
|
|
1065
|
+
* contract revert surfaces HERE, decoded into a
|
|
1066
|
+
* `CONTRACT_REVERT` error with `contractErrorName` — this stage is the
|
|
1067
|
+
* pre-submission revert check that replaced `simulateContract` — and
|
|
1068
|
+
* the estimate is buffered by {@link applyGasMultiplier}.
|
|
1069
|
+
*
|
|
1070
|
+
* @param args - See {@link PrepareTxArgs}.
|
|
1071
|
+
* @returns The {@link PreparedTx} to spread into `writeContract`.
|
|
1072
|
+
* @throws QuipSwapError `BALANCE_TOO_LOW` (with `{required, balance}` in
|
|
1073
|
+
* details) when the sender cannot cover the call value;
|
|
1074
|
+
* `CONTRACT_REVERT` (with `contractErrorName`) when the call would
|
|
1075
|
+
* revert; `GAS_ESTIMATION_FAILED` when estimation fails for a non-revert
|
|
1076
|
+
* reason (network error, bad params).
|
|
1077
|
+
* @example
|
|
1078
|
+
* ```ts
|
|
1079
|
+
* const prepared = await prepareTx({publicClient, contractParams, totalValue: 0n, opts})
|
|
1080
|
+
* await walletClient.writeContract({...contractParams, gas: prepared.gas, ...prepared.fees})
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
declare function prepareTx(args: PrepareTxArgs): Promise<PreparedTx>;
|
|
1084
|
+
|
|
1085
|
+
/** A decoded `Commitment` event. */
|
|
1086
|
+
interface CommitmentEvent {
|
|
1087
|
+
/** The hashlock the commitment is bound to (indexed topic). */
|
|
1088
|
+
readonly lock: Hex32;
|
|
1089
|
+
/** The committing side's FULL terms, recovered from event data. */
|
|
1090
|
+
readonly party: Terms;
|
|
1091
|
+
/** The QuipWallet that committed (indexed topic). */
|
|
1092
|
+
readonly committer: Address;
|
|
1093
|
+
/** Block number the log was found in (`null` for pending logs). */
|
|
1094
|
+
readonly blockNumber: bigint | null;
|
|
1095
|
+
/** Transaction hash the log was found in (`null` for pending logs). */
|
|
1096
|
+
readonly transactionHash: Hex32 | null;
|
|
1097
|
+
/** Log index within the block (`null` for pending logs). */
|
|
1098
|
+
readonly logIndex: number | null;
|
|
1099
|
+
}
|
|
1100
|
+
/** A decoded `Claim` event. The `secret` field is public once emitted. */
|
|
1101
|
+
interface ClaimEvent {
|
|
1102
|
+
/** The address that called `claim` (event data, NOT the asset recipient per se). */
|
|
1103
|
+
readonly recipient: Address;
|
|
1104
|
+
/** The hashlock that was claimed (indexed topic — the only filterable field). */
|
|
1105
|
+
readonly lock: Hex32;
|
|
1106
|
+
/** The revealed 32-byte preimage. Public from this moment on. */
|
|
1107
|
+
readonly secret: Hex32;
|
|
1108
|
+
readonly blockNumber: bigint | null;
|
|
1109
|
+
readonly transactionHash: Hex32 | null;
|
|
1110
|
+
readonly logIndex: number | null;
|
|
1111
|
+
}
|
|
1112
|
+
/** A decoded `Reclaimed` event. Two may appear in a single transaction. */
|
|
1113
|
+
interface ReclaimedEvent {
|
|
1114
|
+
/** The address that called `reclaim` (permissionless — any account). */
|
|
1115
|
+
readonly caller: Address;
|
|
1116
|
+
/** The hashlock that was reclaimed (indexed topic). */
|
|
1117
|
+
readonly lock: Hex32;
|
|
1118
|
+
/** The `reclaimRecipient` that received this leg's assets (indexed topic). */
|
|
1119
|
+
readonly recipient: Address;
|
|
1120
|
+
readonly blockNumber: bigint | null;
|
|
1121
|
+
readonly transactionHash: Hex32 | null;
|
|
1122
|
+
readonly logIndex: number | null;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Decodes every `Commitment` event in a list of logs (e.g. from a receipt
|
|
1126
|
+
* or `getLogs`), recovering the committing side's full typed {@link Terms}
|
|
1127
|
+
* from event data — this is how a coordinator reconstructs a side's terms
|
|
1128
|
+
* from chain history without an off-chain channel.
|
|
1129
|
+
*
|
|
1130
|
+
* Non-`Commitment` logs are skipped, not errors.
|
|
1131
|
+
*
|
|
1132
|
+
* NOTE: a raw ABI decoder — it does NOT verify `log.address`, so it decodes
|
|
1133
|
+
* any `Commitment`-shaped log in `logs`. Scope `logs` to the known Omnibus
|
|
1134
|
+
* deployment first (prefer `client.waitForReceipt` /
|
|
1135
|
+
* `waitForOmnibusReceipt(..., {address})`, or the address-scoped
|
|
1136
|
+
* {@link getCommitmentEvents}).
|
|
1137
|
+
*
|
|
1138
|
+
* @param logs - Pre-scoped logs (a receipt's `logs` array or a `getLogs` result).
|
|
1139
|
+
* @returns All decoded `Commitment` events, in log order.
|
|
1140
|
+
* @see IOmnibus.Commitment
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```ts
|
|
1143
|
+
* // PREFERRED: client.waitForReceipt scopes decoding to the Omnibus address
|
|
1144
|
+
* const {commitments} = await client.waitForReceipt(hash)
|
|
1145
|
+
* commitments[0]?.party.assets // typed Asset[]
|
|
1146
|
+
*
|
|
1147
|
+
* // low-level: only on logs ALREADY scoped to the Omnibus address
|
|
1148
|
+
* const scoped = receipt.logs.filter(l => l.address.toLowerCase() === omnibus.toLowerCase())
|
|
1149
|
+
* const [commitment] = decodeCommitmentEvents(scoped)
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
declare function decodeCommitmentEvents(logs: readonly Log[]): CommitmentEvent[];
|
|
1153
|
+
/**
|
|
1154
|
+
* Decodes every `Claim` event in a list of logs.
|
|
1155
|
+
*
|
|
1156
|
+
* The `secret` field is the revealed preimage: in a cross-chain swap this
|
|
1157
|
+
* is how the taker (or a relayer) learns the secret after the proposer
|
|
1158
|
+
* claims — watch the counterparty chain for `Claim` on the shared lock and
|
|
1159
|
+
* extract `secret`.
|
|
1160
|
+
*
|
|
1161
|
+
* NOTE: This helper does NOT filter by Omnibus contract address — it decodes
|
|
1162
|
+
* any log in `logs` whose shape matches the `Claim` ABI. Callers passing
|
|
1163
|
+
* unscoped logs (e.g. a full receipt or a broad `getLogs` result) may pick up
|
|
1164
|
+
* unrelated contracts. {@link extractRevealedSecret} inherits this behavior
|
|
1165
|
+
* and can then return a spoofed secret if a non-Omnibus log mimics `Claim`.
|
|
1166
|
+
* Prefer {@link getClaimEvents} / {@link watchClaimEvents} (address-scoped)
|
|
1167
|
+
* or pre-filter `logs` to the known Omnibus deployment before decoding.
|
|
1168
|
+
*
|
|
1169
|
+
* @param logs - Raw logs to scan; non-`Claim` logs are skipped.
|
|
1170
|
+
* @returns All decoded `Claim` events, in log order.
|
|
1171
|
+
* @see IOmnibus.Claim
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* // PREFERRED: client.waitForReceipt scopes decoding to the Omnibus address
|
|
1175
|
+
* const {claims} = await client.waitForReceipt(hash)
|
|
1176
|
+
* const secret = extractSecretFromClaims(claims, lock) // verified + scoped
|
|
1177
|
+
*
|
|
1178
|
+
* // low-level: only on logs ALREADY scoped to the Omnibus address
|
|
1179
|
+
* const scoped = receipt.logs.filter(l => l.address.toLowerCase() === omnibus.toLowerCase())
|
|
1180
|
+
* const someClaim = decodeClaimEvents(scoped)[0]?.secret // now public on-chain
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
declare function decodeClaimEvents(logs: readonly Log[]): ClaimEvent[];
|
|
1184
|
+
/**
|
|
1185
|
+
* Extracts the revealed secret for a specific lock from a list of logs.
|
|
1186
|
+
*
|
|
1187
|
+
* Verifies the cryptographic relationship before returning: a `Claim` event
|
|
1188
|
+
* is accepted only when both its indexed `lock` equals the requested lock
|
|
1189
|
+
* AND `generateLock(event.secret)` hashes back to that lock. This rejects a
|
|
1190
|
+
* same-shaped fake `Claim(lock, wrongSecret)` whose `secret` does not
|
|
1191
|
+
* actually open the lock.
|
|
1192
|
+
*
|
|
1193
|
+
* Idempotent by construction: duplicate `Claim` logs for the same lock
|
|
1194
|
+
* carry the same secret (the lock is `keccak256(secret)`, so only one
|
|
1195
|
+
* preimage can ever satisfy it), so processing the same event twice
|
|
1196
|
+
* returns the same value.
|
|
1197
|
+
*
|
|
1198
|
+
* SECURITY: this does NOT filter by `log.address` — it inherits the
|
|
1199
|
+
* raw-log/address behavior of the decoders. Scope `logs` to the correct
|
|
1200
|
+
* Omnibus address first (prefer `client.waitForReceipt`,
|
|
1201
|
+
* `waitForOmnibusReceipt(..., {address})`, or the address-scoped
|
|
1202
|
+
* `getClaimEvents`/`watchClaimEvents`), or extract from an already-scoped
|
|
1203
|
+
* decoded {@link ClaimEvent} array via {@link extractSecretFromClaims}.
|
|
1204
|
+
*
|
|
1205
|
+
* @param logs - Raw logs to scan (receipt logs or a `getLogs` result).
|
|
1206
|
+
* @param lock - The lock whose secret to extract.
|
|
1207
|
+
* @returns The 32-byte secret, or `undefined` when no `Claim` for the lock
|
|
1208
|
+
* carries a secret that hashes to it.
|
|
1209
|
+
* @see IOmnibus.Claim, Omnibus._generateLock
|
|
1210
|
+
* @example
|
|
1211
|
+
* ```ts
|
|
1212
|
+
* // prefer scoped claims; only use raw logs you have already address-scoped
|
|
1213
|
+
* const secret = extractRevealedSecret(scopedChainBLogs, lock)
|
|
1214
|
+
* if (secret) await chainAClient.claim({secret, party: bobTerms, counterparty: aliceTerms})
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
declare function extractRevealedSecret(logs: readonly Log[], lock: Hex32): Hex32 | undefined;
|
|
1218
|
+
/**
|
|
1219
|
+
* Extracts the revealed secret for a lock from already-decoded `Claim`
|
|
1220
|
+
* events — the safe, address-scoped path (the events typically come from
|
|
1221
|
+
* {@link OmnibusReceipt.claims}, which `client.waitForReceipt` /
|
|
1222
|
+
* `waitForOmnibusReceipt(..., {address})` already filter by `log.address`).
|
|
1223
|
+
*
|
|
1224
|
+
* Like {@link extractRevealedSecret} it verifies `generateLock(secret)`
|
|
1225
|
+
* hashes back to the requested lock, so a fake `Claim(lock, wrongSecret)`
|
|
1226
|
+
* is ignored.
|
|
1227
|
+
*
|
|
1228
|
+
* @param claims - Decoded `Claim` events (e.g. `receipt.claims`).
|
|
1229
|
+
* @param lock - The lock whose secret to extract.
|
|
1230
|
+
* @returns The 32-byte secret, or `undefined` when none matches.
|
|
1231
|
+
* @see IOmnibus.Claim, Omnibus._generateLock
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```ts
|
|
1234
|
+
* const receipt = await aliceOnB.waitForReceipt(claimHash)
|
|
1235
|
+
* const secret = extractSecretFromClaims(receipt.claims, lock)
|
|
1236
|
+
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
declare function extractSecretFromClaims(claims: readonly ClaimEvent[], lock: Hex32): Hex32 | undefined;
|
|
1239
|
+
/**
|
|
1240
|
+
* Decodes every `Reclaimed` event in a list of logs.
|
|
1241
|
+
*
|
|
1242
|
+
* IMPORTANT: one reclaim transaction can legitimately emit TWO `Reclaimed`
|
|
1243
|
+
* events — when the counterparty leg is local and the lock was `Committed`,
|
|
1244
|
+
* both legs return to their respective `reclaimRecipient` addresses in one
|
|
1245
|
+
* call. Always handle the array, never assume a single event.
|
|
1246
|
+
*
|
|
1247
|
+
* NOTE: a raw ABI decoder — it does NOT verify `log.address`. Scope `logs`
|
|
1248
|
+
* to the known Omnibus deployment first (prefer `client.waitForReceipt` /
|
|
1249
|
+
* `waitForOmnibusReceipt(..., {address})`, or {@link getReclaimedEvents}).
|
|
1250
|
+
*
|
|
1251
|
+
* @param logs - Pre-scoped logs to scan; non-`Reclaimed` logs are skipped.
|
|
1252
|
+
* @returns All decoded `Reclaimed` events, in log order.
|
|
1253
|
+
* @see IOmnibus.Reclaimed, Omnibus.reclaim
|
|
1254
|
+
*/
|
|
1255
|
+
declare function decodeReclaimedEvents(logs: readonly Log[]): ReclaimedEvent[];
|
|
1256
|
+
/** Common arguments for historical event queries. */
|
|
1257
|
+
interface EventQueryArgs {
|
|
1258
|
+
/** The Viem public client to query through. */
|
|
1259
|
+
readonly publicClient: PublicClient;
|
|
1260
|
+
/** The Omnibus contract address — always filter by contract address. */
|
|
1261
|
+
readonly address: Address;
|
|
1262
|
+
/** Restrict results to one lock (indexed topic) when provided. */
|
|
1263
|
+
readonly lock?: Hex32;
|
|
1264
|
+
/** Inclusive starting block; supply a deployment block to bound the scan. */
|
|
1265
|
+
readonly fromBlock?: BlockNumber | BlockTag;
|
|
1266
|
+
/** Inclusive ending block. */
|
|
1267
|
+
readonly toBlock?: BlockNumber | BlockTag;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Queries historical `Commitment` events via `publicClient.getLogs`.
|
|
1271
|
+
*
|
|
1272
|
+
* Reorg caveat: a log returned here reflects the chain at query time only.
|
|
1273
|
+
* Re-query (or compare block hashes) after your confirmation depth before
|
|
1274
|
+
* acting on it.
|
|
1275
|
+
*
|
|
1276
|
+
* @param args - See {@link EventQueryArgs}.
|
|
1277
|
+
* @returns Decoded events in chain order.
|
|
1278
|
+
* @example
|
|
1279
|
+
* ```ts
|
|
1280
|
+
* const history = await getCommitmentEvents({publicClient, address, lock})
|
|
1281
|
+
* ```
|
|
1282
|
+
*/
|
|
1283
|
+
declare function getCommitmentEvents(args: EventQueryArgs): Promise<CommitmentEvent[]>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Queries historical `Claim` events via `publicClient.getLogs`.
|
|
1286
|
+
*
|
|
1287
|
+
* @param args - See {@link EventQueryArgs}.
|
|
1288
|
+
* @returns Decoded events in chain order. Apply your confirmation policy
|
|
1289
|
+
* before treating a revealed secret's claim as settled.
|
|
1290
|
+
*/
|
|
1291
|
+
declare function getClaimEvents(args: EventQueryArgs): Promise<ClaimEvent[]>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Queries historical `Reclaimed` events via `publicClient.getLogs`.
|
|
1294
|
+
*
|
|
1295
|
+
* @param args - See {@link EventQueryArgs}.
|
|
1296
|
+
* @returns Decoded events in chain order (possibly two per transaction).
|
|
1297
|
+
*/
|
|
1298
|
+
declare function getReclaimedEvents(args: EventQueryArgs): Promise<ReclaimedEvent[]>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Watches for live `Claim` events on a lock — the cross-chain coordinator's
|
|
1301
|
+
* tool for learning the revealed secret promptly.
|
|
1302
|
+
*
|
|
1303
|
+
* This is an OPTIONAL convenience; the SDK never requires a permanently
|
|
1304
|
+
* running watcher. The callback may fire more than once for the same claim
|
|
1305
|
+
* (duplicates, reorg re-emission) — {@link extractRevealedSecret}'s
|
|
1306
|
+
* idempotence makes acting on duplicates safe.
|
|
1307
|
+
*
|
|
1308
|
+
* @param args - Query args plus the callback.
|
|
1309
|
+
* @param args.onClaim - Invoked with each decoded `Claim` event observed.
|
|
1310
|
+
* @returns The unwatch function from Viem; call it to stop watching.
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```ts
|
|
1313
|
+
* const stop = watchClaimEvents({publicClient, address, lock, onClaim: e => use(e.secret)})
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
declare function watchClaimEvents(args: Omit<EventQueryArgs, 'fromBlock' | 'toBlock'> & {
|
|
1317
|
+
readonly onClaim: (event: ClaimEvent) => void;
|
|
1318
|
+
}): () => void;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Receipt helpers.
|
|
1322
|
+
*
|
|
1323
|
+
* A returned transaction hash is NOT confirmation: the transaction may
|
|
1324
|
+
* still be pending, may revert, or may be dropped/replaced. These helpers
|
|
1325
|
+
* wait for a receipt, check `status`, and decode the relevant Omnibus
|
|
1326
|
+
* events into typed results.
|
|
1327
|
+
*
|
|
1328
|
+
* Address-scoped decoding: when `options.address` is supplied, only logs
|
|
1329
|
+
* emitted by that address are decoded — preventing another contract in the
|
|
1330
|
+
* same transaction from emitting an Omnibus-shaped `Commitment`/`Claim`/
|
|
1331
|
+
* `Reclaimed` event that the receipt helper would otherwise decode as
|
|
1332
|
+
* genuine. Prefer the client-bound {@link OmnibusClient.waitForReceipt},
|
|
1333
|
+
* which passes the client's Omnibus address automatically. Omitting
|
|
1334
|
+
* `address` keeps the legacy raw behavior (decode every matching log) for
|
|
1335
|
+
* backward compatibility, but is NOT recommended for security-sensitive
|
|
1336
|
+
* flows.
|
|
1337
|
+
*
|
|
1338
|
+
* Submission ({@link OmnibusClient.commit} et al.) and receipt waiting are
|
|
1339
|
+
* deliberately separate so the application chooses its own confirmation
|
|
1340
|
+
* count, timeout, retry, and finality policy per call.
|
|
1341
|
+
*/
|
|
1342
|
+
|
|
1343
|
+
/** Options forwarded to `publicClient.waitForTransactionReceipt`, plus address scoping. */
|
|
1344
|
+
interface WaitOptions {
|
|
1345
|
+
/**
|
|
1346
|
+
* The expected Omnibus contract address. When set, only logs emitted by
|
|
1347
|
+
* this address are decoded into `commitments`/`claims`/`reclaims` — the
|
|
1348
|
+
* defense against same-signature events from other contracts in the same
|
|
1349
|
+
* transaction. Omitting it decodes every matching log (legacy behavior;
|
|
1350
|
+
* not recommended). {@link OmnibusClient.waitForReceipt} fills this in.
|
|
1351
|
+
*/
|
|
1352
|
+
readonly address?: Address;
|
|
1353
|
+
/** Number of confirmations to wait for (default: the client's default, 1). */
|
|
1354
|
+
readonly confirmations?: number;
|
|
1355
|
+
/** Milliseconds to wait before giving up. */
|
|
1356
|
+
readonly timeout?: number;
|
|
1357
|
+
}
|
|
1358
|
+
/** A successful, decoded Omnibus transaction result. */
|
|
1359
|
+
interface OmnibusReceipt {
|
|
1360
|
+
/** The transaction hash that was waited on. */
|
|
1361
|
+
readonly transactionHash: Hash;
|
|
1362
|
+
/** The full Viem receipt (status is guaranteed `'success'`). */
|
|
1363
|
+
readonly receipt: TransactionReceipt;
|
|
1364
|
+
/** Decoded `Commitment` events emitted by the transaction (0 or 1). */
|
|
1365
|
+
readonly commitments: readonly CommitmentEvent[];
|
|
1366
|
+
/** Decoded `Claim` events emitted by the transaction (0 or 1). */
|
|
1367
|
+
readonly claims: readonly ClaimEvent[];
|
|
1368
|
+
/** Decoded `Reclaimed` events (0, 1, or 2 — dual-leg reclaims emit two). */
|
|
1369
|
+
readonly reclaims: readonly ReclaimedEvent[];
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Waits for a transaction receipt, verifies it succeeded, and decodes all
|
|
1373
|
+
* Omnibus events it emitted.
|
|
1374
|
+
*
|
|
1375
|
+
* @param publicClient - The Viem public client to poll through.
|
|
1376
|
+
* @param hash - The transaction hash returned by a write method.
|
|
1377
|
+
* @param options - `address` (strongly recommended — scopes decoding to the
|
|
1378
|
+
* Omnibus deployment; see {@link WaitOptions}), plus confirmation count
|
|
1379
|
+
* and timeout. Pick confirmations per your finality policy — one
|
|
1380
|
+
* confirmation on a reorg-prone chain is weak evidence.
|
|
1381
|
+
* @returns The typed {@link OmnibusReceipt}; `commitments`/`claims`/
|
|
1382
|
+
* `reclaims` contain only events from `options.address` when supplied.
|
|
1383
|
+
* @throws QuipSwapError `TRANSACTION_REVERTED` when the receipt status is
|
|
1384
|
+
* `'reverted'`; `CONTRACT_REVERT` (with `cause`) when waiting itself
|
|
1385
|
+
* fails (timeout, replacement, RPC error).
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* // prefer client.waitForReceipt; standalone form must pass the address:
|
|
1389
|
+
* const hash = await client.commit({lock, party, counterparty})
|
|
1390
|
+
* const {commitments} = await waitForOmnibusReceipt(publicClient, hash, {
|
|
1391
|
+
* address: omnibusAddress,
|
|
1392
|
+
* confirmations: 3,
|
|
1393
|
+
* })
|
|
1394
|
+
* console.log(commitments[0]?.lock)
|
|
1395
|
+
* ```
|
|
1396
|
+
*/
|
|
1397
|
+
declare function waitForOmnibusReceipt(publicClient: PublicClient, hash: Hash, options?: WaitOptions): Promise<OmnibusReceipt>;
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Minimal `IQuipFactory` surface consumed by the SDK — exactly what the
|
|
1401
|
+
* Omnibus `onlyQuipWallet` modifier reads.
|
|
1402
|
+
*
|
|
1403
|
+
* @see IQuipFactory.vaultIdOf
|
|
1404
|
+
*/
|
|
1405
|
+
declare const quipFactoryAbi: readonly [{
|
|
1406
|
+
readonly type: "function";
|
|
1407
|
+
readonly name: "vaultIdOf";
|
|
1408
|
+
readonly stateMutability: "view";
|
|
1409
|
+
readonly inputs: readonly [{
|
|
1410
|
+
readonly name: "wallet";
|
|
1411
|
+
readonly type: "address";
|
|
1412
|
+
}];
|
|
1413
|
+
readonly outputs: readonly [{
|
|
1414
|
+
readonly name: "vaultId";
|
|
1415
|
+
readonly type: "bytes32";
|
|
1416
|
+
}];
|
|
1417
|
+
}];
|
|
1418
|
+
/** Arguments for {@link createOmnibusClient}. */
|
|
1419
|
+
interface CreateOmnibusClientArgs {
|
|
1420
|
+
/** The deployed Omnibus contract address (see {@link resolveDeployment}). */
|
|
1421
|
+
readonly address: Address;
|
|
1422
|
+
/** A Viem public client connected to the chain the contract lives on. */
|
|
1423
|
+
readonly publicClient: PublicClient;
|
|
1424
|
+
/**
|
|
1425
|
+
* A Viem wallet client for writes. Optional: a read-only client works
|
|
1426
|
+
* without one, and writes then fail with `MISSING_WALLET_CLIENT`. In
|
|
1427
|
+
* production the COMMIT sender must be a QuipWallet contract; claim and
|
|
1428
|
+
* reclaim may be sent by any account.
|
|
1429
|
+
*/
|
|
1430
|
+
readonly walletClient?: WalletClient;
|
|
1431
|
+
}
|
|
1432
|
+
/** Arguments for {@link OmnibusClient.commit}. */
|
|
1433
|
+
interface CommitArgs {
|
|
1434
|
+
/** The hashlock (`generateLock(secret)`); the proposer generates the secret. */
|
|
1435
|
+
readonly lock: Hex32;
|
|
1436
|
+
/** The committing side's terms — the sender acts for this side. */
|
|
1437
|
+
readonly party: Terms;
|
|
1438
|
+
/** The other side's terms. */
|
|
1439
|
+
readonly counterparty: Terms;
|
|
1440
|
+
/**
|
|
1441
|
+
* When `true` (default), preflight additionally reads the lock's
|
|
1442
|
+
* on-chain state: a `Spent` or `Committed` lock rejects with
|
|
1443
|
+
* `INVALID_LOCK_STATE` (no commit can advance from those states), and a
|
|
1444
|
+
* `Free` lock requires the canonical `termsHash` to match
|
|
1445
|
+
* (`TERMS_NOT_ON_CHAIN` otherwise) and the committing side to not
|
|
1446
|
+
* already be posted (`TERMS_ALREADY_POSTED` otherwise — the second
|
|
1447
|
+
* same-chain commit must post the OTHER side). Costs three extra
|
|
1448
|
+
* parallel reads; with the flag off, gas estimation still catches every
|
|
1449
|
+
* case as a decoded `CONTRACT_REVERT`.
|
|
1450
|
+
*/
|
|
1451
|
+
readonly verifyOnChainState?: boolean;
|
|
1452
|
+
}
|
|
1453
|
+
/** Arguments for {@link OmnibusClient.claim}. */
|
|
1454
|
+
interface ClaimArgs {
|
|
1455
|
+
/** The 32-byte preimage of the lock. Sending it on-chain reveals it publicly. */
|
|
1456
|
+
readonly secret: Hex32;
|
|
1457
|
+
/** The claimant role's terms (the side the claimant acts for). */
|
|
1458
|
+
readonly party: Terms;
|
|
1459
|
+
/** The other side's terms — the leg being claimed; must be local. */
|
|
1460
|
+
readonly counterparty: Terms;
|
|
1461
|
+
/**
|
|
1462
|
+
* When `true` (default), preflight additionally verifies on-chain state
|
|
1463
|
+
* in one parallel read batch: `lockState(lock)` must be `Committed`
|
|
1464
|
+
* (`INVALID_LOCK_STATE` otherwise, with the actual state and likely
|
|
1465
|
+
* cause), `termsHash(lock)` must equal the canonical digest, and the
|
|
1466
|
+
* counterparty's side must be `posted` (`TERMS_NOT_ON_CHAIN` otherwise).
|
|
1467
|
+
* Costs three extra parallel reads; disable only if you have just
|
|
1468
|
+
* verified the state yourself — estimation still catches everything.
|
|
1469
|
+
*/
|
|
1470
|
+
readonly verifyOnChainState?: boolean;
|
|
1471
|
+
}
|
|
1472
|
+
/** Arguments for {@link OmnibusClient.reclaim}. */
|
|
1473
|
+
interface ReclaimArgs {
|
|
1474
|
+
/** The hashlock identifying the swap. */
|
|
1475
|
+
readonly lock: Hex32;
|
|
1476
|
+
/** The terms of the leg being reclaimed (must be local to this chain). */
|
|
1477
|
+
readonly party: Terms;
|
|
1478
|
+
/** The other side's terms. */
|
|
1479
|
+
readonly counterparty: Terms;
|
|
1480
|
+
/**
|
|
1481
|
+
* When `true` (default), preflight additionally verifies on-chain state
|
|
1482
|
+
* in one parallel read batch: `lockState(lock)` must be `Free` or
|
|
1483
|
+
* `Committed` (`INVALID_LOCK_STATE` otherwise — `Unused` was never
|
|
1484
|
+
* committed, `Spent` was already settled), `termsHash(lock)` must equal
|
|
1485
|
+
* the canonical digest, and the party's side must be `posted`
|
|
1486
|
+
* (`TERMS_NOT_ON_CHAIN` otherwise).
|
|
1487
|
+
*/
|
|
1488
|
+
readonly verifyOnChainState?: boolean;
|
|
1489
|
+
}
|
|
1490
|
+
/** Owner-only administrative operations (Ownable2Step). */
|
|
1491
|
+
interface OmnibusAdmin {
|
|
1492
|
+
/**
|
|
1493
|
+
* Sets the commitment fee. Owner only; reverts `FeeExceedsMax` above
|
|
1494
|
+
* `MAX_FEE`, `OwnableUnauthorizedAccount` for non-owners.
|
|
1495
|
+
*
|
|
1496
|
+
* @param newFee - The new fee in wei; must be `<= MAX_FEE`.
|
|
1497
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1498
|
+
* @returns The transaction hash.
|
|
1499
|
+
* @throws QuipSwapError `MISSING_WALLET_CLIENT` | `CONTRACT_REVERT` |
|
|
1500
|
+
* `GAS_ESTIMATION_FAILED` | `BALANCE_TOO_LOW`.
|
|
1501
|
+
* @see Omnibus.setCommitmentFee
|
|
1502
|
+
*/
|
|
1503
|
+
setCommitmentFee(newFee: bigint, opts?: TxOptions): Promise<Hash>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Withdraws all accrued fees to `to`. Owner only. Escrowed swap native is
|
|
1506
|
+
* NOT withdrawable — only accrued fees.
|
|
1507
|
+
*
|
|
1508
|
+
* @param to - The recipient of the accrued fees.
|
|
1509
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1510
|
+
* @returns The transaction hash.
|
|
1511
|
+
* @throws QuipSwapError `MISSING_WALLET_CLIENT` | `CONTRACT_REVERT` |
|
|
1512
|
+
* `GAS_ESTIMATION_FAILED` | `BALANCE_TOO_LOW`.
|
|
1513
|
+
* @see Omnibus.withdrawFees
|
|
1514
|
+
*/
|
|
1515
|
+
withdrawFees(to: Address, opts?: TxOptions): Promise<Hash>;
|
|
1516
|
+
/**
|
|
1517
|
+
* Starts the two-step ownership transfer (Ownable2Step): the new owner
|
|
1518
|
+
* must later call {@link acceptOwnership}.
|
|
1519
|
+
*
|
|
1520
|
+
* @param newOwner - The proposed new owner.
|
|
1521
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1522
|
+
* @returns The transaction hash.
|
|
1523
|
+
* @see Ownable2Step.transferOwnership
|
|
1524
|
+
*/
|
|
1525
|
+
transferOwnership(newOwner: Address, opts?: TxOptions): Promise<Hash>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Completes a pending two-step ownership transfer; must be sent by the
|
|
1528
|
+
* pending owner.
|
|
1529
|
+
*
|
|
1530
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1531
|
+
* @returns The transaction hash.
|
|
1532
|
+
* @see Ownable2Step.acceptOwnership
|
|
1533
|
+
*/
|
|
1534
|
+
acceptOwnership(opts?: TxOptions): Promise<Hash>;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* A typed client bound to one deployed Omnibus contract.
|
|
1538
|
+
*
|
|
1539
|
+
* Created by {@link createOmnibusClient}. Read methods mirror the
|
|
1540
|
+
* contract's getters one-to-one; write methods preflight, estimate gas
|
|
1541
|
+
* with a safety buffer, and submit. Write methods return the transaction
|
|
1542
|
+
* HASH only — pair them with {@link OmnibusClient.waitForReceipt} to
|
|
1543
|
+
* confirm success and decode events (it scopes decoding to this client's
|
|
1544
|
+
* Omnibus address automatically).
|
|
1545
|
+
*/
|
|
1546
|
+
interface OmnibusClient {
|
|
1547
|
+
/** The Omnibus contract address this client is bound to. */
|
|
1548
|
+
readonly address: Address;
|
|
1549
|
+
/** The underlying public client (exposed for receipt/event helpers). */
|
|
1550
|
+
readonly publicClient: PublicClient;
|
|
1551
|
+
/** Reads the contract version. @see Omnibus.VERSION */
|
|
1552
|
+
getVersion(): Promise<bigint>;
|
|
1553
|
+
/** Reads the maximum settable commitment fee in wei. @see Omnibus.MAX_FEE */
|
|
1554
|
+
getMaxFee(): Promise<bigint>;
|
|
1555
|
+
/** Reads the QuipFactory address whose registry gates commit. @see Omnibus.QUIP_FACTORY */
|
|
1556
|
+
getQuipFactory(): Promise<Address>;
|
|
1557
|
+
/** Reads the current commitment fee in wei. @see Omnibus.commitmentFee */
|
|
1558
|
+
getCommitmentFee(): Promise<bigint>;
|
|
1559
|
+
/** Reads the withdrawable accrued fees in wei. @see Omnibus.accruedFees */
|
|
1560
|
+
getAccruedFees(): Promise<bigint>;
|
|
1561
|
+
/** Reads a lock's lifecycle state. @see Omnibus.lockState */
|
|
1562
|
+
getLockState(lock: Hex32): Promise<LockState>;
|
|
1563
|
+
/** Reads the canonical terms digest bound to a lock (zero if none). @see Omnibus.termsHash */
|
|
1564
|
+
getTermsHash(lock: Hex32): Promise<Hex32>;
|
|
1565
|
+
/** Reads whether a side's terms digest was posted for a lock. @see Omnibus.posted */
|
|
1566
|
+
getPosted(lock: Hex32, termsDigest: Hex32): Promise<boolean>;
|
|
1567
|
+
/** Reads the current owner. @see Ownable.owner */
|
|
1568
|
+
getOwner(): Promise<Address>;
|
|
1569
|
+
/** Reads the pending owner of an in-flight two-step transfer. @see Ownable2Step.pendingOwner */
|
|
1570
|
+
getPendingOwner(): Promise<Address>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Checks whether `account` passes the `onlyQuipWallet` gate: reads
|
|
1573
|
+
* `vaultIdOf(account)` on the contract's `QUIP_FACTORY` and reports
|
|
1574
|
+
* whether it is non-zero. Only factory-deployed QuipWallets can commit;
|
|
1575
|
+
* `commit` runs this as a preflight and rejects with `NOT_QUIP_WALLET`.
|
|
1576
|
+
*
|
|
1577
|
+
* @param account - The would-be commit sender (the QuipWallet contract
|
|
1578
|
+
* address, NOT its owner's EOA).
|
|
1579
|
+
* @returns `true` iff `vaultIdOf(account)` is non-zero (the account can commit).
|
|
1580
|
+
* @see Omnibus.commit (onlyQuipWallet), IQuipFactory.vaultIdOf
|
|
1581
|
+
*/
|
|
1582
|
+
isQuipWallet(account: Address): Promise<boolean>;
|
|
1583
|
+
/**
|
|
1584
|
+
* Commits the sender's side of a swap. QuipWallet-gated and payable.
|
|
1585
|
+
*
|
|
1586
|
+
* The contract gates commit with `onlyQuipWallet`
|
|
1587
|
+
* (`QUIP_FACTORY.vaultIdOf(msg.sender) != 0`), so the SDK preflights the
|
|
1588
|
+
* gate via {@link OmnibusClient.isQuipWallet} and rejects a non-wallet
|
|
1589
|
+
* sender with `NOT_QUIP_WALLET` BEFORE any estimation round-trip — this is
|
|
1590
|
+
* the most likely integration failure. The committer must be the QuipWallet
|
|
1591
|
+
* CONTRACT address, never its owner's EOA.
|
|
1592
|
+
*
|
|
1593
|
+
* Preflight (in order, all before any transaction exists):
|
|
1594
|
+
* 1. Both terms structurally valid; 2. pairing strictly interleaves;
|
|
1595
|
+
* 3. `party.chainId` matches the connected chain (`counterparty.chainId`
|
|
1596
|
+
* may differ — cross-chain); 4. the sender passes the QuipWallet gate
|
|
1597
|
+
* (`vaultIdOf != 0`); 5. the chain's current timestamp is inside the
|
|
1598
|
+
* sender's commit window — proposer `[0, party.commitmentDeadline)`,
|
|
1599
|
+
* taker `[counterparty.commitmentDeadline, party.commitmentDeadline)`
|
|
1600
|
+
* (the taker's window OPENS only when the proposer's deadline
|
|
1601
|
+
* elapses); 6. unless `verifyOnChainState` is disabled, the lock's
|
|
1602
|
+
* on-chain state permits this commit (see
|
|
1603
|
+
* {@link CommitArgs.verifyOnChainState}); 7. the fee is re-read;
|
|
1604
|
+
* 8. `msg.value` is computed as exactly
|
|
1605
|
+
* `totalNative(party) + commitmentFee` — the contract checks strict
|
|
1606
|
+
* equality (`IncorrectNativeAmountReceived`), so over- and
|
|
1607
|
+
* underpayment both revert; 9. the balance preflight runs (bare
|
|
1608
|
+
* `msg.value` only — gas funding is not preflighted); 10. gas is
|
|
1609
|
+
* estimated node-side (a would-be revert surfaces here, decoded) and
|
|
1610
|
+
* buffered by the safety multiplier; 11. submit.
|
|
1611
|
+
*
|
|
1612
|
+
* Unused gas is refunded, so the default 1.2x buffer costs nothing at
|
|
1613
|
+
* execution; it exists to prevent out-of-gas failures from state drift
|
|
1614
|
+
* between estimation and inclusion — which matters here because writes
|
|
1615
|
+
* happen inside closing time windows.
|
|
1616
|
+
*
|
|
1617
|
+
* @remarks
|
|
1618
|
+
* ⚠️ ASSET-LOSS RISK (cross-chain takers). If you are the TAKER in a
|
|
1619
|
+
* cross-chain swap and you commit before the PROPOSER has actually
|
|
1620
|
+
* committed on their chain, the proposer — who holds the secret — can
|
|
1621
|
+
* claim your escrowed leg while never funding their own, and your assets
|
|
1622
|
+
* are gone. The contract enforces the same-chain *window* ordering (the
|
|
1623
|
+
* taker cannot commit until the proposer's commitment deadline has passed)
|
|
1624
|
+
* and the same-chain lock-state guards prevent a taker-first commit from
|
|
1625
|
+
* ever draining the taker — but it CANNOT protect you cross-chain (your
|
|
1626
|
+
* chain cannot read the proposer's chain), where a taker-first commit
|
|
1627
|
+
* against an uncommitted proposer loses your funds. Before a cross-chain
|
|
1628
|
+
* taker commit, verify the
|
|
1629
|
+
* proposer's commitment yourself with
|
|
1630
|
+
* {@link verifyRemoteCommitment} against the proposer's chain and apply
|
|
1631
|
+
* your own confirmation depth; only then call `commit`. See the
|
|
1632
|
+
* "Security & risks" section of USAGE.md.
|
|
1633
|
+
*
|
|
1634
|
+
* @param args - See {@link CommitArgs}.
|
|
1635
|
+
* @param opts - Optional per-transaction gas/fee/nonce options
|
|
1636
|
+
* ({@link TxOptions}); `skipPreflightChecks` skips ONLY the balance
|
|
1637
|
+
* check, never the protocol preflights.
|
|
1638
|
+
* @returns The transaction hash (not finality — wait for the receipt).
|
|
1639
|
+
* @throws QuipSwapError `MISSING_WALLET_CLIENT` | `MISSING_ACCOUNT` |
|
|
1640
|
+
* structural codes from {@link validateTerms} | `DISORDERED_DEADLINES`
|
|
1641
|
+
* | `CHAIN_ID_MISMATCH` | `NOT_QUIP_WALLET` | `WINDOW_VIOLATED` |
|
|
1642
|
+
* `INVALID_LOCK_STATE` | `TERMS_ALREADY_POSTED` | `TERMS_NOT_ON_CHAIN` |
|
|
1643
|
+
* `GAS_ESTIMATION_FAILED` | `BALANCE_TOO_LOW` | `CONTRACT_REVERT`.
|
|
1644
|
+
* @see Omnibus.commit (onlyQuipWallet)
|
|
1645
|
+
* @example
|
|
1646
|
+
* ```ts
|
|
1647
|
+
* const hash = await client.commit({lock, party: myTerms, counterparty: theirTerms})
|
|
1648
|
+
* const result = await client.waitForReceipt(hash) // address-scoped decoding
|
|
1649
|
+
* ```
|
|
1650
|
+
*/
|
|
1651
|
+
commit(args: CommitArgs, opts?: TxOptions): Promise<Hash>;
|
|
1652
|
+
/**
|
|
1653
|
+
* Claims a swap by revealing the secret. PERMISSIONLESS — the contract
|
|
1654
|
+
* allows anyone holding the secret to claim; the SDK adds no caller
|
|
1655
|
+
* restriction. The transaction makes the secret PUBLIC.
|
|
1656
|
+
*
|
|
1657
|
+
* Same-chain note: when `party.chainId == counterparty.chainId`, one
|
|
1658
|
+
* claim settles BOTH legs (counterparty's assets to `party.recipient`,
|
|
1659
|
+
* party's assets to `counterparty.recipient`).
|
|
1660
|
+
*
|
|
1661
|
+
* Preflight: secret is valid 32-byte hex; both terms valid and paired;
|
|
1662
|
+
* `counterparty.chainId` matches the connected chain (the CLAIMED leg is
|
|
1663
|
+
* local; `party.chainId` may be remote in a cross-chain claim); the
|
|
1664
|
+
* timestamp is inside the claimant role's window; unless disabled, the
|
|
1665
|
+
* lock is `Committed` and its `termsHash`/`posted` state matches (see
|
|
1666
|
+
* {@link ClaimArgs.verifyOnChainState}); then balance preflight,
|
|
1667
|
+
* estimate+buffer gas (the pre-submission revert check), submit.
|
|
1668
|
+
*
|
|
1669
|
+
* @param args - See {@link ClaimArgs}.
|
|
1670
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1671
|
+
* @returns The transaction hash (not finality).
|
|
1672
|
+
* @throws QuipSwapError `INVALID_HEX32` | structural/pairing codes |
|
|
1673
|
+
* `CHAIN_ID_MISMATCH` | `WINDOW_VIOLATED` | `INVALID_LOCK_STATE` |
|
|
1674
|
+
* `TERMS_NOT_ON_CHAIN` | `MISSING_WALLET_CLIENT` |
|
|
1675
|
+
* `GAS_ESTIMATION_FAILED` | `BALANCE_TOO_LOW` | `CONTRACT_REVERT`.
|
|
1676
|
+
* @see Omnibus.claim
|
|
1677
|
+
*/
|
|
1678
|
+
claim(args: ClaimArgs, opts?: TxOptions): Promise<Hash>;
|
|
1679
|
+
/**
|
|
1680
|
+
* Reclaims escrowed assets after the local leg's `reclaimRelease`.
|
|
1681
|
+
* PERMISSIONLESS — assets always go to the terms' `reclaimRecipient`
|
|
1682
|
+
* regardless of caller, so the SDK adds no caller restriction.
|
|
1683
|
+
*
|
|
1684
|
+
* Dual-leg note: when the counterparty leg is also local and the lock is
|
|
1685
|
+
* `Committed`, one reclaim returns BOTH legs to their respective
|
|
1686
|
+
* `reclaimRecipient` addresses and emits two `Reclaimed` events. Reclaim
|
|
1687
|
+
* is also valid from `Free` (a half-committed same-chain swap).
|
|
1688
|
+
*
|
|
1689
|
+
* Preflight: terms valid and paired; `party.chainId` matches the
|
|
1690
|
+
* connected chain; current timestamp `>= party.reclaimRelease`; unless
|
|
1691
|
+
* disabled, the lock is `Free` or `Committed` and its
|
|
1692
|
+
* `termsHash`/`posted` state matches (see
|
|
1693
|
+
* {@link ReclaimArgs.verifyOnChainState}); then balance preflight,
|
|
1694
|
+
* estimate+buffer gas (the pre-submission revert check), submit.
|
|
1695
|
+
*
|
|
1696
|
+
* @param args - See {@link ReclaimArgs}.
|
|
1697
|
+
* @param opts - Optional per-transaction gas/fee/nonce options.
|
|
1698
|
+
* @returns The transaction hash (not finality).
|
|
1699
|
+
* @throws QuipSwapError structural/pairing codes | `CHAIN_ID_MISMATCH` |
|
|
1700
|
+
* `WINDOW_VIOLATED` | `INVALID_LOCK_STATE` | `TERMS_NOT_ON_CHAIN` |
|
|
1701
|
+
* `MISSING_WALLET_CLIENT` | `GAS_ESTIMATION_FAILED` |
|
|
1702
|
+
* `BALANCE_TOO_LOW` | `CONTRACT_REVERT`.
|
|
1703
|
+
* @see Omnibus.reclaim
|
|
1704
|
+
*/
|
|
1705
|
+
reclaim(args: ReclaimArgs, opts?: TxOptions): Promise<Hash>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Waits for a write's receipt, verifies success, and decodes the Omnibus
|
|
1708
|
+
* events — scoped to THIS client's Omnibus address, so a same-signature
|
|
1709
|
+
* event from another contract in the same transaction is never decoded as
|
|
1710
|
+
* genuine. This is the preferred way to confirm a `commit`/`claim`/
|
|
1711
|
+
* `reclaim`; you do not pass the address again.
|
|
1712
|
+
*
|
|
1713
|
+
* @param hash - The transaction hash returned by a write method.
|
|
1714
|
+
* @param options - Confirmation count and timeout ({@link WaitOptions});
|
|
1715
|
+
* `address` is always set to this client's Omnibus address, so you do
|
|
1716
|
+
* not pass it.
|
|
1717
|
+
* @returns The typed {@link OmnibusReceipt} with address-scoped events.
|
|
1718
|
+
* @throws QuipSwapError `TRANSACTION_REVERTED` | `CONTRACT_REVERT`.
|
|
1719
|
+
* @see waitForOmnibusReceipt
|
|
1720
|
+
* @example
|
|
1721
|
+
* ```ts
|
|
1722
|
+
* const hash = await client.commit({lock, party, counterparty})
|
|
1723
|
+
* const {commitments} = await client.waitForReceipt(hash, {confirmations: 3})
|
|
1724
|
+
* ```
|
|
1725
|
+
*/
|
|
1726
|
+
waitForReceipt(hash: Hash, options?: WaitOptions): Promise<OmnibusReceipt>;
|
|
1727
|
+
/** Owner-only operations, namespaced to avoid mixing with user flows. */
|
|
1728
|
+
readonly admin: OmnibusAdmin;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Creates a typed {@link OmnibusClient} bound to one deployed Omnibus.
|
|
1732
|
+
*
|
|
1733
|
+
* @param args - The contract address plus existing Viem clients; see
|
|
1734
|
+
* {@link CreateOmnibusClientArgs}. No private keys, RPC URLs, or
|
|
1735
|
+
* provider-specific objects are accepted — bring your own Viem clients.
|
|
1736
|
+
* @returns The client; see {@link OmnibusClient} for every method.
|
|
1737
|
+
* @example
|
|
1738
|
+
* ```ts
|
|
1739
|
+
* import {createPublicClient, createWalletClient, custom, http} from 'viem'
|
|
1740
|
+
*
|
|
1741
|
+
* const publicClient = createPublicClient({transport: http(rpcUrl)})
|
|
1742
|
+
* const walletClient = createWalletClient({transport: custom(window.ethereum)})
|
|
1743
|
+
* const client = createOmnibusClient({address: omnibusAddress, publicClient, walletClient})
|
|
1744
|
+
* const fee = await client.getCommitmentFee()
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
declare function createOmnibusClient(args: CreateOmnibusClientArgs): OmnibusClient;
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Approval inspection and planning for non-native assets.
|
|
1751
|
+
*
|
|
1752
|
+
* The committer is `msg.sender` of the commit transaction — in production a
|
|
1753
|
+
* QuipWallet CONTRACT (never its owner's EOA; see the QuipWallet gate on
|
|
1754
|
+
* `Omnibus.commit`). Assets must belong to that wallet and approvals must
|
|
1755
|
+
* be issued BY that wallet, so every check here asks: "can the Omnibus
|
|
1756
|
+
* contract pull this asset from the committing wallet?"
|
|
1757
|
+
*
|
|
1758
|
+
* Fee-on-transfer caveat: `Omnibus.commit` reconciles received balances
|
|
1759
|
+
* (`TermsLib.transferAssetsNoNative`). If an ERC-20/ERC-1155 delivers less
|
|
1760
|
+
* than the declared amount (fee-on-transfer, deflationary), commit reverts
|
|
1761
|
+
* with `UnexpectedAmountReceived` EVEN IF the approval plan is fully
|
|
1762
|
+
* satisfied. A satisfied plan is necessary, not sufficient.
|
|
1763
|
+
*/
|
|
1764
|
+
|
|
1765
|
+
/** ERC-20 approval status for one token (amounts aggregated across asset entries). */
|
|
1766
|
+
interface Erc20ApprovalItem {
|
|
1767
|
+
readonly kind: 'erc20';
|
|
1768
|
+
/** The token contract. */
|
|
1769
|
+
readonly token: Address;
|
|
1770
|
+
/** Sum of every asset entry for this token in the terms. */
|
|
1771
|
+
readonly requiredAllowance: bigint;
|
|
1772
|
+
/** `allowance(committer, omnibus)` at plan time. */
|
|
1773
|
+
readonly currentAllowance: bigint;
|
|
1774
|
+
/** `currentAllowance >= requiredAllowance`. */
|
|
1775
|
+
readonly satisfied: boolean;
|
|
1776
|
+
}
|
|
1777
|
+
/** ERC-721 approval status for one specific token id. */
|
|
1778
|
+
interface Erc721ApprovalItem {
|
|
1779
|
+
readonly kind: 'erc721';
|
|
1780
|
+
readonly token: Address;
|
|
1781
|
+
readonly tokenId: bigint;
|
|
1782
|
+
/** `getApproved(tokenId) == omnibus`. */
|
|
1783
|
+
readonly tokenApproved: boolean;
|
|
1784
|
+
/** `isApprovedForAll(committer, omnibus)`. */
|
|
1785
|
+
readonly operatorApproved: boolean;
|
|
1786
|
+
/** Either single-token or operator approval suffices. */
|
|
1787
|
+
readonly satisfied: boolean;
|
|
1788
|
+
}
|
|
1789
|
+
/** ERC-1155 approval status for one token contract (operator approval covers all ids). */
|
|
1790
|
+
interface Erc1155ApprovalItem {
|
|
1791
|
+
readonly kind: 'erc1155';
|
|
1792
|
+
readonly token: Address;
|
|
1793
|
+
/** `isApprovedForAll(committer, omnibus)`. */
|
|
1794
|
+
readonly operatorApproved: boolean;
|
|
1795
|
+
readonly satisfied: boolean;
|
|
1796
|
+
}
|
|
1797
|
+
/** One entry of an {@link ApprovalPlan}. */
|
|
1798
|
+
type ApprovalItem = Erc20ApprovalItem | Erc721ApprovalItem | Erc1155ApprovalItem;
|
|
1799
|
+
/** The result of {@link planApprovals}. */
|
|
1800
|
+
interface ApprovalPlan {
|
|
1801
|
+
/** The wallet whose assets will be pulled (the commit sender). */
|
|
1802
|
+
readonly committer: Address;
|
|
1803
|
+
/** The Omnibus contract that must be able to pull them. */
|
|
1804
|
+
readonly omnibusAddress: Address;
|
|
1805
|
+
/** One item per (token / token+id) requiring approval; empty if all-native. */
|
|
1806
|
+
readonly items: readonly ApprovalItem[];
|
|
1807
|
+
/** True iff every item is satisfied. */
|
|
1808
|
+
readonly satisfied: boolean;
|
|
1809
|
+
}
|
|
1810
|
+
/** Arguments for {@link planApprovals}. */
|
|
1811
|
+
interface PlanApprovalsArgs {
|
|
1812
|
+
/** Public client on the chain where `terms.chainId` points. */
|
|
1813
|
+
readonly publicClient: PublicClient;
|
|
1814
|
+
/** The deployed Omnibus address (the spender/operator to check for). */
|
|
1815
|
+
readonly omnibusAddress: Address;
|
|
1816
|
+
/**
|
|
1817
|
+
* The committing wallet — the QuipWallet CONTRACT address that will send
|
|
1818
|
+
* the commit transaction, NOT its owner's EOA.
|
|
1819
|
+
*/
|
|
1820
|
+
readonly committer: Address;
|
|
1821
|
+
/** The side's terms whose assets will be escrowed. */
|
|
1822
|
+
readonly terms: Terms;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Inspects on-chain approvals for every non-native asset in a side's terms
|
|
1826
|
+
* and returns a typed plan describing what is missing.
|
|
1827
|
+
*
|
|
1828
|
+
* Checks performed (mirroring what `TermsLib.transferAssetsNoNative` will
|
|
1829
|
+
* need at commit time):
|
|
1830
|
+
* - ERC-20: `allowance(committer, omnibus) >= sum(required amounts)` —
|
|
1831
|
+
* multiple entries of the same token are AGGREGATED.
|
|
1832
|
+
* - ERC-721: `getApproved(tokenId) == omnibus` OR
|
|
1833
|
+
* `isApprovedForAll(committer, omnibus)`.
|
|
1834
|
+
* - ERC-1155: `isApprovedForAll(committer, omnibus)`.
|
|
1835
|
+
*
|
|
1836
|
+
* Native assets need no approval (they ride along as `msg.value`).
|
|
1837
|
+
*
|
|
1838
|
+
* Note: nonstandard ERC-20s exist (missing return values, fee-on-transfer).
|
|
1839
|
+
* A satisfied plan does not guarantee commit success for fee-on-transfer
|
|
1840
|
+
* tokens — the contract reverts with `UnexpectedAmountReceived` when less
|
|
1841
|
+
* than the declared amount arrives.
|
|
1842
|
+
*
|
|
1843
|
+
* @param args - See {@link PlanApprovalsArgs}.
|
|
1844
|
+
* @returns The typed {@link ApprovalPlan}.
|
|
1845
|
+
* @throws QuipSwapError `CONTRACT_REVERT` when an allowance/approval read
|
|
1846
|
+
* itself reverts (e.g. a non-token target address).
|
|
1847
|
+
* @see TermsLib.transferAssetsNoNative
|
|
1848
|
+
* @example
|
|
1849
|
+
* ```ts
|
|
1850
|
+
* const plan = await planApprovals({publicClient, omnibusAddress, committer: quipWallet, terms})
|
|
1851
|
+
* for (const item of plan.items.filter(i => !i.satisfied)) {
|
|
1852
|
+
* const hash = await submitApproval({publicClient, walletClient, omnibusAddress, item, erc20Mode: 'exact'})
|
|
1853
|
+
* }
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
declare function planApprovals(args: PlanApprovalsArgs): Promise<ApprovalPlan>;
|
|
1857
|
+
/**
|
|
1858
|
+
* ERC-20 approval sizing. The choice is explicit because it is a real
|
|
1859
|
+
* trade-off the application must own:
|
|
1860
|
+
* - `'exact'` approves only the required amount (safer: a compromised or
|
|
1861
|
+
* buggy spender can take at most the swap amount; costs one approval per
|
|
1862
|
+
* swap).
|
|
1863
|
+
* - `'unlimited'` approves `type(uint256).max` (convenient: one approval
|
|
1864
|
+
* forever; risk: the spender can pull ANY future balance).
|
|
1865
|
+
*
|
|
1866
|
+
* The SDK never defaults to unlimited.
|
|
1867
|
+
*/
|
|
1868
|
+
type Erc20ApprovalMode = 'exact' | 'unlimited';
|
|
1869
|
+
/** Arguments for {@link submitApproval}. */
|
|
1870
|
+
interface SubmitApprovalArgs {
|
|
1871
|
+
/** Public client used for simulation. */
|
|
1872
|
+
readonly publicClient: PublicClient;
|
|
1873
|
+
/** Wallet client of the COMMITTER (the wallet that owns the assets). */
|
|
1874
|
+
readonly walletClient: WalletClient;
|
|
1875
|
+
/** The Omnibus address to approve as spender/operator. */
|
|
1876
|
+
readonly omnibusAddress: Address;
|
|
1877
|
+
/** The unsatisfied plan item to fix. */
|
|
1878
|
+
readonly item: ApprovalItem;
|
|
1879
|
+
/** REQUIRED for ERC-20 items: exact or unlimited (see {@link Erc20ApprovalMode}). */
|
|
1880
|
+
readonly erc20Mode?: Erc20ApprovalMode;
|
|
1881
|
+
/**
|
|
1882
|
+
* For ERC-721 items: `'token'` approves only the specific token id
|
|
1883
|
+
* (default — least privilege); `'operator'` grants `setApprovalForAll`.
|
|
1884
|
+
*/
|
|
1885
|
+
readonly erc721Mode?: 'token' | 'operator';
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Simulates and submits the approval transaction that satisfies one
|
|
1889
|
+
* unsatisfied {@link ApprovalItem}.
|
|
1890
|
+
*
|
|
1891
|
+
* Always simulates before writing (`simulateContract` → `writeContract`)
|
|
1892
|
+
* so approval failures surface as decoded errors, not burned gas. Nothing
|
|
1893
|
+
* is auto-approved: the application explicitly invokes this per item.
|
|
1894
|
+
*
|
|
1895
|
+
* @param args - See {@link SubmitApprovalArgs}.
|
|
1896
|
+
* @returns The transaction hash. Wait for its receipt before re-planning —
|
|
1897
|
+
* a hash alone does not mean the approval landed.
|
|
1898
|
+
* @throws QuipSwapError `MISSING_ACCOUNT` when the wallet client has no
|
|
1899
|
+
* account; `INVALID_RANGE` (mode missing for ERC-20); `CONTRACT_REVERT`
|
|
1900
|
+
* when simulation/submission fails.
|
|
1901
|
+
* @example
|
|
1902
|
+
* ```ts
|
|
1903
|
+
* const hash = await submitApproval({
|
|
1904
|
+
* publicClient, walletClient, omnibusAddress,
|
|
1905
|
+
* item: unsatisfiedItem, erc20Mode: 'exact',
|
|
1906
|
+
* })
|
|
1907
|
+
* await publicClient.waitForTransactionReceipt({hash})
|
|
1908
|
+
* ```
|
|
1909
|
+
*/
|
|
1910
|
+
declare function submitApproval(args: SubmitApprovalArgs): Promise<`0x${string}`>;
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Suggested minimum-buffer presets (seconds) by chain-finality profile.
|
|
1914
|
+
* Starting points to tune to your chains, NOT authoritative values.
|
|
1915
|
+
*
|
|
1916
|
+
* - `fastL2` (~5 min): fast-finality L2s with low reorg risk.
|
|
1917
|
+
* - `standard` (~30 min): general-purpose default.
|
|
1918
|
+
* - `conservativeL1` (~1 hr): congested or deep-reorg-risk L1s.
|
|
1919
|
+
*/
|
|
1920
|
+
declare const DEFAULT_BUFFERS: {
|
|
1921
|
+
/** ~5 min — fast-finality L2s. */
|
|
1922
|
+
readonly fastL2: 300n;
|
|
1923
|
+
/** ~30 min — general default. */
|
|
1924
|
+
readonly standard: 1800n;
|
|
1925
|
+
/** ~1 hr — congested / deep-reorg-risk L1s. */
|
|
1926
|
+
readonly conservativeL1: 3600n;
|
|
1927
|
+
};
|
|
1928
|
+
/**
|
|
1929
|
+
* Default minimum buffer applied to CROSS-CHAIN schedules when the caller
|
|
1930
|
+
* supplies none. A conservative starting point ({@link DEFAULT_BUFFERS}.standard,
|
|
1931
|
+
* ~30 min) — tune to your chains; overriding BELOW it can expose users to
|
|
1932
|
+
* missed windows and lost funds under congestion/reorgs.
|
|
1933
|
+
*/
|
|
1934
|
+
declare const DEFAULT_CROSS_CHAIN_BUFFER_SECONDS: 1800n;
|
|
1935
|
+
/**
|
|
1936
|
+
* Default minimum buffer applied to SAME-CHAIN schedules when the caller
|
|
1937
|
+
* supplies none. Same conservative starting point as the cross-chain default
|
|
1938
|
+
* ({@link DEFAULT_BUFFERS}.standard, ~30 min) but a SEPARATE constant so the
|
|
1939
|
+
* two modes can be tuned independently later without touching call sites.
|
|
1940
|
+
*/
|
|
1941
|
+
declare const DEFAULT_SAME_CHAIN_BUFFER_SECONDS: 1800n;
|
|
1942
|
+
/**
|
|
1943
|
+
* Validates that every adjacent gap in a pairing's interleaved six-timestamp
|
|
1944
|
+
* schedule is at least `minimumBufferSeconds`. This is the gap-SIZE check
|
|
1945
|
+
* (distinct from interleaving ORDER, validated by `validateTermPairing`);
|
|
1946
|
+
* the contract never checks size, so this is the only enforcement point.
|
|
1947
|
+
*
|
|
1948
|
+
* The schedule order checked is: `proposer.commitmentDeadline`,
|
|
1949
|
+
* `taker.commitmentDeadline`, `proposer.claimDeadline`, `taker.claimDeadline`,
|
|
1950
|
+
* `proposer.reclaimRelease`, `taker.reclaimRelease`. Callers must pass terms
|
|
1951
|
+
* whose roles are already normalized (proposer = smaller `commitmentDeadline`).
|
|
1952
|
+
*
|
|
1953
|
+
* @param proposerTerms - The proposer's leg (smaller `commitmentDeadline`).
|
|
1954
|
+
* @param takerTerms - The taker's leg.
|
|
1955
|
+
* @param minimumBufferSeconds - The minimum acceptable gap (seconds) between
|
|
1956
|
+
* every adjacent pair of schedule timestamps.
|
|
1957
|
+
* @returns `{minimumGapSeconds}` — the smallest adjacent gap in the schedule.
|
|
1958
|
+
* @throws QuipSwapError `INSUFFICIENT_BUFFER` when any adjacent gap is below
|
|
1959
|
+
* `minimumBufferSeconds` (details carry the offending pair and the gap).
|
|
1960
|
+
* @see TermsLib.validateTermPairing (the ORDER check this complements)
|
|
1961
|
+
* @example
|
|
1962
|
+
* ```ts
|
|
1963
|
+
* const {minimumGapSeconds} = checkScheduleBuffers(proposer, taker, 1800n)
|
|
1964
|
+
* ```
|
|
1965
|
+
*/
|
|
1966
|
+
declare function checkScheduleBuffers(proposerTerms: Terms, takerTerms: Terms, minimumBufferSeconds: bigint): {
|
|
1967
|
+
minimumGapSeconds: bigint;
|
|
1968
|
+
};
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* A validated same-chain swap plan with both sides normalized into
|
|
1972
|
+
* proposer/taker roles and all five action windows precomputed.
|
|
1973
|
+
*/
|
|
1974
|
+
interface SameChainSwapPlan {
|
|
1975
|
+
/** The proposer's terms (earlier schedule; commits first; holds the secret). */
|
|
1976
|
+
readonly proposerTerms: Terms;
|
|
1977
|
+
/** The taker's terms (later schedule; commits second). */
|
|
1978
|
+
readonly takerTerms: Terms;
|
|
1979
|
+
/** The canonical trade digest stored in `termsHash[lock]` on commit. */
|
|
1980
|
+
readonly canonicalDigest: Hex32;
|
|
1981
|
+
/** The proposer side's single-terms digest (its `posted` key). */
|
|
1982
|
+
readonly proposerDigest: Hex32;
|
|
1983
|
+
/** The taker side's single-terms digest (its `posted` key). */
|
|
1984
|
+
readonly takerDigest: Hex32;
|
|
1985
|
+
/** `[0, proposer.commitmentDeadline)`. */
|
|
1986
|
+
readonly proposerCommitWindow: TimeWindow;
|
|
1987
|
+
/** `[proposer.commitmentDeadline, taker.commitmentDeadline)`. */
|
|
1988
|
+
readonly takerCommitWindow: TimeWindow;
|
|
1989
|
+
/** `[taker.commitmentDeadline, proposer.claimDeadline)` — one claim settles both legs. */
|
|
1990
|
+
readonly claimWindow: TimeWindow;
|
|
1991
|
+
/** `[proposer.reclaimRelease, +inf)` for the proposer's leg. */
|
|
1992
|
+
readonly proposerReclaimWindow: TimeWindow;
|
|
1993
|
+
/** `[taker.reclaimRelease, +inf)` for the taker's leg. */
|
|
1994
|
+
readonly takerReclaimWindow: TimeWindow;
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Validates a same-chain pairing and assembles a {@link SameChainSwapPlan}.
|
|
1998
|
+
*
|
|
1999
|
+
* Validates structure, interleaving (ORDER), that both sides name the SAME
|
|
2000
|
+
* chain, AND the gap-SIZE buffers between adjacent schedule timestamps.
|
|
2001
|
+
* Accepts the two sides in either order; roles are derived from the
|
|
2002
|
+
* schedule (`proposedBy`). Use {@link validateCrossChainSchedule} for
|
|
2003
|
+
* cross-chain swaps.
|
|
2004
|
+
*
|
|
2005
|
+
* The CONTRACT does not check buffer sizes — it only enforces interleaving
|
|
2006
|
+
* order — so this is the ONLY place a dangerously tight same-chain window is
|
|
2007
|
+
* caught. And nothing forces it (unlike the cross-chain reaction handoff):
|
|
2008
|
+
* BOTH parties should call `planSameChainSwap` on their own terms before
|
|
2009
|
+
* acting. It is per-party self-protection, not a shared gate.
|
|
2010
|
+
*
|
|
2011
|
+
* @param a - One side's terms.
|
|
2012
|
+
* @param b - The other side's terms.
|
|
2013
|
+
* @param opts - Optional. `minimumBufferSeconds` sets the minimum acceptable
|
|
2014
|
+
* gap (seconds) between every adjacent pair of schedule timestamps;
|
|
2015
|
+
* defaults to {@link DEFAULT_SAME_CHAIN_BUFFER_SECONDS} when omitted.
|
|
2016
|
+
* Overriding BELOW the default may let dangerously tight windows through —
|
|
2017
|
+
* only do so if you understand your chain's finality.
|
|
2018
|
+
* @returns The normalized plan with windows and digests precomputed.
|
|
2019
|
+
* @throws QuipSwapError - structural codes from {@link validateTerms};
|
|
2020
|
+
* `DISORDERED_DEADLINES` for a non-interleaved schedule;
|
|
2021
|
+
* `CHAIN_ID_MISMATCH` when the sides name different chains;
|
|
2022
|
+
* `INSUFFICIENT_BUFFER` when any adjacent gap is below the minimum.
|
|
2023
|
+
* @see TermsLib.validateTermPairing, checkScheduleBuffers
|
|
2024
|
+
* @example
|
|
2025
|
+
* ```ts
|
|
2026
|
+
* const plan = planSameChainSwap(aliceTerms, bobTerms) // default buffer
|
|
2027
|
+
* // proposer commits first:
|
|
2028
|
+
* await client.commit({lock, party: plan.proposerTerms, counterparty: plan.takerTerms})
|
|
2029
|
+
* ```
|
|
2030
|
+
*/
|
|
2031
|
+
declare function planSameChainSwap(a: Terms, b: Terms, opts?: {
|
|
2032
|
+
readonly minimumBufferSeconds?: bigint;
|
|
2033
|
+
}): SameChainSwapPlan;
|
|
2034
|
+
/**
|
|
2035
|
+
* Application-level swap status — deliberately SEPARATE from the Solidity
|
|
2036
|
+
* {@link LockState}: the chain knows four states, but an application also
|
|
2037
|
+
* needs to know which window is open and which side has posted.
|
|
2038
|
+
*/
|
|
2039
|
+
type SameChainSwapStatus =
|
|
2040
|
+
/** Nothing committed; the proposer's commit window is open. */
|
|
2041
|
+
'awaiting-proposer-commit'
|
|
2042
|
+
/**
|
|
2043
|
+
* Nothing committed and the proposer's window has closed. The swap can
|
|
2044
|
+
* no longer COMPLETE (the proposer can never commit, so the lock can
|
|
2045
|
+
* never reach Committed) — but the contract will still accept a
|
|
2046
|
+
* taker-first commit in `[proposer.commitmentDeadline,
|
|
2047
|
+
* taker.commitmentDeadline)`: `Omnibus.commit` checks only the window,
|
|
2048
|
+
* not that the proposer actually committed (verifying the counterparty's
|
|
2049
|
+
* commitment is the committer's duty, per the contract comments). Such a
|
|
2050
|
+
* commit is pointless and self-harming — it moves the lock Unused→Free
|
|
2051
|
+
* and strands the taker's assets until `taker.reclaimRelease` (reclaim
|
|
2052
|
+
* from Free). Treat this status as terminal and do NOT commit into it.
|
|
2053
|
+
*/
|
|
2054
|
+
| 'proposer-commit-expired'
|
|
2055
|
+
/** Proposer committed (lock Free); the taker's window has not opened yet. */
|
|
2056
|
+
| 'awaiting-taker-window'
|
|
2057
|
+
/** Proposer committed (lock Free); the taker's window is open. */
|
|
2058
|
+
| 'awaiting-taker-commit'
|
|
2059
|
+
/** Only the proposer committed and the taker's window closed; awaiting the proposer's reclaimRelease. */
|
|
2060
|
+
| 'half-committed-expired'
|
|
2061
|
+
/** Both committed before the taker's commitment deadline; the proposer-claim window has not opened yet. */
|
|
2062
|
+
| 'awaiting-claim-window'
|
|
2063
|
+
/** Both committed; the claim window is open — the secret holder should claim. */
|
|
2064
|
+
| 'claimable'
|
|
2065
|
+
/** Both committed; the proposer-claim window closed (taker-claim window may run until proposer.reclaimRelease). */
|
|
2066
|
+
| 'late-claimable'
|
|
2067
|
+
/** Both committed; no claim landed and a leg's reclaim window is open. */
|
|
2068
|
+
| 'reclaimable'
|
|
2069
|
+
/** Lock Free and the proposer's reclaim window is open (reclaim-from-Free). */
|
|
2070
|
+
| 'reclaimable-from-free'
|
|
2071
|
+
/** Terminal: the lock is Spent (claimed or reclaimed). */
|
|
2072
|
+
| 'settled';
|
|
2073
|
+
/** The full status report returned by {@link getSameChainSwapStatus}. */
|
|
2074
|
+
interface SameChainSwapStatusReport {
|
|
2075
|
+
/** The application-level status (see {@link SameChainSwapStatus}). */
|
|
2076
|
+
readonly status: SameChainSwapStatus;
|
|
2077
|
+
/** The raw on-chain {@link LockState} the status was derived from. */
|
|
2078
|
+
readonly lockState: LockState;
|
|
2079
|
+
/** Whether the proposer's side is posted on-chain. */
|
|
2080
|
+
readonly proposerPosted: boolean;
|
|
2081
|
+
/** Whether the taker's side is posted on-chain. */
|
|
2082
|
+
readonly takerPosted: boolean;
|
|
2083
|
+
/** The chain timestamp the report was computed at. */
|
|
2084
|
+
readonly timestamp: bigint;
|
|
2085
|
+
}
|
|
2086
|
+
/**
|
|
2087
|
+
* Inspects a same-chain swap's status from ACTUAL on-chain state
|
|
2088
|
+
* (`lockState`, `posted`) combined with the current block timestamp.
|
|
2089
|
+
*
|
|
2090
|
+
* @param client - An {@link OmnibusClient} on the swap's chain.
|
|
2091
|
+
* @param lock - The swap's hashlock.
|
|
2092
|
+
* @param plan - The plan from {@link planSameChainSwap}.
|
|
2093
|
+
* @returns A {@link SameChainSwapStatusReport}; never throws on unexpected
|
|
2094
|
+
* state combinations — the raw fields are included so the application can
|
|
2095
|
+
* inspect them.
|
|
2096
|
+
* @example
|
|
2097
|
+
* ```ts
|
|
2098
|
+
* const {status} = await getSameChainSwapStatus(client, lock, plan)
|
|
2099
|
+
* if (status === 'claimable') await client.claim({secret, party: plan.proposerTerms, counterparty: plan.takerTerms})
|
|
2100
|
+
* ```
|
|
2101
|
+
*/
|
|
2102
|
+
declare function getSameChainSwapStatus(client: OmnibusClient, lock: Hex32, plan: SameChainSwapPlan): Promise<SameChainSwapStatusReport>;
|
|
2103
|
+
|
|
2104
|
+
/** Arguments for {@link validateCrossChainSchedule}. */
|
|
2105
|
+
interface ValidateCrossChainScheduleArgs {
|
|
2106
|
+
/**
|
|
2107
|
+
* The SECRET HOLDER's leg. The secret holder must be the proposer (the
|
|
2108
|
+
* side with the smaller `commitmentDeadline`); anything else is the
|
|
2109
|
+
* free-option misconfiguration and is rejected.
|
|
2110
|
+
*/
|
|
2111
|
+
readonly proposerTerms: Terms;
|
|
2112
|
+
/** The counterparty's (taker's) leg, on the other chain. */
|
|
2113
|
+
readonly takerTerms: Terms;
|
|
2114
|
+
/**
|
|
2115
|
+
* Minimum acceptable gap, in SECONDS, between EVERY pair of adjacent
|
|
2116
|
+
* timestamps in the interleaved schedule — including the taker's
|
|
2117
|
+
* post-reveal reaction buffer
|
|
2118
|
+
* (`proposer.reclaimRelease - proposer.claimDeadline`).
|
|
2119
|
+
*
|
|
2120
|
+
* Optional: defaults to {@link DEFAULT_CROSS_CHAIN_BUFFER_SECONDS} when
|
|
2121
|
+
* omitted. Choose it from chain finality, reorg risk, RPC reliability,
|
|
2122
|
+
* network congestion, relayer responsiveness, and your operational safety
|
|
2123
|
+
* margin (the {@link DEFAULT_BUFFERS} presets are starting points). A
|
|
2124
|
+
* value comfortable on a fast-finality L2 may be recklessly small on a
|
|
2125
|
+
* congested L1. Overriding BELOW the default can expose users to missed
|
|
2126
|
+
* windows and lost funds under congestion/reorgs — only do so if you
|
|
2127
|
+
* understand your chains' finality.
|
|
2128
|
+
*/
|
|
2129
|
+
readonly minimumBufferSeconds?: bigint;
|
|
2130
|
+
}
|
|
2131
|
+
/** The validated cross-chain schedule summary. */
|
|
2132
|
+
interface CrossChainSchedule {
|
|
2133
|
+
/** The proposer's (secret holder's) leg. */
|
|
2134
|
+
readonly proposerTerms: Terms;
|
|
2135
|
+
/** The taker's leg. */
|
|
2136
|
+
readonly takerTerms: Terms;
|
|
2137
|
+
/**
|
|
2138
|
+
* The taker's post-reveal reaction buffer in seconds:
|
|
2139
|
+
* `proposer.reclaimRelease - proposer.claimDeadline` — the gap between
|
|
2140
|
+
* the latest possible secret reveal (the proposer-claim window closes at
|
|
2141
|
+
* `proposer.claimDeadline`) and the close of the taker's claim window
|
|
2142
|
+
* (`proposer.reclaimRelease`). This is the taker's time to observe the
|
|
2143
|
+
* revealed secret and land their own claim.
|
|
2144
|
+
*/
|
|
2145
|
+
readonly reactionBufferSeconds: bigint;
|
|
2146
|
+
/** The smallest gap between any two adjacent schedule timestamps, in seconds. */
|
|
2147
|
+
readonly minimumGapSeconds: bigint;
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Validates a cross-chain swap schedule before any transaction is sent.
|
|
2151
|
+
*
|
|
2152
|
+
* Checks, in order:
|
|
2153
|
+
* 1. Both terms are structurally valid and the pairing strictly
|
|
2154
|
+
* interleaves (the contract enforces this on BOTH chains; the SDK
|
|
2155
|
+
* rejects bad pairings before any gas is spent).
|
|
2156
|
+
* 2. The secret holder's leg (`proposerTerms`) actually IS the proposer —
|
|
2157
|
+
* rejecting the free-option role mis-assignment.
|
|
2158
|
+
* 3. The two legs are on DIFFERENT chains (use {@link planSameChainSwap}
|
|
2159
|
+
* otherwise).
|
|
2160
|
+
* 4. Every gap between adjacent timestamps in the interleaved schedule —
|
|
2161
|
+
* including the reaction buffer — is at least `minimumBufferSeconds`
|
|
2162
|
+
* (defaults to {@link DEFAULT_CROSS_CHAIN_BUFFER_SECONDS} when omitted).
|
|
2163
|
+
*
|
|
2164
|
+
* This validates the SCHEDULE only (interleaving, roles, buffers) and reads
|
|
2165
|
+
* no chain — it is NOT proof that any party has committed. A taker must
|
|
2166
|
+
* still run {@link verifyRemoteCommitment} against the proposer's chain
|
|
2167
|
+
* before committing; a valid schedule alone does not make a commit safe.
|
|
2168
|
+
*
|
|
2169
|
+
* @param args - See {@link ValidateCrossChainScheduleArgs}; parameter names
|
|
2170
|
+
* are protocol roles (`proposerTerms`/`takerTerms`), not call-site roles.
|
|
2171
|
+
* @returns The {@link CrossChainSchedule} summary (buffers included).
|
|
2172
|
+
* @throws QuipSwapError - structural codes; `DISORDERED_DEADLINES`;
|
|
2173
|
+
* `SECRET_HOLDER_NOT_PROPOSER` when the roles are inverted;
|
|
2174
|
+
* `CHAIN_ID_MISMATCH` when both legs share a chain;
|
|
2175
|
+
* `INSUFFICIENT_BUFFER` when any adjacent gap is below the minimum.
|
|
2176
|
+
* @see TermsLib.validateTermPairing, test/attack/CrossChainFreeOption.t.sol
|
|
2177
|
+
* @example
|
|
2178
|
+
* ```ts
|
|
2179
|
+
* const schedule = validateCrossChainSchedule({
|
|
2180
|
+
* proposerTerms: aliceTermsOnChainA, // Alice holds the secret
|
|
2181
|
+
* takerTerms: bobTermsOnChainB,
|
|
2182
|
+
* // minimumBufferSeconds omitted → DEFAULT_CROSS_CHAIN_BUFFER_SECONDS;
|
|
2183
|
+
* // or pass an explicit margin, e.g. DEFAULT_BUFFERS.conservativeL1
|
|
2184
|
+
* })
|
|
2185
|
+
* ```
|
|
2186
|
+
*/
|
|
2187
|
+
declare function validateCrossChainSchedule(args: ValidateCrossChainScheduleArgs): CrossChainSchedule;
|
|
2188
|
+
/** The result of {@link verifyRemoteCommitment}. */
|
|
2189
|
+
interface RemoteCommitmentStatus {
|
|
2190
|
+
/** True iff the remote lock is `Committed` AND the remote side's terms are posted. */
|
|
2191
|
+
readonly committed: boolean;
|
|
2192
|
+
/** The remote lock's state. */
|
|
2193
|
+
readonly lockState: LockState;
|
|
2194
|
+
/** Whether the remote (proposer) side's terms digest is posted for the lock. */
|
|
2195
|
+
readonly proposerPosted: boolean;
|
|
2196
|
+
/** Whether the on-chain canonical termsHash matches the supplied pairing. */
|
|
2197
|
+
readonly termsHashMatches: boolean;
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* The taker's MANDATORY pre-commit check: verifies on the PROPOSER's chain
|
|
2201
|
+
* that the proposer's commitment has actually taken effect.
|
|
2202
|
+
*
|
|
2203
|
+
* ⚠️ Skipping this before a cross-chain TAKER commit is the single most
|
|
2204
|
+
* dangerous mistake you can make with this SDK. If the taker commits and
|
|
2205
|
+
* the proposer never committed, the proposer (who holds the secret) can
|
|
2206
|
+
* claim the taker's escrowed leg while risking nothing — the taker loses
|
|
2207
|
+
* its funds. The contract states the obligation explicitly (`Omnibus.commit`:
|
|
2208
|
+
* "the party MUST ensure the commitment from the counterparty has taken
|
|
2209
|
+
* effect especially if the swap is cross-chain") but CANNOT enforce it
|
|
2210
|
+
* cross-chain, because the taker's chain cannot read the proposer's chain.
|
|
2211
|
+
*
|
|
2212
|
+
* Not spoofable: this reads on-chain STORAGE (`lockState` / `posted` /
|
|
2213
|
+
* `termsHash`), not events, so a forged log cannot fake a commitment. But
|
|
2214
|
+
* the result is POINT-IN-TIME — a reorg can undo a young commit — so apply
|
|
2215
|
+
* your own confirmation depth (re-check after N blocks) before relying on a
|
|
2216
|
+
* `true` result.
|
|
2217
|
+
*
|
|
2218
|
+
* Chain-agnostic: pass a client bound to the PROPOSER's chain for a
|
|
2219
|
+
* cross-chain swap (the case that matters); passing the local client for a
|
|
2220
|
+
* same-chain swap merely duplicates a guard the contract already enforces.
|
|
2221
|
+
*
|
|
2222
|
+
* @param remoteClient - An {@link OmnibusClient} bound to the PROPOSER's chain.
|
|
2223
|
+
* @param lock - The shared hashlock.
|
|
2224
|
+
* @param proposerTerms - The proposer's (remote) leg.
|
|
2225
|
+
* @param takerTerms - The taker's (local) leg.
|
|
2226
|
+
* @returns A {@link RemoteCommitmentStatus}; commit only when `committed`
|
|
2227
|
+
* is true and your confirmation policy is satisfied.
|
|
2228
|
+
* @see Omnibus.commit
|
|
2229
|
+
* @example
|
|
2230
|
+
* ```ts
|
|
2231
|
+
* const status = await verifyRemoteCommitment(chainAClient, lock, aliceTerms, bobTerms)
|
|
2232
|
+
* if (status.committed) await chainBClient.commit({lock, party: bobTerms, counterparty: aliceTerms})
|
|
2233
|
+
* ```
|
|
2234
|
+
*/
|
|
2235
|
+
declare function verifyRemoteCommitment(remoteClient: OmnibusClient, lock: Hex32, proposerTerms: Terms, takerTerms: Terms): Promise<RemoteCommitmentStatus>;
|
|
2236
|
+
/**
|
|
2237
|
+
* Derives the lock from a secret for cross-chain coordination — re-export
|
|
2238
|
+
* of {@link generateLock} under a workflow-centric name so coordinators
|
|
2239
|
+
* depend only on this module.
|
|
2240
|
+
*
|
|
2241
|
+
* @param secret - The proposer's 32-byte secret.
|
|
2242
|
+
* @returns The shared lock used on BOTH chains.
|
|
2243
|
+
* @throws QuipSwapError `INVALID_HEX32` for malformed secrets.
|
|
2244
|
+
* @see Omnibus._generateLock
|
|
2245
|
+
*/
|
|
2246
|
+
declare function deriveSharedLock(secret: Hex32): Hex32;
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Omnibus contract ABI.
|
|
2250
|
+
*
|
|
2251
|
+
* AUTO-GENERATED by scripts/generate-abi.ts from out/Omnibus.sol/Omnibus.json.
|
|
2252
|
+
* Do not edit by hand — run `forge build && bun run generate:abi` instead.
|
|
2253
|
+
*
|
|
2254
|
+
* Exported `as const` so Viem can infer typed function arguments, return
|
|
2255
|
+
* values, event shapes, and custom error names directly from this object.
|
|
2256
|
+
*/
|
|
2257
|
+
declare const omnibusAbi: readonly [{
|
|
2258
|
+
readonly type: "constructor";
|
|
2259
|
+
readonly inputs: readonly [{
|
|
2260
|
+
readonly name: "initialOwner";
|
|
2261
|
+
readonly type: "address";
|
|
2262
|
+
readonly internalType: "address";
|
|
2263
|
+
}, {
|
|
2264
|
+
readonly name: "quipFactory";
|
|
2265
|
+
readonly type: "address";
|
|
2266
|
+
readonly internalType: "address";
|
|
2267
|
+
}];
|
|
2268
|
+
readonly stateMutability: "nonpayable";
|
|
2269
|
+
}, {
|
|
2270
|
+
readonly type: "receive";
|
|
2271
|
+
readonly stateMutability: "payable";
|
|
2272
|
+
}, {
|
|
2273
|
+
readonly type: "function";
|
|
2274
|
+
readonly name: "MAX_FEE";
|
|
2275
|
+
readonly inputs: readonly [];
|
|
2276
|
+
readonly outputs: readonly [{
|
|
2277
|
+
readonly name: "";
|
|
2278
|
+
readonly type: "uint256";
|
|
2279
|
+
readonly internalType: "uint256";
|
|
2280
|
+
}];
|
|
2281
|
+
readonly stateMutability: "view";
|
|
2282
|
+
}, {
|
|
2283
|
+
readonly type: "function";
|
|
2284
|
+
readonly name: "QUIP_FACTORY";
|
|
2285
|
+
readonly inputs: readonly [];
|
|
2286
|
+
readonly outputs: readonly [{
|
|
2287
|
+
readonly name: "";
|
|
2288
|
+
readonly type: "address";
|
|
2289
|
+
readonly internalType: "contract IQuipFactory";
|
|
2290
|
+
}];
|
|
2291
|
+
readonly stateMutability: "view";
|
|
2292
|
+
}, {
|
|
2293
|
+
readonly type: "function";
|
|
2294
|
+
readonly name: "VERSION";
|
|
2295
|
+
readonly inputs: readonly [];
|
|
2296
|
+
readonly outputs: readonly [{
|
|
2297
|
+
readonly name: "";
|
|
2298
|
+
readonly type: "uint256";
|
|
2299
|
+
readonly internalType: "uint256";
|
|
2300
|
+
}];
|
|
2301
|
+
readonly stateMutability: "view";
|
|
2302
|
+
}, {
|
|
2303
|
+
readonly type: "function";
|
|
2304
|
+
readonly name: "acceptOwnership";
|
|
2305
|
+
readonly inputs: readonly [];
|
|
2306
|
+
readonly outputs: readonly [];
|
|
2307
|
+
readonly stateMutability: "nonpayable";
|
|
2308
|
+
}, {
|
|
2309
|
+
readonly type: "function";
|
|
2310
|
+
readonly name: "accruedFees";
|
|
2311
|
+
readonly inputs: readonly [];
|
|
2312
|
+
readonly outputs: readonly [{
|
|
2313
|
+
readonly name: "";
|
|
2314
|
+
readonly type: "uint256";
|
|
2315
|
+
readonly internalType: "uint256";
|
|
2316
|
+
}];
|
|
2317
|
+
readonly stateMutability: "view";
|
|
2318
|
+
}, {
|
|
2319
|
+
readonly type: "function";
|
|
2320
|
+
readonly name: "claim";
|
|
2321
|
+
readonly inputs: readonly [{
|
|
2322
|
+
readonly name: "secret";
|
|
2323
|
+
readonly type: "bytes32";
|
|
2324
|
+
readonly internalType: "bytes32";
|
|
2325
|
+
}, {
|
|
2326
|
+
readonly name: "party";
|
|
2327
|
+
readonly type: "tuple";
|
|
2328
|
+
readonly internalType: "struct Terms";
|
|
2329
|
+
readonly components: readonly [{
|
|
2330
|
+
readonly name: "chainId";
|
|
2331
|
+
readonly type: "uint256";
|
|
2332
|
+
readonly internalType: "uint256";
|
|
2333
|
+
}, {
|
|
2334
|
+
readonly name: "reclaimRecipient";
|
|
2335
|
+
readonly type: "address";
|
|
2336
|
+
readonly internalType: "address";
|
|
2337
|
+
}, {
|
|
2338
|
+
readonly name: "recipient";
|
|
2339
|
+
readonly type: "address";
|
|
2340
|
+
readonly internalType: "address";
|
|
2341
|
+
}, {
|
|
2342
|
+
readonly name: "commitmentDeadline";
|
|
2343
|
+
readonly type: "uint256";
|
|
2344
|
+
readonly internalType: "uint256";
|
|
2345
|
+
}, {
|
|
2346
|
+
readonly name: "claimDeadline";
|
|
2347
|
+
readonly type: "uint256";
|
|
2348
|
+
readonly internalType: "uint256";
|
|
2349
|
+
}, {
|
|
2350
|
+
readonly name: "reclaimRelease";
|
|
2351
|
+
readonly type: "uint256";
|
|
2352
|
+
readonly internalType: "uint256";
|
|
2353
|
+
}, {
|
|
2354
|
+
readonly name: "assets";
|
|
2355
|
+
readonly type: "tuple[]";
|
|
2356
|
+
readonly internalType: "struct Asset[]";
|
|
2357
|
+
readonly components: readonly [{
|
|
2358
|
+
readonly name: "assetType";
|
|
2359
|
+
readonly type: "uint8";
|
|
2360
|
+
readonly internalType: "enum AssetType";
|
|
2361
|
+
}, {
|
|
2362
|
+
readonly name: "target";
|
|
2363
|
+
readonly type: "address";
|
|
2364
|
+
readonly internalType: "address";
|
|
2365
|
+
}, {
|
|
2366
|
+
readonly name: "id";
|
|
2367
|
+
readonly type: "uint256";
|
|
2368
|
+
readonly internalType: "uint256";
|
|
2369
|
+
}, {
|
|
2370
|
+
readonly name: "amount";
|
|
2371
|
+
readonly type: "uint256";
|
|
2372
|
+
readonly internalType: "uint256";
|
|
2373
|
+
}];
|
|
2374
|
+
}];
|
|
2375
|
+
}, {
|
|
2376
|
+
readonly name: "counterparty";
|
|
2377
|
+
readonly type: "tuple";
|
|
2378
|
+
readonly internalType: "struct Terms";
|
|
2379
|
+
readonly components: readonly [{
|
|
2380
|
+
readonly name: "chainId";
|
|
2381
|
+
readonly type: "uint256";
|
|
2382
|
+
readonly internalType: "uint256";
|
|
2383
|
+
}, {
|
|
2384
|
+
readonly name: "reclaimRecipient";
|
|
2385
|
+
readonly type: "address";
|
|
2386
|
+
readonly internalType: "address";
|
|
2387
|
+
}, {
|
|
2388
|
+
readonly name: "recipient";
|
|
2389
|
+
readonly type: "address";
|
|
2390
|
+
readonly internalType: "address";
|
|
2391
|
+
}, {
|
|
2392
|
+
readonly name: "commitmentDeadline";
|
|
2393
|
+
readonly type: "uint256";
|
|
2394
|
+
readonly internalType: "uint256";
|
|
2395
|
+
}, {
|
|
2396
|
+
readonly name: "claimDeadline";
|
|
2397
|
+
readonly type: "uint256";
|
|
2398
|
+
readonly internalType: "uint256";
|
|
2399
|
+
}, {
|
|
2400
|
+
readonly name: "reclaimRelease";
|
|
2401
|
+
readonly type: "uint256";
|
|
2402
|
+
readonly internalType: "uint256";
|
|
2403
|
+
}, {
|
|
2404
|
+
readonly name: "assets";
|
|
2405
|
+
readonly type: "tuple[]";
|
|
2406
|
+
readonly internalType: "struct Asset[]";
|
|
2407
|
+
readonly components: readonly [{
|
|
2408
|
+
readonly name: "assetType";
|
|
2409
|
+
readonly type: "uint8";
|
|
2410
|
+
readonly internalType: "enum AssetType";
|
|
2411
|
+
}, {
|
|
2412
|
+
readonly name: "target";
|
|
2413
|
+
readonly type: "address";
|
|
2414
|
+
readonly internalType: "address";
|
|
2415
|
+
}, {
|
|
2416
|
+
readonly name: "id";
|
|
2417
|
+
readonly type: "uint256";
|
|
2418
|
+
readonly internalType: "uint256";
|
|
2419
|
+
}, {
|
|
2420
|
+
readonly name: "amount";
|
|
2421
|
+
readonly type: "uint256";
|
|
2422
|
+
readonly internalType: "uint256";
|
|
2423
|
+
}];
|
|
2424
|
+
}];
|
|
2425
|
+
}];
|
|
2426
|
+
readonly outputs: readonly [];
|
|
2427
|
+
readonly stateMutability: "nonpayable";
|
|
2428
|
+
}, {
|
|
2429
|
+
readonly type: "function";
|
|
2430
|
+
readonly name: "commit";
|
|
2431
|
+
readonly inputs: readonly [{
|
|
2432
|
+
readonly name: "lock";
|
|
2433
|
+
readonly type: "bytes32";
|
|
2434
|
+
readonly internalType: "bytes32";
|
|
2435
|
+
}, {
|
|
2436
|
+
readonly name: "party";
|
|
2437
|
+
readonly type: "tuple";
|
|
2438
|
+
readonly internalType: "struct Terms";
|
|
2439
|
+
readonly components: readonly [{
|
|
2440
|
+
readonly name: "chainId";
|
|
2441
|
+
readonly type: "uint256";
|
|
2442
|
+
readonly internalType: "uint256";
|
|
2443
|
+
}, {
|
|
2444
|
+
readonly name: "reclaimRecipient";
|
|
2445
|
+
readonly type: "address";
|
|
2446
|
+
readonly internalType: "address";
|
|
2447
|
+
}, {
|
|
2448
|
+
readonly name: "recipient";
|
|
2449
|
+
readonly type: "address";
|
|
2450
|
+
readonly internalType: "address";
|
|
2451
|
+
}, {
|
|
2452
|
+
readonly name: "commitmentDeadline";
|
|
2453
|
+
readonly type: "uint256";
|
|
2454
|
+
readonly internalType: "uint256";
|
|
2455
|
+
}, {
|
|
2456
|
+
readonly name: "claimDeadline";
|
|
2457
|
+
readonly type: "uint256";
|
|
2458
|
+
readonly internalType: "uint256";
|
|
2459
|
+
}, {
|
|
2460
|
+
readonly name: "reclaimRelease";
|
|
2461
|
+
readonly type: "uint256";
|
|
2462
|
+
readonly internalType: "uint256";
|
|
2463
|
+
}, {
|
|
2464
|
+
readonly name: "assets";
|
|
2465
|
+
readonly type: "tuple[]";
|
|
2466
|
+
readonly internalType: "struct Asset[]";
|
|
2467
|
+
readonly components: readonly [{
|
|
2468
|
+
readonly name: "assetType";
|
|
2469
|
+
readonly type: "uint8";
|
|
2470
|
+
readonly internalType: "enum AssetType";
|
|
2471
|
+
}, {
|
|
2472
|
+
readonly name: "target";
|
|
2473
|
+
readonly type: "address";
|
|
2474
|
+
readonly internalType: "address";
|
|
2475
|
+
}, {
|
|
2476
|
+
readonly name: "id";
|
|
2477
|
+
readonly type: "uint256";
|
|
2478
|
+
readonly internalType: "uint256";
|
|
2479
|
+
}, {
|
|
2480
|
+
readonly name: "amount";
|
|
2481
|
+
readonly type: "uint256";
|
|
2482
|
+
readonly internalType: "uint256";
|
|
2483
|
+
}];
|
|
2484
|
+
}];
|
|
2485
|
+
}, {
|
|
2486
|
+
readonly name: "counterparty";
|
|
2487
|
+
readonly type: "tuple";
|
|
2488
|
+
readonly internalType: "struct Terms";
|
|
2489
|
+
readonly components: readonly [{
|
|
2490
|
+
readonly name: "chainId";
|
|
2491
|
+
readonly type: "uint256";
|
|
2492
|
+
readonly internalType: "uint256";
|
|
2493
|
+
}, {
|
|
2494
|
+
readonly name: "reclaimRecipient";
|
|
2495
|
+
readonly type: "address";
|
|
2496
|
+
readonly internalType: "address";
|
|
2497
|
+
}, {
|
|
2498
|
+
readonly name: "recipient";
|
|
2499
|
+
readonly type: "address";
|
|
2500
|
+
readonly internalType: "address";
|
|
2501
|
+
}, {
|
|
2502
|
+
readonly name: "commitmentDeadline";
|
|
2503
|
+
readonly type: "uint256";
|
|
2504
|
+
readonly internalType: "uint256";
|
|
2505
|
+
}, {
|
|
2506
|
+
readonly name: "claimDeadline";
|
|
2507
|
+
readonly type: "uint256";
|
|
2508
|
+
readonly internalType: "uint256";
|
|
2509
|
+
}, {
|
|
2510
|
+
readonly name: "reclaimRelease";
|
|
2511
|
+
readonly type: "uint256";
|
|
2512
|
+
readonly internalType: "uint256";
|
|
2513
|
+
}, {
|
|
2514
|
+
readonly name: "assets";
|
|
2515
|
+
readonly type: "tuple[]";
|
|
2516
|
+
readonly internalType: "struct Asset[]";
|
|
2517
|
+
readonly components: readonly [{
|
|
2518
|
+
readonly name: "assetType";
|
|
2519
|
+
readonly type: "uint8";
|
|
2520
|
+
readonly internalType: "enum AssetType";
|
|
2521
|
+
}, {
|
|
2522
|
+
readonly name: "target";
|
|
2523
|
+
readonly type: "address";
|
|
2524
|
+
readonly internalType: "address";
|
|
2525
|
+
}, {
|
|
2526
|
+
readonly name: "id";
|
|
2527
|
+
readonly type: "uint256";
|
|
2528
|
+
readonly internalType: "uint256";
|
|
2529
|
+
}, {
|
|
2530
|
+
readonly name: "amount";
|
|
2531
|
+
readonly type: "uint256";
|
|
2532
|
+
readonly internalType: "uint256";
|
|
2533
|
+
}];
|
|
2534
|
+
}];
|
|
2535
|
+
}];
|
|
2536
|
+
readonly outputs: readonly [];
|
|
2537
|
+
readonly stateMutability: "payable";
|
|
2538
|
+
}, {
|
|
2539
|
+
readonly type: "function";
|
|
2540
|
+
readonly name: "commitmentFee";
|
|
2541
|
+
readonly inputs: readonly [];
|
|
2542
|
+
readonly outputs: readonly [{
|
|
2543
|
+
readonly name: "";
|
|
2544
|
+
readonly type: "uint256";
|
|
2545
|
+
readonly internalType: "uint256";
|
|
2546
|
+
}];
|
|
2547
|
+
readonly stateMutability: "view";
|
|
2548
|
+
}, {
|
|
2549
|
+
readonly type: "function";
|
|
2550
|
+
readonly name: "lockState";
|
|
2551
|
+
readonly inputs: readonly [{
|
|
2552
|
+
readonly name: "lock";
|
|
2553
|
+
readonly type: "bytes32";
|
|
2554
|
+
readonly internalType: "bytes32";
|
|
2555
|
+
}];
|
|
2556
|
+
readonly outputs: readonly [{
|
|
2557
|
+
readonly name: "state";
|
|
2558
|
+
readonly type: "uint8";
|
|
2559
|
+
readonly internalType: "enum LockState";
|
|
2560
|
+
}];
|
|
2561
|
+
readonly stateMutability: "view";
|
|
2562
|
+
}, {
|
|
2563
|
+
readonly type: "function";
|
|
2564
|
+
readonly name: "onERC1155BatchReceived";
|
|
2565
|
+
readonly inputs: readonly [{
|
|
2566
|
+
readonly name: "";
|
|
2567
|
+
readonly type: "address";
|
|
2568
|
+
readonly internalType: "address";
|
|
2569
|
+
}, {
|
|
2570
|
+
readonly name: "";
|
|
2571
|
+
readonly type: "address";
|
|
2572
|
+
readonly internalType: "address";
|
|
2573
|
+
}, {
|
|
2574
|
+
readonly name: "";
|
|
2575
|
+
readonly type: "uint256[]";
|
|
2576
|
+
readonly internalType: "uint256[]";
|
|
2577
|
+
}, {
|
|
2578
|
+
readonly name: "";
|
|
2579
|
+
readonly type: "uint256[]";
|
|
2580
|
+
readonly internalType: "uint256[]";
|
|
2581
|
+
}, {
|
|
2582
|
+
readonly name: "";
|
|
2583
|
+
readonly type: "bytes";
|
|
2584
|
+
readonly internalType: "bytes";
|
|
2585
|
+
}];
|
|
2586
|
+
readonly outputs: readonly [{
|
|
2587
|
+
readonly name: "";
|
|
2588
|
+
readonly type: "bytes4";
|
|
2589
|
+
readonly internalType: "bytes4";
|
|
2590
|
+
}];
|
|
2591
|
+
readonly stateMutability: "pure";
|
|
2592
|
+
}, {
|
|
2593
|
+
readonly type: "function";
|
|
2594
|
+
readonly name: "onERC1155Received";
|
|
2595
|
+
readonly inputs: readonly [{
|
|
2596
|
+
readonly name: "";
|
|
2597
|
+
readonly type: "address";
|
|
2598
|
+
readonly internalType: "address";
|
|
2599
|
+
}, {
|
|
2600
|
+
readonly name: "";
|
|
2601
|
+
readonly type: "address";
|
|
2602
|
+
readonly internalType: "address";
|
|
2603
|
+
}, {
|
|
2604
|
+
readonly name: "";
|
|
2605
|
+
readonly type: "uint256";
|
|
2606
|
+
readonly internalType: "uint256";
|
|
2607
|
+
}, {
|
|
2608
|
+
readonly name: "";
|
|
2609
|
+
readonly type: "uint256";
|
|
2610
|
+
readonly internalType: "uint256";
|
|
2611
|
+
}, {
|
|
2612
|
+
readonly name: "";
|
|
2613
|
+
readonly type: "bytes";
|
|
2614
|
+
readonly internalType: "bytes";
|
|
2615
|
+
}];
|
|
2616
|
+
readonly outputs: readonly [{
|
|
2617
|
+
readonly name: "";
|
|
2618
|
+
readonly type: "bytes4";
|
|
2619
|
+
readonly internalType: "bytes4";
|
|
2620
|
+
}];
|
|
2621
|
+
readonly stateMutability: "pure";
|
|
2622
|
+
}, {
|
|
2623
|
+
readonly type: "function";
|
|
2624
|
+
readonly name: "onERC721Received";
|
|
2625
|
+
readonly inputs: readonly [{
|
|
2626
|
+
readonly name: "";
|
|
2627
|
+
readonly type: "address";
|
|
2628
|
+
readonly internalType: "address";
|
|
2629
|
+
}, {
|
|
2630
|
+
readonly name: "";
|
|
2631
|
+
readonly type: "address";
|
|
2632
|
+
readonly internalType: "address";
|
|
2633
|
+
}, {
|
|
2634
|
+
readonly name: "";
|
|
2635
|
+
readonly type: "uint256";
|
|
2636
|
+
readonly internalType: "uint256";
|
|
2637
|
+
}, {
|
|
2638
|
+
readonly name: "";
|
|
2639
|
+
readonly type: "bytes";
|
|
2640
|
+
readonly internalType: "bytes";
|
|
2641
|
+
}];
|
|
2642
|
+
readonly outputs: readonly [{
|
|
2643
|
+
readonly name: "";
|
|
2644
|
+
readonly type: "bytes4";
|
|
2645
|
+
readonly internalType: "bytes4";
|
|
2646
|
+
}];
|
|
2647
|
+
readonly stateMutability: "pure";
|
|
2648
|
+
}, {
|
|
2649
|
+
readonly type: "function";
|
|
2650
|
+
readonly name: "owner";
|
|
2651
|
+
readonly inputs: readonly [];
|
|
2652
|
+
readonly outputs: readonly [{
|
|
2653
|
+
readonly name: "";
|
|
2654
|
+
readonly type: "address";
|
|
2655
|
+
readonly internalType: "address";
|
|
2656
|
+
}];
|
|
2657
|
+
readonly stateMutability: "view";
|
|
2658
|
+
}, {
|
|
2659
|
+
readonly type: "function";
|
|
2660
|
+
readonly name: "pendingOwner";
|
|
2661
|
+
readonly inputs: readonly [];
|
|
2662
|
+
readonly outputs: readonly [{
|
|
2663
|
+
readonly name: "";
|
|
2664
|
+
readonly type: "address";
|
|
2665
|
+
readonly internalType: "address";
|
|
2666
|
+
}];
|
|
2667
|
+
readonly stateMutability: "view";
|
|
2668
|
+
}, {
|
|
2669
|
+
readonly type: "function";
|
|
2670
|
+
readonly name: "posted";
|
|
2671
|
+
readonly inputs: readonly [{
|
|
2672
|
+
readonly name: "lock";
|
|
2673
|
+
readonly type: "bytes32";
|
|
2674
|
+
readonly internalType: "bytes32";
|
|
2675
|
+
}, {
|
|
2676
|
+
readonly name: "termsDigest";
|
|
2677
|
+
readonly type: "bytes32";
|
|
2678
|
+
readonly internalType: "bytes32";
|
|
2679
|
+
}];
|
|
2680
|
+
readonly outputs: readonly [{
|
|
2681
|
+
readonly name: "isPosted";
|
|
2682
|
+
readonly type: "bool";
|
|
2683
|
+
readonly internalType: "bool";
|
|
2684
|
+
}];
|
|
2685
|
+
readonly stateMutability: "view";
|
|
2686
|
+
}, {
|
|
2687
|
+
readonly type: "function";
|
|
2688
|
+
readonly name: "reclaim";
|
|
2689
|
+
readonly inputs: readonly [{
|
|
2690
|
+
readonly name: "lock";
|
|
2691
|
+
readonly type: "bytes32";
|
|
2692
|
+
readonly internalType: "bytes32";
|
|
2693
|
+
}, {
|
|
2694
|
+
readonly name: "party";
|
|
2695
|
+
readonly type: "tuple";
|
|
2696
|
+
readonly internalType: "struct Terms";
|
|
2697
|
+
readonly components: readonly [{
|
|
2698
|
+
readonly name: "chainId";
|
|
2699
|
+
readonly type: "uint256";
|
|
2700
|
+
readonly internalType: "uint256";
|
|
2701
|
+
}, {
|
|
2702
|
+
readonly name: "reclaimRecipient";
|
|
2703
|
+
readonly type: "address";
|
|
2704
|
+
readonly internalType: "address";
|
|
2705
|
+
}, {
|
|
2706
|
+
readonly name: "recipient";
|
|
2707
|
+
readonly type: "address";
|
|
2708
|
+
readonly internalType: "address";
|
|
2709
|
+
}, {
|
|
2710
|
+
readonly name: "commitmentDeadline";
|
|
2711
|
+
readonly type: "uint256";
|
|
2712
|
+
readonly internalType: "uint256";
|
|
2713
|
+
}, {
|
|
2714
|
+
readonly name: "claimDeadline";
|
|
2715
|
+
readonly type: "uint256";
|
|
2716
|
+
readonly internalType: "uint256";
|
|
2717
|
+
}, {
|
|
2718
|
+
readonly name: "reclaimRelease";
|
|
2719
|
+
readonly type: "uint256";
|
|
2720
|
+
readonly internalType: "uint256";
|
|
2721
|
+
}, {
|
|
2722
|
+
readonly name: "assets";
|
|
2723
|
+
readonly type: "tuple[]";
|
|
2724
|
+
readonly internalType: "struct Asset[]";
|
|
2725
|
+
readonly components: readonly [{
|
|
2726
|
+
readonly name: "assetType";
|
|
2727
|
+
readonly type: "uint8";
|
|
2728
|
+
readonly internalType: "enum AssetType";
|
|
2729
|
+
}, {
|
|
2730
|
+
readonly name: "target";
|
|
2731
|
+
readonly type: "address";
|
|
2732
|
+
readonly internalType: "address";
|
|
2733
|
+
}, {
|
|
2734
|
+
readonly name: "id";
|
|
2735
|
+
readonly type: "uint256";
|
|
2736
|
+
readonly internalType: "uint256";
|
|
2737
|
+
}, {
|
|
2738
|
+
readonly name: "amount";
|
|
2739
|
+
readonly type: "uint256";
|
|
2740
|
+
readonly internalType: "uint256";
|
|
2741
|
+
}];
|
|
2742
|
+
}];
|
|
2743
|
+
}, {
|
|
2744
|
+
readonly name: "counterparty";
|
|
2745
|
+
readonly type: "tuple";
|
|
2746
|
+
readonly internalType: "struct Terms";
|
|
2747
|
+
readonly components: readonly [{
|
|
2748
|
+
readonly name: "chainId";
|
|
2749
|
+
readonly type: "uint256";
|
|
2750
|
+
readonly internalType: "uint256";
|
|
2751
|
+
}, {
|
|
2752
|
+
readonly name: "reclaimRecipient";
|
|
2753
|
+
readonly type: "address";
|
|
2754
|
+
readonly internalType: "address";
|
|
2755
|
+
}, {
|
|
2756
|
+
readonly name: "recipient";
|
|
2757
|
+
readonly type: "address";
|
|
2758
|
+
readonly internalType: "address";
|
|
2759
|
+
}, {
|
|
2760
|
+
readonly name: "commitmentDeadline";
|
|
2761
|
+
readonly type: "uint256";
|
|
2762
|
+
readonly internalType: "uint256";
|
|
2763
|
+
}, {
|
|
2764
|
+
readonly name: "claimDeadline";
|
|
2765
|
+
readonly type: "uint256";
|
|
2766
|
+
readonly internalType: "uint256";
|
|
2767
|
+
}, {
|
|
2768
|
+
readonly name: "reclaimRelease";
|
|
2769
|
+
readonly type: "uint256";
|
|
2770
|
+
readonly internalType: "uint256";
|
|
2771
|
+
}, {
|
|
2772
|
+
readonly name: "assets";
|
|
2773
|
+
readonly type: "tuple[]";
|
|
2774
|
+
readonly internalType: "struct Asset[]";
|
|
2775
|
+
readonly components: readonly [{
|
|
2776
|
+
readonly name: "assetType";
|
|
2777
|
+
readonly type: "uint8";
|
|
2778
|
+
readonly internalType: "enum AssetType";
|
|
2779
|
+
}, {
|
|
2780
|
+
readonly name: "target";
|
|
2781
|
+
readonly type: "address";
|
|
2782
|
+
readonly internalType: "address";
|
|
2783
|
+
}, {
|
|
2784
|
+
readonly name: "id";
|
|
2785
|
+
readonly type: "uint256";
|
|
2786
|
+
readonly internalType: "uint256";
|
|
2787
|
+
}, {
|
|
2788
|
+
readonly name: "amount";
|
|
2789
|
+
readonly type: "uint256";
|
|
2790
|
+
readonly internalType: "uint256";
|
|
2791
|
+
}];
|
|
2792
|
+
}];
|
|
2793
|
+
}];
|
|
2794
|
+
readonly outputs: readonly [];
|
|
2795
|
+
readonly stateMutability: "nonpayable";
|
|
2796
|
+
}, {
|
|
2797
|
+
readonly type: "function";
|
|
2798
|
+
readonly name: "renounceOwnership";
|
|
2799
|
+
readonly inputs: readonly [];
|
|
2800
|
+
readonly outputs: readonly [];
|
|
2801
|
+
readonly stateMutability: "nonpayable";
|
|
2802
|
+
}, {
|
|
2803
|
+
readonly type: "function";
|
|
2804
|
+
readonly name: "setCommitmentFee";
|
|
2805
|
+
readonly inputs: readonly [{
|
|
2806
|
+
readonly name: "newFee";
|
|
2807
|
+
readonly type: "uint256";
|
|
2808
|
+
readonly internalType: "uint256";
|
|
2809
|
+
}];
|
|
2810
|
+
readonly outputs: readonly [];
|
|
2811
|
+
readonly stateMutability: "nonpayable";
|
|
2812
|
+
}, {
|
|
2813
|
+
readonly type: "function";
|
|
2814
|
+
readonly name: "supportsInterface";
|
|
2815
|
+
readonly inputs: readonly [{
|
|
2816
|
+
readonly name: "interfaceId";
|
|
2817
|
+
readonly type: "bytes4";
|
|
2818
|
+
readonly internalType: "bytes4";
|
|
2819
|
+
}];
|
|
2820
|
+
readonly outputs: readonly [{
|
|
2821
|
+
readonly name: "";
|
|
2822
|
+
readonly type: "bool";
|
|
2823
|
+
readonly internalType: "bool";
|
|
2824
|
+
}];
|
|
2825
|
+
readonly stateMutability: "pure";
|
|
2826
|
+
}, {
|
|
2827
|
+
readonly type: "function";
|
|
2828
|
+
readonly name: "termsHash";
|
|
2829
|
+
readonly inputs: readonly [{
|
|
2830
|
+
readonly name: "lock";
|
|
2831
|
+
readonly type: "bytes32";
|
|
2832
|
+
readonly internalType: "bytes32";
|
|
2833
|
+
}];
|
|
2834
|
+
readonly outputs: readonly [{
|
|
2835
|
+
readonly name: "canonicalDigest";
|
|
2836
|
+
readonly type: "bytes32";
|
|
2837
|
+
readonly internalType: "bytes32";
|
|
2838
|
+
}];
|
|
2839
|
+
readonly stateMutability: "view";
|
|
2840
|
+
}, {
|
|
2841
|
+
readonly type: "function";
|
|
2842
|
+
readonly name: "transferOwnership";
|
|
2843
|
+
readonly inputs: readonly [{
|
|
2844
|
+
readonly name: "newOwner";
|
|
2845
|
+
readonly type: "address";
|
|
2846
|
+
readonly internalType: "address";
|
|
2847
|
+
}];
|
|
2848
|
+
readonly outputs: readonly [];
|
|
2849
|
+
readonly stateMutability: "nonpayable";
|
|
2850
|
+
}, {
|
|
2851
|
+
readonly type: "function";
|
|
2852
|
+
readonly name: "withdrawFees";
|
|
2853
|
+
readonly inputs: readonly [{
|
|
2854
|
+
readonly name: "to";
|
|
2855
|
+
readonly type: "address";
|
|
2856
|
+
readonly internalType: "address";
|
|
2857
|
+
}];
|
|
2858
|
+
readonly outputs: readonly [];
|
|
2859
|
+
readonly stateMutability: "nonpayable";
|
|
2860
|
+
}, {
|
|
2861
|
+
readonly type: "event";
|
|
2862
|
+
readonly name: "Claim";
|
|
2863
|
+
readonly inputs: readonly [{
|
|
2864
|
+
readonly name: "recipient";
|
|
2865
|
+
readonly type: "address";
|
|
2866
|
+
readonly indexed: false;
|
|
2867
|
+
readonly internalType: "address";
|
|
2868
|
+
}, {
|
|
2869
|
+
readonly name: "lock";
|
|
2870
|
+
readonly type: "bytes32";
|
|
2871
|
+
readonly indexed: true;
|
|
2872
|
+
readonly internalType: "bytes32";
|
|
2873
|
+
}, {
|
|
2874
|
+
readonly name: "secret";
|
|
2875
|
+
readonly type: "bytes32";
|
|
2876
|
+
readonly indexed: false;
|
|
2877
|
+
readonly internalType: "bytes32";
|
|
2878
|
+
}];
|
|
2879
|
+
readonly anonymous: false;
|
|
2880
|
+
}, {
|
|
2881
|
+
readonly type: "event";
|
|
2882
|
+
readonly name: "Commitment";
|
|
2883
|
+
readonly inputs: readonly [{
|
|
2884
|
+
readonly name: "lock";
|
|
2885
|
+
readonly type: "bytes32";
|
|
2886
|
+
readonly indexed: true;
|
|
2887
|
+
readonly internalType: "bytes32";
|
|
2888
|
+
}, {
|
|
2889
|
+
readonly name: "party";
|
|
2890
|
+
readonly type: "tuple";
|
|
2891
|
+
readonly indexed: false;
|
|
2892
|
+
readonly internalType: "struct Terms";
|
|
2893
|
+
readonly components: readonly [{
|
|
2894
|
+
readonly name: "chainId";
|
|
2895
|
+
readonly type: "uint256";
|
|
2896
|
+
readonly internalType: "uint256";
|
|
2897
|
+
}, {
|
|
2898
|
+
readonly name: "reclaimRecipient";
|
|
2899
|
+
readonly type: "address";
|
|
2900
|
+
readonly internalType: "address";
|
|
2901
|
+
}, {
|
|
2902
|
+
readonly name: "recipient";
|
|
2903
|
+
readonly type: "address";
|
|
2904
|
+
readonly internalType: "address";
|
|
2905
|
+
}, {
|
|
2906
|
+
readonly name: "commitmentDeadline";
|
|
2907
|
+
readonly type: "uint256";
|
|
2908
|
+
readonly internalType: "uint256";
|
|
2909
|
+
}, {
|
|
2910
|
+
readonly name: "claimDeadline";
|
|
2911
|
+
readonly type: "uint256";
|
|
2912
|
+
readonly internalType: "uint256";
|
|
2913
|
+
}, {
|
|
2914
|
+
readonly name: "reclaimRelease";
|
|
2915
|
+
readonly type: "uint256";
|
|
2916
|
+
readonly internalType: "uint256";
|
|
2917
|
+
}, {
|
|
2918
|
+
readonly name: "assets";
|
|
2919
|
+
readonly type: "tuple[]";
|
|
2920
|
+
readonly internalType: "struct Asset[]";
|
|
2921
|
+
readonly components: readonly [{
|
|
2922
|
+
readonly name: "assetType";
|
|
2923
|
+
readonly type: "uint8";
|
|
2924
|
+
readonly internalType: "enum AssetType";
|
|
2925
|
+
}, {
|
|
2926
|
+
readonly name: "target";
|
|
2927
|
+
readonly type: "address";
|
|
2928
|
+
readonly internalType: "address";
|
|
2929
|
+
}, {
|
|
2930
|
+
readonly name: "id";
|
|
2931
|
+
readonly type: "uint256";
|
|
2932
|
+
readonly internalType: "uint256";
|
|
2933
|
+
}, {
|
|
2934
|
+
readonly name: "amount";
|
|
2935
|
+
readonly type: "uint256";
|
|
2936
|
+
readonly internalType: "uint256";
|
|
2937
|
+
}];
|
|
2938
|
+
}];
|
|
2939
|
+
}, {
|
|
2940
|
+
readonly name: "committer";
|
|
2941
|
+
readonly type: "address";
|
|
2942
|
+
readonly indexed: true;
|
|
2943
|
+
readonly internalType: "address";
|
|
2944
|
+
}];
|
|
2945
|
+
readonly anonymous: false;
|
|
2946
|
+
}, {
|
|
2947
|
+
readonly type: "event";
|
|
2948
|
+
readonly name: "FeeUpdated";
|
|
2949
|
+
readonly inputs: readonly [{
|
|
2950
|
+
readonly name: "oldFee";
|
|
2951
|
+
readonly type: "uint256";
|
|
2952
|
+
readonly indexed: false;
|
|
2953
|
+
readonly internalType: "uint256";
|
|
2954
|
+
}, {
|
|
2955
|
+
readonly name: "newFee";
|
|
2956
|
+
readonly type: "uint256";
|
|
2957
|
+
readonly indexed: false;
|
|
2958
|
+
readonly internalType: "uint256";
|
|
2959
|
+
}];
|
|
2960
|
+
readonly anonymous: false;
|
|
2961
|
+
}, {
|
|
2962
|
+
readonly type: "event";
|
|
2963
|
+
readonly name: "FeesWithdrawn";
|
|
2964
|
+
readonly inputs: readonly [{
|
|
2965
|
+
readonly name: "to";
|
|
2966
|
+
readonly type: "address";
|
|
2967
|
+
readonly indexed: true;
|
|
2968
|
+
readonly internalType: "address";
|
|
2969
|
+
}, {
|
|
2970
|
+
readonly name: "amount";
|
|
2971
|
+
readonly type: "uint256";
|
|
2972
|
+
readonly indexed: false;
|
|
2973
|
+
readonly internalType: "uint256";
|
|
2974
|
+
}];
|
|
2975
|
+
readonly anonymous: false;
|
|
2976
|
+
}, {
|
|
2977
|
+
readonly type: "event";
|
|
2978
|
+
readonly name: "OwnershipTransferStarted";
|
|
2979
|
+
readonly inputs: readonly [{
|
|
2980
|
+
readonly name: "previousOwner";
|
|
2981
|
+
readonly type: "address";
|
|
2982
|
+
readonly indexed: true;
|
|
2983
|
+
readonly internalType: "address";
|
|
2984
|
+
}, {
|
|
2985
|
+
readonly name: "newOwner";
|
|
2986
|
+
readonly type: "address";
|
|
2987
|
+
readonly indexed: true;
|
|
2988
|
+
readonly internalType: "address";
|
|
2989
|
+
}];
|
|
2990
|
+
readonly anonymous: false;
|
|
2991
|
+
}, {
|
|
2992
|
+
readonly type: "event";
|
|
2993
|
+
readonly name: "OwnershipTransferred";
|
|
2994
|
+
readonly inputs: readonly [{
|
|
2995
|
+
readonly name: "previousOwner";
|
|
2996
|
+
readonly type: "address";
|
|
2997
|
+
readonly indexed: true;
|
|
2998
|
+
readonly internalType: "address";
|
|
2999
|
+
}, {
|
|
3000
|
+
readonly name: "newOwner";
|
|
3001
|
+
readonly type: "address";
|
|
3002
|
+
readonly indexed: true;
|
|
3003
|
+
readonly internalType: "address";
|
|
3004
|
+
}];
|
|
3005
|
+
readonly anonymous: false;
|
|
3006
|
+
}, {
|
|
3007
|
+
readonly type: "event";
|
|
3008
|
+
readonly name: "Reclaimed";
|
|
3009
|
+
readonly inputs: readonly [{
|
|
3010
|
+
readonly name: "caller";
|
|
3011
|
+
readonly type: "address";
|
|
3012
|
+
readonly indexed: false;
|
|
3013
|
+
readonly internalType: "address";
|
|
3014
|
+
}, {
|
|
3015
|
+
readonly name: "lock";
|
|
3016
|
+
readonly type: "bytes32";
|
|
3017
|
+
readonly indexed: true;
|
|
3018
|
+
readonly internalType: "bytes32";
|
|
3019
|
+
}, {
|
|
3020
|
+
readonly name: "recipient";
|
|
3021
|
+
readonly type: "address";
|
|
3022
|
+
readonly indexed: true;
|
|
3023
|
+
readonly internalType: "address";
|
|
3024
|
+
}];
|
|
3025
|
+
readonly anonymous: false;
|
|
3026
|
+
}, {
|
|
3027
|
+
readonly type: "error";
|
|
3028
|
+
readonly name: "CallerNotQuipWallet";
|
|
3029
|
+
readonly inputs: readonly [];
|
|
3030
|
+
}, {
|
|
3031
|
+
readonly type: "error";
|
|
3032
|
+
readonly name: "ChainIdMismatch";
|
|
3033
|
+
readonly inputs: readonly [];
|
|
3034
|
+
}, {
|
|
3035
|
+
readonly type: "error";
|
|
3036
|
+
readonly name: "DisordedDeadlines";
|
|
3037
|
+
readonly inputs: readonly [];
|
|
3038
|
+
}, {
|
|
3039
|
+
readonly type: "error";
|
|
3040
|
+
readonly name: "EmptyAssets";
|
|
3041
|
+
readonly inputs: readonly [];
|
|
3042
|
+
}, {
|
|
3043
|
+
readonly type: "error";
|
|
3044
|
+
readonly name: "FeeExceedsMax";
|
|
3045
|
+
readonly inputs: readonly [];
|
|
3046
|
+
}, {
|
|
3047
|
+
readonly type: "error";
|
|
3048
|
+
readonly name: "IncorrectNativeAmountReceived";
|
|
3049
|
+
readonly inputs: readonly [];
|
|
3050
|
+
}, {
|
|
3051
|
+
readonly type: "error";
|
|
3052
|
+
readonly name: "InvalidERC1155Asset";
|
|
3053
|
+
readonly inputs: readonly [];
|
|
3054
|
+
}, {
|
|
3055
|
+
readonly type: "error";
|
|
3056
|
+
readonly name: "InvalidERC20Asset";
|
|
3057
|
+
readonly inputs: readonly [];
|
|
3058
|
+
}, {
|
|
3059
|
+
readonly type: "error";
|
|
3060
|
+
readonly name: "InvalidERC721Asset";
|
|
3061
|
+
readonly inputs: readonly [];
|
|
3062
|
+
}, {
|
|
3063
|
+
readonly type: "error";
|
|
3064
|
+
readonly name: "InvalidLockAdvancement";
|
|
3065
|
+
readonly inputs: readonly [];
|
|
3066
|
+
}, {
|
|
3067
|
+
readonly type: "error";
|
|
3068
|
+
readonly name: "InvalidLockState";
|
|
3069
|
+
readonly inputs: readonly [];
|
|
3070
|
+
}, {
|
|
3071
|
+
readonly type: "error";
|
|
3072
|
+
readonly name: "InvalidNativeAsset";
|
|
3073
|
+
readonly inputs: readonly [];
|
|
3074
|
+
}, {
|
|
3075
|
+
readonly type: "error";
|
|
3076
|
+
readonly name: "InvalidRange";
|
|
3077
|
+
readonly inputs: readonly [];
|
|
3078
|
+
}, {
|
|
3079
|
+
readonly type: "error";
|
|
3080
|
+
readonly name: "OwnableInvalidOwner";
|
|
3081
|
+
readonly inputs: readonly [{
|
|
3082
|
+
readonly name: "owner";
|
|
3083
|
+
readonly type: "address";
|
|
3084
|
+
readonly internalType: "address";
|
|
3085
|
+
}];
|
|
3086
|
+
}, {
|
|
3087
|
+
readonly type: "error";
|
|
3088
|
+
readonly name: "OwnableUnauthorizedAccount";
|
|
3089
|
+
readonly inputs: readonly [{
|
|
3090
|
+
readonly name: "account";
|
|
3091
|
+
readonly type: "address";
|
|
3092
|
+
readonly internalType: "address";
|
|
3093
|
+
}];
|
|
3094
|
+
}, {
|
|
3095
|
+
readonly type: "error";
|
|
3096
|
+
readonly name: "TermsAlreadyPosted";
|
|
3097
|
+
readonly inputs: readonly [];
|
|
3098
|
+
}, {
|
|
3099
|
+
readonly type: "error";
|
|
3100
|
+
readonly name: "TermsMismatch";
|
|
3101
|
+
readonly inputs: readonly [];
|
|
3102
|
+
}, {
|
|
3103
|
+
readonly type: "error";
|
|
3104
|
+
readonly name: "TermsNotPosted";
|
|
3105
|
+
readonly inputs: readonly [];
|
|
3106
|
+
}, {
|
|
3107
|
+
readonly type: "error";
|
|
3108
|
+
readonly name: "UnexpectedAmountReceived";
|
|
3109
|
+
readonly inputs: readonly [];
|
|
3110
|
+
}, {
|
|
3111
|
+
readonly type: "error";
|
|
3112
|
+
readonly name: "WindowViolated";
|
|
3113
|
+
readonly inputs: readonly [];
|
|
3114
|
+
}, {
|
|
3115
|
+
readonly type: "error";
|
|
3116
|
+
readonly name: "ZeroAddressRecipient";
|
|
3117
|
+
readonly inputs: readonly [];
|
|
3118
|
+
}, {
|
|
3119
|
+
readonly type: "error";
|
|
3120
|
+
readonly name: "ZeroAmount";
|
|
3121
|
+
readonly inputs: readonly [];
|
|
3122
|
+
}, {
|
|
3123
|
+
readonly type: "error";
|
|
3124
|
+
readonly name: "ZeroChainId";
|
|
3125
|
+
readonly inputs: readonly [];
|
|
3126
|
+
}, {
|
|
3127
|
+
readonly type: "error";
|
|
3128
|
+
readonly name: "ZeroDeadline";
|
|
3129
|
+
readonly inputs: readonly [];
|
|
3130
|
+
}, {
|
|
3131
|
+
readonly type: "error";
|
|
3132
|
+
readonly name: "ZeroQuipFactory";
|
|
3133
|
+
readonly inputs: readonly [];
|
|
3134
|
+
}];
|
|
3135
|
+
|
|
3136
|
+
export { type ApprovalItem, type ApprovalPlan, type Asset, AssetType, type ClaimArgs, type ClaimEvent, type CommitArgs, type CommitmentEvent, type CreateOmnibusClientArgs, type CreateTermsArgs, type CrossChainSchedule, DEFAULT_BUFFERS, DEFAULT_CROSS_CHAIN_BUFFER_SECONDS, DEFAULT_GAS_MULTIPLIER, DEFAULT_SAME_CHAIN_BUFFER_SECONDS, type Erc1155ApprovalItem, type Erc20ApprovalItem, type Erc20ApprovalMode, type Erc721ApprovalItem, type EventQueryArgs, type FeeOverrides, type Hex32, LockState, MAX_GAS_MULTIPLIER, MAX_UINT256, MIN_GAS_MULTIPLIER, OMNIBUS_CREATE3_ADDRESS, type OmnibusAdmin, type OmnibusClient, type OmnibusDeployment, type OmnibusReceipt, type PlanApprovalsArgs, type PrepareTxArgs, type PrepareTxContractParams, type PreparedTx, QuipSwapError, type QuipSwapErrorCode, type QuipSwapErrorDetails, type ReclaimArgs, type ReclaimedEvent, type RemoteCommitmentStatus, type SameChainSwapPlan, type SameChainSwapStatus, type SameChainSwapStatusReport, type SecretLockPair, type SubmitApprovalArgs, type Terms, type TimeWindow, type TxOptions, type ValidateCrossChainScheduleArgs, type WaitOptions, applyGasMultiplier, assertHex32, assetArrayAbiParameter, buildFeeOverrides, checkScheduleBuffers, createOmnibusClient, createTerms, decodeClaimEvents, decodeCommitmentEvents, decodeReclaimedEvents, deriveSharedLock, digestTerms, digestTermsCanonically, enforceWithin, erc1155Asset, erc20Asset, erc721Asset, extractContractErrorName, extractRevealedSecret, extractSecretFromClaims, generateLock, generateSecret, getClaimEvents, getCommitmentEvents, getReclaimedEvents, getSameChainSwapStatus, isWithinWindow, knownDeployments, nativeAsset, omnibusAbi, planApprovals, planSameChainSwap, preflightBalanceCheck, prepareTx, proposedBy, proposerClaimWindow, proposerCommitWindow, quipFactoryAbi, reclaimWindow, resolveDeployment, resolveGasMultiplier, secretToPair, submitApproval, takerClaimWindow, takerCommitWindow, termsAbiParameter, totalNative, validateAsset, validateClaimWindow, validateCommitWindow, validateCrossChainSchedule, validateReclaimWindow, validateTermPairing, validateTerms, verifyRemoteCommitment, waitForOmnibusReceipt, watchClaimEvents, wrapContractError };
|