Skip to content

Commit

Permalink
feat(pairs): pass pair type from factory during pool instantiation (#431
Browse files Browse the repository at this point in the history
)

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

* enable conditional compilation for sei and injective

* bump astroport to v5.5.0
  • Loading branch information
epanchee authored Sep 27, 2024
1 parent 034ec43 commit f119d63
Show file tree
Hide file tree
Showing 32 changed files with 702 additions and 92 deletions.
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"
Expand Down
16 changes: 15 additions & 1 deletion contracts/factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {}),
Expand Down
1 change: 1 addition & 0 deletions contracts/factory/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
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.
Expand Down
3 changes: 1 addition & 2 deletions contracts/pair/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions contracts/pair/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn proper_initialization() {
)]);

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

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

let msg = InstantiateMsg {
pair_type: PairType::Xyk {},
asset_infos: vec![
AssetInfo::NativeToken {
denom: "uusd".to_string(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1274,6 +1279,7 @@ fn test_query_pool() {
)]);

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

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

0 comments on commit f119d63

Please sign in to comment.