diff --git a/backstop/src/backstop/user.rs b/backstop/src/backstop/user.rs index b9e299dc..f1739900 100644 --- a/backstop/src/backstop/user.rs +++ b/backstop/src/backstop/user.rs @@ -157,7 +157,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_queue = 500; @@ -198,7 +198,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_queue = 500; @@ -235,7 +235,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_queue = 801; @@ -260,7 +260,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_wd = 1; @@ -291,7 +291,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_wd = 200; @@ -325,7 +325,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_wd = 150; @@ -374,7 +374,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_wd = 300; @@ -428,7 +428,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_wd = 300; @@ -468,7 +468,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_dequeue = 300; // verify exp is respected when specified @@ -507,7 +507,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let to_dequeue = 376; diff --git a/backstop/src/backstop/withdrawal.rs b/backstop/src/backstop/withdrawal.rs index 4bf739f0..3f632da4 100644 --- a/backstop/src/backstop/withdrawal.rs +++ b/backstop/src/backstop/withdrawal.rs @@ -115,7 +115,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -175,7 +175,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -212,7 +212,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); execute_queue_withdrawal(&e, &samwise, &pool_address, 40_0000000); @@ -226,7 +226,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -279,7 +279,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); execute_queue_withdrawal(&e, &samwise, &pool_address, 40_0000000); @@ -293,7 +293,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -325,7 +325,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); // setup pool with queue for withdrawal and allow the backstop to incur a profit @@ -343,7 +343,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -392,7 +392,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); // setup pool with queue for withdrawal and allow the backstop to incur a profit @@ -410,7 +410,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { @@ -445,7 +445,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); // setup pool with queue for withdrawal and allow the backstop to incur a profit @@ -464,7 +464,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&backstop_address, || { diff --git a/backstop/src/emissions/claim.rs b/backstop/src/emissions/claim.rs index b98482c7..77685a00 100644 --- a/backstop/src/emissions/claim.rs +++ b/backstop/src/emissions/claim.rs @@ -106,7 +106,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.budget().reset_unlimited(); @@ -267,7 +267,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_address = create_backstop(&e); @@ -418,7 +418,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_lp_balance = backstop_lp_balance + 6_5244800; let pre_frodo_balance_1 = storage::get_user_balance(&e, &pool_1_id, &frodo).shares; @@ -490,7 +490,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_address = create_backstop(&e); diff --git a/backstop/src/emissions/distributor.rs b/backstop/src/emissions/distributor.rs index ec39aeb7..cff6de46 100644 --- a/backstop/src/emissions/distributor.rs +++ b/backstop/src/emissions/distributor.rs @@ -189,7 +189,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -248,7 +248,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -289,7 +289,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -343,7 +343,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -397,7 +397,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -460,7 +460,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -520,7 +520,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -566,7 +566,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -622,7 +622,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -674,7 +674,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); diff --git a/backstop/src/emissions/manager.rs b/backstop/src/emissions/manager.rs index 4130c6cc..53c6367b 100644 --- a/backstop/src/emissions/manager.rs +++ b/backstop/src/emissions/manager.rs @@ -213,7 +213,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop = create_backstop(&e); @@ -356,7 +356,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop = create_backstop(&e); @@ -448,7 +448,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -482,7 +482,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -519,7 +519,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -545,7 +545,7 @@ mod tests { network_id: Default::default(), min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -582,7 +582,7 @@ mod tests { network_id: Default::default(), min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -618,7 +618,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -668,7 +668,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -715,7 +715,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -782,7 +782,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -842,7 +842,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -902,7 +902,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); @@ -962,7 +962,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let backstop_id = create_backstop(&e); diff --git a/backstop/src/storage.rs b/backstop/src/storage.rs index bb62343d..33da90d8 100644 --- a/backstop/src/storage.rs +++ b/backstop/src/storage.rs @@ -5,11 +5,18 @@ use soroban_sdk::{ use crate::backstop::{PoolBalance, UserBalance}; -pub(crate) const LEDGER_THRESHOLD_SHARED: u32 = 172800; // ~ 10 days -pub(crate) const LEDGER_BUMP_SHARED: u32 = 241920; // ~ 14 days +/********** Ledger Thresholds **********/ -pub(crate) const LEDGER_THRESHOLD_USER: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump -pub(crate) const LEDGER_BUMP_USER: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump +const ONE_DAY_LEDGERS: u32 = 17280; // assumes 5s a ledger + +const LEDGER_THRESHOLD_INSTANCE: u32 = ONE_DAY_LEDGERS * 30; // ~ 30 days +const LEDGER_BUMP_INSTANCE: u32 = LEDGER_THRESHOLD_INSTANCE + ONE_DAY_LEDGERS; // ~ 31 days + +const LEDGER_THRESHOLD_SHARED: u32 = ONE_DAY_LEDGERS * 45; // ~ 45 days +const LEDGER_BUMP_SHARED: u32 = LEDGER_THRESHOLD_SHARED + ONE_DAY_LEDGERS; // ~ 46 days + +const LEDGER_THRESHOLD_USER: u32 = ONE_DAY_LEDGERS * 100; // ~ 100 days +const LEDGER_BUMP_USER: u32 = LEDGER_THRESHOLD_USER + 20 * ONE_DAY_LEDGERS; // ~ 120 days /********** Storage Types **********/ @@ -77,7 +84,7 @@ pub enum BackstopDataKey { pub fn extend_instance(e: &Env) { e.storage() .instance() - .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_INSTANCE, LEDGER_BUMP_INSTANCE); } /// Fetch an entry in persistent storage that has a default value if it doesn't exist diff --git a/backstop/src/testutils.rs b/backstop/src/testutils.rs index e21967f7..c38cef67 100644 --- a/backstop/src/testutils.rs +++ b/backstop/src/testutils.rs @@ -101,7 +101,7 @@ pub(crate) fn create_emitter<'a>( base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(backstop, || { storage::set_emitter(e, &contract_address); @@ -116,7 +116,7 @@ pub(crate) fn create_emitter<'a>( base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); (contract_address.clone(), client) } diff --git a/emitter/src/backstop_manager.rs b/emitter/src/backstop_manager.rs index a655c60d..c80fa3c8 100644 --- a/emitter/src/backstop_manager.rs +++ b/emitter/src/backstop_manager.rs @@ -114,7 +114,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -165,7 +165,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -205,7 +205,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -253,7 +253,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -307,7 +307,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -354,7 +354,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -394,7 +394,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -459,7 +459,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -509,7 +509,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -551,7 +551,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/emitter/src/emitter.rs b/emitter/src/emitter.rs index a5330dd6..898ec74d 100644 --- a/emitter/src/emitter.rs +++ b/emitter/src/emitter.rs @@ -68,7 +68,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let emitter = create_emitter(&e); @@ -102,7 +102,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let frodo = Address::generate(&e); @@ -144,7 +144,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let frodo = Address::generate(&e); @@ -184,7 +184,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let frodo = Address::generate(&e); diff --git a/emitter/src/storage.rs b/emitter/src/storage.rs index b5928db3..665d3407 100644 --- a/emitter/src/storage.rs +++ b/emitter/src/storage.rs @@ -2,8 +2,15 @@ use soroban_sdk::{contracttype, unwrap::UnwrapOptimized, Address, Env, Symbol}; use crate::backstop_manager::Swap; -pub(crate) const LEDGER_THRESHOLD_SHARED: u32 = 172800; // ~ 10 days -pub(crate) const LEDGER_BUMP_SHARED: u32 = 241920; // ~ 14 days +/********** Ledger Thresholds **********/ + +const ONE_DAY_LEDGERS: u32 = 17280; // assumes 5s a ledger + +const LEDGER_THRESHOLD_INSTANCE: u32 = ONE_DAY_LEDGERS * 30; // ~ 30 days +const LEDGER_BUMP_INSTANCE: u32 = LEDGER_THRESHOLD_INSTANCE + ONE_DAY_LEDGERS; // ~ 31 days + +const LEDGER_THRESHOLD_SHARED: u32 = ONE_DAY_LEDGERS * 45; // ~ 45 days +const LEDGER_BUMP_SHARED: u32 = LEDGER_THRESHOLD_SHARED + ONE_DAY_LEDGERS; // ~ 46 days /********** Storage **********/ @@ -23,11 +30,11 @@ pub enum EmitterDataKey { Dropped(Address), } -/// Bump the instance rent for the contract. Bumps for 10 days due to the 7-day cycle window of this contract +/// Bump the instance rent for the contract pub fn extend_instance(e: &Env) { e.storage() .instance() - .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_INSTANCE, LEDGER_BUMP_INSTANCE); } /********** Init **********/ diff --git a/mocks/mock-pool-factory/src/storage.rs b/mocks/mock-pool-factory/src/storage.rs index 4a22190d..b3712438 100644 --- a/mocks/mock-pool-factory/src/storage.rs +++ b/mocks/mock-pool-factory/src/storage.rs @@ -1,8 +1,14 @@ use soroban_sdk::{contracttype, unwrap::UnwrapOptimized, Address, BytesN, Env}; -// @dev: This contract is not expected to be used often, so we can use a higher bump amount -pub(crate) const LEDGER_THRESHOLD: u32 = 725760; // ~ 42 days - 6 weeks -pub(crate) const LEDGER_BUMP: u32 = 967680; // ~ 56 days - 8 weeks +/********** Ledger Thresholds **********/ + +const ONE_DAY_LEDGERS: u32 = 17280; // assumes 5s a ledger + +const LEDGER_THRESHOLD_INSTANCE: u32 = ONE_DAY_LEDGERS * 30; // ~ 30 days +const LEDGER_BUMP_INSTANCE: u32 = LEDGER_THRESHOLD_INSTANCE + ONE_DAY_LEDGERS; // ~ 31 days + +const LEDGER_THRESHOLD_SHARED: u32 = ONE_DAY_LEDGERS * 45; // ~ 45 days +const LEDGER_BUMP_SHARED: u32 = LEDGER_THRESHOLD_SHARED + ONE_DAY_LEDGERS; // ~ 46 days #[derive(Clone)] #[contracttype] @@ -24,7 +30,7 @@ pub struct PoolInitMeta { pub fn extend_instance(e: &Env) { e.storage() .instance() - .extend_ttl(LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(LEDGER_THRESHOLD_INSTANCE, LEDGER_BUMP_INSTANCE); } /// Fetch the pool initialization metadata @@ -32,8 +38,8 @@ pub fn get_pool_init_meta(e: &Env) -> PoolInitMeta { // TODO: Change to instance - https://github.com/stellar/rs-soroban-sdk/issues/1040 e.storage().persistent().extend_ttl( &PoolFactoryDataKey::PoolInitMeta, - LEDGER_THRESHOLD, - LEDGER_BUMP, + LEDGER_THRESHOLD_SHARED, + LEDGER_BUMP_SHARED, ); e.storage() .persistent() @@ -71,7 +77,7 @@ pub fn is_deployed(e: &Env, contract_id: &Address) -> bool { { e.storage() .persistent() - .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); result } else { false @@ -89,5 +95,5 @@ pub fn set_deployed(e: &Env, contract_id: &Address) { .set::(&key, &true); e.storage() .persistent() - .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } diff --git a/pool-factory/src/storage.rs b/pool-factory/src/storage.rs index 8f7d2392..ea07bd95 100644 --- a/pool-factory/src/storage.rs +++ b/pool-factory/src/storage.rs @@ -1,8 +1,14 @@ use soroban_sdk::{contracttype, unwrap::UnwrapOptimized, Address, BytesN, Env, Symbol}; -// @dev: This contract is not expected to be used often, so we can use a higher bump amount -pub(crate) const LEDGER_THRESHOLD: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump -pub(crate) const LEDGER_BUMP: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump +/********** Ledger Thresholds **********/ + +const ONE_DAY_LEDGERS: u32 = 17280; // assumes 5s a ledger + +const LEDGER_THRESHOLD_INSTANCE: u32 = ONE_DAY_LEDGERS * 30; // ~ 30 days +const LEDGER_BUMP_INSTANCE: u32 = LEDGER_THRESHOLD_INSTANCE + ONE_DAY_LEDGERS; // ~ 31 days + +const LEDGER_THRESHOLD_USER: u32 = ONE_DAY_LEDGERS * 100; // ~ 100 days +const LEDGER_BUMP_USER: u32 = LEDGER_THRESHOLD_USER + 20 * ONE_DAY_LEDGERS; // ~ 120 days const IS_INIT_KEY: &str = "IsInit"; @@ -25,7 +31,7 @@ pub struct PoolInitMeta { pub fn extend_instance(e: &Env) { e.storage() .instance() - .extend_ttl(LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(LEDGER_THRESHOLD_INSTANCE, LEDGER_BUMP_INSTANCE); } /// Check if the contract has been initialized @@ -71,7 +77,7 @@ pub fn is_deployed(e: &Env, contract_id: &Address) -> bool { { e.storage() .persistent() - .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD_USER, LEDGER_BUMP_USER); result } else { false @@ -89,5 +95,5 @@ pub fn set_deployed(e: &Env, contract_id: &Address) { .set::(&key, &true); e.storage() .persistent() - .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD_USER, LEDGER_BUMP_USER); } diff --git a/pool/src/auctions/auction.rs b/pool/src/auctions/auction.rs index a035af79..9b6c52dd 100644 --- a/pool/src/auctions/auction.rs +++ b/pool/src/auctions/auction.rs @@ -306,7 +306,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -441,7 +441,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -549,7 +549,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -658,7 +658,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -762,7 +762,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/auctions/backstop_interest_auction.rs b/pool/src/auctions/backstop_interest_auction.rs index d8ea7f11..0cf837a0 100644 --- a/pool/src/auctions/backstop_interest_auction.rs +++ b/pool/src/auctions/backstop_interest_auction.rs @@ -133,7 +133,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let auction_data = AuctionData { @@ -169,7 +169,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); e.as_contract(&pool_address, || { @@ -192,7 +192,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -293,7 +293,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -410,7 +410,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -534,7 +534,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -664,7 +664,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/auctions/bad_debt_auction.rs b/pool/src/auctions/bad_debt_auction.rs index 198e788b..ed94e9e3 100644 --- a/pool/src/auctions/bad_debt_auction.rs +++ b/pool/src/auctions/bad_debt_auction.rs @@ -184,7 +184,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let auction_data = AuctionData { @@ -218,7 +218,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -352,7 +352,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -487,7 +487,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -622,7 +622,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -767,7 +767,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -920,7 +920,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -1084,7 +1084,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/auctions/user_liquidation_auction.rs b/pool/src/auctions/user_liquidation_auction.rs index 1f5085b6..2c76ac45 100644 --- a/pool/src/auctions/user_liquidation_auction.rs +++ b/pool/src/auctions/user_liquidation_auction.rs @@ -169,7 +169,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let liq_pct = 50; @@ -210,7 +210,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -321,7 +321,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -413,7 +413,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -505,7 +505,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -611,7 +611,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -718,7 +718,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/emissions/distributor.rs b/pool/src/emissions/distributor.rs index adeb8d76..6585ce6c 100644 --- a/pool/src/emissions/distributor.rs +++ b/pool/src/emissions/distributor.rs @@ -284,7 +284,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply: i128 = 50_0000000; @@ -347,7 +347,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply: i128 = 100_0000000; @@ -387,7 +387,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply: i128 = 50_0000000; @@ -441,7 +441,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply: i128 = 50_0000000; @@ -505,7 +505,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply: i128 = 100_0000000; @@ -545,7 +545,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 50_0000000; @@ -584,7 +584,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 50_0000000; @@ -635,7 +635,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 50_0000000; @@ -686,7 +686,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 50_0000000; @@ -737,7 +737,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 0; @@ -788,7 +788,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 100_0000000; @@ -836,7 +836,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply = 100_0001111; @@ -887,7 +887,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -933,7 +933,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -979,7 +979,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1032,7 +1032,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1084,7 +1084,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1137,7 +1137,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1191,7 +1191,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1240,7 +1240,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let supply_scalar = 1_0000000; @@ -1300,7 +1300,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); @@ -1425,7 +1425,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); @@ -1552,7 +1552,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); diff --git a/pool/src/emissions/manager.rs b/pool/src/emissions/manager.rs index 1319788b..933a84ff 100644 --- a/pool/src/emissions/manager.rs +++ b/pool/src/emissions/manager.rs @@ -165,7 +165,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -204,7 +204,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -300,7 +300,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -370,7 +370,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -425,7 +425,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -476,7 +476,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); diff --git a/pool/src/pool/actions.rs b/pool/src/pool/actions.rs index 4bafadb0..05cf3bda 100644 --- a/pool/src/pool/actions.rs +++ b/pool/src/pool/actions.rs @@ -359,7 +359,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -428,7 +428,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -502,7 +502,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -573,7 +573,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -645,7 +645,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -718,7 +718,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -788,7 +788,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -853,7 +853,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -927,7 +927,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -1007,7 +1007,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle: Address::generate(&e), @@ -1095,7 +1095,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -1231,7 +1231,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -1354,7 +1354,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -1508,7 +1508,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let samwise = Address::generate(&e); @@ -1593,7 +1593,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { @@ -1650,7 +1650,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { diff --git a/pool/src/pool/bad_debt.rs b/pool/src/pool/bad_debt.rs index 539445fd..e2272c75 100644 --- a/pool/src/pool/bad_debt.rs +++ b/pool/src/pool/bad_debt.rs @@ -76,7 +76,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -143,7 +143,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -196,7 +196,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -245,7 +245,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); diff --git a/pool/src/pool/config.rs b/pool/src/pool/config.rs index f3bbb802..bfffdd83 100644 --- a/pool/src/pool/config.rs +++ b/pool/src/pool/config.rs @@ -672,7 +672,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -698,7 +698,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { @@ -753,7 +753,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); @@ -775,7 +775,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { @@ -830,7 +830,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool = testutils::create_pool(&e); diff --git a/pool/src/pool/health_factor.rs b/pool/src/pool/health_factor.rs index e90fc504..79164ea5 100644 --- a/pool/src/pool/health_factor.rs +++ b/pool/src/pool/health_factor.rs @@ -187,7 +187,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle, diff --git a/pool/src/pool/interest.rs b/pool/src/pool/interest.rs index 186144f9..d0a2dc6c 100644 --- a/pool/src/pool/interest.rs +++ b/pool/src/pool/interest.rs @@ -147,7 +147,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_6565656, ir_mod, 0); @@ -183,7 +183,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_7979797, ir_mod, 0); @@ -219,7 +219,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_9696969, ir_mod, 0); @@ -255,7 +255,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (_accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_9696969, ir_mod, 0); @@ -290,7 +290,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (_accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_2020202, ir_mod, 0); @@ -325,7 +325,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_0500000, ir_mod, 500); @@ -361,7 +361,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let (accrual_0, ir_mod_0) = calc_accrual(&e, &reserve_config, 0, ir_mod, 0); diff --git a/pool/src/pool/pool.rs b/pool/src/pool/pool.rs index 3ec9a6b4..41e3843b 100644 --- a/pool/src/pool/pool.rs +++ b/pool/src/pool/pool.rs @@ -156,7 +156,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -217,7 +217,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -305,7 +305,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -586,7 +586,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/pool/reserve.rs b/pool/src/pool/reserve.rs index f24512eb..08ce5997 100644 --- a/pool/src/pool/reserve.rs +++ b/pool/src/pool/reserve.rs @@ -256,7 +256,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -305,7 +305,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -354,7 +354,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -400,7 +400,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -449,7 +449,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/pool/submit.rs b/pool/src/pool/submit.rs index 455792de..948647ba 100644 --- a/pool/src/pool/submit.rs +++ b/pool/src/pool/submit.rs @@ -92,7 +92,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -217,7 +217,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let pool_config = PoolConfig { oracle, @@ -260,7 +260,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -320,7 +320,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); @@ -380,7 +380,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let bombadil = Address::generate(&e); diff --git a/pool/src/pool/user.rs b/pool/src/pool/user.rs index 3e4298c5..1056860e 100644 --- a/pool/src/pool/user.rs +++ b/pool/src/pool/user.rs @@ -342,7 +342,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -434,7 +434,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -581,7 +581,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -672,7 +672,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -821,7 +821,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -912,7 +912,7 @@ mod tests { base_reserve: 10, min_temp_entry_ttl: 10, min_persistent_entry_ttl: 10, - max_entry_ttl: 2000000, + max_entry_ttl: 3110400, }); let mut reserve_0 = testutils::default_reserve(&e); diff --git a/pool/src/storage.rs b/pool/src/storage.rs index ae5d4515..ac073f16 100644 --- a/pool/src/storage.rs +++ b/pool/src/storage.rs @@ -5,11 +5,18 @@ use soroban_sdk::{ use crate::{auctions::AuctionData, pool::Positions, PoolError}; -pub(crate) const LEDGER_THRESHOLD_SHARED: u32 = 172800; // ~ 10 days -pub(crate) const LEDGER_BUMP_SHARED: u32 = 241920; // ~ 14 days +/********** Ledger Thresholds **********/ -pub(crate) const LEDGER_THRESHOLD_USER: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump -pub(crate) const LEDGER_BUMP_USER: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump +const ONE_DAY_LEDGERS: u32 = 17280; // assumes 5s a ledger + +const LEDGER_THRESHOLD_INSTANCE: u32 = ONE_DAY_LEDGERS * 30; // ~ 30 days +const LEDGER_BUMP_INSTANCE: u32 = LEDGER_THRESHOLD_INSTANCE + ONE_DAY_LEDGERS; // ~ 31 days + +const LEDGER_THRESHOLD_SHARED: u32 = ONE_DAY_LEDGERS * 45; // ~ 45 days +const LEDGER_BUMP_SHARED: u32 = LEDGER_THRESHOLD_SHARED + ONE_DAY_LEDGERS; // ~ 46 days + +const LEDGER_THRESHOLD_USER: u32 = ONE_DAY_LEDGERS * 100; // ~ 100 days +const LEDGER_BUMP_USER: u32 = LEDGER_THRESHOLD_USER + 20 * ONE_DAY_LEDGERS; // ~ 120 days /********** Storage Types **********/ @@ -150,7 +157,7 @@ pub enum PoolDataKey { pub fn extend_instance(e: &Env) { e.storage() .instance() - .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_INSTANCE, LEDGER_BUMP_INSTANCE); } /// Fetch an entry in persistent storage that has a default value if it doesn't exist