cross contract call to ref finance on near protocol

55 Views Asked by At

I'm currently building a smart contract that tries swap tokens on ref finance dex but did not find a trait implementing the ref finance dex interface.

I attempted using "transfer_call" method and pass function arguments to "swap" the transfered token A for token B, taking inspiration from ref dex.

I have code that look like so:

                let swap_param = format!(
                    "{{\"pool_id\": 0, \"token_in\": {}, \"token_out\": {}, \"min_amount_out\": \"0\"}}",
                    asset_name.to_string(),
                    fiat_asset.to_string()
                );

                let xcc_param = format!(
                    "{{
                        \"receiver_id\": {}, \"amount\": {} \"msg\": {}, 
                    }}",
                    ref_dex_id, asset_balance, swap_param
                );

                Promise::new(ref_dex_id.clone())
                    .function_call(
                        "ft_transfer_call".to_string(),
                        xcc_param.into(),
                        1,
                        FT_TRANSFER_CALL_GAS,
                    )
                    .then(
                        Self::ext(env::current_account_id())
                            .liquidate_callback(),
                    );

I'm sure that I'm likely missing something as the code above failed with a FunctionCallError(MethodResolveError(MethodNotFound) error

Any idea what I could be missing?

0

There are 0 best solutions below