Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math tests #25

Closed
wants to merge 13 commits into from
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ coverage
.vscode
note.txt
log.txt
dependencies
dependencies

/master
/development
10 changes: 10 additions & 0 deletions _tests/match_test/match_orders_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ mod success {
use super::*;

// ✅ buyOrder.orderPrice > sellOrder.orderPrice & buyOrder.baseSize > sellOrder.baseSize
// constants
// balances check
// alice deposit
// deposit check
// create a buy order
// deposited balance check and order check
// same stuff for a sell order
// match orders
// close order in nessesary
// deposited balances check
#[tokio::test]
async fn greater_buy_price_and_greater_buy_amount() {
let buy_price = 46_000_f64;
Expand Down
11 changes: 11 additions & 0 deletions market-contract/src/data_structures/asset_type.sw
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ impl Hash for AssetType {
}
}
}


// impl core::ops::Eq for AssetType {
// fn eq(self, other: Self) -> bool {
// match (self, other) {
// (Self::Base, Self::Base) => true,
// (Self::Quote, Self::Quote) => true,
// _ => false,
// }
// }
// }
25 changes: 0 additions & 25 deletions market-contract/src/data_structures/order.sw
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,4 @@ impl Order {
require(price != 0, OrderError::PriceCannotBeZero);
self.price = price;
}

// #[storage(read)]
// pub fn calculate_deposit(
// self,
// BASE_ASSET_DECIMALS: u32,
// PRICE_DECIMALS: u32,
// QUOTE_TOKEN_DECIMALS: u32,
// QUOTE_TOKEN: AssetId,
// ) -> Asset {
// match self.order_type {
// OrderType::Sell => Asset::new(self.amount, self.asset),
// OrderType::Buy => {
// Asset::new(
// quote(
// self.amount,
// BASE_ASSET_DECIMALS,
// self.price,
// PRICE_DECIMALS,
// QUOTE_TOKEN_DECIMALS,
// ),
// QUOTE_TOKEN,
// )
// },
// }
// }
}
2 changes: 1 addition & 1 deletion market-contract/src/data_structures/order_type.sw
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ impl Hash for OrderType {
}
}
}
}
}
2 changes: 1 addition & 1 deletion market-contract/src/interface.sw
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abi Market {
// fn fulfill(order_id: b256);

#[storage(read, write)]
fn batch_fulfill(order_id: b256, orders: Vec<b256>);
fn batch_fulfill(order_sell_id: b256, order_buy_id: b256);

#[storage(write)]
fn set_fee(amount: u64, user: Option<Identity>);
Expand Down
Loading