astroport-fi / astroport-core

Astroport DEX core contracts
https://astroport.fi/
GNU General Public License v3.0
153 stars 104 forks source link

Testnet contract error when add pools #370

Closed Jcaster99 closed 1 year ago

Jcaster99 commented 1 year ago

When i try to add pools the request error

https://multichain-nodes.astroport.fi/injective-888/lcd/cosmos/tx/v1beta1/simulate

code
"[reason:\"execute wasm contract failed\" metadata:{key:\"ABCICode\" value:\"5\"} metadata:{key:\"Codespace\" value:\"wasm\"}]: rpc error: code = Unknown desc = failed to execute message; message index: 1: dispatch: submessages: cosmwasm_std::addresses::Addr not found: execute wasm contract failed [!injective!labs/wasmd@v0.40.0-inj/x/wasm/keeper/keeper.go:394] With gas wanted: '50000000' and gas used: '509130' : unknown request"

this error from astro side or on my side ?

epanchee commented 1 year ago

What are the tokens/denoms you are trying to use for a new pool? Which pool type do you want to create? Does your wallet balance is >0 and you ever made any transaction on injective testnet before?

Jcaster99 commented 1 year ago

@epanchee Thanks for answer i have solved the problem now i need to automatic create pair and store pair info to storage but not succeess here is code


use astroport::asset::AssetInfo;
use astroport::factory::{PairType, ExecuteMsg};
use astroport::factory::ExecuteMsg::CreatePair;
use cosmwasm_std::{Addr, attr, Response, to_binary, WasmMsg, DepsMut, Env, MessageInfo};
use cw20_base::ContractError;

const FACTORY: &str = "inj1c4e2787cwawlqslph0yzn62wq4xpzzq9y9kjwj";

pub fn try_create_pair(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    token_code_id: u64,
) -> Result<Response, ContractError> {

    let assets: Vec<AssetInfo> = vec![
        AssetInfo::NativeToken {
            denom: "inj".to_string(),
        },
        AssetInfo::Token {
            contract_addr: env.contract.address,
        },
    ];

    let create_pair_msg = to_binary(&CreatePair {
        pair_type: PairType::Xyk {},
        asset_infos:assets,
        init_params: None,
    })?;

    let msg = WasmMsg::Execute {
        contract_addr: FACTORY.to_string(),
        msg: create_pair_msg,
        funds: vec![],
    };

//create error
failed to execute message; message index: 0: dispatch: submessages: Error parsing into type astroport::factory::ExecuteMsg: unknown variant `asset_infos`, expected one of `update_config`, `update_pair_config`, `create_pair`, `deregister`, `propose_new_owner`, `drop_ownership_proposal`, `claim_ownership`, `mark_as_migrated`: execute wasm contract failed

//get pair address and store to storage

  Ok(Response::new()
          .add_message(msg)
          .add_attributes(vec![
              attr("action", "create_pair"),
          ]))
  }
}
epanchee commented 1 year ago

Hi,

Sorry for the long reply.

Are you using test-tube? Please note that Astroport doesn't provide test-tube support and you have to figure out it yourself. The error denotes that you're trying to send wrong execute message on factory. Consult with factory execute messages here.