- Obtaining the user’s CW20 token balance.
- Creating a message to convert CW20 tokens to bank tokens using ConvertCw20ToBankService
- Executing a market order using the converted bank balance and existing bank balance
Get User’s CW20 Balance
You can perform this using explorer indexer queries.- Find the cw20 address and balance from the result set that you want to convert to a bank factory token
Create CW20 to Bank Conversion Message
- create the
convertMsgusing the steps detailed here in order to convert your CW20 token to a bank factory token. No need to submit the tsx yet.
Create a MsgCreateSpotMarketOrder message
- Create the
msgusing the steps detailed in MsgCreateSpotMarketOrder. No need to submit the tsx yet. - Note that the buy order you create will have access to your converted cw20 balance + existing bank balance. Example:
- If you had 5 Cw20 tokens and 5 bank tokens at a price of $1 each, then the order above will go through because we will convert the cw20 to bank before the chain executes this market order. This will be more clear in the next step.
