iCKB limit_order(lock + type)约束iCKB limit_order (lock + type) Constraints
来源:ickb/contracts / scripts/contracts/limit_order/src · mainnet code_hash 0x49df…254a(data1)Source: ickb/contracts / scripts/contracts/limit_order/src · mainnet code_hash 0x49df…254a (data1)
iCKB
- 官网Websiteickb.org
- GitHubGitHubgithub.com/ickb
来源:Source: ickb GitHub org profile; ickb/contracts README
Mint挂单:order + masterPlace: order + master
Inputs 输入Inputs
用户资产user fundsCell{ lock: user, type: UDT? }
➜
Outputs 输出Outputs
order(第 i 个输出)order (output i)Cell{
lock: LIMIT_ORDER,
type: UDT,
data: udt u128 ‖ action=0 ‖ 0×32 ‖ master_distance i32 ‖ OrderInfo
}
master(第 i + distance 个输出)master (output i + distance)Cell{ lock: user, type: LIMIT_ORDER }
order data(89B)order data (89B)
udt_amount16B
action4B
tx_hash | padding32B
index | distance4B
ckb_to_udt16B
udt_to_ckb16B
ckb_min_match_log1B
- udt_amount 16B u128 LE data 恰 89Bdata exactly 89B (4)
- action 4B 0 mint / 1 match0 mint / 1 match ∈ {0,1} (7)
- tx_hash | padding 32B match:master OutPoint.tx_hash;mint:全 0match: master OutPoint.tx_hash; mint: zeros mint 时全 0zeros on mint (8)
- index | distance 4B match:master index u32;mint:distance i32match: master index u32; mint: distance i32 — (21)
- ckb_to_udt 16B ckb_mul u64 ‖ udt_mul u64 同 0 或同非 0both 0 or both non-0 (9)
- udt_to_ckb 16B ckb_mul u64 ‖ udt_mul u64 至少一个方向;双向不凹at least one; not concave (11 / 12)
- ckb_min_match_log 1B 最小成交 = 2^n shannonminimum match = 2^n shannons ≤ 64 (10)
限制Constraints
- type:: order cell 必须有 UDT typeorder cell must have a UDT type (13)
- master:: 同一订单同侧至多 1 个 master / 1 个 orderper order and side at most 1 master / 1 order (6 / 14)
- cell:: 不能同时 lock = type = 本脚本not both lock and type = this script (15)
Match撮合:order → order'Match: order → order'
Inputs 输入Inputs
orderCell{ lock: LIMIT_ORDER, ckb: C, udt: U }
➜
Outputs 输出Outputs
order'Cell{ lock: LIMIT_ORDER, ckb: C', udt: U',
data: action=1, master OutPoint, same OrderInfo }
限制Constraints
- info:: OrderInfo 与 UDT type 不变OrderInfo and UDT type unchanged (16)
- direction:: CKB 减少且 UDT 不减(用 ckb_to_udt),或 UDT 减少且 CKB 不减(用 udt_to_ckb)CKB decreases and UDT doesn't (ckb_to_udt), or UDT decreases and CKB doesn't (udt_to_ckb) (17)
- value:: C·ckb_mul + U·udt_mul 不减少C·ckb_mul + U·udt_mul does not decrease (18)
- fulfilled:: 已完成方向(unoccupied CKB = 0 或 UDT = 0)不能再撮合a fulfilled side (unoccupied CKB = 0 or UDT = 0) cannot be matched again (19)
- min match:: 部分成交不得低于 2^ckb_min_match_log 等值a partial match must be ≥ 2^ckb_min_match_log in value (20)
Melt撤单:order + master 一起花费Cancel: spend order + master together
Inputs 输入Inputs
orderCell{ lock: LIMIT_ORDER }
masterCell{ lock: user(签名), type: LIMIT_ORDER }Cell{ lock: user (signs), type: LIMIT_ORDER }
➜
Outputs 输出Outputs
outputs任意any
限制Constraints
- config:: 每个订单只能是 mint / melt / match 之一each order must be exactly one of mint / melt / match (21)
部署与来源Deployments & source 已核验verified
源码source ickb/contracts@c951927e · scripts/contracts/limit_order/src (default-branch HEAD recorded at backfill 2026-10-21; spec/plugin were written from the default branch shortly before (exact read commit not recorded))
二进制核验binary check 已核验verified deployed data hash matches a binary / checksum in the repo at the recorded commit
0x49dfb6afee…4b13254a: listed in scripts/deployment/mainnet/migrations/2024-09-12-151119.json; listed in scripts/deployment/testnet/migrations/2024-09-12-141730.json; blake2b of scripts/build/release/limit_order
0x49dfb6afee…4b13254a: listed in scripts/deployment/mainnet/migrations/2024-09-12-151119.json; listed in scripts/deployment/testnet/migrations/2024-09-12-141730.json; blake2b of scripts/build/release/limit_order
| 网络network | code_hash | cell_dep | type_id args | 数据哈希data hash | 部署交易deploy tx |
|---|---|---|---|---|---|
| mainnet | 0x49dfb6afee5cc8ac4225aeea8cb8928b150caf3cd92fea33750683c74b13254a data1 | 0x621a6f38de…5d3ed165:0 dep_group | — | 0x49dfb6afee…4b13254a | 0xd730919138…29dc8f44 #14010067 |
链上数据核对于 on-chain data checked 2026-10-20
错误码:1–4 系统 · 5 NotEmptyArgs · 6 DuplicatedMaster · 7 InvalidAction · 8 NonZeroPadding · 9 InvalidRatio · 10 InvalidCkbMinMatchLog · 11 ConcaveRatio · 12 BothRatioNull · 13 MissingUdtType · 14 SameMaster · 15 ScriptMisuse · 16 DifferentInfo · 17 InvalidMatch · 18 DecreasingValue · 19 AttemptToChangeFulfilled · 20 InsufficientMatch · 21 InvalidConfigurationError codes: 1–4 syscall · 5 NotEmptyArgs · 6 DuplicatedMaster · 7 InvalidAction · 8 NonZeroPadding · 9 InvalidRatio · 10 InvalidCkbMinMatchLog · 11 ConcaveRatio · 12 BothRatioNull · 13 MissingUdtType · 14 SameMaster · 15 ScriptMisuse · 16 DifferentInfo · 17 InvalidMatch · 18 DecreasingValue · 19 AttemptToChangeFulfilled · 20 InsufficientMatch · 21 InvalidConfiguration