Autopilot to pass custom memo in the forwarding IBC packet
Background
When we use autopilot's "ibc_receiver" prop in stakeibc's LiquidStake action (so that the newly minted stAsset can be forwarded to another IBC chain), a static memo is passed in the resulting MsgTransfer message: "autopilot-liquid-stake-and-forward" https://github.com/Stride-Labs/stride/blob/v21.0.0/x/autopilot/keeper/liquidstake.go#L138
Chains like Osmosis have IBC hooks that would allow automated swap (for instance, stATOM to ATOM), and they require a specially crafted memo within the IBC packet. If we wanted to automate swapping after liquid staking, we would need to be able to craft a memo that would be passed to the next hop (a bit like the "next" field of the packet-forward-middleware).
This would be very useful, especially if combined with LSMLiquidStake in Autopilot as described here: https://github.com/Stride-Labs/stride/issues/1169. It would unlock the ability to immediately redeem staked ATOM into ATOM on the Cosmos Hub in two transactions:
- TX # 1: Tokenize Shares from already staked ATOM
- TX # 2:
- IBC to Stride with the action LSMLiquidStake, IBC receiver on Osmosis, custom IBC memo
- Stride automatically mints stATOM
- Stride automatically sends it to Osmosis, with the custom memo to convert to ATOM
- Osmosis automatically swaps stATOM for ATOM (query from the custom memo)
- Osmosis automatically sends ATOM to Cosmos Hub
Suggested Design
I would like to suggest:
- Adding IbcMemo to StakeibcPacketMetadata so we can pass a custom string in the ibc_memo field.
Suggestion to include in StakeibcPacketMetadata as:
IbcMemo string `json:"ibc_memo,omitempty"` - If
autopilotMetadata.IbcMemois not empty, it can be added here: https://github.com/Stride-Labs/stride/blob/main/x/autopilot/keeper/liquidstake.go#L138. If it's empty, we can keep "autopilot-liquid-stake-and-forward"
Acceptance Criteria
This should be pretty straightforward, but if you agree that this could be a nice-to-have feature, please let me know and I'll create a PR for it.
Thank you.