Skip to content

Commit

Permalink
Merge branch 'main' into pi/SSW-304
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation authored Jan 16, 2024
2 parents 2a375a3 + 5d78f9e commit 38f2eb7
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/calculation/process.ak
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ pub fn process_order(
amortized_base_fee: Int,
simple_fee: Int,
strategy_fee: Int,
output: Output,
outputs: List<Output>,
rest_outputs: List<Output>
) -> (PoolState, List<Output>, Int) {
when details is {
order.Strategy(signer) -> {
Expand All @@ -127,12 +125,11 @@ pub fn process_order(
// reuse the code to calculate the result, but charge the higher fee
strategy_fee,
strategy_fee,
output,
outputs,
rest_outputs,
)
}
order.Swap(offer, min_received) -> {
expect [output, ..rest_outputs] = outputs
// Make sure the scooper can only take up to the max fee the user has agreed to
let fee = amortized_base_fee + simple_fee
expect max_protocol_fee >= fee
Expand All @@ -149,13 +146,15 @@ pub fn process_order(
(next, rest_outputs, fee)
}
order.Deposit(assets) -> {
expect [output, ..rest_outputs] = outputs
// Make sure the scooper can only take up to the max fee the user has agreed to
let fee = amortized_base_fee + simple_fee
expect max_protocol_fee >= fee
let next = deposit.do_deposit(initial, value, assets, destination, fee, output)
(next, rest_outputs, fee)
}
order.Withdrawal(amount) -> {
expect [output, ..rest_outputs] = outputs
// Make sure the scooper can only take up to the max fee the user has agreed to
let fee = amortized_base_fee + simple_fee
expect max_protocol_fee >= fee
Expand All @@ -165,6 +164,7 @@ pub fn process_order(
}
// order.Zap(..) -> do_zap(initial, input, datum)
order.Donation(assets) -> {
expect [output, ..rest_outputs] = outputs
// Make sure the scooper can only take up to the max fee the user has agreed to
let fee = amortized_base_fee + simple_fee
expect max_protocol_fee >= fee
Expand Down Expand Up @@ -211,7 +211,6 @@ pub fn process_orders(
expect [input_to_process, ..rest_of_input_list] = next_input_list

let Input{ output_reference, output: order } = input_to_process
expect [output, ..rest_outputs] = outputs

// make sure we only process scripts; this is so that our "order count" and "indexing set" logic is correct
expect is_script(order.address.payment_credential)
Expand Down Expand Up @@ -240,9 +239,7 @@ pub fn process_orders(
amortized_base_fee,
simple_fee,
strategy_fee,
output,
outputs,
rest_outputs,
)

process_orders(
Expand Down

0 comments on commit 38f2eb7

Please sign in to comment.