Hi all,
Yet another swap/smart contract interaction question, when I run the following:
USTANC_contract = ’
mk = mnemonic key set elsewhere
spread = 0.1
UST_amount_to_be_swapped1 = 1
def Swap_UST_for_ANC(UST_amount_to_be_swapped1, mk, USTANC_contract, spread):
Testwallet = terra.wallet(mk)
data = '{"swap":{"max_spread":'+str(spread)+'}}'
encodedBytes = base64.b64encode(data.encode("utf-8"))
encodedStr = str(encodedBytes, "utf-8")
send_Swap_UST_for_ANC = (
MsgExecuteContract(
sender=mk.acc_address,
contract="terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76", #ANC
execute_msg={
"send": {
"msg": encodedStr, #'{"swap":{"max_spread":"0.005"}}' converted from json to Base64. Refer to https://docs.terraswap.io/docs/howto/swap/
"amount": str(UST_amount_to_be_swapped1),
"contract": USTANC_contract
}
},
),
)
# Send tx
tx_Swap_UST_for_ANC = Testwallet.create_and_sign_tx(
CreateTxOptions(
send_Swap_UST_for_ANC
)
)
result_tx_Swap_UST_for_ANC = terra.tx.broadcast(tx_Swap_UST_for_ANC)
print(result_tx_Swap_UST_for_ANC.txhash)
Swap_UST_for_ANC(1000000, mk, USTANC_contract, 0.1)
I get the following error:
LCDResponseError: Status 400 - failed to execute message; message index: 0: dispatch: Error parsing into type terraswap::pair::Cw20HookMsg: Invalid type: execute wasm contract failed: invalid request
If I change the ANC CW-20 token contract to ‘uusd’ so I can swap from UST to ANC it gives the following error:
LCDResponseError: Status 400 - Invalid contract address (decoding bech32 failed: invalid bech32 string length 4): invalid address: invalid request
I am not really sure what is going on here? Any possible fixes I can try on this one?