Skip to content

Commit

Permalink
remove fee_finalized
Browse files Browse the repository at this point in the history
  • Loading branch information
rrruko committed May 7, 2024
1 parent f11d50b commit e675ea6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 43 deletions.
2 changes: 0 additions & 2 deletions lib/calculation/process.ak
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ pub fn pool_input_to_state(
// Scoopers could in theory set a wide validity range to cause users to overpay, but this should be considered malicious activity and
// get the scooper removed from the list of valid scoopers / ignore scooper rewards
// TODO: we could solve this by enforcing a validity range, and checking the length is within 4 hours.
// Calculate the fees per 10k rate to use for this whole scoop
// We let the creator of the pool specify a fee rate that decays (or increases) between market_open and fee_finalized
let bid_fees = bid_fees_per_10_thousand
let ask_fees = ask_fees_per_10_thousand
// Then construct the pool state. We include the assets here, instead of just the reserves, so we can check the values of each order
Expand Down
1 change: 0 additions & 1 deletion lib/tests/examples/ex_pool.ak
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fn mk_pool_datum() -> PoolDatum {
ask_fees_per_10_thousand: 2000,
fee_manager: None,
market_open: 100,
fee_finalized: 1000,
protocol_fees: 10000000,
}
}
Expand Down
6 changes: 0 additions & 6 deletions lib/types/pool.ak
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ pub type PoolDatum {
circulating_lp: Int,
/// The basis points to charge on each trade for bid (A -> B) and ask (B -> A) orders
/// For example, a 1% fee would be represented as 100 (out of 10,000), and a 0.3% fee would be represented as 30
/// The two values represent the fees as of `market_open` and as of `fee_finalized`, respectively, with a linear
/// decay from one to the other.
/// The transaction uses the valid_from field to charge the largest fee the transaction *could* be obligated to pay
bid_fees_per_10_thousand: Int,
ask_fees_per_10_thousand: Int,
// An optional multisig condition under which the protocol fees can be updated
fee_manager: Option<multisig.MultisigScript>,
/// The UNIX millisecond timestamp at which trading against the pool should be allowed
/// TODO: deposits and arguably withdrawals should be processed before the market open
market_open: PosixTime,
/// The UNIX millisecond timestamp at which the fees reach their final resting state
/// For example, a pool may be opened at a 20% fee, and decay gradually down to a 1% fee pool over the course of the first month.
fee_finalized: PosixTime,
/// The amount of ADA on the UTXO that is set aside by collecting protocol fees
/// This should be increased on each scoop to represent collecting fees; deducted from the reserve amount (if one of the tokens in the pair is ADA)
/// to calculate the swap amounts, and decreased when some amount is withdrawn.
Expand Down
35 changes: 15 additions & 20 deletions plutus.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion validators/oracle.ak
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ fn mint_oracle(
ask_fees_per_10_thousand: 5,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 2_000_000,
},
),
Expand Down
3 changes: 0 additions & 3 deletions validators/pool.ak
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,12 @@ validator(
// - the pool identifier is set correctly
// - the assets is set correctly
// - the initial circulating supply is set correctly
// - the market open time is before the fee finalized time; TODO: should we relax this?
// I'm not sure it's harmful if someone initializes this with a feeFinalized in the past
// - the initial and final fees per 10,000 are both non-negative (>= 0%)
// - the intitial and final fees per 10,000 are both less than or equal to 10000 (<= 100%)
let pool_output_datum_correct = and {
pool_output_datum.identifier == new_pool_id,
pool_output_datum.assets == (asset_a, asset_b),
pool_output_datum.circulating_lp == initial_lq,
pool_output_datum.market_open <= pool_output_datum.fee_finalized,
shared.fees_in_legal_range(
pool_output_datum.bid_fees_per_10_thousand,
),
Expand Down
10 changes: 0 additions & 10 deletions validators/tests/pool.ak
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ fn scoop(options: ScoopTestOptions) {
ask_fees_per_10_thousand: fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 100,
protocol_fees: 2_000_000,
}
let pool_out_datum =
Expand All @@ -356,7 +355,6 @@ fn scoop(options: ScoopTestOptions) {
ask_fees_per_10_thousand: fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 7_000_000,
}
let pool_nft_name = shared.pool_nft_name(constants.pool_ident)
Expand Down Expand Up @@ -561,7 +559,6 @@ fn scoop_swap_deposit(options: ScoopTestOptions) {
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 2_000_000,
}
let pool_out_datum =
Expand All @@ -576,7 +573,6 @@ fn scoop_swap_deposit(options: ScoopTestOptions) {
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 7_000_000,
}
let pool_nft_name = shared.pool_nft_name(constants.pool_ident)
Expand Down Expand Up @@ -791,7 +787,6 @@ fn withdraw_fees_transaction(options: ScoopTestOptions, withdraw_amount: Int, po
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees,
}
let normal_input =
Expand Down Expand Up @@ -1037,7 +1032,6 @@ fn update_pool_fees_transaction(options: ScoopTestOptions) {
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager,
market_open: 0,
fee_finalized: 0,
protocol_fees: 2_000_000,
}
let pool_rider = 2_000_000
Expand Down Expand Up @@ -1249,7 +1243,6 @@ fn mint_test_modify(
ask_fees_per_10_thousand: 5,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 2_000_000,
},
),
Expand Down Expand Up @@ -1538,7 +1531,6 @@ fn evaporate_pool_tx(options: ScoopTestOptions, withdraw_amount: Int) {
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 18_000_000,
}
// pool_test_tx_input deduplicate?
Expand Down Expand Up @@ -1625,7 +1617,6 @@ test attempt_evaporate_pool_test() {
ask_fees_per_10_thousand: pool_fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 18_000_000,
}
// pool_test_tx_input deduplicate?
Expand Down Expand Up @@ -1696,7 +1687,6 @@ test burn_pool() {
ask_fees_per_10_thousand: fees.2nd,
fee_manager: None,
market_open: 0,
fee_finalized: 0,
protocol_fees: 2_000_000,
}
let pool_nft_name = shared.pool_nft_name(constants.pool_ident)
Expand Down

0 comments on commit e675ea6

Please sign in to comment.