CKBSwap 恒定乘积 AMM 约束CKBSwap Constant-product AMM Constraints
来源:ckbswap/contracts @b7cd845 contracts/swap/src/main.rs、crates/protocol/src/lib.rs · 一个二进制、三种角色(args[0]) · 仓库未公布部署Source: ckbswap/contracts @b7cd845 contracts/swap/src/main.rs, crates/protocol/src/lib.rs · one binary, three roles (args[0]) · no deployment published
给 AI agent:For AI agents: ckbswap_amm.md · llms.txt
0 → State创建池(genesis)Create a pool (genesis)
Inputs 输入Inputs
inputs[0]任意 cell;其 CellInput 决定 pool_idany cell; its CellInput determines pool_id
Outputs 输出Outputs
output 0:Stateoutput 0: StateCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: 500 CKB,
data: CSWP\x01 ‖ nonce 0 ‖ asset0 ‖ asset1 ‖ 0 ‖ 0 ‖ 0
}
output 1..:每个 xUDT 资产的 reserveoutputs 1..: one reserve per xUDT assetCell{
lock: SWAP{ args: 0x02 ‖ pool_id ‖ asset },
type: xUDT{ args: … ‖ 00000000 },
capacity: 200 CKB,
data: 0u128
}
script.args(三种角色共用 code_hash)script.args (three roles share one code_hash)
role1B
pool_id32B
asset32B (role 2)
- role1B0 = state type、1 = state lock、2 = xUDT reserve lock0 = state type, 1 = state lock, 2 = xUDT reserve lock0 / 1 → 共 33B;2 → 共 65B0 / 1 → 33B total; 2 → 65B total5
- pool_id32Bckb_hash(创建交易 inputs[0] ‖ u64 LE 0)ckb_hash(creating tx inputs[0] ‖ u64 LE 0)genesis 时校验checked at genesis14
- asset32B (role 2)该 reserve 的 xUDT type hashthe reserve’s xUDT type hash5
role0x00
pool_id0x… (32B)
State cell data(恰好 125B,LE)State cell data (exactly 125B, LE)
magic5B
nonce8B u64
asset032B
asset132B
reserve016B u128
reserve116B u128
total_lp16B u128
- magic5B"CSWP" ‖ 0x01"CSWP" ‖ 0x01完全相等exact5
- nonce8B u64每次动作 +1+1 per action9
- asset032BCKB = 全零,否则 xUDT type hashCKB = all zero, else xUDT type hashasset0 < asset1(字节序)asset0 < asset1 (byte order)9
- asset132B9
- reserve016B u128≤ 2^112 − 1≤ 2^112 − 19
- reserve116B u128≤ 2^112 − 1≤ 2^112 − 19
- total_lp16B u128含永久锁定的 1000includes the permanently locked 10000 ⇒ 储备为 0;否则 ≥ 1000 且储备 > 00 ⇒ reserves 0; else ≥ 1000 and reserves > 09
magic0x4353575001
nonce0x0100000000000000
asset00x00…00 (CKB)
asset10x0101…01
reserve00x40420f00000000000000000000000000 (1 000 000)
reserve10x80841e00000000000000000000000000 (2 000 000)
total_lp0x45941500000000000000000000000000 (1 414 213)
示例为协议单元测试 pool()(首次 ADD 1 000 000 / 2 000 000 之后)构造的值,非链上数据Example values are built from the protocol unit test pool() (after the first ADD 1 000 000 / 2 000 000), not on-chain data
限制Constraints
- type argsrole 0 ‖ pool_id,共 33B;role/长度组合非法 → 5role 0 ‖ pool_id, 33B; invalid role/length combination → 55
- 结构structure同 type 输出恰好在 output 0;同 type 输入 ≤ 1;同 code_hash 的 state 输出全交易恰好 1 个,state 输入数 = 本 pool 输入数same-type outputs are exactly [0]; ≤ 1 same-type input; exactly one state output tx-wide for this code_hash, and state input count = this pool’s input count11
- output 0lock = role 1 ‖ pool_id;capacity = 500 CKB + (asset0 为 CKB 时 reserve0)lock = role 1 ‖ pool_id; capacity = 500 CKB + (reserve0 if asset0 is CKB)12
- reserve 输出reserve outputs每个 xUDT 资产恰好一个 role 2 lock 的 cell,依资产顺序位于 output 1、2;全交易该 pool 的 role 2 cell 数 = xUDT 资产数one role-2 cell per xUDT asset, at outputs 1, 2 in asset order; tx-wide role-2 cell count for the pool = number of xUDT assets11
- reserve cellreserve celltype 为规范 xUDT(code_hash 0x50bd…1b95、hash_type data1、36B args 以 4 个 0 结尾)、hash = asset、≠ LP token、data 恰好 16B = reserve、capacity = 200 CKBtype is canonical xUDT (code_hash 0x50bd…1b95, hash_type data1, 36B args ending in four zero bytes), hash = asset, ≠ LP token, data exactly 16B = reserve, capacity = 200 CKB13
- LPasset0 / asset1 都不能是本 pool 的 LP tokenneither asset may be the pool’s own LP token13
- pool_id= ckb_hash(序列化 inputs[0] ‖ u64 LE 0)= ckb_hash(serialized inputs[0] ‖ u64 LE 0)14
- state= State::new(asset0, asset1):nonce、储备、total_lp 全 0= State::new(asset0, asset1): nonce, reserves, total_lp all 014
- LP输入与输出中本 pool 的 LP token 总量均为 0total LP token of this pool is 0 in both inputs and outputs14
- state data125B、magic、asset0 < asset1 等合法性125B, magic, asset0 < asset1 and other validity5 / 9
State → State (ADD)添加流动性Add liquidity
Inputs 输入Inputs
State + reserve(同一前序交易,reserve 索引 1、2)State + reserves (same previous tx, reserve indices 1, 2)Cell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: 500 CKB + reserve0?,
data: … ‖ reserve0 ‖ reserve1 ‖ total_lp
}
actorCell{ lock: hash = actor } + 存入的资产Cell{ lock: hash = actor } + deposited assets
Outputs 输出Outputs
output 0:Stateoutput 0: StateCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: + in0 (CKB pool),
data: nonce + 1 ‖ … ‖ reserve0 + in0 ‖ reserve1 + in1 ‖ total_lp + lp_mint
}
reservereservesCell{
lock: SWAP{ args: 0x02 ‖ pool_id ‖ asset },
type: xUDT{ args: … ‖ 00000000 },
capacity: 200 CKB,
data: reserve + in
}
actorLP token + lp_mintLP token + lp_mint
witness[state 输入].input_type = Action(恰好 114B,LE)witness[state input].input_type = Action (exactly 114B, LE)
op1B
side1B
actor32B
amount016B u128
amount116B u128
min016B u128
min116B u128
min_lp16B u128
- op1B0 ADD、1 REMOVE、2 SWAP_IN、3 SWAP_OUT0 ADD, 1 REMOVE, 2 SWAP_IN, 3 SWAP_OUT5
- side1Bswap 方向:0 = 0→1,1 = 1→0;流动性动作须为 0swap direction: 0 = 0→1, 1 = 1→0; liquidity actions require 0≤ 1≤ 15 / 7
- actor32B动作方 lock hashactor lock hash出现在输入中appears among inputs10
- amount016B u1287
- amount116B u1287
- min016B u1288
- min116B u1288
- min_lp16B u1288
op0x02 (SWAP_IN)
side0x00
actor0x0303…03
amount00x10270000000000000000000000000000 (10 000)
amount1 / min0 / min1 / min_lp0x00…
示例:单元测试 fee_stays_in_pool 的 SWAP_IN 10 000 → out1 = 19 743Example: unit test fee_stays_in_pool, SWAP_IN 10 000 → out1 = 19 743
witness[state 输入].input_type = Action{ op: 0 ADD }witness[state input].input_type = Action{ op: 0 ADD }
限制Constraints
- type argsrole 0 ‖ pool_id,共 33B;role/长度组合非法 → 5role 0 ‖ pool_id, 33B; invalid role/length combination → 55
- 结构structure同 type 输出恰好在 output 0;同 type 输入 ≤ 1;同 code_hash 的 state 输出全交易恰好 1 个,state 输入数 = 本 pool 输入数same-type outputs are exactly [0]; ≤ 1 same-type input; exactly one state output tx-wide for this code_hash, and state input count = this pool’s input count11
- output 0lock = role 1 ‖ pool_id;capacity = 500 CKB + (asset0 为 CKB 时 reserve0)lock = role 1 ‖ pool_id; capacity = 500 CKB + (reserve0 if asset0 is CKB)12
- reserve 输出reserve outputs每个 xUDT 资产恰好一个 role 2 lock 的 cell,依资产顺序位于 output 1、2;全交易该 pool 的 role 2 cell 数 = xUDT 资产数one role-2 cell per xUDT asset, at outputs 1, 2 in asset order; tx-wide role-2 cell count for the pool = number of xUDT assets11
- reserve cellreserve celltype 为规范 xUDT(code_hash 0x50bd…1b95、hash_type data1、36B args 以 4 个 0 结尾)、hash = asset、≠ LP token、data 恰好 16B = reserve、capacity = 200 CKBtype is canonical xUDT (code_hash 0x50bd…1b95, hash_type data1, 36B args ending in four zero bytes), hash = asset, ≠ LP token, data exactly 16B = reserve, capacity = 200 CKB13
- LPasset0 / asset1 都不能是本 pool 的 LP tokenneither asset may be the pool’s own LP token13
- 输入 stateinput statelock = role 1、capacity 公式;reserve 输入与 state 来自同一 tx,索引 1、2lock = role 1, capacity formula; reserve inputs come from the same tx as the state, at indices 1, 212 / 11
- witnessstate 输入索引处的 WitnessArgs.input_type 存在且恰好 114BWitnessArgs.input_type at the state input index exists and is exactly 114B5
- actorlock hash 出现在输入中lock hash appears among inputs10
- 数量amountsside = 0,amount0 / amount1 ∈ (0, 2^112)side = 0, amount0 / amount1 ∈ (0, 2^112)7
- 首次first depositroot = ⌊√(a0·a1)⌋ > 1000;lp_mint = root − 1000;total_lp = rootroot = ⌊√(a0·a1)⌋ > 1000; lp_mint = root − 1000; total_lp = root7
- 后续later deposits按储备比例取 (in0, in1);lp_mint = min(in0·L/r0, in1·L/r1) > 0take (in0, in1) at the reserve ratio; lp_mint = min(in0·L/r0, in1·L/r1) > 07
- 滑点slippagein0 ≥ min0、in1 ≥ min1、lp_mint ≥ min_lpin0 ≥ min0, in1 ≥ min1, lp_mint ≥ min_lp8
- 状态state输出 state = apply(输入 state, action)output state = apply(input state, action)9
- actor 余额actor balancesxUDT:新 + in = 旧 + out;CKB:新 + in + 手续费 ≥ 旧 + outxUDT: new + in = old + out; CKB: new + in + fee ≥ old + out13 / 12
- LP全交易与 actor:新 + burn = 旧 + minttx-wide and for the actor: new + burn = old + mint13
- 算术arithmetic溢出 / 除零overflow / divide by zero6
State → State (REMOVE)移除流动性Remove liquidity
Inputs 输入Inputs
State + reserveState + reservesCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: …,
data: … ‖ reserve0 ‖ reserve1 ‖ total_lp
}
actorCell{ lock: hash = actor } + LP tokenCell{ lock: hash = actor } + LP token
Outputs 输出Outputs
output 0:Stateoutput 0: StateCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: …,
data: nonce + 1 ‖ … ‖ reserve0 − out0 ‖ reserve1 − out1 ‖ total_lp − burn
}
actor+ out0、+ out1;LP − burn+ out0, + out1; LP − burn
witness[state 输入].input_type = Action(恰好 114B,LE)witness[state input].input_type = Action (exactly 114B, LE)
op1B
side1B
actor32B
amount016B u128
amount116B u128
min016B u128
min116B u128
min_lp16B u128
- op1B0 ADD、1 REMOVE、2 SWAP_IN、3 SWAP_OUT0 ADD, 1 REMOVE, 2 SWAP_IN, 3 SWAP_OUT5
- side1Bswap 方向:0 = 0→1,1 = 1→0;流动性动作须为 0swap direction: 0 = 0→1, 1 = 1→0; liquidity actions require 0≤ 1≤ 15 / 7
- actor32B动作方 lock hashactor lock hash出现在输入中appears among inputs10
- amount016B u1287
- amount116B u1287
- min016B u1288
- min116B u1288
- min_lp16B u1288
op0x02 (SWAP_IN)
side0x00
actor0x0303…03
amount00x10270000000000000000000000000000 (10 000)
amount1 / min0 / min1 / min_lp0x00…
示例:单元测试 fee_stays_in_pool 的 SWAP_IN 10 000 → out1 = 19 743Example: unit test fee_stays_in_pool, SWAP_IN 10 000 → out1 = 19 743
witness[state 输入].input_type = Action{ op: 1 REMOVE, amount0: burn }witness[state input].input_type = Action{ op: 1 REMOVE, amount0: burn }
限制Constraints
- type argsrole 0 ‖ pool_id,共 33B;role/长度组合非法 → 5role 0 ‖ pool_id, 33B; invalid role/length combination → 55
- 结构structure同 type 输出恰好在 output 0;同 type 输入 ≤ 1;同 code_hash 的 state 输出全交易恰好 1 个,state 输入数 = 本 pool 输入数same-type outputs are exactly [0]; ≤ 1 same-type input; exactly one state output tx-wide for this code_hash, and state input count = this pool’s input count11
- output 0lock = role 1 ‖ pool_id;capacity = 500 CKB + (asset0 为 CKB 时 reserve0)lock = role 1 ‖ pool_id; capacity = 500 CKB + (reserve0 if asset0 is CKB)12
- reserve 输出reserve outputs每个 xUDT 资产恰好一个 role 2 lock 的 cell,依资产顺序位于 output 1、2;全交易该 pool 的 role 2 cell 数 = xUDT 资产数one role-2 cell per xUDT asset, at outputs 1, 2 in asset order; tx-wide role-2 cell count for the pool = number of xUDT assets11
- reserve cellreserve celltype 为规范 xUDT(code_hash 0x50bd…1b95、hash_type data1、36B args 以 4 个 0 结尾)、hash = asset、≠ LP token、data 恰好 16B = reserve、capacity = 200 CKBtype is canonical xUDT (code_hash 0x50bd…1b95, hash_type data1, 36B args ending in four zero bytes), hash = asset, ≠ LP token, data exactly 16B = reserve, capacity = 200 CKB13
- LPasset0 / asset1 都不能是本 pool 的 LP tokenneither asset may be the pool’s own LP token13
- 参数parametersside = 0、amount1 = 0、min_lp = 0、0 < burn ≤ total_lp − 1000side = 0, amount1 = 0, min_lp = 0, 0 < burn ≤ total_lp − 10007
- 返还returnsout_i = ⌊burn · r_i / total_lp⌋ > 0out_i = ⌊burn · r_i / total_lp⌋ > 07
- 滑点slippageout0 ≥ min0、out1 ≥ min1out0 ≥ min0, out1 ≥ min18
- 状态 / 余额state / balances同 ADD:apply 相等、actor 与 LP 余额守恒as ADD: apply equality, actor and LP balance conservation9 / 12 / 13
- actorlock hash 出现在输入中lock hash appears among inputs10
State → State (SWAP)兑换(SWAP_IN 固定输入 / SWAP_OUT 固定输出)Swap (SWAP_IN exact input / SWAP_OUT exact output)
Inputs 输入Inputs
State + reserveState + reservesCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: …,
data: … ‖ r_in ‖ r_out ‖ total_lp
}
actorCell{ lock: hash = actor } + 输入资产Cell{ lock: hash = actor } + input asset
Outputs 输出Outputs
output 0:Stateoutput 0: StateCell{
lock: SWAP{ args: 0x01 ‖ pool_id },
type: SWAP{ args: 0x00 ‖ pool_id },
capacity: …,
data: nonce + 1 ‖ … ‖ r_in + input ‖ r_out − output ‖ total_lp
}
actor+ output+ output
witness[state 输入].input_type = Action(恰好 114B,LE)witness[state input].input_type = Action (exactly 114B, LE)
op1B
side1B
actor32B
amount016B u128
amount116B u128
min016B u128
min116B u128
min_lp16B u128
- op1B0 ADD、1 REMOVE、2 SWAP_IN、3 SWAP_OUT0 ADD, 1 REMOVE, 2 SWAP_IN, 3 SWAP_OUT5
- side1Bswap 方向:0 = 0→1,1 = 1→0;流动性动作须为 0swap direction: 0 = 0→1, 1 = 1→0; liquidity actions require 0≤ 1≤ 15 / 7
- actor32B动作方 lock hashactor lock hash出现在输入中appears among inputs10
- amount016B u1287
- amount116B u1287
- min016B u1288
- min116B u1288
- min_lp16B u1288
op0x02 (SWAP_IN)
side0x00
actor0x0303…03
amount00x10270000000000000000000000000000 (10 000)
amount1 / min0 / min1 / min_lp0x00…
示例:单元测试 fee_stays_in_pool 的 SWAP_IN 10 000 → out1 = 19 743Example: unit test fee_stays_in_pool, SWAP_IN 10 000 → out1 = 19 743
witness[state 输入].input_type = Action{ op: 2 | 3, side }witness[state input].input_type = Action{ op: 2 | 3, side }
限制Constraints
- type argsrole 0 ‖ pool_id,共 33B;role/长度组合非法 → 5role 0 ‖ pool_id, 33B; invalid role/length combination → 55
- 结构structure同 type 输出恰好在 output 0;同 type 输入 ≤ 1;同 code_hash 的 state 输出全交易恰好 1 个,state 输入数 = 本 pool 输入数same-type outputs are exactly [0]; ≤ 1 same-type input; exactly one state output tx-wide for this code_hash, and state input count = this pool’s input count11
- output 0lock = role 1 ‖ pool_id;capacity = 500 CKB + (asset0 为 CKB 时 reserve0)lock = role 1 ‖ pool_id; capacity = 500 CKB + (reserve0 if asset0 is CKB)12
- reserve 输出reserve outputs每个 xUDT 资产恰好一个 role 2 lock 的 cell,依资产顺序位于 output 1、2;全交易该 pool 的 role 2 cell 数 = xUDT 资产数one role-2 cell per xUDT asset, at outputs 1, 2 in asset order; tx-wide role-2 cell count for the pool = number of xUDT assets11
- reserve cellreserve celltype 为规范 xUDT(code_hash 0x50bd…1b95、hash_type data1、36B args 以 4 个 0 结尾)、hash = asset、≠ LP token、data 恰好 16B = reserve、capacity = 200 CKBtype is canonical xUDT (code_hash 0x50bd…1b95, hash_type data1, 36B args ending in four zero bytes), hash = asset, ≠ LP token, data exactly 16B = reserve, capacity = 200 CKB13
- LPasset0 / asset1 都不能是本 pool 的 LP tokenneither asset may be the pool’s own LP token13
- 参数parametersmin1 = 0、min_lp = 0;SWAP_IN 还要求 amount1 = 0;SWAP_OUT 要求 min0 = 0min1 = 0, min_lp = 0; SWAP_IN also needs amount1 = 0; SWAP_OUT needs min0 = 05
- SWAP_INoutput = ⌊in·997·r_out / (r_in·1000 + in·997)⌋,0 < output < r_out,in ≤ 2^112 − 1output = ⌊in·997·r_out / (r_in·1000 + in·997)⌋, 0 < output < r_out, in ≤ 2^112 − 17
- SWAP_INoutput ≥ min0output ≥ min08
- SWAP_OUTinput = ⌊r_in·out·1000 / ((r_out − out)·997)⌋ + 1 ≤ 2^112 − 1,0 < out < r_outinput = ⌊r_in·out·1000 / ((r_out − out)·997)⌋ + 1 ≤ 2^112 − 1, 0 < out < r_out7
- SWAP_OUTinput ≤ amount1(最大输入)input ≤ amount1 (max input)8
- 不变式invariant(r0′·1000 − in0·3)(r1′·1000 − in1·3) ≥ r0·r1·10^6(0.3% 费用留在池内)(r0′·1000 − in0·3)(r1′·1000 − in1·3) ≥ r0·r1·10^6 (0.3% fee stays in the pool)9
- 状态 / 余额state / balancesapply 相等、actor 余额守恒;total_lp 不变apply equality, actor balance conservation; total_lp unchanged9 / 12 / 13
- actorlock hash 出现在输入中lock hash appears among inputs10
lock rolesState lock(role 1)与 reserve lock(role 2)State lock (role 1) and reserve lock (role 2)
Inputs 输入Inputs
role 1 lock 组role 1 lock groupCell{ lock: SWAP{ args: 0x01 ‖ pool_id }, type: SWAP{ 0x00 ‖ pool_id } }
role 2 lock 组role 2 lock groupCell{ lock: SWAP{ args: 0x02 ‖ pool_id ‖ asset } }
Outputs 输出Outputs
由 state type 约束constrained by the state typelock 本身不检查输出the locks check no outputs
script.args(三种角色共用 code_hash)script.args (three roles share one code_hash)
role1B
pool_id32B
asset32B (role 2)
- role1B0 = state type、1 = state lock、2 = xUDT reserve lock0 = state type, 1 = state lock, 2 = xUDT reserve lock0 / 1 → 共 33B;2 → 共 65B0 / 1 → 33B total; 2 → 65B total5
- pool_id32Bckb_hash(创建交易 inputs[0] ‖ u64 LE 0)ckb_hash(creating tx inputs[0] ‖ u64 LE 0)genesis 时校验checked at genesis14
- asset32B (role 2)该 reserve 的 xUDT type hashthe reserve’s xUDT type hash5
role0x00
pool_id0x… (32B)
限制Constraints
- role 1args 33B;group 恰好 1 个输入,且其 type = role 0 ‖ 同 pool_idargs 33B; exactly 1 group input whose type = role 0 ‖ same pool_id11
- role 2args 65B;交易输入中恰好 1 个 cell 的 type = role 0 ‖ pool_idargs 65B; exactly 1 tx input has type = role 0 ‖ pool_id10
- args其他 role / 长度组合any other role / length combination5
- 签名signature两个 lock 都不检查签名或 witness;安全性完全来自 state type 的校验neither lock checks a signature or witness; safety comes entirely from the state type checks—
部署与来源Deployments & source 未核验unverified
源码source
ckbswap/contracts@b7cd8458 · contracts/swap/src/main.rs · crates/protocol/src/lib.rs · README.md (commit read when writing this spec (default-branch HEAD, 2026-10-27). The repository publishes no deployment (README: no deployment configuration, transaction builder or CKB-VM integration tests), so there is no on-chain code_hash and no test tx.)
二进制核验binary check
未核验unverified no deployment resolved on chain
未在链上找到部署no on-chain deployment resolved
链上数据核对于 on-chain data checked 2026-11-12
错误码(crates/protocol/src/lib.rs Error):5 Encoding、6 Arithmetic、7 Amount、8 Slippage、9 Invariant、10 Authorization、11 Structure、12 Capacity、13 Token、14 Genesis。所有 syscall 失败经 sys() 映射为 11 Structure。Error codes (crates/protocol/src/lib.rs Error): 5 Encoding, 6 Arithmetic, 7 Amount, 8 Slippage, 9 Invariant, 10 Authorization, 11 Structure, 12 Capacity, 13 Token, 14 Genesis. Every syscall failure is mapped to 11 Structure by sys().
没有销毁池的路径:state type 要求同 type 输出恰好为 [0],池一旦创建只能继续更新。全交易只允许一个 state 输出(同 code_hash),所以多个池不能在同一交易中更新。There is no pool-destruction path: the state type requires same-type outputs to be exactly [0], so a pool can only be updated after creation. Only one state output (same code_hash) is allowed per tx, so several pools cannot be updated in one transaction.
LP token = xUDT(code_hash 0x50bd…1b95、data1),args = hash(role 1 state lock) ‖ 00000000;铸造依赖 xUDT owner 模式(state cell 在输入中)。XUDT_CODE_HASH 写死在协议 crate 中。LP token = xUDT (code_hash 0x50bd…1b95, data1), args = hash(role 1 state lock) ‖ 00000000; minting relies on xUDT owner mode (the state cell is an input). XUDT_CODE_HASH is hard-coded in the protocol crate.
部署:README 明确说明仓库不含部署配置、交易构造器或 CKB-VM 集成测试;未找到官方 code_hash,因此本页 match 为空、无测试交易。plugin 在 JS 中重算 apply(已用协议单元测试的数值核对),并标注余额与 reserve 布局为未检查。Deployment: the README says the repo contains no deployment configuration, transaction builder or CKB-VM integration tests; no official code_hash was found, so match is empty and there are no test txs. The plugin recomputes apply in JS (cross-checked against the protocol unit-test values) and marks balances and reserve layout as not checked.
没有销毁池的路径:state type 要求同 type 输出恰好为 [0],池一旦创建只能继续更新。全交易只允许一个 state 输出(同 code_hash),所以多个池不能在同一交易中更新。There is no pool-destruction path: the state type requires same-type outputs to be exactly [0], so a pool can only be updated after creation. Only one state output (same code_hash) is allowed per tx, so several pools cannot be updated in one transaction.
LP token = xUDT(code_hash 0x50bd…1b95、data1),args = hash(role 1 state lock) ‖ 00000000;铸造依赖 xUDT owner 模式(state cell 在输入中)。XUDT_CODE_HASH 写死在协议 crate 中。LP token = xUDT (code_hash 0x50bd…1b95, data1), args = hash(role 1 state lock) ‖ 00000000; minting relies on xUDT owner mode (the state cell is an input). XUDT_CODE_HASH is hard-coded in the protocol crate.
部署:README 明确说明仓库不含部署配置、交易构造器或 CKB-VM 集成测试;未找到官方 code_hash,因此本页 match 为空、无测试交易。plugin 在 JS 中重算 apply(已用协议单元测试的数值核对),并标注余额与 reserve 布局为未检查。Deployment: the README says the repo contains no deployment configuration, transaction builder or CKB-VM integration tests; no official code_hash was found, so match is empty and there are no test txs. The plugin recomputes apply in JS (cross-checked against the protocol unit-test values) and marks balances and reserve layout as not checked.