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.
- UST -> ASSET
Order
+-----------------+ Terraswap Price (UST-mAAPL)
| OrderId 1 | +------------------------+
| Offer 100 UST | | price 95 UST : 1 mAAPL |
| Ask 1 mAAPL | +------------------------+
+-----------------+ |
^ |
| +-------------+ |
+----- | Arbitrageur |<----+
Sell +-------------+ Buy
- ASSET => UST
Order
+-----------------+ Terraswap Price (UST-mAAPL)
| OrderId 1 | +-------------------------+
| Offer 1 mAAPL | | price 110 UST : 1 mAAPL |
| Ask 100 UST | +-------------------------+
+-----------------+ ^
| |
| +-------------+ |
+-----> | Arbitrageur |-----+
Buy +-------------+ Sell
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, })), }) )
MsgExecuteContract(
'limit_order_contract_addr',
[],
base64(CancelOrder {
order_id: u64,
})
)
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 a order
-
Query orders
- Query with bidder address
- https://lcd.terra.dev/wasm/contracts/`limit_order_contract`/store?query_msg={"orders":{"bidder_addr": "terra~"}}
- https://lcd.terra.dev/wasm/contracts/`limit_order_contract`/store?query_msg={"orders":{"bidder_addr": "terra~", "start_after": 50, "limit": 10, "order_by": "desc"}}
- Query without filter
- Query with bidder address
-
Query last order id