Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Latest commit

 

History

History

terraswap_router

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Terraswap Router

The Router Contract contains the logic to facilitate multi-hop swap operations among the liquidity pools.

Imagine there are three tokens, A B and C. Say a bot wants to swap A for C, but only two pools are available, A-B and B-C. Thus, the router can be used to swap A for B and then B for C.

The router can handle both native and cw20 tokens, provided the corresponding AssetInfo:

pub enum AssetInfo {
    Token { contract_addr: String },
    NativeToken { denom: String },
}

Example

Swap A => B => C

{
   "execute_swap_operations":{
      "operations":[
         {
            "terra_swap":{
               "offer_asset_info":{
                   "token":{
                     "contract_addr":"juno1...A"
                  }
               },
               "ask_asset_info":{
                  "token":{
                     "contract_addr":"juno1...B"
                  }
               }
            }
         },
         {
            "terra_swap":{
               "offer_asset_info":{
                  "token":{
                     "contract_addr":"juno1...B"
                  }
               },
               "ask_asset_info":{
                   "token":{
                     "contract_addr":"juno1...C"
                  }
               }
            }
         }
      ],
      "minimum_receive":"1"
   }
}