11use aiken/ builtin
22use aiken/ collection/ dict
3+ use aiken/ collection/ pairs
34use aiken/ crypto.{VerificationKey }
45use cardano/ address.{Address , Credential }
56use cardano/ assets.{AssetName , PolicyId }
@@ -67,14 +68,12 @@ pub type SettingsDatum {
6768 /// - publish data for convenient and canonical access by off-chain actors
6869 /// - expose data to the script conditions in the multisig scripts of the two administrator roles
6970 /// - expose additional settings for more advanced pool and order types to operate off of
70- extensions: ProtocolFeeBasisPointsExtension ,
71+ extensions: Pairs < Int , Data > ,
7172}
7273
7374pub type ProtocolFeeBasisPointsExtension {
7475 /// The default protocol fee basis points to charge on each trade for bid (A -> B) and ask (B -> A) orders, for pools that don't override it
7576 protocol_fee_basis_points: (Int , Int ),
76- /// Pointing to next extension in the future
77- next: Data ,
7877}
7978
8079/// The settings redeemer can be spent for two different purposes
@@ -88,6 +87,19 @@ pub type SettingsRedeemer {
8887/// The name of the token that authenticates the settings UTXO
8988pub const settings_nft_name: AssetName = "settings"
9089
90+ pub fn find_protocol_fee_extension (
91+ settings: SettingsDatum ,
92+ ) -> Option < ProtocolFeeBasisPointsExtension > {
93+ let maybe_extension = pairs.get_first (settings.extensions, 0 )
94+ when maybe_extension is {
95+ Some (extension_data) -> {
96+ expect extension: ProtocolFeeBasisPointsExtension = extension_data
97+ Some (extension)
98+ }
99+ None -> None
100+ }
101+ }
102+
91103/// Scan over the list of reference inputs to find the settings datum, and ensure it's the correct one
92104/// Note that this makes the assumption that the settings datum is the first reference input, for performance
93105/// This means that when storing reference scripts on-chain, there needs to be a small amount of "farming" to select
0 commit comments