Skip to content

Commit

Permalink
fix deps and remove migrations in all pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee committed Jun 19, 2024
1 parent 82a1532 commit 1472778
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 952 deletions.
1,000 changes: 452 additions & 548 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 9 additions & 34 deletions contracts/pair/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use std::vec;
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, coin, ensure_eq, from_json, to_json_binary, wasm_execute, Addr, Binary, Coin, CosmosMsg,
CustomMsg, CustomQuery, Decimal, Decimal256, Deps, DepsMut, Env, Fraction, MessageInfo,
CustomMsg, CustomQuery, Decimal, Decimal256, Deps, DepsMut, Empty, Env, Fraction, MessageInfo,
QuerierWrapper, Reply, Response, StdError, StdResult, SubMsg, SubMsgResponse, SubMsgResult,
Uint128, Uint256, Uint64, WasmMsg,
};
use cw2::{get_contract_version, set_contract_version};
use cw2::set_contract_version;
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg};
use cw_utils::{
one_coin, parse_reply_instantiate_data, MsgInstantiateContractResponse, PaymentError,
};

use astroport::asset::{
addr_opt_validate, check_swap_parameters, Asset, AssetInfo, CoinsExt, PairInfo,
Expand All @@ -24,20 +27,16 @@ use astroport::pair::{
DEFAULT_SLIPPAGE, MAX_ALLOWED_SLIPPAGE, MAX_FEE_SHARE_BPS,
};
use astroport::pair::{
CumulativePricesResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, PoolResponse,
QueryMsg, ReverseSimulationResponse, SimulationResponse, TWAP_PRECISION,
CumulativePricesResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PoolResponse, QueryMsg,
ReverseSimulationResponse, SimulationResponse, TWAP_PRECISION,
};

use astroport::querier::{
query_factory_config, query_fee_info, query_native_supply, query_tracker_config,
};
use astroport::token_factory::{
tf_before_send_hook_msg, tf_burn_msg, tf_create_denom_msg, tf_mint_msg, MsgCreateDenomResponse,
};
use astroport::{tokenfactory_tracker, U256};
use cw_utils::{
one_coin, parse_reply_instantiate_data, MsgInstantiateContractResponse, PaymentError,
};

use crate::error::ContractError;
use crate::state::{Config, BALANCES, CONFIG};
Expand Down Expand Up @@ -1423,32 +1422,8 @@ pub fn assert_slippage_tolerance(

/// Manages the contract migration.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
use crate::migration;
let contract_version = get_contract_version(deps.storage)?;

match contract_version.contract.as_ref() {
"astroport-pair" => match contract_version.version.as_ref() {
"1.0.0" | "1.0.1" | "1.1.0" | "1.2.0" => {
migration::add_asset_balances_tracking_flag(deps.storage)?;
}
"1.3.0" | "1.3.1" => {}
_ => return Err(ContractError::MigrationError {}),
},
_ => return Err(ContractError::MigrationError {}),
}

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Ok(Response::default().add_attributes([
("previous_contract_name", contract_version.contract.as_str()),
(
"previous_contract_version",
contract_version.version.as_str(),
),
("new_contract_name", CONTRACT_NAME),
("new_contract_version", CONTRACT_VERSION),
]))
pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
unimplemented!("No safe path available for migration from cw20 to tokenfactory LP tokens")
}

/// Returns the total amount of assets in the pool as well as the total amount of LP tokens currently minted.
Expand Down
2 changes: 0 additions & 2 deletions contracts/pair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pub mod state;

pub mod error;

mod migration;

#[cfg(test)]
mod testing;

Expand Down
48 changes: 0 additions & 48 deletions contracts/pair/src/migration.rs

This file was deleted.

1 change: 0 additions & 1 deletion contracts/pair_concentrated/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ thiserror.workspace = true
cosmwasm-schema.workspace = true
itertools.workspace = true
cw-utils.workspace = true
astroport-pair-concentrated_v1 = { package = "astroport-pair-concentrated", version = "1.2.13", features = ["library"] }

[dev-dependencies]
cw20-base = "1.1"
Expand Down
41 changes: 9 additions & 32 deletions contracts/pair_concentrated/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use std::vec;

use astroport::token_factory::{
tf_before_send_hook_msg, tf_burn_msg, tf_create_denom_msg, MsgCreateDenomResponse,
};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, coin, ensure_eq, from_json, to_json_binary, wasm_execute, Addr, Binary, Coin, CosmosMsg,
Decimal, Decimal256, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg,
SubMsgResponse, SubMsgResult, Uint128, WasmMsg,
Decimal, Decimal256, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdError, StdResult,
SubMsg, SubMsgResponse, SubMsgResult, Uint128, WasmMsg,
};
use cw2::{get_contract_version, set_contract_version};
use cw2::set_contract_version;
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg};
use cw_utils::{
one_coin, parse_reply_instantiate_data, MsgInstantiateContractResponse, PaymentError,
Expand All @@ -30,11 +27,14 @@ use astroport::pair::{
MIN_TRADE_SIZE,
};
use astroport::pair_concentrated::{
ConcentratedPoolParams, ConcentratedPoolUpdateParams, MigrateMsg, UpdatePoolParams,
ConcentratedPoolParams, ConcentratedPoolUpdateParams, UpdatePoolParams,
};
use astroport::querier::{
query_factory_config, query_fee_info, query_native_supply, query_tracker_config,
};
use astroport::token_factory::{
tf_before_send_hook_msg, tf_burn_msg, tf_create_denom_msg, MsgCreateDenomResponse,
};
use astroport::tokenfactory_tracker;
use astroport_circular_buffer::BufferManager;
use astroport_pcl_common::state::{
Expand All @@ -47,7 +47,6 @@ use astroport_pcl_common::utils::{
use astroport_pcl_common::{calc_d, get_xcp};

use crate::error::ContractError;
use crate::migration::{migrate_config, migrate_config_v2};
use crate::state::{BALANCES, CONFIG, OBSERVATIONS, OWNERSHIP_PROPOSAL};
use crate::utils::{
accumulate_swap_sizes, calculate_shares, get_assets_with_precision, query_pools,
Expand Down Expand Up @@ -894,28 +893,6 @@ fn update_config(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
let contract_version = get_contract_version(deps.storage)?;

match contract_version.contract.as_ref() {
"astroport-pair-concentrated" => match contract_version.version.as_ref() {
"1.2.13" | "1.2.14" => {
migrate_config(deps.storage)?;
BufferManager::init(deps.storage, OBSERVATIONS, OBSERVATIONS_SIZE)?;
}
"2.3.0" => {
migrate_config_v2(deps.storage, &env)?;
}
_ => return Err(ContractError::MigrationError {}),
},
_ => return Err(ContractError::MigrationError {}),
}

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Ok(Response::new()
.add_attribute("previous_contract_name", &contract_version.contract)
.add_attribute("previous_contract_version", &contract_version.version)
.add_attribute("new_contract_name", CONTRACT_NAME)
.add_attribute("new_contract_version", CONTRACT_VERSION))
pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
unimplemented!("No safe path available for migration from cw20 to tokenfactory LP tokens")
}
1 change: 0 additions & 1 deletion contracts/pair_concentrated/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ pub mod contract;
pub mod state;

pub mod error;
mod migration;
pub mod queries;
pub mod utils;
73 changes: 0 additions & 73 deletions contracts/pair_concentrated/src/migration.rs

This file was deleted.

42 changes: 9 additions & 33 deletions contracts/pair_stable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ use std::collections::HashMap;
use std::str::FromStr;
use std::vec;

use astroport::token_factory::{tf_burn_msg, tf_create_denom_msg, MsgCreateDenomResponse};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, coin, ensure_eq, from_json, to_json_binary, Addr, Binary, Coin, CosmosMsg, Decimal,
Decimal256, Deps, DepsMut, Env, Fraction, MessageInfo, QuerierWrapper, Reply, Response,
Decimal256, Deps, DepsMut, Empty, Env, Fraction, MessageInfo, QuerierWrapper, Reply, Response,
StdError, StdResult, SubMsg, SubMsgResponse, SubMsgResult, Uint128, WasmMsg,
};
use cw2::{get_contract_version, set_contract_version};
use cw2::set_contract_version;
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg};
use cw_utils::{one_coin, PaymentError};
use itertools::Itertools;
Expand All @@ -19,23 +18,21 @@ use astroport::asset::{
addr_opt_validate, check_swap_parameters, Asset, AssetInfo, CoinsExt, Decimal256Ext,
DecimalAsset, PairInfo, MINIMUM_LIQUIDITY_AMOUNT,
};

use astroport::common::{claim_ownership, drop_ownership_proposal, propose_new_owner};
use astroport::cosmwasm_ext::IntegerToDecimal;
use astroport::factory::PairType;
use astroport::observation::{query_observation, PrecommitObservation, OBSERVATIONS_SIZE};
use astroport::pair::{
ConfigResponse, CumulativePricesResponse, FeeShareConfig, InstantiateMsg, StablePoolParams,
StablePoolUpdateParams, DEFAULT_SLIPPAGE, MAX_ALLOWED_SLIPPAGE, MAX_FEE_SHARE_BPS,
MIN_TRADE_SIZE,
};

use crate::migration::{migrate_config_from_v21, migrate_config_to_v210};
use astroport::observation::{query_observation, PrecommitObservation, OBSERVATIONS_SIZE};
use astroport::pair::{
Cw20HookMsg, ExecuteMsg, MigrateMsg, PoolResponse, QueryMsg, ReverseSimulationResponse,
SimulationResponse, StablePoolConfig,
Cw20HookMsg, ExecuteMsg, PoolResponse, QueryMsg, ReverseSimulationResponse, SimulationResponse,
StablePoolConfig,
};
use astroport::querier::{query_factory_config, query_fee_info, query_native_supply};
use astroport::token_factory::{tf_burn_msg, tf_create_denom_msg, MsgCreateDenomResponse};
use astroport::DecimalCheckedOps;
use astroport_circular_buffer::BufferManager;

Expand Down Expand Up @@ -1049,31 +1046,10 @@ pub fn assert_max_spread(

/// Manages the contract migration.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
let contract_version = get_contract_version(deps.storage)?;

match contract_version.contract.as_ref() {
"astroport-pair-stable" => match contract_version.version.as_ref() {
"1.0.0-fix1" | "1.1.0" | "1.1.1" => {
migrate_config_to_v210(deps.branch())?;
}
"2.1.1" | "2.1.2" => {
migrate_config_from_v21(deps.branch())?;
}
"3.0.0" | "3.1.0" => {}
_ => return Err(ContractError::MigrationError {}),
},
_ => return Err(ContractError::MigrationError {}),
}

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Ok(Response::new()
.add_attribute("previous_contract_name", &contract_version.contract)
.add_attribute("previous_contract_version", &contract_version.version)
.add_attribute("new_contract_name", CONTRACT_NAME)
.add_attribute("new_contract_version", CONTRACT_VERSION))
pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
unimplemented!("No safe path available for migration from cw20 to tokenfactory LP tokens")
}

/// Returns the total amount of assets in the pool as well as the total amount of LP tokens currently minted.
pub fn pool_info(querier: QuerierWrapper, config: &Config) -> StdResult<(Vec<Asset>, Uint128)> {
let pools = config
Expand Down
1 change: 0 additions & 1 deletion contracts/pair_stable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ pub mod utils;
#[cfg(test)]
mod testing;

mod migration;
#[cfg(test)]
mod mock_querier;
Loading

0 comments on commit 1472778

Please sign in to comment.