Skip to content

Latest commit

 

History

History

mirror_limit_order

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Mirror Limit Order

NOTE: Reference documentation for this contract is available here.

The Limit Order Contract is to provide limit order interface to a bidder and also provide arbitrage opportunity to a market maker.

Use Cases

  1. UST -> ASSET
Order                     
+-----------------+    Terraswap Price (UST-mAAPL)
| OrderId       1 |    +------------------------+
| Offer   100 UST |    | price 95 UST : 1 mAAPL |
| Ask     1 mAAPL |    +------------------------+
+-----------------+                 |
        ^                           |
        |       +-------------+     | 
        +-----  | Arbitrageur |<----+
         Sell   +-------------+  Buy

  1. ASSET => UST
Order                     
+-----------------+    Terraswap Price (UST-mAAPL)
| OrderId       1 |    +-------------------------+
| Offer   1 mAAPL |    | price 110 UST : 1 mAAPL |
| Ask     100 UST |    +-------------------------+
+-----------------+                 ^
        |                           |
        |       +-------------+     | 
        +-----> | Arbitrageur |-----+
         Buy    +-------------+  Sell

Handlers

Submit Order

Depends on the offer asset type

  • Native Token

    MsgExecuteContract(
        'limit_order_contract_addr',
        [Coin('denom', 'amount')],
        base64(SubmitOrder {
            offer_asset: Asset,
            ask_asset: Asset,
        })
    )
    
  • Token

    MsgExecuteContract(
        'token_contract',
        [],
        base64(Send {
            contract_addr: 'limit_order_contract_addr',
            amount: 'amount',
            msg: Some(base64(SubmitOrder {
                ask_asset: Asset,
            })),
        })
    )
    

Cancel Order

MsgExecuteContract(
    'limit_order_contract_addr',
    [],
    base64(CancelOrder {
        order_id: u64,
    })
)

Execute Order

Order can be executed partially

Depends on the ask asset(= execute asset) type

  • Native Token

    MsgExecuteContract(
        'limit_order_contract_addr',
        [Coin('denom', 'amount')],
        base64(ExecuteOrder {
         execute_asset: Asset,
         order_id: u64,
        })
    )
    
  • Token

    MsgExecuteContract(
        'token_contract',
        [],
        base64(Send {
            contract_addr: 'limit_order_contract_addr',
            amount: 'amount',
            msg: Some(base64(ExecuteOrder {
                order_id: u64,
            })),
        })
    )
    

Query Orders