@wowok/agent-mcp 3.2.2 → 3.2.4
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/dist/chain-semantics/field-capability.d.ts +11 -0
- package/dist/chain-semantics/field-capability.js +1 -0
- package/dist/chain-semantics/freeze-map.d.ts +11 -0
- package/dist/chain-semantics/freeze-map.js +1 -0
- package/dist/chain-semantics/fund-flow.d.ts +10 -0
- package/dist/chain-semantics/fund-flow.js +1 -0
- package/dist/chain-semantics/guard-verbs.d.ts +22 -0
- package/dist/chain-semantics/guard-verbs.js +1 -0
- package/dist/chain-semantics/index.d.ts +10 -0
- package/dist/chain-semantics/index.js +1 -0
- package/dist/chain-semantics/object-graph.d.ts +18 -0
- package/dist/chain-semantics/object-graph.js +1 -0
- package/dist/communication/proof-reuse.d.ts +9 -0
- package/dist/communication/proof-reuse.js +1 -0
- package/dist/composition/audit.d.ts +10 -0
- package/dist/composition/audit.js +1 -0
- package/dist/composition/compile.d.ts +38 -0
- package/dist/composition/compile.js +1 -0
- package/dist/composition/materialize.d.ts +64 -0
- package/dist/composition/materialize.js +1 -0
- package/dist/composition/plan.d.ts +92 -0
- package/dist/composition/plan.js +1 -0
- package/dist/composition/reflux.d.ts +28 -0
- package/dist/composition/reflux.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/keeper/detectors.d.ts +7 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/types.d.ts +1 -1
- package/dist/keeper/types.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +31 -0
- package/dist/knowledge/arb-fund-facts.js +1 -0
- package/dist/knowledge/baselines/rules/allocation.json +44 -15
- package/dist/knowledge/baselines/rules/guard.json +27 -8
- package/dist/knowledge/baselines/rules/plan.json +161 -0
- package/dist/knowledge/baselines/semantic-facts.d.ts +12 -0
- package/dist/knowledge/baselines/semantic-facts.js +1 -0
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +13 -0
- package/dist/knowledge/service-allocation-semantics.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +17 -1
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.d.ts +6 -0
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.d.ts +1 -0
- package/dist/playbooks/service-build/service-quote.spec.js +1 -0
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +4 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +60 -0
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +56 -0
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +2 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +48 -0
- package/dist/schema/query/bi.d.ts +26 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/service-clone/index.d.ts +46 -0
- package/dist/schema/service-clone/index.js +1 -0
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +1 -0
- package/dist/schemas/bridge_operation.output.json +1 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +4 -0
- package/dist/schemas/industry_pack_operation.schema.json +4 -0
- package/dist/schemas/local_cache_operation.output.json +1 -0
- package/dist/schemas/local_history_operation.output.json +1 -0
- package/dist/schemas/local_info_operation.output.json +1 -0
- package/dist/schemas/local_mark_operation.output.json +1 -0
- package/dist/schemas/onchain_operations.output.json +2 -1
- package/dist/schemas/onchain_operations.schema.json +408 -97
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +1 -1
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +59 -59
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +133 -1
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +4 -4
- package/dist/schemas/onchain_operations_service.schema.json +187 -8
- package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
- package/dist/schemas/query_toolkit.output.json +136 -52
- package/dist/schemas/service_clone_operation.output.json +168 -0
- package/dist/schemas/service_clone_operation.schema.json +49 -0
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/service-clone.d.ts +2 -0
- package/dist/tools/handlers/service-clone.js +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.d.ts +6 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
function assert_declared_share(a,b,c,d){const e=c===undefined||c===null||c===''?d:c,f=Number(e);if(!Number['isInteger'](f))throw new Error('E-RATE-EXPLICIT:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20an\x20explicit\x20integer\x20number\x20of\x20basis\x20points\x20'+('(the\x20buyer\x20must\x20be\x20able\x20to\x20compute\x20it\x20pre-order;\x20never\x20an\x20implicit\x20remainder),\x20got\x20'+String(c)));if(f<0x0||f>0x2710)throw new Error('E-RATE-RANGE:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20within\x20[0,\x2010000],\x20got\x20'+f);return f;}function assert_explicit_recipient(a,b,c,d){if(d<=0x0)return;const e=typeof c==='string'?c['trim']():'';if(e['length']===0x0)throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20a\x20non-empty\x20explicit\x20recipient\x20'+('because\x20its\x20rate\x20is\x20'+d+'\x20>\x200.\x20A\x20blank/omitted\x20recipient\x20silently\x20falls\x20back\x20to\x20')+'Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20'+'so\x20the\x20outflow\x20would\x20go\x20to\x20whoever\x20ran\x20the\x20deploy.');if(e['toLowerCase']()['startsWith']('0x')){const f=e['slice'](0x2);if(f['length']===0x0||!/^[0-9a-f]+$/['test'](f)||/^0+$/['test'](f))throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20looks\x20like\x20an\x20address\x20but\x20carries\x20no\x20'+('identity\x20(\x22'+e+'\x22).\x20Point\x20it\x20at\x20the\x20declared\x20recipient\x20Entity\x20(a\x20Treasury/Entity\x20address\x20the\x20')+'buyer\x20can\x20see\x20pre-order).');}}export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services','DIRECT-SALES\x20DEFAULT\x20SHAPE\x20(L2):\x20this\x20IS\x20the\x20default\x20payout\x20form\x20—\x20one\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant\x27s\x20own\x20Entity.\x20No\x20platform\x20leg\x20exists,\x20and\x20nothing\x20is\x20left\x20over','If\x20the\x20merchant\x20declares\x20its\x20OWN\x20fee,\x20use\x20T-A-02\x20(an\x20explicit\x20fee\x20leg\x20to\x20an\x20explicit\x20non-empty\x20recipient)\x20instead\x20of\x20shrinking\x20this\x20leg\x20and\x20routing\x20the\x20difference\x20through\x20an\x20implicit\x20remainder\x20(L3)','A\x20BLANK\x20recipient_address\x20is\x20NOT\x20a\x20no-op:\x20it\x20resolves\x20to\x20Account.Instance().get_address(undefined),\x20the\x20logged-in/deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91)\x20—\x20so\x20this\x20template\x20pays\x20whoever\x20ran\x20the\x20deploy']},{'id':'T-A-02','name':'Merchant\x20payout\x20+\x20optional\x20declared\x20fee\x20/\x20third-party\x20leg\x20(merchant\x20keeps\x20100%\x20by\x20default)','description':'DIRECT-SALES\x20split:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20by\x20default\x20(one\x20Rate\x2010000\x20leg\x20to\x20its\x20own\x20Entity).\x20Optional\x20extra\x20legs\x20are\x20(a)\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20—\x20only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator\x20—\x20and\x20(b)\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider,\x20arbitrator,\x20partner),\x20which\x20is\x20a\x20payment\x20for\x20a\x20service,\x20not\x20platform\x20extraction.\x20Pure\x20Rate\x20mode:\x20the\x20emitted\x20sharing\x20rows\x20MUST\x20sum\x20to\x20exactly\x2010000,\x20and\x20with\x20the\x20default\x20parameters\x20they\x20are\x20a\x20single\x2010000\x20row.\x20L3\x20fee\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20buyer\x20can\x20compute\x20BEFORE\x20ordering,\x20never\x20an\x20implicit\x20remainder\x20such\x20as\x20\x27order\x20total\x20-\x20segment\x20sums\x27;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20the\x20buyer\x20can\x20see\x20pre-order\x20(a\x20blank\x20recipient\x20is\x20NOT\x20a\x20no-op\x20—\x20it\x20falls\x20back\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).\x20WoWok\x20itself\x20takes\x20nothing.','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Entity\x20that\x20receives\x20its\x20own\x20sale\x20proceeds\x20—\x20the\x20direct-sales\x20destination.\x20Required\x20and\x20never\x20blank\x20(blank\x20silently\x20routes\x20the\x20payout\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91).','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20merchant_service_fee_bps\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20Pass\x20merchant_treasury\x20if\x20the\x20merchant\x20charges\x20itself.','required':![]},{'name':'third_party_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20third_party_rate\x20(e.g.\x20the\x20logistics\x20provider\x27s\x20own\x20Treasury).\x20MUST\x20be\x20explicit\x20and\x20non-empty\x20whenever\x20third_party_rate\x20>\x200\x20—\x20same\x20blank-fallback\x20hazard\x20as\x20merchant_fee_treasury.','required':![]},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium\x20/\x20an\x20OTA\x20that\x20really\x20is\x20the\x20seller\x27s\x20counterparty).\x20WoWok\x20extracts\x20nothing\x20—\x20this\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20price,\x20never\x20a\x20platform\x20share.\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20before\x20ordering;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20third_party_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'third_party_rate','type':'number','description':'Rate\x20for\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider\x20/\x20arbitrator\x20/\x20supply-chain\x20partner),\x20default\x200.\x20Kept\x20expressible\x20on\x20purpose\x20—\x20a\x20real\x20provider\x20fee\x20is\x20a\x20payment\x20FOR\x20a\x20service\x20—\x20but\x20it\x20must\x20be\x20an\x20explicit\x20number\x20with\x20an\x20explicit\x20recipient,\x20exactly\x20like\x20the\x20merchant\x20fee.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-02','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-02','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-02','third_party_rate',a['third_party_rate'],0x0);assert_explicit_recipient('T-A-02','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-02','merchant_fee_treasury',a['merchant_fee_treasury'],c),assert_explicit_recipient('T-A-02','third_party_treasury',a['third_party_treasury'],d);const e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20third_party='+d+')'));const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&f['push']({'who':{'Entity':a['third_party_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Direct-sales\x20payout\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20third\x20party\x20(e.g.\x20logistics)\x20'+d+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)\x20—\x20a\x20Rate\x20sum\x20<\x2010000\x20with\x20no\x20Surplus\x20recipient\x20leaves\x20residual\x20balance\x20that\x20ANYONE\x20passing\x20the\x20same\x20Guard\x20can\x20claim\x20repeatedly\x20(E-2\x20/\x20finding\x20T-04)','DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','merchant_service_fee_bps\x20is\x20the\x20MERCHANT\x27s\x20own\x20fee\x20(merchant\x20IS\x20the\x20aggregator),\x20default\x200\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission\x20and\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template','third_party_rate\x20is\x20a\x20real\x20provider\x20payment\x20(logistics\x20/\x20arbitrator\x20/\x20partner),\x20not\x20platform\x20extraction;\x20keep\x20it\x20expressible,\x20but\x20name\x20the\x20payee\x20explicitly','Never\x20express\x20a\x20fee\x20as\x20an\x20implicit\x20remainder\x20(\x27the\x20merchant\x20keeps\x20whatever\x20is\x20left\x27)\x20and\x20never\x20take\x20one\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant.\x20No\x20fee\x20and\x20no\x20platform\x20leg:\x20the\x20Surplus\x20is\x20the\x20merchant\x27s\x20residual\x20of\x20a\x20mixed\x20refund/delivery\x20pool,\x20NOT\x20a\x20fee\x20mechanism','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','the\x20fix\x20is\x20cached\x20as\x20refundAmount\x20when\x20the\x20Allocator\x20is\x20added','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)','SURPLUS\x20IS\x20NOT\x20A\x20FEE:\x20Surplus\x20calls\x20balance::withdraw_all\x20(allocation.move:420),\x20so\x20a\x20fee\x20taken\x20that\x20way\x20doubles\x20as\x20draining\x20the\x20pool\x20(L3\x20constraint\x203).\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg,\x20never\x20here','The\x20Surplus\x20recipient\x20is\x20the\x20merchant\x20(the\x20counterparty\x20of\x20the\x20delivered\x20part),\x20not\x20an\x20unnamed\x20third\x20party\x20—\x20but\x20pin\x20refund_amount\x20to\x20the\x20refund\x20actually\x20owed,\x20or\x20a\x20smaller/empty\x20refund\x20lets\x20the\x20Surplus\x20leg\x20absorb\x20money\x20that\x20is\x20not\x20the\x20merchant\x27s']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20the\x20Passport\x27s\x20guard\x20result\x20is\x20hard-verified\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)','Each\x20Allocator\x20sums\x20to\x2010000\x20INDEPENDENTLY\x20—\x20the\x20Rate-total\x20invariant\x20is\x20per\x20Allocator,\x20not\x20across\x20Allocators,\x20and\x20each\x20of\x20the\x20two\x20paths\x20pays\x20ONE\x20recipient\x20the\x20full\x20amount\x20(no\x20split,\x20no\x20platform\x20leg,\x20no\x20residual)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order).\x20DIRECT-SALES\x20default:\x20BOTH\x20tiers\x20pay\x20the\x20merchant\x20100%\x20—\x20the\x20tier\x20selects\x20the\x20guard,\x20not\x20a\x20cut.\x20The\x20large\x20tier\x20may\x20add\x20the\x20merchant\x27s\x20OWN\x20declared\x20fee,\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20computable\x20before\x20ordering,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(blank\x20silently\x20routes\x20it\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20never\x20a\x20Surplus\x20fee\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all).\x20No\x20platform\x20leg\x20exists\x20in\x20this\x20template.','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(receives\x20the\x20full\x20sale\x20on\x20both\x20tiers\x20by\x20default)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20large_order_merchant_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20not\x20a\x20no-op.','required':![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20small-order\x20tier.\x20Default\x20(and\x20only)\x20value\x2010000\x20—\x20direct\x20sales:\x20no\x20platform\x20take.','required':![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20large-order\x20tier.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(there\x20is\x20no\x20platform\x20take\x20to\x20deduct).','required':![],'default':0x2710},{'name':'large_order_merchant_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20on\x20the\x20large-order\x20tier,\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20large_order_merchant_rate\x20+\x20large_order_merchant_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20takes\x20no\x20platform\x20commission.','required':![],'default':0x0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=assert_declared_share('T-A-05','small_order_merchant_rate',a['small_order_merchant_rate'],0x2710);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=assert_declared_share('T-A-05','large_order_merchant_rate',a['large_order_merchant_rate'],0x2710),d=assert_declared_share('T-A-05','large_order_merchant_fee_bps',a['large_order_merchant_fee_bps'],0x0);assert_explicit_recipient('T-A-05','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-05','merchant_fee_treasury',a['merchant_fee_treasury'],d);const e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20merchant_fee='+d+')');const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'}];return d>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount\x20(platform\x20commission\x200):\x20small=100%\x20merchant,\x20'+('large='+c+'/10000\x20merchant')+(d>0x0?'\x20+\x20'+d+'/10000\x20merchant\x27s\x20own\x20service\x20fee':''),'threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)','DIRECT-SALES\x20DEFAULT:\x20both\x20tiers\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury\x20—\x20the\x20tier\x20picks\x20the\x20guard,\x20not\x20a\x20cut.\x20Each\x20Allocator\x20sums\x20to\x2010000\x20on\x20its\x20own','large_order_merchant_fee_bps\x20is\x20the\x20merchant\x27s\x20OWN\x20large-tier\x20fee\x20(default\x200),\x20only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator;\x20it\x20is\x20never\x20a\x20platform\x20take,\x20never\x20an\x20implicit\x20remainder,\x20and\x20its\x20recipient\x20must\x20be\x20explicit\x20and\x20non-empty']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20whose\x20Rate\x20sharing\x20items\x20include\x20one\x20recipient\x20resolved\x20from\x20the\x20customer\x27s\x20Passport\x20table[identifier].\x20DIRECT-SALES\x20default:\x20merchant_rate\x2010000\x20and\x20every\x20optional\x20leg\x200,\x20so\x20the\x20emitted\x20template\x20is\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant.\x20Two\x20optional\x20legs\x20may\x20be\x20switched\x20on,\x20each\x20under\x20the\x20L3\x20rule\x20(explicit\x20number\x20computable\x20pre-order;\x20explicit\x20non-empty\x20recipient\x20—\x20blank\x20silently\x20pays\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91;\x20no\x20mandatory\x20transit\x20pool,\x20never\x20a\x20Surplus\x20fee\x20leg):\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20(only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator)\x20and\x20a\x20referral/reward\x20to\x20a\x20referrer\x20the\x20buyer\x20names.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template.','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(default:\x20the\x20sole\x2010000\x20recipient)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20NEVER\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20through\x20GuardIdentifier:\x20that\x20recipient\x20is\x20buyer-submitted,\x20not\x20merchant-declared.','required':![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20carrying\x20the\x20referrer\x20address\x20the\x20buyer\x20submits\x20—\x20only\x20consulted\x20when\x20referrer_rate\x20>\x200\x20(default\x200)','required':![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20referrer_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'referrer_rate','type':'number','description':'Referral\x20/\x20reward\x20rate\x20paid\x20to\x20the\x20referrer\x20the\x20BUYER\x20names\x20in\x20its\x20Passport,\x20default\x200.\x20This\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20acquisition\x20price,\x20not\x20a\x20platform\x20share\x20—\x20keep\x20it\x200\x20unless\x20the\x20merchant\x20actually\x20runs\x20a\x20referral\x20programme,\x20and\x20never\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20here.','required':![],'default':0x0}],'body':a=>{const b=assert_declared_share('T-A-06','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-06','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-06','referrer_rate',a['referrer_rate'],0x0),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20referrer='+d+')');assert_explicit_recipient('T-A-06','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-06','merchant_fee_treasury',a['merchant_fee_treasury'],c);const f=Number(a['passport_identifier']??0x0);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);const g=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&g['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&g['push']({'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':g,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury;\x20to\x20exercise\x20the\x20GuardIdentifier\x20form\x20set\x20referrer_rate\x20>\x200\x20and\x20lower\x20merchant_rate\x20by\x20exactly\x20that\x20amount\x20(the\x20emitted\x20rows\x20must\x20still\x20total\x2010000)','F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','The\x20Guard\x20identifier\x20slot\x27s\x20address-type\x20check\x20MUST\x20pass\x20when\x20the\x20Allocator\x20is\x20added\x20(else\x20the\x20Allocator\x20add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes','The\x20GuardIdentifier\x20recipient\x20is\x20CHOSEN\x20BY\x20THE\x20BUYER\x20(the\x20submitted\x20address\x20bound\x20to\x20for_object),\x20so\x20the\x20Guard\x20—\x20not\x20the\x20template\x20—\x20is\x20what\x20makes\x20it\x20trustworthy:\x20bind\x20it\x20(e.g.\x20an\x20allow-listed\x20referrer)\x20before\x20enabling\x20a\x20non-zero\x20referrer_rate,\x20and\x20never\x20use\x20it\x20for\x20the\x20merchant\x27s\x20own\x20fee','merchant_service_fee_bps\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20fee,\x20default\x200,\x20and\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20—\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20the\x20Allocator\x20add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.','No\x20fee\x20leg\x20and\x20no\x20platform\x20leg:\x20a\x20refund\x20path\x20pays\x20the\x20order\x27s\x20owner\x20and\x20nothing\x20else.\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg\x20—\x20never\x20as\x20a\x20leg\x20here,\x20and\x20never\x20as\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain']},{'id':'T-A-08','name':'Arbitration\x20fees\x20payout\x20(arbitrator\x20keeps\x20100%\x20by\x20default\x20/\x20optional\x20declared\x20operator\x20fee)','description':'Single\x20Allocator,\x20Rate\x20sharing\x20items\x20summing\x20to\x20exactly\x2010000.\x20Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20365),\x20with\x20or\x20without\x20a\x20Passport.\x20DIRECT-SALES\x20default:\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20fee\x20(single\x20Rate\x2010000\x20leg)\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission.\x20An\x20optional\x20fee\x20for\x20the\x20arbitration\x20OPERATOR\x20(the\x20arbitrator\x27s\x20own\x20declared\x20service\x20price,\x20or\x20a\x20third\x20party\x20such\x20as\x20a\x20payments/escrow\x20provider)\x20is\x20allowed\x20only\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20parties\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20visible\x20to\x20both\x20sides\x20beforehand\x20(blank\x20silently\x20routes\x20the\x20money\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address\x20—\x20default\x20sole\x2010000\x20recipient\x20of\x20the\x20dispute\x20fee','required':!![]},{'name':'arbitration_operator_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20arbitration_operator_fee_bps:\x20the\x20ARBITRATION\x20OPERATOR\x27s\x20own\x20fee\x20treasury\x20(the\x20arbitrator\x27s\x20declared\x20service\x20price)\x20or\x20a\x20genuine\x20third-party\x20treasury\x20(e.g.\x20an\x20escrow\x20/\x20payments\x20provider).\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20the\x20fee\x20is\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).','required':![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x27s\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'arbitration_operator_fee_bps','type':'number','description':'The\x20ARBITRATION\x20OPERATOR\x27s\x20(or\x20a\x20named\x20third\x20party\x27s)\x20own\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Explicit\x20number\x20both\x20sides\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged;\x20arbitrator_rate\x20+\x20arbitration_operator_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20extracts\x20nothing,\x20so\x20there\x20is\x20no\x20platform\x20share\x20here.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-08','arbitrator_rate',a['arbitrator_rate'],0x2710),c=assert_declared_share('T-A-08','arbitration_operator_fee_bps',a['arbitration_operator_fee_bps'],0x0);assert_explicit_recipient('T-A-08','arbitrator_treasury',a['arbitrator_treasury'],b),assert_explicit_recipient('T-A-08','arbitration_operator_treasury',a['arbitration_operator_treasury'],c);const d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20operator_fee='+c+')');const e=[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&e['push']({'who':{'Entity':a['arbitration_operator_treasury']},'sharing':String(c),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20(platform\x20commission\x200):\x20arbitrator\x20'+b+'/10000'+(c>0x0?',\x20arbitration\x20operator\x27s\x20own\x20fee\x20'+c+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':e,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20ARBITRATION_FEES_ALLOC=365),\x20with\x20or\x20without\x20a\x20Passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission','DIRECT-SALES\x20DEFAULT:\x20the\x20emitted\x20rows\x20are\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20arbitrator_treasury\x20—\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee,\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','arbitration_operator_fee_bps\x20is\x20the\x20arbitration\x20OPERATOR\x27s\x20own\x20declared\x20fee\x20(or\x20a\x20named\x20third\x20party\x27s),\x20default\x200;\x20it\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20and\x20is\x20never\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)','Every\x20rate\x20is\x20an\x20EXPLICIT\x20declared\x20share\x20to\x20an\x20EXPLICIT\x20non-empty\x20address:\x20nothing\x20here\x20is\x20an\x20implicit\x20platform\x20beneficiary\x20and\x20no\x20leg\x20is\x20left\x20unset\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20A\x20share\x20intended\x20for\x20a\x20third\x20party\x20is\x20the\x20payer\x27s\x20own\x20declared\x20price\x20and\x20must\x20be\x20named\x20on\x20both\x20sides']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone','Single\x20beneficiary\x20—\x20no\x20platform\x20leg.\x20The\x20stage-3\x20Surplus\x20is\x20this\x20contract\x27s\x20own\x20vesting\x20remainder,\x20NOT\x20a\x20fee:\x20Surplus\x20calls\x20balance::withdraw_all,\x20so\x20never\x20express\x20a\x20declared\x20fee\x20through\x20a\x20Surplus\x20leg\x20(L3\x20constraint\x203)']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer','The\x20issuer/employer\x20is\x20the\x20payer\x20and\x20keeps\x20the\x20whole\x20payroll\x20pool\x20by\x20default:\x20there\x20is\x20no\x20platform\x20share\x20in\x20this\x20template.\x20Every\x20rate\x20is\x20an\x20explicit\x20per-employee\x20price\x20to\x20an\x20explicit\x20non-empty\x20address\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20and\x20sum(rates)\x20MUST\x20stay\x2010000\x20so\x20no\x20residual\x20stays\x20claimable']}];export const ALLOCATION_TEMPLATES_VERSION='1.1.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
|
|
1
|
+
function assert_declared_share(a,b,c,d){const e=c===undefined||c===null||c===''?d:c,f=Number(e);if(!Number['isInteger'](f))throw new Error('E-RATE-EXPLICIT:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20an\x20explicit\x20integer\x20number\x20of\x20basis\x20points\x20'+('(the\x20buyer\x20must\x20be\x20able\x20to\x20compute\x20it\x20pre-order;\x20never\x20an\x20implicit\x20remainder),\x20got\x20'+String(c)));if(f<0x0||f>0x2710)throw new Error('E-RATE-RANGE:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20within\x20[0,\x2010000],\x20got\x20'+f);return f;}function assert_explicit_recipient(a,b,c,d){if(d<=0x0)return;const e=typeof c==='string'?c['trim']():'';if(e['length']===0x0)throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20MUST\x20be\x20a\x20non-empty\x20explicit\x20recipient\x20'+('because\x20its\x20rate\x20is\x20'+d+'\x20>\x200.\x20A\x20blank/omitted\x20recipient\x20silently\x20falls\x20back\x20to\x20')+'Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20'+'so\x20the\x20outflow\x20would\x20go\x20to\x20whoever\x20ran\x20the\x20deploy.');if(e['toLowerCase']()['startsWith']('0x')){const f=e['slice'](0x2);if(f['length']===0x0||!/^[0-9a-f]+$/['test'](f)||/^0+$/['test'](f))throw new Error('E-RECIPIENT-UNDEFINED:\x20'+a+':\x20'+b+'\x20looks\x20like\x20an\x20address\x20but\x20carries\x20no\x20'+('identity\x20(\x22'+e+'\x22).\x20Point\x20it\x20at\x20the\x20declared\x20recipient\x20Entity\x20(a\x20Treasury/Entity\x20address\x20the\x20')+'buyer\x20can\x20see\x20pre-order).');}}export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services','DIRECT-SALES\x20DEFAULT\x20SHAPE\x20(L2):\x20this\x20IS\x20the\x20default\x20payout\x20form\x20—\x20one\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant\x27s\x20own\x20Entity.\x20No\x20platform\x20leg\x20exists,\x20and\x20nothing\x20is\x20left\x20over','If\x20the\x20merchant\x20declares\x20its\x20OWN\x20fee,\x20use\x20T-A-02\x20(an\x20explicit\x20fee\x20leg\x20to\x20an\x20explicit\x20non-empty\x20recipient)\x20instead\x20of\x20shrinking\x20this\x20leg\x20and\x20routing\x20the\x20difference\x20through\x20an\x20implicit\x20remainder\x20(L3)','A\x20BLANK\x20recipient_address\x20is\x20NOT\x20a\x20no-op:\x20it\x20resolves\x20to\x20Account.Instance().get_address(undefined),\x20the\x20logged-in/deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91)\x20—\x20so\x20this\x20template\x20pays\x20whoever\x20ran\x20the\x20deploy']},{'id':'T-A-02','name':'Merchant\x20payout\x20+\x20optional\x20declared\x20fee\x20/\x20third-party\x20leg\x20(merchant\x20keeps\x20100%\x20by\x20default)','description':'DIRECT-SALES\x20split:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20by\x20default\x20(one\x20Rate\x2010000\x20leg\x20to\x20its\x20own\x20Entity).\x20Optional\x20extra\x20legs\x20are\x20(a)\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20—\x20only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator\x20—\x20and\x20(b)\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider,\x20arbitrator,\x20partner),\x20which\x20is\x20a\x20payment\x20for\x20a\x20service,\x20not\x20platform\x20extraction.\x20Pure\x20Rate\x20mode:\x20the\x20emitted\x20sharing\x20rows\x20MUST\x20sum\x20to\x20exactly\x2010000,\x20and\x20with\x20the\x20default\x20parameters\x20they\x20are\x20a\x20single\x2010000\x20row.\x20L3\x20fee\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20buyer\x20can\x20compute\x20BEFORE\x20ordering,\x20never\x20an\x20implicit\x20remainder\x20such\x20as\x20\x27order\x20total\x20-\x20segment\x20sums\x27;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20the\x20buyer\x20can\x20see\x20pre-order\x20(a\x20blank\x20recipient\x20is\x20NOT\x20a\x20no-op\x20—\x20it\x20falls\x20back\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).\x20WoWok\x20itself\x20takes\x20nothing.','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Entity\x20that\x20receives\x20its\x20own\x20sale\x20proceeds\x20—\x20the\x20direct-sales\x20destination.\x20Required\x20and\x20never\x20blank\x20(blank\x20silently\x20routes\x20the\x20payout\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91).','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20merchant_service_fee_bps\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20Pass\x20merchant_treasury\x20if\x20the\x20merchant\x20charges\x20itself.','required':![]},{'name':'third_party_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20third_party_rate\x20(e.g.\x20the\x20logistics\x20provider\x27s\x20own\x20Treasury).\x20MUST\x20be\x20explicit\x20and\x20non-empty\x20whenever\x20third_party_rate\x20>\x200\x20—\x20same\x20blank-fallback\x20hazard\x20as\x20merchant_fee_treasury.','required':![]},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium\x20/\x20an\x20OTA\x20that\x20really\x20is\x20the\x20seller\x27s\x20counterparty).\x20WoWok\x20extracts\x20nothing\x20—\x20this\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20price,\x20never\x20a\x20platform\x20share.\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20before\x20ordering;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20third_party_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'third_party_rate','type':'number','description':'Rate\x20for\x20a\x20genuine\x20third-party\x20payment\x20(logistics\x20provider\x20/\x20arbitrator\x20/\x20supply-chain\x20partner),\x20default\x200.\x20Kept\x20expressible\x20on\x20purpose\x20—\x20a\x20real\x20provider\x20fee\x20is\x20a\x20payment\x20FOR\x20a\x20service\x20—\x20but\x20it\x20must\x20be\x20an\x20explicit\x20number\x20with\x20an\x20explicit\x20recipient,\x20exactly\x20like\x20the\x20merchant\x20fee.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-02','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-02','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-02','third_party_rate',a['third_party_rate'],0x0);assert_explicit_recipient('T-A-02','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-02','merchant_fee_treasury',a['merchant_fee_treasury'],c),assert_explicit_recipient('T-A-02','third_party_treasury',a['third_party_treasury'],d);const e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20third_party='+d+')'));const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&f['push']({'who':{'Entity':a['third_party_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Direct-sales\x20payout\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20third\x20party\x20(e.g.\x20logistics)\x20'+d+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)\x20—\x20a\x20Rate\x20sum\x20<\x2010000\x20with\x20no\x20Surplus\x20recipient\x20leaves\x20residual\x20balance\x20that\x20ANYONE\x20passing\x20the\x20same\x20Guard\x20can\x20claim\x20repeatedly\x20(E-2\x20/\x20finding\x20T-04)','DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury:\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','merchant_service_fee_bps\x20is\x20the\x20MERCHANT\x27s\x20own\x20fee\x20(merchant\x20IS\x20the\x20aggregator),\x20default\x200\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission\x20and\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template','third_party_rate\x20is\x20a\x20real\x20provider\x20payment\x20(logistics\x20/\x20arbitrator\x20/\x20partner),\x20not\x20platform\x20extraction;\x20keep\x20it\x20expressible,\x20but\x20name\x20the\x20payee\x20explicitly','Never\x20express\x20a\x20fee\x20as\x20an\x20implicit\x20remainder\x20(\x27the\x20merchant\x20keeps\x20whatever\x20is\x20left\x27)\x20and\x20never\x20take\x20one\x20via\x20a\x20Surplus\x20leg\x20(an\x20uncapped\x20Surplus\x20sweeps\x20the\x20entire\x20remaining\x20pool)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant.\x20No\x20fee\x20and\x20no\x20platform\x20leg:\x20the\x20Surplus\x20is\x20the\x20merchant\x27s\x20residual\x20of\x20a\x20mixed\x20refund/delivery\x20pool,\x20NOT\x20a\x20fee\x20mechanism','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','the\x20fix\x20is\x20cached\x20as\x20refundAmount\x20when\x20the\x20Allocator\x20is\x20added','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)','SURPLUS\x20IS\x20NOT\x20A\x20FEE:\x20an\x20uncapped\x20Surplus\x20sweeps\x20the\x20entire\x20remaining\x20pool\x20(a\x20max-capped\x20one\x20tops\x20the\x20payout\x20up\x20to\x20the\x20cap),\x20so\x20a\x20fee\x20taken\x20that\x20way\x20doubles\x20as\x20draining\x20the\x20pool\x20(L3\x20constraint\x203).\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg,\x20never\x20here','The\x20Surplus\x20recipient\x20is\x20the\x20merchant\x20(the\x20counterparty\x20of\x20the\x20delivered\x20part),\x20not\x20an\x20unnamed\x20third\x20party\x20—\x20but\x20pin\x20refund_amount\x20to\x20the\x20refund\x20actually\x20owed,\x20or\x20a\x20smaller/empty\x20refund\x20lets\x20the\x20Surplus\x20leg\x20absorb\x20money\x20that\x20is\x20not\x20the\x20merchant\x27s']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20the\x20Passport\x27s\x20guard\x20result\x20is\x20hard-verified\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)','Each\x20Allocator\x20sums\x20to\x2010000\x20INDEPENDENTLY\x20—\x20the\x20Rate-total\x20invariant\x20is\x20per\x20Allocator,\x20not\x20across\x20Allocators,\x20and\x20each\x20of\x20the\x20two\x20paths\x20pays\x20ONE\x20recipient\x20the\x20full\x20amount\x20(no\x20split,\x20no\x20platform\x20leg,\x20no\x20residual)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order).\x20DIRECT-SALES\x20default:\x20BOTH\x20tiers\x20pay\x20the\x20merchant\x20100%\x20—\x20the\x20tier\x20selects\x20the\x20guard,\x20not\x20a\x20cut.\x20The\x20large\x20tier\x20may\x20add\x20the\x20merchant\x27s\x20OWN\x20declared\x20fee,\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20computable\x20before\x20ordering,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(blank\x20silently\x20routes\x20it\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20never\x20a\x20Surplus\x20fee\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all).\x20No\x20platform\x20leg\x20exists\x20in\x20this\x20template.','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(receives\x20the\x20full\x20sale\x20on\x20both\x20tiers\x20by\x20default)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20large_order_merchant_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20not\x20a\x20no-op.','required':![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20small-order\x20tier.\x20Default\x20(and\x20only)\x20value\x2010000\x20—\x20direct\x20sales:\x20no\x20platform\x20take.','required':![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20on\x20the\x20large-order\x20tier.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(there\x20is\x20no\x20platform\x20take\x20to\x20deduct).','required':![],'default':0x2710},{'name':'large_order_merchant_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20on\x20the\x20large-order\x20tier,\x20in\x20basis\x20points.\x20KEEP\x20AT\x200\x20unless\x20the\x20merchant\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20large_order_merchant_rate\x20+\x20large_order_merchant_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20takes\x20no\x20platform\x20commission.','required':![],'default':0x0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=assert_declared_share('T-A-05','small_order_merchant_rate',a['small_order_merchant_rate'],0x2710);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=assert_declared_share('T-A-05','large_order_merchant_rate',a['large_order_merchant_rate'],0x2710),d=assert_declared_share('T-A-05','large_order_merchant_fee_bps',a['large_order_merchant_fee_bps'],0x0);assert_explicit_recipient('T-A-05','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-05','merchant_fee_treasury',a['merchant_fee_treasury'],d);const e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20merchant_fee='+d+')');const f=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'}];return d>0x0&&f['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount\x20(platform\x20commission\x200):\x20small=100%\x20merchant,\x20'+('large='+c+'/10000\x20merchant')+(d>0x0?'\x20+\x20'+d+'/10000\x20merchant\x27s\x20own\x20service\x20fee':''),'threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':f,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)','DIRECT-SALES\x20DEFAULT:\x20both\x20tiers\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury\x20—\x20the\x20tier\x20picks\x20the\x20guard,\x20not\x20a\x20cut.\x20Each\x20Allocator\x20sums\x20to\x2010000\x20on\x20its\x20own','large_order_merchant_fee_bps\x20is\x20the\x20merchant\x27s\x20OWN\x20large-tier\x20fee\x20(default\x200),\x20only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator;\x20it\x20is\x20never\x20a\x20platform\x20take,\x20never\x20an\x20implicit\x20remainder,\x20and\x20its\x20recipient\x20must\x20be\x20explicit\x20and\x20non-empty']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20whose\x20Rate\x20sharing\x20items\x20include\x20one\x20recipient\x20resolved\x20from\x20the\x20customer\x27s\x20Passport\x20table[identifier].\x20DIRECT-SALES\x20default:\x20merchant_rate\x2010000\x20and\x20every\x20optional\x20leg\x200,\x20so\x20the\x20emitted\x20template\x20is\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20the\x20merchant.\x20Two\x20optional\x20legs\x20may\x20be\x20switched\x20on,\x20each\x20under\x20the\x20L3\x20rule\x20(explicit\x20number\x20computable\x20pre-order;\x20explicit\x20non-empty\x20recipient\x20—\x20blank\x20silently\x20pays\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91;\x20no\x20mandatory\x20transit\x20pool,\x20never\x20a\x20Surplus\x20fee\x20leg):\x20the\x20merchant\x27s\x20OWN\x20service\x20fee\x20(only\x20when\x20the\x20merchant\x20IS\x20the\x20aggregator)\x20and\x20a\x20referral/reward\x20to\x20a\x20referrer\x20the\x20buyer\x20names.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template.','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20(default:\x20the\x20sole\x2010000\x20recipient)','required':!![]},{'name':'merchant_fee_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20merchant_service_fee_bps.\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20that\x20fee\x20is\x20>\x200\x20—\x20blank\x20or\x20omitted\x20silently\x20pays\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20NEVER\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20through\x20GuardIdentifier:\x20that\x20recipient\x20is\x20buyer-submitted,\x20not\x20merchant-declared.','required':![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20carrying\x20the\x20referrer\x20address\x20the\x20buyer\x20submits\x20—\x20only\x20consulted\x20when\x20referrer_rate\x20>\x200\x20(default\x200)','required':![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x27s\x20own\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20merchant\x20keeps\x20the\x20whole\x20sale\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'merchant_service_fee_bps','type':'number','description':'The\x20MERCHANT\x27S\x20OWN\x20service\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Only\x20for\x20a\x20merchant\x20that\x20IS\x20the\x20aggregator\x20(chain\x20/\x20multi-supplier\x20orchestrator\x20/\x20consortium).\x20Explicit\x20number\x20the\x20buyer\x20can\x20compute\x20pre-order;\x20merchant_rate\x20+\x20merchant_service_fee_bps\x20+\x20referrer_rate\x20MUST\x20sum\x20to\x2010000.','required':![],'default':0x0},{'name':'referrer_rate','type':'number','description':'Referral\x20/\x20reward\x20rate\x20paid\x20to\x20the\x20referrer\x20the\x20BUYER\x20names\x20in\x20its\x20Passport,\x20default\x200.\x20This\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20acquisition\x20price,\x20not\x20a\x20platform\x20share\x20—\x20keep\x20it\x200\x20unless\x20the\x20merchant\x20actually\x20runs\x20a\x20referral\x20programme,\x20and\x20never\x20route\x20the\x20merchant\x27s\x20own\x20fee\x20here.','required':![],'default':0x0}],'body':a=>{const b=assert_declared_share('T-A-06','merchant_rate',a['merchant_rate'],0x2710),c=assert_declared_share('T-A-06','merchant_service_fee_bps',a['merchant_service_fee_bps'],0x0),d=assert_declared_share('T-A-06','referrer_rate',a['referrer_rate'],0x0),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20merchant_service_fee='+c+'\x20+\x20referrer='+d+')');assert_explicit_recipient('T-A-06','merchant_treasury',a['merchant_treasury'],b),assert_explicit_recipient('T-A-06','merchant_fee_treasury',a['merchant_fee_treasury'],c);const f=Number(a['passport_identifier']??0x0);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);const g=[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&g['push']({'who':{'Entity':a['merchant_fee_treasury']},'sharing':String(c),'mode':'Rate'}),d>0x0&&g['push']({'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient\x20(platform\x20commission\x200):\x20merchant\x20'+b+'/10000'+(c>0x0?',\x20merchant\x27s\x20own\x20service\x20fee\x20'+c+'/10000':'')+(d>0x0?',\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':g,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['DEFAULT\x20PARAMETERS\x20emit\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20merchant_treasury;\x20to\x20exercise\x20the\x20GuardIdentifier\x20form\x20set\x20referrer_rate\x20>\x200\x20and\x20lower\x20merchant_rate\x20by\x20exactly\x20that\x20amount\x20(the\x20emitted\x20rows\x20must\x20still\x20total\x2010000)','F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','The\x20Guard\x20identifier\x20slot\x27s\x20address-type\x20check\x20MUST\x20pass\x20when\x20the\x20Allocator\x20is\x20added\x20(else\x20the\x20Allocator\x20add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes','The\x20GuardIdentifier\x20recipient\x20is\x20CHOSEN\x20BY\x20THE\x20BUYER\x20(the\x20submitted\x20address\x20bound\x20to\x20for_object),\x20so\x20the\x20Guard\x20—\x20not\x20the\x20template\x20—\x20is\x20what\x20makes\x20it\x20trustworthy:\x20bind\x20it\x20(e.g.\x20an\x20allow-listed\x20referrer)\x20before\x20enabling\x20a\x20non-zero\x20referrer_rate,\x20and\x20never\x20use\x20it\x20for\x20the\x20merchant\x27s\x20own\x20fee','merchant_service_fee_bps\x20is\x20the\x20merchant\x27s\x20own\x20declared\x20fee,\x20default\x200,\x20and\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20—\x20there\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20the\x20Allocator\x20add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.','No\x20fee\x20leg\x20and\x20no\x20platform\x20leg:\x20a\x20refund\x20path\x20pays\x20the\x20order\x27s\x20owner\x20and\x20nothing\x20else.\x20A\x20declared\x20service\x20fee\x20belongs\x20on\x20the\x20purchase-side\x20allocation\x20(T-A-02)\x20as\x20an\x20explicit\x20Rate\x20leg\x20—\x20never\x20as\x20a\x20leg\x20here,\x20and\x20never\x20as\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain']},{'id':'T-A-08','name':'Arbitration\x20fees\x20payout\x20(arbitrator\x20keeps\x20100%\x20by\x20default\x20/\x20optional\x20declared\x20operator\x20fee)','description':'Single\x20Allocator,\x20Rate\x20sharing\x20items\x20summing\x20to\x20exactly\x2010000.\x20Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20365),\x20with\x20or\x20without\x20a\x20Passport.\x20DIRECT-SALES\x20default:\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20fee\x20(single\x20Rate\x2010000\x20leg)\x20—\x20WoWok\x20takes\x20no\x20platform\x20commission.\x20An\x20optional\x20fee\x20for\x20the\x20arbitration\x20OPERATOR\x20(the\x20arbitrator\x27s\x20own\x20declared\x20service\x20price,\x20or\x20a\x20third\x20party\x20such\x20as\x20a\x20payments/escrow\x20provider)\x20is\x20allowed\x20only\x20under\x20the\x20L3\x20rule:\x20(1)\x20an\x20EXPLICIT\x20number\x20the\x20parties\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged,\x20never\x20an\x20implicit\x20remainder;\x20(2)\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20visible\x20to\x20both\x20sides\x20beforehand\x20(blank\x20silently\x20routes\x20the\x20money\x20to\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91);\x20(3)\x20no\x20mandatory\x20transit\x20pool,\x20and\x20the\x20fee\x20is\x20NEVER\x20taken\x20via\x20a\x20Surplus\x20leg\x20(Surplus\x20calls\x20balance::withdraw_all,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool).','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address\x20—\x20default\x20sole\x2010000\x20recipient\x20of\x20the\x20dispute\x20fee','required':!![]},{'name':'arbitration_operator_treasury','type':'address','description':'Recipient\x20Entity\x20of\x20arbitration_operator_fee_bps:\x20the\x20ARBITRATION\x20OPERATOR\x27s\x20own\x20fee\x20treasury\x20(the\x20arbitrator\x27s\x20declared\x20service\x20price)\x20or\x20a\x20genuine\x20third-party\x20treasury\x20(e.g.\x20an\x20escrow\x20/\x20payments\x20provider).\x20MUST\x20be\x20an\x20explicit\x20NON-EMPTY\x20address\x20whenever\x20the\x20fee\x20is\x20>\x200\x20—\x20leaving\x20it\x20blank\x20or\x20omitting\x20it\x20is\x20NOT\x20a\x20no-op:\x20the\x20share\x20silently\x20goes\x20to\x20Account.Instance().get_address(undefined)\x20=\x20the\x20deploying\x20account\x20(ts-sdk/packages/wowok/src/w/local/index.ts:89-91).','required':![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x27s\x20share\x20in\x20basis\x20points.\x20Default\x2010000\x20=\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee\x20(direct\x20sales:\x20no\x20platform\x20take).','required':![],'default':0x2710},{'name':'arbitration_operator_fee_bps','type':'number','description':'The\x20ARBITRATION\x20OPERATOR\x27s\x20(or\x20a\x20named\x20third\x20party\x27s)\x20own\x20fee\x20in\x20basis\x20points,\x20default\x200.\x20Explicit\x20number\x20both\x20sides\x20can\x20compute\x20before\x20the\x20fee\x20is\x20charged;\x20arbitrator_rate\x20+\x20arbitration_operator_fee_bps\x20MUST\x20sum\x20to\x2010000.\x20WoWok\x20extracts\x20nothing,\x20so\x20there\x20is\x20no\x20platform\x20share\x20here.','required':![],'default':0x0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=assert_declared_share('T-A-08','arbitrator_rate',a['arbitrator_rate'],0x2710),c=assert_declared_share('T-A-08','arbitration_operator_fee_bps',a['arbitration_operator_fee_bps'],0x0);assert_explicit_recipient('T-A-08','arbitrator_treasury',a['arbitrator_treasury'],b),assert_explicit_recipient('T-A-08','arbitration_operator_treasury',a['arbitration_operator_treasury'],c);const d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20operator_fee='+c+')');const e=[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'}];return c>0x0&&e['push']({'who':{'Entity':a['arbitration_operator_treasury']},'sharing':String(c),'mode':'Rate'}),{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20(platform\x20commission\x200):\x20arbitrator\x20'+b+'/10000'+(c>0x0?',\x20arbitration\x20operator\x27s\x20own\x20fee\x20'+c+'/10000':''),'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':e,'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20ARBITRATION_FEES_ALLOC=365),\x20with\x20or\x20without\x20a\x20Passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission','DIRECT-SALES\x20DEFAULT:\x20the\x20emitted\x20rows\x20are\x20a\x20single\x20Rate\x2010000\x20leg\x20to\x20arbitrator_treasury\x20—\x20the\x20arbitrator\x20keeps\x20the\x20whole\x20dispute\x20fee,\x20and\x20the\x2010000\x20invariant\x20holds\x20by\x20construction','arbitration_operator_fee_bps\x20is\x20the\x20arbitration\x20OPERATOR\x27s\x20own\x20declared\x20fee\x20(or\x20a\x20named\x20third\x20party\x27s),\x20default\x200;\x20it\x20requires\x20an\x20explicit\x20non-empty\x20recipient\x20and\x20is\x20never\x20an\x20implicit\x20remainder\x20or\x20a\x20Surplus\x20drain.\x20There\x20is\x20no\x20platform\x20leg\x20in\x20this\x20template']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)','Every\x20rate\x20is\x20an\x20EXPLICIT\x20declared\x20share\x20to\x20an\x20EXPLICIT\x20non-empty\x20address:\x20nothing\x20here\x20is\x20an\x20implicit\x20platform\x20beneficiary\x20and\x20no\x20leg\x20is\x20left\x20unset\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91).\x20A\x20share\x20intended\x20for\x20a\x20third\x20party\x20is\x20the\x20payer\x27s\x20own\x20declared\x20price\x20and\x20must\x20be\x20named\x20on\x20both\x20sides']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone','Single\x20beneficiary\x20—\x20no\x20platform\x20leg.\x20The\x20stage-3\x20Surplus\x20is\x20this\x20contract\x27s\x20own\x20vesting\x20remainder,\x20NOT\x20a\x20fee:\x20Surplus\x20calls\x20balance::withdraw_all,\x20so\x20never\x20express\x20a\x20declared\x20fee\x20through\x20a\x20Surplus\x20leg\x20(L3\x20constraint\x203)']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer','The\x20issuer/employer\x20is\x20the\x20payer\x20and\x20keeps\x20the\x20whole\x20payroll\x20pool\x20by\x20default:\x20there\x20is\x20no\x20platform\x20share\x20in\x20this\x20template.\x20Every\x20rate\x20is\x20an\x20explicit\x20per-employee\x20price\x20to\x20an\x20explicit\x20non-empty\x20address\x20(blank\x20silently\x20binds\x20the\x20deploying\x20account,\x20ts-sdk/packages/wowok/src/w/local/index.ts:89-91),\x20and\x20sum(rates)\x20MUST\x20stay\x2010000\x20so\x20no\x20residual\x20stays\x20claimable']}];export const ALLOCATION_TEMPLATES_VERSION='1.1.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ArbFundFactsOptions {
|
|
2
|
+
arbRef?: string;
|
|
3
|
+
orderRef?: string;
|
|
4
|
+
network?: string;
|
|
5
|
+
noCache?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface OrderFundFacts {
|
|
8
|
+
arb_case?: string;
|
|
9
|
+
arb_status?: number;
|
|
10
|
+
arb_indemnity?: string | number | null;
|
|
11
|
+
order: string;
|
|
12
|
+
order_amount: string;
|
|
13
|
+
claimed_by: string | null;
|
|
14
|
+
progress_node: string | null;
|
|
15
|
+
allocation: string | null;
|
|
16
|
+
allocation_balance: string | null;
|
|
17
|
+
escrow_deficit: string | null;
|
|
18
|
+
withdraw_history: {
|
|
19
|
+
payment: string;
|
|
20
|
+
amount: string;
|
|
21
|
+
time: string | number;
|
|
22
|
+
remark?: string;
|
|
23
|
+
}[];
|
|
24
|
+
order_time?: string | number;
|
|
25
|
+
case_time?: string | number;
|
|
26
|
+
}
|
|
27
|
+
export interface BuiltOrderFundFacts {
|
|
28
|
+
structured: OrderFundFacts;
|
|
29
|
+
text: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function buildOrderFundFacts(opts: ArbFundFactsOptions): Promise<BuiltOrderFundFacts | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{batchQueryObjectsByIds}from'../graph/onchain/sdk-batch.js';const PAYMENT_HISTORY_CAP=0x5;function asBigIntOrUndefined(a){try{if(typeof a==='bigint')return a;if(typeof a==='number'&&Number['isFinite'](a))return BigInt(Math['trunc'](a));if(typeof a==='string'&&a['trim']()!=='')return BigInt(a);}catch{}return undefined;}function pickData(a){return a?.['data']??a;}function pickAddr(a){return a?.['object']??a?.['data']?.['object']??a?.['id'];}export async function buildOrderFundFacts(b){const c=b['noCache']??!![];let d,e,f,g,h;if(b['arbRef']){const B=await batchQueryObjectsByIds([b['arbRef']],b['network'],c),C=B['find'](E=>pickData(E)?.['type']==='Arb'||pickData(E)?.['order']),D=pickData(C);D?.['order']&&typeof D['order']==='string'&&(d=D['order'],e=pickAddr(C),f=typeof D['status']==='number'?D['status']:undefined,g=D['indemnity']?.['amount']??null,h=D['time']);}if(!d&&b['orderRef'])d=b['orderRef'];if(!d)return undefined;const i=await batchQueryObjectsByIds([d],b['network'],c),j=pickData(i[0x0]);if(!j||j['amount']===undefined)return undefined;const k=[];if(typeof j['allocation']==='string'&&j['allocation'])k['push'](j['allocation']);if(typeof j['progress']==='string'&&j['progress'])k['push'](j['progress']);const l=k['length']>0x0?await batchQueryObjectsByIds(k,b['network'],c):[],m=new Map();for(const E of l){const F=pickAddr(E);if(F)m['set'](F['toLowerCase'](),E);}const n=j['allocation']?m['get'](String(j['allocation'])['toLowerCase']()):undefined,q=pickData(n),r=j['progress']?m['get'](String(j['progress'])['toLowerCase']()):undefined,s=pickData(r),t=[],u=Array['isArray'](q?.['payment'])?q['payment']['slice'](-PAYMENT_HISTORY_CAP):[];if(u['length']>0x0){const G=await batchQueryObjectsByIds(u,b['network'],c),H=new Map();for(const I of G){const J=pickAddr(I);if(J)H['set'](J['toLowerCase'](),I);}for(const K of u){const L=pickData(H['get'](String(K)['toLowerCase']()));if(!L)continue;t['push']({'payment':K,'amount':String(L['amount']??'0'),'time':L['time']??'',...L['info']?.['remark']?{'remark':String(L['info']['remark'])}:{}});}}const v=asBigIntOrUndefined(j['amount'])??0x0n,x=q?asBigIntOrUndefined(q['balance']):undefined,y=x!==undefined?v-x:undefined,z={...e?{'arb_case':e}:{},...f!==undefined?{'arb_status':f}:{},...g!==undefined?{'arb_indemnity':g}:{},'order':d,'order_amount':String(j['amount']),'claimed_by':typeof j['claimed_by']==='string'?j['claimed_by']:null,'progress_node':typeof s?.['current']==='string'&&s['current']!==''?s['current']:null,'allocation':typeof j['allocation']==='string'&&j['allocation']?j['allocation']:null,'allocation_balance':x!==undefined?String(x):null,'escrow_deficit':y!==undefined?String(y):null,'withdraw_history':t,...j['time']!==undefined?{'order_time':j['time']}:{},...h!==undefined?{'case_time':h}:{}},A=['ORDER\x20FUND\x20FACTS\x20(raw\x20units,\x20live\x20read):'];A['push']('-\x20order\x20'+d+':\x20amount='+z['order_amount']);z['allocation']?A['push']('-\x20escrow\x20allocation\x20'+z['allocation']+':\x20balance='+z['allocation_balance']+'\x20(deficit\x20vs\x20amount:\x20'+z['escrow_deficit']+')'):A['push']('-\x20escrow\x20allocation:\x20none\x20(zero-amount\x20order\x20carries\x20no\x20escrow)');A['push']('-\x20compensation\x20claimed_by:\x20'+(z['claimed_by']??'null\x20(unclaimed)')),A['push']('-\x20workflow\x20node:\x20'+(z['progress_node']??'(none)'));if(t['length']>0x0){A['push']('-\x20escrow\x20payouts\x20so\x20far\x20('+t['length']+(u['length']===PAYMENT_HISTORY_CAP?'+':'')+'):');for(const M of t){A['push']('\x20\x20*\x20'+M['amount']+'\x20at\x20'+M['time']+(M['remark']?'\x20—\x20'+M['remark']:'')+'\x20['+M['payment']+']');}}return y!==undefined&&y>0x0n&&A['push']('NET\x20GUIDANCE:\x20the\x20escrow\x20has\x20already\x20paid\x20out\x20'+y+'\x20raw\x20units\x20more\x20than\x20it\x20holds\x20—\x20'+'if\x20the\x20buyer\x20was\x20refunded\x20through\x20the\x20escrow\x20track\x20before\x20filing,\x20net\x20the\x20indemnity\x20against\x20the\x20refunded\x20principal;\x20'+'compensate\x20the\x20delta,\x20not\x20the\x20full\x20loss.'),z['claimed_by']&&A['push']('NOTE:\x20claimed_by\x20is\x20set\x20—\x20the\x20order\x20has\x20already\x20marked\x20a\x20compensation\x20claim;\x20a\x20further\x20ruling\x20pays\x20on\x20top\x20of\x20any\x20escrow\x20payout.'),{'structured':z,'text':A['join']('\x0a')};}
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"amount_rule_amount_sum": "Sum of Amount-mode sharing values (Number()) for the offender.",
|
|
29
29
|
"amount_rule_threshold": "Number(allocators_config.threshold) for the offender (NaN when absent — comparisons stay false).",
|
|
30
30
|
"amount_rule_max": "Number(allocator.max) for the offender (only set on the exceeds_max branch).",
|
|
31
|
+
"surplus_dup_rate_index": "First allocator whose Surplus row pays the SAME recipient as one of its own Rate/RateGross legs (undefined when none). Recipient identity is normalized per kind (Entity lowercased, GuardIdentifier by id, Signer by kind).",
|
|
32
|
+
"surplus_dup_rate_guard": "Guard address of the Surplus-duplication offender.",
|
|
33
|
+
"surplus_dup_rate_recipient": "Rendered duplicated recipient (e.g. 'Entity(0x…)', 'GuardIdentifier(0)', 'Signer') for evidence display.",
|
|
31
34
|
"signer_theft_detected": "Canonical RC-FIND-01 judgment (recipient-constraint.ts): a sharing.who=Signer recipient whose Guard does not bind the caller identity.",
|
|
32
35
|
"signer_theft_index": "Allocator index of the unbound-Signer theft offender.",
|
|
33
36
|
"signer_theft_guard": "Guard address of the theft offender.",
|
|
@@ -224,6 +227,32 @@
|
|
|
224
227
|
}
|
|
225
228
|
]
|
|
226
229
|
},
|
|
230
|
+
{
|
|
231
|
+
"rule_id": "R-A-1-04",
|
|
232
|
+
"dimension": "structural",
|
|
233
|
+
"trigger": "A Surplus sharing row pays the same recipient as a Rate leg in the same Allocator — the remainder swallows an undeclared share",
|
|
234
|
+
"cases": [
|
|
235
|
+
{
|
|
236
|
+
"when": { "field": "surplus_dup_rate_index", "op": "present" },
|
|
237
|
+
"level": "critical",
|
|
238
|
+
"title": "Surplus row pays ${surplus_dup_rate_recipient}, which a Rate leg already pays (Allocator ${surplus_dup_rate_index}) — undeclared share swallowed",
|
|
239
|
+
"description": "Allocator ${surplus_dup_rate_index} (guard=${surplus_dup_rate_guard}) carries a Surplus row whose recipient ${surplus_dup_rate_recipient} is identical to one of its own Rate legs. The chain pays every Rate leg its declared basis points and then pays the ENTIRE remainder to the Surplus recipient — so this party quietly receives rate% + 100% of the residual, and any leg the author intended but forgot (commission, payment fee, platform take) is never created. The Rate-sum rule (R-A-1-02) passes because the sum is legal; the misroute is invisible there. order_allocators freezes permanently at Service publish, so the error is irreversible once live. Mainnet precedent (Booking replica, 2026-10-06): a Surplus row added to satisfy the Rate-sum rule pointed at the property again — the property took 100%, the 15% commission and 1.5% payment-fee legs never existed, and the published Service had to be abandoned.",
|
|
240
|
+
"scenario": "Surplus recipient duplicated from a Rate leg — typically a filler row added to make the Rate sum legal, whose recipient the author forgot to change to the intended commission/fee party",
|
|
241
|
+
"mitigation": "Point the Surplus row at the party meant to absorb the remainder (usually the merchant), distinct from every Rate leg — or, if the duplicated recipient is truly intended to take rate% + remainder, collapse the two rows into ONE Rate leg at 10000 minus the other legs' sum so the declared split equals the actual split. Every intended payee must be its own explicit leg.",
|
|
242
|
+
"evidence": "allocator=${surplus_dup_rate_index}, guard=${surplus_dup_rate_guard}, duplicatedRecipient=${surplus_dup_rate_recipient}",
|
|
243
|
+
"stakeholders": ["owner", "recipient", "service_provider"],
|
|
244
|
+
"exposure": {
|
|
245
|
+
"loss_parties": [
|
|
246
|
+
{ "role": "merchant", "basis": "The omitted leg (commission, fee, royalty) is paid to the duplicated recipient instead — the intended payee is silently unpaid on every order, and the misroute is frozen at publish." },
|
|
247
|
+
{ "role": "buyer", "basis": "The declared split the buyer read before ordering no longer matches where the money lands — the ledger overstates the duplicated party's share." }
|
|
248
|
+
],
|
|
249
|
+
"gain_paths": [
|
|
250
|
+
{ "role": "merchant", "path": "The duplicated recipient leg (a merchant-designated payee) receives its Rate share plus the entire Surplus remainder on every distribution, with no on-chain assertion objecting.", "viability": "viable", "gate": "Nothing gates it — the chain pays Rate legs then the Surplus verbatim; only this scan sees the duplication." }
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
227
256
|
{
|
|
228
257
|
"rule_id": "R-A-2-01",
|
|
229
258
|
"dimension": "semantic",
|
|
@@ -270,15 +299,15 @@
|
|
|
270
299
|
{
|
|
271
300
|
"rule_id": "R-A-2-03",
|
|
272
301
|
"dimension": "semantic",
|
|
273
|
-
"trigger": "Duplicate Guard addresses in allocators (
|
|
302
|
+
"trigger": "Duplicate Guard addresses in allocators (every allocator bound to the submitted guard fires — duplicates stack, they do not compete)",
|
|
274
303
|
"cases": [
|
|
275
304
|
{
|
|
276
305
|
"when": { "field": "duplicate_guards_present", "op": "eq", "value": true },
|
|
277
|
-
"level": "
|
|
278
|
-
"title": "Duplicate Guard addresses in allocators",
|
|
279
|
-
"description": "Multiple Allocators reference the same Guard object: ${duplicate_guards_csv_sp}.
|
|
306
|
+
"level": "high",
|
|
307
|
+
"title": "Duplicate Guard addresses in allocators — every duplicate FIRES on the same call",
|
|
308
|
+
"description": "Multiple Allocators reference the same Guard object: ${duplicate_guards_csv_sp}. allocation.move:366-368 runs a full loop with no early exit: a distribution call submitting that guard fires EVERY matching allocator, in vector order, each against the balance left by the previous one. This is a legitimate waterfall mechanism ONLY if intended; if the duplicates were meant as alternative paths, they are NOT alternatives — one call triggers all of them, the pool is split repeatedly, and a later allocator may abort on insufficient balance or pay out of money earmarked for another track.",
|
|
280
309
|
"scenario": "Reusing same Guard object across multiple Allocators",
|
|
281
|
-
"mitigation": "
|
|
310
|
+
"mitigation": "Intended waterfall (fee first, then split the remainder): keep the shared guard and verify the vector order matches the intended payout sequence. Intended alternatives (refund vs damage vs settle): give each path its OWN Guard object (they may share root/table but must be distinct objects) so the caller's guard selection picks exactly one path.",
|
|
282
311
|
"evidence": "total=${allocators_total}, unique=${allocators_unique}, dupes=${duplicate_guards_csv}",
|
|
283
312
|
"stakeholders": ["owner", "allocator"]
|
|
284
313
|
}
|
|
@@ -309,11 +338,11 @@
|
|
|
309
338
|
{ "field": "guard_identifier_recipient_present", "op": "eq", "value": true },
|
|
310
339
|
{ "field": "for_object_anchor_set", "op": "eq", "value": false }
|
|
311
340
|
] },
|
|
312
|
-
"level": "
|
|
313
|
-
"title": "
|
|
314
|
-
"description": "payment_info.for_object is
|
|
341
|
+
"level": "critical",
|
|
342
|
+
"title": "GuardIdentifier recipients with NO for_object anchor — the chain enforces NOTHING",
|
|
343
|
+
"description": "payment_info.for_object is None while allocator(s) pay GuardIdentifier recipients. Verified on-chain: the recipient binding check is gated on the anchor being Some — allocation.move:444-448 runs the ERECIPIENT_NOT_FOR_OBJECT (15) assertion only inside `if (option::is_some(&binding))`; with None the passport-submitted address is paid VERBATIM, and the code comment itself (allocation.move:434-443) pushes the due-diligence obligation to the tooling layer. Whoever builds a satisfying passport names the payout address — funds can be redirected with nothing on-chain objecting. The Service order flow always anchors (service.move:394 sets for_object to the paying order) and the Arbitration fee flow anchors too (arbitration.move:342), so a None anchor is reachable only through a standalone or custom-constructed PaymentInfo — exactly the surface this rule gates.",
|
|
315
344
|
"scenario": "Allocation created without a for_object anchor while using GuardIdentifier recipients",
|
|
316
|
-
"mitigation": "
|
|
345
|
+
"mitigation": "Set payment_info.for_object to the intended anchor at create (mismatch then aborts with code 15 — mechanism-enforced). If the payout destination must stay passport-chosen by design, do NOT use GuardIdentifier legs: use Entity legs (static, declared at create) or constrain the submitted address inside the guard expression itself. Treat any None+GuardIdentifier config as a fund-redirection hole until one of those is in place.",
|
|
317
346
|
"evidence": "for_object=None",
|
|
318
347
|
"stakeholders": ["owner", "recipient"],
|
|
319
348
|
"exposure": {
|
|
@@ -423,7 +452,7 @@
|
|
|
423
452
|
{
|
|
424
453
|
"rule_id": "R-A-4-01",
|
|
425
454
|
"dimension": "lifecycle",
|
|
426
|
-
"trigger": "caller-specified guard with no matching Allocator —
|
|
455
|
+
"trigger": "caller-specified guard with no matching Allocator — aborts with E_ALLOCATOR_NOT_MATCHED",
|
|
427
456
|
"cases": [
|
|
428
457
|
{
|
|
429
458
|
"when": { "all": [
|
|
@@ -432,16 +461,16 @@
|
|
|
432
461
|
{ "field": "has_fallback_allocator", "op": "falsy" }
|
|
433
462
|
] },
|
|
434
463
|
"level": "critical",
|
|
435
|
-
"title": "caller-specified guard with no matching Allocator —
|
|
436
|
-
"description": "Multi-Allocation configuration (${allocators_count} Allocators) without alternative Allocator. alloc() is driven by the caller explicitly specifying an Allocator via alloc_by_guard: if the guard address does not match any allocators[].guard, alloc()
|
|
464
|
+
"title": "caller-specified guard with no matching Allocator — aborts with E_ALLOCATOR_NOT_MATCHED",
|
|
465
|
+
"description": "Multi-Allocation configuration (${allocators_count} Allocators) without alternative Allocator. alloc() is driven by the caller explicitly specifying an Allocator via alloc_by_guard: if the guard address does not match any allocators[].guard, alloc() aborts with E_ALLOCATOR_NOT_MATCHED (allocation.move:295) — the transaction reverts and funds remain in the order escrow, not stuck in Allocation.balance. Linked to guard-risk.ts R-X1-05.",
|
|
437
466
|
"scenario": "Caller passes a guard address not present in allocators[] (e.g. wrong Guard object, or order state not matching any terminal node)",
|
|
438
|
-
"mitigation": "1) The caller should verify alloc_by_guard ∈ allocators[].guard address set before calling alloc(). 2) Provide an alternative Allocator and document the caller's retry strategy. 3)
|
|
467
|
+
"mitigation": "1) The caller should verify alloc_by_guard ∈ allocators[].guard address set before calling alloc(). 2) Provide an alternative Allocator and document the caller's retry strategy. 3) Catch the abort and surface the mismatch to the operator.",
|
|
439
468
|
"evidence": "allocators=${allocators_count}, hasFallback=${has_fallback_allocator_display}",
|
|
440
469
|
"stakeholders": ["owner", "service_provider", "system"],
|
|
441
470
|
"exposure": {
|
|
442
471
|
"loss_parties": [
|
|
443
|
-
{ "role": "buyer", "basis": "A no-match alloc_by_guard call
|
|
444
|
-
{ "role": "merchant", "basis": "The merchant share stays
|
|
472
|
+
{ "role": "buyer", "basis": "A no-match alloc_by_guard call aborts with E_ALLOCATOR_NOT_MATCHED — the escrowed order funds stay in the order escrow, and the caller must retry with a matching guard." },
|
|
473
|
+
{ "role": "merchant", "basis": "The merchant share stays in the order escrow until a caller retries with a matching guard address." }
|
|
445
474
|
],
|
|
446
475
|
"gain_paths": []
|
|
447
476
|
}
|