Skip to content

Commit

Permalink
Merge pull request #426 from astroport-fi/merge/features_200824
Browse files Browse the repository at this point in the history
Merge new features 20.08.24
  • Loading branch information
epanchee authored Aug 20, 2024
2 parents 4d3be0e + 47a21b1 commit 2bb41b8
Show file tree
Hide file tree
Showing 41 changed files with 607 additions and 187 deletions.
43 changes: 31 additions & 12 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ thiserror = "1.0"
itertools = "0.12"
cosmwasm-schema = "1.5"
cw-utils = "1"
astroport = { path = "./packages/astroport", version = "5.3.0" }

[profile.release]
opt-level = "z"
Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ library = []

[dependencies]
cosmwasm-std.workspace = true
astroport = { path = "../../packages/astroport", version = "5" }
astroport.workspace = true
cw-storage-plus.workspace = true
cw2.workspace = true
thiserror.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion contracts/pair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library = []

[dependencies]
integer-sqrt = "0.1"
astroport = { path = "../../packages/astroport", version = "5" }
astroport.workspace = true
cw2.workspace = true
cw20 = "1.1"
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_1", "stargate"] }
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 @@ -20,6 +20,7 @@ use astroport::asset::{
addr_opt_validate, check_swap_parameters, Asset, AssetInfo, CoinsExt, PairInfo,
MINIMUM_LIQUIDITY_AMOUNT,
};
use astroport::common::LP_SUBDENOM;
use astroport::factory::PairType;
use astroport::incentives::ExecuteMsg as IncentiveExecuteMsg;
use astroport::pair::{
Expand All @@ -45,8 +46,6 @@ use crate::state::{Config, BALANCES, CONFIG};
const CONTRACT_NAME: &str = "astroport-pair";
/// Contract version that is used for migration.
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Tokenfactory LP token subdenom
pub const LP_SUBDENOM: &str = "astroport/share";

/// Creates a new contract with the specified parameters in the [`InstantiateMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
6 changes: 3 additions & 3 deletions contracts/pair/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ use cosmwasm_std::{
};
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg};
use proptest::prelude::*;
use prost::Message;

use astroport::asset::{Asset, AssetInfo, PairInfo};
use astroport::common::LP_SUBDENOM;
use astroport::factory::PairType;
use astroport::pair::{
Cw20HookMsg, ExecuteMsg, InstantiateMsg, PoolResponse, ReverseSimulationResponse,
SimulationResponse, TWAP_PRECISION,
};
use astroport::token_factory::{MsgBurn, MsgCreateDenom, MsgCreateDenomResponse, MsgMint};

use crate::contract::compute_offer_amount;
use crate::contract::reply;
use crate::contract::{
accumulate_prices, assert_max_spread, compute_swap, execute, instantiate, query_pool,
query_reverse_simulation, query_share, query_simulation,
};
use crate::contract::{compute_offer_amount, LP_SUBDENOM};
use crate::error::ContractError;
use crate::mock_querier::mock_dependencies;
use crate::state::{Config, CONFIG};

use prost::Message;

#[derive(Clone, PartialEq, Message)]
struct MsgInstantiateContractResponse {
#[prost(string, tag = "1")]
Expand Down
9 changes: 3 additions & 6 deletions contracts/pair/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use astroport::tokenfactory_tracker::{
use astroport_test::cw_multi_test::{AppBuilder, ContractWrapper, Executor, TOKEN_FACTORY_MODULE};
use astroport_test::modules::stargate::{MockStargate, StargateApp as TestApp};

use astroport_pair::contract::LP_SUBDENOM;
use astroport_pair::error::ContractError;

use astroport::common::LP_SUBDENOM;
use cosmwasm_std::{
attr, coin, to_json_binary, Addr, Coin, Decimal, DepsMut, Empty, Env, MessageInfo, Response,
StdResult, Uint128, Uint64,
Expand Down Expand Up @@ -162,7 +162,7 @@ fn instantiate_pair(mut router: &mut TestApp, owner: &Addr) -> Addr {
.unwrap();
assert_eq!("contract1", res.contract_addr);
assert_eq!(
format!("factory/contract1/{}", LP_SUBDENOM),
format!("factory/contract1/{LP_SUBDENOM}"),
res.liquidity_token
);

Expand Down Expand Up @@ -383,10 +383,7 @@ fn test_provide_and_withdraw_liquidity() {

assert_eq!(
err.root_cause().to_string(),
format!(
"Must send reserve token 'factory/contract1/{}'",
LP_SUBDENOM
)
format!("Must send reserve token 'factory/contract1/{LP_SUBDENOM}'",)
);

// Withdraw liquidity doubling the minimum to recieve
Expand Down
4 changes: 2 additions & 2 deletions contracts/pair_concentrated/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astroport-pair-concentrated"
version = "4.0.1"
version = "4.0.2"
authors = ["Astroport"]
edition = "2021"
description = "The Astroport concentrated liquidity pair"
Expand Down Expand Up @@ -29,7 +29,7 @@ injective = ["astroport/injective", "astroport-pcl-common/injective"]
sei = ["astroport/sei", "astroport-pcl-common/sei"]

[dependencies]
astroport = { path = "../../packages/astroport", version = "5" }
astroport.workspace = true
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" }
Expand Down
4 changes: 1 addition & 3 deletions contracts/pair_concentrated/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use astroport::asset::AssetInfoExt;
use astroport::asset::{
addr_opt_validate, token_asset, Asset, AssetInfo, CoinsExt, PairInfo, MINIMUM_LIQUIDITY_AMOUNT,
};
use astroport::common::{claim_ownership, drop_ownership_proposal, propose_new_owner};
use astroport::common::{claim_ownership, drop_ownership_proposal, propose_new_owner, LP_SUBDENOM};
use astroport::cosmwasm_ext::{DecimalToInteger, IntegerToDecimal};
use astroport::factory::PairType;
use astroport::observation::{PrecommitObservation, OBSERVATIONS_SIZE};
Expand Down Expand Up @@ -56,8 +56,6 @@ use crate::utils::{
const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
/// Contract version that is used for migration.
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Tokenfactory LP token subdenom
pub const LP_SUBDENOM: &str = "astroport/share";
/// An LP token's precision.
pub(crate) const LP_TOKEN_PRECISION: u8 = 6;

Expand Down
33 changes: 33 additions & 0 deletions contracts/pair_concentrated/tests/pair_concentrated_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,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);
Expand All @@ -1580,6 +1591,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();
Expand All @@ -1588,6 +1610,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();
Expand Down
2 changes: 1 addition & 1 deletion contracts/pair_stable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sei = ["astroport/sei"]
library = []

[dependencies]
astroport = { path = "../../packages/astroport", version = "5" }
astroport.workspace = true
cw2.workspace = true
cw20 = "1.1"
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_1", "stargate"] }
Expand Down
4 changes: 1 addition & 3 deletions contracts/pair_stable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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::common::{claim_ownership, drop_ownership_proposal, propose_new_owner, LP_SUBDENOM};
use astroport::cosmwasm_ext::IntegerToDecimal;
use astroport::factory::PairType;
use astroport::observation::{query_observation, PrecommitObservation, OBSERVATIONS_SIZE};
Expand Down Expand Up @@ -56,8 +56,6 @@ const CONTRACT_NAME: &str = "astroport-pair-stable";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Reply ID for create denom reply
const CREATE_DENOM_REPLY_ID: u64 = 1;
/// Tokenfactory LP token subdenom
pub const LP_SUBDENOM: &str = "astroport/share";
/// Number of assets in the pool.
const N_COINS: usize = 2;

Expand Down
7 changes: 4 additions & 3 deletions contracts/pair_stable/src/testing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use astroport::token_factory::{MsgBurn, MsgCreateDenom, MsgCreateDenomResponse, MsgMint};
use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
attr, coin, from_json, to_json_binary, Addr, BankMsg, Binary, BlockInfo, Coin, CosmosMsg,
Expand All @@ -12,24 +11,26 @@ use prost::Message;
use sim::StableSwapModel;

use astroport::asset::{native_asset, native_asset_info, Asset, AssetInfo};
use astroport::common::LP_SUBDENOM;
use astroport::observation::query_observation;
use astroport::observation::Observation;
use astroport::observation::OracleObservation;
use astroport::pair::{
ConfigResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PoolResponse, QueryMsg,
SimulationResponse, StablePoolParams,
};
use astroport::token_factory::{MsgBurn, MsgCreateDenom, MsgCreateDenomResponse, MsgMint};
use astroport_circular_buffer::BufferManager;
use astroport_test::convert::f64_to_dec;

use crate::contract::{
assert_max_spread, execute, instantiate, query, query_pool, query_reverse_simulation,
query_share, query_simulation, reply, LP_SUBDENOM,
query_share, query_simulation, reply,
};
use crate::error::ContractError;
use crate::mock_querier::mock_dependencies;
use crate::state::{CONFIG, OBSERVATIONS};
use crate::utils::{compute_swap, select_pools};
use astroport_test::convert::f64_to_dec;

#[derive(Clone, PartialEq, Message)]
struct MsgInstantiateContractResponse {
Expand Down
4 changes: 2 additions & 2 deletions contracts/pair_stable/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use astroport::pair::{
MAX_FEE_SHARE_BPS, TWAP_PRECISION,
};

use astroport_pair_stable::contract::LP_SUBDENOM;
use astroport_pair_stable::error::ContractError;

use std::str::FromStr;

use astroport::common::LP_SUBDENOM;
use astroport::token::InstantiateMsg as TokenInstantiateMsg;
use astroport_pair_stable::math::{MAX_AMP, MAX_AMP_CHANGE, MIN_AMP_CHANGING_TIME};
use astroport_test::cw_multi_test::{AppBuilder, ContractWrapper, Executor};
Expand Down Expand Up @@ -231,7 +231,7 @@ fn instantiate_pair(mut router: &mut TestApp, owner: &Addr) -> Addr {
.unwrap();
assert_eq!("contract2", res.contract_addr);
assert_eq!(
format!("factory/contract2/{}", LP_SUBDENOM),
format!("factory/contract2/{LP_SUBDENOM}"),
res.liquidity_token
);

Expand Down
Loading

0 comments on commit 2bb41b8

Please sign in to comment.