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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module oft::oft_impl_config {
use std::event::emit;
use std::math64::min;
use std::string::utf8;
use std::table::{Self, Table};
use std::timestamp;
Expand Down Expand Up @@ -250,7 +249,8 @@ module oft::oft_impl_config {
let rate_limit = *table::borrow(&store().rate_limit_by_eid, eid);
if (timestamp > rate_limit.last_update) {
// If the timestamp is greater than the last update, calculate the decayed in-flight amount
let elapsed = min(timestamp - rate_limit.last_update, rate_limit.window_seconds);
// Remove min() cap to allow decay beyond one window when needed
let elapsed = timestamp - rate_limit.last_update;
let decay = ((((elapsed as u128) * (rate_limit.limit as u128)) / (rate_limit.window_seconds as u128)) as u64);

// Ensure the decayed in-flight amount is not negative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module oft::move_oft_adapter_tests {
remove_pauser,
set_fee_bps,
set_fee_deposit_address,
EPAUSED,
EUNAUTHORIZED,
};
use oft::oft_impl_config;
use oft::oft_store;
Expand Down Expand Up @@ -85,7 +87,7 @@ module oft::move_oft_adapter_tests {
}

#[test]
#[expected_failure(abort_code = 5)] // EUNAUTHORIZED
#[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)]
fun test_only_pauser_or_admin_can_toggle() {
setup();

Expand All @@ -97,7 +99,7 @@ module oft::move_oft_adapter_tests {
}

#[test]
#[expected_failure(abort_code = 4)] // EPAUSED
#[expected_failure(abort_code = EPAUSED, location = move_oft_adapter)]
fun test_paused_blocks_debit() {
let mint_ref = setup();
let admin = &create_signer_for_test(@oft_admin);
Expand Down Expand Up @@ -149,7 +151,7 @@ module oft::move_oft_adapter_tests {
}

#[test]
#[expected_failure(abort_code = 5)] // EUNAUTHORIZED
#[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)]
fun test_non_pauser_still_unauthorized() {
setup();
let admin = &create_signer_for_test(@oft_admin);
Expand All @@ -160,7 +162,7 @@ module oft::move_oft_adapter_tests {
}

#[test]
#[expected_failure(abort_code = 4)] // EPAUSED
#[expected_failure(abort_code = EPAUSED, location = move_oft_adapter)]
fun test_credit_blocked_when_paused() {
let mint_ref = setup();
let amount_ld = 500u64;
Expand All @@ -181,7 +183,7 @@ module oft::move_oft_adapter_tests {
}

#[test]
#[expected_failure(abort_code = 5)] // EUNAUTHORIZED
#[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)]
fun test_removed_pauser_loses_ability() {
setup();

Expand Down
Loading