Skip to content

Commit 0a680e4

Browse files
committed
allow increasing lovelace held in utxo to support size increase when
updating pool fees
1 parent 2c8e5a7 commit 0a680e4

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

aiken.lock

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[[requirements]]
55
name = "aiken-lang/stdlib"
6-
version = "v2.2.0"
6+
version = "v2"
77
source = "github"
88

99
[[requirements]]
@@ -16,14 +16,9 @@ name = "KtorZ/tx_util"
1616
version = "48a3e88ff3776f30133f9c3a5852f2b5163ae51e"
1717
source = "github"
1818

19-
[[requirements]]
20-
name = "aiken-lang/fuzz"
21-
version = "main"
22-
source = "github"
23-
2419
[[packages]]
2520
name = "aiken-lang/stdlib"
26-
version = "v2.2.0"
21+
version = "v2"
2722
requirements = []
2823
source = "github"
2924

@@ -39,11 +34,5 @@ version = "48a3e88ff3776f30133f9c3a5852f2b5163ae51e"
3934
requirements = []
4035
source = "github"
4136

42-
[[packages]]
43-
name = "aiken-lang/fuzz"
44-
version = "main"
45-
requirements = []
46-
source = "github"
47-
4837
[etags]
49-
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1756987430, nanos_since_epoch = 526865000 }, "9843473958e51725a9274b487d2d4aac0395ec1a2e30f090724fa737226bc127"]
38+
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1757327975, nanos_since_epoch = 498142917 }, "25c8d0802b8266feca04b47933382c5dee3cadb422208a5d3810d9d2df108c2e"]

validators/pool.ak

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,8 @@ validator manage(settings_policy_id: PolicyId) {
756756
expect InlineDatum(datum) = pool_input.datum
757757
expect datum: PoolDatum = datum
758758
// We need the pool output to check that only the fees or fee manager are updated
759-
let (
760-
Output { address: pool_output_address, value: pool_output_value, .. },
761-
pool_output_datum,
762-
) = find_pool_output(outputs)
759+
let (lovelace_diff, pool_output_datum) =
760+
pool_output_datum(pool_input, outputs)
763761

764762
let PoolDatum {
765763
bid_fees_per_10_thousand,
@@ -775,6 +773,7 @@ validator manage(settings_policy_id: PolicyId) {
775773
let expected_datum =
776774
PoolDatum {
777775
..datum,
776+
protocol_fees: datum.protocol_fees + lovelace_diff,
778777
bid_fees_per_10_thousand: bid_fees_per_10_thousand,
779778
ask_fees_per_10_thousand: ask_fees_per_10_thousand,
780779
fee_manager: output_fee_manager,
@@ -791,12 +790,32 @@ validator manage(settings_policy_id: PolicyId) {
791790
withdrawals,
792791
)
793792

794-
// And make sure we don't touch the assets on the pool input; they must be spent back into the same script
795-
and {
796-
pool_output_address == pool_input.address,
797-
pool_output_value == pool_input.value,
798-
}
793+
// The value and address are verified in pool_output_datum
794+
pool_output_datum == expected_datum
799795
}
800796
}
801797
}
802798
}
799+
800+
fn pool_output_datum(
801+
pool_input: Output,
802+
outputs: List<Output>,
803+
) -> (Int, PoolDatum) {
804+
let (
805+
Output { address: pool_output_address, value: pool_output_value, .. },
806+
pool_output_datum,
807+
) = find_pool_output(outputs)
808+
expect pool_output_address == pool_input.address
809+
expect
810+
assets.without_lovelace(pool_output_value) == assets.without_lovelace(
811+
pool_input.value,
812+
)
813+
814+
// Allow for increased lovelace amount in case the minutxo cost of the output is larger than the input
815+
// it is important to verify this is also added to the protocol fees so that the pool values are not changed
816+
let lovelace_diff =
817+
assets.lovelace_of(pool_output_value) - assets.lovelace_of(pool_input.value)
818+
expect lovelace_diff >= 0
819+
820+
(lovelace_diff, pool_output_datum)
821+
}

0 commit comments

Comments
 (0)