You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[tokio::main]
async fn main() {
print_title("Match in pairs multicall");
dotenv().ok();
let provider = Provider::connect(RPC).await.unwrap();
let secret = std::env::var("ADMIN").unwrap();
let wallet =
WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone()));
println!("wallet.address() = {:?}", wallet.address());
let token_contract = TokenContract::new(
&ContractId::from_str(TOKEN_CONTRACT_ID).unwrap().into(),
wallet.clone(),
);
let token_contract_id = token_contract.contract_id().into();
let base_asset = Asset::new(wallet.clone(), token_contract_id, MARKET_SYMBOL);
let quote_asset = Asset::new(wallet.clone(), token_contract_id, "USDC");
let orderbook = Orderbook::new(&wallet, ORDERBOOK_CONTRACT_ID).await;
let price = (BASE_PRICE * 10f64.powf(orderbook.price_decimals as f64)) as u64;
//mint base asset to sell
let base_size = base_asset.parse_units(BASE_SIZE as f64) as u64;
base_asset
.mint(wallet.address().into(), base_size)
.await
.unwrap();
// sell
let sell_order_id = orderbook
.open_order(base_asset.asset_id, -1 * base_size as i64, price - 1)
.await
.unwrap()
.value;
println!(
"sell_order = {:?}",
orderbook.order_by_id(&sell_order_id).await.unwrap().value
);
//mint quote asset to buy
let quote_size = quote_asset.parse_units(BASE_SIZE as f64 * BASE_PRICE as f64);
quote_asset
.mint(wallet.address().into(), quote_size as u64)
.await
.unwrap();
//buy
let buy_order_id = orderbook
.open_order(base_asset.asset_id, base_size as i64, price)
.await
.unwrap()
.value;
println!(
"buy_order = {:?}\n",
orderbook.order_by_id(&buy_order_id).await.unwrap().value
);
orderbook
.match_in_pairs_multicall(vec![(sell_order_id, buy_order_id)])
.await
.unwrap();
}
Expected Behavior
The MultiContractCallHandler should not throw an error if the transaction is successful. The handler should correctly interpret the result type without encountering the Unit vs Tuple([Unit]) mismatch.
The text was updated successfully, but these errors were encountered:
The problem is that for the MultiContractCallHandler you have to specify the output type of the call. It is a tuple of types of the added calls. Let's say you added 3 calls and each returns an u8 the output type of the multi-call would be (u8, u8, u8)
Please have a look at the docs: https://rust.fuel.network/v0.63.1/calling-contracts/multicalls.html#output-values
As you are dynamically processing orders, I think you will not be able to use MultiCallHandler in this way as you can not dynamically set the output type.
Issue: Error When Calling Contract Functions Using MultiContractCallHandler
Description
When invoking contract functions using
MultiContractCallHandler
, an error occurs:However, the transaction actually succeeds.
Steps to Reproduce
Error Details
While executing the script, the following error is encountered:
Despite this error, the transaction is successfully processed.
References
Function being called
https://github.com/compolabs/orderbook-contract/blob/testnet/src/orderbook_utils.rs#L308
Script used to call the function
https://github.com/compolabs/orderbook-contract/blob/testnet/scripts/match_in_pairs_multicall.rs
Expected Behavior
The
MultiContractCallHandler
should not throw an error if the transaction is successful. The handler should correctly interpret the result type without encountering theUnit
vsTuple([Unit])
mismatch.The text was updated successfully, but these errors were encountered: