Getting different values in result and log of function

Hi everyone,

I’m facing a perplexing issue:
My function’s return values different from what I log inside the function.
This odd behavior also occurred with my open_order function, where the returned ID didn’t match its logged value.
Below is a test file showcasing the issue. Any insights or similar experiences would be greatly appreciated!

Test case

 let max_abs_position_size = clearing_house
    let logs: Vec<(u64, u64)> = max_abs_position_size.decode_logs_with_type::<(u64, u64)>().unwrap();

    println!("max_abs_position_size = {:?}", max_abs_position_size.value);
    println!("logs = {:?}", logs);


max_abs_position_size = (0, 0)
logs= [(71428571, 71428571)]


fn get_max_abs_position_size(trader: Address, base_asset: AssetId) -> (u64, u64) { //(max_abs_short_size: u64, max_abs_long_size:u64) 

//some code where I get valueson_size = max_position_value.mul_div(scale, mark_price).value;

        let mut result =(0,0);
        if current_position_size > I64::new(){
            result = (2 * current_position_size.value + max_position_size, max_position_size);
        } else{
            result = (max_position_size, 2 * current_position_size.value + max_position_size);
        return result;
1 Like

installed toolchains


beta-4-aarch64-apple-darwin (default)


active toolchain

beta-4-aarch64-apple-darwin (default)

forc : 0.46.1

- forc-client

- forc-deploy : 0.46.1

- forc-run : 0.46.1

- forc-doc : 0.46.1

- forc-explore : 0.28.1

- forc-fmt : 0.46.1

- forc-index : 0.23.0

- forc-lsp : 0.46.1

- forc-tx : 0.46.1

- forc-wallet : 0.3.0

fuel-core : 0.20.5

fuel-core-keygen : Error getting version string

fuel-indexer : 0.23.0

fuels versions

forc : 0.45

forc-wallet : 0.45

My toolchain

It’s definitely not expected behavior.
Can you please check which version of fuels-rs you are using?

Also, just to double-check, can you please tell me if by changing your function to:

        let result = if current_position_size > I64::new() {
            (2 * current_position_size.value + max_position_size, max_position_size)
        } else{
            (max_position_size, 2 * current_position_size.value + max_position_size)
        return result;

you still have the same issue? And also changing the condition of I64::new() by 0i64?

EDIT: just realized this is Sway not Rust, maybe my suggestion is not applicable.

Not sure if it is the same issue I faced some weeks ago, using fuels 0.49:

Please check if this a similar setup to yours:

Which was fixed here:


Hi there @sway

Is the fixed posted by @DefiCake working for you?

nope, still same problem

We’re having some problems reproducing this error.

Could you tell us the version of the Rust SDK you’re using?

Also, could you show us the raw receipts you’re getting back?

Is this code open source? If so, could you point us to it so we could try running it and investigate further?