# AKT fee abstraction Hi Akash Team. I'm Nguyen from Caelus Labs. We have idea about [Stable payments & Take rates]. It's related with `Phase 2 - Fast-follow` and `Phase 3 - Bells and whistles` in this discusstion : https://github.com/orgs/akash-network/discussions/147. We called it `AKT Fee abstraction` ## Context Currently, Akash Network only allows the use of AKT tokens for its services. Users who hold tokens other than AKT need to swap their tokens for AKT if they want to use Akash services. With `AKT fee abstraction` implementation, user can use IBC token for service fee in Akash Network. Module will swap IBC token via Osmosis automatically and dont't break current payment flow. The usecases that motivated the development of this module are: - More flexiable payment : this module allow the use of IBC token to pay service fees in Akash Network - Additional payment options for the Bid/Lease mechanism in Akash Network, with `AKT fee abstraction`. - Providers able to choose the types of tokens they accept for their services, as currently they only receive AKT. - Users who want to lease a service can use any type of token as a service fee. Otherwise, using fee abstraction promote the AKT trading volumn in DEX. ## Prototype Akash fee abstraction mechanism : 1. Get price data from osmosis (this is on-chain data) : - Periodically pulling `twap data` from osmosis by ibc-ing to `async-icq` module on Osmosis, this `twap data` will update the exchange rate of osmosis to customer chain's native token. - This exchange rate is used to calaculate swap out amount. 2. Handling bid/lease with ibc-token fee: - The core change is in `escrow` and `market` module. - For bid/lease process : - Providers can choose IBC token for their payment when they `CreateBid`. When a user `CreateLease`, the module calculates and converts IBC tokens to the needed amount for the bid. In this process we will use osmosis's Cross chain Swap (XCS) feature for converting token. - User can deposit IBC token into escrow address (by `DepositDeployment` msg), this amount will be automatically convert to token with denom specified when provider `CreateBid`. ## Specification #### 1. Get price data from osmosis (this is on-chain data) The exchange rate will be set by TWAP data from osmosis DEX via `async-icq`. This exchange rate will be used to calculate `EstimatedLeaseAmount` when user leasing by`CreateLease` msg. #### 2.Allow providers to use IBC token in their bid when `CreateBid`. Providers can choose a token for payment when they CreateBid. When a user creates a lease by `CreateLease` msg, the fee abstraction module calculates the IBC token needed by `twap data` : `EstimatedLeaseAmount = bidAmount * exchangeTwapRate` The module will convert the `EstimatedLeaseAmount` to the required bid by swapping this token via XCS. Once this is completed, we will have the `FractionalPayment` with the bid token and process it the same way as the current process. #### 3. Allow user deposit IBC token when `DepositDeployment`. If a user wants to `DepositDeployment` with IBC tokens, the module will first check if that token is allowed (allowed denom is a module parameter). Then, it will use Osmosis's Cross Chain Swap (XCS) feature to convert the IBC token to the required bid token (specified by the provider when `CreateBid`) via the Osmosis DEX. Essentially, the module transfers IBC tokens to the Osmosis Cross Chain Swap contract with a custom memo to swap the IBC token for the matched bid token, and then transfers them back to the escrow address in Akash Network.