@hyperscale0/hsx 2.4.0 → 3.0.0
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/CHANGELOG.md +2 -400
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +76 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +77 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4131
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5381
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.0. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# rotating_pool
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/rotating_pool.hsx`](../../../std/money_flows/rotating_pool.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`rotating_pool<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `members` | `optional<list<party>>` | No | List of parties belonging to the rotating group. |
|
|
16
|
-
| `contribution` | `money<C>` | Yes | Fixed contribution amount required from each member per cycle in minor units of currency `C`. |
|
|
17
|
-
| `count` | `integer` | Yes | Total number of cycles in the rotation (matching the member count). |
|
|
18
|
-
| `every` | `optional<text>` | No | Recurrence interval between contribution cycles (e.g. `"P30D"`). |
|
|
19
|
-
| `first_due` | `date` | Yes | Due date for the first cycle's contribution. |
|
|
20
|
-
| `payout_order` | `optional<list<party>>` | No | Ordered list of member parties defining the cycle payout sequence. |
|
|
21
|
-
| `default_policy` | `optional<text>` | No | Policy for handling missed contributions (`due_condition`). |
|
|
22
|
-
| `guarantee_policy` | `optional<text>` | No | Policy for backing defaulted contributions (`funded_only`). |
|
|
23
|
-
| `guarantor` | `optional<party>` | No | Optional guarantor party covering member defaults. |
|
|
24
|
-
| `exit_policy` | `optional<text>` | No | Policy governing member departures (`before_activation_only`). |
|
|
25
|
-
| `memo` | `optional<text>` | No | Optional memo text stored on the pool. |
|
|
26
|
-
| `membership` | `optional<block>` | No | Optional custom membership configuration block. |
|
|
27
|
-
|
|
28
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
29
|
-
|
|
30
|
-
## Module guidance
|
|
31
|
-
|
|
32
|
-
Rotating savings and credit association (ROSCA) pool where members contribute fixed amounts and take turns receiving the pot.
|
|
33
|
-
|
|
34
|
-
### Purpose
|
|
35
|
-
|
|
36
|
-
`rotating_pool` coordinates peer savings circles, chit funds, tandas, and committee savings groups.
|
|
37
|
-
A fixed group of members contributes an identical contribution amount each cycle. In each cycle, one designated member
|
|
38
|
-
receives the entire pooled pot according to a predefined `payout_order` until all members have taken their turn.
|
|
39
|
-
|
|
40
|
-
### Selection guidance
|
|
41
|
-
|
|
42
|
-
- vs `threshold_pool`: `rotating_pool` coordinates recurring multi-party peer savings with rotating payouts.
|
|
43
|
-
`threshold_pool` is all-or-nothing capital accumulation toward a single threshold for one beneficiary.
|
|
44
|
-
- vs `scheduled`: `scheduled` coordinates a single payer to a single payee. `rotating_pool` orchestrates
|
|
45
|
-
a closed circular group of members taking sequential turns.
|
|
46
|
-
|
|
47
|
-
### Parameters
|
|
48
|
-
|
|
49
|
-
- `members`: List of parties belonging to the rotating group.
|
|
50
|
-
- `contribution`: Fixed contribution amount required from each member per cycle in minor units of currency `C`.
|
|
51
|
-
- `count`: Total number of cycles in the rotation (matching the member count).
|
|
52
|
-
- `every`: Recurrence interval between contribution cycles (e.g. `"P30D"`).
|
|
53
|
-
- `first_due`: Due date for the first cycle's contribution.
|
|
54
|
-
- `payout_order`: Ordered list of member parties defining the cycle payout sequence.
|
|
55
|
-
- `default_policy`: Policy for handling missed contributions (`due_condition`).
|
|
56
|
-
- `guarantee_policy`: Policy for backing defaulted contributions (`funded_only`).
|
|
57
|
-
- `guarantor`: Optional guarantor party covering member defaults.
|
|
58
|
-
- `exit_policy`: Policy governing member departures (`before_activation_only`).
|
|
59
|
-
- `memo`: Optional memo text stored on the pool.
|
|
60
|
-
- `membership`: Optional custom membership configuration block.
|
|
61
|
-
|
|
62
|
-
### Decision ports
|
|
63
|
-
|
|
64
|
-
None. Cycle advancement and pot payouts follow the declared schedule and membership actions.
|
|
65
|
-
|
|
66
|
-
### Example
|
|
67
|
-
|
|
68
|
-
```hsx
|
|
69
|
-
program rotating_pool_example "Rotating pool example"
|
|
70
|
-
import { rotating_pool } from "std/money_flows"
|
|
71
|
-
party member_a: person
|
|
72
|
-
party member_b: person
|
|
73
|
-
party member_c: person
|
|
74
|
-
party guarantor: business
|
|
75
|
-
settlement pool = rotating_pool {
|
|
76
|
-
members: [member_a, member_b, member_c]
|
|
77
|
-
contribution: contributionAmount: money(SAR)
|
|
78
|
-
count: 3
|
|
79
|
-
every: P30D
|
|
80
|
-
first_due: firstContributionAt
|
|
81
|
-
payout_order: [member_b, member_c, member_a]
|
|
82
|
-
default_policy: due_condition
|
|
83
|
-
guarantee_policy: funded_only
|
|
84
|
-
guarantor: guarantor
|
|
85
|
-
exit_policy: before_activation_only
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Declared clauses
|
|
90
|
-
|
|
91
|
-
- `agent description`
|
|
92
|
-
- `aggregate invariants`
|
|
93
|
-
- `caller parked states`
|
|
94
|
-
- `description`
|
|
95
|
-
- `due`
|
|
96
|
-
- `examples`
|
|
97
|
-
- `id prefix`
|
|
98
|
-
- `moves`
|
|
99
|
-
- `sandbox failure point`
|
|
100
|
-
- `steps`
|
|
101
|
-
- `summary`
|
|
102
|
-
- `title`
|
|
103
|
-
- `unique`
|
|
104
|
-
|
|
105
|
-
This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
|
|
106
|
-
|
|
107
|
-
## Decision ports
|
|
108
|
-
|
|
109
|
-
None.
|
|
110
|
-
|
|
111
|
-
## Actions and clauses
|
|
112
|
-
|
|
113
|
-
| Action | Clauses lowered |
|
|
114
|
-
| --- | --- |
|
|
115
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
116
|
-
| `cancel` | `agent description`, `moves`, `steps`, `summary` |
|
|
117
|
-
| `activate` | `agent description`, `moves`, `steps`, `summary` |
|
|
118
|
-
| `ready_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
|
|
119
|
-
| `advance_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
|
|
120
|
-
| `create` | `agent description`, `moves`, `steps`, `summary`, `unique` |
|
|
121
|
-
| `contribute_cycle_[cycle]` | `due`, `moves`, `sandbox failure point`, `steps`, `summary` |
|
|
122
|
-
| `mark_default_cycle_[cycle]` | `due`, `moves`, `steps`, `summary` |
|
|
123
|
-
| `guarantee_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
|
|
124
|
-
| `pay_cycle_[cycle]` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
|
|
125
|
-
| `pay_guaranteed_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
|
|
126
|
-
| `close` | `agent description`, `moves`, `steps`, `summary` |
|
|
127
|
-
| `create` | `agent description`, `examples`, `moves`, `steps` |
|
|
128
|
-
| `activate` | `due`, `examples`, `moves`, `steps` |
|
|
129
|
-
| `disband` | `agent description`, `examples`, `moves`, `steps` |
|
|
130
|
-
| `close` | `agent description`, `examples`, `moves`, `steps` |
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.0. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# scheduled
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/scheduled.hsx`](../../../std/money_flows/scheduled.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`scheduled<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `payer` | `party` | Yes | The paying party (or repayment source). |
|
|
16
|
-
| `payee` | `party` | Yes | The beneficiary party receiving installment funds. |
|
|
17
|
-
| `amount` | `money<C>` | Yes | Total amount to partition into installments or recurring charge amount in minor units of currency `C`. |
|
|
18
|
-
| `count` | `optional<integer>` | No | Optional number of installments for installment or obligation modes. |
|
|
19
|
-
| `every` | `text` | Yes | Recurrence cadence duration string (e.g. `"P30D"`, `"P1M"`). |
|
|
20
|
-
| `first_due` | `date` | Yes | Stored date anchor for the first installment or charge. |
|
|
21
|
-
| `mode` | `optional<text>` | No | Optional mode selector (`obligation`). Omit for standard installment plans. |
|
|
22
|
-
| `debtor` | `optional<party>` | No | Optional debtor party when distinct from the payment source in obligation mode. |
|
|
23
|
-
| `advance_to` | `optional<party>` | No | Optional third-party receiving upfront advance disbursements in obligation mode. |
|
|
24
|
-
| `until` | `optional<condition>` | No | Optional condition port triggering cancellation of recurring subscription runs. |
|
|
25
|
-
| `month_end` | `optional<text>` | No | Optional handling policy for calendar month-end adjustments. |
|
|
26
|
-
| `period_liability` | `optional<text>` | No | Optional liability policy for billing periods. |
|
|
27
|
-
| `termination_drain` | `optional<text>` | No | Optional policy for draining balances on early termination. |
|
|
28
|
-
| `mandate` | `optional<condition>` | No | Optional condition port supplying formal debit mandate evidence. |
|
|
29
|
-
| `derived_amount` | `optional<unknown>` | No | Optional calculated markup or fee rules. |
|
|
30
|
-
|
|
31
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
32
|
-
|
|
33
|
-
## Module guidance
|
|
34
|
-
|
|
35
|
-
Calendar-anchored payments supporting fixed installment plans, recurring subscriptions, or debt obligations.
|
|
36
|
-
|
|
37
|
-
### Purpose
|
|
38
|
-
|
|
39
|
-
`scheduled` automates time-anchored payment series between one payer and one payee.
|
|
40
|
-
It supports three modes:
|
|
41
|
-
|
|
42
|
-
1. Installment plan: Partitions a fixed total amount into `count` installments, each collected on its own stored date.
|
|
43
|
-
2. Open recurring subscription: Charges a recurring amount on an interval `every` until an `until` port fires.
|
|
44
|
-
3. Debt obligation: Manages legally binding multi-installment debt with delinquency tracking, mandate evidence, and child payment records.
|
|
45
|
-
|
|
46
|
-
### Selection guidance
|
|
47
|
-
|
|
48
|
-
- vs `metered`: `scheduled` executes calendar-based recurring charges or fixed installment plans.
|
|
49
|
-
`metered` bills variable usage per event based on a committed rate card.
|
|
50
|
-
- vs `rotating_pool`: `scheduled` coordinates one payer to one payee on a calendar.
|
|
51
|
-
`rotating_pool` coordinates a multi-party peer circle where members rotate turns receiving the entire pot.
|
|
52
|
-
|
|
53
|
-
### Parameters
|
|
54
|
-
|
|
55
|
-
- `payer`: The paying party (or repayment source).
|
|
56
|
-
- `payee`: The beneficiary party receiving installment funds.
|
|
57
|
-
- `amount`: Total amount to partition into installments or recurring charge amount in minor units of currency `C`.
|
|
58
|
-
- `count`: Optional number of installments for installment or obligation modes.
|
|
59
|
-
- `every`: Recurrence cadence duration string (e.g. `"P30D"`, `"P1M"`).
|
|
60
|
-
- `first_due`: Stored date anchor for the first installment or charge.
|
|
61
|
-
- `mode`: Optional mode selector (`obligation`). Omit for standard installment plans.
|
|
62
|
-
- `debtor`: Optional debtor party when distinct from the payment source in obligation mode.
|
|
63
|
-
- `advance_to`: Optional third-party receiving upfront advance disbursements in obligation mode.
|
|
64
|
-
- `until`: Optional condition port triggering cancellation of recurring subscription runs.
|
|
65
|
-
- `month_end`: Optional handling policy for calendar month-end adjustments.
|
|
66
|
-
- `period_liability`: Optional liability policy for billing periods.
|
|
67
|
-
- `termination_drain`: Optional policy for draining balances on early termination.
|
|
68
|
-
- `mandate`: Optional condition port supplying formal debit mandate evidence.
|
|
69
|
-
- `derived_amount`: Optional calculated markup or fee rules.
|
|
70
|
-
|
|
71
|
-
### Decision ports
|
|
72
|
-
|
|
73
|
-
- `until`: Port terminating recurring subscriptions.
|
|
74
|
-
- `mandate`: Port supplying mandate verification evidence for direct debit obligations.
|
|
75
|
-
|
|
76
|
-
### Example
|
|
77
|
-
|
|
78
|
-
```hsx
|
|
79
|
-
program scheduled_example "Scheduled example"
|
|
80
|
-
import { scheduled } from "std/money_flows"
|
|
81
|
-
party payer: business
|
|
82
|
-
party payee: business
|
|
83
|
-
settlement installments = scheduled {
|
|
84
|
-
payer: payer
|
|
85
|
-
payee: payee
|
|
86
|
-
amount: totalAmount: money(SAR)
|
|
87
|
-
count: 3
|
|
88
|
-
every: P30D
|
|
89
|
-
first_due: firstDueAt
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Declared clauses
|
|
94
|
-
|
|
95
|
-
- `agent description`
|
|
96
|
-
- `aggregate invariants`
|
|
97
|
-
- `capture input`
|
|
98
|
-
- `description`
|
|
99
|
-
- `due`
|
|
100
|
-
- `input`
|
|
101
|
-
- `moves`
|
|
102
|
-
- `partitions`
|
|
103
|
-
- `port`
|
|
104
|
-
- `sandbox failure point`
|
|
105
|
-
- `sets at`
|
|
106
|
-
- `steps`
|
|
107
|
-
- `summary`
|
|
108
|
-
- `title`
|
|
109
|
-
|
|
110
|
-
This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
|
|
111
|
-
|
|
112
|
-
## Decision ports
|
|
113
|
-
|
|
114
|
-
- `until`
|
|
115
|
-
- `mandate`
|
|
116
|
-
|
|
117
|
-
## Actions and clauses
|
|
118
|
-
|
|
119
|
-
| Action | Clauses lowered |
|
|
120
|
-
| --- | --- |
|
|
121
|
-
| `create` | `agent description`, `steps`, `summary` |
|
|
122
|
-
| `pay_installment_[i]` | `due`, `moves`, `sandbox failure point`, `steps`, `summary` |
|
|
123
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
124
|
-
| `approve` | `agent description`, `steps`, `summary` |
|
|
125
|
-
| `advance` | `agent description`, `moves`, `steps`, `summary` |
|
|
126
|
-
| `collect_installment_[i]` | `due`, `steps`, `summary` |
|
|
127
|
-
| `[delinquent_action]` | `due`, `sets at`, `steps`, `summary` |
|
|
128
|
-
| `complete` | `due`, `steps`, `summary` |
|
|
129
|
-
| `write_off` | `agent description`, `steps`, `summary` |
|
|
130
|
-
| `create` | `agent description`, `steps`, `summary` |
|
|
131
|
-
| `repay` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
|
|
132
|
-
| `refund` | `agent description`, `moves`, `steps`, `summary` |
|
|
133
|
-
| `create` | `agent description`, `steps`, `summary` |
|
|
134
|
-
| `open_period` | `due`, `steps`, `summary` |
|
|
135
|
-
| `collect_period` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
|
|
136
|
-
| `[until]` | `agent description`, `capture input`, `input`, `port`, `steps`, `summary` |
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.0. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# security_deposit
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/security_deposit.hsx`](../../../std/money_flows/security_deposit.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`security_deposit<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `payer` | `party` | Yes | The customer providing the deposit collateral. |
|
|
16
|
-
| `holder` | `party` | Yes | The merchant or owner holding the deposit rights. |
|
|
17
|
-
| `amount` | `money<C>` | Yes | Total reserved deposit amount in minor units of currency `C`. |
|
|
18
|
-
| `claim` | `optional<condition>` | No | Optional condition port triggering a damage claim. |
|
|
19
|
-
| `return` | `optional<condition>` | No | Optional condition port triggering full return of the deposit. |
|
|
20
|
-
| `claim_amount` | `optional<block>` | No | Optional block defining partial claim logic (`field`, `bound`, `remainder`). |
|
|
21
|
-
| `deadline` | `optional<date>` | No | Optional stored date anchor for automatic deposit release or expiry. |
|
|
22
|
-
| `claim_to` | `optional<party>` | No | Optional alternate destination for claimed funds. |
|
|
23
|
-
| `return_to` | `optional<party>` | No | Optional alternate destination for returned funds. |
|
|
24
|
-
| `memo` | `optional<text>` | No | Optional memo text stored on the deposit record. |
|
|
25
|
-
| `claim_input` | `optional<block>` | No | Optional custom input schema for the claim action. |
|
|
26
|
-
| `claim_capture` | `optional<block>` | No | Optional capture mappings for claim evidence. |
|
|
27
|
-
| `fund_failure_point` | `optional<text>` | No | Optional configuration for deposit funding failure. |
|
|
28
|
-
| `id_prefix_override` | `optional<text>` | No | Optional custom prefix for generated instrument IDs. |
|
|
29
|
-
|
|
30
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
31
|
-
|
|
32
|
-
## Module guidance
|
|
33
|
-
|
|
34
|
-
Collateral deposit reserved against a payer's account in favor of a holder, returned in full or claimed against damages.
|
|
35
|
-
|
|
36
|
-
### Purpose
|
|
37
|
-
|
|
38
|
-
`security_deposit` reserves collateral funds for vehicle rentals, property leasing, equipment hire, and security bonds.
|
|
39
|
-
Funds remain held until the rental or lease concludes. The holder can either return the deposit in full
|
|
40
|
-
or assess damages, claim a decided partial amount, and return the exact unspent remainder.
|
|
41
|
-
|
|
42
|
-
### Selection guidance
|
|
43
|
-
|
|
44
|
-
- vs `held_payment`: `security_deposit` holds collateral where the standard outcome is returning 100% of the funds
|
|
45
|
-
to the payer, and claims are partial damage assessments. `held_payment` holds payment consideration where the
|
|
46
|
-
standard outcome is releasing 100% of the funds to the payee upon delivery.
|
|
47
|
-
- vs `cancellable_booking`: `cancellable_booking` holds booking fees and applies time-based cancellation penalties.
|
|
48
|
-
`security_deposit` holds damage collateral and supports arbitrary damage claims with remainder refund.
|
|
49
|
-
|
|
50
|
-
### Parameters
|
|
51
|
-
|
|
52
|
-
- `payer`: The customer providing the deposit collateral.
|
|
53
|
-
- `holder`: The merchant or owner holding the deposit rights.
|
|
54
|
-
- `amount`: Total reserved deposit amount in minor units of currency `C`.
|
|
55
|
-
- `claim`: Optional condition port triggering a damage claim.
|
|
56
|
-
- `return`: Optional condition port triggering full return of the deposit.
|
|
57
|
-
- `claim_amount`: Optional block defining partial claim logic (`field`, `bound`, `remainder`).
|
|
58
|
-
- `deadline`: Optional stored date anchor for automatic deposit release or expiry.
|
|
59
|
-
- `claim_to`: Optional alternate destination for claimed funds.
|
|
60
|
-
- `return_to`: Optional alternate destination for returned funds.
|
|
61
|
-
- `memo`: Optional memo text stored on the deposit record.
|
|
62
|
-
- `claim_input`: Optional custom input schema for the claim action.
|
|
63
|
-
- `claim_capture`: Optional capture mappings for claim evidence.
|
|
64
|
-
- `fund_failure_point`: Optional configuration for deposit funding failure.
|
|
65
|
-
- `id_prefix_override`: Optional custom prefix for generated instrument IDs.
|
|
66
|
-
|
|
67
|
-
### Decision ports
|
|
68
|
-
|
|
69
|
-
- `claim`: Port permitting the holder to submit a damage claim.
|
|
70
|
-
- `return`: Port permitting the holder to return the deposit to the payer.
|
|
71
|
-
|
|
72
|
-
### Example
|
|
73
|
-
|
|
74
|
-
```hsx
|
|
75
|
-
program deposit_example "Deposit example"
|
|
76
|
-
import { security_deposit } from "std/money_flows"
|
|
77
|
-
party renter: person
|
|
78
|
-
party owner: business
|
|
79
|
-
settlement security_deposit = security_deposit {
|
|
80
|
-
payer: renter
|
|
81
|
-
holder: owner
|
|
82
|
-
amount: depositAmount: money(SAR)
|
|
83
|
-
claim: port assess_damage
|
|
84
|
-
claim_amount: decided {
|
|
85
|
-
field: damageAmount
|
|
86
|
-
bound: depositAmount
|
|
87
|
-
remainder: return
|
|
88
|
-
}
|
|
89
|
-
return: port return_deposit
|
|
90
|
-
}
|
|
91
|
-
port assess_damage {
|
|
92
|
-
allowed: [owner]
|
|
93
|
-
shape: { damageAmount: money(SAR), evidence: text }
|
|
94
|
-
}
|
|
95
|
-
port return_deposit { allowed: [owner] }
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Declared clauses
|
|
99
|
-
|
|
100
|
-
- `agent description`
|
|
101
|
-
- `caller parked states`
|
|
102
|
-
- `capture input`
|
|
103
|
-
- `deadline`
|
|
104
|
-
- `decided amount`
|
|
105
|
-
- `description`
|
|
106
|
-
- `dials`
|
|
107
|
-
- `distinct parties`
|
|
108
|
-
- `due`
|
|
109
|
-
- `id prefix`
|
|
110
|
-
- `input`
|
|
111
|
-
- `moves`
|
|
112
|
-
- `port`
|
|
113
|
-
- `sandbox failure point`
|
|
114
|
-
- `steps`
|
|
115
|
-
- `summary`
|
|
116
|
-
- `title`
|
|
117
|
-
|
|
118
|
-
This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
|
|
119
|
-
|
|
120
|
-
## Decision ports
|
|
121
|
-
|
|
122
|
-
- `claim`
|
|
123
|
-
- `return`
|
|
124
|
-
|
|
125
|
-
## Actions and clauses
|
|
126
|
-
|
|
127
|
-
| Action | Clauses lowered |
|
|
128
|
-
| --- | --- |
|
|
129
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
130
|
-
| `place_deposit` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
|
|
131
|
-
| `[claim_name]` | `agent description`, `input`, `moves`, `port`, `steps`, `summary` |
|
|
132
|
-
| `[return_name]` | `agent description`, `capture input`, `input`, `moves`, `port`, `steps`, `summary` |
|
|
133
|
-
| `create` | `agent description`, `deadline`, `moves`, `steps`, `summary` |
|
|
134
|
-
| `fund` | `agent description`, `deadline`, `moves`, `sandbox failure point`, `steps`, `summary` |
|
|
135
|
-
| `claim` | `agent description`, `capture input`, `deadline`, `decided amount`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
|
|
136
|
-
| `return` | `agent description`, `deadline`, `moves`, `port`, `steps`, `summary` |
|
|
137
|
-
| `expire` | `due`, `moves`, `steps`, `summary` |
|
|
138
|
-
| `cancel` | `agent description`, `moves`, `steps`, `summary` |
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.0. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# settlement_batch
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/settlement_batch.hsx`](../../../std/money_flows/settlement_batch.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`settlement_batch<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `settlement_account` | `party` | Yes | The source clearing account holding captured funds and paying the batch. |
|
|
16
|
-
| `source_capture_refs` | `text` | Yes | Binding name for gross capture references included in the batch. |
|
|
17
|
-
| `fee_entries` | `text` | Yes | Binding name for fee deductions applied to the batch. |
|
|
18
|
-
| `external_reversal_offsets` | `text` | Yes | Binding name for reversal adjustments applied to the batch. |
|
|
19
|
-
| `close_trigger` | `date` | Yes | Date when the batch closes and ceases accepting new transaction entries. |
|
|
20
|
-
| `payout_destination` | `party` | Yes | The merchant or partner account receiving the net payout. |
|
|
21
|
-
| `negative_position` | `text` | Yes | Policy when calculated net payable is zero or negative (`reject`). |
|
|
22
|
-
| `payout_acknowledgement` | `condition` | Yes | Condition port confirming bank receipt of the payout. |
|
|
23
|
-
| `payout_beneficiary_ref` | `text` | Yes | Beneficiary identifier for external bank dispatch. |
|
|
24
|
-
|
|
25
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
26
|
-
|
|
27
|
-
## Module guidance
|
|
28
|
-
|
|
29
|
-
Periodic aggregation of capture lineage, fee entries, and adjustments into a single net calculated payout.
|
|
30
|
-
|
|
31
|
-
### Purpose
|
|
32
|
-
|
|
33
|
-
`settlement_batch` settles merchant balances, marketplace vendor earnings, and partner clearing accounts.
|
|
34
|
-
Individual payment captures, platform fees, and reversal adjustments accumulate into an open batch over a period.
|
|
35
|
-
On `close_trigger`, the batch freezes. The platform calculates the signed net payable from gross captures plus credit
|
|
36
|
-
adjustments minus debit adjustments. If positive, an outbound bank payout is instructed and acknowledged.
|
|
37
|
-
|
|
38
|
-
### Selection guidance
|
|
39
|
-
|
|
40
|
-
- vs `reconciled_payout`: `settlement_batch` aggregates multiple transactions and adjustments over a billing cycle
|
|
41
|
-
to compute a single net payable. `reconciled_payout` manages bank instruction dispatch and statement line reconciliation
|
|
42
|
-
for an individual payout amount.
|
|
43
|
-
- vs `weighted_distribution`: `settlement_batch` consolidates many inbound transactions into one net outbound payout.
|
|
44
|
-
`weighted_distribution` splits one funding pool into many recipient payouts.
|
|
45
|
-
|
|
46
|
-
### Parameters
|
|
47
|
-
|
|
48
|
-
- `settlement_account`: The source clearing account holding captured funds and paying the batch.
|
|
49
|
-
- `source_capture_refs`: Binding name for gross capture references included in the batch.
|
|
50
|
-
- `fee_entries`: Binding name for fee deductions applied to the batch.
|
|
51
|
-
- `external_reversal_offsets`: Binding name for reversal adjustments applied to the batch.
|
|
52
|
-
- `close_trigger`: Date when the batch closes and ceases accepting new transaction entries.
|
|
53
|
-
- `payout_destination`: The merchant or partner account receiving the net payout.
|
|
54
|
-
- `negative_position`: Policy when calculated net payable is zero or negative (`reject`).
|
|
55
|
-
- `payout_acknowledgement`: Condition port confirming bank receipt of the payout.
|
|
56
|
-
- `payout_beneficiary_ref`: Beneficiary identifier for external bank dispatch.
|
|
57
|
-
|
|
58
|
-
### Decision ports
|
|
59
|
-
|
|
60
|
-
- `payout_acknowledgement`: Port recording external bank or partner receipt confirmation.
|
|
61
|
-
|
|
62
|
-
### Example
|
|
63
|
-
|
|
64
|
-
```hsx
|
|
65
|
-
program settlement_batch_example "Settlement batch example"
|
|
66
|
-
import { settlement_batch } from "std/money_flows"
|
|
67
|
-
party settlement_account: business
|
|
68
|
-
party payout_destination: business
|
|
69
|
-
settlement batch = settlement_batch {
|
|
70
|
-
settlement_account: settlement_account
|
|
71
|
-
source_capture_refs: captureReference
|
|
72
|
-
fee_entries: feeReference
|
|
73
|
-
external_reversal_offsets: reversalReference
|
|
74
|
-
close_trigger: closeAt
|
|
75
|
-
payout_destination: payout_destination
|
|
76
|
-
negative_position: reject
|
|
77
|
-
payout_acknowledgement: port acknowledge_payout
|
|
78
|
-
payout_beneficiary_ref: payoutBeneficiaryId
|
|
79
|
-
}
|
|
80
|
-
port acknowledge_payout {
|
|
81
|
-
allowed: [payout_destination]
|
|
82
|
-
shape: { acknowledgementReference: text }
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Declared clauses
|
|
87
|
-
|
|
88
|
-
- `agent description`
|
|
89
|
-
- `capture input`
|
|
90
|
-
- `description`
|
|
91
|
-
- `due`
|
|
92
|
-
- `id prefix`
|
|
93
|
-
- `input`
|
|
94
|
-
- `moves`
|
|
95
|
-
- `payout`
|
|
96
|
-
- `port`
|
|
97
|
-
- `reconcile`
|
|
98
|
-
- `steps`
|
|
99
|
-
- `summary`
|
|
100
|
-
- `title`
|
|
101
|
-
|
|
102
|
-
This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
|
|
103
|
-
|
|
104
|
-
## Decision ports
|
|
105
|
-
|
|
106
|
-
- `payout_acknowledgement`
|
|
107
|
-
|
|
108
|
-
## Actions and clauses
|
|
109
|
-
|
|
110
|
-
| Action | Clauses lowered |
|
|
111
|
-
| --- | --- |
|
|
112
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
113
|
-
| `close` | `due`, `moves`, `steps`, `summary` |
|
|
114
|
-
| `calculate` | `agent description`, `moves`, `steps`, `summary` |
|
|
115
|
-
| `approve` | `agent description`, `moves`, `steps`, `summary` |
|
|
116
|
-
| `instruct` | `agent description`, `moves`, `payout`, `steps`, `summary` |
|
|
117
|
-
| `[payout_acknowledgement]` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
|
|
118
|
-
| `reconcile` | `due`, `moves`, `reconcile`, `steps`, `summary` |
|
|
119
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
120
|
-
| `accrue` | `agent description`, `moves`, `steps`, `summary` |
|
|
121
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
122
|
-
| `adjust` | `agent description`, `moves`, `steps`, `summary` |
|
|
123
|
-
| `correct` | `agent description`, `moves`, `steps`, `summary` |
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.0. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# swap
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/swap.hsx`](../../../std/money_flows/swap.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`swap<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `between` | `list<party>` | Yes | List containing exactly two trade participant parties (`[side_a, side_b]`). |
|
|
16
|
-
| `amounts` | `block` | Yes | Block declaring the principal money amounts for each party. |
|
|
17
|
-
| `fees` | `block` | Yes | Block declaring the platform fee money amounts for each party. |
|
|
18
|
-
| `release` | `condition` | Yes | Condition port required to execute the atomic swap release. |
|
|
19
|
-
| `dispute` | `condition` | Yes | Condition port triggering unwinding and refunding of both trade legs. |
|
|
20
|
-
| `side_names` | `optional<block>` | No | Optional custom naming block for the two sides (`first`, `second`). |
|
|
21
|
-
| `lifecycle_state_order` | `optional<list<text>>` | No | Optional custom ordering for lifecycle states. |
|
|
22
|
-
| `action_bindings` | `optional<block>` | No | Optional custom action names. |
|
|
23
|
-
| `parked_states` | `optional<block>` | No | Optional configuration for parked states. |
|
|
24
|
-
| `fixed_prefix` | `optional<text>` | No | Optional custom prefix for generated instrument IDs. |
|
|
25
|
-
|
|
26
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
27
|
-
|
|
28
|
-
## Module guidance
|
|
29
|
-
|
|
30
|
-
Atomic two-sided trade between two parties where neither leg settles alone.
|
|
31
|
-
|
|
32
|
-
### Purpose
|
|
33
|
-
|
|
34
|
-
`swap` executes atomic delivery-versus-payment (DvP) or payment-versus-payment (PvP) exchanges between two named parties.
|
|
35
|
-
Both sides fund their declared principal amounts and platform fees into a shared escrow. The exchange settles atomically
|
|
36
|
-
upon triggering the `release` condition port, paying each party the other's funded amount. If a `dispute` occurs,
|
|
37
|
-
both legs unwind and refund simultaneously. Half-funded or half-released states cannot occur.
|
|
38
|
-
|
|
39
|
-
### Selection guidance
|
|
40
|
-
|
|
41
|
-
- vs `held_payment`: `swap` is a bilateral trade where both sides must deposit funds into escrow and receive each other's
|
|
42
|
-
disbursements simultaneously. `held_payment` is unilateral escrow where a single payer funds a payment held for a payee.
|
|
43
|
-
- vs `instant_transfer`: `instant_transfer` executes an immediate one-way transfer. `swap` coordinates two reciprocal transfers
|
|
44
|
-
held atomically in escrow until release confirmation.
|
|
45
|
-
|
|
46
|
-
### Parameters
|
|
47
|
-
|
|
48
|
-
- `between`: List containing exactly two trade participant parties (`[side_a, side_b]`).
|
|
49
|
-
- `amounts`: Block declaring the principal money amounts for each party.
|
|
50
|
-
- `fees`: Block declaring the platform fee money amounts for each party.
|
|
51
|
-
- `release`: Condition port required to execute the atomic swap release.
|
|
52
|
-
- `dispute`: Condition port triggering unwinding and refunding of both trade legs.
|
|
53
|
-
- `side_names`: Optional custom naming block for the two sides (`first`, `second`).
|
|
54
|
-
- `lifecycle_state_order`: Optional custom ordering for lifecycle states.
|
|
55
|
-
- `action_bindings`: Optional custom action names.
|
|
56
|
-
- `parked_states`: Optional configuration for parked states.
|
|
57
|
-
- `fixed_prefix`: Optional custom prefix for generated instrument IDs.
|
|
58
|
-
|
|
59
|
-
### Decision ports
|
|
60
|
-
|
|
61
|
-
- `release`: Port authorizing atomic settlement of both trade legs.
|
|
62
|
-
- `dispute`: Port triggering atomic cancellation and refund of both parties.
|
|
63
|
-
|
|
64
|
-
### Example
|
|
65
|
-
|
|
66
|
-
```hsx
|
|
67
|
-
program swap_example "Swap example"
|
|
68
|
-
import { swap } from "std/money_flows"
|
|
69
|
-
party buyer: business
|
|
70
|
-
party seller: business
|
|
71
|
-
settlement exchange = swap {
|
|
72
|
-
between: [buyer, seller]
|
|
73
|
-
amounts {
|
|
74
|
-
buyer: buyerAmount: money(SAR)
|
|
75
|
-
seller: sellerAmount: money(SAR)
|
|
76
|
-
}
|
|
77
|
-
fees {
|
|
78
|
-
buyer: buyerFee: money(SAR)
|
|
79
|
-
seller: sellerFee: money(SAR)
|
|
80
|
-
}
|
|
81
|
-
release: port release_exchange
|
|
82
|
-
dispute: port dispute_exchange within P7D
|
|
83
|
-
}
|
|
84
|
-
port release_exchange { allowed: [buyer, seller] }
|
|
85
|
-
port dispute_exchange { allowed: [buyer, seller] }
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Declared clauses
|
|
89
|
-
|
|
90
|
-
- `agent description`
|
|
91
|
-
- `caller parked states`
|
|
92
|
-
- `capture input`
|
|
93
|
-
- `deadline`
|
|
94
|
-
- `description`
|
|
95
|
-
- `distinct parties`
|
|
96
|
-
- `due`
|
|
97
|
-
- `event name`
|
|
98
|
-
- `id prefix`
|
|
99
|
-
- `input`
|
|
100
|
-
- `moves`
|
|
101
|
-
- `port`
|
|
102
|
-
- `public action`
|
|
103
|
-
- `sandbox failure point`
|
|
104
|
-
- `sets at`
|
|
105
|
-
- `steps`
|
|
106
|
-
- `summary`
|
|
107
|
-
- `title`
|
|
108
|
-
|
|
109
|
-
This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
|
|
110
|
-
|
|
111
|
-
## Decision ports
|
|
112
|
-
|
|
113
|
-
- `release`
|
|
114
|
-
- `dispute`
|
|
115
|
-
|
|
116
|
-
## Actions and clauses
|
|
117
|
-
|
|
118
|
-
| Action | Clauses lowered |
|
|
119
|
-
| --- | --- |
|
|
120
|
-
| `abandon` | `agent description`, `moves`, `public action`, `steps`, `summary` |
|
|
121
|
-
| `cancel` | `agent description`, `moves`, `public action`, `steps`, `summary` |
|
|
122
|
-
| `create` | `agent description`, `moves`, `public action`, `steps`, `summary` |
|
|
123
|
-
| `dispute` | `agent description`, `capture input`, `deadline`, `input`, `moves`, `port`, `public action`, `steps`, `summary` |
|
|
124
|
-
| `fund` | `agent description`, `moves`, `public action`, `sandbox failure point`, `steps`, `summary` |
|
|
125
|
-
| `post` | `due`, `moves`, `steps`, `summary` |
|
|
126
|
-
| `release` | `agent description`, `moves`, `port`, `public action`, `sandbox failure point`, `sets at`, `steps`, `summary` |
|
|
127
|
-
| `create` | `agent description`, `moves`, `public action`, `steps`, `summary` |
|
|
128
|
-
| `fund` | `agent description`, `event name`, `moves`, `public action`, `sandbox failure point`, `steps`, `summary` |
|
|
129
|
-
| `release` | `agent description`, `event name`, `moves`, `port`, `public action`, `sandbox failure point`, `sets at`, `steps`, `summary` |
|
|
130
|
-
| `post` | `due`, `event name`, `moves`, `steps`, `summary` |
|
|
131
|
-
| `dispute` | `agent description`, `capture input`, `deadline`, `event name`, `input`, `moves`, `port`, `public action`, `steps`, `summary` |
|
|
132
|
-
| `cancel` | `agent description`, `event name`, `moves`, `public action`, `steps`, `summary` |
|
|
133
|
-
| `abandon` | `agent description`, `event name`, `moves`, `public action`, `steps`, `summary` |
|