@cancore/contracts 0.1.0 → 0.2.0-rc.13

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.
Files changed (62) hide show
  1. package/README.md +522 -10
  2. package/dist/abi.d.ts +6598 -1675
  3. package/dist/abi.js +1 -1
  4. package/dist/chunk-2ELHDMZ7.js +9911 -0
  5. package/dist/chunk-2ELHDMZ7.js.map +1 -0
  6. package/dist/{chunk-CIBYXHSX.js → chunk-IAPV7XWJ.js} +2 -2
  7. package/dist/chunk-IAPV7XWJ.js.map +1 -0
  8. package/dist/index.d.ts +1774 -29
  9. package/dist/index.js +3692 -21
  10. package/dist/index.js.map +1 -1
  11. package/dist/networks.d.ts +2 -2
  12. package/dist/networks.js +1 -1
  13. package/package.json +10 -8
  14. package/spec/abi/AttestorSet.json +476 -0
  15. package/spec/abi/CNRX.json +1294 -0
  16. package/spec/abi/CNRXStaking.json +510 -0
  17. package/spec/abi/CancoreRouter.json +2666 -0
  18. package/spec/abi/FeeVault.json +604 -0
  19. package/spec/abi/HTLC.json +717 -0
  20. package/spec/abi/IAttribute.json +110 -0
  21. package/spec/abi/IBurnMintERC20.json +252 -0
  22. package/spec/abi/ICancoreRouter.json +1361 -0
  23. package/spec/abi/IFormula.json +28 -0
  24. package/spec/abi/IHTLC.json +382 -0
  25. package/spec/abi/IPayment.json +40 -0
  26. package/spec/abi/IPermit2.json +150 -0
  27. package/spec/abi/IResolver.json +55 -0
  28. package/spec/abi/IStep.json +30 -0
  29. package/spec/abi/IVariableRole.json +141 -0
  30. package/spec/abi/MultiBalanceChecker.json +34 -0
  31. package/spec/abi/PointsClaim.json +791 -0
  32. package/spec/constants.json +66 -0
  33. package/spec/protocol/asyncapi.json +1587 -0
  34. package/spec/protocol/messages.schema.json +906 -0
  35. package/spec/protocol/records.schema.json +94 -0
  36. package/spec/protocol/rest.schema.json +193 -0
  37. package/spec/protocol/typed-data/CantonTicketReceipt.json +77 -0
  38. package/spec/protocol/typed-data/FillerAuth.json +58 -0
  39. package/spec/protocol/typed-data/FillerKeyRegistration.json +69 -0
  40. package/spec/protocol/typed-data/FillerMessage.json +115 -0
  41. package/spec/protocol/typed-data/FillerQuote.json +75 -0
  42. package/spec/protocol/typed-data/GatewayMessage.json +95 -0
  43. package/spec/protocol/typed-data/StakeBinding.json +75 -0
  44. package/spec/protocol/typed-data/TicketIntent.json +113 -0
  45. package/spec/protocol/typed-data/TicketReceipt.json +51 -0
  46. package/spec/protocol/vectors/draw.json +61 -0
  47. package/spec/protocol/vectors/jcs.json +59 -0
  48. package/spec/protocol/vectors/messages.json +743 -0
  49. package/spec/protocol/vectors/records.json +81 -0
  50. package/spec/protocol/vectors/settle-attestations.json +544 -0
  51. package/spec/typed-data/FillProof.json +227 -0
  52. package/spec/typed-data/FillTicket.json +116 -0
  53. package/spec/typed-data/Order.json +169 -0
  54. package/spec/typed-data/Quote.json +79 -0
  55. package/spec/vectors/canton-destination.json +60 -0
  56. package/spec/vectors/canton-order.json +70 -0
  57. package/spec/vectors/evm-order.json +50 -0
  58. package/spec/vectors/fee-split.json +179 -0
  59. package/spec/vectors/permit-witness.json +150 -0
  60. package/dist/chunk-CIBYXHSX.js.map +0 -1
  61. package/dist/chunk-ZSX67S72.js +0 -3423
  62. package/dist/chunk-ZSX67S72.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- export { CNRX_ABI, CNRX_ERRORS, FEE_VAULT_ABI, FEE_VAULT_ERRORS, HTLC_ABI, HTLC_ERRORS, IBURN_MINT_ERC20_ABI, IHTLC_ABI, IPERMIT2_ABI, MULTI_BALANCE_CHECKER_ABI } from './chunk-ZSX67S72.js';
2
- export { NETWORKS, NETWORK_ALIASES, networkByChainId, networkKindOf, networkOf } from './chunk-CIBYXHSX.js';
1
+ export { ATTESTOR_SET_ABI, ATTESTOR_SET_ERRORS, CANCORE_ROUTER_ABI, CANCORE_ROUTER_ERRORS, CNRX_ABI, CNRX_ERRORS, CNRX_STAKING_ABI, CNRX_STAKING_ERRORS, FEE_VAULT_ABI, FEE_VAULT_ERRORS, HTLC_ABI, HTLC_ERRORS, IATTRIBUTE_ABI, IBURN_MINT_ERC20_ABI, ICANCORE_ROUTER_ABI, ICANCORE_ROUTER_ERRORS, IFORMULA_ABI, IHTLC_ABI, IPAYMENT_ABI, IPERMIT2_ABI, IRESOLVER_ABI, ISTEP_ABI, IVARIABLE_ROLE_ABI, MULTI_BALANCE_CHECKER_ABI, POINTS_CLAIM_ABI, POINTS_CLAIM_ERRORS } from './chunk-2ELHDMZ7.js';
2
+ export { NETWORKS, NETWORK_ALIASES, networkByChainId, networkKindOf, networkOf } from './chunk-IAPV7XWJ.js';
3
+ import { utf8ToBytes, concatBytes, bytesToHex, hexToBytes } from '@noble/hashes/utils';
4
+ import { keccak_256 } from '@noble/hashes/sha3';
3
5
 
4
6
  // src/deployments.ts
5
7
  var DEPLOYMENTS = {
@@ -16,10 +18,11 @@ var DEPLOYMENTS = {
16
18
  { network: "robinhood_testnet", chainId: 46630, htlc: "0x5eBf3faAf3a86c37dDf6a46075b8366Ed4D8021A", htlcBlock: 96742769, multiBalanceChecker: "0x9548fd6fA8A3869b215E9D86F6a2628Bf2BEFB74" }
17
19
  ],
18
20
  devnet: [
19
- { network: "sepolia", chainId: 11155111, htlc: "0xc74469B26206A7b3Aee2781EC21F9F47a1552DD6", htlcBlock: 10469876 },
20
- { network: "bnb_testnet", chainId: 97, htlc: "0xC649d578FD0122E2Ce3Bcf6b89E3ef2564d1a30D", htlcBlock: 96439032 },
21
- { network: "arbitrum_sepolia", chainId: 421614, htlc: "0xE23A046Df3542C4C548162adab4397956b136031", htlcBlock: 251260393 },
22
- { network: "robinhood_testnet", chainId: 46630, htlc: "0x58D154441Fd7efEd22E49Eda369909DdbE54cC0a", htlcBlock: 96651438, multiBalanceChecker: "0x1b2A32A976F904a1fca87D427239635Ccd97FaFb" }
21
+ // Routers: evm-contracts deployments/router/dev/*.json (#120, CAN-2327), verified on chain 2026-10-14.
22
+ { network: "sepolia", chainId: 11155111, htlc: "0xc74469B26206A7b3Aee2781EC21F9F47a1552DD6", htlcBlock: 10469876, router: "0xfd227a0de77807206f4eEF9eE6eDd5795a45EF95", routerBlock: 11913649 },
23
+ { network: "bnb_testnet", chainId: 97, htlc: "0xC649d578FD0122E2Ce3Bcf6b89E3ef2564d1a30D", htlcBlock: 96439032, router: "0x57A8ad8392C5fF21aF52Fc3Cf246C1a464aCc6B1", routerBlock: 136752813 },
24
+ { network: "arbitrum_sepolia", chainId: 421614, htlc: "0xE23A046Df3542C4C548162adab4397956b136031", htlcBlock: 251260393, router: "0x7e27831316F7Ee8E44B96056F4354A6D1a22953a", routerBlock: 319105856 },
25
+ { network: "robinhood_testnet", chainId: 46630, htlc: "0x58D154441Fd7efEd22E49Eda369909DdbE54cC0a", htlcBlock: 96651438, multiBalanceChecker: "0x1b2A32A976F904a1fca87D427239635Ccd97FaFb", router: "0xF833A980ae858fe3cD14a79a9f610525AbB95BF9", routerBlock: 135089078 }
23
26
  ]
24
27
  };
25
28
  var PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
@@ -27,6 +30,264 @@ function deploymentOf(env, network) {
27
30
  return DEPLOYMENTS[env].find((d) => d.network === network);
28
31
  }
29
32
 
33
+ // src/generated/typedData.ts
34
+ var FILL_PROOF_TYPES = {
35
+ "FillProof": [
36
+ {
37
+ "name": "kind",
38
+ "type": "uint8"
39
+ },
40
+ {
41
+ "name": "orderHash",
42
+ "type": "bytes32"
43
+ },
44
+ {
45
+ "name": "destination",
46
+ "type": "bytes32"
47
+ },
48
+ {
49
+ "name": "fillRef",
50
+ "type": "bytes32"
51
+ },
52
+ {
53
+ "name": "recipient",
54
+ "type": "bytes32"
55
+ },
56
+ {
57
+ "name": "outputAsset",
58
+ "type": "bytes32"
59
+ },
60
+ {
61
+ "name": "amountDelivered",
62
+ "type": "uint256"
63
+ },
64
+ {
65
+ "name": "filledAt",
66
+ "type": "uint64"
67
+ },
68
+ {
69
+ "name": "fillerId",
70
+ "type": "bytes32"
71
+ },
72
+ {
73
+ "name": "repayTo",
74
+ "type": "bytes32"
75
+ },
76
+ {
77
+ "name": "attempt",
78
+ "type": "uint32"
79
+ },
80
+ {
81
+ "name": "setId",
82
+ "type": "uint32"
83
+ }
84
+ ]
85
+ };
86
+ var FILL_PROOF_TYPE_STRING = "FillProof(uint8 kind,bytes32 orderHash,bytes32 destination,bytes32 fillRef,bytes32 recipient,bytes32 outputAsset,uint256 amountDelivered,uint64 filledAt,bytes32 fillerId,bytes32 repayTo,uint32 attempt,uint32 setId)";
87
+ var FILL_PROOF_DOMAIN = { "name": "CancoreRouter", "version": "1" };
88
+ var FILL_TICKET_TYPES = {
89
+ "FillTicket": [
90
+ {
91
+ "name": "orderHash",
92
+ "type": "bytes32"
93
+ },
94
+ {
95
+ "name": "fillerId",
96
+ "type": "bytes32"
97
+ },
98
+ {
99
+ "name": "deliveryKey",
100
+ "type": "address"
101
+ },
102
+ {
103
+ "name": "repayTo",
104
+ "type": "bytes32"
105
+ },
106
+ {
107
+ "name": "attempt",
108
+ "type": "uint32"
109
+ },
110
+ {
111
+ "name": "validFrom",
112
+ "type": "uint64"
113
+ },
114
+ {
115
+ "name": "validUntil",
116
+ "type": "uint64"
117
+ }
118
+ ]
119
+ };
120
+ var FILL_TICKET_DOMAIN = { "name": "CancoreFillTicket", "version": "1" };
121
+ var ORDER_TYPES = {
122
+ "Order": [
123
+ {
124
+ "name": "user",
125
+ "type": "address"
126
+ },
127
+ {
128
+ "name": "originChainId",
129
+ "type": "uint64"
130
+ },
131
+ {
132
+ "name": "inputToken",
133
+ "type": "address"
134
+ },
135
+ {
136
+ "name": "inputAmount",
137
+ "type": "uint256"
138
+ },
139
+ {
140
+ "name": "destination",
141
+ "type": "bytes32"
142
+ },
143
+ {
144
+ "name": "outputAsset",
145
+ "type": "bytes32"
146
+ },
147
+ {
148
+ "name": "minReceived",
149
+ "type": "uint256"
150
+ },
151
+ {
152
+ "name": "recipient",
153
+ "type": "bytes32"
154
+ },
155
+ {
156
+ "name": "createdAt",
157
+ "type": "uint64"
158
+ },
159
+ {
160
+ "name": "fillDeadline",
161
+ "type": "uint64"
162
+ },
163
+ {
164
+ "name": "feeBps",
165
+ "type": "uint16"
166
+ },
167
+ {
168
+ "name": "fillerId",
169
+ "type": "bytes32"
170
+ }
171
+ ]
172
+ };
173
+ var ORDER_DOMAIN = { "name": "CancoreRouter", "version": "1" };
174
+ var QUOTE_TYPES = {
175
+ "Quote": [
176
+ {
177
+ "name": "orderHash",
178
+ "type": "bytes32"
179
+ },
180
+ {
181
+ "name": "quoteDeadline",
182
+ "type": "uint64"
183
+ }
184
+ ]
185
+ };
186
+ var toHex = (bytes) => `0x${bytesToHex(bytes)}`;
187
+ var keccak = (bytes) => keccak_256(bytes);
188
+ function hexBytes(value, field, length) {
189
+ if (typeof value !== "string" || !/^0x([0-9a-fA-F]{2})*$/.test(value)) throw new TypeError(`${field}: expected 0x-prefixed hex, got ${String(value)}`);
190
+ const bytes = hexToBytes(value.slice(2));
191
+ if (length !== void 0 && bytes.length !== length) throw new TypeError(`${field}: expected ${length} bytes, got ${bytes.length}`);
192
+ return bytes;
193
+ }
194
+ function uint(value, bits, field) {
195
+ let n;
196
+ if (typeof value === "bigint") n = value;
197
+ else if (typeof value === "number" && Number.isSafeInteger(value)) n = BigInt(value);
198
+ else if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) n = BigInt(value);
199
+ else throw new TypeError(`${field}: expected an unsigned integer, got ${String(value)}`);
200
+ if (n < 0n || n >= 1n << BigInt(bits)) throw new RangeError(`${field}: ${n} does not fit uint${bits}`);
201
+ return n;
202
+ }
203
+ var beBytes = (n, size) => hexToBytes(n.toString(16).padStart(size * 2, "0"));
204
+
205
+ // src/protocol/hash.ts
206
+ var ATOMIC = /^(address|bool|string|bytes([1-9]|[12][0-9]|3[0-2])?|uint(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256))$/;
207
+ var flatOnly = (type, field) => new TypeError(`${field}: type ${type} is not supported \u2014 hashTypedData encodes flat structs of address/bool/bytes/bytesN/string/uintN only`);
208
+ function encodeValue(type, value, field) {
209
+ if (type === "address") return padded(hexBytes(value, field, 20), 12);
210
+ if (type === "string") {
211
+ if (typeof value !== "string") throw new TypeError(`${field}: expected a string`);
212
+ return keccak(utf8ToBytes(value));
213
+ }
214
+ if (type === "bool") {
215
+ if (typeof value !== "boolean") throw new TypeError(`${field}: expected a boolean`);
216
+ return beBytes(value ? 1n : 0n, 32);
217
+ }
218
+ if (type === "bytes") return keccak(hexBytes(value, field));
219
+ if (type.startsWith("bytes")) return padded(hexBytes(value, field, Number(type.slice(5))), 0);
220
+ return beBytes(uint(value, Number(type.slice(4)), field), 32);
221
+ }
222
+ function padded(bytes, offset) {
223
+ const word = new Uint8Array(32);
224
+ word.set(bytes, offset);
225
+ return word;
226
+ }
227
+ function fieldsOf(types, primaryType) {
228
+ const fields = types[primaryType];
229
+ if (!fields) throw new TypeError(`no type ${primaryType}`);
230
+ for (const f of fields) if (!ATOMIC.test(f.type)) throw flatOnly(f.type, `${primaryType}.${f.name}`);
231
+ return fields;
232
+ }
233
+ function encodeType(types, primaryType) {
234
+ return `${primaryType}(${fieldsOf(types, primaryType).map((f) => `${f.type} ${f.name}`).join(",")})`;
235
+ }
236
+ function typeHash(types, primaryType) {
237
+ return toHex(keccak(utf8ToBytes(encodeType(types, primaryType))));
238
+ }
239
+ function structHash(types, primaryType, message) {
240
+ const words = fieldsOf(types, primaryType).map((f) => encodeValue(f.type, message[f.name], `${primaryType}.${f.name}`));
241
+ return keccak(concatBytes(keccak(utf8ToBytes(encodeType(types, primaryType))), ...words));
242
+ }
243
+ function hashStruct(types, primaryType, message) {
244
+ return toHex(structHash(types, primaryType, message));
245
+ }
246
+ var DOMAIN_FIELDS = [
247
+ { name: "name", type: "string" },
248
+ { name: "version", type: "string" },
249
+ { name: "chainId", type: "uint256" },
250
+ { name: "verifyingContract", type: "address" },
251
+ { name: "salt", type: "bytes32" }
252
+ ];
253
+ function hashDomain(domain) {
254
+ const present = DOMAIN_FIELDS.filter((f) => domain[f.name] !== void 0);
255
+ return hashStruct({ EIP712Domain: present }, "EIP712Domain", domain);
256
+ }
257
+ function hashTypedData({ domain, types, primaryType, message }) {
258
+ const separator = hexBytes(hashDomain(domain), "domain", 32);
259
+ return toHex(keccak(concatBytes(new Uint8Array([25, 1]), separator, structHash(types, primaryType, message))));
260
+ }
261
+ function jcs(value) {
262
+ if (value === null || typeof value === "boolean") return JSON.stringify(value);
263
+ if (typeof value === "string") {
264
+ if (/\p{Cs}/u.test(value)) throw new TypeError("jcs: lone surrogate in a string");
265
+ return JSON.stringify(value);
266
+ }
267
+ if (typeof value === "number") {
268
+ if (!Number.isSafeInteger(value)) throw new TypeError(`jcs: ${value} is not a safe integer`);
269
+ return JSON.stringify(value);
270
+ }
271
+ if (Array.isArray(value)) return `[${value.map(jcs).join(",")}]`;
272
+ if (typeof value === "object") {
273
+ const obj = value;
274
+ return `{${Object.keys(obj).sort().map((k) => `${jcs(k)}:${jcs(obj[k])}`).join(",")}}`;
275
+ }
276
+ throw new TypeError(`jcs: a ${typeof value} has no JSON form`);
277
+ }
278
+ function gatewayBodyHash(message) {
279
+ const { sig: _sig, ...body } = message;
280
+ return toHex(keccak(utf8ToBytes(jcs(body))));
281
+ }
282
+ function fillerMessageBodyHash(message) {
283
+ const { msgSig: _msgSig, ...body } = message;
284
+ return toHex(keccak(utf8ToBytes(jcs(body))));
285
+ }
286
+ function requestIdHash(requestId) {
287
+ if (!/^[\x21-\x7e]{1,64}$/.test(requestId)) throw new TypeError(`requestId must be 1..64 printable ASCII characters: ${JSON.stringify(requestId)}`);
288
+ return toHex(keccak(utf8ToBytes(requestId)));
289
+ }
290
+
30
291
  // src/eip712.ts
31
292
  var FEE_CLAIM_DOMAIN_NAME = "CancoreFeeVault";
32
293
  var FEE_CLAIM_DOMAIN_VERSION = "1";
@@ -47,25 +308,3417 @@ function feeClaimDomain(chainId, verifyingContract) {
47
308
  verifyingContract
48
309
  };
49
310
  }
311
+ var PROOF_KIND_ATTESTATION = 1;
312
+ function fillProofDomain(chainId, verifyingContract) {
313
+ return { ...FILL_PROOF_DOMAIN, chainId, verifyingContract };
314
+ }
315
+ function hashFillProof(proof, chainId, verifyingContract) {
316
+ return hashTypedData({ domain: fillProofDomain(chainId, verifyingContract), types: FILL_PROOF_TYPES, primaryType: "FillProof", message: { ...proof } });
317
+ }
318
+
319
+ // src/constants.ts
320
+ var BPS = 1e4;
321
+ var MAX_FEE_BPS = 1e3;
322
+ var MIN_FILL_TTL = 60;
323
+ var MAX_FILL_TTL = 86400;
324
+ var MAX_SIG_TTL = 86400;
325
+ var MAX_PROOF_WINDOW = 14400;
326
+ var GRACE = MAX_FILL_TTL + MAX_PROOF_WINDOW;
327
+ var SET_DELAY = 259200;
328
+ var EIP2294_MAX_CHAIN_ID = 9223372036854775771n;
329
+ var CANTON_ORIGIN_ID = {
330
+ mainnet: 9223372036854775809n,
331
+ testnet: 9223372036854775810n,
332
+ devnet: 9223372036854775811n
333
+ };
334
+ var CANTON_SOURCE_ANCHOR = "0x2f37b46Ea93001829498b145985fb53028033701";
335
+ var OWNER_LABEL_TAG = "cancore:owner:v1";
336
+ var INSTRUMENT_LABEL_TAG = "cancore:instrument:v1";
337
+ var DAML_NUMERIC_SCALE = 10;
338
+ function exactUnits(value, decimals, field) {
339
+ if (typeof value !== "string" || !/^\d+(\.\d+)?$/.test(value)) throw new TypeError(`${field}: not a plain decimal string: ${String(value)}`);
340
+ if (!Number.isSafeInteger(decimals) || decimals < 0) throw new TypeError(`${field}: decimals must be a non-negative integer`);
341
+ const [whole, fraction = ""] = value.split(".");
342
+ if (fraction.length > decimals) throw new RangeError(`${field}: ${value} does not fit ${decimals} decimals exactly`);
343
+ return BigInt(whole + fraction.padEnd(decimals, "0"));
344
+ }
345
+ function abiEncodeStrings(values) {
346
+ const tails = values.map((v) => {
347
+ const bytes = utf8ToBytes(v);
348
+ const body = new Uint8Array(Math.ceil(bytes.length / 32) * 32);
349
+ body.set(bytes);
350
+ return concatBytes(beBytes(BigInt(bytes.length), 32), body);
351
+ });
352
+ let offset = BigInt(values.length * 32);
353
+ const heads = tails.map((t) => {
354
+ const head = beBytes(offset, 32);
355
+ offset += BigInt(t.length);
356
+ return head;
357
+ });
358
+ return concatBytes(...heads, ...tails);
359
+ }
360
+ var FILLER_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
361
+ var SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
362
+ function fillerIdHash(fillerId) {
363
+ if (typeof fillerId !== "string" || !FILLER_ID_PATTERN.test(fillerId)) throw new TypeError(`fillerId must match ${FILLER_ID_PATTERN}: ${JSON.stringify(fillerId)}`);
364
+ return toHex(keccak(utf8ToBytes(fillerId)));
365
+ }
366
+ function repayToFromEvm(address) {
367
+ const bytes = hexBytes(address, "repayTo address", 20);
368
+ if (bytes.every((b) => b === 0)) throw new RangeError("repayTo: the zero address is not a payee");
369
+ return `0x${"00".repeat(12)}${address.slice(2).toLowerCase()}`;
370
+ }
371
+ function repayToFromParty(partyId) {
372
+ if (typeof partyId !== "string" || partyId.length === 0) throw new TypeError("repayTo: a Canton party id is a non-empty string");
373
+ return toHex(keccak(utf8ToBytes(partyId)));
374
+ }
375
+ function isEvmRepayTo(repayTo) {
376
+ return /^0x0{24}[0-9a-fA-F]{40}$/.test(repayTo) && !/^0x0{64}$/.test(repayTo);
377
+ }
378
+ function evmAddressFromRepayTo(repayTo) {
379
+ hexBytes(repayTo, "repayTo", 32);
380
+ if (!isEvmRepayTo(repayTo)) throw new RangeError(`repayTo ${repayTo} is not a padded, non-zero EVM address`);
381
+ return `0x${repayTo.slice(26).toLowerCase()}`;
382
+ }
383
+ function isEoaSignature(sig) {
384
+ if (typeof sig !== "string" || !/^0x[0-9a-fA-F]{128}(1[bB]|1[cC])$/.test(sig)) return false;
385
+ const r = BigInt(`0x${sig.slice(2, 66)}`);
386
+ const s = BigInt(`0x${sig.slice(66, 130)}`);
387
+ return r > 0n && r < SECP256K1_N && s > 0n && s <= SECP256K1_N / 2n;
388
+ }
389
+
390
+ // src/protocol/typedData.ts
391
+ var FILLER_PROTOCOL_DOMAIN = { name: "CancoreFillerProtocol", version: "1" };
392
+ function routerDomain(chainId, verifyingContract) {
393
+ return { ...ORDER_DOMAIN, chainId, verifyingContract };
394
+ }
395
+ var FILLER_QUOTE_TYPES = {
396
+ FillerQuote: [
397
+ { name: "requestId", type: "bytes32" },
398
+ { name: "fillerId", type: "string" },
399
+ { name: "amountOut", type: "uint256" },
400
+ { name: "validUntil", type: "uint64" },
401
+ { name: "nonce", type: "uint64" }
402
+ ]
403
+ };
404
+ var TICKET_INTENT_TYPES = {
405
+ TicketIntent: [
406
+ { name: "orderHash", type: "bytes32" },
407
+ { name: "attempt", type: "uint32" },
408
+ { name: "validFrom", type: "uint64" },
409
+ { name: "validUntil", type: "uint64" },
410
+ { name: "fillerId", type: "string" },
411
+ { name: "deliveryKey", type: "address" },
412
+ { name: "repayTo", type: "bytes32" }
413
+ ]
414
+ };
415
+ var TICKET_RECEIPT_TYPES = {
416
+ TicketReceipt: [
417
+ { name: "ticketHash", type: "bytes32" },
418
+ { name: "ticketSigHash", type: "bytes32" }
419
+ ]
420
+ };
421
+ var CANTON_TICKET_RECEIPT_TYPES = {
422
+ CantonTicketReceipt: [
423
+ { name: "orderHash", type: "bytes32" },
424
+ { name: "attempt", type: "uint32" },
425
+ { name: "deliveryOrderCidHash", type: "bytes32" },
426
+ { name: "validUntil", type: "uint64" }
427
+ ]
428
+ };
429
+ var STAKE_BINDING_TYPES = {
430
+ StakeBinding: [
431
+ { name: "partnerId", type: "string" },
432
+ { name: "stakingAddress", type: "address" },
433
+ { name: "chainId", type: "uint256" },
434
+ { name: "nonce", type: "uint64" }
435
+ ]
436
+ };
437
+ var FILLER_AUTH_TYPES = {
438
+ FillerAuth: [
439
+ { name: "fillerId", type: "string" },
440
+ { name: "nonce", type: "bytes32" },
441
+ { name: "expiresAt", type: "uint64" }
442
+ ]
443
+ };
444
+ var GATEWAY_MESSAGE_TYPES = {
445
+ GatewayMessage: [{ name: "bodyHash", type: "bytes32" }]
446
+ };
447
+ var FILLER_MESSAGE_TYPES = {
448
+ FillerMessage: [{ name: "bodyHash", type: "bytes32" }]
449
+ };
450
+ var FILLER_KEY_REGISTRATION_TYPES = {
451
+ FillerKeyRegistration: [
452
+ { name: "fillerId", type: "string" },
453
+ { name: "messageKey", type: "address" },
454
+ { name: "issuedAt", type: "uint64" }
455
+ ]
456
+ };
457
+
458
+ // src/order.ts
459
+ function hashOrder(order, domain) {
460
+ return hashTypedData({ domain: routerDomain(domain.chainId, domain.verifyingContract), types: ORDER_TYPES, primaryType: "Order", message: { ...order } });
461
+ }
462
+ function isCantonOriginId(chainId) {
463
+ let id;
464
+ try {
465
+ id = uint(chainId, 64, "chainId");
466
+ } catch {
467
+ return false;
468
+ }
469
+ return Object.values(CANTON_ORIGIN_ID).includes(id);
470
+ }
471
+ function sourceOrderHash(order, sourceRouter) {
472
+ const router = sourceRouter ?? (isCantonOriginId(order.originChainId) ? CANTON_SOURCE_ANCHOR : void 0);
473
+ if (router === void 0) throw new Error(`sourceOrderHash: no source router for originChainId ${String(order.originChainId)} (SourceRouterUnknown)`);
474
+ return hashOrder(order, { chainId: order.originChainId, verifyingContract: router });
475
+ }
476
+ function buildCantonSourceOrder(intent) {
477
+ for (const field of ["ownerPartyId", "requestId", "instrumentAdmin", "instrumentId"]) {
478
+ if (typeof intent[field] !== "string" || intent[field].length === 0) throw new TypeError(`${field}: a non-empty string`);
479
+ }
480
+ const originChainId = uint(intent.cantonOriginId, 64, "cantonOriginId");
481
+ if (originChainId <= EIP2294_MAX_CHAIN_ID) throw new RangeError(`cantonOriginId: ${originChainId} collides with the EVM chain-id range`);
482
+ const feeBps = exactUnits(intent.feeRate, 4, "feeRate");
483
+ if (feeBps > BigInt(MAX_FEE_BPS)) throw new RangeError(`feeRate: ${intent.feeRate} exceeds MAX_FEE_BPS`);
484
+ const order = {
485
+ user: label(OWNER_LABEL_TAG, intent.ownerPartyId, intent.requestId),
486
+ originChainId: originChainId.toString(),
487
+ inputToken: label(INSTRUMENT_LABEL_TAG, intent.instrumentAdmin, intent.instrumentId),
488
+ inputAmount: exactUnits(intent.amount, DAML_NUMERIC_SCALE, "amount").toString(),
489
+ destination: toHex(beBytes(uint(intent.destinationChainId, 256, "destinationChainId"), 32)),
490
+ outputAsset: addressWord(intent.wantToken, "wantToken"),
491
+ minReceived: exactUnits(intent.minReceived, intent.wantDecimals, "minReceived").toString(),
492
+ recipient: addressWord(intent.recipient, "recipient"),
493
+ createdAt: wholeSecond(intent.createdAt, "createdAt"),
494
+ fillDeadline: wholeSecond(intent.fillDeadline, "fillDeadline"),
495
+ feeBps: feeBps.toString(),
496
+ // refuses an empty or malformed id: an order with no picked filler can be filled by nobody
497
+ fillerId: fillerIdHash(intent.fillerId)
498
+ };
499
+ const domain = { name: "CancoreRouter", version: "1", chainId: originChainId.toString(), verifyingContract: CANTON_SOURCE_ANCHOR };
500
+ return { order, domain, orderHash: hashOrder(order, domain) };
501
+ }
502
+ var TOKEN_PERMISSIONS_TYPES = {
503
+ TokenPermissions: [
504
+ { name: "token", type: "address" },
505
+ { name: "amount", type: "uint256" }
506
+ ]
507
+ };
508
+ var PERMIT2_WITNESS_TYPE_STRING = `Order witness)${encodeType(ORDER_TYPES, "Order")}${encodeType(TOKEN_PERMISSIONS_TYPES, "TokenPermissions")}`;
509
+ var PERMIT_WITNESS_TYPEHASH = keccak(
510
+ utf8ToBytes(`PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,${PERMIT2_WITNESS_TYPE_STRING}`)
511
+ );
512
+ var PERMIT_WITNESS_TYPES = {
513
+ PermitWitnessTransferFrom: [
514
+ { name: "permitted", type: "TokenPermissions" },
515
+ { name: "spender", type: "address" },
516
+ { name: "nonce", type: "uint256" },
517
+ { name: "deadline", type: "uint256" },
518
+ { name: "witness", type: "Order" }
519
+ ],
520
+ ...TOKEN_PERMISSIONS_TYPES,
521
+ ...ORDER_TYPES
522
+ };
523
+ function permit2Domain(chainId, permit2 = PERMIT2_ADDRESS) {
524
+ return { name: "Permit2", chainId, verifyingContract: permit2 };
525
+ }
526
+ function hashPermitWitness(permit, chainId, permit2 = PERMIT2_ADDRESS) {
527
+ const struct = keccak(
528
+ concatBytes(
529
+ PERMIT_WITNESS_TYPEHASH,
530
+ hexBytes(hashStruct(TOKEN_PERMISSIONS_TYPES, "TokenPermissions", permit.permitted), "permitted", 32),
531
+ hexBytes(addressWord(permit.spender, "spender"), "spender", 32),
532
+ beBytes(uint(permit.nonce, 256, "nonce"), 32),
533
+ beBytes(uint(permit.deadline, 256, "deadline"), 32),
534
+ hexBytes(hashStruct(ORDER_TYPES, "Order", { ...permit.witness }), "witness", 32)
535
+ )
536
+ );
537
+ const separator = hexBytes(hashDomain(permit2Domain(chainId, permit2)), "domain", 32);
538
+ return toHex(keccak(concatBytes(new Uint8Array([25, 1]), separator, struct)));
539
+ }
540
+ function wholeSecond(value, field) {
541
+ return uint(value, 64, `${field} (a whole second)`).toString();
542
+ }
543
+ function addressWord(value, field) {
544
+ const address = checksumAddress(value, field);
545
+ return `0x${"00".repeat(12)}${address.slice(2).toLowerCase()}`;
546
+ }
547
+ function checksumAddress(value, field) {
548
+ hexBytes(value, field, 20);
549
+ const lower = value.slice(2).toLowerCase();
550
+ const hash = toHex(keccak(utf8ToBytes(lower))).slice(2);
551
+ const sum = `0x${[...lower].map((c, i) => parseInt(hash[i], 16) >= 8 ? c.toUpperCase() : c).join("")}`;
552
+ const body = value.slice(2);
553
+ if (body !== body.toLowerCase() && body !== body.toUpperCase() && `0x${body}` !== sum) throw new TypeError(`${field}: bad EIP-55 checksum: ${String(value)}`);
554
+ return sum;
555
+ }
556
+ function label(tag, a, b) {
557
+ const hash = toHex(keccak(abiEncodeStrings([tag, a, b])));
558
+ return checksumAddress(`0x${hash.slice(-40)}`, "label");
559
+ }
560
+
561
+ // src/fee.ts
562
+ function operands(total, feeBps) {
563
+ const t = uint(total, 256, "total");
564
+ const bps = uint(feeBps, 16, "feeBps");
565
+ if (bps > BigInt(MAX_FEE_BPS)) throw new RangeError(`feeBps: ${bps} exceeds MAX_FEE_BPS (${MAX_FEE_BPS})`);
566
+ return [t, bps];
567
+ }
568
+ function inclusiveFeeSplit(total, feeBps) {
569
+ const [t, bps] = operands(total, feeBps);
570
+ const payout = t * BigInt(BPS) / (BigInt(BPS) + bps);
571
+ return { payout, fee: t - payout };
572
+ }
573
+ function cantonInclusiveFeeSplit(total, feeBps) {
574
+ const [t, bps] = operands(total, feeBps);
575
+ const n = t * BigInt(BPS);
576
+ const d = BigInt(BPS) + bps;
577
+ const q = n / d;
578
+ const r = n - q * d;
579
+ const payout = 2n * r > d || 2n * r === d && q % 2n === 1n ? q + 1n : q;
580
+ return { payout, fee: t - payout };
581
+ }
582
+ var NETWORKS2 = Object.keys(CANTON_ORIGIN_ID);
583
+ var utf8Hash = (text) => toHex(keccak(utf8ToBytes(text)));
584
+ var nonEmpty = (value, field) => {
585
+ if (typeof value !== "string" || value.length === 0) throw new TypeError(`${field}: a non-empty string`);
586
+ return value;
587
+ };
588
+ function encodeCantonDestination(network) {
589
+ if (!NETWORKS2.includes(network)) throw new TypeError(`network: one of ${NETWORKS2.join(", ")}, got ${JSON.stringify(network)}`);
590
+ return utf8Hash(`canton:${network}`);
591
+ }
592
+ function cantonNetworkOfDestination(destination) {
593
+ const word = typeof destination === "string" ? destination.toLowerCase() : "";
594
+ return NETWORKS2.find((network) => encodeCantonDestination(network) === word);
595
+ }
596
+ function encodeCantonOutputAsset(instrument) {
597
+ return toHex(keccak(abiEncodeStrings([INSTRUMENT_LABEL_TAG, nonEmpty(instrument.admin, "instrument.admin"), nonEmpty(instrument.id, "instrument.id")])));
598
+ }
599
+ function encodeCantonRecipient(partyId) {
600
+ return utf8Hash(nonEmpty(partyId, "partyId"));
601
+ }
602
+ function encodeCantonAmount(amount) {
603
+ return exactUnits(amount, DAML_NUMERIC_SCALE, "amount");
604
+ }
605
+ var hashFillTicket = (ticket) => hashTypedData({ domain: FILL_TICKET_DOMAIN, types: FILL_TICKET_TYPES, primaryType: "FillTicket", message: { ...ticket } });
606
+ var hashFillerQuote = (quote) => hashTypedData({ domain: FILLER_PROTOCOL_DOMAIN, types: FILLER_QUOTE_TYPES, primaryType: "FillerQuote", message: { ...quote } });
607
+ var hashTicketIntent = (intent) => hashTypedData({ domain: FILLER_PROTOCOL_DOMAIN, types: TICKET_INTENT_TYPES, primaryType: "TicketIntent", message: { ...intent } });
608
+ var hashFillerMessage = (message) => hashTypedData({ domain: FILLER_PROTOCOL_DOMAIN, types: FILLER_MESSAGE_TYPES, primaryType: "FillerMessage", message: { bodyHash: fillerMessageBodyHash(message) } });
609
+ var hashFillerKeyRegistration = (registration) => hashTypedData({ domain: FILLER_PROTOCOL_DOMAIN, types: FILLER_KEY_REGISTRATION_TYPES, primaryType: "FillerKeyRegistration", message: { ...registration } });
610
+ function deliveryOrderCidHash(deliveryOrderCid) {
611
+ if (typeof deliveryOrderCid !== "string" || deliveryOrderCid.length === 0) throw new TypeError("deliveryOrderCid: a Canton contract id is a non-empty string");
612
+ return toHex(keccak(utf8ToBytes(deliveryOrderCid)));
613
+ }
614
+ function cantonTicketReceipt(ticket) {
615
+ hexBytes(ticket.orderHash, "orderHash", 32);
616
+ return {
617
+ orderHash: ticket.orderHash.toLowerCase(),
618
+ attempt: Number(uint(ticket.attempt, 32, "attempt")),
619
+ deliveryOrderCidHash: deliveryOrderCidHash(ticket.deliveryOrderCid),
620
+ validUntil: uint(ticket.validUntil, 64, "validUntil").toString()
621
+ };
622
+ }
623
+ var hashCantonTicketReceipt = (receipt) => hashTypedData({ domain: FILLER_PROTOCOL_DOMAIN, types: CANTON_TICKET_RECEIPT_TYPES, primaryType: "CantonTicketReceipt", message: { ...receipt } });
624
+
625
+ // src/protocol/envelope.ts
626
+ function fillerEnvelopeError(message, ctx) {
627
+ const { msgSig, fillerId, sentAt, id } = message;
628
+ if (!isEoaSignature(msgSig)) return "BAD_SIGNATURE";
629
+ if (fillerId !== ctx.fillerId) return "UNAUTHENTICATED";
630
+ if (typeof sentAt !== "number" || !Number.isSafeInteger(sentAt) || sentAt < 1e12) return "BAD_REQUEST";
631
+ if (Math.abs(ctx.receivedAt - sentAt) > ctx.maxMessageAgeMs) return "STALE_MESSAGE";
632
+ if (typeof id !== "string" || id.length < 1 || id.length > 64) return "BAD_REQUEST";
633
+ return null;
634
+ }
635
+ function messageIdRetainUntil(sentAt, receivedAt, maxMessageAgeMs) {
636
+ return Math.max(receivedAt, sentAt) + maxMessageAgeMs;
637
+ }
638
+ var DRAND_QUICKNET = {
639
+ chainHash: "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971",
640
+ publicKey: "83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a",
641
+ scheme: "bls-unchained-g1-rfc9380",
642
+ genesisTime: 1692803367,
643
+ period: 3
644
+ };
645
+ function firstRoundAtOrAfter(unixSeconds) {
646
+ const t = BigInt(unixSeconds);
647
+ const genesis = BigInt(DRAND_QUICKNET.genesisTime);
648
+ const period = BigInt(DRAND_QUICKNET.period);
649
+ return t <= genesis ? 1n : (t - genesis + period - 1n) / period + 1n;
650
+ }
651
+ function drawValue(randomness, orderHash, attempt) {
652
+ const rand = hexBytes(randomness.startsWith("0x") ? randomness : `0x${randomness}`, "randomness", 32);
653
+ const preimage = concatBytes(rand, hexBytes(orderHash, "orderHash", 32), beBytes(uint(attempt, 32, "attempt"), 4));
654
+ return BigInt(toHex(keccak(preimage)));
655
+ }
656
+ function compareUtf8(a, b) {
657
+ const n = Math.min(a.length, b.length);
658
+ for (let i = 0; i < n; i++) if (a[i] !== b[i]) return a[i] - b[i];
659
+ return a.length - b.length;
660
+ }
661
+ function drawWinner(h, candidates) {
662
+ const sorted = candidates.map((c) => ({ id: c.fillerId, key: utf8ToBytes(c.fillerId), weight: uint(c.weight, 256, `weight of ${c.fillerId}`) })).sort((a, b) => compareUtf8(a.key, b.key));
663
+ if (new Set(sorted.map((c) => c.id)).size !== sorted.length) throw new Error("draw: duplicated fillerId");
664
+ const total = sorted.reduce((sum, c) => sum + c.weight, 0n);
665
+ if (total === 0n) throw new Error("draw: no candidate with a positive weight");
666
+ const r = h % total;
667
+ let acc = 0n;
668
+ const winner = sorted.find((c) => (acc += c.weight) > r);
669
+ return { r, winnerFillerId: winner.id };
670
+ }
671
+
672
+ // src/protocol/gateway.ts
673
+ var PROTOCOL_VERSION = "1";
674
+ var FILLER_WS_SUBPROTOCOL = "cancore-filler.v1";
675
+ var FILLER_WS_BEARER_PREFIX = "bearer.";
676
+ function fillerWsProtocols(token) {
677
+ return [FILLER_WS_SUBPROTOCOL, `${FILLER_WS_BEARER_PREFIX}${token}`];
678
+ }
679
+ var FILLER_CLOSE_CODES = {
680
+ /** filler-gateway is shutting down. */
681
+ GOING_AWAY: 1001,
682
+ /** The filler missed its heartbeats. */
683
+ HEARTBEAT_MISSED: 4e3,
684
+ /** A newer session of this fillerId superseded this one. */
685
+ SUPERSEDED: 4001,
686
+ /** Cancore staff changed the message key the session was opened with: log in again with the new key. */
687
+ KEY_CHANGED: 4002,
688
+ /** The filler is no longer `ACTIVE` (suspended). */
689
+ NOT_ACTIVE: 4003,
690
+ /** This session's inbound queue overflowed (count or bytes); only this session is closed. */
691
+ QUEUE_OVERFLOW: 4008,
692
+ /**
693
+ * Sustained excess over the rate limits: every session of the fillerId is
694
+ * closed and its upgrades and bearer requests are refused for a cooldown;
695
+ * the `error RATE_LIMITED` sent just before carries `retryAfterMs` = the
696
+ * remaining cooldown.
697
+ */
698
+ RATE_LIMITED: 4029
699
+ };
700
+ var FILLER_UPGRADE_REFUSALS = {
701
+ /** `cancore-filler.v1` not offered, or not exactly one `bearer.` entry. */
702
+ 400: "BAD_REQUEST",
703
+ /** The token is missing, unknown or expired, or the message key changed. */
704
+ 401: "UNAUTHENTICATED",
705
+ /** The filler is unknown or not `ACTIVE`. */
706
+ 403: "NOT_ACTIVE",
707
+ /** The login rate class is over its limit, or the fillerId is cooling down; `Retry-After` in seconds. */
708
+ 429: "RATE_LIMITED",
709
+ /** The replica is at its connection limit, or the fillerId already holds its maximum of live sessions. */
710
+ 503: "UNAVAILABLE"
711
+ };
712
+ var FILLER_GATEWAYS = {
713
+ mainnet: { gateway: null, ticketSigners: [] },
714
+ testnet: { gateway: null, ticketSigners: [] },
715
+ // The ticket signer every dev router registers (evm-contracts deployments/router/dev/*.input.json, CAN-2331).
716
+ // The gateway key is published with the gateway release.
717
+ devnet: { gateway: null, ticketSigners: ["0x9a3fc3f44cddbdfb036a8c8a528a903d0c835c1c"] }
718
+ };
719
+
720
+ // src/protocol/messages.ts
721
+ var DECLINE_REASONS = [
722
+ "NO_INVENTORY",
723
+ "RISK_LIMIT",
724
+ "PRICE_MOVED",
725
+ "PAUSED",
726
+ "OTHER",
727
+ "TICKET_SIGNER_UNKNOWN",
728
+ "TICKET_MISMATCH",
729
+ "TICKET_TTL_TOO_SHORT",
730
+ "TICKET_ISSUED_LATE",
731
+ "TICKET_BEYOND_DEADLINE",
732
+ "ESCROW_NOT_OPEN",
733
+ "ESCROW_MISMATCH",
734
+ "PROOF_WINDOW_TOO_SHORT",
735
+ "SKEW_MARGIN_TOO_SHORT",
736
+ "DRAW_MISMATCH"
737
+ ];
738
+ var ERROR_CODES = [
739
+ "BAD_REQUEST",
740
+ "UNAUTHENTICATED",
741
+ "UNSUPPORTED_VERSION",
742
+ "UNSUPPORTED_TYPE",
743
+ "BAD_SIGNATURE",
744
+ "STALE_MESSAGE",
745
+ "REPLAYED_MESSAGE",
746
+ "TICKET_REFUSED",
747
+ "UNKNOWN_REQUEST",
748
+ "UNKNOWN_TICKET",
749
+ "TICKET_CLOSED",
750
+ "NOT_ELIGIBLE",
751
+ "RATE_LIMITED",
752
+ "INTERNAL",
753
+ "ATTESTATIONS_NOT_READY",
754
+ "CANTON_NOT_READY",
755
+ "CANTON_REFUSED",
756
+ "CANTON_UNAVAILABLE",
757
+ "OPERATION_EXPIRED"
758
+ ];
759
+ var ERROR_HTTP_STATUS = {
760
+ BAD_REQUEST: 400,
761
+ UNAUTHENTICATED: 401,
762
+ UNSUPPORTED_VERSION: 400,
763
+ UNSUPPORTED_TYPE: 400,
764
+ BAD_SIGNATURE: 422,
765
+ STALE_MESSAGE: 400,
766
+ REPLAYED_MESSAGE: 409,
767
+ TICKET_REFUSED: 409,
768
+ UNKNOWN_REQUEST: 404,
769
+ UNKNOWN_TICKET: 404,
770
+ TICKET_CLOSED: 409,
771
+ NOT_ELIGIBLE: 403,
772
+ RATE_LIMITED: 429,
773
+ INTERNAL: 500,
774
+ ATTESTATIONS_NOT_READY: 404,
775
+ CANTON_NOT_READY: 409,
776
+ CANTON_REFUSED: 422,
777
+ CANTON_UNAVAILABLE: 503,
778
+ OPERATION_EXPIRED: 410
779
+ };
780
+ var TICKET_REFUSED_REASONS = [
781
+ "REPAY_TO_INVALID",
782
+ "REPAY_TO_BLOCKLISTED",
783
+ "DELIVERY_KEY_INVALID",
784
+ "PAYOUT_NOT_READY",
785
+ "RECIPIENT_NOT_READY",
786
+ "OPEN_TICKET_LIMIT",
787
+ "PROOF_WINDOW_TOO_SHORT",
788
+ "ATTESTOR_REVOCATION_PENDING",
789
+ "SERVICE_DEGRADED",
790
+ "OTHER"
791
+ ];
792
+ var EXPIRED_RESULTS = ["FILLED", "NO_SHOW", "NO_SHOW_UNCONFIRMED", "EXEMPT"];
793
+ var EXEMPT_REASONS = ["DESTINATION_HALTED", "GATEWAY_FAULT", "REORGED_AFTER_INCLUSION", "RECIPIENT_NOT_READY", "OTHER"];
794
+ var QUOTE_ACK_STATUSES = ["COUNTED", "LATE", "SHORT_TTL"];
795
+ var QUOTE_FINAL_STATUSES = [...QUOTE_ACK_STATUSES, "REPLACED", "BAD_SIG", "OUTLIER", "IN_BAND", "OUT_OF_BAND", "WON", "LOST"];
796
+ var PENALTY_STEPS = ["L1", "L2", "L3", "L4"];
797
+ var DRAW_CLOSED_BY = ["OFFER_TIMEOUT", "OFFER_DECLINE", "TICKET_DECLINE", "TICKET_EXPIRED", "FILLED"];
798
+ var TICKET_LIST_STATUSES = ["OFFERED", "ISSUED"];
799
+ var CANTON_OPS = ["party.allocate", "registry.accept", "delivery.fill", "intent.settle", "holdings.transfer"];
800
+ var CANTON_TRANSFER_OUTCOMES = ["COMPLETED", "PENDING"];
801
+ var CANTON_LEG_KINDS = ["transaction", "topology"];
802
+ var CANTON_REGISTRY_STATES = ["NONE", "PROPOSED", "ACTIVE", "REMOVED"];
803
+
804
+ // spec/protocol/asyncapi.json
805
+ var asyncapi_default = {
806
+ asyncapi: "3.0.0",
807
+ info: {
808
+ title: "Cancore filler protocol",
809
+ version: "1.0.0-rc.2",
810
+ description: "The WebSocket protocol between a filler and the Cancore filler gateway, v1 (release candidate). Operations are the gateway's: it sends S\u2192F frames and receives F\u2192S frames. Every frame carries id, fillerId and sentAt and is signed in the CancoreFillerProtocol v1 domain: S\u2192F with sig = the gateway key over GatewayMessage{bodyHash}, F\u2192S with msgSig = the filler's message key over FillerMessage{bodyHash}, bodyHash = keccak256(JCS(frame without that field)). Payload schemas: messages.schema.json. Generated by scripts/gen-protocol-docs.mjs.",
811
+ license: {
812
+ name: "Apache-2.0"
813
+ }
814
+ },
815
+ defaultContentType: "application/json",
816
+ servers: {
817
+ devnet: {
818
+ host: "{gatewayHost}",
819
+ protocol: "wss",
820
+ description: "Published per environment (O-6)",
821
+ variables: {
822
+ gatewayHost: {
823
+ default: "filler.dev.cancore.io"
824
+ }
825
+ }
826
+ }
827
+ },
828
+ channels: {
829
+ filler: {
830
+ address: "/v1",
831
+ description: "One JSON object per text frame. Connect only after login: the filler logs in over REST (GET /v1/filler/auth/challenge?fillerId=, POST /v1/filler/auth \u2192 {token, expiresAt}, rest.schema.json) and offers two subprotocols on the upgrade, cancore-filler.v1 and bearer.<token>; Authorization and the query string are not read. filler-gateway checks them before the upgrade and refuses with a plain HTTP response (x-upgrade-refusals: no WebSocket, nothing signed, Retry-After in seconds on 429). On success it answers Sec-WebSocket-Protocol: cancore-filler.v1 (the token is never echoed), the session is authenticated from the first byte, and the first frame is a signed auth.ok. auth.challenge and auth.response never travel on the socket (auth.response here is UNSUPPORTED_TYPE). Over a per-fillerId rate limit a frame is dropped unverified and the filler gets error RATE_LIMITED with retryAfterMs at most once per window and rate class; sustained excess closes every session of the fillerId with 4029. Close codes: x-close-codes.",
832
+ bindings: {
833
+ ws: {
834
+ method: "GET",
835
+ headers: {
836
+ type: "object",
837
+ required: [
838
+ "Sec-WebSocket-Protocol"
839
+ ],
840
+ properties: {
841
+ "Sec-WebSocket-Protocol": {
842
+ type: "string",
843
+ pattern: "^cancore-filler\\.v1, ?bearer\\.[A-Za-z0-9_-]+$|^bearer\\.[A-Za-z0-9_-]+, ?cancore-filler\\.v1$",
844
+ description: "cancore-filler.v1 and exactly one bearer.<token>, the token of POST /v1/filler/auth (base64url). The server selects cancore-filler.v1"
845
+ }
846
+ }
847
+ },
848
+ bindingVersion: "0.1.0"
849
+ }
850
+ },
851
+ "x-upgrade-refusals": {
852
+ "400": "cancore-filler.v1 not offered, or not exactly one bearer. entry",
853
+ "401": "token missing, unknown or expired, or the message key changed",
854
+ "403": "filler unknown or not ACTIVE",
855
+ "429": "login rate class over its limit, or the fillerId is cooling down; Retry-After (seconds, rounded up)",
856
+ "503": "the replica is at its connection limit, or the fillerId already holds its maximum of live sessions (across replicas)"
857
+ },
858
+ "x-close-codes": {
859
+ "1001": "filler-gateway shutting down",
860
+ "4000": "heartbeats missed",
861
+ "4001": "superseded by a newer session of this fillerId",
862
+ "4002": "the message key of the session was changed by staff",
863
+ "4003": "the filler is no longer ACTIVE (suspended)",
864
+ "4008": "this session's inbound queue overflowed (count or bytes); only this session",
865
+ "4029": "sustained over-limit: every session of the fillerId closed, cooling down; the error RATE_LIMITED sent just before carries retryAfterMs = the remaining cooldown"
866
+ },
867
+ messages: {
868
+ "auth.ok": {
869
+ $ref: "#/components/messages/auth.ok"
870
+ },
871
+ pingS2F: {
872
+ $ref: "#/components/messages/pingS2F"
873
+ },
874
+ pingF2S: {
875
+ $ref: "#/components/messages/pingF2S"
876
+ },
877
+ pongS2F: {
878
+ $ref: "#/components/messages/pongS2F"
879
+ },
880
+ pongF2S: {
881
+ $ref: "#/components/messages/pongF2S"
882
+ },
883
+ errorS2F: {
884
+ $ref: "#/components/messages/errorS2F"
885
+ },
886
+ errorF2S: {
887
+ $ref: "#/components/messages/errorF2S"
888
+ },
889
+ "epoch.weights": {
890
+ $ref: "#/components/messages/epoch.weights"
891
+ },
892
+ "quote.request": {
893
+ $ref: "#/components/messages/quote.request"
894
+ },
895
+ quote: {
896
+ $ref: "#/components/messages/quote"
897
+ },
898
+ "quote.ack": {
899
+ $ref: "#/components/messages/quote.ack"
900
+ },
901
+ "quote.reconfirm": {
902
+ $ref: "#/components/messages/quote.reconfirm"
903
+ },
904
+ "quote.reconfirm.reply": {
905
+ $ref: "#/components/messages/quote.reconfirm.reply"
906
+ },
907
+ "ticket.offer": {
908
+ $ref: "#/components/messages/ticket.offer"
909
+ },
910
+ "ticket.intent": {
911
+ $ref: "#/components/messages/ticket.intent"
912
+ },
913
+ "ticket.decline": {
914
+ $ref: "#/components/messages/ticket.decline"
915
+ },
916
+ "ticket.intent.ack": {
917
+ $ref: "#/components/messages/ticket.intent.ack"
918
+ },
919
+ "ticket.issued": {
920
+ $ref: "#/components/messages/ticket.issued"
921
+ },
922
+ "ticket.receipt": {
923
+ $ref: "#/components/messages/ticket.receipt"
924
+ },
925
+ "fill.reported": {
926
+ $ref: "#/components/messages/fill.reported"
927
+ },
928
+ "ticket.expired": {
929
+ $ref: "#/components/messages/ticket.expired"
930
+ },
931
+ "order.settled": {
932
+ $ref: "#/components/messages/order.settled"
933
+ },
934
+ "penalty.applied": {
935
+ $ref: "#/components/messages/penalty.applied"
936
+ },
937
+ "settle.attestations": {
938
+ $ref: "#/components/messages/settle.attestations"
939
+ },
940
+ "canton.prepare": {
941
+ $ref: "#/components/messages/canton.prepare"
942
+ },
943
+ "canton.prepared": {
944
+ $ref: "#/components/messages/canton.prepared"
945
+ },
946
+ "canton.submit": {
947
+ $ref: "#/components/messages/canton.submit"
948
+ },
949
+ "canton.submitted": {
950
+ $ref: "#/components/messages/canton.submitted"
951
+ }
952
+ }
953
+ }
954
+ },
955
+ operations: {
956
+ sendAuthOk: {
957
+ action: "send",
958
+ channel: {
959
+ $ref: "#/channels/filler"
960
+ },
961
+ messages: [
962
+ {
963
+ $ref: "#/channels/filler/messages/auth.ok"
964
+ }
965
+ ]
966
+ },
967
+ sendPing: {
968
+ action: "send",
969
+ channel: {
970
+ $ref: "#/channels/filler"
971
+ },
972
+ messages: [
973
+ {
974
+ $ref: "#/channels/filler/messages/pingS2F"
975
+ }
976
+ ]
977
+ },
978
+ receivePing: {
979
+ action: "receive",
980
+ channel: {
981
+ $ref: "#/channels/filler"
982
+ },
983
+ messages: [
984
+ {
985
+ $ref: "#/channels/filler/messages/pingF2S"
986
+ }
987
+ ]
988
+ },
989
+ sendPong: {
990
+ action: "send",
991
+ channel: {
992
+ $ref: "#/channels/filler"
993
+ },
994
+ messages: [
995
+ {
996
+ $ref: "#/channels/filler/messages/pongS2F"
997
+ }
998
+ ]
999
+ },
1000
+ receivePong: {
1001
+ action: "receive",
1002
+ channel: {
1003
+ $ref: "#/channels/filler"
1004
+ },
1005
+ messages: [
1006
+ {
1007
+ $ref: "#/channels/filler/messages/pongF2S"
1008
+ }
1009
+ ]
1010
+ },
1011
+ sendError: {
1012
+ action: "send",
1013
+ channel: {
1014
+ $ref: "#/channels/filler"
1015
+ },
1016
+ messages: [
1017
+ {
1018
+ $ref: "#/channels/filler/messages/errorS2F"
1019
+ }
1020
+ ]
1021
+ },
1022
+ receiveError: {
1023
+ action: "receive",
1024
+ channel: {
1025
+ $ref: "#/channels/filler"
1026
+ },
1027
+ messages: [
1028
+ {
1029
+ $ref: "#/channels/filler/messages/errorF2S"
1030
+ }
1031
+ ]
1032
+ },
1033
+ sendEpochWeights: {
1034
+ action: "send",
1035
+ channel: {
1036
+ $ref: "#/channels/filler"
1037
+ },
1038
+ messages: [
1039
+ {
1040
+ $ref: "#/channels/filler/messages/epoch.weights"
1041
+ }
1042
+ ]
1043
+ },
1044
+ sendQuoteRequest: {
1045
+ action: "send",
1046
+ channel: {
1047
+ $ref: "#/channels/filler"
1048
+ },
1049
+ messages: [
1050
+ {
1051
+ $ref: "#/channels/filler/messages/quote.request"
1052
+ }
1053
+ ]
1054
+ },
1055
+ receiveQuote: {
1056
+ action: "receive",
1057
+ channel: {
1058
+ $ref: "#/channels/filler"
1059
+ },
1060
+ messages: [
1061
+ {
1062
+ $ref: "#/channels/filler/messages/quote"
1063
+ }
1064
+ ]
1065
+ },
1066
+ sendQuoteAck: {
1067
+ action: "send",
1068
+ channel: {
1069
+ $ref: "#/channels/filler"
1070
+ },
1071
+ messages: [
1072
+ {
1073
+ $ref: "#/channels/filler/messages/quote.ack"
1074
+ }
1075
+ ]
1076
+ },
1077
+ sendQuoteReconfirm: {
1078
+ action: "send",
1079
+ channel: {
1080
+ $ref: "#/channels/filler"
1081
+ },
1082
+ messages: [
1083
+ {
1084
+ $ref: "#/channels/filler/messages/quote.reconfirm"
1085
+ }
1086
+ ]
1087
+ },
1088
+ receiveQuoteReconfirmReply: {
1089
+ action: "receive",
1090
+ channel: {
1091
+ $ref: "#/channels/filler"
1092
+ },
1093
+ messages: [
1094
+ {
1095
+ $ref: "#/channels/filler/messages/quote.reconfirm.reply"
1096
+ }
1097
+ ]
1098
+ },
1099
+ sendTicketOffer: {
1100
+ action: "send",
1101
+ channel: {
1102
+ $ref: "#/channels/filler"
1103
+ },
1104
+ messages: [
1105
+ {
1106
+ $ref: "#/channels/filler/messages/ticket.offer"
1107
+ }
1108
+ ]
1109
+ },
1110
+ receiveTicketIntent: {
1111
+ action: "receive",
1112
+ channel: {
1113
+ $ref: "#/channels/filler"
1114
+ },
1115
+ messages: [
1116
+ {
1117
+ $ref: "#/channels/filler/messages/ticket.intent"
1118
+ }
1119
+ ]
1120
+ },
1121
+ receiveTicketDecline: {
1122
+ action: "receive",
1123
+ channel: {
1124
+ $ref: "#/channels/filler"
1125
+ },
1126
+ messages: [
1127
+ {
1128
+ $ref: "#/channels/filler/messages/ticket.decline"
1129
+ }
1130
+ ]
1131
+ },
1132
+ sendTicketIntentAck: {
1133
+ action: "send",
1134
+ channel: {
1135
+ $ref: "#/channels/filler"
1136
+ },
1137
+ messages: [
1138
+ {
1139
+ $ref: "#/channels/filler/messages/ticket.intent.ack"
1140
+ }
1141
+ ]
1142
+ },
1143
+ sendTicketIssued: {
1144
+ action: "send",
1145
+ channel: {
1146
+ $ref: "#/channels/filler"
1147
+ },
1148
+ messages: [
1149
+ {
1150
+ $ref: "#/channels/filler/messages/ticket.issued"
1151
+ }
1152
+ ]
1153
+ },
1154
+ receiveTicketReceipt: {
1155
+ action: "receive",
1156
+ channel: {
1157
+ $ref: "#/channels/filler"
1158
+ },
1159
+ messages: [
1160
+ {
1161
+ $ref: "#/channels/filler/messages/ticket.receipt"
1162
+ }
1163
+ ]
1164
+ },
1165
+ receiveFillReported: {
1166
+ action: "receive",
1167
+ channel: {
1168
+ $ref: "#/channels/filler"
1169
+ },
1170
+ messages: [
1171
+ {
1172
+ $ref: "#/channels/filler/messages/fill.reported"
1173
+ }
1174
+ ]
1175
+ },
1176
+ sendTicketExpired: {
1177
+ action: "send",
1178
+ channel: {
1179
+ $ref: "#/channels/filler"
1180
+ },
1181
+ messages: [
1182
+ {
1183
+ $ref: "#/channels/filler/messages/ticket.expired"
1184
+ }
1185
+ ]
1186
+ },
1187
+ sendOrderSettled: {
1188
+ action: "send",
1189
+ channel: {
1190
+ $ref: "#/channels/filler"
1191
+ },
1192
+ messages: [
1193
+ {
1194
+ $ref: "#/channels/filler/messages/order.settled"
1195
+ }
1196
+ ]
1197
+ },
1198
+ sendPenaltyApplied: {
1199
+ action: "send",
1200
+ channel: {
1201
+ $ref: "#/channels/filler"
1202
+ },
1203
+ messages: [
1204
+ {
1205
+ $ref: "#/channels/filler/messages/penalty.applied"
1206
+ }
1207
+ ]
1208
+ },
1209
+ sendSettleAttestations: {
1210
+ action: "send",
1211
+ channel: {
1212
+ $ref: "#/channels/filler"
1213
+ },
1214
+ messages: [
1215
+ {
1216
+ $ref: "#/channels/filler/messages/settle.attestations"
1217
+ }
1218
+ ]
1219
+ },
1220
+ receiveCantonPrepare: {
1221
+ action: "receive",
1222
+ channel: {
1223
+ $ref: "#/channels/filler"
1224
+ },
1225
+ messages: [
1226
+ {
1227
+ $ref: "#/channels/filler/messages/canton.prepare"
1228
+ }
1229
+ ]
1230
+ },
1231
+ sendCantonPrepared: {
1232
+ action: "send",
1233
+ channel: {
1234
+ $ref: "#/channels/filler"
1235
+ },
1236
+ messages: [
1237
+ {
1238
+ $ref: "#/channels/filler/messages/canton.prepared"
1239
+ }
1240
+ ]
1241
+ },
1242
+ receiveCantonSubmit: {
1243
+ action: "receive",
1244
+ channel: {
1245
+ $ref: "#/channels/filler"
1246
+ },
1247
+ messages: [
1248
+ {
1249
+ $ref: "#/channels/filler/messages/canton.submit"
1250
+ }
1251
+ ]
1252
+ },
1253
+ sendCantonSubmitted: {
1254
+ action: "send",
1255
+ channel: {
1256
+ $ref: "#/channels/filler"
1257
+ },
1258
+ messages: [
1259
+ {
1260
+ $ref: "#/channels/filler/messages/canton.submitted"
1261
+ }
1262
+ ]
1263
+ }
1264
+ },
1265
+ components: {
1266
+ messages: {
1267
+ "auth.ok": {
1268
+ name: "auth.ok",
1269
+ title: "auth.ok (S2F)",
1270
+ payload: {
1271
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1272
+ schema: {
1273
+ $ref: "messages.schema.json#/$defs/auth.ok"
1274
+ }
1275
+ },
1276
+ examples: [
1277
+ {
1278
+ name: "auth-ok-1",
1279
+ payload: {
1280
+ type: "auth.ok",
1281
+ id: "g-2",
1282
+ fillerId: "acme-markets",
1283
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1284
+ sentAt: 1789999980200,
1285
+ re: "a-1",
1286
+ heartbeatIntervalMs: 15e3
1287
+ }
1288
+ }
1289
+ ]
1290
+ },
1291
+ pingS2F: {
1292
+ name: "ping",
1293
+ title: "ping (S2F)",
1294
+ payload: {
1295
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1296
+ schema: {
1297
+ $ref: "messages.schema.json#/$defs/pingS2F"
1298
+ }
1299
+ },
1300
+ examples: [
1301
+ {
1302
+ name: "pingS2F-1",
1303
+ payload: {
1304
+ type: "ping",
1305
+ fillerId: "acme-markets",
1306
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1307
+ sentAt: 1789999995e3,
1308
+ id: "gp-1"
1309
+ }
1310
+ }
1311
+ ]
1312
+ },
1313
+ pingF2S: {
1314
+ name: "ping",
1315
+ title: "ping (F2S)",
1316
+ payload: {
1317
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1318
+ schema: {
1319
+ $ref: "messages.schema.json#/$defs/pingF2S"
1320
+ }
1321
+ },
1322
+ examples: [
1323
+ {
1324
+ name: "pingF2S-1",
1325
+ payload: {
1326
+ type: "ping",
1327
+ id: "p-1",
1328
+ fillerId: "acme-markets",
1329
+ sentAt: 1789999994e3,
1330
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1331
+ }
1332
+ }
1333
+ ]
1334
+ },
1335
+ pongS2F: {
1336
+ name: "pong",
1337
+ title: "pong (S2F)",
1338
+ payload: {
1339
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1340
+ schema: {
1341
+ $ref: "messages.schema.json#/$defs/pongS2F"
1342
+ }
1343
+ },
1344
+ examples: [
1345
+ {
1346
+ name: "pongS2F-1",
1347
+ payload: {
1348
+ type: "pong",
1349
+ id: "g-3",
1350
+ fillerId: "acme-markets",
1351
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1352
+ sentAt: 1789999994100,
1353
+ re: "p-1"
1354
+ }
1355
+ }
1356
+ ]
1357
+ },
1358
+ pongF2S: {
1359
+ name: "pong",
1360
+ title: "pong (F2S)",
1361
+ payload: {
1362
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1363
+ schema: {
1364
+ $ref: "messages.schema.json#/$defs/pongF2S"
1365
+ }
1366
+ },
1367
+ examples: [
1368
+ {
1369
+ name: "pongF2S-1",
1370
+ payload: {
1371
+ type: "pong",
1372
+ id: "po-1",
1373
+ fillerId: "acme-markets",
1374
+ sentAt: 1789999995100,
1375
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1376
+ re: "gp-1"
1377
+ }
1378
+ }
1379
+ ]
1380
+ },
1381
+ errorS2F: {
1382
+ name: "error",
1383
+ title: "error (S2F)",
1384
+ payload: {
1385
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1386
+ schema: {
1387
+ $ref: "messages.schema.json#/$defs/errorS2F"
1388
+ }
1389
+ },
1390
+ examples: [
1391
+ {
1392
+ name: "errorS2F-1",
1393
+ payload: {
1394
+ type: "error",
1395
+ id: "g-4",
1396
+ fillerId: "acme-markets",
1397
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1398
+ sentAt: 1790000023500,
1399
+ re: "i-2",
1400
+ code: "TICKET_CLOSED",
1401
+ message: "ticket.intent after acceptBy"
1402
+ }
1403
+ },
1404
+ {
1405
+ name: "errorS2F-2",
1406
+ payload: {
1407
+ type: "error",
1408
+ id: "g-5",
1409
+ sentAt: 1789999980150,
1410
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1411
+ re: "a-2",
1412
+ code: "UNAUTHENTICATED",
1413
+ message: "no live challenge of this fillerId with this nonce"
1414
+ }
1415
+ },
1416
+ {
1417
+ name: "errorS2F-3",
1418
+ payload: {
1419
+ type: "error",
1420
+ id: "g-6",
1421
+ fillerId: "acme-markets",
1422
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1423
+ sentAt: 1790000021500,
1424
+ re: "i-3",
1425
+ code: "TICKET_REFUSED",
1426
+ reason: "REPAY_TO_BLOCKLISTED",
1427
+ message: "repayTo is blocklisted by the input token"
1428
+ }
1429
+ },
1430
+ {
1431
+ name: "errorS2F-4",
1432
+ payload: {
1433
+ type: "error",
1434
+ id: "g-18",
1435
+ fillerId: "acme-markets",
1436
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1437
+ sentAt: 1789999991500,
1438
+ re: "q-2",
1439
+ code: "RATE_LIMITED",
1440
+ message: "quote rate class over its limit",
1441
+ retryAfterMs: 850
1442
+ }
1443
+ }
1444
+ ]
1445
+ },
1446
+ errorF2S: {
1447
+ name: "error",
1448
+ title: "error (F2S)",
1449
+ payload: {
1450
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1451
+ schema: {
1452
+ $ref: "messages.schema.json#/$defs/errorF2S"
1453
+ }
1454
+ },
1455
+ examples: [
1456
+ {
1457
+ name: "errorF2S-1",
1458
+ payload: {
1459
+ type: "error",
1460
+ id: "e-1",
1461
+ fillerId: "acme-markets",
1462
+ sentAt: 179000003e4,
1463
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1464
+ re: "g-77",
1465
+ code: "UNKNOWN_TICKET",
1466
+ message: "no ticket for this orderHash"
1467
+ }
1468
+ }
1469
+ ]
1470
+ },
1471
+ "epoch.weights": {
1472
+ name: "epoch.weights",
1473
+ title: "epoch.weights (S2F)",
1474
+ payload: {
1475
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1476
+ schema: {
1477
+ $ref: "messages.schema.json#/$defs/epoch.weights"
1478
+ }
1479
+ },
1480
+ examples: [
1481
+ {
1482
+ name: "epoch-weights-1",
1483
+ payload: {
1484
+ type: "epoch.weights",
1485
+ id: "g-7",
1486
+ fillerId: "acme-markets",
1487
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1488
+ sentAt: 1789999980300,
1489
+ epochId: "20717",
1490
+ startsAt: "1789948800",
1491
+ endsAt: "1790035200",
1492
+ weightsRoot: "0xa1c24765b55b34e0c206f808d2fac2e448d9db6f154d89f898921a80bad76e92"
1493
+ }
1494
+ }
1495
+ ]
1496
+ },
1497
+ "quote.request": {
1498
+ name: "quote.request",
1499
+ title: "quote.request (S2F)",
1500
+ payload: {
1501
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1502
+ schema: {
1503
+ $ref: "messages.schema.json#/$defs/quote.request"
1504
+ }
1505
+ },
1506
+ examples: [
1507
+ {
1508
+ name: "quote-request-1",
1509
+ payload: {
1510
+ type: "quote.request",
1511
+ id: "g-8",
1512
+ fillerId: "acme-markets",
1513
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1514
+ sentAt: 178999999e4,
1515
+ requestId: "req-7f3a9c21-4d88-4e5b-9a1e-0c2f6b8d4e31",
1516
+ route: {
1517
+ src: "eip155:11155111",
1518
+ dst: "eip155:421614"
1519
+ },
1520
+ inputToken: "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
1521
+ inputAmount: "1003000000",
1522
+ outputAsset: "0x75faf114eafb1bdbe2f0316df893fd58ce46aa4d",
1523
+ feeBps: 30,
1524
+ fillDeadlineHint: "1790000600",
1525
+ windowCloseAt: 1789999992e3,
1526
+ quoteTtlMs: 6e4,
1527
+ imbalanceHint: {
1528
+ dstAsset: "0x75faf114eafb1bdbe2f0316df893fd58ce46aa4d",
1529
+ netFlow24hUsd: "-12500.50"
1530
+ }
1531
+ }
1532
+ }
1533
+ ]
1534
+ },
1535
+ quote: {
1536
+ name: "quote",
1537
+ title: "quote (F2S)",
1538
+ payload: {
1539
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1540
+ schema: {
1541
+ $ref: "messages.schema.json#/$defs/quote"
1542
+ }
1543
+ },
1544
+ examples: [
1545
+ {
1546
+ name: "quote-1",
1547
+ payload: {
1548
+ type: "quote",
1549
+ id: "q-1",
1550
+ fillerId: "acme-markets",
1551
+ sentAt: 1789999991e3,
1552
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1553
+ requestId: "req-7f3a9c21-4d88-4e5b-9a1e-0c2f6b8d4e31",
1554
+ amountOut: "999000000",
1555
+ validUntil: "1790000060",
1556
+ nonce: "1",
1557
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1558
+ }
1559
+ }
1560
+ ]
1561
+ },
1562
+ "quote.ack": {
1563
+ name: "quote.ack",
1564
+ title: "quote.ack (S2F)",
1565
+ payload: {
1566
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1567
+ schema: {
1568
+ $ref: "messages.schema.json#/$defs/quote.ack"
1569
+ }
1570
+ },
1571
+ examples: [
1572
+ {
1573
+ name: "quote-ack-1",
1574
+ payload: {
1575
+ type: "quote.ack",
1576
+ id: "g-9",
1577
+ fillerId: "acme-markets",
1578
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1579
+ sentAt: 1789999991001,
1580
+ re: "q-1",
1581
+ requestId: "req-7f3a9c21-4d88-4e5b-9a1e-0c2f6b8d4e31",
1582
+ quoteHash: "0xe3b63a6ae2730532fb841002059d6e8c92124d95e98c09857d7e0f5ba3512e3b",
1583
+ receivedAt: 1789999991e3,
1584
+ status: "COUNTED"
1585
+ }
1586
+ }
1587
+ ]
1588
+ },
1589
+ "quote.reconfirm": {
1590
+ name: "quote.reconfirm",
1591
+ title: "quote.reconfirm (S2F)",
1592
+ payload: {
1593
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1594
+ schema: {
1595
+ $ref: "messages.schema.json#/$defs/quote.reconfirm"
1596
+ }
1597
+ },
1598
+ examples: [
1599
+ {
1600
+ name: "quote-reconfirm-1",
1601
+ payload: {
1602
+ type: "quote.reconfirm",
1603
+ id: "g-10",
1604
+ fillerId: "acme-markets",
1605
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1606
+ sentAt: 1790000013e3,
1607
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1608
+ requestId: "req-7f3a9c21-4d88-4e5b-9a1e-0c2f6b8d4e31",
1609
+ order: {
1610
+ user: "0xa11ce00000000000000000000000000000000001",
1611
+ originChainId: "11155111",
1612
+ inputToken: "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
1613
+ inputAmount: "1003000000",
1614
+ destination: "0x0000000000000000000000000000000000000000000000000000000000066eee",
1615
+ outputAsset: "0x00000000000000000000000075faf114eafb1bdbe2f0316df893fd58ce46aa4d",
1616
+ minReceived: "999000000",
1617
+ recipient: "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
1618
+ createdAt: "1790000000",
1619
+ fillDeadline: "1790000600",
1620
+ feeBps: "30",
1621
+ fillerId: "0x112e2693409c427698100f54d0439fc3593fedb25221fe3a54c4823c0a0ee2d5"
1622
+ },
1623
+ amountOut: "999000000",
1624
+ ticketTtl: 360,
1625
+ replyBy: 1790000016e3
1626
+ }
1627
+ }
1628
+ ]
1629
+ },
1630
+ "quote.reconfirm.reply": {
1631
+ name: "quote.reconfirm.reply",
1632
+ title: "quote.reconfirm.reply (F2S)",
1633
+ payload: {
1634
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1635
+ schema: {
1636
+ $ref: "messages.schema.json#/$defs/quote.reconfirm.reply"
1637
+ }
1638
+ },
1639
+ examples: [
1640
+ {
1641
+ name: "quote-reconfirm-reply-1",
1642
+ payload: {
1643
+ type: "quote.reconfirm.reply",
1644
+ id: "r-1",
1645
+ fillerId: "acme-markets",
1646
+ sentAt: 1790000014e3,
1647
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1648
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1649
+ accept: true,
1650
+ validUntil: "1790000400",
1651
+ nonce: "2",
1652
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1653
+ }
1654
+ },
1655
+ {
1656
+ name: "quote-reconfirm-reply-2",
1657
+ payload: {
1658
+ type: "quote.reconfirm.reply",
1659
+ id: "r-2",
1660
+ fillerId: "acme-markets",
1661
+ sentAt: 1790000014e3,
1662
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1663
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1664
+ accept: false
1665
+ }
1666
+ }
1667
+ ]
1668
+ },
1669
+ "ticket.offer": {
1670
+ name: "ticket.offer",
1671
+ title: "ticket.offer (S2F)",
1672
+ payload: {
1673
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1674
+ schema: {
1675
+ $ref: "messages.schema.json#/$defs/ticket.offer"
1676
+ }
1677
+ },
1678
+ examples: [
1679
+ {
1680
+ name: "ticket-offer-1",
1681
+ payload: {
1682
+ type: "ticket.offer",
1683
+ id: "g-20",
1684
+ fillerId: "acme-markets",
1685
+ sentAt: 179000002e4,
1686
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1687
+ attempt: 0,
1688
+ order: {
1689
+ user: "0xa11ce00000000000000000000000000000000001",
1690
+ originChainId: "11155111",
1691
+ inputToken: "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
1692
+ inputAmount: "1003000000",
1693
+ destination: "0x0000000000000000000000000000000000000000000000000000000000066eee",
1694
+ outputAsset: "0x00000000000000000000000075faf114eafb1bdbe2f0316df893fd58ce46aa4d",
1695
+ minReceived: "999000000",
1696
+ recipient: "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
1697
+ createdAt: "1790000000",
1698
+ fillDeadline: "1790000600",
1699
+ feeBps: "30",
1700
+ fillerId: "0x112e2693409c427698100f54d0439fc3593fedb25221fe3a54c4823c0a0ee2d5"
1701
+ },
1702
+ amountOut: "999000000",
1703
+ validFrom: "1790000040",
1704
+ validUntil: "1790000400",
1705
+ acceptBy: 1790000023e3,
1706
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1707
+ }
1708
+ }
1709
+ ]
1710
+ },
1711
+ "ticket.intent": {
1712
+ name: "ticket.intent",
1713
+ title: "ticket.intent (F2S)",
1714
+ payload: {
1715
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1716
+ schema: {
1717
+ $ref: "messages.schema.json#/$defs/ticket.intent"
1718
+ }
1719
+ },
1720
+ examples: [
1721
+ {
1722
+ name: "ticket-intent-1",
1723
+ payload: {
1724
+ type: "ticket.intent",
1725
+ id: "i-1",
1726
+ fillerId: "acme-markets",
1727
+ sentAt: 1790000021e3,
1728
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1729
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1730
+ attempt: 0,
1731
+ validFrom: "1790000040",
1732
+ validUntil: "1790000400",
1733
+ deliveryKey: "0x742d35cc6634c0532925a3b844bc454e4438f44e",
1734
+ repayTo: "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
1735
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1736
+ }
1737
+ },
1738
+ {
1739
+ name: "ticket-intent-2",
1740
+ payload: {
1741
+ type: "ticket.intent",
1742
+ id: "i-4",
1743
+ fillerId: "acme-markets",
1744
+ sentAt: 1790000021e3,
1745
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1746
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1747
+ attempt: 2,
1748
+ validFrom: "1790000040",
1749
+ validUntil: "1790000400",
1750
+ deliveryKey: "0x0000000000000000000000000000000000000000",
1751
+ repayTo: "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
1752
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1753
+ }
1754
+ }
1755
+ ]
1756
+ },
1757
+ "ticket.decline": {
1758
+ name: "ticket.decline",
1759
+ title: "ticket.decline (F2S)",
1760
+ payload: {
1761
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1762
+ schema: {
1763
+ $ref: "messages.schema.json#/$defs/ticket.decline"
1764
+ }
1765
+ },
1766
+ examples: [
1767
+ {
1768
+ name: "ticket-decline-1",
1769
+ payload: {
1770
+ type: "ticket.decline",
1771
+ id: "d-1",
1772
+ fillerId: "acme-markets",
1773
+ sentAt: 1790000027001,
1774
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1775
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1776
+ attempt: 0,
1777
+ reason: "TICKET_ISSUED_LATE",
1778
+ detail: "ticket.issued 3001 ms after acceptBy"
1779
+ }
1780
+ }
1781
+ ]
1782
+ },
1783
+ "ticket.intent.ack": {
1784
+ name: "ticket.intent.ack",
1785
+ title: "ticket.intent.ack (S2F)",
1786
+ payload: {
1787
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1788
+ schema: {
1789
+ $ref: "messages.schema.json#/$defs/ticket.intent.ack"
1790
+ }
1791
+ },
1792
+ examples: [
1793
+ {
1794
+ name: "ticket-intent-ack-1",
1795
+ payload: {
1796
+ type: "ticket.intent.ack",
1797
+ id: "g-11",
1798
+ fillerId: "acme-markets",
1799
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1800
+ sentAt: 1790000021001,
1801
+ re: "i-1",
1802
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1803
+ attempt: 0,
1804
+ intentHash: "0x53dcabb35a92525e69f2637f618e2cd1eed25bb9ee3caf608e7e9025825abfe0",
1805
+ receivedAt: 1790000021e3
1806
+ }
1807
+ }
1808
+ ]
1809
+ },
1810
+ "ticket.issued": {
1811
+ name: "ticket.issued",
1812
+ title: "ticket.issued (S2F)",
1813
+ payload: {
1814
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1815
+ schema: {
1816
+ $ref: "messages.schema.json#/$defs/ticket.issued"
1817
+ }
1818
+ },
1819
+ examples: [
1820
+ {
1821
+ name: "ticket-issued-1",
1822
+ payload: {
1823
+ type: "ticket.issued",
1824
+ id: "g-12",
1825
+ fillerId: "acme-markets",
1826
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1827
+ sentAt: 1790000024e3,
1828
+ form: "evm",
1829
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1830
+ attempt: 0,
1831
+ ticket: {
1832
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1833
+ fillerId: "0x112e2693409c427698100f54d0439fc3593fedb25221fe3a54c4823c0a0ee2d5",
1834
+ deliveryKey: "0x742d35cc6634c0532925a3b844bc454e4438f44e",
1835
+ repayTo: "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
1836
+ attempt: 0,
1837
+ validFrom: "1790000040",
1838
+ validUntil: "1790000400"
1839
+ },
1840
+ ticketSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1841
+ }
1842
+ },
1843
+ {
1844
+ name: "ticket-issued-2",
1845
+ payload: {
1846
+ type: "ticket.issued",
1847
+ id: "g-13",
1848
+ fillerId: "acme-markets",
1849
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1850
+ sentAt: 1790000024e3,
1851
+ form: "canton",
1852
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1853
+ attempt: 2,
1854
+ deliveryOrderCid: "00a1b2c3d4e5f6#fixture-delivery-order",
1855
+ validUntil: "1790000400",
1856
+ repayTo: "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc"
1857
+ }
1858
+ }
1859
+ ]
1860
+ },
1861
+ "ticket.receipt": {
1862
+ name: "ticket.receipt",
1863
+ title: "ticket.receipt (F2S)",
1864
+ payload: {
1865
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1866
+ schema: {
1867
+ $ref: "messages.schema.json#/$defs/ticket.receipt"
1868
+ }
1869
+ },
1870
+ examples: [
1871
+ {
1872
+ name: "ticket-receipt-1",
1873
+ payload: {
1874
+ type: "ticket.receipt",
1875
+ id: "rc-1",
1876
+ fillerId: "acme-markets",
1877
+ sentAt: 1790000025e3,
1878
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1879
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1880
+ attempt: 0,
1881
+ ticketHash: "0x963e823a2d9709d6630515731512094e45976407536974cb9f81817591ed1f16",
1882
+ ticketSigHash: "0x9d30145c6e97cad96cf7cee181ac9d5b879dea7fed0730d7197e84e28487292b",
1883
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1884
+ }
1885
+ },
1886
+ {
1887
+ name: "ticket-receipt-2",
1888
+ payload: {
1889
+ type: "ticket.receipt",
1890
+ id: "rc-2",
1891
+ fillerId: "acme-markets",
1892
+ sentAt: 1790000025e3,
1893
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1894
+ form: "canton",
1895
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1896
+ attempt: 2,
1897
+ deliveryOrderCid: "00a1b2c3d4e5f6#fixture-delivery-order",
1898
+ validUntil: "1790000400",
1899
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b"
1900
+ }
1901
+ }
1902
+ ]
1903
+ },
1904
+ "fill.reported": {
1905
+ name: "fill.reported",
1906
+ title: "fill.reported (F2S)",
1907
+ payload: {
1908
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1909
+ schema: {
1910
+ $ref: "messages.schema.json#/$defs/fill.reported"
1911
+ }
1912
+ },
1913
+ examples: [
1914
+ {
1915
+ name: "fill-reported-1",
1916
+ payload: {
1917
+ type: "fill.reported",
1918
+ id: "f-1",
1919
+ fillerId: "acme-markets",
1920
+ sentAt: 179000006e4,
1921
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1922
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1923
+ attempt: 0,
1924
+ txRef: "0xfc4cba975d6b96ed2be00adae2d970f61413b963279089dcfc6402ddccc42740"
1925
+ }
1926
+ }
1927
+ ]
1928
+ },
1929
+ "ticket.expired": {
1930
+ name: "ticket.expired",
1931
+ title: "ticket.expired (S2F)",
1932
+ payload: {
1933
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1934
+ schema: {
1935
+ $ref: "messages.schema.json#/$defs/ticket.expired"
1936
+ }
1937
+ },
1938
+ examples: [
1939
+ {
1940
+ name: "ticket-expired-1",
1941
+ payload: {
1942
+ type: "ticket.expired",
1943
+ id: "g-14",
1944
+ fillerId: "acme-markets",
1945
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1946
+ sentAt: 179000046e4,
1947
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1948
+ attempt: 0,
1949
+ result: "FILLED"
1950
+ }
1951
+ },
1952
+ {
1953
+ name: "ticket-expired-2",
1954
+ payload: {
1955
+ type: "ticket.expired",
1956
+ id: "g-15",
1957
+ fillerId: "acme-markets",
1958
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1959
+ sentAt: 179000046e4,
1960
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1961
+ attempt: 0,
1962
+ result: "EXEMPT",
1963
+ exemptReason: "DESTINATION_HALTED"
1964
+ }
1965
+ }
1966
+ ]
1967
+ },
1968
+ "order.settled": {
1969
+ name: "order.settled",
1970
+ title: "order.settled (S2F)",
1971
+ payload: {
1972
+ schemaFormat: "application/schema+json;version=draft-2020-12",
1973
+ schema: {
1974
+ $ref: "messages.schema.json#/$defs/order.settled"
1975
+ }
1976
+ },
1977
+ examples: [
1978
+ {
1979
+ name: "order-settled-1",
1980
+ payload: {
1981
+ type: "order.settled",
1982
+ id: "g-16",
1983
+ fillerId: "acme-markets",
1984
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
1985
+ sentAt: 17900009e5,
1986
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
1987
+ payout: "1000000000",
1988
+ fee: "3000000",
1989
+ penaltyWithheld: "0",
1990
+ txRef: "0x8d99b79edaf0d9c062753bb308a72f52ec1ed8873fe06580c14524bb66a9f614"
1991
+ }
1992
+ }
1993
+ ]
1994
+ },
1995
+ "penalty.applied": {
1996
+ name: "penalty.applied",
1997
+ title: "penalty.applied (S2F)",
1998
+ payload: {
1999
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2000
+ schema: {
2001
+ $ref: "messages.schema.json#/$defs/penalty.applied"
2002
+ }
2003
+ },
2004
+ examples: [
2005
+ {
2006
+ name: "penalty-applied-1",
2007
+ payload: {
2008
+ type: "penalty.applied",
2009
+ id: "g-17",
2010
+ fillerId: "acme-markets",
2011
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2012
+ sentAt: 1790001e6,
2013
+ violationId: "v-1",
2014
+ code: "NO_SHOW",
2015
+ step: "L1",
2016
+ details: {
2017
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
2018
+ attempt: 0
2019
+ }
2020
+ }
2021
+ }
2022
+ ]
2023
+ },
2024
+ "settle.attestations": {
2025
+ name: "settle.attestations",
2026
+ title: "settle.attestations (S2F)",
2027
+ payload: {
2028
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2029
+ schema: {
2030
+ $ref: "messages.schema.json#/$defs/settle.attestations"
2031
+ }
2032
+ },
2033
+ examples: [
2034
+ {
2035
+ name: "settle-attestations-1",
2036
+ payload: {
2037
+ type: "settle.attestations",
2038
+ id: "g-sa-1",
2039
+ fillerId: "acme-markets",
2040
+ sentAt: 179000016e4,
2041
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
2042
+ attempt: 0,
2043
+ sourceChainId: "eip155:11155111",
2044
+ proof: {
2045
+ kind: 1,
2046
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
2047
+ destination: "0x0000000000000000000000000000000000000000000000000000000000066eee",
2048
+ fillRef: "0xfc4cba975d6b96ed2be00adae2d970f61413b963279089dcfc6402ddccc42740",
2049
+ recipient: "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
2050
+ outputAsset: "0x00000000000000000000000075faf114eafb1bdbe2f0316df893fd58ce46aa4d",
2051
+ amountDelivered: "999000000",
2052
+ filledAt: "1790000100",
2053
+ fillerId: "0x112e2693409c427698100f54d0439fc3593fedb25221fe3a54c4823c0a0ee2d5",
2054
+ repayTo: "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
2055
+ attempt: 0,
2056
+ setId: 1
2057
+ },
2058
+ signatures: [
2059
+ {
2060
+ signer: "0x5e877d05b3bfef8b53a59dde76b911fb521415cd",
2061
+ signature: "0x280a1c67572079434e423c51ee29272a0afb87bc485b3292192fb08242aeef687bcd1417aff35025ab16da3f43a73972585877b131a2b4dfe83d1ae4f5ef0fad1b"
2062
+ },
2063
+ {
2064
+ signer: "0x6805cf7ce01e1c392d47806813503e367c932544",
2065
+ signature: "0x77cba7cedee87b88ac9d90ce0440bb55fa510930318e1a7cb9e2567f198208fb3784a5ca3343c3df2d7dfc29b0a2eae3b87b475893b4d134fa6ce9d8df2a88521b"
2066
+ }
2067
+ ],
2068
+ setId: 1,
2069
+ threshold: 2,
2070
+ refundAfter: "1790002400",
2071
+ sig: "0x703468572b0f0d056f7c8547a2a70dbb76469888d23059926e906d23cc0468ac54cd96efe6a0f298750a225cd4a7e6acb511f144631076ed2825de0bf0e40b1e1b"
2072
+ }
2073
+ },
2074
+ {
2075
+ name: "settle-attestations-2",
2076
+ payload: {
2077
+ type: "settle.attestations",
2078
+ id: "g-sa-3",
2079
+ fillerId: "acme",
2080
+ sentAt: 178999976e4,
2081
+ orderHash: "0x22e3a53ab72c6990b1971fd50b9ec6c527a003d987cd58d26058b380dd7ae79a",
2082
+ attempt: 1,
2083
+ sourceChainId: "canton:mainnet",
2084
+ proof: {
2085
+ kind: 1,
2086
+ orderHash: "0x22e3a53ab72c6990b1971fd50b9ec6c527a003d987cd58d26058b380dd7ae79a",
2087
+ destination: "0x0000000000000000000000000000000000000000000000000000000000000001",
2088
+ fillRef: "0xfba8fd8a079872a9efe9646fcf34cfbbe8711ebd63665e8f2e0924949264c471",
2089
+ recipient: "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
2090
+ outputAsset: "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
2091
+ amountDelivered: "1200250000",
2092
+ filledAt: "1789999700",
2093
+ fillerId: "0xe29dae06ef4c3e336b7538b6d4f52ca1ecec009b1df6fb501320e11b223aeeaf",
2094
+ repayTo: "0x4fa94ace29856f88ebea07ce6d18e21f52c60b4f66d147134c03c82b62957f9d",
2095
+ attempt: 1,
2096
+ setId: 3
2097
+ },
2098
+ signatures: [
2099
+ {
2100
+ signer: "0x5e877d05b3bfef8b53a59dde76b911fb521415cd",
2101
+ pubKey: "0x3056301006072a8648ce3d020106052b8104000a034200046e4ce4835ad9bacce317724d5a85bfb72f73c0e0e0d9bb0ece443a23c405994056f031b0c83296033a1fd06fc21cbfdab8a821b09c0172ed64ef1b1ee3469be3",
2102
+ signature: "0x3044022048f14c61c1f52f541ab136ef92bbbcfca14dd0560db802feb510f7fce19477b20220230a636d4d10c7e5c16b997394a8261185a899f0e8d8e5ffad14db4d4123dd16"
2103
+ },
2104
+ {
2105
+ signer: "0x6805cf7ce01e1c392d47806813503e367c932544",
2106
+ pubKey: "0x3056301006072a8648ce3d020106052b8104000a034200044f15010d9f9457006502d7cbe0cfc5ed67076c2d6f2d4d034b8412e1c07561c370356c5da930ec7a271c3c8d11d00a14e36a3cd3a2a4fad8c05b367357f15b7e",
2107
+ signature: "0x3045022100d4cb2f8a3084bf5749871a06fa543a9ba80889471eb2799ab4c4c08b31ee7e2902203e2b4af4e08f263168a046a4b6a6370398c7b03de7797f1a011910c0d784f4bc"
2108
+ },
2109
+ {
2110
+ signer: "0x695ba7eb3c2a35bfc8d16562560a01ba1f9931d0",
2111
+ pubKey: "0x3056301006072a8648ce3d020106052b8104000a0342000479d89465d2de95e32eb728c63c58f4554dbecd39dacf7b680a326672cbc601af2abda0dd84f5b8a4bf8efebcb5eb0d24643dc0cc32af3f76a6ef877b71e19e2b",
2112
+ signature: "0x304402200a300c658594fe20fb429c4f32e23e0b3e444a017f320622cb636792d6f13ca802200cbd9bcb4ea5719f63f8a510e7e9f3d730a47691a7b6eb8e78ec787218997e02"
2113
+ }
2114
+ ],
2115
+ setId: 3,
2116
+ threshold: 2,
2117
+ refundAfter: "1790001800",
2118
+ sig: "0x481041cd0c07174f6db63b7acdc96a0bcc399de0be60df07faea3be6f0f09c83553a59f5e5443a6d7d1763789404d732a4b5cdc57758b729adf50245b8f96c2d1b"
2119
+ }
2120
+ }
2121
+ ]
2122
+ },
2123
+ "canton.prepare": {
2124
+ name: "canton.prepare",
2125
+ title: "canton.prepare (F2S)",
2126
+ payload: {
2127
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2128
+ schema: {
2129
+ $ref: "messages.schema.json#/$defs/canton.prepare"
2130
+ }
2131
+ },
2132
+ examples: [
2133
+ {
2134
+ name: "canton-prepare-1",
2135
+ payload: {
2136
+ type: "canton.prepare",
2137
+ id: "cp-1",
2138
+ fillerId: "acme-markets",
2139
+ sentAt: 178999e7,
2140
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2141
+ op: "party.allocate",
2142
+ params: {
2143
+ publicKey: "0x1111111111111111111111111111111111111111111111111111111111111111"
2144
+ }
2145
+ }
2146
+ },
2147
+ {
2148
+ name: "canton-prepare-2",
2149
+ payload: {
2150
+ type: "canton.prepare",
2151
+ id: "cp-2",
2152
+ fillerId: "acme-markets",
2153
+ sentAt: 17899901e5,
2154
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2155
+ op: "registry.accept",
2156
+ params: {}
2157
+ }
2158
+ },
2159
+ {
2160
+ name: "canton-prepare-3",
2161
+ payload: {
2162
+ type: "canton.prepare",
2163
+ id: "cp-3",
2164
+ fillerId: "acme-markets",
2165
+ sentAt: 1790000026e3,
2166
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2167
+ op: "delivery.fill",
2168
+ params: {
2169
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
2170
+ attempt: 2
2171
+ }
2172
+ }
2173
+ },
2174
+ {
2175
+ name: "canton-prepare-4",
2176
+ payload: {
2177
+ type: "canton.prepare",
2178
+ id: "cp-4",
2179
+ fillerId: "acme-markets",
2180
+ sentAt: 17900007e5,
2181
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2182
+ op: "intent.settle",
2183
+ params: {
2184
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b"
2185
+ }
2186
+ }
2187
+ },
2188
+ {
2189
+ name: "canton-prepare-5",
2190
+ payload: {
2191
+ type: "canton.prepare",
2192
+ id: "cp-5",
2193
+ fillerId: "acme-markets",
2194
+ sentAt: 1790001e6,
2195
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2196
+ op: "holdings.transfer",
2197
+ params: {
2198
+ asset: {
2199
+ admin: "cancore-registry::1220aa",
2200
+ id: "CNRX"
2201
+ },
2202
+ amount: "250.5",
2203
+ toParty: "alice::1220f0e1d2c3b4a5968778695a4b3c2d1e0ff0e1d2c3b4a5968778695a4b3c2d1e0f"
2204
+ }
2205
+ }
2206
+ }
2207
+ ]
2208
+ },
2209
+ "canton.prepared": {
2210
+ name: "canton.prepared",
2211
+ title: "canton.prepared (S2F)",
2212
+ payload: {
2213
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2214
+ schema: {
2215
+ $ref: "messages.schema.json#/$defs/canton.prepared"
2216
+ }
2217
+ },
2218
+ examples: [
2219
+ {
2220
+ name: "canton-prepared-1",
2221
+ payload: {
2222
+ type: "canton.prepared",
2223
+ id: "g-19",
2224
+ fillerId: "acme-markets",
2225
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2226
+ sentAt: 1789990000200,
2227
+ re: "cp-1",
2228
+ operationId: "op-1",
2229
+ op: "party.allocate",
2230
+ legs: [
2231
+ {
2232
+ legId: "topology-0",
2233
+ kind: "topology",
2234
+ hash: "0x12203d71f7c09428bb0f75651436e3a1c92b3a12490049882ff50711337cf5c9de0a",
2235
+ topologyTransactions: [
2236
+ "CgMyLjESBTAuMC4x",
2237
+ "CgMyLjESBTAuMC4y"
2238
+ ]
2239
+ }
2240
+ ],
2241
+ summary: {
2242
+ partyId: "acme-markets::1220a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90",
2243
+ publicKey: "0x1111111111111111111111111111111111111111111111111111111111111111",
2244
+ hosting: {
2245
+ participantUid: "PAR::cancore::1220c0ffee",
2246
+ permission: "CONFIRMATION",
2247
+ threshold: 1
2248
+ }
2249
+ },
2250
+ expiresAt: 1789990300200
2251
+ }
2252
+ },
2253
+ {
2254
+ name: "canton-prepared-2",
2255
+ payload: {
2256
+ type: "canton.prepared",
2257
+ id: "g-20",
2258
+ fillerId: "acme-markets",
2259
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2260
+ sentAt: 1790000026300,
2261
+ re: "cp-3",
2262
+ operationId: "op-3",
2263
+ op: "delivery.fill",
2264
+ legs: [
2265
+ {
2266
+ legId: "delivery-fill-0",
2267
+ kind: "transaction",
2268
+ hash: "0xf85381267321fc9b5122e45db048de3313dbc0dce8b36202673245d6c6d92840",
2269
+ preparedTransaction: "CgMyLjESBTAuMC4x",
2270
+ hashingSchemeVersion: "HASHING_SCHEME_VERSION_V2"
2271
+ }
2272
+ ],
2273
+ summary: {
2274
+ orderHash: "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
2275
+ attempt: 2,
2276
+ deliveryOrderCid: "00a1b2c3d4e5f6#fixture-delivery-order",
2277
+ recipient: "alice::1220f0e1d2c3b4a5968778695a4b3c2d1e0ff0e1d2c3b4a5968778695a4b3c2d1e0f",
2278
+ asset: {
2279
+ admin: "cancore-registry::1220aa",
2280
+ id: "CNRX"
2281
+ },
2282
+ amount: "999.0",
2283
+ repayTo: "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
2284
+ validUntil: "1790000400",
2285
+ inputHoldingCids: [
2286
+ "00h1",
2287
+ "00h2"
2288
+ ],
2289
+ executeBefore: "1790000400",
2290
+ transferFactoryCid: "00tf"
2291
+ },
2292
+ expiresAt: 1790000326300
2293
+ }
2294
+ }
2295
+ ]
2296
+ },
2297
+ "canton.submit": {
2298
+ name: "canton.submit",
2299
+ title: "canton.submit (F2S)",
2300
+ payload: {
2301
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2302
+ schema: {
2303
+ $ref: "messages.schema.json#/$defs/canton.submit"
2304
+ }
2305
+ },
2306
+ examples: [
2307
+ {
2308
+ name: "canton-submit-1",
2309
+ payload: {
2310
+ type: "canton.submit",
2311
+ id: "cs-3",
2312
+ fillerId: "acme-markets",
2313
+ sentAt: 1790000027e3,
2314
+ msgSig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2315
+ operationId: "op-3",
2316
+ signatures: [
2317
+ {
2318
+ legId: "delivery-fill-0",
2319
+ signature: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
2320
+ }
2321
+ ]
2322
+ }
2323
+ }
2324
+ ]
2325
+ },
2326
+ "canton.submitted": {
2327
+ name: "canton.submitted",
2328
+ title: "canton.submitted (S2F)",
2329
+ payload: {
2330
+ schemaFormat: "application/schema+json;version=draft-2020-12",
2331
+ schema: {
2332
+ $ref: "messages.schema.json#/$defs/canton.submitted"
2333
+ }
2334
+ },
2335
+ examples: [
2336
+ {
2337
+ name: "canton-submitted-1",
2338
+ payload: {
2339
+ type: "canton.submitted",
2340
+ id: "g-21",
2341
+ fillerId: "acme-markets",
2342
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2343
+ sentAt: 1790000029e3,
2344
+ re: "cs-3",
2345
+ operationId: "op-3",
2346
+ op: "delivery.fill",
2347
+ updateId: "1220ab0c",
2348
+ result: {
2349
+ receiptCid: "00c1d2"
2350
+ }
2351
+ }
2352
+ },
2353
+ {
2354
+ name: "canton-submitted-2",
2355
+ payload: {
2356
+ type: "canton.submitted",
2357
+ id: "g-22",
2358
+ fillerId: "acme-markets",
2359
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2360
+ sentAt: 1789990002e3,
2361
+ re: "cs-1",
2362
+ operationId: "op-1",
2363
+ op: "party.allocate",
2364
+ result: {
2365
+ partyId: "acme-markets::1220a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90"
2366
+ }
2367
+ }
2368
+ },
2369
+ {
2370
+ name: "canton-submitted-3",
2371
+ payload: {
2372
+ type: "canton.submitted",
2373
+ id: "g-23",
2374
+ fillerId: "acme-markets",
2375
+ sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b",
2376
+ sentAt: 1790001002e3,
2377
+ re: "cs-5",
2378
+ operationId: "op-5",
2379
+ op: "holdings.transfer",
2380
+ updateId: "1220ab0d",
2381
+ result: {
2382
+ outcome: "PENDING",
2383
+ transferInstructionCid: "00ti"
2384
+ }
2385
+ }
2386
+ }
2387
+ ]
2388
+ }
2389
+ }
2390
+ }
2391
+ };
2392
+
2393
+ // spec/protocol/messages.schema.json
2394
+ var messages_schema_default = {
2395
+ $schema: "https://json-schema.org/draft/2020-12/schema",
2396
+ $id: "https://cancore.io/schemas/filler-protocol/v1/messages.schema.json",
2397
+ title: "Cancore filler protocol v1 \u2014 WebSocket frames",
2398
+ $comment: "One $def per frame type, validated by name ($defs/<type>). The schemas encode the SENDER rule (protocol \xA73.1): lowercase hex, uint64 and wider as canonical decimal strings, uint8/16/32 as JSON integers, gateway times in milliseconds. No object is closed (V-2): receivers ignore unknown fields, takers ignore unknown S\u2192F types, and treat an unknown reason/result/code as OTHER/generic. Every enum is open: anyOf [known values, futureEnumValue]. x-direction: S2F = gateway to filler, F2S = filler to gateway, both = either way (ping, pong, error; <type>S2F is the gateway's copy, <type>F2S the filler's). x-rest-only: the type travels only as a REST body (auth.challenge, auth.response: the login of protocol \xA73.6), never on the WebSocket. Every frame in both directions carries id, sentAt and fillerId (optional only on a gateway error that refuses a login, POST /v1/filler/auth) and is signed (protocol \xA73.4): `sig` = the gateway key over GatewayMessage{bodyHash} on S2F, `msgSig` = the filler's message key over FillerMessage{bodyHash} on F2S, bodyHash = keccak256(JCS(frame without that field)). No exceptions: ticket.decline, a declining quote.reconfirm.reply, fill.reported, pong and error from the filler are signed too.",
2399
+ $defs: {
2400
+ uintDec64: { type: "string", pattern: "^(0|[1-9][0-9]*)$", maxLength: 20, description: "uint64 as a decimal string: digits only, no sign, no exponent, no leading zero" },
2401
+ uintDec256: { type: "string", pattern: "^(0|[1-9][0-9]*)$", maxLength: 78, description: "uint256 as a decimal string" },
2402
+ intDecUsd: { type: "string", pattern: "^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$", description: "signed decimal USD amount" },
2403
+ uint8: { type: "integer", minimum: 0, maximum: 255 },
2404
+ uint16: { type: "integer", minimum: 0, maximum: 65535 },
2405
+ uint32: { type: "integer", minimum: 0, maximum: 4294967295 },
2406
+ address: { type: "string", pattern: "^0x[0-9a-f]{40}$", description: "EVM address, lowercase hex" },
2407
+ bytes32: { type: "string", pattern: "^0x[0-9a-f]{64}$" },
2408
+ repayTo: { $ref: "#/$defs/bytes32", description: "where settle pays the filler, encoded for the SOURCE chain (protocol \xA73.15): EVM \u2014 the address left-padded to 32 bytes (repayToEvm); Canton \u2014 keccak256(utf8(partyId)) of the filler's registered party" },
2409
+ repayToEvm: { type: "string", pattern: "^0x0{24}(?!0{40})[0-9a-f]{40}$", description: "repayTo for an EVM source: zero top 12 bytes (the router refuses others, InvalidBytes32Address) and not the zero address (ZeroAddress). A receiver that knows the source chain checks repayTo against this" },
2410
+ deliveryKey: { $ref: "#/$defs/address", description: "the address that sends fill on the destination (FillTicket.deliveryKey); the zero address for a Canton destination" },
2411
+ sig65: { type: "string", pattern: "^0x[0-9a-f]{64}[0-7][0-9a-f]{63}(1b|1c)$", description: "65-byte r \u2016 s \u2016 v of an EOA, low-s, v \u2208 {27, 28}; no EIP-1271. The pattern refuses any other length or v and an s with its top bit set; isEoaSignature checks the exact bound s \u2264 n/2" },
2412
+ timeMs: { type: "integer", minimum: 1e12, maximum: 9007199254740991, description: "unix milliseconds, gateway clock; the minimum rejects seconds" },
2413
+ durationMs: { type: "integer", minimum: 0, maximum: 9007199254740991 },
2414
+ timeS: { $ref: "#/$defs/uintDec64", description: "unix seconds as a decimal string (on-chain and signed times)" },
2415
+ caip2: { type: "string", pattern: "^(eip155:[1-9][0-9]*|canton:(mainnet|testnet|devnet))$" },
2416
+ cantonAsset: {
2417
+ type: "object",
2418
+ required: ["admin", "id"],
2419
+ properties: { admin: { type: "string", minLength: 1 }, id: { type: "string", minLength: 1 } }
2420
+ },
2421
+ asset: { oneOf: [{ $ref: "#/$defs/address" }, { $ref: "#/$defs/cantonAsset" }] },
2422
+ requestId: { type: "string", pattern: "^[!-~]{1,64}$", description: "1..64 printable ASCII (Canonical.daml:90-93)" },
2423
+ fillerId: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{0,62}$" },
2424
+ messageId: { type: "string", minLength: 1, maxLength: 64, description: "unique per fillerId and direction across every session of that fillerId; never reused by its sender within maxMessageAgeMs" },
2425
+ protocolVersion: { const: "1" },
2426
+ order: {
2427
+ type: "object",
2428
+ description: "ICancoreRouter.Order, twelve fields, every numeric field a decimal string (the shape of canton-order.json vector.order)",
2429
+ required: ["user", "originChainId", "inputToken", "inputAmount", "destination", "outputAsset", "minReceived", "recipient", "createdAt", "fillDeadline", "feeBps", "fillerId"],
2430
+ properties: {
2431
+ user: { $ref: "#/$defs/address" },
2432
+ originChainId: { $ref: "#/$defs/uintDec64" },
2433
+ inputToken: { $ref: "#/$defs/address" },
2434
+ inputAmount: { $ref: "#/$defs/uintDec256" },
2435
+ destination: { $ref: "#/$defs/bytes32" },
2436
+ outputAsset: { $ref: "#/$defs/bytes32" },
2437
+ minReceived: { $ref: "#/$defs/uintDec256" },
2438
+ recipient: { $ref: "#/$defs/bytes32" },
2439
+ createdAt: { $ref: "#/$defs/timeS" },
2440
+ fillDeadline: { $ref: "#/$defs/timeS" },
2441
+ feeBps: { type: "string", pattern: "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$", description: "uint16" },
2442
+ fillerId: { $ref: "#/$defs/bytes32", description: "keccak256(utf8(fillerId)) of the filler the user picked" }
2443
+ }
2444
+ },
2445
+ ticket: {
2446
+ type: "object",
2447
+ description: "FillTicket(bytes32 orderHash,bytes32 fillerId,address deliveryKey,bytes32 repayTo,uint32 attempt,uint64 validFrom,uint64 validUntil); fillerId is keccak256(utf8(fillerId)), deliveryKey and repayTo are those of the filler's signed ticket.intent (S-22)",
2448
+ required: ["orderHash", "fillerId", "deliveryKey", "repayTo", "attempt", "validFrom", "validUntil"],
2449
+ properties: {
2450
+ orderHash: { $ref: "#/$defs/bytes32" },
2451
+ fillerId: { $ref: "#/$defs/bytes32" },
2452
+ deliveryKey: { $ref: "#/$defs/address" },
2453
+ repayTo: { $ref: "#/$defs/repayTo" },
2454
+ attempt: { $ref: "#/$defs/uint32" },
2455
+ validFrom: { $ref: "#/$defs/timeS" },
2456
+ validUntil: { $ref: "#/$defs/timeS" }
2457
+ }
2458
+ },
2459
+ futureEnumValue: { type: "string", pattern: "^[A-Z][A-Z0-9_]*$", description: "a value added to an open enum within v1 (V-2); the receiver treats it as OTHER/generic. Every protocol enum is `anyOf: [{enum: known values}, futureEnumValue]`" },
2460
+ declineReason: {
2461
+ anyOf: [
2462
+ { enum: ["NO_INVENTORY", "RISK_LIMIT", "PRICE_MOVED", "PAUSED", "OTHER", "TICKET_SIGNER_UNKNOWN", "TICKET_MISMATCH", "TICKET_TTL_TOO_SHORT", "TICKET_ISSUED_LATE", "TICKET_BEYOND_DEADLINE", "ESCROW_NOT_OPEN", "ESCROW_MISMATCH", "PROOF_WINDOW_TOO_SHORT", "SKEW_MARGIN_TOO_SHORT", "DRAW_MISMATCH"] },
2463
+ { $ref: "#/$defs/futureEnumValue" }
2464
+ ]
2465
+ },
2466
+ errorCode: {
2467
+ anyOf: [
2468
+ { enum: ["BAD_REQUEST", "UNAUTHENTICATED", "UNSUPPORTED_VERSION", "UNSUPPORTED_TYPE", "BAD_SIGNATURE", "STALE_MESSAGE", "REPLAYED_MESSAGE", "TICKET_REFUSED", "UNKNOWN_REQUEST", "UNKNOWN_TICKET", "TICKET_CLOSED", "NOT_ELIGIBLE", "RATE_LIMITED", "INTERNAL", "ATTESTATIONS_NOT_READY", "CANTON_NOT_READY", "CANTON_REFUSED", "CANTON_UNAVAILABLE", "OPERATION_EXPIRED"] },
2469
+ { $ref: "#/$defs/futureEnumValue" }
2470
+ ]
2471
+ },
2472
+ ticketRefusedReason: {
2473
+ anyOf: [
2474
+ { enum: ["REPAY_TO_INVALID", "REPAY_TO_BLOCKLISTED", "DELIVERY_KEY_INVALID", "PAYOUT_NOT_READY", "RECIPIENT_NOT_READY", "OPEN_TICKET_LIMIT", "PROOF_WINDOW_TOO_SHORT", "ATTESTOR_REVOCATION_PENDING", "SERVICE_DEGRADED", "OTHER"] },
2475
+ { $ref: "#/$defs/futureEnumValue" }
2476
+ ],
2477
+ description: "error.reason with TICKET_REFUSED: the pre-ticket check that failed (S-21); the order is re-drawn, nothing is recorded against the filler"
2478
+ },
2479
+ expiredResult: { anyOf: [{ enum: ["FILLED", "NO_SHOW", "NO_SHOW_UNCONFIRMED", "EXEMPT"] }, { $ref: "#/$defs/futureEnumValue" }] },
2480
+ exemptReason: { anyOf: [{ enum: ["DESTINATION_HALTED", "GATEWAY_FAULT", "REORGED_AFTER_INCLUSION", "RECIPIENT_NOT_READY", "OTHER"] }, { $ref: "#/$defs/futureEnumValue" }] },
2481
+ quoteAckStatus: { anyOf: [{ enum: ["COUNTED", "LATE", "SHORT_TTL"] }, { $ref: "#/$defs/futureEnumValue" }], description: "verdict at receipt time; the final status is on GET /v1/filler/quotes" },
2482
+ penaltyStep: { anyOf: [{ enum: ["L1", "L2", "L3", "L4"] }, { $ref: "#/$defs/futureEnumValue" }] },
2483
+ s2fEnvelope: {
2484
+ type: "object",
2485
+ required: ["type", "id", "sentAt", "sig"],
2486
+ properties: {
2487
+ type: { type: "string" },
2488
+ id: { $ref: "#/$defs/messageId" },
2489
+ fillerId: { $ref: "#/$defs/fillerId", description: "the addressee" },
2490
+ sentAt: { $ref: "#/$defs/timeMs" },
2491
+ sig: { $ref: "#/$defs/sig65", description: "gateway key over GatewayMessage{bodyHash = keccak256(JCS(frame without sig))}" },
2492
+ re: { $ref: "#/$defs/messageId" }
2493
+ }
2494
+ },
2495
+ s2fBase: { allOf: [{ $ref: "#/$defs/s2fEnvelope" }, { type: "object", required: ["fillerId"], properties: { fillerId: { $ref: "#/$defs/fillerId" } } }] },
2496
+ f2sEnvelope: {
2497
+ type: "object",
2498
+ description: "What every filler \u2192 filler-gateway message and REST request body carries (protocol \xA73.4, S-19): the gateway refuses one without it, with another fillerId than the session's, with a stale sentAt or a reused id",
2499
+ required: ["id", "fillerId", "sentAt", "msgSig"],
2500
+ properties: {
2501
+ id: { $ref: "#/$defs/messageId" },
2502
+ fillerId: { $ref: "#/$defs/fillerId", description: "the sender; must be the fillerId the session is authenticated for" },
2503
+ sentAt: { $ref: "#/$defs/timeMs" },
2504
+ msgSig: { $ref: "#/$defs/sig65", description: "the filler's message key over FillerMessage{bodyHash = keccak256(JCS(message without msgSig))}; the body keeps id, fillerId, sentAt and any inner sig" },
2505
+ re: { $ref: "#/$defs/messageId" }
2506
+ }
2507
+ },
2508
+ f2sBase: { allOf: [{ $ref: "#/$defs/f2sEnvelope" }, { type: "object", required: ["type"], properties: { type: { type: "string" } } }] },
2509
+ fillerKeyRegistration: {
2510
+ type: "object",
2511
+ description: "Proof of possession of a message key (protocol \xA73.16): FillerKeyRegistration{fillerId, messageKey, issuedAt} signed by that key \u2014 at onboarding, and with the NEW key at a manual key change by Cancore staff, who submit it to the key registry of filler-gateway. Not a frame: there is no key-change message. sig must be an EOA signature (65 bytes, low-s, v \u2208 {27, 28}) that recovers to messageKey; an EIP-1271 signature is refused",
2512
+ required: ["fillerId", "messageKey", "issuedAt", "sig"],
2513
+ properties: {
2514
+ fillerId: { $ref: "#/$defs/fillerId" },
2515
+ messageKey: { $ref: "#/$defs/address" },
2516
+ issuedAt: { $ref: "#/$defs/timeS" },
2517
+ sig: { $ref: "#/$defs/sig65" }
2518
+ }
2519
+ },
2520
+ "auth.challenge": {
2521
+ "x-direction": "S2F",
2522
+ "x-rest-only": true,
2523
+ type: "object",
2524
+ description: "The login challenge, addressed to the fillerId it was asked for: the 200 body of GET /v1/filler/auth/challenge?fillerId=. Never sent on the WebSocket. The filler checks the gateway sig and that fillerId is its own before it signs FillerAuth{fillerId, nonce, expiresAt}",
2525
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2526
+ required: ["type", "nonce", "expiresAt"],
2527
+ properties: { type: { const: "auth.challenge" }, nonce: { $ref: "#/$defs/bytes32" }, expiresAt: { $ref: "#/$defs/timeS" } }
2528
+ },
2529
+ "auth.response": {
2530
+ "x-direction": "F2S",
2531
+ type: "object",
2532
+ "x-rest-only": true,
2533
+ description: "The body of POST /v1/filler/auth, answered with {token, expiresAt}. sig = FillerAuth{fillerId, nonce, expiresAt} by the registered message key of fillerId (keyAddress = its address); msgSig by the same key. Never sent on the WebSocket: a WebSocket connection is authenticated by the bearer token offered on the upgrade",
2534
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2535
+ required: ["type", "fillerId", "keyAddress", "protocolVersion", "sig"],
2536
+ properties: {
2537
+ type: { const: "auth.response" },
2538
+ fillerId: { $ref: "#/$defs/fillerId" },
2539
+ keyAddress: { $ref: "#/$defs/address" },
2540
+ protocolVersion: { type: "string", description: 'the gateway answers UNSUPPORTED_VERSION to anything it does not serve; v1 senders send "1"' },
2541
+ nonce: { $ref: "#/$defs/bytes32", description: "the auth.challenge nonce this response answers (optional; senders SHOULD send it), so POST /v1/filler/auth finds the live challenge of this fillerId without trying every one" },
2542
+ sig: { $ref: "#/$defs/sig65" }
2543
+ }
2544
+ },
2545
+ "auth.ok": {
2546
+ "x-direction": "S2F",
2547
+ type: "object",
2548
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2549
+ required: ["type", "heartbeatIntervalMs"],
2550
+ properties: { type: { const: "auth.ok" }, heartbeatIntervalMs: { $ref: "#/$defs/durationMs" } }
2551
+ },
2552
+ ping: {
2553
+ "x-direction": "both",
2554
+ description: "Heartbeat, either way. A receiver checks the copy of its direction: pingS2F (gateway sig) or pingF2S (filler msgSig)",
2555
+ anyOf: [{ $ref: "#/$defs/pingF2S" }, { $ref: "#/$defs/pingS2F" }]
2556
+ },
2557
+ pingF2S: {
2558
+ type: "object",
2559
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2560
+ required: ["type", "id"],
2561
+ properties: { type: { const: "ping" }, id: { $ref: "#/$defs/messageId" } }
2562
+ },
2563
+ pingS2F: {
2564
+ type: "object",
2565
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2566
+ required: ["type", "id"],
2567
+ properties: { type: { const: "ping" }, id: { $ref: "#/$defs/messageId" } }
2568
+ },
2569
+ pong: {
2570
+ "x-direction": "both",
2571
+ description: "Answer to a ping, re = ping.id. A receiver checks the copy of its direction: pongS2F (gateway sig) or pongF2S (filler msgSig)",
2572
+ anyOf: [{ $ref: "#/$defs/pongF2S" }, { $ref: "#/$defs/pongS2F" }]
2573
+ },
2574
+ pongF2S: {
2575
+ type: "object",
2576
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2577
+ required: ["type", "re"],
2578
+ properties: { type: { const: "pong" }, re: { $ref: "#/$defs/messageId" } }
2579
+ },
2580
+ pongS2F: {
2581
+ type: "object",
2582
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2583
+ required: ["type", "re"],
2584
+ properties: { type: { const: "pong" }, re: { $ref: "#/$defs/messageId" } }
2585
+ },
2586
+ error: {
2587
+ "x-direction": "both",
2588
+ description: "Either way. A receiver checks the copy of its direction: errorS2F (the gateway's reply, also the REST error body) or errorF2S (the filler's reply to a gateway frame it cannot handle)",
2589
+ anyOf: [{ $ref: "#/$defs/errorF2S" }, { $ref: "#/$defs/errorS2F" }]
2590
+ },
2591
+ errorS2F: {
2592
+ type: "object",
2593
+ description: "Reply to the F\u2192S frame `re`; also the REST error body. fillerId may be absent on a refusal of POST /v1/filler/auth, which is not authenticated yet. reason names the failed pre-ticket check with TICKET_REFUSED. retryAfterMs comes with RATE_LIMITED only",
2594
+ allOf: [{ $ref: "#/$defs/s2fEnvelope" }],
2595
+ required: ["type", "code", "message"],
2596
+ properties: {
2597
+ type: { const: "error" },
2598
+ code: { $ref: "#/$defs/errorCode" },
2599
+ message: { type: "string" },
2600
+ reason: { $ref: "#/$defs/ticketRefusedReason" },
2601
+ retryAfterMs: { $ref: "#/$defs/durationMs", type: "integer", minimum: 1, description: "with RATE_LIMITED: ms (\u2265 1) until the rate class of the refused message holds a token again, or until the cooldown of the fillerId ends; the filler sends nothing of that class before it" }
2602
+ },
2603
+ if: { type: "object", properties: { code: { const: "TICKET_REFUSED" } }, required: ["code"] },
2604
+ then: { type: "object", required: ["reason"], properties: { reason: true } }
2605
+ },
2606
+ errorF2S: {
2607
+ type: "object",
2608
+ description: "The filler's reply to the S\u2192F frame `re` it cannot handle (malformed, unknown orderHash); informational, it changes no state in filler-gateway. Signed like every filler message",
2609
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2610
+ required: ["type", "re", "code", "message"],
2611
+ properties: { type: { const: "error" }, re: { $ref: "#/$defs/messageId" }, code: { $ref: "#/$defs/errorCode" }, message: { type: "string" } }
2612
+ },
2613
+ "epoch.weights": {
2614
+ "x-direction": "S2F",
2615
+ type: "object",
2616
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2617
+ required: ["type", "epochId", "startsAt", "endsAt", "weightsRoot"],
2618
+ properties: {
2619
+ type: { const: "epoch.weights" },
2620
+ epochId: { $ref: "#/$defs/uintDec64" },
2621
+ startsAt: { $ref: "#/$defs/timeS" },
2622
+ endsAt: { $ref: "#/$defs/timeS" },
2623
+ weightsRoot: { $ref: "#/$defs/bytes32" }
2624
+ }
2625
+ },
2626
+ "quote.request": {
2627
+ "x-direction": "S2F",
2628
+ type: "object",
2629
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2630
+ required: ["type", "requestId", "route", "inputToken", "inputAmount", "outputAsset", "feeBps", "fillDeadlineHint", "windowCloseAt", "quoteTtlMs"],
2631
+ properties: {
2632
+ type: { const: "quote.request" },
2633
+ requestId: { $ref: "#/$defs/requestId" },
2634
+ route: {
2635
+ type: "object",
2636
+ required: ["src", "dst"],
2637
+ properties: { src: { $ref: "#/$defs/caip2" }, dst: { $ref: "#/$defs/caip2" } }
2638
+ },
2639
+ inputToken: { $ref: "#/$defs/asset" },
2640
+ inputAmount: { $ref: "#/$defs/uintDec256", description: "the total T the maker deposits (inclusive fee), input base units" },
2641
+ outputAsset: { $ref: "#/$defs/asset" },
2642
+ feeBps: { $ref: "#/$defs/uint16" },
2643
+ fillDeadlineHint: { $ref: "#/$defs/timeS" },
2644
+ windowCloseAt: { $ref: "#/$defs/timeMs" },
2645
+ quoteTtlMs: { $ref: "#/$defs/durationMs" },
2646
+ imbalanceHint: {
2647
+ type: "object",
2648
+ required: ["dstAsset", "netFlow24hUsd"],
2649
+ properties: { dstAsset: { $ref: "#/$defs/asset" }, netFlow24hUsd: { $ref: "#/$defs/intDecUsd" } }
2650
+ }
2651
+ }
2652
+ },
2653
+ quote: {
2654
+ "x-direction": "F2S",
2655
+ type: "object",
2656
+ description: "sig = FillerQuote{keccak256(utf8(requestId)), fillerId, amountOut, validUntil, nonce} by the message key, fillerId the envelope's; counts only if validUntil \xD7 1000 \u2265 windowCloseAt + quoteTtlMs",
2657
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2658
+ required: ["type", "requestId", "amountOut", "validUntil", "nonce", "sig"],
2659
+ properties: {
2660
+ type: { const: "quote" },
2661
+ requestId: { $ref: "#/$defs/requestId" },
2662
+ amountOut: { $ref: "#/$defs/uintDec256" },
2663
+ validUntil: { $ref: "#/$defs/timeS" },
2664
+ nonce: { $ref: "#/$defs/uintDec64" },
2665
+ sig: { $ref: "#/$defs/sig65" }
2666
+ }
2667
+ },
2668
+ "quote.ack": {
2669
+ "x-direction": "S2F",
2670
+ type: "object",
2671
+ description: "For every well-formed, correctly signed quote, late ones included (S-12)",
2672
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2673
+ required: ["type", "requestId", "quoteHash", "receivedAt", "status"],
2674
+ properties: {
2675
+ type: { const: "quote.ack" },
2676
+ requestId: { $ref: "#/$defs/requestId" },
2677
+ quoteHash: { $ref: "#/$defs/bytes32" },
2678
+ receivedAt: { $ref: "#/$defs/timeMs" },
2679
+ status: { $ref: "#/$defs/quoteAckStatus" }
2680
+ }
2681
+ },
2682
+ "quote.reconfirm": {
2683
+ "x-direction": "S2F",
2684
+ type: "object",
2685
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2686
+ required: ["type", "orderHash", "requestId", "order", "amountOut", "ticketTtl", "replyBy"],
2687
+ properties: {
2688
+ type: { const: "quote.reconfirm" },
2689
+ orderHash: { $ref: "#/$defs/bytes32" },
2690
+ requestId: { $ref: "#/$defs/requestId" },
2691
+ order: { $ref: "#/$defs/order" },
2692
+ amountOut: { $ref: "#/$defs/uintDec256" },
2693
+ ticketTtl: { $ref: "#/$defs/uint32", description: "seconds" },
2694
+ replyBy: { $ref: "#/$defs/timeMs" }
2695
+ }
2696
+ },
2697
+ "quote.reconfirm.reply": {
2698
+ "x-direction": "F2S",
2699
+ type: "object",
2700
+ description: "An accept carries sig = FillerQuote{keccak256(utf8(requestId)), fillerId, amountOut, validUntil, nonce} by the message key; a decline carries only the envelope msgSig",
2701
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2702
+ required: ["type", "orderHash", "accept"],
2703
+ properties: {
2704
+ type: { const: "quote.reconfirm.reply" },
2705
+ orderHash: { $ref: "#/$defs/bytes32" },
2706
+ accept: { type: "boolean" },
2707
+ validUntil: { $ref: "#/$defs/timeS" },
2708
+ nonce: { $ref: "#/$defs/uintDec64" },
2709
+ sig: { $ref: "#/$defs/sig65" }
2710
+ },
2711
+ if: { type: "object", properties: { accept: { const: true } }, required: ["accept"] },
2712
+ then: { type: "object", required: ["validUntil", "nonce", "sig"], properties: { validUntil: true, nonce: true, sig: true } }
2713
+ },
2714
+ "ticket.offer": {
2715
+ "x-direction": "S2F",
2716
+ type: "object",
2717
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2718
+ required: ["type", "orderHash", "attempt", "order", "amountOut", "validFrom", "validUntil", "acceptBy"],
2719
+ properties: {
2720
+ type: { const: "ticket.offer" },
2721
+ orderHash: { $ref: "#/$defs/bytes32" },
2722
+ attempt: { $ref: "#/$defs/uint32" },
2723
+ order: { $ref: "#/$defs/order" },
2724
+ amountOut: { $ref: "#/$defs/uintDec256" },
2725
+ validFrom: { $ref: "#/$defs/timeS" },
2726
+ validUntil: { $ref: "#/$defs/timeS" },
2727
+ acceptBy: { $ref: "#/$defs/timeMs" }
2728
+ }
2729
+ },
2730
+ "ticket.intent": {
2731
+ "x-direction": "F2S",
2732
+ type: "object",
2733
+ description: "sig = TicketIntent{orderHash, attempt, validFrom, validUntil, fillerId, deliveryKey, repayTo} by the message key, fillerId the envelope's; orderHash, attempt, validFrom, validUntil equal the offer; the issued ticket carries exactly this deliveryKey and repayTo (S-22), or the gateway answers error TICKET_REFUSED (S-21)",
2734
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2735
+ required: ["type", "orderHash", "attempt", "validFrom", "validUntil", "deliveryKey", "repayTo", "sig"],
2736
+ properties: {
2737
+ type: { const: "ticket.intent" },
2738
+ orderHash: { $ref: "#/$defs/bytes32" },
2739
+ attempt: { $ref: "#/$defs/uint32" },
2740
+ validFrom: { $ref: "#/$defs/timeS" },
2741
+ validUntil: { $ref: "#/$defs/timeS" },
2742
+ deliveryKey: { $ref: "#/$defs/deliveryKey" },
2743
+ repayTo: { $ref: "#/$defs/repayTo" },
2744
+ sig: { $ref: "#/$defs/sig65" }
2745
+ }
2746
+ },
2747
+ "ticket.decline": {
2748
+ "x-direction": "F2S",
2749
+ type: "object",
2750
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2751
+ required: ["type", "orderHash", "attempt", "reason"],
2752
+ properties: {
2753
+ type: { const: "ticket.decline" },
2754
+ orderHash: { $ref: "#/$defs/bytes32" },
2755
+ attempt: { $ref: "#/$defs/uint32" },
2756
+ reason: { $ref: "#/$defs/declineReason" },
2757
+ detail: { type: "string" }
2758
+ }
2759
+ },
2760
+ "ticket.intent.ack": {
2761
+ "x-direction": "S2F",
2762
+ type: "object",
2763
+ description: "Idempotent: a repeated identical intent gets the identical ack",
2764
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2765
+ required: ["type", "orderHash", "attempt", "intentHash", "receivedAt"],
2766
+ properties: {
2767
+ type: { const: "ticket.intent.ack" },
2768
+ orderHash: { $ref: "#/$defs/bytes32" },
2769
+ attempt: { $ref: "#/$defs/uint32" },
2770
+ intentHash: { $ref: "#/$defs/bytes32" },
2771
+ receivedAt: { $ref: "#/$defs/timeMs" }
2772
+ }
2773
+ },
2774
+ "ticket.issued": {
2775
+ "x-direction": "S2F",
2776
+ type: "object",
2777
+ description: "form discriminates the EVM-destination ticket (FillTicket + ticketSig) from the Canton-destination one (DeliveryOrder, with its repayTo); a form added within v1 (V-2) is checked against the common fields only. The filler checks fillerId, deliveryKey and repayTo against its own ticket.intent before it delivers (T-15)",
2778
+ required: ["type", "form", "orderHash", "attempt"],
2779
+ properties: {
2780
+ type: { const: "ticket.issued" },
2781
+ form: { anyOf: [{ enum: ["evm", "canton"] }, { type: "string", pattern: "^[a-z][a-z0-9-]*$" }] },
2782
+ orderHash: { $ref: "#/$defs/bytes32" },
2783
+ attempt: { $ref: "#/$defs/uint32" }
2784
+ },
2785
+ allOf: [
2786
+ { $ref: "#/$defs/s2fBase" },
2787
+ {
2788
+ if: { type: "object", properties: { form: { const: "evm" } }, required: ["form"] },
2789
+ then: { type: "object", required: ["ticket", "ticketSig"], properties: { ticket: { $ref: "#/$defs/ticket" }, ticketSig: { $ref: "#/$defs/sig65" } } }
2790
+ },
2791
+ {
2792
+ if: { type: "object", properties: { form: { const: "canton" } }, required: ["form"] },
2793
+ then: { type: "object", required: ["deliveryOrderCid", "validUntil", "repayTo"], properties: { deliveryOrderCid: { type: "string", minLength: 1 }, validUntil: { $ref: "#/$defs/timeS" }, repayTo: { $ref: "#/$defs/repayTo", description: "the repayTo of the DeliveryOrder, = the filler's signed ticket.intent (S-22); fillerId is the envelope's" } } }
2794
+ }
2795
+ ]
2796
+ },
2797
+ "ticket.receipt": {
2798
+ "x-direction": "F2S",
2799
+ type: "object",
2800
+ description: 'form follows the issued ticket (S-14). EVM form (form absent or "evm"): sig = TicketReceipt{ticketHash, ticketSigHash} by the message key. Canton form: sig = CantonTicketReceipt{orderHash, attempt, deliveryOrderCidHash = keccak256(utf8(deliveryOrderCid)), validUntil} by the message key, deliveryOrderCid and validUntil exactly as in ticket.issued; fillerId and repayTo are not part of it (protocol \xA73.3, \xA710 D-O)',
2801
+ required: ["type", "orderHash", "attempt", "sig"],
2802
+ properties: {
2803
+ type: { const: "ticket.receipt" },
2804
+ form: { anyOf: [{ enum: ["evm", "canton"] }, { type: "string", pattern: "^[a-z][a-z0-9-]*$" }] },
2805
+ orderHash: { $ref: "#/$defs/bytes32" },
2806
+ attempt: { $ref: "#/$defs/uint32" },
2807
+ sig: { $ref: "#/$defs/sig65" }
2808
+ },
2809
+ allOf: [
2810
+ { $ref: "#/$defs/f2sBase" },
2811
+ {
2812
+ if: { type: "object", properties: { form: { const: "evm" } } },
2813
+ then: { type: "object", required: ["ticketHash", "ticketSigHash"], properties: { ticketHash: { $ref: "#/$defs/bytes32" }, ticketSigHash: { $ref: "#/$defs/bytes32" } } }
2814
+ },
2815
+ {
2816
+ if: { type: "object", properties: { form: { const: "canton" } }, required: ["form"] },
2817
+ then: { type: "object", required: ["deliveryOrderCid", "validUntil"], properties: { deliveryOrderCid: { type: "string", minLength: 1, description: "the contract id of the DeliveryOrder, exactly as ticket.issued sent it" }, validUntil: { $ref: "#/$defs/timeS", description: "= ticket.issued.validUntil" } } }
2818
+ }
2819
+ ]
2820
+ },
2821
+ "fill.reported": {
2822
+ "x-direction": "F2S",
2823
+ type: "object",
2824
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
2825
+ required: ["type", "orderHash", "attempt", "txRef"],
2826
+ properties: {
2827
+ type: { const: "fill.reported" },
2828
+ orderHash: { $ref: "#/$defs/bytes32" },
2829
+ attempt: { $ref: "#/$defs/uint32" },
2830
+ txRef: { type: "string", minLength: 1, description: "EVM tx hash or Canton update id" }
2831
+ }
2832
+ },
2833
+ "ticket.expired": {
2834
+ "x-direction": "S2F",
2835
+ type: "object",
2836
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2837
+ required: ["type", "orderHash", "attempt", "result"],
2838
+ properties: {
2839
+ type: { const: "ticket.expired" },
2840
+ orderHash: { $ref: "#/$defs/bytes32" },
2841
+ attempt: { $ref: "#/$defs/uint32" },
2842
+ result: { $ref: "#/$defs/expiredResult" },
2843
+ exemptReason: { $ref: "#/$defs/exemptReason" }
2844
+ },
2845
+ if: { type: "object", properties: { result: { const: "EXEMPT" } }, required: ["result"] },
2846
+ then: { type: "object", required: ["exemptReason"], properties: { exemptReason: true } }
2847
+ },
2848
+ "order.settled": {
2849
+ "x-direction": "S2F",
2850
+ type: "object",
2851
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2852
+ required: ["type", "orderHash", "payout", "fee", "penaltyWithheld", "txRef"],
2853
+ properties: {
2854
+ type: { const: "order.settled" },
2855
+ orderHash: { $ref: "#/$defs/bytes32" },
2856
+ payout: { $ref: "#/$defs/uintDec256" },
2857
+ fee: { $ref: "#/$defs/uintDec256" },
2858
+ penaltyWithheld: { $ref: "#/$defs/uintDec256" },
2859
+ txRef: { type: "string", minLength: 1 }
2860
+ }
2861
+ },
2862
+ "penalty.applied": {
2863
+ "x-direction": "S2F",
2864
+ type: "object",
2865
+ allOf: [{ $ref: "#/$defs/s2fBase" }],
2866
+ required: ["type", "violationId", "code", "step", "details"],
2867
+ properties: {
2868
+ type: { const: "penalty.applied" },
2869
+ violationId: { type: "string", minLength: 1 },
2870
+ code: { type: "string", minLength: 1 },
2871
+ step: { $ref: "#/$defs/penaltyStep" },
2872
+ details: { type: "object" }
2873
+ }
2874
+ },
2875
+ fillProof: {
2876
+ type: "object",
2877
+ description: "FillProof as the source router hashes it (FILL_PROOF_TYPES, the twelve variant A fields, protocol \xA73.3), encoded per protocol \xA73.1: kind, attempt, setId JSON integers; amountDelivered, filledAt decimal strings; fillerId the on-chain form keccak256(utf8(fillerId))",
2878
+ required: ["kind", "orderHash", "destination", "fillRef", "recipient", "outputAsset", "amountDelivered", "filledAt", "fillerId", "repayTo", "attempt", "setId"],
2879
+ properties: {
2880
+ kind: { $ref: "#/$defs/uint8" },
2881
+ orderHash: { $ref: "#/$defs/bytes32" },
2882
+ destination: { $ref: "#/$defs/bytes32" },
2883
+ fillRef: { $ref: "#/$defs/bytes32" },
2884
+ recipient: { $ref: "#/$defs/bytes32" },
2885
+ outputAsset: { $ref: "#/$defs/bytes32" },
2886
+ amountDelivered: { $ref: "#/$defs/uintDec256" },
2887
+ filledAt: { $ref: "#/$defs/timeS" },
2888
+ fillerId: { $ref: "#/$defs/bytes32", description: "keccak256(utf8(fillerId)) of the filler that delivered: this filler's" },
2889
+ repayTo: { $ref: "#/$defs/repayTo", description: "the payee of settle, encoded for the source chain: the repayTo of this filler's ticket" },
2890
+ attempt: { $ref: "#/$defs/uint32" },
2891
+ setId: { $ref: "#/$defs/uint32" }
2892
+ }
2893
+ },
2894
+ attestationEvm: {
2895
+ type: "object",
2896
+ description: "One attestor signature for an EVM source: EIP-712 over FillProof in the source-router domain; in the payload's order the signature values are the sigs argument of settle",
2897
+ required: ["signer", "signature"],
2898
+ properties: { signer: { $ref: "#/$defs/address" }, signature: { $ref: "#/$defs/sig65" } }
2899
+ },
2900
+ attestationCanton: {
2901
+ type: "object",
2902
+ description: "One attestor signature for a Canton source: the same digest, carried as SwapIntent_SettleWithProof takes it (SigEntry {pubKey, sig}; strip 0x for Daml). signer is the address Daml derives from pubKey",
2903
+ required: ["signer", "pubKey", "signature"],
2904
+ properties: {
2905
+ signer: { $ref: "#/$defs/address" },
2906
+ pubKey: { type: "string", pattern: "^0x3056301006072a8648ce3d020106052b8104000a03420004[0-9a-f]{128}$", description: "DER SubjectPublicKeyInfo of the uncompressed secp256k1 key (88 bytes), as KMS GetPublicKey returns it" },
2907
+ signature: { type: "string", pattern: "^0x30([0-9a-f]{2}){7,71}$", description: "minimal DER ECDSA signature, low-s, no recovery byte" }
2908
+ }
2909
+ },
2910
+ "settle.attestations": {
2911
+ "x-direction": "S2F",
2912
+ type: "object",
2913
+ description: "\u2265 threshold attestor signatures over the filler's FillProof (\xA710 D-N, S-13). Sent once per (orderHash, attempt); GET /v1/filler/attestations/{orderHash} serves the same payload. signatures: at least threshold entries, strictly ascending by signer (not expressible here; settleAttestationsErrors checks it). sourceChainId picks the entry form: eip155 \u2192 attestationEvm, canton \u2192 attestationCanton",
2914
+ allOf: [
2915
+ { $ref: "#/$defs/s2fBase" },
2916
+ {
2917
+ if: { type: "object", properties: { sourceChainId: { type: "string", pattern: "^canton:" } }, required: ["sourceChainId"] },
2918
+ then: { type: "object", properties: { signatures: { type: "array", items: { $ref: "#/$defs/attestationCanton" } } } },
2919
+ else: { type: "object", properties: { signatures: { type: "array", items: { $ref: "#/$defs/attestationEvm" } } } }
2920
+ }
2921
+ ],
2922
+ required: ["type", "orderHash", "attempt", "sourceChainId", "proof", "signatures", "setId", "threshold", "refundAfter"],
2923
+ properties: {
2924
+ type: { const: "settle.attestations" },
2925
+ orderHash: { $ref: "#/$defs/bytes32" },
2926
+ attempt: { $ref: "#/$defs/uint32", description: "equals proof.attempt" },
2927
+ sourceChainId: { $ref: "#/$defs/caip2", description: "where settle is submitted" },
2928
+ proof: { $ref: "#/$defs/fillProof" },
2929
+ signatures: { type: "array", minItems: 1 },
2930
+ setId: { $ref: "#/$defs/uint32", description: "equals proof.setId; EVM: attestationSetFor(orderHash)" },
2931
+ threshold: { type: "integer", minimum: 1, maximum: 4294967295, description: "k of that set" },
2932
+ refundAfter: { $ref: "#/$defs/timeS", description: "from this time settle reverts; the node gets its settle included before it" }
2933
+ }
2934
+ },
2935
+ cantonOp: {
2936
+ description: "A Canton operation of the filler's own external party on the Cancore participant (protocol \xA73.19): the backend prepares and submits it, the node signs it with its party key and never talks to a Ledger API. party.allocate creates the party (topology); registry.accept accepts the FillerRegistryEntryProposal of the fillerId; delivery.fill exercises DeliveryOrder_Fill of a Canton ticket issued to the filler; intent.settle exercises SwapIntent_SettleWithProof of a Canton-source order the filler delivered; holdings.transfer moves the party's own holdings to a party it names (TransferFactory_Transfer)",
2937
+ anyOf: [
2938
+ { enum: ["party.allocate", "registry.accept", "delivery.fill", "intent.settle", "holdings.transfer"] },
2939
+ { type: "string", pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$" }
2940
+ ]
2941
+ },
2942
+ operationId: {
2943
+ type: "string",
2944
+ pattern: "^[!-~]{1,64}$",
2945
+ description: "the handle canton.prepared hands out for canton.submit: opaque, 1..64 printable ASCII, valid until expiresAt"
2946
+ },
2947
+ edPublicKey: { type: "string", pattern: "^0x[0-9a-f]{64}$", description: "the raw 32-byte Ed25519 public key of the filler's Canton party, lowercase hex" },
2948
+ edSignature: { type: "string", pattern: "^0x[0-9a-f]{128}$", description: "64-byte Ed25519 signature by the party key over the bytes of a leg's hash, lowercase hex" },
2949
+ cantonLegTransaction: {
2950
+ type: "object",
2951
+ description: "A prepared Canton transaction to sign. MUST before signing (protocol \xA73.19): the node recomputes `hash` from `preparedTransaction` with the participant's prepared-transaction hashing of `hashingSchemeVersion`, decodes the transaction and checks it against `summary` for the op of the message \u2014 template and choice, acting and receiving parties, instrument, amount; on any difference it does not sign. It signs the 32 hash bytes with its party key",
2952
+ required: ["legId", "kind", "hash", "preparedTransaction", "hashingSchemeVersion"],
2953
+ properties: {
2954
+ legId: { type: "string", minLength: 1, maxLength: 128 },
2955
+ kind: { const: "transaction" },
2956
+ hash: { type: "string", pattern: "^0x[0-9a-f]{64}$", description: "the 32-byte prepared-transaction hash" },
2957
+ preparedTransaction: {
2958
+ type: "string",
2959
+ minLength: 1,
2960
+ pattern: "^[A-Za-z0-9+/]+={0,2}$",
2961
+ description: "the prepared transaction (base64 protobuf) the hash is over. Never logged"
2962
+ },
2963
+ hashingSchemeVersion: {
2964
+ type: "string",
2965
+ pattern: "^HASHING_SCHEME_VERSION_V[0-9]+$",
2966
+ description: "the participant's prepared-transaction hashing scheme the hash was computed with"
2967
+ }
2968
+ }
2969
+ },
2970
+ cantonLegTopology: {
2971
+ type: "object",
2972
+ description: "The onboarding topology of the filler's party, in `party.allocate` only (a topology leg in any other op is refused by the schema). MUST before signing (protocol \xA73.19): the node recomputes the multihash over `topologyTransactions` and checks that they create the party of `summary.partyId` with the key of `summary.publicKey` as its only signing key, hosted on the Cancore participant; on any difference it does not sign. It signs the 34 multihash bytes with its party key",
2973
+ required: ["legId", "kind", "hash", "topologyTransactions"],
2974
+ properties: {
2975
+ legId: { type: "string", minLength: 1, maxLength: 128 },
2976
+ kind: { const: "topology" },
2977
+ hash: { type: "string", pattern: "^0x1220[0-9a-f]{64}$", description: "the topology multihash: 0x1220 \u2016 sha256" },
2978
+ topologyTransactions: {
2979
+ type: "array",
2980
+ minItems: 1,
2981
+ items: { type: "string", minLength: 1, pattern: "^[A-Za-z0-9+/]+={0,2}$" },
2982
+ description: "the topology transactions (base64 protobuf) the multihash is over, in order"
2983
+ }
2984
+ }
2985
+ },
2986
+ cantonSignature: {
2987
+ type: "object",
2988
+ required: ["legId", "signature"],
2989
+ properties: { legId: { type: "string", minLength: 1, maxLength: 128 }, signature: { $ref: "#/$defs/edSignature" } }
2990
+ },
2991
+ "canton.prepare": {
2992
+ "x-direction": "F2S",
2993
+ type: "object",
2994
+ description: "Prepare a Canton operation of the sender's own party (\xA73.19); answered by canton.prepared (re = this id) or error. params select the operation only: the backend picks every contract itself (holdings, delivery order, intent, registry entry, disclosed contracts, attestor signatures). Admission: party.allocate \u2014 the fillerId has no party yet, or this key's party; registry.accept \u2014 a proposal for the fillerId and its party is live; delivery.fill \u2014 an ISSUED Canton ticket of this filler for (orderHash, attempt), before validUntil; intent.settle \u2014 a Canton-source order this filler delivered, with attestations held; holdings.transfer \u2014 enough unlocked holdings of the asset beyond what the party's open delivery orders need, to a party other than its own. Each prepare prepares afresh and replaces the filler's open operation of the same op and target",
2995
+ allOf: [
2996
+ { $ref: "#/$defs/f2sBase" },
2997
+ {
2998
+ if: { type: "object", properties: { op: { const: "party.allocate" } }, required: ["op"] },
2999
+ then: {
3000
+ type: "object",
3001
+ required: ["params"],
3002
+ properties: { params: { type: "object", required: ["publicKey"], properties: { publicKey: { $ref: "#/$defs/edPublicKey" } } } }
3003
+ }
3004
+ },
3005
+ {
3006
+ if: { type: "object", properties: { op: { const: "registry.accept" } }, required: ["op"] },
3007
+ then: { type: "object", required: ["params"], properties: { params: { type: "object" } } }
3008
+ },
3009
+ {
3010
+ if: { type: "object", properties: { op: { const: "delivery.fill" } }, required: ["op"] },
3011
+ then: {
3012
+ type: "object",
3013
+ required: ["params"],
3014
+ properties: {
3015
+ params: {
3016
+ type: "object",
3017
+ required: ["orderHash", "attempt"],
3018
+ properties: { orderHash: { $ref: "#/$defs/bytes32" }, attempt: { $ref: "#/$defs/uint32" } }
3019
+ }
3020
+ }
3021
+ }
3022
+ },
3023
+ {
3024
+ if: { type: "object", properties: { op: { const: "intent.settle" } }, required: ["op"] },
3025
+ then: {
3026
+ type: "object",
3027
+ required: ["params"],
3028
+ properties: { params: { type: "object", required: ["orderHash"], properties: { orderHash: { $ref: "#/$defs/bytes32" } } } }
3029
+ }
3030
+ },
3031
+ {
3032
+ if: { type: "object", properties: { op: { const: "holdings.transfer" } }, required: ["op"] },
3033
+ then: {
3034
+ type: "object",
3035
+ required: ["params"],
3036
+ properties: {
3037
+ params: {
3038
+ type: "object",
3039
+ required: ["asset", "amount", "toParty"],
3040
+ properties: {
3041
+ asset: { $ref: "#/$defs/cantonAsset" },
3042
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", description: "Daml Decimal, > 0" },
3043
+ toParty: { type: "string", minLength: 1, maxLength: 255, description: "the receiving Canton party; never the filler's own" }
3044
+ }
3045
+ }
3046
+ }
3047
+ }
3048
+ }
3049
+ ],
3050
+ required: ["type", "op", "params"],
3051
+ properties: { type: { const: "canton.prepare" }, op: { $ref: "#/$defs/cantonOp" }, params: { type: "object" } }
3052
+ },
3053
+ "canton.prepared": {
3054
+ "x-direction": "S2F",
3055
+ type: "object",
3056
+ description: "A prepared operation. The node MUST verify every leg before it signs it (cantonLegTransaction, cantonLegTopology): what it signs is what Cancore assembled, and summary is only what Cancore says about it \u2014 a leg that does not match summary, or summary that does not match what the node expects of the op, is not signed. Topology legs come with party.allocate only; every other op prepares transactions. Then the node signs every leg's hash with its party key and sends canton.submit before expiresAt. An operationId stays valid until its own expiresAt whatever is prepared after it",
3057
+ allOf: [
3058
+ { $ref: "#/$defs/s2fBase" },
3059
+ {
3060
+ if: { type: "object", properties: { op: { const: "party.allocate" } }, required: ["op"] },
3061
+ then: { type: "object", properties: { legs: { type: "array", items: { $ref: "#/$defs/cantonLegTopology" } } } },
3062
+ else: { type: "object", properties: { legs: { type: "array", items: { $ref: "#/$defs/cantonLegTransaction" } } } }
3063
+ },
3064
+ {
3065
+ if: { type: "object", properties: { op: { const: "party.allocate" } }, required: ["op"] },
3066
+ then: {
3067
+ type: "object",
3068
+ required: ["summary"],
3069
+ properties: {
3070
+ summary: {
3071
+ type: "object",
3072
+ required: ["partyId", "publicKey", "hosting"],
3073
+ properties: {
3074
+ partyId: { type: "string", minLength: 1 },
3075
+ publicKey: { $ref: "#/$defs/edPublicKey" },
3076
+ hosting: {
3077
+ type: "object",
3078
+ required: ["participantUid", "permission", "threshold"],
3079
+ description: "how the topology hosts the party: on the Cancore participant alone, with Confirmation permission, threshold 1 \u2014 the node checks the decoded topology against it",
3080
+ properties: { participantUid: { type: "string", minLength: 1 }, permission: { const: "CONFIRMATION" }, threshold: { const: 1 } }
3081
+ }
3082
+ }
3083
+ }
3084
+ }
3085
+ }
3086
+ },
3087
+ {
3088
+ if: { type: "object", properties: { op: { const: "registry.accept" } }, required: ["op"] },
3089
+ then: {
3090
+ type: "object",
3091
+ required: ["summary"],
3092
+ properties: {
3093
+ summary: {
3094
+ type: "object",
3095
+ required: ["fillerId", "party", "operator", "proposalCid"],
3096
+ properties: {
3097
+ fillerId: { $ref: "#/$defs/fillerId" },
3098
+ party: { type: "string", minLength: 1 },
3099
+ operator: { type: "string", minLength: 1 },
3100
+ proposalCid: { type: "string", minLength: 1 }
3101
+ }
3102
+ }
3103
+ }
3104
+ }
3105
+ },
3106
+ {
3107
+ if: { type: "object", properties: { op: { const: "delivery.fill" } }, required: ["op"] },
3108
+ then: {
3109
+ type: "object",
3110
+ required: ["summary"],
3111
+ properties: {
3112
+ summary: {
3113
+ type: "object",
3114
+ required: [
3115
+ "orderHash",
3116
+ "attempt",
3117
+ "deliveryOrderCid",
3118
+ "recipient",
3119
+ "asset",
3120
+ "amount",
3121
+ "repayTo",
3122
+ "validUntil",
3123
+ "inputHoldingCids",
3124
+ "executeBefore",
3125
+ "transferFactoryCid"
3126
+ ],
3127
+ properties: {
3128
+ orderHash: { $ref: "#/$defs/bytes32" },
3129
+ attempt: { $ref: "#/$defs/uint32" },
3130
+ deliveryOrderCid: { type: "string", minLength: 1 },
3131
+ recipient: { type: "string", minLength: 1, description: "the Canton party the order delivers to" },
3132
+ asset: { $ref: "#/$defs/cantonAsset" },
3133
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", description: "DeliveryOrder.amount, Daml Decimal" },
3134
+ repayTo: { $ref: "#/$defs/repayTo" },
3135
+ validUntil: { $ref: "#/$defs/timeS" },
3136
+ inputHoldingCids: {
3137
+ type: "array",
3138
+ minItems: 1,
3139
+ items: { type: "string", minLength: 1 },
3140
+ description: "the party's holdings the transfer spends; whatever they hold beyond amount comes back as change"
3141
+ },
3142
+ executeBefore: { $ref: "#/$defs/timeS", description: "the transfer's executeBefore: the order's fillDeadline" },
3143
+ transferFactoryCid: { type: "string", minLength: 1, description: "the registry factory the order pins" }
3144
+ }
3145
+ }
3146
+ }
3147
+ }
3148
+ },
3149
+ {
3150
+ if: { type: "object", properties: { op: { const: "intent.settle" } }, required: ["op"] },
3151
+ then: {
3152
+ type: "object",
3153
+ required: ["summary"],
3154
+ properties: {
3155
+ summary: {
3156
+ type: "object",
3157
+ required: ["orderHash", "intentCid", "asset", "amount", "executeBefore", "payee", "giveAmount", "fee"],
3158
+ properties: {
3159
+ orderHash: { $ref: "#/$defs/bytes32" },
3160
+ intentCid: { type: "string", minLength: 1 },
3161
+ asset: { $ref: "#/$defs/cantonAsset" },
3162
+ amount: {
3163
+ type: "string",
3164
+ pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$",
3165
+ description: "what the settlement pays the payee: giveAmount less fee.amount, Daml Decimal"
3166
+ },
3167
+ executeBefore: { $ref: "#/$defs/timeS" },
3168
+ payee: { type: "string", minLength: 1, description: "the party paid: the filler's own" },
3169
+ giveAmount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", description: "the intent's committed give, fee-inclusive" },
3170
+ fee: {
3171
+ type: "object",
3172
+ required: ["receiver", "amount"],
3173
+ properties: {
3174
+ receiver: { type: "string", minLength: 1, description: "the operator party" },
3175
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$" }
3176
+ },
3177
+ description: "the settlement's fee leg; amount 0 when there is none"
3178
+ }
3179
+ }
3180
+ }
3181
+ }
3182
+ }
3183
+ },
3184
+ {
3185
+ if: { type: "object", properties: { op: { const: "holdings.transfer" } }, required: ["op"] },
3186
+ then: {
3187
+ type: "object",
3188
+ required: ["summary"],
3189
+ properties: {
3190
+ summary: {
3191
+ type: "object",
3192
+ required: ["asset", "amount", "receiver", "inputHoldingCids", "executeBefore"],
3193
+ properties: {
3194
+ asset: { $ref: "#/$defs/cantonAsset" },
3195
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$" },
3196
+ receiver: { type: "string", minLength: 1 },
3197
+ inputHoldingCids: {
3198
+ type: "array",
3199
+ minItems: 1,
3200
+ items: { type: "string", minLength: 1 },
3201
+ description: "the party's holdings the transfer spends; what they hold beyond amount comes back as change"
3202
+ },
3203
+ executeBefore: { $ref: "#/$defs/timeS" }
3204
+ }
3205
+ }
3206
+ }
3207
+ }
3208
+ }
3209
+ ],
3210
+ required: ["type", "re", "operationId", "op", "legs", "summary", "expiresAt"],
3211
+ properties: {
3212
+ type: { const: "canton.prepared" },
3213
+ re: { $ref: "#/$defs/messageId" },
3214
+ operationId: { $ref: "#/$defs/operationId" },
3215
+ op: { $ref: "#/$defs/cantonOp" },
3216
+ legs: { type: "array", minItems: 1 },
3217
+ summary: { type: "object" },
3218
+ expiresAt: { $ref: "#/$defs/timeMs" }
3219
+ }
3220
+ },
3221
+ "canton.submit": {
3222
+ "x-direction": "F2S",
3223
+ type: "object",
3224
+ description: "Submit a prepared operation: one party-key signature per leg. Idempotent per operationId: a repeat (after a lost answer or CANTON_UNAVAILABLE) is answered with the same canton.submitted and never executes twice. OPERATION_EXPIRED: prepare again",
3225
+ allOf: [{ $ref: "#/$defs/f2sBase" }],
3226
+ required: ["type", "operationId", "signatures"],
3227
+ properties: {
3228
+ type: { const: "canton.submit" },
3229
+ operationId: { $ref: "#/$defs/operationId" },
3230
+ signatures: { type: "array", minItems: 1, items: { $ref: "#/$defs/cantonSignature" } }
3231
+ }
3232
+ },
3233
+ "canton.submitted": {
3234
+ "x-direction": "S2F",
3235
+ type: "object",
3236
+ description: "The operation committed. updateId is its Canton update (absent for party.allocate, a topology change); result names what it created, by op",
3237
+ allOf: [
3238
+ { $ref: "#/$defs/s2fBase" },
3239
+ {
3240
+ if: { type: "object", properties: { op: { const: "party.allocate" } }, required: ["op"] },
3241
+ then: {
3242
+ type: "object",
3243
+ required: ["result"],
3244
+ properties: { result: { type: "object", required: ["partyId"], properties: { partyId: { type: "string", minLength: 1 } } } }
3245
+ }
3246
+ },
3247
+ {
3248
+ if: { type: "object", properties: { op: { const: "registry.accept" } }, required: ["op"] },
3249
+ then: {
3250
+ type: "object",
3251
+ required: ["result"],
3252
+ properties: { result: { type: "object", required: ["entryCid"], properties: { entryCid: { type: "string", minLength: 1 } } } }
3253
+ }
3254
+ },
3255
+ {
3256
+ if: { type: "object", properties: { op: { const: "delivery.fill" } }, required: ["op"] },
3257
+ then: {
3258
+ type: "object",
3259
+ required: ["result"],
3260
+ properties: { result: { type: "object", required: ["receiptCid"], properties: { receiptCid: { type: "string", minLength: 1 } } } }
3261
+ }
3262
+ },
3263
+ {
3264
+ if: { type: "object", properties: { op: { const: "intent.settle" } }, required: ["op"] },
3265
+ then: { type: "object", required: ["result"], properties: { result: { type: "object" } } }
3266
+ },
3267
+ {
3268
+ if: { type: "object", properties: { op: { const: "holdings.transfer" } }, required: ["op"] },
3269
+ then: {
3270
+ type: "object",
3271
+ required: ["result"],
3272
+ properties: {
3273
+ result: {
3274
+ type: "object",
3275
+ required: ["outcome"],
3276
+ properties: {
3277
+ outcome: {
3278
+ anyOf: [{ enum: ["COMPLETED", "PENDING"] }, { $ref: "#/$defs/futureEnumValue" }],
3279
+ description: "COMPLETED: the receiver holds it (a preapproval accepted it); PENDING: a TransferInstruction waits for the receiver to accept"
3280
+ },
3281
+ transferInstructionCid: { type: "string", minLength: 1, description: "with PENDING" }
3282
+ }
3283
+ }
3284
+ }
3285
+ }
3286
+ }
3287
+ ],
3288
+ required: ["type", "re", "operationId", "op", "result"],
3289
+ properties: {
3290
+ type: { const: "canton.submitted" },
3291
+ re: { $ref: "#/$defs/messageId" },
3292
+ operationId: { $ref: "#/$defs/operationId" },
3293
+ op: { $ref: "#/$defs/cantonOp" },
3294
+ updateId: { type: "string", minLength: 1 },
3295
+ result: { type: "object" }
3296
+ }
3297
+ }
3298
+ }
3299
+ };
3300
+
3301
+ // spec/protocol/records.schema.json
3302
+ var records_schema_default = {
3303
+ $schema: "https://json-schema.org/draft/2020-12/schema",
3304
+ $id: "https://cancore.io/schemas/filler-protocol/v1/records.schema.json",
3305
+ title: "Cancore filler protocol v1 \u2014 public records",
3306
+ $comment: "The draw record (GET /v1/draws/{orderHash}), the epoch record (GET /v1/draws/epochs/{id}) \u2014 auction-and-draw \xA73.3\u20133.4 \u2014 and the gateway identity (GET /v1/gateway). Records are signed by the gateway like an S\u2192F frame (sig over GatewayMessage{keccak256(JCS(record without sig))}) but are public: no fillerId, no sentAt.",
3307
+ $defs: {
3308
+ drawCandidate: {
3309
+ type: "object",
3310
+ required: ["fillerId", "weight"],
3311
+ properties: { fillerId: { $ref: "messages.schema.json#/$defs/fillerId" }, weight: { $ref: "messages.schema.json#/$defs/uintDec256" } }
3312
+ },
3313
+ drawAttempt: {
3314
+ type: "object",
3315
+ required: ["attempt", "tBase", "closedBy", "drandRound", "drandRandomness", "drandSignature", "candidates", "r", "winnerFillerId", "fallbackReason"],
3316
+ properties: {
3317
+ attempt: { $ref: "messages.schema.json#/$defs/uint32" },
3318
+ tBase: { $ref: "messages.schema.json#/$defs/timeS" },
3319
+ closedBy: { anyOf: [{ enum: ["OFFER_TIMEOUT", "OFFER_DECLINE", "TICKET_DECLINE", "TICKET_EXPIRED", "FILLED", null] }, { $ref: "messages.schema.json#/$defs/futureEnumValue" }] },
3320
+ drandRound: { $ref: "messages.schema.json#/$defs/uintDec64" },
3321
+ drandRandomness: { $ref: "messages.schema.json#/$defs/bytes32" },
3322
+ drandSignature: { type: "string", pattern: "^0x[0-9a-f]{96}$", description: "BLS signature of the round, 48 bytes (G1)" },
3323
+ candidates: { type: "array", items: { $ref: "#/$defs/drawCandidate" }, description: "ascending by the UTF-8 bytes of fillerId (A-22)" },
3324
+ r: { $ref: "messages.schema.json#/$defs/uintDec256" },
3325
+ winnerFillerId: { $ref: "messages.schema.json#/$defs/fillerId" },
3326
+ fallbackReason: { anyOf: [{ enum: ["DRAW_FALLBACK", null] }, { $ref: "messages.schema.json#/$defs/futureEnumValue" }] }
3327
+ }
3328
+ },
3329
+ drawRecord: {
3330
+ type: "object",
3331
+ required: ["orderHash", "source", "openRef", "t0", "epochId", "deltaDrand", "attempts", "sig"],
3332
+ properties: {
3333
+ orderHash: { $ref: "messages.schema.json#/$defs/bytes32" },
3334
+ source: { $ref: "messages.schema.json#/$defs/caip2" },
3335
+ openRef: { type: "string", minLength: 1, description: "EVM: open tx hash; Canton: Execute update id" },
3336
+ t0: { $ref: "messages.schema.json#/$defs/timeS" },
3337
+ epochId: { $ref: "messages.schema.json#/$defs/uintDec64" },
3338
+ deltaDrand: { $ref: "messages.schema.json#/$defs/uint32", description: "seconds" },
3339
+ attempts: { type: "array", items: { $ref: "#/$defs/drawAttempt" } },
3340
+ sig: { $ref: "messages.schema.json#/$defs/sig65" }
3341
+ }
3342
+ },
3343
+ epochLeaf: {
3344
+ type: "object",
3345
+ description: 'StandardMerkleTree leaf ["string", "uint256", "uint8", "uint16"] = (fillerId, base, tier, reliabilityBps)',
3346
+ required: ["fillerId", "base", "tier", "reliabilityBps"],
3347
+ properties: {
3348
+ fillerId: { $ref: "messages.schema.json#/$defs/fillerId" },
3349
+ base: { $ref: "messages.schema.json#/$defs/uintDec256" },
3350
+ tier: { $ref: "messages.schema.json#/$defs/uint8" },
3351
+ reliabilityBps: { type: "integer", minimum: 0, maximum: 1e4 }
3352
+ }
3353
+ },
3354
+ stakeStep: {
3355
+ type: "object",
3356
+ required: ["tier", "minStake", "step"],
3357
+ properties: {
3358
+ tier: { $ref: "messages.schema.json#/$defs/uint8" },
3359
+ minStake: { $ref: "messages.schema.json#/$defs/uintDec256" },
3360
+ step: { $ref: "messages.schema.json#/$defs/uintDec256" }
3361
+ }
3362
+ },
3363
+ epochRecord: {
3364
+ type: "object",
3365
+ required: ["epochId", "startsAt", "endsAt", "weightsRoot", "leaves", "stakeSteps", "rMinBps", "snapshotBlocks", "sig"],
3366
+ properties: {
3367
+ epochId: { $ref: "messages.schema.json#/$defs/uintDec64" },
3368
+ startsAt: { $ref: "messages.schema.json#/$defs/timeS" },
3369
+ endsAt: { $ref: "messages.schema.json#/$defs/timeS" },
3370
+ weightsRoot: { $ref: "messages.schema.json#/$defs/bytes32" },
3371
+ leaves: { type: "array", items: { $ref: "#/$defs/epochLeaf" } },
3372
+ stakeSteps: { type: "array", items: { $ref: "#/$defs/stakeStep" } },
3373
+ rMinBps: { type: "integer", minimum: 0, maximum: 1e4 },
3374
+ snapshotBlocks: {
3375
+ type: "object",
3376
+ propertyNames: { $ref: "messages.schema.json#/$defs/caip2" },
3377
+ additionalProperties: { $ref: "messages.schema.json#/$defs/uintDec64" }
3378
+ },
3379
+ sig: { $ref: "messages.schema.json#/$defs/sig65" }
3380
+ }
3381
+ },
3382
+ gatewayInfo: {
3383
+ type: "object",
3384
+ description: "GET /v1/gateway: the mirror of @cancore/contracts FILLER_GATEWAYS for this environment. A taker trusts the package, and uses this to notice a rotation",
3385
+ required: ["env", "gateway", "ticketSigners", "protocolVersion", "maxMessageAgeMs"],
3386
+ properties: {
3387
+ env: { type: "string", minLength: 1 },
3388
+ gateway: { $ref: "messages.schema.json#/$defs/address" },
3389
+ ticketSigners: { type: "array", items: { $ref: "messages.schema.json#/$defs/address" } },
3390
+ protocolVersion: { $ref: "messages.schema.json#/$defs/protocolVersion" },
3391
+ maxMessageAgeMs: { $ref: "messages.schema.json#/$defs/durationMs", description: "freshness bound of \xA73.4 in both directions: |receivedAt \u2212 sentAt| \u2264 maxMessageAgeMs, and a message id is not reused within it" }
3392
+ }
3393
+ }
3394
+ }
3395
+ };
3396
+
3397
+ // spec/protocol/rest.schema.json
3398
+ var rest_schema_default = {
3399
+ $schema: "https://json-schema.org/draft/2020-12/schema",
3400
+ $id: "https://cancore.io/schemas/filler-protocol/v1/rest.schema.json",
3401
+ title: "Cancore filler protocol v1 \u2014 REST fallback",
3402
+ $comment: "protocol \xA73.6. Bodies are the WebSocket frames: every request body is a filler message with its envelope (id, fillerId, sentAt) and msgSig, verified before processing as on the WebSocket (S-19); every response is a freshly signed S\u2192F message. Login: GET /v1/filler/auth/challenge?fillerId= returns a signed auth.challenge addressed to that fillerId; POST /v1/filler/auth with the auth.response (FillerAuth over it) returns {token, expiresAt}. The challenge route is anonymous and its refusals are UNSIGNED (unsignedErrorBody, no sig, nothing journalled): 400 BAD_REQUEST \u2014 fillerId missing or not a fillerId; 404 UNKNOWN_REQUEST \u2014 fillerId unknown or not ACTIVE; the anonymous login steps are charged to no fillerId's rate limits (knowing a fillerId cannot lock its filler out); a 429 here comes only from the per-IP limit in front of filler-gateway. POST /v1/filler/auth refuses UNSIGNED too as long as it has checked no signature: 400 BAD_REQUEST \u2014 no or a malformed fillerId; 404 UNKNOWN_REQUEST \u2014 fillerId unknown or not ACTIVE; 401 UNAUTHENTICATED \u2014 the fillerId holds no live challenge (evicted, expired or used: ask for a new one). Its refusals after the signature checks (BAD_SIGNATURE, STALE_MESSAGE, REPLAYED_MESSAGE, UNSUPPORTED_VERSION, NOT_ELIGIBLE, UNAUTHENTICATED) are the signed error. The other /v1/filler/* routes need `Authorization: Bearer <token>`; the token is bound to (fillerId, message key) and stops working when it expires, when the message key is changed, or when the filler is no longer ACTIVE. The same token opens the WebSocket (asyncapi.json: offered as the subprotocol bearer.<token>). A ticket of another filler is 404 UNKNOWN_TICKET. Rate limits are per fillerId and rate class (quote, ticket, service, read for every bearer GET, login, cantonPrepare for canton.prepare of \xA73.19 \u2014 an hourly budget per filler, 60 by default \u2014 and canton for canton.submit, so a spent prepare budget never holds back the submit of an operation already prepared), shared by REST and every WebSocket session of it: over the limit a bearer route answers 429 with an UNSIGNED unsignedErrorBody {type: error, code: RATE_LIMITED, message, retryAfterMs} and a Retry-After header (seconds, rounded up), journals nothing one by one, and the request changes nothing; during the cooldown after sustained excess every bearer route answers so. Every 429 is unsigned, on every route; a filler decides by the status and takes retryAfterMs (else Retry-After) as a hint. Every other non-2xx of a bearer route is the signed error. GET /v1/filler/attestations/{orderHash} answers 404 ATTESTATIONS_NOT_READY until the gateway holds \u2265 threshold verified signatures for this filler's fill, and 404 UNKNOWN_TICKET when this filler holds no ticket on the order. /v1/filler/canton/* (\xA73.19) serve only the caller's own party: POST prepare and submit take the canton.prepare and canton.submit messages and answer canton.prepared and canton.submitted (the same frames as on the WebSocket); GET party, holdings and delivery-orders read the party registered for the fillerId, and answer 409 CANTON_NOT_READY while it has none. /v1/draws/* and /v1/gateway are public. Every non-2xx body is the signed `error` frame, with the HTTP status of x-error-status \u2014 except a 429 (always unsignedErrorBody) and the unsigned refusals of an endpoint that names an errorBody. x-endpoints: request/query/response/errorBody name a $def here or in messages.schema.json.",
3403
+ "x-endpoints": [
3404
+ { method: "GET", path: "/v1/filler/auth/challenge", auth: "none", query: "#/$defs/challengeQuery", response: "messages.schema.json#/$defs/auth.challenge", errorBody: "#/$defs/unsignedErrorBody" },
3405
+ { method: "POST", path: "/v1/filler/auth", auth: "none", request: "messages.schema.json#/$defs/auth.response", response: "#/$defs/authToken", errorBody: "#/$defs/unsignedErrorBody" },
3406
+ { method: "GET", path: "/v1/filler/tickets", auth: "bearer", query: "#/$defs/ticketListQuery", response: "#/$defs/ticketList" },
3407
+ { method: "POST", path: "/v1/filler/tickets/{orderHash}/{attempt}/intent", auth: "bearer", request: "messages.schema.json#/$defs/ticket.intent", response: "messages.schema.json#/$defs/ticket.intent.ack" },
3408
+ { method: "POST", path: "/v1/filler/tickets/{orderHash}/{attempt}/receipt", auth: "bearer", request: "messages.schema.json#/$defs/ticket.receipt", response: "#/$defs/empty" },
3409
+ { method: "POST", path: "/v1/filler/tickets/{orderHash}/{attempt}/decline", auth: "bearer", request: "messages.schema.json#/$defs/ticket.decline", response: "#/$defs/empty" },
3410
+ { method: "POST", path: "/v1/filler/stake-bindings", auth: "bearer", request: "#/$defs/stakeBindingRequest", response: "#/$defs/empty" },
3411
+ { method: "GET", path: "/v1/filler/quotes", auth: "bearer", query: "#/$defs/quoteListQuery", response: "#/$defs/quoteList" },
3412
+ { method: "GET", path: "/v1/filler/stats", auth: "bearer", response: "#/$defs/fillerStats" },
3413
+ { method: "GET", path: "/v1/filler/penalties", auth: "bearer", query: "#/$defs/pageQuery", response: "#/$defs/penaltyList" },
3414
+ { method: "GET", path: "/v1/filler/attestations/{orderHash}", auth: "bearer", response: "messages.schema.json#/$defs/settle.attestations" },
3415
+ { method: "GET", path: "/v1/draws/{orderHash}", auth: "none", response: "records.schema.json#/$defs/drawRecord" },
3416
+ { method: "GET", path: "/v1/draws/epochs/{id}", auth: "none", response: "records.schema.json#/$defs/epochRecord" },
3417
+ { method: "GET", path: "/v1/gateway", auth: "none", response: "records.schema.json#/$defs/gatewayInfo" },
3418
+ { method: "POST", path: "/v1/filler/canton/prepare", auth: "bearer", request: "messages.schema.json#/$defs/canton.prepare", response: "messages.schema.json#/$defs/canton.prepared" },
3419
+ { method: "POST", path: "/v1/filler/canton/submit", auth: "bearer", request: "messages.schema.json#/$defs/canton.submit", response: "messages.schema.json#/$defs/canton.submitted" },
3420
+ { method: "GET", path: "/v1/filler/canton/party", auth: "bearer", response: "#/$defs/cantonParty" },
3421
+ { method: "GET", path: "/v1/filler/canton/holdings", auth: "bearer", query: "#/$defs/pageQuery", response: "#/$defs/cantonHoldingList" },
3422
+ { method: "GET", path: "/v1/filler/canton/delivery-orders", auth: "bearer", query: "#/$defs/pageQuery", response: "#/$defs/cantonDeliveryOrderList" }
3423
+ ],
3424
+ "x-error-status": {
3425
+ BAD_REQUEST: 400,
3426
+ UNAUTHENTICATED: 401,
3427
+ UNSUPPORTED_VERSION: 400,
3428
+ UNSUPPORTED_TYPE: 400,
3429
+ BAD_SIGNATURE: 422,
3430
+ STALE_MESSAGE: 400,
3431
+ REPLAYED_MESSAGE: 409,
3432
+ TICKET_REFUSED: 409,
3433
+ UNKNOWN_REQUEST: 404,
3434
+ UNKNOWN_TICKET: 404,
3435
+ TICKET_CLOSED: 409,
3436
+ NOT_ELIGIBLE: 403,
3437
+ RATE_LIMITED: 429,
3438
+ INTERNAL: 500,
3439
+ ATTESTATIONS_NOT_READY: 404,
3440
+ CANTON_NOT_READY: 409,
3441
+ CANTON_REFUSED: 422,
3442
+ CANTON_UNAVAILABLE: 503,
3443
+ OPERATION_EXPIRED: 410
3444
+ },
3445
+ $defs: {
3446
+ errorBody: { $ref: "messages.schema.json#/$defs/errorS2F" },
3447
+ unsignedErrorBody: {
3448
+ type: "object",
3449
+ description: "An unsigned refusal: every 429, and the refusals of the login routes decided before any signature check. Not signed, not addressed, nothing journalled; a filler cannot verify it and treats it as a hint only (status, code, retryAfterMs)",
3450
+ required: ["type", "code", "message"],
3451
+ properties: {
3452
+ type: { const: "error" },
3453
+ code: { $ref: "messages.schema.json#/$defs/errorCode" },
3454
+ message: { type: "string" },
3455
+ retryAfterMs: { $ref: "messages.schema.json#/$defs/durationMs", type: "integer", minimum: 1, description: "with RATE_LIMITED (429): ms until the rate class may be used again" }
3456
+ }
3457
+ },
3458
+ challengeQuery: {
3459
+ type: "object",
3460
+ required: ["fillerId"],
3461
+ properties: { fillerId: { $ref: "messages.schema.json#/$defs/fillerId", description: "the filler logging in; the challenge is addressed to it and answerable only by it" } }
3462
+ },
3463
+ empty: { type: "object", description: "no fields in v1; receivers ignore unknown ones (V-2)" },
3464
+ authToken: {
3465
+ type: "object",
3466
+ required: ["token", "expiresAt"],
3467
+ properties: { token: { type: "string", minLength: 1 }, expiresAt: { $ref: "messages.schema.json#/$defs/timeMs" } }
3468
+ },
3469
+ pageQuery: {
3470
+ type: "object",
3471
+ properties: { cursor: { type: "string", minLength: 1 }, limit: { type: "string", pattern: "^([1-9][0-9]?|100)$", description: "1..100, default 50" } }
3472
+ },
3473
+ ticketListQuery: {
3474
+ allOf: [{ $ref: "#/$defs/pageQuery" }],
3475
+ type: "object",
3476
+ properties: { status: { enum: ["OFFERED", "ISSUED"], description: "a request filter: the gateway owns the list, so it is closed" } }
3477
+ },
3478
+ quoteListQuery: {
3479
+ allOf: [{ $ref: "#/$defs/pageQuery" }],
3480
+ type: "object",
3481
+ properties: { since: { type: "string", pattern: "^(0|[1-9][0-9]*)$", description: "unix ms" } }
3482
+ },
3483
+ ticketList: {
3484
+ type: "object",
3485
+ required: ["items", "nextCursor"],
3486
+ properties: {
3487
+ items: {
3488
+ type: "array",
3489
+ items: { oneOf: [{ $ref: "messages.schema.json#/$defs/ticket.offer" }, { $ref: "messages.schema.json#/$defs/ticket.issued" }] }
3490
+ },
3491
+ nextCursor: { type: ["string", "null"] }
3492
+ }
3493
+ },
3494
+ stakeBindingRequest: {
3495
+ type: "object",
3496
+ description: "sig = StakeBinding{partnerId, stakingAddress, chainId, nonce} by the staking address; the body carries the filler envelope and msgSig like every request body",
3497
+ allOf: [{ $ref: "messages.schema.json#/$defs/f2sEnvelope" }],
3498
+ required: ["partnerId", "stakingAddress", "chainId", "nonce", "sig"],
3499
+ properties: {
3500
+ partnerId: { $ref: "messages.schema.json#/$defs/fillerId" },
3501
+ stakingAddress: { $ref: "messages.schema.json#/$defs/address" },
3502
+ chainId: { $ref: "messages.schema.json#/$defs/uintDec256" },
3503
+ nonce: { $ref: "messages.schema.json#/$defs/uintDec64" },
3504
+ sig: { $ref: "messages.schema.json#/$defs/sig65" }
3505
+ }
3506
+ },
3507
+ quoteRecord: {
3508
+ type: "object",
3509
+ required: ["quote", "ack", "status"],
3510
+ properties: {
3511
+ quote: { $ref: "messages.schema.json#/$defs/quote" },
3512
+ ack: { $ref: "messages.schema.json#/$defs/quote.ack" },
3513
+ status: { anyOf: [{ enum: ["COUNTED", "LATE", "SHORT_TTL", "REPLACED", "BAD_SIG", "OUTLIER", "IN_BAND", "OUT_OF_BAND", "WON", "LOST"] }, { $ref: "messages.schema.json#/$defs/futureEnumValue" }] }
3514
+ }
3515
+ },
3516
+ quoteList: {
3517
+ type: "object",
3518
+ required: ["items", "nextCursor"],
3519
+ properties: { items: { type: "array", items: { $ref: "#/$defs/quoteRecord" } }, nextCursor: { type: ["string", "null"] } }
3520
+ },
3521
+ fillerStats: {
3522
+ type: "object",
3523
+ required: ["won", "delivered", "noShow", "reliability", "capacityUsd", "inFlightUsd"],
3524
+ properties: {
3525
+ won: { type: "integer", minimum: 0 },
3526
+ delivered: { type: "integer", minimum: 0 },
3527
+ noShow: { type: "integer", minimum: 0 },
3528
+ reliability: { type: "integer", minimum: 0, maximum: 1e4, description: "basis points" },
3529
+ capacityUsd: { $ref: "messages.schema.json#/$defs/intDecUsd" },
3530
+ inFlightUsd: { $ref: "messages.schema.json#/$defs/intDecUsd" }
3531
+ }
3532
+ },
3533
+ penaltyRecord: {
3534
+ type: "object",
3535
+ required: ["violationId", "code", "step", "at", "details"],
3536
+ properties: {
3537
+ violationId: { type: "string", minLength: 1 },
3538
+ code: { type: "string", minLength: 1 },
3539
+ step: { $ref: "messages.schema.json#/$defs/penaltyStep" },
3540
+ orderHash: { $ref: "messages.schema.json#/$defs/bytes32" },
3541
+ attempt: { $ref: "messages.schema.json#/$defs/uint32" },
3542
+ at: { $ref: "messages.schema.json#/$defs/timeMs" },
3543
+ details: { type: "object" }
3544
+ }
3545
+ },
3546
+ penaltyList: {
3547
+ type: "object",
3548
+ required: ["items", "nextCursor"],
3549
+ properties: { items: { type: "array", items: { $ref: "#/$defs/penaltyRecord" } }, nextCursor: { type: ["string", "null"] } }
3550
+ },
3551
+ cantonParty: {
3552
+ type: "object",
3553
+ description: "The filler's Canton party and its FillerRegistryEntry with the operator. party null: none allocated or registered yet (party.allocate). registry.state NONE: no proposal yet; PROPOSED: accept it (registry.accept); ACTIVE: the Canton routes may be activated; REMOVED: staff removed the entry",
3554
+ required: ["party", "publicKey", "registry"],
3555
+ properties: {
3556
+ party: { type: ["string", "null"], minLength: 1 },
3557
+ publicKey: { anyOf: [{ $ref: "messages.schema.json#/$defs/edPublicKey" }, { type: "null" }] },
3558
+ registry: {
3559
+ type: "object",
3560
+ required: ["state", "proposalCid", "entryCid"],
3561
+ properties: {
3562
+ state: { anyOf: [{ enum: ["NONE", "PROPOSED", "ACTIVE", "REMOVED"] }, { $ref: "messages.schema.json#/$defs/futureEnumValue" }] },
3563
+ proposalCid: { type: ["string", "null"] },
3564
+ entryCid: { type: ["string", "null"] }
3565
+ }
3566
+ }
3567
+ }
3568
+ },
3569
+ cantonHolding: {
3570
+ type: "object",
3571
+ required: ["contractId", "asset", "amount", "locked"],
3572
+ properties: {
3573
+ contractId: { type: "string", minLength: 1 },
3574
+ asset: { $ref: "messages.schema.json#/$defs/cantonAsset" },
3575
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", description: "Daml Decimal" },
3576
+ locked: { type: "boolean", description: "held by a lock (an allocation or a pending transfer); not spendable by delivery.fill" }
3577
+ }
3578
+ },
3579
+ cantonHoldingList: {
3580
+ type: "object",
3581
+ description: "Holdings of the party (CNRX and Canton Coin among them), oldest first",
3582
+ required: ["items", "nextCursor"],
3583
+ properties: { items: { type: "array", items: { $ref: "#/$defs/cantonHolding" } }, nextCursor: { type: ["string", "null"] } }
3584
+ },
3585
+ cantonDeliveryOrder: {
3586
+ type: "object",
3587
+ required: ["deliveryOrderCid", "orderHash", "attempt", "asset", "amount", "recipient", "repayTo", "validUntil"],
3588
+ properties: {
3589
+ deliveryOrderCid: { type: "string", minLength: 1 },
3590
+ orderHash: { $ref: "messages.schema.json#/$defs/bytes32" },
3591
+ attempt: { $ref: "messages.schema.json#/$defs/uint32" },
3592
+ asset: { $ref: "messages.schema.json#/$defs/cantonAsset" },
3593
+ amount: { type: "string", pattern: "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", description: "Daml Decimal" },
3594
+ recipient: { type: "string", minLength: 1 },
3595
+ repayTo: { $ref: "messages.schema.json#/$defs/repayTo" },
3596
+ validUntil: { $ref: "messages.schema.json#/$defs/timeS" }
3597
+ }
3598
+ },
3599
+ cantonDeliveryOrderList: {
3600
+ type: "object",
3601
+ description: "The live DeliveryOrders naming the party as filler, oldest first",
3602
+ required: ["items", "nextCursor"],
3603
+ properties: { items: { type: "array", items: { $ref: "#/$defs/cantonDeliveryOrder" } }, nextCursor: { type: ["string", "null"] } }
3604
+ }
3605
+ }
3606
+ };
3607
+
3608
+ // src/protocol/schemas.ts
3609
+ var PROTOCOL_SCHEMAS = { messages: messages_schema_default, rest: rest_schema_default, records: records_schema_default };
3610
+ var ASYNCAPI = asyncapi_default;
3611
+ var SCHEMA_VOCABULARY = ["x-direction", "x-rest-only", "x-endpoints", "x-error-status"];
3612
+ var MESSAGE_DIRECTIONS = Object.fromEntries(
3613
+ Object.entries(messages_schema_default.$defs).filter(([, def]) => def["x-direction"]).map(([type, def]) => [type, def["x-direction"]])
3614
+ );
3615
+ var REST_ONLY_TYPES = Object.entries(messages_schema_default.$defs).filter(([, def]) => def["x-rest-only"] === true).map(([type]) => type);
3616
+ var REST_ENDPOINTS = rest_schema_default["x-endpoints"];
3617
+ function messageSchemaRef(type, direction) {
3618
+ const def = direction && MESSAGE_DIRECTIONS[type] === "both" ? `${type}${direction}` : type;
3619
+ return `${messages_schema_default.$id}#/$defs/${def}`;
3620
+ }
3621
+ var ENVELOPE = /* @__PURE__ */ new Set(["type", "id", "fillerId", "sentAt", "sig", "re"]);
3622
+ function settleAttestationsPayload(frame) {
3623
+ return Object.fromEntries(Object.entries(frame).filter(([k]) => !ENVELOPE.has(k)));
3624
+ }
3625
+ function settleAttestationsPayloadHash(frame) {
3626
+ return toHex(keccak(utf8ToBytes(jcs(settleAttestationsPayload(frame)))));
3627
+ }
3628
+ var isCantonSource = (sourceChainId) => sourceChainId.startsWith("canton:");
3629
+ function settleAttestationsErrors(payload) {
3630
+ const errors = [];
3631
+ if (payload.attempt !== payload.proof.attempt) errors.push(`attempt ${payload.attempt} differs from proof.attempt ${payload.proof.attempt}`);
3632
+ if (payload.setId !== payload.proof.setId) errors.push(`setId ${payload.setId} differs from proof.setId ${payload.proof.setId}`);
3633
+ if (payload.orderHash.toLowerCase() !== payload.proof.orderHash.toLowerCase()) errors.push("orderHash differs from proof.orderHash");
3634
+ if (payload.signatures.length < payload.threshold) errors.push(`${payload.signatures.length} signatures, fewer than threshold ${payload.threshold}`);
3635
+ const signers = payload.signatures.map((s) => s.signer.toLowerCase());
3636
+ for (let i = 1; i < signers.length; i++) {
3637
+ if (signers[i] <= signers[i - 1]) {
3638
+ errors.push(`signers not strictly ascending at index ${i}`);
3639
+ break;
3640
+ }
3641
+ }
3642
+ return errors;
3643
+ }
3644
+ function settleSigs(payload) {
3645
+ if (isCantonSource(payload.sourceChainId)) throw new TypeError(`${payload.sourceChainId} is a Canton source: use cantonSigEntries`);
3646
+ return payload.signatures.map((s) => s.signature);
3647
+ }
3648
+ function cantonSigEntries(payload) {
3649
+ if (!isCantonSource(payload.sourceChainId)) throw new TypeError(`${payload.sourceChainId} is not a Canton source: use settleSigs`);
3650
+ return payload.signatures.map((s) => ({ pubKey: s.pubKey.slice(2).toLowerCase(), sig: s.signature.slice(2).toLowerCase() }));
3651
+ }
50
3652
 
51
3653
  // src/generated/meta.ts
52
3654
  var CONTRACTS_RELEASE = {
53
3655
  "version": "1.4.0-dev",
54
3656
  "releaseChannel": "dev",
55
- "updatedAt": "2026-07-24T19:55:00Z"
3657
+ "updatedAt": "2026-07-24T19:55:00Z",
3658
+ "commit": "4056e83cd84a94d9d00eb4486d5cabf55dd71741"
3659
+ };
3660
+ var BUILD_HASHES = {
3661
+ "HTLC": {
3662
+ "creationHexSha256": "93a991d3a6451f7c3f02dfb70b365a48d29bebccc7f16d8dbe3d56d3dfee0af1",
3663
+ "runtimeHexSha256": "40ab52456c3b5a04365fc1fad837eb79bbe4b85c8dbd990f549468ae48f97e3a",
3664
+ "creationHexLength": 14976,
3665
+ "runtimeHexLength": 14686
3666
+ },
3667
+ "FeeVault": {
3668
+ "creationHexSha256": "1c97d27c8d3e584f879bb57549d75ef10394a56a298eaf4a772516b9316e2248",
3669
+ "runtimeHexSha256": "0631177a64cde0829c2cec8426c08a507564f7d8b084e0237d724ed63faea0e9",
3670
+ "creationHexLength": 13176,
3671
+ "runtimeHexLength": 10968
3672
+ },
3673
+ "MultiBalanceChecker": {
3674
+ "creationHexSha256": "c0a0326694f2a1594e332ba06120692cc98bc06c57d6d8981cb3768e01fad423",
3675
+ "runtimeHexSha256": "93a1f0aa251715cc6a1b6a472f10762463b5c24668886630cbc6da5632e5739b",
3676
+ "creationHexLength": 2456,
3677
+ "runtimeHexLength": 2394
3678
+ },
3679
+ "CancoreRouter": {
3680
+ "creationHexSha256": "361c33f0b5c50625ea1fab280886f9df5f96e6353d8d0d7e9fbce11d64cde5f8",
3681
+ "runtimeHexSha256": "d3374648eaf5bdd0ddfc3ef6a67cd41ffea64b0551b24baded93cf2cb0aca1e0",
3682
+ "creationHexLength": 49814,
3683
+ "runtimeHexLength": 44242
3684
+ },
3685
+ "CNRXStaking": {
3686
+ "creationHexSha256": "dfda056ee22b593e2f2e1fc4e679fbb9dc34b04964f389b46914402c422b40fb",
3687
+ "runtimeHexSha256": "d11534242f166e52f4ad063b5b6b59146e31634d3932f7ad63db05d83a1485f6",
3688
+ "creationHexLength": 7412,
3689
+ "runtimeHexLength": 6240
3690
+ },
3691
+ "PointsClaim": {
3692
+ "creationHexSha256": "0f29890b609f7e15ef4dbcda17a7f2cd7482d016a0057a5f6c4270d7780ff38d",
3693
+ "runtimeHexSha256": "f2b10c4ec8458c0d6ab0f465481e645524f618f7a3327822e8ae5d3fd42fa46c",
3694
+ "creationHexLength": 14300,
3695
+ "runtimeHexLength": 11504
3696
+ },
3697
+ "BurnMintTokenPool": {
3698
+ "creationHexSha256": "b5b19721149d9dd63e0650d0a1f95ac82affa4b9c650fdffd375db6ea361e416",
3699
+ "runtimeHexSha256": "c9aaa6a40ef4f0caadeb66f0a9adc68b1191949e9e0bdb420f331132bf651c3a",
3700
+ "creationHexLength": 41756,
3701
+ "runtimeHexLength": 39936
3702
+ },
3703
+ "CNRX": {
3704
+ "creationHexSha256": "61b4e114722e99f93aac4bd4ef3cfb7973dd050b66e6ffb326efad29d4cc8c95",
3705
+ "runtimeHexSha256": "2b23774e41fb25f820227a50de4f48d7ad79b0bd131c1956aab07c100e0c3948",
3706
+ "creationHexLength": 21266,
3707
+ "runtimeHexLength": 17374
3708
+ }
56
3709
  };
57
3710
  var BYTECODE_HASHES = {
58
3711
  "HTLC": {
59
- "bytecodeHash": "17e8b4dfbb8cb7095ce9f0c0334a8f506233e70c3baa1c15784ccb594c5ba07f",
60
- "deployedBytecodeHash": "86cff816f5875c8c5afefe9feb223c62ec5c0e2754606db2cecc96883c50c6a2",
61
- "bytecodeLength": 14204,
62
- "deployedBytecodeLength": 13914
3712
+ "bytecodeHash": "93a991d3a6451f7c3f02dfb70b365a48d29bebccc7f16d8dbe3d56d3dfee0af1",
3713
+ "deployedBytecodeHash": "40ab52456c3b5a04365fc1fad837eb79bbe4b85c8dbd990f549468ae48f97e3a",
3714
+ "bytecodeLength": 14976,
3715
+ "deployedBytecodeLength": 14686
63
3716
  },
64
3717
  "FeeVault": {
65
- "bytecodeHash": "83785435a8a603143b3bbf0a68587a0df1f966bfdbb66b364ca4f39b9c276da4",
66
- "deployedBytecodeHash": "e2458a305d0b8c4489cdf5cde2f1fa3411157292ffb7b2cfc95169550f093bec",
67
- "bytecodeLength": 13680,
68
- "deployedBytecodeLength": 11472
3718
+ "bytecodeHash": "1c97d27c8d3e584f879bb57549d75ef10394a56a298eaf4a772516b9316e2248",
3719
+ "deployedBytecodeHash": "0631177a64cde0829c2cec8426c08a507564f7d8b084e0237d724ed63faea0e9",
3720
+ "bytecodeLength": 13176,
3721
+ "deployedBytecodeLength": 10968
69
3722
  },
70
3723
  "MultiBalanceChecker": {
71
3724
  "bytecodeHash": "c0a0326694f2a1594e332ba06120692cc98bc06c57d6d8981cb3768e01fad423",
@@ -73,17 +3726,35 @@ var BYTECODE_HASHES = {
73
3726
  "bytecodeLength": 2456,
74
3727
  "deployedBytecodeLength": 2394
75
3728
  },
76
- "CNRX": {
77
- "bytecodeHash": "61b4e114722e99f93aac4bd4ef3cfb7973dd050b66e6ffb326efad29d4cc8c95",
78
- "deployedBytecodeHash": "2b23774e41fb25f820227a50de4f48d7ad79b0bd131c1956aab07c100e0c3948",
79
- "bytecodeLength": 21266,
80
- "deployedBytecodeLength": 17374
3729
+ "CancoreRouter": {
3730
+ "bytecodeHash": "361c33f0b5c50625ea1fab280886f9df5f96e6353d8d0d7e9fbce11d64cde5f8",
3731
+ "deployedBytecodeHash": "d3374648eaf5bdd0ddfc3ef6a67cd41ffea64b0551b24baded93cf2cb0aca1e0",
3732
+ "bytecodeLength": 49814,
3733
+ "deployedBytecodeLength": 44242
3734
+ },
3735
+ "CNRXStaking": {
3736
+ "bytecodeHash": "dfda056ee22b593e2f2e1fc4e679fbb9dc34b04964f389b46914402c422b40fb",
3737
+ "deployedBytecodeHash": "d11534242f166e52f4ad063b5b6b59146e31634d3932f7ad63db05d83a1485f6",
3738
+ "bytecodeLength": 7412,
3739
+ "deployedBytecodeLength": 6240
3740
+ },
3741
+ "PointsClaim": {
3742
+ "bytecodeHash": "0f29890b609f7e15ef4dbcda17a7f2cd7482d016a0057a5f6c4270d7780ff38d",
3743
+ "deployedBytecodeHash": "f2b10c4ec8458c0d6ab0f465481e645524f618f7a3327822e8ae5d3fd42fa46c",
3744
+ "bytecodeLength": 14300,
3745
+ "deployedBytecodeLength": 11504
81
3746
  },
82
3747
  "BurnMintTokenPool": {
83
3748
  "bytecodeHash": "b5b19721149d9dd63e0650d0a1f95ac82affa4b9c650fdffd375db6ea361e416",
84
3749
  "deployedBytecodeHash": "c9aaa6a40ef4f0caadeb66f0a9adc68b1191949e9e0bdb420f331132bf651c3a",
85
3750
  "bytecodeLength": 41756,
86
3751
  "deployedBytecodeLength": 39936
3752
+ },
3753
+ "CNRX": {
3754
+ "bytecodeHash": "61b4e114722e99f93aac4bd4ef3cfb7973dd050b66e6ffb326efad29d4cc8c95",
3755
+ "deployedBytecodeHash": "2b23774e41fb25f820227a50de4f48d7ad79b0bd131c1956aab07c100e0c3948",
3756
+ "bytecodeLength": 21266,
3757
+ "deployedBytecodeLength": 17374
87
3758
  }
88
3759
  };
89
3760
 
@@ -97,6 +3768,6 @@ function describeRevert(selectorOrData, tables) {
97
3768
  return void 0;
98
3769
  }
99
3770
 
100
- export { BYTECODE_HASHES, CONTRACTS_RELEASE, DEPLOYMENTS, FEE_CLAIM_DOMAIN_NAME, FEE_CLAIM_DOMAIN_VERSION, FEE_CLAIM_TYPES, PERMIT2_ADDRESS, deploymentOf, describeRevert, feeClaimDomain };
3771
+ export { ASYNCAPI, BPS, BUILD_HASHES, BYTECODE_HASHES, CANTON_LEG_KINDS, CANTON_OPS, CANTON_ORIGIN_ID, CANTON_REGISTRY_STATES, CANTON_SOURCE_ANCHOR, CANTON_TICKET_RECEIPT_TYPES, CANTON_TRANSFER_OUTCOMES, CONTRACTS_RELEASE, DAML_NUMERIC_SCALE, DECLINE_REASONS, DEPLOYMENTS, DRAND_QUICKNET, DRAW_CLOSED_BY, EIP2294_MAX_CHAIN_ID, ERROR_CODES, ERROR_HTTP_STATUS, EXEMPT_REASONS, EXPIRED_RESULTS, FEE_CLAIM_DOMAIN_NAME, FEE_CLAIM_DOMAIN_VERSION, FEE_CLAIM_TYPES, FILLER_AUTH_TYPES, FILLER_CLOSE_CODES, FILLER_GATEWAYS, FILLER_ID_PATTERN, FILLER_KEY_REGISTRATION_TYPES, FILLER_MESSAGE_TYPES, FILLER_PROTOCOL_DOMAIN, FILLER_QUOTE_TYPES, FILLER_UPGRADE_REFUSALS, FILLER_WS_BEARER_PREFIX, FILLER_WS_SUBPROTOCOL, FILL_PROOF_DOMAIN, FILL_PROOF_TYPES, FILL_PROOF_TYPE_STRING, FILL_TICKET_DOMAIN, FILL_TICKET_TYPES, GATEWAY_MESSAGE_TYPES, GRACE, INSTRUMENT_LABEL_TAG, MAX_FEE_BPS, MAX_FILL_TTL, MAX_PROOF_WINDOW, MAX_SIG_TTL, MESSAGE_DIRECTIONS, MIN_FILL_TTL, ORDER_TYPES, OWNER_LABEL_TAG, PENALTY_STEPS, PERMIT2_ADDRESS, PERMIT2_WITNESS_TYPE_STRING, PERMIT_WITNESS_TYPES, PROOF_KIND_ATTESTATION, PROTOCOL_SCHEMAS, PROTOCOL_VERSION, QUOTE_ACK_STATUSES, QUOTE_FINAL_STATUSES, QUOTE_TYPES, REST_ENDPOINTS, REST_ONLY_TYPES, SCHEMA_VOCABULARY, SET_DELAY, STAKE_BINDING_TYPES, TICKET_INTENT_TYPES, TICKET_LIST_STATUSES, TICKET_RECEIPT_TYPES, TICKET_REFUSED_REASONS, buildCantonSourceOrder, cantonInclusiveFeeSplit, cantonNetworkOfDestination, cantonSigEntries, cantonTicketReceipt, deliveryOrderCidHash, deploymentOf, describeRevert, drawValue, drawWinner, encodeCantonAmount, encodeCantonDestination, encodeCantonOutputAsset, encodeCantonRecipient, encodeType, evmAddressFromRepayTo, feeClaimDomain, fillProofDomain, fillerEnvelopeError, fillerIdHash, fillerMessageBodyHash, fillerWsProtocols, firstRoundAtOrAfter, gatewayBodyHash, hashCantonTicketReceipt, hashDomain, hashFillProof, hashFillTicket, hashFillerKeyRegistration, hashFillerMessage, hashFillerQuote, hashOrder, hashPermitWitness, hashStruct, hashTicketIntent, hashTypedData, inclusiveFeeSplit, isCantonOriginId, isCantonSource, isEoaSignature, isEvmRepayTo, jcs, messageIdRetainUntil, messageSchemaRef, permit2Domain, repayToFromEvm, repayToFromParty, requestIdHash, routerDomain, settleAttestationsErrors, settleAttestationsPayload, settleAttestationsPayloadHash, settleSigs, sourceOrderHash, typeHash };
101
3772
  //# sourceMappingURL=index.js.map
102
3773
  //# sourceMappingURL=index.js.map