Canto-Network / Canto

Layer-1 blockchain powered by Free Public Infrastructure
GNU Lesser General Public License v3.0
83 stars 80 forks source link

feat: Onboarding IBC middleware #103

Closed poorphd closed 1 year ago

poorphd commented 1 year ago

Description

IBC onboarding middleware for Canto Onboarding UX Improvement

When users transfer assets to the Canto network through Gravity Bridge, the IBC transfer automatically triggers swap and conversion to Canto ERC20 via IBC middleware. Auto swap is triggered based on the recipient's Canto balance, and the remaining transferred balance is converted to Canto ERC20. The conversion process is independent of the result of the swap. It attempts to convert all assets transferred via IBC to ERC20 tokens, provided that the transferred asset is registered in the ERC20 token pairs. This applies even if the swap fails or is not triggered. onboarding middleware always returns original ACK from previous middleware stack meaning that even if the swap or conversion fails, it does not revert IBC transfer and the asset transferred to the Canto network will still remain in the Canto network

For auto swap function, Coinswap module is also added.

This module is a forked modification of IRISNET's Coinswap module v1.6. Several modifications have been made to ensure that the liquidity pools are only used for onboarding. The modifications are as follows:

IBC Testing package issue

There have been issues with onboarding middleware testing due to the low version of IBC-go currently used in Canto. When using ibc-go/testing, there were cases where EVM configuration loading failed because the proposer was not set in the block header, or the EVM call failed due to gas shortage caused by a low DefaultGenTxGas value. To resolve these issues, a custom version of ibc-go/testing is implemented in ibc/testing and used.

Tasks

After this pull request is merged, a follow-up pull request will be created to change the package name from v6 to v7.

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.

I have...

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.

I have...


Resolving Security Audit Findings

All security audit findings are resolved in this PR.

poorphd commented 1 year ago

@zscole Please review the PR. Thanks.

poorphd commented 1 year ago

With the recent v6 upgrade, there are conflicts that need to be resolved in the onboarding PR.

https://github.com/Canto-Network/Canto/pull/106 It looks like we may have to repeat the conflict resolve for the onboarding module if there is an upgrade coming soon that removes the vesting module. @tkkwon1998 Can you give us an idea of the features that will be included in the v7 upgrade?

Once we have confirmation of the above, we will modify the upgrade handler to the version that will include onboarding.

tkkwon1998 commented 1 year ago

Let's go with option 1, remove modules in v7 + onboarding merge.

I'll merge #106, then we can go ahead with resolving conflicts for onboarding PR.

tkkwon1998 commented 1 year ago

@poorphd #109 has been merged into main branch now

poorphd commented 1 year ago

We will resolve the conflicts once this PR is merged.

dongsam commented 1 year ago

The update related to swagger will be carried out after the https://github.com/Canto-Network/Canto/pull/112 is reviewed/merged or will be updated together on the PR depending on the merge order

tkkwon1998 commented 1 year ago

@dongsam #112 has been reviewed & merged now

tkkwon1998 commented 1 year ago

LGTM