Cosmos custom calls

Execute any custom calls at the end of Squid Route

There are mainly two types of calls in cosmos - native call or CosmWasm contract call. Squid supports both cases.

Custom Cosmos contract call structure

export type CustomCosmosContractCall = {
  contract?: string; // must be set for wasm calls
  msg: object; // properly built object with a message call
}

Building a valid contract call

Let's assume we want to stake our OSMO tokens after we completed our swaps. Staking on Osmosis can be done in 2 ways - via native message or via calling a smart contract.

Example of stargate message


{
    "msg": {
        "stake": {
            "denom": "uosmo"
        }
    }
}

Example of wasm hook message

{
    "contract": "osmo1...",
    "msg": {
        "wasm": {
            "contract": "osmo1...",
            "msg": {
                "stake": {
                    "denom": "uosmo"
                }
            }
        }
    }
}

Example of Mars Red Bank deposit call on Osmosis

const params = {
  fromChain: "axelar-dojo-1",
  fromToken: "uaxl",
  fromAmount: "1000000",
  fromAddress: signerAddress,
  toChain: "osmosis-1",
  toToken: "uosmo",
  toAddress: osmosisAddress, // this address will be replaced with contract address
  slippage: 3.0,
  customContractCall: {
    contract:
      "osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg",
    msg: {
      deposit: {
        on_behalf_of: osmosisAddress,
      },
    },
  },
};

Last updated