@cancore/contracts 0.2.0-rc.6 → 0.2.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -23
- package/dist/abi.d.ts +110 -178
- package/dist/abi.js +1 -1
- package/dist/{chunk-NV5IUURP.js → chunk-GJPX4H5K.js} +132 -232
- package/dist/chunk-GJPX4H5K.js.map +1 -0
- package/dist/index.d.ts +397 -24
- package/dist/index.js +380 -125
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/spec/abi/CancoreRouter.json +64 -155
- package/spec/abi/ICancoreRouter.json +64 -69
- package/spec/constants.json +66 -0
- package/spec/protocol/asyncapi.json +70 -95
- package/spec/protocol/messages.schema.json +30 -13
- package/spec/protocol/rest.schema.json +19 -3
- package/spec/protocol/typed-data/CantonTicketReceipt.json +77 -0
- package/spec/protocol/typed-data/GatewayMessage.json +5 -4
- package/spec/protocol/vectors/messages.json +28 -3
- package/spec/typed-data/FillProof.json +1 -1
- package/spec/typed-data/FillTicket.json +2 -1
- package/spec/vectors/canton-destination.json +59 -0
- package/spec/vectors/evm-order.json +48 -0
- package/spec/vectors/fee-split.json +179 -0
- package/spec/vectors/permit-witness.json +144 -0
- package/dist/chunk-NV5IUURP.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "EVM-source Order (protocol.md §3.3) and its orderHash = CancoreRouter.hashOrder in the source router domain {CancoreRouter, 1, chainId, verifyingContract}. Digests by ethers TypedDataEncoder; @cancore/contracts hashOrder must reproduce them. Generated by scripts/gen-router-vectors.mjs.",
|
|
3
|
+
"typeString": "Order(address user,uint64 originChainId,address inputToken,uint256 inputAmount,bytes32 destination,bytes32 outputAsset,uint256 minReceived,bytes32 recipient,uint64 createdAt,uint64 fillDeadline,uint16 feeBps)",
|
|
4
|
+
"vectors": [
|
|
5
|
+
{
|
|
6
|
+
"note": "EVM-source fixture order (sepolia to arbitrum sepolia, 30 bps) — the same order and digest as spec/typed-data/Order.json",
|
|
7
|
+
"domain": {
|
|
8
|
+
"chainId": "11155111",
|
|
9
|
+
"verifyingContract": "0x00000000000000000000000000000000cafe0001"
|
|
10
|
+
},
|
|
11
|
+
"order": {
|
|
12
|
+
"user": "0xa11ce00000000000000000000000000000000001",
|
|
13
|
+
"originChainId": "11155111",
|
|
14
|
+
"inputToken": "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
|
|
15
|
+
"inputAmount": "1003000000",
|
|
16
|
+
"destination": "0x0000000000000000000000000000000000000000000000000000000000066eee",
|
|
17
|
+
"outputAsset": "0x00000000000000000000000075faf114eafb1bdbe2f0316df893fd58ce46aa4d",
|
|
18
|
+
"minReceived": "999000000",
|
|
19
|
+
"recipient": "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
|
|
20
|
+
"createdAt": "1790000000",
|
|
21
|
+
"fillDeadline": "1790000600",
|
|
22
|
+
"feeBps": "30"
|
|
23
|
+
},
|
|
24
|
+
"orderHash": "0x585ec61a0813109803da9d47aea37a165f7df1371553f1e4ea8c139cf74058a6"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"note": "the reverse route at MAX_FEE_BPS: 110 total, 100 net",
|
|
28
|
+
"domain": {
|
|
29
|
+
"chainId": "421614",
|
|
30
|
+
"verifyingContract": "0x00000000000000000000000000000000cafe0002"
|
|
31
|
+
},
|
|
32
|
+
"order": {
|
|
33
|
+
"user": "0xa11ce00000000000000000000000000000000001",
|
|
34
|
+
"originChainId": "421614",
|
|
35
|
+
"inputToken": "0x75faf114eafb1bdbe2f0316df893fd58ce46aa4d",
|
|
36
|
+
"inputAmount": "110000000",
|
|
37
|
+
"destination": "0x0000000000000000000000000000000000000000000000000000000000aa36a7",
|
|
38
|
+
"outputAsset": "0x0000000000000000000000001c7d4b196cb0c7b01d743fbc6116a902379c7238",
|
|
39
|
+
"minReceived": "100000000",
|
|
40
|
+
"recipient": "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
|
|
41
|
+
"createdAt": "1790000000",
|
|
42
|
+
"fillDeadline": "1790000600",
|
|
43
|
+
"feeBps": "1000"
|
|
44
|
+
},
|
|
45
|
+
"orderHash": "0x4bd8ea081a1d534041be8022b4eb685b56e6fb9434c8ba8c0e68600873d6f719"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "The inclusive fee of protocol.md §3.11: the maker hands over the total T, the filler is paid `payout`, Cancore keeps `fee` = T − payout. evm: CancoreRouter.settle, payout = floor(T × 10000 / (10000 + feeBps)) — each case names the router test that pins it (pinnedBy). canton: Daml inclusiveFee in EVM-form units (T = amount × 10^10, feeBps = feeRate × 10000), payout = the same quotient rounded half to even; ledgerPayout/ledgerFee are the Daml Decimal values (protocol.md §3.11), evmPayout the EVM formula for comparison. Generated by scripts/gen-router-vectors.mjs.",
|
|
3
|
+
"evm": [
|
|
4
|
+
{
|
|
5
|
+
"note": "protocol.md §3.11 hand vector: 105 total at 5 % — 100 to the filler, 5 of fee (6 decimals)",
|
|
6
|
+
"total": "105000000",
|
|
7
|
+
"feeBps": 500,
|
|
8
|
+
"payout": "100000000",
|
|
9
|
+
"fee": "5000000",
|
|
10
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1042"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"note": "the same at 18 decimals",
|
|
14
|
+
"total": "105000000000000000000",
|
|
15
|
+
"feeBps": 500,
|
|
16
|
+
"payout": "100000000000000000000",
|
|
17
|
+
"fee": "5000000000000000000",
|
|
18
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1042"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"note": "feeBps = 0: the whole input is paid out",
|
|
22
|
+
"total": "100000000000000000000",
|
|
23
|
+
"feeBps": 0,
|
|
24
|
+
"payout": "100000000000000000000",
|
|
25
|
+
"fee": "0",
|
|
26
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1058"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"note": "feeBps = MAX_FEE_BPS: 11 000 total, 10 000 net, 1 000 fee (1/11 of the total)",
|
|
30
|
+
"total": "11000",
|
|
31
|
+
"feeBps": 1000,
|
|
32
|
+
"payout": "10000",
|
|
33
|
+
"fee": "1000",
|
|
34
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1066"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"note": "rounding dust on the fee: 12 345 at 33 bps pays 12 304, fee 41 (the ideal 40.6 rounded up)",
|
|
38
|
+
"total": "12345",
|
|
39
|
+
"feeBps": 33,
|
|
40
|
+
"payout": "12304",
|
|
41
|
+
"fee": "41",
|
|
42
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1079"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"note": "inexact division",
|
|
46
|
+
"total": "1000001",
|
|
47
|
+
"feeBps": 7,
|
|
48
|
+
"payout": "999301",
|
|
49
|
+
"fee": "700",
|
|
50
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1092"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"note": "inexact division",
|
|
54
|
+
"total": "999",
|
|
55
|
+
"feeBps": 999,
|
|
56
|
+
"payout": "908",
|
|
57
|
+
"fee": "91",
|
|
58
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1092"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"note": "inexact division",
|
|
62
|
+
"total": "7",
|
|
63
|
+
"feeBps": 1,
|
|
64
|
+
"payout": "6",
|
|
65
|
+
"fee": "1",
|
|
66
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1092"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"note": "dust below one net unit is all fee: 1 at MAX_FEE_BPS pays 0",
|
|
70
|
+
"total": "1",
|
|
71
|
+
"feeBps": 1000,
|
|
72
|
+
"payout": "0",
|
|
73
|
+
"fee": "1",
|
|
74
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1100"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"note": "dust at a low rate: 1 at 30 bps pays 0",
|
|
78
|
+
"total": "1",
|
|
79
|
+
"feeBps": 30,
|
|
80
|
+
"payout": "0",
|
|
81
|
+
"fee": "1",
|
|
82
|
+
"pinnedBy": "CAN-1934 acceptance"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"note": "11 at MAX_FEE_BPS: 10 and 1",
|
|
86
|
+
"total": "11",
|
|
87
|
+
"feeBps": 1000,
|
|
88
|
+
"payout": "10",
|
|
89
|
+
"fee": "1",
|
|
90
|
+
"pinnedBy": "CAN-1934 acceptance"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"note": "10 000 at 0 bps",
|
|
94
|
+
"total": "10000",
|
|
95
|
+
"feeBps": 0,
|
|
96
|
+
"payout": "10000",
|
|
97
|
+
"fee": "0",
|
|
98
|
+
"pinnedBy": "CAN-1934 acceptance"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"note": "2^250 at MAX_FEE_BPS: no overflow (mulDiv)",
|
|
102
|
+
"total": "1809251394333065553493296640760748560207343510400633813116524750123642650624",
|
|
103
|
+
"feeBps": 1000,
|
|
104
|
+
"payout": "1644773994848241412266633309782498691097585009455121648287749772839675136930",
|
|
105
|
+
"fee": "164477399484824141226663330978249869109758500945512164828774977283967513694",
|
|
106
|
+
"pinnedBy": "evm-contracts test/CancoreRouter.ts @ c214f56:1112"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"note": "the fixture order: 1003 USDC at 30 bps is 1000 to the filler, 3 of fee (order.settled example)",
|
|
110
|
+
"total": "1003000000",
|
|
111
|
+
"feeBps": 30,
|
|
112
|
+
"payout": "1000000000",
|
|
113
|
+
"fee": "3000000",
|
|
114
|
+
"pinnedBy": "spec/protocol/vectors/messages.json"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"canton": [
|
|
118
|
+
{
|
|
119
|
+
"note": "worked: 1000.0 at 0.003",
|
|
120
|
+
"amount": "1000.0",
|
|
121
|
+
"feeRate": "0.003",
|
|
122
|
+
"total": "10000000000000",
|
|
123
|
+
"feeBps": 30,
|
|
124
|
+
"payout": "9970089730808",
|
|
125
|
+
"fee": "29910269192",
|
|
126
|
+
"ledgerPayout": "997.0089730808",
|
|
127
|
+
"ledgerFee": "2.9910269192",
|
|
128
|
+
"evmPayout": "9970089730807"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"note": "same as EVM: 105.0 at 0.05",
|
|
132
|
+
"amount": "105.0",
|
|
133
|
+
"feeRate": "0.05",
|
|
134
|
+
"total": "1050000000000",
|
|
135
|
+
"feeBps": 500,
|
|
136
|
+
"payout": "1000000000000",
|
|
137
|
+
"fee": "50000000000",
|
|
138
|
+
"ledgerPayout": "100.0",
|
|
139
|
+
"ledgerFee": "5.0",
|
|
140
|
+
"evmPayout": "1000000000000"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"note": "tie, q even, kept",
|
|
144
|
+
"amount": "100.8000000063",
|
|
145
|
+
"feeRate": "0.008",
|
|
146
|
+
"total": "1008000000063",
|
|
147
|
+
"feeBps": 80,
|
|
148
|
+
"payout": "1000000000062",
|
|
149
|
+
"fee": "8000000001",
|
|
150
|
+
"ledgerPayout": "100.0000000062",
|
|
151
|
+
"ledgerFee": "0.8000000001",
|
|
152
|
+
"evmPayout": "1000000000062"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"note": "tie, q odd, rounded up",
|
|
156
|
+
"amount": "100.8000000189",
|
|
157
|
+
"feeRate": "0.008",
|
|
158
|
+
"total": "1008000000189",
|
|
159
|
+
"feeBps": 80,
|
|
160
|
+
"payout": "1000000000188",
|
|
161
|
+
"fee": "8000000001",
|
|
162
|
+
"ledgerPayout": "100.0000000188",
|
|
163
|
+
"ledgerFee": "0.8000000001",
|
|
164
|
+
"evmPayout": "1000000000187"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"note": "dust: 0.0000000002 at 0.1 is all payout",
|
|
168
|
+
"amount": "0.0000000002",
|
|
169
|
+
"feeRate": "0.1",
|
|
170
|
+
"total": "2",
|
|
171
|
+
"feeBps": 1000,
|
|
172
|
+
"payout": "2",
|
|
173
|
+
"fee": "0",
|
|
174
|
+
"ledgerPayout": "0.0000000002",
|
|
175
|
+
"ledgerFee": "0.0",
|
|
176
|
+
"evmPayout": "1"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "The Permit2 PermitWitnessTransferFrom typed data a maker signs to open an EVM-source intent, the Order nested as witness; the type is the stub Permit2 prepends followed by CancoreRouter.WITNESS_TYPE_STRING (spec/constants.json). Domain {Permit2, chainId, verifyingContract = PERMIT2_ADDRESS}, no version. witnessHash = hashStruct(Order) = what openFor passes to Permit2. Digests by ethers TypedDataEncoder. Generated by scripts/gen-router-vectors.mjs.",
|
|
3
|
+
"typeString": "PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,Order witness)Order(address user,uint64 originChainId,address inputToken,uint256 inputAmount,bytes32 destination,bytes32 outputAsset,uint256 minReceived,bytes32 recipient,uint64 createdAt,uint64 fillDeadline,uint16 feeBps)TokenPermissions(address token,uint256 amount)",
|
|
4
|
+
"types": {
|
|
5
|
+
"PermitWitnessTransferFrom": [
|
|
6
|
+
{
|
|
7
|
+
"name": "permitted",
|
|
8
|
+
"type": "TokenPermissions"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "spender",
|
|
12
|
+
"type": "address"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "nonce",
|
|
16
|
+
"type": "uint256"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "deadline",
|
|
20
|
+
"type": "uint256"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "witness",
|
|
24
|
+
"type": "Order"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"TokenPermissions": [
|
|
28
|
+
{
|
|
29
|
+
"name": "token",
|
|
30
|
+
"type": "address"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "amount",
|
|
34
|
+
"type": "uint256"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"Order": [
|
|
38
|
+
{
|
|
39
|
+
"name": "user",
|
|
40
|
+
"type": "address"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "originChainId",
|
|
44
|
+
"type": "uint64"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "inputToken",
|
|
48
|
+
"type": "address"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "inputAmount",
|
|
52
|
+
"type": "uint256"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "destination",
|
|
56
|
+
"type": "bytes32"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "outputAsset",
|
|
60
|
+
"type": "bytes32"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "minReceived",
|
|
64
|
+
"type": "uint256"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "recipient",
|
|
68
|
+
"type": "bytes32"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "createdAt",
|
|
72
|
+
"type": "uint64"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "fillDeadline",
|
|
76
|
+
"type": "uint64"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "feeBps",
|
|
80
|
+
"type": "uint16"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"vectors": [
|
|
85
|
+
{
|
|
86
|
+
"note": "the fixture order: permitted = its input token and total, spender = its source router, deadline = its fillDeadline (the router refuses a permit that outlives the order)",
|
|
87
|
+
"chainId": "11155111",
|
|
88
|
+
"verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
89
|
+
"message": {
|
|
90
|
+
"permitted": {
|
|
91
|
+
"token": "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
|
|
92
|
+
"amount": "1003000000"
|
|
93
|
+
},
|
|
94
|
+
"spender": "0x00000000000000000000000000000000cafe0001",
|
|
95
|
+
"nonce": "1",
|
|
96
|
+
"deadline": "1790000600",
|
|
97
|
+
"witness": {
|
|
98
|
+
"user": "0xa11ce00000000000000000000000000000000001",
|
|
99
|
+
"originChainId": "11155111",
|
|
100
|
+
"inputToken": "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
|
|
101
|
+
"inputAmount": "1003000000",
|
|
102
|
+
"destination": "0x0000000000000000000000000000000000000000000000000000000000066eee",
|
|
103
|
+
"outputAsset": "0x00000000000000000000000075faf114eafb1bdbe2f0316df893fd58ce46aa4d",
|
|
104
|
+
"minReceived": "999000000",
|
|
105
|
+
"recipient": "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
|
|
106
|
+
"createdAt": "1790000000",
|
|
107
|
+
"fillDeadline": "1790000600",
|
|
108
|
+
"feeBps": "30"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"witnessHash": "0xb6285b17e62a3a481c20b8fe84e0821e0e633d865da540d4a56014c3f3304f97",
|
|
112
|
+
"digest": "0x080bd6f1e7e1680a54410b6c8db48ffb4921127cb65c3f94c7d8573200a97678"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"note": "the reverse route on arbitrum sepolia, a large unordered nonce",
|
|
116
|
+
"chainId": "421614",
|
|
117
|
+
"verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
118
|
+
"message": {
|
|
119
|
+
"permitted": {
|
|
120
|
+
"token": "0x75faf114eafb1bdbe2f0316df893fd58ce46aa4d",
|
|
121
|
+
"amount": "110000000"
|
|
122
|
+
},
|
|
123
|
+
"spender": "0x00000000000000000000000000000000cafe0002",
|
|
124
|
+
"nonce": "1790000000123456789",
|
|
125
|
+
"deadline": "1790000600",
|
|
126
|
+
"witness": {
|
|
127
|
+
"user": "0xa11ce00000000000000000000000000000000001",
|
|
128
|
+
"originChainId": "421614",
|
|
129
|
+
"inputToken": "0x75faf114eafb1bdbe2f0316df893fd58ce46aa4d",
|
|
130
|
+
"inputAmount": "110000000",
|
|
131
|
+
"destination": "0x0000000000000000000000000000000000000000000000000000000000aa36a7",
|
|
132
|
+
"outputAsset": "0x0000000000000000000000001c7d4b196cb0c7b01d743fbc6116a902379c7238",
|
|
133
|
+
"minReceived": "100000000",
|
|
134
|
+
"recipient": "0x000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e",
|
|
135
|
+
"createdAt": "1790000000",
|
|
136
|
+
"fillDeadline": "1790000600",
|
|
137
|
+
"feeBps": "1000"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"witnessHash": "0xdb46592de997d0befae7171d0a017c57aa24e62b60a1c82932482dbf3c22a0fa",
|
|
141
|
+
"digest": "0x8f8a53aa01d9f9111e2438bb30928160c3e703145b62f2d5d6eceb7cf0abbbba"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|