Recently, we became aware of this issue and the lack of a way to do it in the Bastion UI, so we decided to create a tutorial for everyone to use independently. Big thanks to the people in the community who helped me create and test this tutorial and provided invaluable insights and feedback!

To formulate the problem more precisely, a user has some cUSDCcUSDTLP tokens and wants to convert these back to stables. The Bastion project's UI doesn't allow this today, so the only way is to call smart contracts directly.

We will go through the next steps:

  • What contracts should we call?

  • What method should we call, and how?

  • How to convert cUSDC and cUSDT into regular stables?

We will use the most convenient way for users to interact with smart contracts—the Explorer. However, devs can always write a script to perform the steps described in this article with Ethers or Web3.js.

Let's go!

What contracts?

The main actor of this article will be SwapFlashLoan contract:

The plan is:

  1. Approve cUSDCcUSDTLP token to be used by the SwapFlashLoan contract.

  2. Get cUSDC and cUSDT from SwapFlashLoan.

  3. Redeem cUSDC and cUSDT from their contracts to get stables.

Approve cUSDCcUSDTLP

Let's start with connecting your wallet. To do this, please open cUSDCcUSDTLP token contract and click Contract -> Write Contract -> Connect Wallet:

Then you will see the next popup to connect your wallet:

We recommend using the Aurora Pass wallet, which you can connect via the Wallet Connect option above and a QR code. It offers 50 free transactions a month on the Aurora blockchain and is a very user-friendly mobile wallet.

After connecting it, we're ready to move further.

If you scroll down, you will see the contract methods, and here is the one we need – approve and enter the arguments there with spender being the swapFlashLoan contract address and amount equal to the number of tokens you want to get back (probably all you have right now):

Now, we're ready to execute the transaction, just click the "Write" button on the right and confirm it in your wallet!

Get cUSDC and cUSDT

Let's open now the SwapFlashLoan contract. Go to the Contract -> Write Contract tab. If you scroll down, you will see the contract methods, and here is the one we need – removeLiquidity:

We're unsure about the arguments here yet, so let's find out what values we should use. To do this, we will look at one such transaction, which has already been executed by someone. We need to find it in history. So here is one:

You can see what exactly has happened here during the execution in terms of the token transfers:

  • cUSDCcUSDTLP tokens were burned

  • cUSDT and cUSDC tokens were transferred to the caller

Now, let's scroll down a bit and click on "View details" link at the left bottom of the page, you will see the arguments of the method used there:

We can conclude by looking at the both screenshots above that:

  1. amount argument is equal to your cUSDCcUSDTLP tokens amount with 18 decimals added. E.g. in this case, the user has 2021.941835489438, so the correct value should be 2021294184354893800000. You can use this tool to convert your values.

  2. deadline is your time now, with 20 minutes added to it in a timestamp format. You can use the EpochConverter tool to get the correct value. Just add 20 minutes to the datetime there and copy-paste the timestamp value.

  3. The first value in minAmounts corresponds to the cUSDT token amount transferred back, and the second one is for the cUSDC. They have 8 decimals, and if you sum them up, you will get your amount of cUSDCcUSDTLP tokens. So you can just enter any values which in sum give you a value smaller or equal to the amount.

We're ready to execute the method now. Just enter the correct arguments to your Explorer tab, it should look like this:

After that, just click the "Write" button and confirm the transaction in your wallet.
That is it! Now you got back your cUSDC and cUSDT tokens.

How to convert cTokens to stables?

To do this, we will need to point our attention to these contracts:

For both of them, the process will look the same, so let's just talk about cUSDT case. To unwrap you need to call this method – `redeem`:

It has only one argument, which is the amount of tokens to unwrap with 8 decimals added to it. So, for the transaction from the previous section, it should be 167994638559. It is the amount of the cUSDT tokens you have received after your removeLiquidity call.

Final thoughts

That is it – you have successfully got your cUSDCcUSDTLP tokens converted back to stables. If you need any help or have a similar issue, please come to our Discord, and we will help you! Thank you for reading!