|
3 | 3 | Use this file for field semantics, order-shape mapping, defaults, validation, and local normalization. |
4 | 4 |
|
5 | 5 | 1. Required: `chainId`, `swapper`, `input.token`, `input.amount`, `output.token`. |
6 | | -2. Optional: `input.maxAmount`, `nonce`, `start`, `deadline`, `epoch`, `slippage`, `output.limit`, `output.triggerLower`, `output.triggerUpper`, `output.recipient`. |
| 6 | +2. Optional: `input.maxAmount`, `nonce`, `start`, `deadline`, `epoch`, `freshness`, `slippage`, `output.limit`, `output.triggerLower`, `output.triggerUpper`, `output.recipient`. |
7 | 7 | 3. Common order-shape fields: market = `output.limit = 0`; limit = `output.limit > 0`; stop-loss = `output.triggerLower > 0`; take-profit = `output.triggerUpper > 0`; delayed-start = future `start`; chunked or TWAP = `input.amount < input.maxAmount`; recurring chunked = `epoch > 0`; back to native output = `output.token = 0x0000000000000000000000000000000000000000`. |
8 | 8 | 4. `input.amount` is the fixed per-chunk size. `input.maxAmount` is the total requested size. If omitted, it defaults to `input.amount`. If it is not divisible by `input.amount`, round it down to a whole number of chunks before building `typedData`. |
9 | 9 | 5. `output.limit`, `output.triggerLower`, and `output.triggerUpper` are output-token amounts per chunk, encoded in the output token's smallest unit. When `output.token` is an ERC-20, encode them in that token's decimals. When `output.token = 0x0000000000000000000000000000000000000000`, encode them in native `wei` with 18 decimals. |
10 | 10 | 6. Input and output units are independent. Always encode `input.amount` and `input.maxAmount` in `input.token` decimals, even for back-to-native orders; encode `output.limit`, `output.triggerLower`, and `output.triggerUpper` in `output.token` units. For example, USDC-to-native uses USDC decimals for input amounts and native `wei` for output triggers. |
11 | 11 | 7. Future `start` delays the first fill. `epoch` is the delay between chunks, but it is not exact: each chunk can fill anywhere inside its epoch window, only once. Large `epoch` is not a delayed order by itself. |
12 | 12 | 8. Chunked orders should use `epoch > 0`; with `epoch = 0`, only the first chunk can fill. |
13 | 13 | 9. Defaults: |
14 | | - `input.maxAmount = input.amount`, `nonce = now`, `start = now`, `epoch = 0` for single orders, `epoch = 60` for chunked orders, `deadline = start + 300 + chunkCount * epoch`, `slippage = 500`, `output.limit = 0`, `output.triggerLower = 0`, `output.triggerUpper = 0`, `output.recipient = swapper`. |
| 14 | + `input.maxAmount = input.amount`, `nonce = now`, `start = now`, `epoch = 0` for single orders, `epoch = 60` for chunked orders, `freshness = 50`, `deadline = start + 300 + chunkCount * epoch`, `slippage = 500`, `output.limit = 0`, `output.triggerLower = 0`, `output.triggerUpper = 0`, `output.recipient = swapper`. When replacing `<EPOCH_SECONDS>` for a recurring order, choose a value greater than `freshness`. |
15 | 15 | 10. Validation: |
16 | | - `start != 0`, `input.amount != 0`, `input.amount <= input.maxAmount`, `input.token != output.token`, `output.triggerLower <= output.triggerUpper` when `triggerUpper != 0`, `slippage <= 5000`, non-zero `epoch >= 31`, and `freshness = 30 < epoch` when `epoch != 0`. |
| 16 | + `start != 0`, `input.amount != 0`, `input.amount <= input.maxAmount`, `input.token != output.token`, `output.triggerLower <= output.triggerUpper` when `triggerUpper != 0`, `slippage <= 5000`, `freshness != 0`, `freshness < epoch` when `epoch != 0`, and non-zero `epoch >= 60`. |
17 | 17 | 11. Higher slippage is still protected by oracle pricing and offchain executors. |
18 | 18 | 12. `output.recipient` is dangerous to change away from `swapper`. |
19 | 19 | 13. Native input is not supported. Wrap to WNATIVE first. Native output, including back-to-native orders, is supported directly with `output.token = 0x0000000000000000000000000000000000000000`. |
|
0 commit comments