Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pairs): pass pair type from factory during pool instantiation #431

Merged
merged 3 commits into from
Sep 27, 2024
Merged
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
82 changes: 49 additions & 33 deletions 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 contracts/factory/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astroport-factory"
version = "1.8.1"
version = "1.9.0"
authors = ["Astroport"]
edition = "2021"
description = "Astroport factory contract - pair contract generator and directory"
16 changes: 15 additions & 1 deletion contracts/factory/src/contract.rs
Original file line number Diff line number Diff line change
@@ -327,12 +327,13 @@ pub fn execute_create_pair(
admin: Some(config.owner.to_string()),
code_id: pair_config.code_id,
msg: to_json_binary(&PairInstantiateMsg {
pair_type,
asset_infos: asset_infos.clone(),
token_code_id: config.token_code_id,
factory_addr: env.contract.address.to_string(),
init_params,
})?,
// Pass executer funds to pair contract in order to pay for LP token creation
// Pass executor funds to pair contract to pay for LP token creation
funds: info.funds,
label: "Astroport pair".to_string(),
}
@@ -576,6 +577,18 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
// atlantic-2: 1.3.1
"1.3.1" | "1.5.1" | "1.6.0" => {
migrate_pair_configs(deps.storage)?;
if let Some(tracker_config) = msg.tracker_config {
TRACKER_CONFIG.save(
deps.storage,
&TrackerConfig {
code_id: tracker_config.code_id,
token_factory_addr: deps
.api
.addr_validate(&tracker_config.token_factory_addr)?
.to_string(),
},
)?;
}
}
"1.7.0" => {
if let Some(tracker_config) = msg.tracker_config {
@@ -591,6 +604,7 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
)?;
}
}
"1.8.0" | "1.8.1" => {}
_ => return Err(ContractError::MigrationError {}),
},
_ => return Err(ContractError::MigrationError {}),
1 change: 1 addition & 0 deletions contracts/factory/src/testing.rs
Original file line number Diff line number Diff line change
@@ -498,6 +498,7 @@ fn create_pair() {
vec![SubMsg {
msg: WasmMsg::Instantiate {
msg: to_json_binary(&PairInstantiateMsg {
pair_type: PairType::Xyk {},
factory_addr: String::from(MOCK_CONTRACT_ADDR),
asset_infos: asset_infos.clone(),
token_code_id: msg.token_code_id,
3 changes: 2 additions & 1 deletion contracts/pair/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "astroport-pair"
version = "2.0.2"
version = "2.1.0"
authors = ["Astroport"]
edition = "2021"
description = "The Astroport constant product pool contract implementation"
license = "GPL-3.0-only"
repository = "https://github.com/astroport-fi/astroport"
homepage = "https://astroport.fi"
metadata = { build_variants = ["injective", "sei"] }

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
3 changes: 1 addition & 2 deletions contracts/pair/src/contract.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ use astroport::asset::{
MINIMUM_LIQUIDITY_AMOUNT,
};
use astroport::common::LP_SUBDENOM;
use astroport::factory::PairType;
use astroport::incentives::ExecuteMsg as IncentiveExecuteMsg;
use astroport::pair::{
ConfigResponse, FeeShareConfig, ReplyIds, XYKPoolConfig, XYKPoolParams, XYKPoolUpdateParams,
@@ -80,7 +79,7 @@ pub fn instantiate(
contract_addr: env.contract.address.clone(),
liquidity_token: "".to_owned(),
asset_infos: msg.asset_infos.clone(),
pair_type: PairType::Xyk {},
pair_type: msg.pair_type,
},
factory_addr: deps.api.addr_validate(msg.factory_addr.as_str())?,
block_time_last: 0,
7 changes: 7 additions & 0 deletions contracts/pair/src/testing.rs
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ fn proper_initialization() {
)]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
factory_addr: String::from("factory"),
asset_infos: vec![
AssetInfo::NativeToken {
@@ -140,6 +141,7 @@ fn provide_liquidity() {
]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
@@ -671,6 +673,7 @@ fn withdraw_liquidity() {
]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
@@ -812,6 +815,7 @@ fn try_native_to_token() {
]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
@@ -1019,6 +1023,7 @@ fn try_token_to_native() {
]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
@@ -1274,6 +1279,7 @@ fn test_query_pool() {
)]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
@@ -1342,6 +1348,7 @@ fn test_query_share() {
)]);

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
Loading