@rootzero/contracts 1.22.0 → 1.24.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/Codec.sol +1 -1
  3. package/Commands.sol +1 -1
  4. package/Core.sol +2 -2
  5. package/Endpoints.sol +10 -4
  6. package/Events.sol +1 -1
  7. package/README.md +40 -32
  8. package/Utils.sol +1 -1
  9. package/annotations/Action.sol +1 -1
  10. package/annotations/Label.sol +1 -1
  11. package/annotations/Schema.sol +2 -8
  12. package/codec/Blocks.sol +113 -33
  13. package/codec/Decoders.sol +18 -1
  14. package/codec/Descriptors.sol +3 -1
  15. package/codec/Keys.sol +2 -0
  16. package/codec/Readers.sol +12 -0
  17. package/codec/Schema.sol +5 -4
  18. package/codec/Specs.sol +3 -0
  19. package/codec/Writers.sol +12 -1
  20. package/commands/Allocate.sol +5 -8
  21. package/commands/Base.sol +29 -13
  22. package/commands/Burn.sol +5 -7
  23. package/commands/Credit.sol +5 -7
  24. package/commands/Debit.sol +5 -7
  25. package/commands/Deposit.sol +10 -14
  26. package/commands/Payout.sol +5 -8
  27. package/commands/Provision.sol +10 -14
  28. package/commands/Recover.sol +4 -6
  29. package/commands/Relay.sol +14 -21
  30. package/commands/Repay.sol +120 -24
  31. package/commands/Settle.sol +10 -14
  32. package/commands/Withdraw.sol +5 -7
  33. package/commands/admin/AllowAssets.sol +5 -7
  34. package/commands/admin/Allowance.sol +5 -7
  35. package/commands/admin/Annotate.sol +5 -7
  36. package/commands/admin/Appoint.sol +5 -7
  37. package/commands/admin/Authorize.sol +5 -7
  38. package/commands/admin/Base.sol +12 -3
  39. package/commands/admin/DenyAssets.sol +5 -7
  40. package/commands/admin/Dismiss.sol +5 -7
  41. package/commands/admin/Execute.sol +5 -7
  42. package/commands/admin/Unauthorize.sol +5 -7
  43. package/core/Access.sol +8 -0
  44. package/core/Calls.sol +72 -3
  45. package/core/Portal.sol +2 -2
  46. package/core/Types.sol +8 -0
  47. package/events/Positioned.sol +22 -0
  48. package/execution/Execution.sol +66 -1
  49. package/package.json +1 -1
  50. package/ports/Allowance.sol +22 -12
  51. package/ports/Assets.sol +99 -0
  52. package/utils/Cursors.sol +3 -3
  53. package/utils/Nodes.sol +1 -1
  54. package/utils/Utils.sol +41 -31
  55. package/events/Commander.sol +0 -19
  56. package/ports/AllowAssets.sol +0 -34
  57. package/ports/DenyAssets.sol +0 -34
@@ -26,22 +26,20 @@ abstract contract CreditAccount is CommandBase, CreditAccountHook {
26
26
  }
27
27
 
28
28
  /// @notice Credit each BALANCE block from the command state to the command account.
29
- /// @param state BALANCE block stream.
29
+ /// @param context Command context carrying the BALANCE state stream.
30
30
  /// @return Empty output state.
31
31
  /// @return Empty transaction stream.
32
32
  function creditAccount(
33
- bytes32 account,
34
- bytes calldata state,
35
- bytes calldata input
33
+ bytes calldata context
36
34
  ) external onlyCommand returns (bytes memory, bytes memory) {
37
- Execution memory exec = openCommand(state, input, descriptor, 0);
35
+ Execution memory exec = openCommand(context, descriptor, 0);
38
36
 
39
37
  while (exec.more()) {
40
38
  (bytes32 asset, uint amount) = exec.unpackBalance(Lanes.State);
41
- creditAccount(account, asset, amount);
39
+ creditAccount(exec.account, asset, amount);
42
40
  }
43
41
 
44
- return close(exec, account);
42
+ return closeCommand(exec);
45
43
  }
46
44
  }
47
45
 
@@ -29,23 +29,21 @@ abstract contract DebitAccount is CommandBase, DebitAccountHook {
29
29
  }
30
30
 
31
31
  /// @notice Debit AMOUNT input blocks from the command account and output matching BALANCE blocks.
32
- /// @param input AMOUNT block stream.
32
+ /// @param context Command context carrying the AMOUNT input stream.
33
33
  /// @return BALANCE block stream matching the debited amounts.
34
34
  /// @return Empty transaction stream.
35
35
  function debitAccount(
36
- bytes32 account,
37
- bytes calldata state,
38
- bytes calldata input
36
+ bytes calldata context
39
37
  ) external onlyCommand returns (bytes memory, bytes memory) {
40
- Execution memory exec = openCommand(state, input, descriptor, 0);
38
+ Execution memory exec = openCommand(context, descriptor, 0);
41
39
 
42
40
  while (exec.more()) {
43
41
  (bytes32 asset, uint amount) = exec.unpackAmount(Lanes.Input);
44
- debitAccount(account, asset, amount);
42
+ debitAccount(exec.account, asset, amount);
45
43
  exec.outputBalance(asset, amount);
46
44
  }
47
45
 
48
- return close(exec, account);
46
+ return closeCommand(exec);
49
47
  }
50
48
  }
51
49
 
@@ -44,23 +44,21 @@ abstract contract Deposit is CommandBase, DepositHook, Action {
44
44
  }
45
45
 
46
46
  /// @notice Deposit AMOUNT input blocks into the command account and output matching BALANCE blocks.
47
- /// @param input AMOUNT block stream.
47
+ /// @param context Command context carrying the AMOUNT input stream.
48
48
  /// @return BALANCE block stream matching the deposited amounts.
49
49
  /// @return Empty transaction stream.
50
50
  function deposit(
51
- bytes32 account,
52
- bytes calldata state,
53
- bytes calldata input
51
+ bytes calldata context
54
52
  ) external onlyCommand returns (bytes memory, bytes memory) {
55
- Execution memory exec = openCommand(state, input, descriptor, 0);
53
+ Execution memory exec = openCommand(context, descriptor, 0);
56
54
 
57
55
  while (exec.more()) {
58
56
  (bytes32 asset, uint amount) = exec.unpackAmount(Lanes.Input);
59
- deposit(account, asset, amount);
57
+ deposit(exec.account, asset, amount);
60
58
  exec.outputBalance(asset, amount);
61
59
  }
62
60
 
63
- return close(exec, account);
61
+ return closeCommand(exec);
64
62
  }
65
63
  }
66
64
 
@@ -77,22 +75,20 @@ abstract contract DepositPayable is CommandBase, DepositPayableHook, Action {
77
75
  }
78
76
 
79
77
  /// @notice Deposit AMOUNT input blocks with access to a mutable native-value budget.
80
- /// @param input AMOUNT block stream.
78
+ /// @param context Command context carrying the AMOUNT input stream.
81
79
  /// @return BALANCE block stream matching the deposited amounts.
82
80
  /// @return Remaining native value as a refund transaction stream.
83
81
  function depositPayable(
84
- bytes32 account,
85
- bytes calldata state,
86
- bytes calldata input
82
+ bytes calldata context
87
83
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
88
- Execution memory exec = openCommand(state, input, descriptor, 0);
84
+ Execution memory exec = openCommand(context, descriptor, 0);
89
85
 
90
86
  while (exec.more()) {
91
87
  (bytes32 asset, uint amount) = exec.unpackAmount(Lanes.Input);
92
- deposit(account, asset, amount, exec);
88
+ deposit(exec.account, asset, amount, exec);
93
89
  exec.outputBalance(asset, amount);
94
90
  }
95
91
 
96
- return close(exec, account);
92
+ return closeCommand(exec);
97
93
  }
98
94
  }
@@ -31,22 +31,19 @@ abstract contract Payout is CommandBase, PayoutHook, Action {
31
31
  }
32
32
 
33
33
  /// @notice Pay out BALANCE state blocks to matching ACCOUNT input blocks.
34
- /// @param state BALANCE block stream.
35
- /// @param input Matching ACCOUNT block stream.
34
+ /// @param context Command context carrying BALANCE state and matching ACCOUNT input.
36
35
  /// @return Empty output state.
37
36
  /// @return Empty transaction stream.
38
37
  function payout(
39
- bytes32 account,
40
- bytes calldata state,
41
- bytes calldata input
38
+ bytes calldata context
42
39
  ) external onlyCommand returns (bytes memory, bytes memory) {
43
- Execution memory exec = openCommand(state, input, descriptor, 0);
40
+ Execution memory exec = openCommand(context, descriptor, 0);
44
41
 
45
42
  while (exec.more()) {
46
43
  (bytes32 asset, uint amount) = exec.unpackBalance(Lanes.State);
47
- payout(account, exec.unpackAccount(Lanes.Input), asset, amount);
44
+ payout(exec.account, exec.unpackAccount(Lanes.Input), asset, amount);
48
45
  }
49
46
 
50
- return close(exec, account);
47
+ return closeCommand(exec);
51
48
  }
52
49
  }
@@ -36,23 +36,21 @@ abstract contract Provision is CommandBase, ProvisionHook {
36
36
  }
37
37
 
38
38
  /// @notice Provision ALLOCATION input blocks and output matching CUSTODY state blocks.
39
- /// @param input ALLOCATION block stream.
39
+ /// @param context Command context carrying the ALLOCATION input stream.
40
40
  /// @return CUSTODY block stream matching the provisioned allocations.
41
41
  /// @return Empty transaction stream.
42
42
  function provision(
43
- bytes32 account,
44
- bytes calldata state,
45
- bytes calldata input
43
+ bytes calldata context
46
44
  ) external onlyCommand returns (bytes memory, bytes memory) {
47
- Execution memory exec = openCommand(state, input, descriptor, 0);
45
+ Execution memory exec = openCommand(context, descriptor, 0);
48
46
 
49
47
  while (exec.more()) {
50
48
  HostAmount memory allocation = exec.unpackAllocationValue(Lanes.Input);
51
- provision(account, allocation);
49
+ provision(exec.account, allocation);
52
50
  exec.outputCustody(allocation);
53
51
  }
54
52
 
55
- return close(exec, account);
53
+ return closeCommand(exec);
56
54
  }
57
55
  }
58
56
 
@@ -68,23 +66,21 @@ abstract contract ProvisionPayable is CommandBase, ProvisionPayableHook {
68
66
  }
69
67
 
70
68
  /// @notice Provision ALLOCATION input blocks with access to a mutable native-value budget.
71
- /// @param input ALLOCATION block stream.
69
+ /// @param context Command context carrying the ALLOCATION input stream.
72
70
  /// @return CUSTODY block stream matching the provisioned allocations.
73
71
  /// @return Remaining native value as a refund transaction stream.
74
72
  function provisionPayable(
75
- bytes32 account,
76
- bytes calldata state,
77
- bytes calldata input
73
+ bytes calldata context
78
74
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
79
- Execution memory exec = openCommand(state, input, descriptor, 0);
75
+ Execution memory exec = openCommand(context, descriptor, 0);
80
76
 
81
77
  while (exec.more()) {
82
78
  HostAmount memory allocation = exec.unpackAllocationValue(Lanes.Input);
83
- provision(account, allocation, exec);
79
+ provision(exec.account, allocation, exec);
84
80
  exec.outputCustody(allocation);
85
81
  }
86
82
 
87
- return close(exec, account);
83
+ return closeCommand(exec);
88
84
  }
89
85
  }
90
86
 
@@ -35,21 +35,19 @@ abstract contract RecoverPayable is CommandBase, RecoverPayableHook {
35
35
  }
36
36
 
37
37
  /// @notice Recover each recover block in the command input.
38
- /// @param input RECOVER block stream.
38
+ /// @param context Command context carrying the RECOVER input stream.
39
39
  /// @return Empty output state.
40
40
  /// @return Remaining native value as a refund transaction stream.
41
41
  function recoverPayable(
42
- bytes32 account,
43
- bytes calldata state,
44
- bytes calldata input
42
+ bytes calldata context
45
43
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
46
- Execution memory exec = openCommand(state, input, descriptor, 0);
44
+ Execution memory exec = openCommand(context, descriptor, 0);
47
45
 
48
46
  while (exec.more()) {
49
47
  (uint handler, uint resources, bytes32 key, bytes calldata witness) = exec.unpackRecover(Lanes.Input);
50
48
  recover(handler, resources, key, witness, exec);
51
49
  }
52
50
 
53
- return close(exec, account);
51
+ return closeCommand(exec);
54
52
  }
55
53
  }
@@ -13,17 +13,15 @@ abstract contract RelayPayableHook {
13
13
  /// @param resources Chain-specific destination resources. EVM adapters
14
14
  /// may interpret this as packed execution gas and destination value.
15
15
  /// @param account Destination command account.
16
- /// @param state State forwarded into the destination context.
17
16
  /// @param input Input forwarded into the destination context.
18
- /// @param funds Execution used for source value available for transport fees
19
- /// and destination resource funding.
17
+ /// @param exec Execution carrying the source state and value available for
18
+ /// transport fees and destination resource funding.
20
19
  function relay(
21
20
  uint portal,
22
21
  uint resources,
23
22
  bytes32 account,
24
- bytes calldata state,
25
23
  bytes calldata input,
26
- Execution memory funds
24
+ Execution memory exec
27
25
  ) internal virtual;
28
26
  }
29
27
 
@@ -38,15 +36,13 @@ abstract contract RelayPayable is CommandBase, RelayPayableHook {
38
36
 
39
37
  /// @notice Relay one RELAY input block with the command account and empty state.
40
38
  function relayPayable(
41
- bytes32 account,
42
- bytes calldata state,
43
- bytes calldata input
39
+ bytes calldata context
44
40
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
45
- Execution memory exec = openCommand(state, input, descriptor, 1);
46
- (uint portal, uint resources, bytes calldata relayInput) = exec.unpackRelay(Lanes.Input);
47
- relay(portal, resources, account, state, relayInput, exec);
41
+ Execution memory exec = openCommand(context, descriptor, 1);
42
+ (uint portal, uint resources, bytes calldata input) = exec.unpackRelay(Lanes.Input);
43
+ relay(portal, resources, exec.account, input, exec);
48
44
 
49
- return close(exec, account);
45
+ return closeCommand(exec);
50
46
  }
51
47
  }
52
48
 
@@ -63,19 +59,16 @@ abstract contract RelayBalancePayable is CommandBase, RelayPayableHook {
63
59
  }
64
60
 
65
61
  /// @notice Relay one RELAY input block with the command account and current state.
66
- /// @param state State forwarded into the destination context.
67
- /// @param input Exactly one RELAY block.
62
+ /// @param context Command context carrying state and exactly one RELAY input block.
68
63
  /// @return Empty output state.
69
64
  /// @return Remaining native value as a refund transaction stream.
70
65
  function relayBalancePayable(
71
- bytes32 account,
72
- bytes calldata state,
73
- bytes calldata input
66
+ bytes calldata context
74
67
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
75
- Execution memory exec = openCommand(state, input, descriptor, 1);
76
- (uint portal, uint resources, bytes calldata relayInput) = exec.unpackRelay(Lanes.Input);
77
- relay(portal, resources, account, state, relayInput, exec);
68
+ Execution memory exec = openCommand(context, descriptor, 1);
69
+ (uint portal, uint resources, bytes calldata input) = exec.unpackRelay(Lanes.Input);
70
+ relay(portal, resources, exec.account, input, exec);
78
71
 
79
- return close(exec, account);
72
+ return closeCommand(exec);
80
73
  }
81
74
  }
@@ -5,10 +5,13 @@ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.so
5
5
  import {RepayHook} from "../core/Settlement.sol";
6
6
  import {Action} from "../annotations/Action.sol";
7
7
  import {Actions} from "../utils/Actions.sol";
8
+ import {Blocks} from "../codec/Blocks.sol";
9
+ import {Reader, Readers} from "../codec/Readers.sol";
8
10
 
9
11
  using Executions for Execution;
12
+ using Readers for Reader;
10
13
 
11
- /// @notice Hook implemented by hosts that repay position liabilities using native value.
14
+ /// @notice Hook implemented by hosts that repay liabilities using native value.
12
15
  abstract contract RepayPayableHook {
13
16
  /// @notice Override to repay one liability for `account` with a shared value budget.
14
17
  /// @param account Account whose liability is being repaid.
@@ -19,65 +22,158 @@ abstract contract RepayPayableHook {
19
22
  }
20
23
 
21
24
  /// @title Repay
22
- /// @notice Command that repays POSITION liabilities and returns their assets as BALANCE state.
25
+ /// @notice Command that consumes DEBT state by repaying each liability.
23
26
  abstract contract Repay is CommandBase, RepayHook, Action {
24
27
  uint private immutable descriptor;
28
+ uint private immutable id;
29
+
30
+ constructor() {
31
+ (id, descriptor) = command("repay", Specs.Debt, Specs.Empty, Specs.Empty, 0, 0);
32
+ action(id, Actions.Repay);
33
+ }
34
+
35
+ /// @notice Return the registered REPAY command ID.
36
+ function repayId() internal view returns (uint) {
37
+ return id;
38
+ }
39
+
40
+ /// @notice Repay each liability in the DEBT state stream.
41
+ /// @param context Command context carrying the DEBT state stream.
42
+ /// @return Empty output state.
43
+ /// @return Empty transaction stream.
44
+ function repay(
45
+ bytes calldata context
46
+ ) external onlyCommand returns (bytes memory, bytes memory) {
47
+ Execution memory exec = openCommand(context, descriptor, 0);
48
+
49
+ while (exec.more()) {
50
+ (bytes32 liability, uint debt) = exec.unpackDebt(Lanes.State);
51
+ repay(exec.account, liability, debt);
52
+ }
53
+
54
+ return closeCommand(exec);
55
+ }
56
+ }
57
+
58
+ /// @title RepayPayable
59
+ /// @notice Funded command that consumes DEBT state by repaying each liability.
60
+ abstract contract RepayPayable is CommandBase, RepayPayableHook, Action {
61
+ uint private immutable descriptor;
62
+
63
+ constructor() {
64
+ uint id;
65
+ (id, descriptor) = command("repayPayable", Specs.Debt, Specs.Empty, Specs.Empty, 0, Flags.Funded);
66
+ action(id, Actions.Repay);
67
+ }
68
+
69
+ /// @notice Repay each liability in the DEBT state stream.
70
+ /// @param context Command context carrying the DEBT state stream.
71
+ /// @return Empty output state.
72
+ /// @return Remaining native value as a refund transaction stream.
73
+ function repayPayable(
74
+ bytes calldata context
75
+ ) external payable onlyCommand returns (bytes memory, bytes memory) {
76
+ Execution memory exec = openCommand(context, descriptor, 0);
77
+
78
+ while (exec.more()) {
79
+ (bytes32 liability, uint debt) = exec.unpackDebt(Lanes.State);
80
+ repay(exec.account, liability, debt, exec);
81
+ }
82
+
83
+ return closeCommand(exec);
84
+ }
85
+ }
86
+
87
+ /// @title RepayPosition
88
+ /// @notice Command that repays POSITION liabilities and returns their assets as BALANCE state.
89
+ abstract contract RepayPosition is CommandBase, RepayHook, Action {
90
+ uint private immutable descriptor;
25
91
 
26
92
  constructor() {
27
93
  uint id;
28
- (id, descriptor) = command("repay", Specs.Position, Specs.Empty, Specs.Balance, 0, 0);
29
- action(id, Actions.Settle);
94
+ (id, descriptor) = command("repayPosition", Specs.Position, Specs.Empty, Specs.Balance, 0, 0);
95
+ action(id, Actions.Repay);
30
96
  }
31
97
 
32
98
  /// @notice Repay each POSITION liability and return its asset as BALANCE state.
33
- /// @param state POSITION block stream.
99
+ /// @param context Command context carrying the POSITION state stream.
34
100
  /// @return BALANCE output state containing each released asset side.
35
101
  /// @return Empty transaction stream.
36
- function repay(
37
- bytes32 account,
38
- bytes calldata state,
39
- bytes calldata input
102
+ function repayPosition(
103
+ bytes calldata context
40
104
  ) external onlyCommand returns (bytes memory, bytes memory) {
41
- Execution memory exec = openCommand(state, input, descriptor, 0);
105
+ Execution memory exec = openCommand(context, descriptor, 0);
42
106
 
43
107
  while (exec.more()) {
44
108
  (bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
45
- repay(account, liability, debt);
109
+ repay(exec.account, liability, debt);
46
110
  exec.outputBalance(asset, amount);
47
111
  }
48
112
 
49
- return close(exec, account);
113
+ return closeCommand(exec);
50
114
  }
51
115
  }
52
116
 
53
- /// @title RepayPayable
117
+ /// @title RepayPositionPayable
54
118
  /// @notice Funded command that repays POSITION liabilities and returns their assets as BALANCE state.
55
- abstract contract RepayPayable is CommandBase, RepayPayableHook, Action {
119
+ abstract contract RepayPositionPayable is CommandBase, RepayPayableHook, Action {
56
120
  uint private immutable descriptor;
57
121
 
58
122
  constructor() {
59
123
  uint id;
60
- (id, descriptor) = command("repayPayable", Specs.Position, Specs.Empty, Specs.Balance, 0, Flags.Funded);
61
- action(id, Actions.Settle);
124
+ (id, descriptor) = command(
125
+ "repayPositionPayable", Specs.Position, Specs.Empty, Specs.Balance, 0, Flags.Funded
126
+ );
127
+ action(id, Actions.Repay);
62
128
  }
63
129
 
64
130
  /// @notice Repay each POSITION liability and return its asset as BALANCE state.
65
- /// @param state POSITION block stream.
131
+ /// @param context Command context carrying the POSITION state stream.
66
132
  /// @return BALANCE output state containing each released asset side.
67
133
  /// @return Remaining native value as a refund transaction stream.
68
- function repayPayable(
69
- bytes32 account,
70
- bytes calldata state,
71
- bytes calldata input
134
+ function repayPositionPayable(
135
+ bytes calldata context
72
136
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
73
- Execution memory exec = openCommand(state, input, descriptor, 0);
137
+ Execution memory exec = openCommand(context, descriptor, 0);
74
138
 
75
139
  while (exec.more()) {
76
140
  (bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
77
- repay(account, liability, debt, exec);
141
+ repay(exec.account, liability, debt, exec);
78
142
  exec.outputBalance(asset, amount);
79
143
  }
80
144
 
81
- return close(exec, account);
145
+ return closeCommand(exec);
146
+ }
147
+ }
148
+
149
+ /// @title RepayInternal
150
+ /// @notice Extends the advertised repay command with memory-state pipeline dispatch.
151
+ /// @dev This adapter is not a separate command. It uses the command ID and repayment hook
152
+ /// inherited from `Repay` while accepting the state location used by `Pipeline`.
153
+ abstract contract RepayInternal is Repay {
154
+ /// @notice Execute the inherited repay command from an internal pipeline.
155
+ /// @param account Account whose liabilities are repaid.
156
+ /// @param state DEBT block stream held in pipeline memory.
157
+ /// @param input Empty input required by the command schema.
158
+ /// @param value Native value assigned to the command; must be zero.
159
+ /// @return output Empty output state.
160
+ /// @return transactions Empty transaction stream.
161
+ function executeRepay(
162
+ bytes32 account,
163
+ bytes memory state,
164
+ bytes calldata input,
165
+ uint128 value
166
+ ) internal returns (bytes memory, bytes memory) {
167
+ if (value != 0) revert ValueNotAllowed();
168
+ if (input.length != 0) revert Executions.ZeroStride();
169
+ if (state.length == 0) revert Blocks.EmptyRun();
170
+
171
+ Reader memory reader = Readers.open(state);
172
+ while (reader.more()) {
173
+ (bytes32 liability, uint debt) = reader.unpackDebt();
174
+ repay(account, liability, debt);
175
+ }
176
+
177
+ return ("", "");
82
178
  }
83
179
  }
@@ -47,22 +47,20 @@ abstract contract Settle is CommandBase, SettleHook, Action {
47
47
  }
48
48
 
49
49
  /// @notice Settle each POSITION block from the command state.
50
- /// @param state POSITION block stream.
50
+ /// @param context Command context carrying the POSITION state stream.
51
51
  /// @return Empty output state.
52
52
  /// @return Empty transaction stream.
53
53
  function settle(
54
- bytes32 account,
55
- bytes calldata state,
56
- bytes calldata input
54
+ bytes calldata context
57
55
  ) external onlyCommand returns (bytes memory, bytes memory) {
58
- Execution memory exec = openCommand(state, input, descriptor, 0);
56
+ Execution memory exec = openCommand(context, descriptor, 0);
59
57
 
60
58
  while (exec.more()) {
61
59
  (bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
62
- settle(account, asset, amount, liability, debt);
60
+ settle(exec.account, asset, amount, liability, debt);
63
61
  }
64
62
 
65
- return close(exec, account);
63
+ return closeCommand(exec);
66
64
  }
67
65
  }
68
66
 
@@ -78,22 +76,20 @@ abstract contract SettlePayable is CommandBase, SettlePayableHook, Action {
78
76
  }
79
77
 
80
78
  /// @notice Settle each POSITION block with access to a shared native-value budget.
81
- /// @param state POSITION block stream.
79
+ /// @param context Command context carrying the POSITION state stream.
82
80
  /// @return Empty output state.
83
81
  /// @return Remaining native value as a refund transaction stream.
84
82
  function settlePayable(
85
- bytes32 account,
86
- bytes calldata state,
87
- bytes calldata input
83
+ bytes calldata context
88
84
  ) external payable onlyCommand returns (bytes memory, bytes memory) {
89
- Execution memory exec = openCommand(state, input, descriptor, 0);
85
+ Execution memory exec = openCommand(context, descriptor, 0);
90
86
 
91
87
  while (exec.more()) {
92
88
  (bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
93
- settle(account, asset, amount, liability, debt, exec);
89
+ settle(exec.account, asset, amount, liability, debt, exec);
94
90
  }
95
91
 
96
- return close(exec, account);
92
+ return closeCommand(exec);
97
93
  }
98
94
  }
99
95
 
@@ -30,21 +30,19 @@ abstract contract Withdraw is CommandBase, WithdrawHook, Action {
30
30
  }
31
31
 
32
32
  /// @notice Withdraw each BALANCE block from the command state to the command account.
33
- /// @param state BALANCE block stream.
33
+ /// @param context Command context carrying the BALANCE state stream.
34
34
  /// @return Empty output state.
35
35
  /// @return Empty transaction stream.
36
36
  function withdraw(
37
- bytes32 account,
38
- bytes calldata state,
39
- bytes calldata input
37
+ bytes calldata context
40
38
  ) external onlyCommand returns (bytes memory, bytes memory) {
41
- Execution memory exec = openCommand(state, input, descriptor, 0);
39
+ Execution memory exec = openCommand(context, descriptor, 0);
42
40
 
43
41
  while (exec.more()) {
44
42
  (bytes32 asset, uint amount) = exec.unpackBalance(Lanes.State);
45
- withdraw(account, asset, amount);
43
+ withdraw(exec.account, asset, amount);
46
44
  }
47
45
 
48
- return close(exec, account);
46
+ return closeCommand(exec);
49
47
  }
50
48
  }
@@ -23,22 +23,20 @@ abstract contract AllowAssets is AdminBase, AllowAssetsHook {
23
23
  }
24
24
 
25
25
  /// @notice Allow each ASSET block in the admin input.
26
- /// @param input ASSET block stream.
26
+ /// @param context Admin command context carrying the ASSET input stream.
27
27
  /// @return Empty output state.
28
28
  /// @return Empty transaction stream.
29
29
  function allowAssets(
30
- bytes32 account,
31
- bytes calldata state,
32
- bytes calldata input
33
- ) external onlyAdmin(account) returns (bytes memory, bytes memory) {
34
- Execution memory exec = openCommand(state, input, descriptor, 0);
30
+ bytes calldata context
31
+ ) external returns (bytes memory, bytes memory) {
32
+ Execution memory exec = openAdminCommand(context, descriptor, 0);
35
33
 
36
34
  while (exec.more()) {
37
35
  bytes32 asset = exec.unpackAsset(Lanes.Input);
38
36
  allowAsset(asset);
39
37
  }
40
38
 
41
- return close(exec, account);
39
+ return closeCommand(exec);
42
40
  }
43
41
  }
44
42
 
@@ -27,21 +27,19 @@ abstract contract Allowance is AdminBase, AllowanceHook {
27
27
  }
28
28
 
29
29
  /// @notice Apply each ALLOWANCE block in the admin input.
30
- /// @param input ALLOWANCE block stream.
30
+ /// @param context Admin command context carrying the ALLOWANCE input stream.
31
31
  /// @return Empty output state.
32
32
  /// @return Empty transaction stream.
33
33
  function allowance(
34
- bytes32 account,
35
- bytes calldata state,
36
- bytes calldata input
37
- ) external onlyAdmin(account) returns (bytes memory, bytes memory) {
38
- Execution memory exec = openCommand(state, input, descriptor, 0);
34
+ bytes calldata context
35
+ ) external returns (bytes memory, bytes memory) {
36
+ Execution memory exec = openAdminCommand(context, descriptor, 0);
39
37
 
40
38
  while (exec.more()) {
41
39
  (uint peer, bytes32 asset, uint amount) = exec.unpackAllowance(Lanes.Input);
42
40
  allowance(peer, asset, amount);
43
41
  }
44
42
 
45
- return close(exec, account);
43
+ return closeCommand(exec);
46
44
  }
47
45
  }