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

factory contract integration testcases #75

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions cli_commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
STORE
================================================================
secretcli tx compute store ./target/wasm32-unknown-unknown/release/snip20.wasm --from owner --gas auto --gas-prices 0.0125uscrt --gas-adjustment 1.3 -y -b sync --output json
================================================================

INSTANTIATE
================================================================
secretcli tx compute instantiate 12318 '{"router_contract":"nibi15v6ucun55ud6aera98wm6su2fs46pja9apef3pthfp3mmza3eg3sy44cwq","chain_uid":"secret","escrow_code_id":12319,"escrow_code_hash":"25d467c87f5378333af6d9cfc0e40e0dcbfe984eebb987f5278e61650c1e88fa","snip20_code_id":12320,"snip20_code_hash":"f11bdae9c36ce54dd7a648837b5975de8be2e741a45aaae93eae52b491509149","is_native":false}' --from owner --chain-id pulsar-3 --node https://rpc.testnet.secretsaturn.net/ --fees=70000uscrt --label factorytest18 -y --admin secret12739yy09ln4vv2tcwchccuxatmmjz4q2axrzj2
================================================================

EXECUTE
================================================================
secretcli tx compute execute secret14srwunhsztatds2anzyft6tyz80fwktkq6g222 '{"update_factory_state":{}}' --from owner --chain-id pulsar-3 --node https://rpc.testnet.secretsaturn.net/ --fees=70000uscrt -y
================================================================

DECODE HASH
================================================================
secretcli q compute tx 26E18902514FFD82E7FD0ACA4C4F8794D3D0E0EFD8447FF48CB8E7C88E06BF46
================================================================

factory : secret14srwunhsztatds2anzyft6tyz80fwktkq6g222
4 changes: 2 additions & 2 deletions contracts/liquidity/factory/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub fn execute_swap_request(

ensure!(
first_swap.token_in == asset_in.token,
ContractError::new("Amount in doesn't match swap route")
ContractError::new("Token in doesn't match swap route")
);

let last_swap = swaps.last().ok_or(ContractError::Generic {
Expand All @@ -561,7 +561,7 @@ pub fn execute_swap_request(

ensure!(
last_swap.token_out == asset_out,
ContractError::new("Amount out doesn't match swap route")
ContractError::new("Token out doesn't match swap route")
);

let channel = if !state.is_native {
Expand Down
Binary file added optimized-wasm/cw_multicall.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/escrow.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/euclid.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/euclid_ibc.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/euclid_utils.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/factory.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/query_auth.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/schema.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/snip20.wasm.gz
Binary file not shown.
Binary file added optimized-wasm/snip20_reference_impl.wasm.gz
Binary file not shown.
58 changes: 42 additions & 16 deletions tests-integration/src/helpers/factory.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#![cfg(not(target_arch = "wasm32"))]

use cosmwasm_std::coin;
use cosmwasm_std::{coin, Uint128};
use cw20::Cw20Contract;
use cw_orch::mock::MockBase;
use cw_orch::prelude::*;

use cw_orch_interchain::IbcQueryHandler;
use euclid::chain::CrossChainUserWithLimit;
use euclid::fee::PartnerFee;
use euclid::msgs::cw20::ExecuteMsgFns;
use euclid::msgs::factory::{
ExecuteMsgFns as FactoryExecuteMsgFns, QueryMsgFns as FactoryQueryMsgFns,
};

use cw_orch_interchain::InterchainEnv;
use cw_orch_interchain::MockInterchainEnv;
use euclid::token::PairWithDenomAndAmount;
use euclid::swap::NextSwapPair;
use euclid::token::TokenType;
use euclid::token::TokenWithDenom;
use euclid::token::{PairWithDenomAndAmount, Token};
use factory::FactoryContract;

pub fn register_token(
Expand Down Expand Up @@ -114,26 +117,49 @@ pub fn add_liquidity(
factory: &FactoryContract<MockBase>,
pair_with_denom: PairWithDenomAndAmount,
slippage_tolerance_bps: u64,
timeout: Option<u64>,
funds: Vec<Coin>,
) {
let chain = interchain
.get_chain(factory.environment().chain_id().as_str())
.unwrap();
let mut funds = vec![];
for token in pair_with_denom.get_vec_token_info() {
faucet(
&chain,
chain.sender.as_str(),
token.amount.u128(),
token.token_type.clone(),
&mut funds,
);
}
let tx_response = factory
.execute(
&euclid::msgs::factory::ExecuteMsg::AddLiquidityRequest {
pair_info: pair_with_denom.clone(),
slippage_tolerance_bps,
timeout: None,
timeout,
},
Some(&funds),
)
.unwrap();

let _ = interchain
.await_packets(factory.environment().chain_id().as_str(), tx_response)
.unwrap();
}

pub fn swap_request(
interchain: &MockInterchainEnv,
factory: &FactoryContract<MockBase>,
asset_in: TokenWithDenom,
amount_in: Uint128,
asset_out: Token,
min_amount_out: Uint128,
timeout: Option<u64>,
swaps: Vec<NextSwapPair>,
cross_chain_addresses: Vec<CrossChainUserWithLimit>,
partner_fee: Option<PartnerFee>,
funds: Vec<Coin>,
) {
let tx_response = factory
.execute(
&euclid::msgs::factory::ExecuteMsg::ExecuteSwapRequest {
asset_in,
amount_in,
asset_out,
min_amount_out,
timeout,
swaps,
cross_chain_addresses,
partner_fee,
},
Some(&funds),
)
Expand Down
Loading
Loading