Skip to content
Open
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ c6bb97648dfef5c69d42924d48dc579bb5db0c4fc0514cee1d54ee387a657a05 dexter_lp_toke
520307ff5f915ad232cafb3b3a14747491bef37e3cd1e2b630d9ad0cb915023f dexter_router.wasm
030b85563cefa2f87246cf383498220fa577ae7e5711138a69f6ce6e5839f792 dexter_stable_pool.wasm
3acb65a778fc3f467d29a0e22a5c093b78648b893a18e5b611db25e8c8368587 dexter_superfluid_lp.wasm
036795694b5d5d2ed947c457219f09b9de3db52a86a1f90b1cc2284ee3d6c90c dexter_vault.wasm
96ed1c5d47a49987f88f7584784bde3a24706c4c9bc4834b81147a99bcda9b90 dexter_vault.wasm
899428140866ec5249b9382f8e13f1874394f9bbd1beee9fd5f020b8ba1d82fd dexter_weighted_pool.wasm
Binary file modified artifacts/dexter_vault.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/vault/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dexter-vault"
version = "1.2.0"
version = "1.2.2"
authors = ["Persistence Labs"]
edition = "2021"
description = "Dexter Factory contract - entry point to create new pools. Maintains directory for all pools"
Expand Down
90 changes: 25 additions & 65 deletions contracts/vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ use dexter::pool;
const CONTRACT_NAME: &str = "dexter-vault";
/// Contract version that is used for migration.
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
const CONTRACT_VERSION_V1: &str = "1.0.0";
const CONTRACT_VERSION_V1_1: &str = "1.1.0";
const CONTRACT_VERSION_V1_2_1: &str = "1.2.1";

/// A `reply` call code ID of sub-message.
const INSTANTIATE_LP_REPLY_ID: u64 = 1;
Expand Down Expand Up @@ -1985,9 +1984,10 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
(pool_id.to_string().as_bytes(), user.as_str()),
);
to_json_binary(&is_refunded)
},
}
QueryMsg::RewardScheduleValidationAssets {} => {
let reward_schedule_validation_assets = REWARD_SCHEDULE_VALIDATION_ASSETS.load(deps.storage)?;
let reward_schedule_validation_assets =
REWARD_SCHEDULE_VALIDATION_ASSETS.load(deps.storage)?;
to_json_binary(&reward_schedule_validation_assets)
}
}
Expand Down Expand Up @@ -2028,15 +2028,23 @@ pub fn query_pools(
let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT);
let start = start_after.unwrap_or_default().u128() + 1u128;

let mut end = start + Uint128::from(limit).u128();
if end > config.next_pool_id.u128() {
end = config.next_pool_id.u128();
}

let mut response: Vec<PoolInfoResponse> = vec![];
for pool_id in start..end {
response
.push(ACTIVE_POOLS.load(deps.storage, Uint128::from(pool_id).to_string().as_bytes())?);
let mut collected = 0;

for pool_id in start..config.next_pool_id.u128() {
if collected >= limit as usize {
break;
}

// Try to load from ACTIVE_POOLS, skip if not found (could be defunct)
if let Ok(maybe_pool_info) =
ACTIVE_POOLS.may_load(deps.storage, Uint128::from(pool_id).to_string().as_bytes())
{
if let Some(pool_info) = maybe_pool_info {
response.push(pool_info);
collected += 1;
}
}
}

Ok(response)
Expand Down Expand Up @@ -2087,49 +2095,9 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
let contract_version = get_contract_version(deps.storage)?;

match msg {
MigrateMsg::V1_1 {
updated_pool_type_configs,
} => {
// validate contract name
if contract_version.contract != CONTRACT_NAME {
return Err(ContractError::InvalidContractNameForMigration {
expected: CONTRACT_NAME.to_string(),
actual: contract_version.contract,
});
}
MigrateMsg::V1_2_2 {} => {
// This migration includes the query_pools fix for defunct pools

// validate that current version is v1.0
if contract_version.version != CONTRACT_VERSION_V1 {
return Err(ContractError::InvalidContractVersionForUpgrade {
upgrade_version: CONTRACT_VERSION.to_string(),
expected: CONTRACT_VERSION_V1.to_string(),
actual: contract_version.version,
});
}

// update pool type configs to new values. This makes sure we instantiate new pools with the new configs particularly the
// Code ID for each pool type which has been updated to a new value with the new version of the pool contracts
for pool_type_config in updated_pool_type_configs {
// Check if code id is valid
if pool_type_config.code_id == 0 {
return Err(ContractError::InvalidCodeId {});
}
// validate fee bps limits
if !pool_type_config.default_fee_info.valid_fee_info() {
return Err(ContractError::InvalidFeeInfo {});
}
REGISTRY.save(
deps.storage,
pool_type_config.pool_type.to_string(),
&pool_type_config,
)?;
}

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
MigrateMsg::V1_2 {
reward_schedule_validation_assets,
} => {
// validate contract name
if contract_version.contract != CONTRACT_NAME {
return Err(ContractError::InvalidContractNameForMigration {
Expand All @@ -2138,22 +2106,14 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
});
}

// validate that current version is v1.1
if contract_version.version != CONTRACT_VERSION_V1_1 {
// validate that current version is v1.2.1
if contract_version.version != CONTRACT_VERSION_V1_2_1 {
return Err(ContractError::InvalidContractVersionForUpgrade {
upgrade_version: CONTRACT_VERSION.to_string(),
expected: CONTRACT_VERSION_V1_1.to_string(),
expected: CONTRACT_VERSION_V1_2_1.to_string(),
actual: contract_version.version,
});
}


// Expect reward_schedule_validation_assets to be non-empty on migrate
let validation_assets = reward_schedule_validation_assets
.expect("reward_schedule_validation_assets must be provided");

// Store the reward schedule validation assets
REWARD_SCHEDULE_VALIDATION_ASSETS.save(deps.storage, &validation_assets)?;

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
Loading
Loading