Skip to content

swap_order: relax cancel policy from AllOf to AtLeast(2, owners) - #18

Merged
KtorZ merged 1 commit into
mainfrom
swap-cancel-atleast-2
May 16, 2026
Merged

KtorZ merged 1 commit into
mainfrom
swap-cancel-atleast-2

Conversation

@paolino

@paolino paolino commented May 16, 2026

Copy link
Copy Markdown
Contributor

As discussed in the Discord channel.

Summary

Flip the SundaeSwap V3 order owner-policy embedded into the swap order datum from AllOf (4-of-4 owners) to AtLeast 2 (2-of-4 owners). One-file change in journal/2026/lib/swap_order.sh.

Rationale

Any 2 of the 4 treasury scope owners can already disburse funds out of the treasury at will. Requiring all 4 signatures merely to cancel a pending swap order — and return the locked ADA back to that same treasury — is therefore strictly more restrictive than the disburse permission and creates a denial-of-cancellation risk if any one owner is unavailable. Aligning the swap-cancel policy with the disburse threshold makes cancellation no easier than spending the returned funds, so the change does not weaken control.

Plutus-data shape change

Per the SundaeSwap aicone multisig schema (0=Signature, 1=AllOf, 2=AnyOf, 3=AtLeast, 4=Before, 5=After):

- AllOf [Signature(core_dev), Signature(ops), Signature(network_compliance), Signature(middleware)]
+ AtLeast 2 [Signature(core_dev), Signature(ops), Signature(network_compliance), Signature(middleware)]

In the bash recipe's JSON:

-    "constructor": 1,
-    "fields": [{ "list": [ ...4 owner signatures... ] }]
+    "constructor": 3,
+    "fields": [
+      { "int": 2 },
+      { "list": [ ...4 owner signatures... ] }
+    ]

Scope

  • Only swap orders built going forward by this script are affected.
  • Past orders already on chain are immutable and keep whatever policy they were created with.
  • No other scripts change.

As discussed in the Discord channel.

Rationale: any 2 of the 4 treasury scope owners can already disburse
funds out of the treasury at will. Requiring all 4 signatures merely
to cancel a pending swap order — and return the locked ADA back to
that same treasury — is therefore strictly more restrictive than the
disburse permission and creates a denial-of-cancellation risk if any
one owner is unavailable. Aligning the swap-cancel policy with the
disburse threshold makes cancellation no easier than spending the
returned funds, so the change does not weaken control.

Concretely the SundaeSwap V3 order owner-policy datum flips from
`AllOf [Signature(o1), Signature(o2), Signature(o3), Signature(o4)]`
to `AtLeast 2 [Signature(o1), Signature(o2), Signature(o3),
Signature(o4)]`:

- constructor 1 (AllOf) → constructor 3 (AtLeast)
- adds a leading `Int 2` quorum field before the signer list

(SundaeSwap aicone multisig schema: 0=Signature, 1=AllOf, 2=AnyOf,
3=AtLeast, 4=Before, 5=After.)

Past orders already on chain keep whatever policy they were created
with; only future orders built by this script are affected.

Signed-off-by: paolino <paolo.veronelli@gmail.com>
@paolino
paolino force-pushed the swap-cancel-atleast-2 branch from 0556b3c to 6c08ba5 Compare May 16, 2026 06:18
@paolino
paolino requested a review from KtorZ May 16, 2026 06:19
{ "constructor": 0, "fields": [ { "bytes": "$(echo "$metadata" | jq -cr ".treasuries.middleware.owner")" } ] }
]
}
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/SundaeSwap-finance/aicone/blob/769a33046ccd08a4950e8d647f3b0c1fbc01a941/lib/sundae/multisig.ak#L11-L19

pub type MultisigScript {
  Signature { key_hash: ByteArray }                            // variant 0 
  AllOf { scripts: List<MultisigScript> }                      // variant 1
  AnyOf { scripts: List<MultisigScript> }                      // variant 2
  AtLeast { required: Int, scripts: List<MultisigScript> }     // variant 3
  Before { time: Int }
  After { time: Int }
  Script { script_hash: ByteArray }
}

Looks about right.

@KtorZ
KtorZ merged commit 5503e17 into main May 16, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants