Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[[requirements]]
name = "aiken-lang/stdlib"
version = "v2.2.0"
version = "v2"
source = "github"

[[requirements]]
Expand All @@ -16,14 +16,9 @@ name = "KtorZ/tx_util"
version = "48a3e88ff3776f30133f9c3a5852f2b5163ae51e"
source = "github"

[[requirements]]
name = "aiken-lang/fuzz"
version = "main"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "v2.2.0"
version = "v2"
requirements = []
source = "github"

Expand All @@ -39,11 +34,5 @@ version = "48a3e88ff3776f30133f9c3a5852f2b5163ae51e"
requirements = []
source = "github"

[[packages]]
name = "aiken-lang/fuzz"
version = "main"
requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1756987430, nanos_since_epoch = 526865000 }, "9843473958e51725a9274b487d2d4aac0395ec1a2e30f090724fa737226bc127"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1757327975, nanos_since_epoch = 498142917 }, "25c8d0802b8266feca04b47933382c5dee3cadb422208a5d3810d9d2df108c2e"]
37 changes: 28 additions & 9 deletions validators/pool.ak
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,8 @@ validator manage(settings_policy_id: PolicyId) {
expect InlineDatum(datum) = pool_input.datum
expect datum: PoolDatum = datum
// We need the pool output to check that only the fees or fee manager are updated
let (
Output { address: pool_output_address, value: pool_output_value, .. },
pool_output_datum,
) = find_pool_output(outputs)
let (lovelace_diff, pool_output_datum) =
pool_output_datum(pool_input, outputs)

let PoolDatum {
bid_fees_per_10_thousand,
Expand All @@ -775,6 +773,7 @@ validator manage(settings_policy_id: PolicyId) {
let expected_datum =
PoolDatum {
..datum,
protocol_fees: datum.protocol_fees + lovelace_diff,
bid_fees_per_10_thousand: bid_fees_per_10_thousand,
ask_fees_per_10_thousand: ask_fees_per_10_thousand,
fee_manager: output_fee_manager,
Expand All @@ -791,12 +790,32 @@ validator manage(settings_policy_id: PolicyId) {
withdrawals,
)

// And make sure we don't touch the assets on the pool input; they must be spent back into the same script
and {
pool_output_address == pool_input.address,
pool_output_value == pool_input.value,
}
// The value and address are verified in pool_output_datum
pool_output_datum == expected_datum
}
}
}
}

fn pool_output_datum(
pool_input: Output,
outputs: List<Output>,
) -> (Int, PoolDatum) {
let (
Output { address: pool_output_address, value: pool_output_value, .. },
pool_output_datum,
) = find_pool_output(outputs)
expect pool_output_address == pool_input.address
expect
assets.without_lovelace(pool_output_value) == assets.without_lovelace(
pool_input.value,
)

// Allow for increased lovelace amount in case the minutxo cost of the output is larger than the input
// it is important to verify this is also added to the protocol fees so that the pool values are not changed
let lovelace_diff =
assets.lovelace_of(pool_output_value) - assets.lovelace_of(pool_input.value)
expect lovelace_diff >= 0

(lovelace_diff, pool_output_datum)
}