Error parsing into type prismswap::pair

I am trying to execute a swap for the PRISM-LUNA pair, on the Prism Protocol using the below code, but it’s failing. The code worked fine when executing a test UST-SCRT transaction on TerraSwap. Can’t work out what I need to send differently to Prism Protocol to get it to execute.

require("dotenv").config();
const { LCDClient, Coins, MsgExecuteContract, MnemonicKey } = require('@terra-money/terra.js');

const terra = new LCDClient({
    URL: 'https://lcd.terra.dev',
    chainID: 'columbus-5'
});

async function main(){
      
    // const lcd = new LCDClient(...);

    const mnemonic = process.env[`MNEMONIC`];
    
    const mk = new MnemonicKey({
    mnemonic: mnemonic,
    });
    
    const wallet = terra.wallet(mk);
    
    // UST <> SCRT
    // const pool = "terra1tq4mammgkqrxrmcfhwdz59mwvwf4qgy6rdrt46";

    // PRISM-LUNA
    const pool = "terra1r38qlqt69lez4nja5h56qwf4drzjpnu8gz04jd";
    
    // Fetch the number of each asset in the pool.
    const { assets } = await terra.wasm.contractQuery(pool, { pool: {} });
    
    // Calculate belief price using pool balances.
    const beliefPrice = (assets[0].amount / assets[1].amount).toFixed(18);

    
    // Swap LUNA to PRISM with 1% slippage tolerance.
    const terraSwap = new MsgExecuteContract(
        wallet.key.accAddress,
        pool, 
        {
            swap: {
                max_spread: "0.01",
                offer_asset: {
                    info: {
                        native: {
                            denom: "uluna",
                        },
                    },
                    amount: "10000",
                },
            belief_price: beliefPrice,
            },
        },
        new Coins({ uluna: "10000" }),
    );
    
    const tx = await wallet.createAndSignTx({ msgs: [terraSwap] });
    const result = await terra.tx.broadcast(tx);
   
    console.log(result);
};

main();

Error message: ‘failed to execute message; message index: 0: Error parsing into type prismswap::pair::ExecuteMsg: Invalid type: execute wasm contract failed: invalid request’,

Can someone please help with this?

2 Likes