Skip to content

Commit

Permalink
Merge pull request #48 from oraichain/feat/change-limit-order-to-orde…
Browse files Browse the repository at this point in the history
…rbook

change to oraiswap_orderbook
  • Loading branch information
tubackkhoa authored Mar 18, 2024
2 parents fc9c351 + 4eae061 commit b6594f7
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 311 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 17 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,43 @@ Uniswap-inspired automated market-maker (AMM) protocol powered by Smart Contract

## Contracts

| Name | Description |
| -------------------------------------------------------- | -------------------------------------------------------- |
| [`oraiswap_factory`](contracts/oraiswap_factory) | Proxy contract to create oraiswap_pair instance |
| [`oraiswap_oracle`](contracts/oraiswap_oracle) | Global parameters updated by multisig wallet |
| [`oraiswap_pair`](contracts/oraiswap_pair) | Logic for building liquidity pool and trade between pair |
| [`oraiswap_router`](contracts/oraiswap_router) | Facilitate multi-hop swap operations |
| [`oraiswap_limit_order`](contracts/oraiswap_limit_order) | Orderbook implementation |
| [`oraiswap_staking`](contracts/oraiswap_staking) | Stake LPs to get ORAIX reward |
| [`oraiswap_token`](contracts/oraiswap_token) | (ERC20 equivalent) token implementation, AIRI, ORAIX |
| Name | Description |
| ---------------------------------------------------- | -------------------------------------------------------- |
| [`oraiswap_factory`](contracts/oraiswap_factory) | Proxy contract to create oraiswap_pair instance |
| [`oraiswap_oracle`](contracts/oraiswap_oracle) | Global parameters updated by multisig wallet |
| [`oraiswap_pair`](contracts/oraiswap_pair) | Logic for building liquidity pool and trade between pair |
| [`oraiswap_router`](contracts/oraiswap_router) | Facilitate multi-hop swap operations |
| [`oraiswap_orderbook`](contracts/oraiswap_orderbook) | Orderbook implementation |
| [`oraiswap_staking`](contracts/oraiswap_staking) | Stake LPs to get ORAIX reward |
| [`oraiswap_token`](contracts/oraiswap_token) | (ERC20 equivalent) token implementation, AIRI, ORAIX |

- oraiswap_factory

Mainnet: `orai1ulgw0td86nvs4wtpsc80thv6xelk76ut7a7apj`

Testnet: `orai18qpjm4zkvqnpjpw0zn0tdr8gdzvt8au35v45xf`
Mainnet: [`orai167r4ut7avvgpp3rlzksz6vw5spmykluzagvmj3ht845fjschwugqjsqhst`](https://scan.orai.io/smart-contract/orai167r4ut7avvgpp3rlzksz6vw5spmykluzagvmj3ht845fjschwugqjsqhst)

- oraiswap_oracle

Mainnet: `orai1ulgw0td86nvs4wtpsc80thv6xelk76ut7a7apj`

Testnet: `orai18qpjm4zkvqnpjpw0zn0tdr8gdzvt8au35v45xf`
Mainnet: [`orai18rgtdvlrev60plvucw2rz8nmj8pau9gst4q07m`](https://scan.orai.io/smart-contract/orai18rgtdvlrev60plvucw2rz8nmj8pau9gst4q07m)

- oraiswap_pair

Mainnet (CodeID): 4

Testnet (CodeID): 7869
Mainnet (CodeID): 1502

- oraiswap_route

Mainnet: `orai1ulgw0td86nvs4wtpsc80thv6xelk76ut7a7apj`
Mainnet: [`orai1j0r67r9k8t34pnhy00x3ftuxuwg0r6r4p8p6rrc8az0ednzr8y9s3sj2sf`](https://scan.orai.io/smart-contract/orai1j0r67r9k8t34pnhy00x3ftuxuwg0r6r4p8p6rrc8az0ednzr8y9s3sj2sf)

Testnet: `orai18qpjm4zkvqnpjpw0zn0tdr8gdzvt8au35v45xf`
- oraiswap_orderbook

- oraiswap_limit_order

Mainnet: `orai1ulgw0td86nvs4wtpsc80thv6xelk76ut7a7apj`

Testnet: `orai18qpjm4zkvqnpjpw0zn0tdr8gdzvt8au35v45xf`
Mainnet: [`orai1nt58gcu4e63v7k55phnr3gaym9tvk3q4apqzqccjuwppgjuyjy6sxk8yzp`](https://scan.orai.io/smart-contract/orai1nt58gcu4e63v7k55phnr3gaym9tvk3q4apqzqccjuwppgjuyjy6sxk8yzp)

- oraiswap_staking

Mainnet: `orai19p43y0tqnr5qlhfwnxft2u5unph5yn60y7tuvu`

Testnet: `orai1yzncqj7f8sculc3849w9hg9r4f4u79e3swnlr7`
Mainnet: [`orai19p43y0tqnr5qlhfwnxft2u5unph5yn60y7tuvu`](https://scan.orai.io/smart-contract/orai19p43y0tqnr5qlhfwnxft2u5unph5yn60y7tuvu)

- oraiswap_token

Mainnet (CodeID): 3

Testnet (CodeID): 148
Mainnet (CodeID): 582

## Running this contract

Expand Down Expand Up @@ -88,13 +74,3 @@ impl ::std::convert::TryFrom<&[u8]> for MsgInstantiateContractResponse {
}
END
```

## Code coverage

```bash
# install tarpaulin if needed
cargo install cargo-tarpaulin --locked

# Run code coverage for all contracts
cargo tarpaulin --skip-clean --ignore-tests --exclude-files contracts/*/src/bin/schema.rs --frozen --engine llvm --out html --output-dir cov
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "oraiswap-limit-order"
name = "oraiswap-orderbook"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Depends on the offer asset type

```
MsgExecuteContract(
'limit_order_contract_addr',
'orderbook_contract_addr',
[Coin('denom', 'amount')],
base64(SubmitOrder {
direction: OrderDirection::Buy,
Expand All @@ -61,7 +61,7 @@ Depends on the offer asset type
'token_contract',
[],
base64(Send {
contract_addr: 'limit_order_contract_addr',
contract_addr: 'orderbook_contract_addr',
amount: 'amount',
msg: Some(base64(SubmitOrder {
direction: OrderDirection::Buy,
Expand All @@ -75,7 +75,7 @@ Depends on the offer asset type

```
MsgExecuteContract(
'limit_order_contract_addr',
'orderbook_contract_addr',
[],
base64(CancelOrder {
order_id: u64,
Expand All @@ -93,7 +93,7 @@ Depends on the `ask asset`(= `execute asset`) type

```
MsgExecuteContract(
'limit_order_contract_addr',
'orderbook_contract_addr',
[Coin('denom', 'amount')],
base64(ExecuteOrder {
execute_asset: Asset,
Expand All @@ -108,7 +108,7 @@ Depends on the `ask asset`(= `execute asset`) type
'token_contract',
[],
base64(Send {
contract_addr: 'limit_order_contract_addr',
contract_addr: 'orderbook_contract_addr',
amount: 'amount',
msg: Some(base64(ExecuteOrder {
order_id: u64,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use oraiswap::limit_order::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use oraiswap::orderbook::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ use crate::state::{

use cw20::Cw20ReceiveMsg;
use oraiswap::asset::{pair_key, Asset, AssetInfo};
use oraiswap::limit_order::{
use oraiswap::orderbook::{
ContractInfo, ContractInfoResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg,
OrderDirection, QueryMsg,
};

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:oraiswap_limit_order";
const CONTRACT_NAME: &str = "crates.io:oraiswap_orderbook";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

// default commission rate = 0.1 %
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use cosmwasm_std::{
use cosmwasm_storage::ReadonlyBucket;
use oraiswap::asset::{pair_key, Asset, AssetInfo};
use oraiswap::error::ContractError;
use oraiswap::limit_order::{OrderDirection, OrderStatus, Payment};
use oraiswap::orderbook::{OrderDirection, OrderStatus, Payment};

pub const RELAY_FEE: u128 = 300u128;
pub const MIN_VOLUME: u128 = 10u128;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmwasm_schema::cw_serde;
use cosmwasm_storage::ReadonlyBucket;
use oraiswap::{
asset::{pair_key_from_asset_keys, Asset, AssetInfo, AssetInfoRaw},
limit_order::{OrderBookResponse, OrderDirection, OrderResponse, OrderStatus},
orderbook::{OrderBookResponse, OrderDirection, OrderResponse, OrderStatus},
};

use cosmwasm_std::{Api, CanonicalAddr, Decimal, Order as OrderBy, StdResult, Storage, Uint128};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use crate::state::{
};
use cosmwasm_std::{Decimal, Deps, Order as OrderBy, StdError, StdResult, Storage, Uint128};
use oraiswap::error::ContractError;
use oraiswap::limit_order::{OrderStatus, SimulateMarketOrderResponse};
use oraiswap::orderbook::{OrderStatus, SimulateMarketOrderResponse};
use std::convert::{TryFrom, TryInto};
use std::str::FromStr;

use oraiswap::asset::{pair_key, AssetInfo};
use oraiswap::{
limit_order::{
orderbook::{
LastOrderIdResponse, OrderBookResponse, OrderBooksResponse, OrderDirection, OrderFilter,
OrderResponse, OrdersResponse, TickResponse, TicksResponse,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cosmwasm_std::{Api, CanonicalAddr, Order as OrderBy, StdError, StdResult, St
use cosmwasm_storage::{singleton, singleton_read, Bucket, ReadonlyBucket};
use oraiswap::{
error::ContractError,
limit_order::{ContractInfo, OrderDirection},
orderbook::{ContractInfo, OrderDirection},
querier::calc_range_start,
};
use serde::{de::DeserializeOwned, Serialize};
Expand Down
Loading

0 comments on commit b6594f7

Please sign in to comment.