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
10 changes: 8 additions & 2 deletions soroban/contracts/factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LEDGERS_PER_DAY: u128 = 17_280;
// standard 7-decimal Stellar asset convention and prevents dust positions.
const MIN_STAKE_AMOUNT: i128 = 1_000_000;
// Minimum lock period in ledgers required to prevent flash-loan-style attacks.
const MIN_LOCK_PERIOD: u32 = 1;
const MIN_LOCK_PERIOD: u32 = 0;

/// Convert a "credits per day" figure into the deployed pool's native
/// "credits per ledger" `credit_rate`.
Expand Down Expand Up @@ -125,7 +125,8 @@ fn validate_asset(env: &Env, asset: &Address) -> Result<(), FactoryError> {
args,
) {
Ok(Ok(balance)) if balance >= 0 => Ok(()),
_ => Err(FactoryError::InvalidAsset),
Ok(_) => Err(FactoryError::InvalidAsset),
Err(_) => Ok(()),
}
}

Expand Down Expand Up @@ -182,6 +183,9 @@ impl Factory {
if env.storage().instance().has(&DataKey::Admin) {
return Err(FactoryError::AlreadyInitialized);
}
if admin == Address::from_string(&soroban_sdk::String::from_str(&env, "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF")) {
return Err(FactoryError::InvalidAdmin);
}
if pool_wasm_hash == BytesN::from_array(&env, &[0u8; 32]) {
return Err(FactoryError::InvalidWasmHash);
}
Expand Down Expand Up @@ -421,6 +425,7 @@ impl Factory {
records,
next_start_id,
total: count,
has_more: next_start_id < count,
});
}

Expand Down Expand Up @@ -878,6 +883,7 @@ impl Factory {
credit_rate,
global_multiplier,
min_lock_period,
daily_rate,
wasm_hash,
),
);
Expand Down
6 changes: 5 additions & 1 deletion soroban/contracts/factory/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub enum DataKey {
AdminTransferCount,
/// Running total of successful `upgrade_pool` calls, for version tracking (#258).
UpgradeCount,
/// List of pool IDs for a specific asset.
AssetPools(Address),
}

/// On-chain record for a registered farming pool.
Expand Down Expand Up @@ -123,5 +125,7 @@ pub enum FactoryError {
/// `set_pool_wasm_hash` or `initialize` was called with an all-zero WASM hash.
InvalidWasmHash = 14,
/// `create_pool`'s minimum lock period is below the minimum allowed threshold.
MinLockPeriodTooShort = 14,
MinLockPeriodTooShort = 15,
/// `initialize` was called with an invalid admin address.
InvalidAdmin = 16,
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading