---
# System prepended metadata

title: Fee abstraction for sercet

---

# Fee abstraction for sercet network

## Goal 
1. It should use Shadeswap (app.shadeprotocol.io) as the swap base, and have osmosis as a fallback swap base in case a token isn't supported by Shade.
2. It should be able to be implemented natively on Secret but also on other Cosmos SDK blockchains v0.45 and up.
3. It should be easily integrateable into Keplr/Leap.
4. It should work to use CW20 like private tokens on Secret (SNIP-20) as gas.

## Feasability study
**1. Use shadeprotocol as swap-base and osmosis as fallback swap-base**

In osmosis fee-abs, the osmosis dex is used as the swap base which serves two key functions: `swaping of collected fee in batches` and `fetching conversion rate` (TWAP data). Applying the same logic, if we want  Shadeswap as swap base, we just need to use Shadeswap (instead of osmosis dex) for `swaping of collected fee in batches` and `fetching conversion rate` (spot price data of the contract).

However, we wants our module to have osmosis as fallback swap base. This means the module needs to support multiple swap bases. Design wise, we need to:
- Define swap base as an interface where shadeswap and osmosis is two implementations. 
- Create a swap base router to determine when to use what swap base, with logic of the router being `if shade swap base doesn't support the fee token, resort to osmosis swap base`


**2. Implementation in SecretNetwork and other Cosmos SDK blockchains v0.45 and up**

 - For Secret: 
    - Implementation should be split up into many phases:
        1. Redesign the osmosis fee-abs from hardcoding osmosis swap-base to allowing multiple swap bases. This step includes defining the swap base interface and creating a swap base router.
        2. Implement shadeswap swap-base. This implementation should be much more simple than osmosis swap base as we don't need to use IBC-swap and IBC-query since our swap base is native. Becuse there's no IBC logic, there's no complications related path unwinding or ibc errors handling.
        3. Implement osmosis swap-base. Should be able to re-use the logic from osmosis fee-abs.
 - For other chains:
    - For other chains, shadeswap swap-base is no longer native, we need to re-implement the shadeswap swap-base into a different version to support IBC operations.  
    - Furthermore, for ibc swap-base, the IBC processes is handled via an IBC chan between fee-abs module and the `Outpost` contract on swap-base chain. Thus, an `Outpost` contract needs to be deployed on secret chain to support secret fee-abs on other chains.

**3. Integrateable into Keplr/Leap**
For now keplr only allows paying fee using native `x/bank` token, not SNIP-20 token. We need to make feature request to keplr.

I believe that Leap wallet still needs to be modified. We will investigate further and diccuss with Leap wallet team for this change if needed.
There're still have some problem with Kelpr wallet when show the SNIP-20 amount as fees.

**4. It should work to use CW20 like private tokens on Secret (SNIP-2O) as gas**
Fee abstraction will work with any token that can swapeed by shade swap.

