diff --git a/Cargo.lock b/Cargo.lock index fb43e5a7..b8869181 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,7 +57,7 @@ dependencies = [ name = "astro-token-converter" version = "1.0.0" dependencies = [ - "astroport 4.0.3", + "astroport 4.0.4", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.2.0", @@ -72,7 +72,7 @@ name = "astro-token-converter-neutron" version = "1.0.0" dependencies = [ "astro-token-converter", - "astroport 4.0.3", + "astroport 4.0.4", "cosmwasm-std", "cw-utils 1.0.3", "cw2 1.1.2", @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "astroport" -version = "4.0.3" +version = "4.0.4" dependencies = [ "astroport-circular-buffer 0.2.0", "cosmwasm-schema", @@ -173,7 +173,7 @@ name = "astroport-factory" version = "1.7.0" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-pair 1.5.1", "cosmwasm-schema", "cosmwasm-std", @@ -208,7 +208,7 @@ name = "astroport-governance" version = "1.2.0" source = "git+https://github.com/astroport-fi/astroport-governance#182dd5bc201dd634995b5e4dc9e2774495693703" dependencies = [ - "astroport 4.0.3", + "astroport 4.0.4", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 0.15.1", @@ -221,7 +221,7 @@ version = "1.1.0" dependencies = [ "anyhow", "astro-token-converter", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-native-coin-registry", "astroport-pair 1.5.1", @@ -246,12 +246,12 @@ name = "astroport-liquidity-manager" version = "1.2.0" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-incentives", "astroport-native-coin-registry", "astroport-pair 1.5.1", - "astroport-pair-concentrated 3.0.0", + "astroport-pair-concentrated 3.0.1", "astroport-pair-stable", "astroport-pcl-common", "cosmwasm-schema", @@ -271,7 +271,7 @@ name = "astroport-maker" version = "1.5.0" dependencies = [ "astro-satellite-package", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-native-coin-registry", "astroport-pair 1.5.1", @@ -291,11 +291,11 @@ name = "astroport-mocks" version = "0.2.0" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-native-coin-registry", "astroport-pair 1.5.1", - "astroport-pair-concentrated 3.0.0", + "astroport-pair-concentrated 3.0.1", "astroport-pair-stable", "astroport-staking", "astroport-vesting 1.4.0", @@ -368,7 +368,7 @@ dependencies = [ name = "astroport-pair" version = "1.5.1" dependencies = [ - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-mocks", "cosmwasm-schema", @@ -404,10 +404,10 @@ dependencies = [ [[package]] name = "astroport-pair-concentrated" -version = "3.0.0" +version = "3.0.1" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-circular-buffer 0.2.0", "astroport-factory 1.7.0", "astroport-mocks", @@ -433,7 +433,7 @@ version = "1.0.0" dependencies = [ "anyhow", "astro-token-converter", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-pair 1.3.3", "cosmwasm-schema", @@ -455,7 +455,7 @@ name = "astroport-pair-stable" version = "3.5.0" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-circular-buffer 0.2.0", "astroport-factory 1.7.0", "astroport-mocks", @@ -500,7 +500,7 @@ dependencies = [ name = "astroport-pair-xyk-sale-tax" version = "1.6.0" dependencies = [ - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "astroport-mocks", "astroport-pair 1.3.3", @@ -521,10 +521,10 @@ dependencies = [ [[package]] name = "astroport-pcl-common" -version = "2.0.1" +version = "2.0.1-feeshare-fix" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-factory 1.7.0", "cosmwasm-schema", "cosmwasm-std", @@ -558,7 +558,7 @@ name = "astroport-staking" version = "2.1.0" dependencies = [ "anyhow", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-tokenfactory-tracker", "cosmwasm-schema", "cosmwasm-std", @@ -575,7 +575,7 @@ dependencies = [ name = "astroport-tokenfactory-tracker" version = "1.0.0" dependencies = [ - "astroport 4.0.3", + "astroport 4.0.4", "cosmwasm-schema", "cosmwasm-std", "cw-multi-test 0.20.0 (git+https://github.com/astroport-fi/cw-multi-test?branch=feat/bank_with_send_hooks)", @@ -608,7 +608,7 @@ name = "astroport-vesting" version = "1.4.0" dependencies = [ "astro-token-converter", - "astroport 4.0.3", + "astroport 4.0.4", "astroport-vesting 1.3.1", "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/pair_concentrated/Cargo.toml b/contracts/pair_concentrated/Cargo.toml index 45ba58a6..f7a815ac 100644 --- a/contracts/pair_concentrated/Cargo.toml +++ b/contracts/pair_concentrated/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astroport-pair-concentrated" -version = "3.0.0" +version = "3.0.1" authors = ["Astroport"] edition = "2021" description = "The Astroport concentrated liquidity pair" @@ -29,7 +29,7 @@ library = [] astroport = { path = "../../packages/astroport", version = "4" } astroport-factory = { path = "../factory", features = ["library"], version = "1" } astroport-circular-buffer = { path = "../../packages/circular_buffer", version = "0.2" } -astroport-pcl-common = { path = "../../packages/astroport_pcl_common", version = "2" } +astroport-pcl-common = { path = "../../packages/astroport_pcl_common", version = "2.0.1-feeshare-fix" } cw2.workspace = true cw20 = "1.1" cosmwasm-std.workspace = true diff --git a/contracts/pair_concentrated/src/contract.rs b/contracts/pair_concentrated/src/contract.rs index 50c8e6ce..fd4b6b16 100644 --- a/contracts/pair_concentrated/src/contract.rs +++ b/contracts/pair_concentrated/src/contract.rs @@ -987,6 +987,7 @@ pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result { migrate_config_v2(deps.storage, &env)?; } + "3.0.0" => {} _ => return Err(ContractError::MigrationError {}), }, _ => return Err(ContractError::MigrationError {}), diff --git a/contracts/pair_concentrated/tests/pair_concentrated_integration.rs b/contracts/pair_concentrated/tests/pair_concentrated_integration.rs index 1a94114e..80c6f37c 100644 --- a/contracts/pair_concentrated/tests/pair_concentrated_integration.rs +++ b/contracts/pair_concentrated/tests/pair_concentrated_integration.rs @@ -1561,6 +1561,17 @@ fn check_correct_fee_share() { helper.give_me_money(&[offer_asset.clone()], &user); helper.swap(&user, &offer_asset, None).unwrap(); + let last_price = helper + .query_config() + .unwrap() + .pool_state + .price_state + .last_price; + assert_eq!( + last_price, + Decimal256::from_str("1.001187607454013938").unwrap() + ); + // Check that the shared fees are sent let expected_fee_share = 26081u128; let recipient_balance = helper.coin_balance(&test_coins[1], &share_recipient); @@ -1578,6 +1589,17 @@ fn check_correct_fee_share() { helper.give_me_money(&[offer_asset.clone()], &user); helper.swap(&user, &offer_asset, None).unwrap(); + let last_price = helper + .query_config() + .unwrap() + .pool_state + .price_state + .last_price; + assert_eq!( + last_price, + Decimal256::from_str("0.998842355796925899").unwrap() + ); + helper .withdraw_liquidity(&provider, 999_999354, vec![]) .unwrap(); @@ -1586,6 +1608,17 @@ fn check_correct_fee_share() { helper.give_me_money(&[offer_asset.clone()], &user); helper.swap(&user, &offer_asset, None).unwrap(); + let last_price = helper + .query_config() + .unwrap() + .pool_state + .price_state + .last_price; + assert_eq!( + last_price, + Decimal256::from_str("1.00118760696709103").unwrap() + ); + // Disable fee share let action = ConcentratedPoolUpdateParams::DisableFeeShare {}; helper.update_config(&owner, &action).unwrap(); diff --git a/contracts/periphery/liquidity_manager/Cargo.toml b/contracts/periphery/liquidity_manager/Cargo.toml index 6376b535..edf4baf9 100644 --- a/contracts/periphery/liquidity_manager/Cargo.toml +++ b/contracts/periphery/liquidity_manager/Cargo.toml @@ -25,7 +25,7 @@ cw20-base = { version = "1.1", features = ["library"] } astroport-pair = { path = "../../pair", features = ["library"], version = "1.5" } astroport-pair-stable = { path = "../../pair_stable", features = ["library"], version = "3" } astroport-pair-concentrated = { path = "../../pair_concentrated", features = ["library"], version = "3" } -astroport-pcl-common = { path = "../../../packages/astroport_pcl_common", version = "2" } +astroport-pcl-common = { path = "../../../packages/astroport_pcl_common", version = "2.0.1-feeshare-fix" } astroport-factory = { path = "../../factory", features = ["library"], version = "1" } [dev-dependencies] diff --git a/packages/astroport/Cargo.toml b/packages/astroport/Cargo.toml index 6d2988a0..e21467d0 100644 --- a/packages/astroport/Cargo.toml +++ b/packages/astroport/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astroport" -version = "4.0.3" +version = "4.0.4" authors = ["Astroport"] edition = "2021" description = "Common Astroport types, queriers and other utils" diff --git a/packages/astroport_pcl_common/Cargo.toml b/packages/astroport_pcl_common/Cargo.toml index 3f91bcbf..8551f549 100644 --- a/packages/astroport_pcl_common/Cargo.toml +++ b/packages/astroport_pcl_common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astroport-pcl-common" -version = "2.0.1" +version = "2.0.1-feeshare-fix" edition = "2021" description = "Common package contains math tools and utils for Astroport PCL pairs" license = "GPL-3.0-only" diff --git a/packages/astroport_pcl_common/src/utils.rs b/packages/astroport_pcl_common/src/utils.rs index 62d5b0dd..967b786e 100644 --- a/packages/astroport_pcl_common/src/utils.rs +++ b/packages/astroport_pcl_common/src/utils.rs @@ -209,14 +209,12 @@ pub struct SwapResult { } impl SwapResult { - /// Calculates **last price** and **last real price**. - /// Returns (last_price, last_real_price) where: - /// - last_price is a price for repeg algo, + /// Calculates **last price** for PCL repeg algo pub fn calc_last_price(&self, offer_amount: Decimal256, offer_ind: usize) -> Decimal256 { if offer_ind == 0 { - offer_amount / (self.dy + self.maker_fee) + offer_amount / (self.dy + self.maker_fee + self.share_fee) } else { - (self.dy + self.maker_fee) / offer_amount + (self.dy + self.maker_fee + self.share_fee) / offer_amount } } } diff --git a/schemas/astroport-pair-concentrated/astroport-pair-concentrated.json b/schemas/astroport-pair-concentrated/astroport-pair-concentrated.json index d1dca0d1..b088761c 100644 --- a/schemas/astroport-pair-concentrated/astroport-pair-concentrated.json +++ b/schemas/astroport-pair-concentrated/astroport-pair-concentrated.json @@ -1,6 +1,6 @@ { "contract_name": "astroport-pair-concentrated", - "contract_version": "3.0.0", + "contract_version": "3.0.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#",