Skip to content

Commit

Permalink
chore: bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo-sturdy committed Aug 15, 2023
1 parent d80835f commit bf216f8
Show file tree
Hide file tree
Showing 20 changed files with 334 additions and 1,044 deletions.
1,136 changes: 206 additions & 930 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 20 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,27 @@ keywords = ["cosmwasm", "liquidity", "provision", "osmosis", "astroport"]
rust-version = "1.64.0"

[workspace.dependencies]
cosmwasm-schema = "1.2.1"
cosmwasm-std = "1.2.1"
cw2 = "1.0.1"
cw20 = "1.0.1"
cw-storage-plus = "1.0.1"
thiserror = "1.0.38"
schemars = "0.8.11"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
apollo-cw-asset = "0.1.0"
cw-dex = "0.1.0"
apollo-utils = "0.1.0"
liquidity-helper = { path = "./packages/liquidity-helper" }
cosmwasm-std = "1.3.2"
cosmwasm-schema = "1.3.2"
cw2 = "1.1.0"
cw20 = "1.1.0"
cw-storage-plus = "1.1.0"
thiserror = "1.0.45"
apollo-cw-asset = "0.1.2"
cw-dex = "0.4.0-rc.1"
apollo-utils = "0.1.1"
liquidity-helper = { path = "./packages/liquidity-helper" }

# Dev dependencies
osmosis-test-tube = { git = "https://github.com/apollodao/test-tube.git", rev = "d2245dfed56329d8c2e84d109a5a01f29d0db0e8" }
cw-it = { git = "https://github.com/apollodao/cw-it", rev = "cc1b973" }
test-case = "3.0.0"
cw-it = "0.1.2"
test-case = "3.1.0"

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
rpath = false
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
rpath = false
30 changes: 14 additions & 16 deletions contracts/astroport-liquidity-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
apollo-cw-asset = { workspace = true }
cw-dex = { workspace = true, features = ["astroport"] }
apollo-utils = { workspace = true }
cw20 = { workspace = true }
liquidity-helper = { workspace = true }
cw-bigint = { git = "https://github.com/apollodao/cw-bigint", rev = "c2217a76b08cb65204db407f661298c48b01e763" }
astroport-types = "0.1.3"
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
apollo-cw-asset = { workspace = true }
cw-dex = { workspace = true, features = ["astroport"] }
apollo-utils = { workspace = true }
cw20 = { workspace = true }
liquidity-helper = { workspace = true }
cw-bigint = { git = "https://github.com/apollodao/cw-bigint", rev = "c2217a76b08cb65204db407f661298c48b01e763" }

[dev-dependencies]
osmosis-test-tube = { workspace = true }
cw-it = { workspace = true, features = ["astroport"] }
env_logger = "0.9.0"
test-case = "2.2.2"
cw-it = { workspace = true, features = ["astroport", "osmosis-test-tube"] }
env_logger = "0.9.0"
test-case = "2.2.2"
8 changes: 5 additions & 3 deletions contracts/astroport-liquidity-helper/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use apollo_cw_asset::{Asset, AssetList};
use apollo_utils::assets::receive_assets;
use apollo_utils::responses::merge_responses;
use astroport_types::factory::PairType;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
from_binary, to_binary, Addr, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, Event,
MessageInfo, Response, StdResult, Uint128,
};
use cw2::set_contract_version;
use cw_dex::astroport::astroport::factory::PairType;
use cw_dex::astroport::helpers::query_fee_info;

use cw_dex::astroport::AstroportPool;
Expand Down Expand Up @@ -112,8 +112,10 @@ pub fn execute_balancing_provide_liquidity(
// into the other and then provide liquidity
let pool_res = pool.query_pool_info(&deps.querier)?;

let pool_reserves: [Asset; 2] =
[(&pool_res.assets[0]).into(), (&pool_res.assets[1]).into()];
let pool_reserves: [Asset; 2] = [
Asset::from(pool_res.assets[0].clone()),
Asset::from(pool_res.assets[1].clone()),
];
if assets.len() > 2 {
return Err(ContractError::MoreThanTwoAssets {});
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 16 additions & 12 deletions contracts/astroport-liquidity-helper/tests/artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
7b57fe7a4ef418a7be7d3bb7bfbba3d9a258dff25bce62fe4e4df558be33aa14 astro_token.wasm
d17fd884d3c4642e762f94aa66473a5ad66e60f3f7a3c5b4a8904e7475f51521 astroport_factory.wasm
2f6a0374a583c30b228e4ac1df19c29f57201315f39d1185548fb64ab2a2efd1 astroport_generator.wasm
21096a8d0509df1c09726ea789260febc339cb8f178682f8ad8cb39e772b06a6 astroport_liquidity_helper.wasm
37d63cdd0064c291c3773173ff62663918046eb62fb176181b4c186af32b4edf astroport_liquidity_helper_broken.wasm
cb706233a9c090d82e87e51751d188fb6712b47bde2f4da45150b47c0fa39b70 astroport_maker.wasm
f6acaf41d2730d709d1c57562b754553a67a632f13d94875b71d5633de038a13 astroport_pair_stable.wasm
a5155c856cebff4519a63a3acb4985971f3ed98289519cf588a92425464476e1 astroport_pair_xyk.wasm
24d27c6515cc28719611110ea74a10f9aae8a98d3a28be9ccb97d68385fe2233 astroport_router.wasm
8dc9d046372894725a81916134ab52b91160be36c856dd3e9db0354b30bac215 astroport_staking.wasm
f2a9dee9e7f132d76ae586bd2dd21bb272fd9fafe243b78c0b205bbd5f3bb24e astroport_vesting.wasm
ad5bcf115c100973099f26965e48ac799607db7cff3848e673ac9ed1fd4023ce astroport_whitelist.wasm
554ab0ea27ed7d7885c05e17fe9c861909c75dd26dab7b8b1c05fc9e4fc71824 astroport_factory.wasm
3a89d4b34ceaea04d3b267a1b6898c44cfd1548303759eb2d19834c8c98fd0db astroport_generator.wasm
169a3e9880ed8857b3e2923d65a3b17a928d92b837919287f93e6e81c2fd221b astroport_maker.wasm
a9a7433dcf7fc3b1c8083c0700cde747dfab69e6737beea007198c3c2f4342e7 astroport_native_coin_registry.wasm
fa7f8377bc02cecdffc8ac0859e326cd47115babdf8eb56b4c684469205ea284 astroport_native_coin_wrapper.wasm
09ec5b44b2af52e71bdbd38ba41b140df0ffd5fc92f2522c0449fca82765f19e astroport_oracle.wasm
419da41609bc9db64f4949adf30a7a825916bd31f99d972237921c5cf7bca862 astroport_pair.wasm
2775acbcdf4e61edbc7bd9529473b7825a21fb5d1f7abef3750abcfd8a96a28c astroport_pair_astro_xastro.wasm
7c1d8d5617b0b91193365f7d319dbb0a8d28aed4545f8defebabc432e516038c astroport_pair_concentrated.wasm
226d94adaf4c5e80409cae1af833abe8a32d0c47d151049e2880a3bd4db97cbb astroport_pair_stable.wasm
04e4cf04463cf62798faddbe2a30731f83a4a098f91667ef837399818a248f57 astroport_router.wasm
758f60c3fd1dc13d7ee26b314dc7c2629d6268aa19858aeea557de0a86f21e9f astroport_staking.wasm
0fc3850a504a9b379b4bba3a08e33c2dd79a0a097dc69ab9be82a050b30057ec astroport_token.wasm
936ed932d96188178a6a1a13ee0af0a49e17ba72c48c5185922c16003ddaccbc astroport_vesting.wasm
c24adab7ccce236bfbfc1945f9fc0bcc58c10aef606648e56e534733cd16d62f astroport_whitelist.wasm
1b79f716c62a05445b4cc23df6feddd9e91374c5388171f072021a4489e0fa7a astroport_xastro_token.wasm
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
use apollo_cw_asset::{Asset, AssetInfo, AssetList};
use astroport_liquidity_helper::math::calc_xyk_balancing_swap;
use astroport_liquidity_helper::msg::InstantiateMsg;
use astroport_types::asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo};
use astroport_types::factory::{FeeInfoResponse, PairType, QueryMsg as FactoryQueryMsg};
use astroport_types::pair::{
use cosmwasm_std::{coin, to_binary, Addr, Coin, Decimal, Uint128};
use cw20::{AllowanceResponse, BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg};
use cw_dex::astroport::astroport::asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo};
use cw_dex::astroport::astroport::factory::{
FeeInfoResponse, PairType, QueryMsg as FactoryQueryMsg,
};
use cw_dex::astroport::astroport::pair::{
ExecuteMsg as PairExecuteMsg, PoolResponse, QueryMsg as PairQueryMsg, SimulationResponse,
};
use cosmwasm_std::{to_binary, Addr, Coin, Decimal, Uint128};
use cw20::{AllowanceResponse, BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg};
use cw_dex::astroport::AstroportPool;
use cw_it::astroport::{
create_astroport_pair, instantiate_astroport, upload_astroport_contracts, AstroportContracts,
use cw_dex::astroport::{astroport, AstroportPool};
use cw_it::astroport::utils::{
create_astroport_pair, get_local_contracts, instantiate_astroport, AstroportContracts,
};
use cw_it::config::TestConfig;
use cw_it::helpers::upload_wasm_files;
use cw_it::osmosis_test_tube::osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceRequest;
use cw_it::traits::CwItRunner;
use cw_it::TestRunner;
use liquidity_helper::LiquidityHelper;
use osmosis_test_tube::cosmrs::proto::cosmos::bank::v1beta1::QueryBalanceRequest;
use test_case::test_case;

use osmosis_test_tube::cosmrs::proto::cosmwasm::wasm::v1::MsgExecuteContractResponse;
use osmosis_test_tube::{Account, Bank, Module, OsmosisTestApp, Runner, SigningAccount, Wasm};
use cw_it::osmosis_test_tube::cosmrs::proto::cosmwasm::wasm::v1::MsgExecuteContractResponse;
use cw_it::osmosis_test_tube::{
Account, Bank, Module, OsmosisTestApp, Runner, SigningAccount, Wasm,
};
use std::collections::HashMap;
use std::str::FromStr;

const TEST_CONFIG_PATH: &str = "tests/configs/terra.yaml";
pub const ASTROPORT_LIQUIDITY_HELPER_WASM_FILE: &str =
"../../target/wasm32-unknown-unknown/release/astroport_liquidity_helper.wasm";

/// Runs tests against the Osmosis bindings.
/// This works since there are no big differences between Terra and Osmosis.
pub fn setup_with_osmosis_bindings() -> (OsmosisTestApp, Vec<SigningAccount>, HashMap<String, u64>)
{
let app = OsmosisTestApp::default();

let accs = app
.init_accounts(&[Coin::new(1_000_000_000_000_000, "uluna")], 2)
pub fn setup(runner: &TestRunner) -> (Vec<SigningAccount>, HashMap<String, u64>) {
let accs = runner
.init_accounts(
&[
coin(1_000_000_000_000_000, "uluna"),
coin(1_000_000_000_000_000, "uosmo"),
],
2,
)
.unwrap();

let test_config = TestConfig::from_yaml(TEST_CONFIG_PATH);

// Upload astroport contracts
let astroport_code_ids = upload_astroport_contracts(&app, &test_config, &accs[0]);
let contracts = get_local_contracts(&runner, &Some("tests/artifacts"), false, &None);
let astroport_code_ids = upload_wasm_files(runner, &accs[0], contracts).unwrap();

(app, accs, astroport_code_ids)
(accs, astroport_code_ids)
}

/// Instantiates the liquidity helper contract
pub fn setup_astroport_liquidity_provider_tests<R>(
app: &R,
pub fn setup_astroport_liquidity_provider_tests<'a, R: Runner<'a>>(
app: &'a R,
accs: &[SigningAccount],
astroport_contracts: &AstroportContracts,
) -> LiquidityHelper
where
R: for<'a> Runner<'a>,
{
let wasm = Wasm::new(app);
let admin = &accs[0];
Expand Down Expand Up @@ -90,7 +96,8 @@ where

#[test]
pub fn test_calc_xyk_balancing_swap() {
let (app, accs, astroport_code_ids) = setup_with_osmosis_bindings();
let app = TestRunner::OsmosisTestApp(OsmosisTestApp::default());
let (accs, astroport_code_ids) = setup(&app);
let wasm = Wasm::new(&app);
let admin = &accs[0];

Expand All @@ -115,6 +122,7 @@ pub fn test_calc_xyk_balancing_swap() {
asset_infos.clone(),
None,
admin,
None,
);

// Increase allowance of astro token for Pair contract
Expand Down Expand Up @@ -142,7 +150,8 @@ pub fn test_calc_xyk_balancing_swap() {
contract_addr: Addr::unchecked(&astro_token),
},
},
],
]
.to_vec(),
slippage_tolerance: Some(Decimal::from_str("0.02").unwrap()),
auto_stake: Some(false),
receiver: None,
Expand Down Expand Up @@ -196,6 +205,7 @@ pub fn test_calc_xyk_balancing_swap() {
amount: offer_asset.amount,
info: asset_infos[0].clone(),
},
ask_asset_info: Some(return_asset.info.into()),
},
)
.unwrap();
Expand Down Expand Up @@ -259,15 +269,16 @@ pub fn test_balancing_provide_liquidity(
reserves: [Uint128; 2],
should_provide: bool,
) {
let (app, accs, astroport_code_ids) = &setup_with_osmosis_bindings();
let app = TestRunner::OsmosisTestApp(OsmosisTestApp::default());
let (accs, astroport_code_ids) = &setup(&app);
let admin = &accs[0];
let wasm = Wasm::new(app);
let wasm = Wasm::new(&app);

// Instantiate Astroport contracts
let astroport_contracts = instantiate_astroport(app, admin, astroport_code_ids);
let astroport_contracts = instantiate_astroport(&app, admin, astroport_code_ids);

let liquidity_helper =
setup_astroport_liquidity_provider_tests(app, accs, &astroport_contracts);
setup_astroport_liquidity_provider_tests(&app, accs, &astroport_contracts);
let astro_token = astroport_contracts.astro_token.address.clone();

// Create 1:1 XYK pool
Expand All @@ -280,17 +291,18 @@ pub fn test_balancing_provide_liquidity(
},
];
let (uluna_astro_pair_addr, uluna_astro_lp_token) = create_astroport_pair(
app,
&app,
&astroport_contracts.factory.address,
PairType::Xyk {},
asset_infos,
None,
admin,
None,
);
let pool = AstroportPool {
lp_token_addr: Addr::unchecked(uluna_astro_lp_token),
pair_addr: Addr::unchecked(uluna_astro_pair_addr.clone()),
pair_type: astroport_types::factory::PairType::Xyk {},
pair_type: astroport::factory::PairType::Xyk {},
pool_assets: vec![
AssetInfo::native("uluna".to_string()),
AssetInfo::cw20(Addr::unchecked(&astro_token)),
Expand Down Expand Up @@ -334,7 +346,8 @@ pub fn test_balancing_provide_liquidity(
contract_addr: Addr::unchecked(&astro_token),
},
},
],
]
.to_vec(),
slippage_tolerance: Some(Decimal::from_str("0.02").unwrap()),
auto_stake: Some(false),
receiver: None,
Expand Down Expand Up @@ -363,8 +376,8 @@ pub fn test_balancing_provide_liquidity(
}

// Check asset balances before balancing provide liquidity
let uluna_balance_before = query_token_balance(app, &admin.address(), "uluna");
let astro_balance_before = query_cw20_balance(app, admin.address(), &astro_token);
let uluna_balance_before = query_token_balance(&app, &admin.address(), "uluna");
let astro_balance_before = query_cw20_balance(&app, admin.address(), &astro_token);

// Balancing Provide liquidity
println!("Balancing provide liquidity");
Expand All @@ -388,8 +401,8 @@ pub fn test_balancing_provide_liquidity(
.unwrap()
.assets;
// Check asset balances after balancing provide liquidity.
let uluna_balance_after = query_token_balance(app, &admin.address(), "uluna");
let astro_balance_after = query_cw20_balance(app, admin.address(), &astro_token);
let uluna_balance_after = query_token_balance(&app, &admin.address(), "uluna");
let astro_balance_after = query_cw20_balance(&app, admin.address(), &astro_token);
if should_provide {
assert_eq!(pool_liquidity[0].amount, reserves[0] + asset_amounts[0]);
assert_eq!(pool_liquidity[1].amount, reserves[1] + asset_amounts[1]);
Expand Down
19 changes: 9 additions & 10 deletions contracts/osmosis-liquidity-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ optimize-m1 = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
apollo-cw-asset = { workspace = true }
cw-dex = { workspace = true, features = ["osmosis"] }
liquidity-helper = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
apollo-cw-asset = { workspace = true }
cw-dex = { workspace = true, features = ["osmosis"] }
liquidity-helper = { workspace = true }

[dev-dependencies]
osmosis-test-tube = { workspace = true }
cw-it = { workspace = true }
test-case = { workspace = true }
cw-it = { workspace = true, features = ["osmosis-test-tube"] }
test-case = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ use std::vec;
use apollo_cw_asset::{Asset, AssetList};
use cosmwasm_std::{to_binary, Addr, Coin, StdError, Uint128};
use cw_dex::osmosis::OsmosisPool;
use cw_it::{
osmosis_std::types::{
cosmos::bank::v1beta1::QueryBalanceRequest, cosmwasm::wasm::v1::MsgExecuteContractResponse,
},
osmosis_test_tube::{
Account, Bank, Gamm, Module, OsmosisTestApp, Runner, RunnerError, RunnerResult,
SigningAccount, Wasm,
},
};
use liquidity_helper::LiquidityHelper;
use osmosis_liquidity_helper::msg::InstantiateMsg;
use osmosis_test_tube::cosmrs::proto::cosmos::bank::v1beta1::QueryBalanceRequest;
use osmosis_test_tube::cosmrs::proto::cosmwasm::wasm::v1::MsgExecuteContractResponse;
use osmosis_test_tube::{
Account, Bank, Gamm, Module, OsmosisTestApp, Runner, RunnerError, RunnerResult, SigningAccount,
Wasm,
};

use test_case::test_case;

Expand Down
Loading

0 comments on commit bf216f8

Please sign in to comment.