@cancore/contracts 0.1.0 → 0.2.0-rc.10

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 +448 -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 +1559 -29
  9. package/dist/index.js +2925 -17
  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 +1265 -0
  34. package/spec/protocol/messages.schema.json +543 -0
  35. package/spec/protocol/records.schema.json +94 -0
  36. package/spec/protocol/rest.schema.json +134 -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 +550 -0
  49. package/spec/protocol/vectors/records.json +81 -0
  50. package/spec/protocol/vectors/settle-attestations.json +542 -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
@@ -0,0 +1,543 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cancore.io/schemas/filler-protocol/v1/messages.schema.json",
4
+ "title": "Cancore filler protocol v1 — WebSocket frames",
5
+ "$comment": "One $def per frame type, validated by name ($defs/<type>). The schemas encode the SENDER rule (protocol §3.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→F 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 §3.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 §3.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.",
6
+ "$defs": {
7
+ "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" },
8
+ "uintDec256": { "type": "string", "pattern": "^(0|[1-9][0-9]*)$", "maxLength": 78, "description": "uint256 as a decimal string" },
9
+ "intDecUsd": { "type": "string", "pattern": "^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$", "description": "signed decimal USD amount" },
10
+ "uint8": { "type": "integer", "minimum": 0, "maximum": 255 },
11
+ "uint16": { "type": "integer", "minimum": 0, "maximum": 65535 },
12
+ "uint32": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
13
+ "address": { "type": "string", "pattern": "^0x[0-9a-f]{40}$", "description": "EVM address, lowercase hex" },
14
+ "bytes32": { "type": "string", "pattern": "^0x[0-9a-f]{64}$" },
15
+ "repayTo": { "$ref": "#/$defs/bytes32", "description": "where settle pays the filler, encoded for the SOURCE chain (protocol §3.15): EVM — the address left-padded to 32 bytes (repayToEvm); Canton — keccak256(utf8(partyId)) of the filler's registered party" },
16
+ "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" },
17
+ "deliveryKey": { "$ref": "#/$defs/address", "description": "the address that sends fill on the destination (FillTicket.deliveryKey); the zero address for a Canton destination" },
18
+ "sig65": { "type": "string", "pattern": "^0x[0-9a-f]{64}[0-7][0-9a-f]{63}(1b|1c)$", "description": "65-byte r ‖ s ‖ v of an EOA, low-s, v ∈ {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 ≤ n/2" },
19
+ "timeMs": { "type": "integer", "minimum": 1000000000000, "maximum": 9007199254740991, "description": "unix milliseconds, gateway clock; the minimum rejects seconds" },
20
+ "durationMs": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
21
+ "timeS": { "$ref": "#/$defs/uintDec64", "description": "unix seconds as a decimal string (on-chain and signed times)" },
22
+ "caip2": { "type": "string", "pattern": "^(eip155:[1-9][0-9]*|canton:(mainnet|testnet|devnet))$" },
23
+ "cantonAsset": {
24
+ "type": "object",
25
+ "required": ["admin", "id"],
26
+ "properties": { "admin": { "type": "string", "minLength": 1 }, "id": { "type": "string", "minLength": 1 } }
27
+ },
28
+ "asset": { "oneOf": [{ "$ref": "#/$defs/address" }, { "$ref": "#/$defs/cantonAsset" }] },
29
+ "requestId": { "type": "string", "pattern": "^[!-~]{1,64}$", "description": "1..64 printable ASCII (Canonical.daml:90-93)" },
30
+ "fillerId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,62}$" },
31
+ "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" },
32
+ "protocolVersion": { "const": "1" },
33
+ "order": {
34
+ "type": "object",
35
+ "description": "ICancoreRouter.Order, twelve fields, every numeric field a decimal string (the shape of canton-order.json vector.order)",
36
+ "required": ["user", "originChainId", "inputToken", "inputAmount", "destination", "outputAsset", "minReceived", "recipient", "createdAt", "fillDeadline", "feeBps", "fillerId"],
37
+ "properties": {
38
+ "user": { "$ref": "#/$defs/address" },
39
+ "originChainId": { "$ref": "#/$defs/uintDec64" },
40
+ "inputToken": { "$ref": "#/$defs/address" },
41
+ "inputAmount": { "$ref": "#/$defs/uintDec256" },
42
+ "destination": { "$ref": "#/$defs/bytes32" },
43
+ "outputAsset": { "$ref": "#/$defs/bytes32" },
44
+ "minReceived": { "$ref": "#/$defs/uintDec256" },
45
+ "recipient": { "$ref": "#/$defs/bytes32" },
46
+ "createdAt": { "$ref": "#/$defs/timeS" },
47
+ "fillDeadline": { "$ref": "#/$defs/timeS" },
48
+ "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" },
49
+ "fillerId": { "$ref": "#/$defs/bytes32", "description": "keccak256(utf8(fillerId)) of the filler the user picked" }
50
+ }
51
+ },
52
+ "ticket": {
53
+ "type": "object",
54
+ "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)",
55
+ "required": ["orderHash", "fillerId", "deliveryKey", "repayTo", "attempt", "validFrom", "validUntil"],
56
+ "properties": {
57
+ "orderHash": { "$ref": "#/$defs/bytes32" },
58
+ "fillerId": { "$ref": "#/$defs/bytes32" },
59
+ "deliveryKey": { "$ref": "#/$defs/address" },
60
+ "repayTo": { "$ref": "#/$defs/repayTo" },
61
+ "attempt": { "$ref": "#/$defs/uint32" },
62
+ "validFrom": { "$ref": "#/$defs/timeS" },
63
+ "validUntil": { "$ref": "#/$defs/timeS" }
64
+ }
65
+ },
66
+ "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]`" },
67
+ "declineReason": {
68
+ "anyOf": [
69
+ { "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"] },
70
+ { "$ref": "#/$defs/futureEnumValue" }
71
+ ]
72
+ },
73
+ "errorCode": {
74
+ "anyOf": [
75
+ { "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"] },
76
+ { "$ref": "#/$defs/futureEnumValue" }
77
+ ]
78
+ },
79
+ "ticketRefusedReason": {
80
+ "anyOf": [
81
+ { "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"] },
82
+ { "$ref": "#/$defs/futureEnumValue" }
83
+ ],
84
+ "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"
85
+ },
86
+ "expiredResult": { "anyOf": [{ "enum": ["FILLED", "NO_SHOW", "NO_SHOW_UNCONFIRMED", "EXEMPT"] }, { "$ref": "#/$defs/futureEnumValue" }] },
87
+ "exemptReason": { "anyOf": [{ "enum": ["DESTINATION_HALTED", "GATEWAY_FAULT", "REORGED_AFTER_INCLUSION", "RECIPIENT_NOT_READY", "OTHER"] }, { "$ref": "#/$defs/futureEnumValue" }] },
88
+ "quoteAckStatus": { "anyOf": [{ "enum": ["COUNTED", "LATE", "SHORT_TTL"] }, { "$ref": "#/$defs/futureEnumValue" }], "description": "verdict at receipt time; the final status is on GET /v1/filler/quotes" },
89
+ "penaltyStep": { "anyOf": [{ "enum": ["L1", "L2", "L3", "L4"] }, { "$ref": "#/$defs/futureEnumValue" }] },
90
+ "s2fEnvelope": {
91
+ "type": "object",
92
+ "required": ["type", "id", "sentAt", "sig"],
93
+ "properties": {
94
+ "type": { "type": "string" },
95
+ "id": { "$ref": "#/$defs/messageId" },
96
+ "fillerId": { "$ref": "#/$defs/fillerId", "description": "the addressee" },
97
+ "sentAt": { "$ref": "#/$defs/timeMs" },
98
+ "sig": { "$ref": "#/$defs/sig65", "description": "gateway key over GatewayMessage{bodyHash = keccak256(JCS(frame without sig))}" },
99
+ "re": { "$ref": "#/$defs/messageId" }
100
+ }
101
+ },
102
+ "s2fBase": { "allOf": [{ "$ref": "#/$defs/s2fEnvelope" }, { "type": "object", "required": ["fillerId"], "properties": { "fillerId": { "$ref": "#/$defs/fillerId" } } }] },
103
+ "f2sEnvelope": {
104
+ "type": "object",
105
+ "description": "What every filler → filler-gateway message and REST request body carries (protocol §3.4, S-19): the gateway refuses one without it, with another fillerId than the session's, with a stale sentAt or a reused id",
106
+ "required": ["id", "fillerId", "sentAt", "msgSig"],
107
+ "properties": {
108
+ "id": { "$ref": "#/$defs/messageId" },
109
+ "fillerId": { "$ref": "#/$defs/fillerId", "description": "the sender; must be the fillerId the session is authenticated for" },
110
+ "sentAt": { "$ref": "#/$defs/timeMs" },
111
+ "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" },
112
+ "re": { "$ref": "#/$defs/messageId" }
113
+ }
114
+ },
115
+ "f2sBase": { "allOf": [{ "$ref": "#/$defs/f2sEnvelope" }, { "type": "object", "required": ["type"], "properties": { "type": { "type": "string" } } }] },
116
+ "fillerKeyRegistration": {
117
+ "type": "object",
118
+ "description": "Proof of possession of a message key (protocol §3.16): FillerKeyRegistration{fillerId, messageKey, issuedAt} signed by that key — 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 ∈ {27, 28}) that recovers to messageKey; an EIP-1271 signature is refused",
119
+ "required": ["fillerId", "messageKey", "issuedAt", "sig"],
120
+ "properties": {
121
+ "fillerId": { "$ref": "#/$defs/fillerId" },
122
+ "messageKey": { "$ref": "#/$defs/address" },
123
+ "issuedAt": { "$ref": "#/$defs/timeS" },
124
+ "sig": { "$ref": "#/$defs/sig65" }
125
+ }
126
+ },
127
+ "auth.challenge": {
128
+ "x-direction": "S2F",
129
+ "x-rest-only": true,
130
+ "type": "object",
131
+ "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}",
132
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
133
+ "required": ["type", "nonce", "expiresAt"],
134
+ "properties": { "type": { "const": "auth.challenge" }, "nonce": { "$ref": "#/$defs/bytes32" }, "expiresAt": { "$ref": "#/$defs/timeS" } }
135
+ },
136
+ "auth.response": {
137
+ "x-direction": "F2S",
138
+ "type": "object",
139
+ "x-rest-only": true,
140
+ "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",
141
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
142
+ "required": ["type", "fillerId", "keyAddress", "protocolVersion", "sig"],
143
+ "properties": {
144
+ "type": { "const": "auth.response" },
145
+ "fillerId": { "$ref": "#/$defs/fillerId" },
146
+ "keyAddress": { "$ref": "#/$defs/address" },
147
+ "protocolVersion": { "type": "string", "description": "the gateway answers UNSUPPORTED_VERSION to anything it does not serve; v1 senders send \"1\"" },
148
+ "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" },
149
+ "sig": { "$ref": "#/$defs/sig65" }
150
+ }
151
+ },
152
+ "auth.ok": {
153
+ "x-direction": "S2F",
154
+ "type": "object",
155
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
156
+ "required": ["type", "heartbeatIntervalMs"],
157
+ "properties": { "type": { "const": "auth.ok" }, "heartbeatIntervalMs": { "$ref": "#/$defs/durationMs" } }
158
+ },
159
+ "ping": {
160
+ "x-direction": "both",
161
+ "description": "Heartbeat, either way. A receiver checks the copy of its direction: pingS2F (gateway sig) or pingF2S (filler msgSig)",
162
+ "anyOf": [{ "$ref": "#/$defs/pingF2S" }, { "$ref": "#/$defs/pingS2F" }]
163
+ },
164
+ "pingF2S": {
165
+ "type": "object",
166
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
167
+ "required": ["type", "id"],
168
+ "properties": { "type": { "const": "ping" }, "id": { "$ref": "#/$defs/messageId" } }
169
+ },
170
+ "pingS2F": {
171
+ "type": "object",
172
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
173
+ "required": ["type", "id"],
174
+ "properties": { "type": { "const": "ping" }, "id": { "$ref": "#/$defs/messageId" } }
175
+ },
176
+ "pong": {
177
+ "x-direction": "both",
178
+ "description": "Answer to a ping, re = ping.id. A receiver checks the copy of its direction: pongS2F (gateway sig) or pongF2S (filler msgSig)",
179
+ "anyOf": [{ "$ref": "#/$defs/pongF2S" }, { "$ref": "#/$defs/pongS2F" }]
180
+ },
181
+ "pongF2S": {
182
+ "type": "object",
183
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
184
+ "required": ["type", "re"],
185
+ "properties": { "type": { "const": "pong" }, "re": { "$ref": "#/$defs/messageId" } }
186
+ },
187
+ "pongS2F": {
188
+ "type": "object",
189
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
190
+ "required": ["type", "re"],
191
+ "properties": { "type": { "const": "pong" }, "re": { "$ref": "#/$defs/messageId" } }
192
+ },
193
+ "error": {
194
+ "x-direction": "both",
195
+ "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)",
196
+ "anyOf": [{ "$ref": "#/$defs/errorF2S" }, { "$ref": "#/$defs/errorS2F" }]
197
+ },
198
+ "errorS2F": {
199
+ "type": "object",
200
+ "description": "Reply to the F→S 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",
201
+ "allOf": [{ "$ref": "#/$defs/s2fEnvelope" }],
202
+ "required": ["type", "code", "message"],
203
+ "properties": {
204
+ "type": { "const": "error" },
205
+ "code": { "$ref": "#/$defs/errorCode" },
206
+ "message": { "type": "string" },
207
+ "reason": { "$ref": "#/$defs/ticketRefusedReason" },
208
+ "retryAfterMs": { "$ref": "#/$defs/durationMs", "type": "integer", "minimum": 1, "description": "with RATE_LIMITED: ms (≥ 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" }
209
+ },
210
+ "if": { "type": "object", "properties": { "code": { "const": "TICKET_REFUSED" } }, "required": ["code"] },
211
+ "then": { "type": "object", "required": ["reason"], "properties": { "reason": true } }
212
+ },
213
+ "errorF2S": {
214
+ "type": "object",
215
+ "description": "The filler's reply to the S→F frame `re` it cannot handle (malformed, unknown orderHash); informational, it changes no state in filler-gateway. Signed like every filler message",
216
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
217
+ "required": ["type", "re", "code", "message"],
218
+ "properties": { "type": { "const": "error" }, "re": { "$ref": "#/$defs/messageId" }, "code": { "$ref": "#/$defs/errorCode" }, "message": { "type": "string" } }
219
+ },
220
+ "epoch.weights": {
221
+ "x-direction": "S2F",
222
+ "type": "object",
223
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
224
+ "required": ["type", "epochId", "startsAt", "endsAt", "weightsRoot"],
225
+ "properties": {
226
+ "type": { "const": "epoch.weights" },
227
+ "epochId": { "$ref": "#/$defs/uintDec64" },
228
+ "startsAt": { "$ref": "#/$defs/timeS" },
229
+ "endsAt": { "$ref": "#/$defs/timeS" },
230
+ "weightsRoot": { "$ref": "#/$defs/bytes32" }
231
+ }
232
+ },
233
+ "quote.request": {
234
+ "x-direction": "S2F",
235
+ "type": "object",
236
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
237
+ "required": ["type", "requestId", "route", "inputToken", "inputAmount", "outputAsset", "feeBps", "fillDeadlineHint", "windowCloseAt", "quoteTtlMs"],
238
+ "properties": {
239
+ "type": { "const": "quote.request" },
240
+ "requestId": { "$ref": "#/$defs/requestId" },
241
+ "route": {
242
+ "type": "object",
243
+ "required": ["src", "dst"],
244
+ "properties": { "src": { "$ref": "#/$defs/caip2" }, "dst": { "$ref": "#/$defs/caip2" } }
245
+ },
246
+ "inputToken": { "$ref": "#/$defs/asset" },
247
+ "inputAmount": { "$ref": "#/$defs/uintDec256", "description": "the total T the maker deposits (inclusive fee), input base units" },
248
+ "outputAsset": { "$ref": "#/$defs/asset" },
249
+ "feeBps": { "$ref": "#/$defs/uint16" },
250
+ "fillDeadlineHint": { "$ref": "#/$defs/timeS" },
251
+ "windowCloseAt": { "$ref": "#/$defs/timeMs" },
252
+ "quoteTtlMs": { "$ref": "#/$defs/durationMs" },
253
+ "imbalanceHint": {
254
+ "type": "object",
255
+ "required": ["dstAsset", "netFlow24hUsd"],
256
+ "properties": { "dstAsset": { "$ref": "#/$defs/asset" }, "netFlow24hUsd": { "$ref": "#/$defs/intDecUsd" } }
257
+ }
258
+ }
259
+ },
260
+ "quote": {
261
+ "x-direction": "F2S",
262
+ "type": "object",
263
+ "description": "sig = FillerQuote{keccak256(utf8(requestId)), fillerId, amountOut, validUntil, nonce} by the message key, fillerId the envelope's; counts only if validUntil × 1000 ≥ windowCloseAt + quoteTtlMs",
264
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
265
+ "required": ["type", "requestId", "amountOut", "validUntil", "nonce", "sig"],
266
+ "properties": {
267
+ "type": { "const": "quote" },
268
+ "requestId": { "$ref": "#/$defs/requestId" },
269
+ "amountOut": { "$ref": "#/$defs/uintDec256" },
270
+ "validUntil": { "$ref": "#/$defs/timeS" },
271
+ "nonce": { "$ref": "#/$defs/uintDec64" },
272
+ "sig": { "$ref": "#/$defs/sig65" }
273
+ }
274
+ },
275
+ "quote.ack": {
276
+ "x-direction": "S2F",
277
+ "type": "object",
278
+ "description": "For every well-formed, correctly signed quote, late ones included (S-12)",
279
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
280
+ "required": ["type", "requestId", "quoteHash", "receivedAt", "status"],
281
+ "properties": {
282
+ "type": { "const": "quote.ack" },
283
+ "requestId": { "$ref": "#/$defs/requestId" },
284
+ "quoteHash": { "$ref": "#/$defs/bytes32" },
285
+ "receivedAt": { "$ref": "#/$defs/timeMs" },
286
+ "status": { "$ref": "#/$defs/quoteAckStatus" }
287
+ }
288
+ },
289
+ "quote.reconfirm": {
290
+ "x-direction": "S2F",
291
+ "type": "object",
292
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
293
+ "required": ["type", "orderHash", "requestId", "order", "amountOut", "ticketTtl", "replyBy"],
294
+ "properties": {
295
+ "type": { "const": "quote.reconfirm" },
296
+ "orderHash": { "$ref": "#/$defs/bytes32" },
297
+ "requestId": { "$ref": "#/$defs/requestId" },
298
+ "order": { "$ref": "#/$defs/order" },
299
+ "amountOut": { "$ref": "#/$defs/uintDec256" },
300
+ "ticketTtl": { "$ref": "#/$defs/uint32", "description": "seconds" },
301
+ "replyBy": { "$ref": "#/$defs/timeMs" }
302
+ }
303
+ },
304
+ "quote.reconfirm.reply": {
305
+ "x-direction": "F2S",
306
+ "type": "object",
307
+ "description": "An accept carries sig = FillerQuote{keccak256(utf8(requestId)), fillerId, amountOut, validUntil, nonce} by the message key; a decline carries only the envelope msgSig",
308
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
309
+ "required": ["type", "orderHash", "accept"],
310
+ "properties": {
311
+ "type": { "const": "quote.reconfirm.reply" },
312
+ "orderHash": { "$ref": "#/$defs/bytes32" },
313
+ "accept": { "type": "boolean" },
314
+ "validUntil": { "$ref": "#/$defs/timeS" },
315
+ "nonce": { "$ref": "#/$defs/uintDec64" },
316
+ "sig": { "$ref": "#/$defs/sig65" }
317
+ },
318
+ "if": { "type": "object", "properties": { "accept": { "const": true } }, "required": ["accept"] },
319
+ "then": { "type": "object", "required": ["validUntil", "nonce", "sig"], "properties": { "validUntil": true, "nonce": true, "sig": true } }
320
+ },
321
+ "ticket.offer": {
322
+ "x-direction": "S2F",
323
+ "type": "object",
324
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
325
+ "required": ["type", "orderHash", "attempt", "order", "amountOut", "validFrom", "validUntil", "acceptBy"],
326
+ "properties": {
327
+ "type": { "const": "ticket.offer" },
328
+ "orderHash": { "$ref": "#/$defs/bytes32" },
329
+ "attempt": { "$ref": "#/$defs/uint32" },
330
+ "order": { "$ref": "#/$defs/order" },
331
+ "amountOut": { "$ref": "#/$defs/uintDec256" },
332
+ "validFrom": { "$ref": "#/$defs/timeS" },
333
+ "validUntil": { "$ref": "#/$defs/timeS" },
334
+ "acceptBy": { "$ref": "#/$defs/timeMs" }
335
+ }
336
+ },
337
+ "ticket.intent": {
338
+ "x-direction": "F2S",
339
+ "type": "object",
340
+ "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)",
341
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
342
+ "required": ["type", "orderHash", "attempt", "validFrom", "validUntil", "deliveryKey", "repayTo", "sig"],
343
+ "properties": {
344
+ "type": { "const": "ticket.intent" },
345
+ "orderHash": { "$ref": "#/$defs/bytes32" },
346
+ "attempt": { "$ref": "#/$defs/uint32" },
347
+ "validFrom": { "$ref": "#/$defs/timeS" },
348
+ "validUntil": { "$ref": "#/$defs/timeS" },
349
+ "deliveryKey": { "$ref": "#/$defs/deliveryKey" },
350
+ "repayTo": { "$ref": "#/$defs/repayTo" },
351
+ "sig": { "$ref": "#/$defs/sig65" }
352
+ }
353
+ },
354
+ "ticket.decline": {
355
+ "x-direction": "F2S",
356
+ "type": "object",
357
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
358
+ "required": ["type", "orderHash", "attempt", "reason"],
359
+ "properties": {
360
+ "type": { "const": "ticket.decline" },
361
+ "orderHash": { "$ref": "#/$defs/bytes32" },
362
+ "attempt": { "$ref": "#/$defs/uint32" },
363
+ "reason": { "$ref": "#/$defs/declineReason" },
364
+ "detail": { "type": "string" }
365
+ }
366
+ },
367
+ "ticket.intent.ack": {
368
+ "x-direction": "S2F",
369
+ "type": "object",
370
+ "description": "Idempotent: a repeated identical intent gets the identical ack",
371
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
372
+ "required": ["type", "orderHash", "attempt", "intentHash", "receivedAt"],
373
+ "properties": {
374
+ "type": { "const": "ticket.intent.ack" },
375
+ "orderHash": { "$ref": "#/$defs/bytes32" },
376
+ "attempt": { "$ref": "#/$defs/uint32" },
377
+ "intentHash": { "$ref": "#/$defs/bytes32" },
378
+ "receivedAt": { "$ref": "#/$defs/timeMs" }
379
+ }
380
+ },
381
+ "ticket.issued": {
382
+ "x-direction": "S2F",
383
+ "type": "object",
384
+ "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)",
385
+ "required": ["type", "form", "orderHash", "attempt"],
386
+ "properties": {
387
+ "type": { "const": "ticket.issued" },
388
+ "form": { "anyOf": [{ "enum": ["evm", "canton"] }, { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }] },
389
+ "orderHash": { "$ref": "#/$defs/bytes32" },
390
+ "attempt": { "$ref": "#/$defs/uint32" }
391
+ },
392
+ "allOf": [
393
+ { "$ref": "#/$defs/s2fBase" },
394
+ {
395
+ "if": { "type": "object", "properties": { "form": { "const": "evm" } }, "required": ["form"] },
396
+ "then": { "type": "object", "required": ["ticket", "ticketSig"], "properties": { "ticket": { "$ref": "#/$defs/ticket" }, "ticketSig": { "$ref": "#/$defs/sig65" } } }
397
+ },
398
+ {
399
+ "if": { "type": "object", "properties": { "form": { "const": "canton" } }, "required": ["form"] },
400
+ "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" } } }
401
+ }
402
+ ]
403
+ },
404
+ "ticket.receipt": {
405
+ "x-direction": "F2S",
406
+ "type": "object",
407
+ "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 §3.3, §10 D-O)",
408
+ "required": ["type", "orderHash", "attempt", "sig"],
409
+ "properties": {
410
+ "type": { "const": "ticket.receipt" },
411
+ "form": { "anyOf": [{ "enum": ["evm", "canton"] }, { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }] },
412
+ "orderHash": { "$ref": "#/$defs/bytes32" },
413
+ "attempt": { "$ref": "#/$defs/uint32" },
414
+ "sig": { "$ref": "#/$defs/sig65" }
415
+ },
416
+ "allOf": [
417
+ { "$ref": "#/$defs/f2sBase" },
418
+ {
419
+ "if": { "type": "object", "properties": { "form": { "const": "evm" } } },
420
+ "then": { "type": "object", "required": ["ticketHash", "ticketSigHash"], "properties": { "ticketHash": { "$ref": "#/$defs/bytes32" }, "ticketSigHash": { "$ref": "#/$defs/bytes32" } } }
421
+ },
422
+ {
423
+ "if": { "type": "object", "properties": { "form": { "const": "canton" } }, "required": ["form"] },
424
+ "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" } } }
425
+ }
426
+ ]
427
+ },
428
+ "fill.reported": {
429
+ "x-direction": "F2S",
430
+ "type": "object",
431
+ "allOf": [{ "$ref": "#/$defs/f2sBase" }],
432
+ "required": ["type", "orderHash", "attempt", "txRef"],
433
+ "properties": {
434
+ "type": { "const": "fill.reported" },
435
+ "orderHash": { "$ref": "#/$defs/bytes32" },
436
+ "attempt": { "$ref": "#/$defs/uint32" },
437
+ "txRef": { "type": "string", "minLength": 1, "description": "EVM tx hash or Canton update id" }
438
+ }
439
+ },
440
+ "ticket.expired": {
441
+ "x-direction": "S2F",
442
+ "type": "object",
443
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
444
+ "required": ["type", "orderHash", "attempt", "result"],
445
+ "properties": {
446
+ "type": { "const": "ticket.expired" },
447
+ "orderHash": { "$ref": "#/$defs/bytes32" },
448
+ "attempt": { "$ref": "#/$defs/uint32" },
449
+ "result": { "$ref": "#/$defs/expiredResult" },
450
+ "exemptReason": { "$ref": "#/$defs/exemptReason" }
451
+ },
452
+ "if": { "type": "object", "properties": { "result": { "const": "EXEMPT" } }, "required": ["result"] },
453
+ "then": { "type": "object", "required": ["exemptReason"], "properties": { "exemptReason": true } }
454
+ },
455
+ "order.settled": {
456
+ "x-direction": "S2F",
457
+ "type": "object",
458
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
459
+ "required": ["type", "orderHash", "payout", "fee", "penaltyWithheld", "txRef"],
460
+ "properties": {
461
+ "type": { "const": "order.settled" },
462
+ "orderHash": { "$ref": "#/$defs/bytes32" },
463
+ "payout": { "$ref": "#/$defs/uintDec256" },
464
+ "fee": { "$ref": "#/$defs/uintDec256" },
465
+ "penaltyWithheld": { "$ref": "#/$defs/uintDec256" },
466
+ "txRef": { "type": "string", "minLength": 1 }
467
+ }
468
+ },
469
+ "penalty.applied": {
470
+ "x-direction": "S2F",
471
+ "type": "object",
472
+ "allOf": [{ "$ref": "#/$defs/s2fBase" }],
473
+ "required": ["type", "violationId", "code", "step", "details"],
474
+ "properties": {
475
+ "type": { "const": "penalty.applied" },
476
+ "violationId": { "type": "string", "minLength": 1 },
477
+ "code": { "type": "string", "minLength": 1 },
478
+ "step": { "$ref": "#/$defs/penaltyStep" },
479
+ "details": { "type": "object" }
480
+ }
481
+ },
482
+ "fillProof": {
483
+ "type": "object",
484
+ "description": "FillProof as the source router hashes it (FILL_PROOF_TYPES, the twelve variant A fields, protocol §3.3), encoded per protocol §3.1: kind, attempt, setId JSON integers; amountDelivered, filledAt decimal strings; fillerId the on-chain form keccak256(utf8(fillerId))",
485
+ "required": ["kind", "orderHash", "destination", "fillRef", "recipient", "outputAsset", "amountDelivered", "filledAt", "fillerId", "repayTo", "attempt", "setId"],
486
+ "properties": {
487
+ "kind": { "$ref": "#/$defs/uint8" },
488
+ "orderHash": { "$ref": "#/$defs/bytes32" },
489
+ "destination": { "$ref": "#/$defs/bytes32" },
490
+ "fillRef": { "$ref": "#/$defs/bytes32" },
491
+ "recipient": { "$ref": "#/$defs/bytes32" },
492
+ "outputAsset": { "$ref": "#/$defs/bytes32" },
493
+ "amountDelivered": { "$ref": "#/$defs/uintDec256" },
494
+ "filledAt": { "$ref": "#/$defs/timeS" },
495
+ "fillerId": { "$ref": "#/$defs/bytes32", "description": "keccak256(utf8(fillerId)) of the filler that delivered: this filler's" },
496
+ "repayTo": { "$ref": "#/$defs/repayTo", "description": "the payee of settle, encoded for the source chain: the repayTo of this filler's ticket" },
497
+ "attempt": { "$ref": "#/$defs/uint32" },
498
+ "setId": { "$ref": "#/$defs/uint32" }
499
+ }
500
+ },
501
+ "attestationEvm": {
502
+ "type": "object",
503
+ "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",
504
+ "required": ["signer", "signature"],
505
+ "properties": { "signer": { "$ref": "#/$defs/address" }, "signature": { "$ref": "#/$defs/sig65" } }
506
+ },
507
+ "attestationCanton": {
508
+ "type": "object",
509
+ "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",
510
+ "required": ["signer", "pubKey", "signature"],
511
+ "properties": {
512
+ "signer": { "$ref": "#/$defs/address" },
513
+ "pubKey": { "type": "string", "pattern": "^0x3056301006072a8648ce3d020106052b8104000a03420004[0-9a-f]{128}$", "description": "DER SubjectPublicKeyInfo of the uncompressed secp256k1 key (88 bytes), as KMS GetPublicKey returns it" },
514
+ "signature": { "type": "string", "pattern": "^0x30([0-9a-f]{2}){7,71}$", "description": "minimal DER ECDSA signature, low-s, no recovery byte" }
515
+ }
516
+ },
517
+ "settle.attestations": {
518
+ "x-direction": "S2F",
519
+ "type": "object",
520
+ "description": "≥ threshold attestor signatures over the filler's FillProof (§10 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 → attestationEvm, canton → attestationCanton",
521
+ "allOf": [
522
+ { "$ref": "#/$defs/s2fBase" },
523
+ {
524
+ "if": { "type": "object", "properties": { "sourceChainId": { "type": "string", "pattern": "^canton:" } }, "required": ["sourceChainId"] },
525
+ "then": { "type": "object", "properties": { "signatures": { "type": "array", "items": { "$ref": "#/$defs/attestationCanton" } } } },
526
+ "else": { "type": "object", "properties": { "signatures": { "type": "array", "items": { "$ref": "#/$defs/attestationEvm" } } } }
527
+ }
528
+ ],
529
+ "required": ["type", "orderHash", "attempt", "sourceChainId", "proof", "signatures", "setId", "threshold", "refundAfter"],
530
+ "properties": {
531
+ "type": { "const": "settle.attestations" },
532
+ "orderHash": { "$ref": "#/$defs/bytes32" },
533
+ "attempt": { "$ref": "#/$defs/uint32", "description": "equals proof.attempt" },
534
+ "sourceChainId": { "$ref": "#/$defs/caip2", "description": "where settle is submitted" },
535
+ "proof": { "$ref": "#/$defs/fillProof" },
536
+ "signatures": { "type": "array", "minItems": 1 },
537
+ "setId": { "$ref": "#/$defs/uint32", "description": "equals proof.setId; EVM: attestationSetFor(orderHash)" },
538
+ "threshold": { "type": "integer", "minimum": 1, "maximum": 4294967295, "description": "k of that set" },
539
+ "refundAfter": { "$ref": "#/$defs/timeS", "description": "from this time settle reverts; the node gets its settle included before it" }
540
+ }
541
+ }
542
+ }
543
+ }