From 94d4f12fb468a670382691fd7ca5ae91c520aa84 Mon Sep 17 00:00:00 2001 From: politeWall <138504353+politeWall@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:22:25 +0100 Subject: [PATCH] feat: fix test, add map handling for order and reply, change status , updated doc --- Cargo.lock | 10 ++--- Cargo.toml | 8 ++-- front_end_script/README.md | 40 ++++++++++++++++--- front_end_script/upload.js | 38 +++++++++++++++++- src/action/execute/cancel_margin_order.rs | 2 +- src/action/execute/cancel_margin_orders.rs | 2 +- src/action/execute/cancel_spot_order.rs | 2 +- src/action/execute/cancel_spot_orders.rs | 2 +- src/action/execute/claim_rewards_request.rs | 1 - .../claim_validator_commission_request.rs | 1 - src/action/execute/close_margin_position.rs | 2 +- src/action/execute/create_margin_order.rs | 38 +++++++++++------- .../execute/eden_cancel_vest_request.rs | 1 - src/action/execute/eden_vest_request.rs | 1 - .../execute/elys_cancel_unstake_request.rs | 1 - .../execute/elys_redelegation_request.rs | 1 - src/action/execute/stake_request.rs | 1 - src/action/execute/unstake_request.rs | 1 - src/action/query/get_margin_orders.rs | 34 ++++++++-------- src/action/query/get_spot_orders.rs | 34 ++++++++-------- src/action/reply/close_margin_position.rs | 4 +- .../reply/create_margin_order_market_close.rs | 2 +- .../reply/create_margin_order_market_open.rs | 2 +- src/action/reply/open_margin_position.rs | 4 +- src/action/reply/spot_order.rs | 2 +- src/action/reply/spot_order_market.rs | 2 +- src/action/sudo/process_orders.rs | 25 +++++++----- src/entry_point/execute.rs | 22 ++++------ src/entry_point/query.rs | 4 ++ src/msg/query_msg.rs | 4 +- .../process_spot_order_processing.rs | 4 +- .../successfully_cancel_orders.rs | 8 ++-- .../successfully_cancel_orders_id.rs | 8 ++-- .../successfully_cancel_orders_type.rs | 8 ++-- .../closing_a_margin_position.rs | 2 +- .../successful_create_margin_market_order.rs | 2 +- .../successful_create_nargin_market_close.rs | 2 +- src/tests/create_spot_order/coin_number.rs | 6 ++- .../successful_create_market_order.rs | 3 +- src/tests/get_spot_orders/get_spot_orders.rs | 13 +++--- .../process_limit_open.rs | 2 +- .../process_order_close.rs | 34 +++++++++++++++- .../successful_process_5_of_10_orders.rs | 20 +++++----- src/types/margin_order.rs | 4 +- src/types/spot_order/impls/new.rs | 2 +- src/types/spot_order/impls/new_dummy.rs | 2 +- src/types/status.rs | 4 +- 47 files changed, 259 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0384b99..de6a767 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,8 +371,8 @@ dependencies = [ [[package]] name = "elys-bindings" -version = "0.7.0" -source = "git+https://github.com/elys-network/bindings?tag=v0.7.0#1fd2d8733894e6f2a5f943cc7a072d665803f378" +version = "0.8.0" +source = "git+https://github.com/elys-network/bindings?tag=v0.8.0#6e3eba16496f7ea9ded374099c6ad6e51331708f" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -381,8 +381,8 @@ dependencies = [ [[package]] name = "elys-bindings-test" -version = "0.7.0" -source = "git+https://github.com/elys-network/bindings?tag=v0.7.0#1fd2d8733894e6f2a5f943cc7a072d665803f378" +version = "0.8.0" +source = "git+https://github.com/elys-network/bindings?tag=v0.8.0#6e3eba16496f7ea9ded374099c6ad6e51331708f" dependencies = [ "anyhow", "cosmwasm-schema", @@ -787,7 +787,7 @@ dependencies = [ [[package]] name = "trade_shield_contract" -version = "0.9.0" +version = "0.10.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index edfbd80..7e3ad1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trade_shield_contract" -version = "0.9.0" +version = "0.10.0" edition = "2021" [lib] @@ -14,13 +14,13 @@ thiserror = "1" schemars = "0.8.1" cosmwasm-schema = "1.1.4" cw-utils = "0.13" -elys-bindings = { version = "0.7.0", git = "https://github.com/elys-network/bindings", tag = "v0.7.0" } +elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0" } [dev-dependencies] cw-multi-test = "0.13.4" serde_json = "1.0.107" -elys-bindings = { version = "0.7.0", git = "https://github.com/elys-network/bindings", tag = "v0.7.0", features = [ +elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0", features = [ "testing", ] } -elys-bindings-test = { version = "0.7.0", git = "https://github.com/elys-network/bindings", tag = "v0.7.0" } +elys-bindings-test = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0" } diff --git a/front_end_script/README.md b/front_end_script/README.md index 12f9700..5473bce 100644 --- a/front_end_script/README.md +++ b/front_end_script/README.md @@ -89,7 +89,7 @@ This function retrieves information about multiple order by querying a CosmWasm #### Usage ```javascript -cancelSpotOrders("order_ids", "order_type", "owner_address"); +cancelSpotOrders("order_ids", "order_type", "order_owner"); ``` #### Exemple @@ -122,7 +122,7 @@ getSpotOrder("your_order_id_here"); getSpotOrder("1"); ``` -### 5. getSpotOrders(pagination, order_type, owner_address) +### 5. getSpotOrders(pagination, order_type, order_owner, order_status) This function retrieves information about multiple order by querying a CosmWasm contract on the blockchain. @@ -130,12 +130,13 @@ This function retrieves information about multiple order by querying a CosmWasm - `pagination` {PageRequest} : - `order_type` (OrderType or null): select the order type that should be querried -- `owner_address` (String or null): select the owner of the order that should be querried +- `order_owner` (String or null): select the owner of the order that should be querried +- `order_status` (String or null) : select the order staus that should be querried (Pending,Executed,Canceled) #### Usage ```javascript -getSpotOrders({"count_total", "limit", "reverse", "key"}, "order_type", "owner_address") +getSpotOrders({"count_total", "limit", "reverse", "key"}, "order_type", "order_owner", "status") ``` #### @@ -144,7 +145,8 @@ getSpotOrders({"count_total", "limit", "reverse", "key"}, "order_type", "owner_a getSpotOrders( { count_total: true, limit: 10, reverse: false, key: null }, "stop_loss", - "elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w" + "elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w", + null ); ``` @@ -300,6 +302,34 @@ SwapEstimationByDenom({ }); ``` +### 12. getMarginOrders(pagination, order_type, order_owner, order_status) + +This function retrieves information about multiple order by querying a CosmWasm contract on the blockchain. + +#### Parameters + +- `pagination` {PageRequest} : +- `order_type` (OrderType or null): select the order type that should be querried +- `order_owner` (String or null): select the owner of the order that should be querried +- `order_status` (String or null) : select the order staus that should be querried (pending,executed,canceled) + +#### Usage + +```javascript +getMarginOrders({"count_total", "limit", "reverse", "key"}, "order_type", "order_owner", status) +``` + +#### + +```js +getMarginOrders( + { count_total: true, limit: 10, reverse: false, key: null }, + "stop_loss", + "elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w", + "pending" +); +``` + ## Configuration Before using these functions, you need to configure the following parameters in the script: diff --git a/front_end_script/upload.js b/front_end_script/upload.js index 34fea81..26178eb 100644 --- a/front_end_script/upload.js +++ b/front_end_script/upload.js @@ -135,7 +135,40 @@ async function cancelSpotOrders(order_type, owner_address, order_ids) { console.log("create_spot_orders_res:", create_spot_orders_res); } -async function getSpotOrders(pagination, order_type, owner_address) { +async function getSpotOrders( + pagination, + order_type, + order_owner, + order_status +) { + const sender_wallet = await DirectSecp256k1HdWallet.fromMnemonic( + sender.mnemonic, + { prefix: "elys" } + ); + const sender_client = await SigningCosmWasmClient.connectWithSigner( + rpcEndpoint, + sender_wallet + ); + const result = await sender_client.queryContractSmart( + trade_shield_contract_addr, + { + get_spot_orders: { + pagination: pagination, + order_type: order_type, + order_owner: order_owner, + order_status: order_status, + }, + } + ); + console.log(`Result: `, result); +} + +async function getSpotOrders( + pagination, + order_type, + order_owner, + order_status +) { const sender_wallet = await DirectSecp256k1HdWallet.fromMnemonic( sender.mnemonic, { prefix: "elys" } @@ -150,7 +183,8 @@ async function getSpotOrders(pagination, order_type, owner_address) { get_spot_orders: { pagination: pagination, order_type: order_type, - owner_address: owner_address, + order_owner: order_owner, + order_status: order_status, }, } ); diff --git a/src/action/execute/cancel_margin_order.rs b/src/action/execute/cancel_margin_order.rs index a6de82d..bea1411 100644 --- a/src/action/execute/cancel_margin_order.rs +++ b/src/action/execute/cancel_margin_order.rs @@ -18,7 +18,7 @@ pub fn cancel_margin_order( }); } - if order.status != Status::NotProcessed { + if order.status != Status::Pending { return Err(ContractError::CancelStatusError { order_id, status: order.status.clone(), diff --git a/src/action/execute/cancel_margin_orders.rs b/src/action/execute/cancel_margin_orders.rs index c1df434..e1b6a9e 100644 --- a/src/action/execute/cancel_margin_orders.rs +++ b/src/action/execute/cancel_margin_orders.rs @@ -38,7 +38,7 @@ pub fn cancel_margin_orders( if let Some(order) = filtered_order .iter() - .find(|order| order.status != Status::NotProcessed) + .find(|order| order.status != Status::Pending) { return Err(ContractError::CancelStatusError { order_id: order.order_id, diff --git a/src/action/execute/cancel_spot_order.rs b/src/action/execute/cancel_spot_order.rs index 093b4c2..01639f4 100644 --- a/src/action/execute/cancel_spot_order.rs +++ b/src/action/execute/cancel_spot_order.rs @@ -16,7 +16,7 @@ pub fn cancel_spot_order( }); } - if order.status != Status::NotProcessed { + if order.status != Status::Pending { return Err(ContractError::CancelStatusError { order_id, status: order.status.clone(), diff --git a/src/action/execute/cancel_spot_orders.rs b/src/action/execute/cancel_spot_orders.rs index daf16d5..32323a1 100644 --- a/src/action/execute/cancel_spot_orders.rs +++ b/src/action/execute/cancel_spot_orders.rs @@ -38,7 +38,7 @@ pub fn cancel_spot_orders( if let Some(order) = filtered_order .iter() - .find(|order| order.status != Status::NotProcessed) + .find(|order| order.status != Status::Pending) { return Err(ContractError::CancelStatusError { order_id: order.order_id, diff --git a/src/action/execute/claim_rewards_request.rs b/src/action/execute/claim_rewards_request.rs index cfe260c..fccfeaf 100644 --- a/src/action/execute/claim_rewards_request.rs +++ b/src/action/execute/claim_rewards_request.rs @@ -2,7 +2,6 @@ use super::*; use elys_bindings::types::EarnType; pub fn claim_rewards_request( - env: Env, info: MessageInfo, _deps: DepsMut, withdraw_type: EarnType, diff --git a/src/action/execute/claim_validator_commission_request.rs b/src/action/execute/claim_validator_commission_request.rs index ee05d0f..62d47a8 100644 --- a/src/action/execute/claim_validator_commission_request.rs +++ b/src/action/execute/claim_validator_commission_request.rs @@ -1,7 +1,6 @@ use super::*; // delegator_address, validator_address, denom pub fn claim_validator_commission_request( - env: Env, info: MessageInfo, _deps: DepsMut, validator_address: String, diff --git a/src/action/execute/close_margin_position.rs b/src/action/execute/close_margin_position.rs index 7a801ac..a3d7160 100644 --- a/src/action/execute/close_margin_position.rs +++ b/src/action/execute/close_margin_position.rs @@ -4,7 +4,7 @@ use super::*; pub fn close_margin_position( info: MessageInfo, - env: Env, + id: u64, amount: Int128, ) -> Result, ContractError> { diff --git a/src/action/execute/create_margin_order.rs b/src/action/execute/create_margin_order.rs index faafe98..f1c9525 100644 --- a/src/action/execute/create_margin_order.rs +++ b/src/action/execute/create_margin_order.rs @@ -8,7 +8,6 @@ use MarginOrderType::*; pub fn create_margin_order( info: MessageInfo, deps: DepsMut, - env: Env, position: Option, leverage: Option, trading_asset: Option, @@ -31,7 +30,6 @@ pub fn create_margin_order( create_margin_open_order( info, deps, - env, order_type, position.unwrap(), trading_asset.unwrap(), @@ -40,14 +38,7 @@ pub fn create_margin_order( trigger_price, ) } else { - create_margin_close_order( - info, - deps, - env, - order_type, - position_id.unwrap(), - trigger_price, - ) + create_margin_close_order(info, deps, order_type, position_id.unwrap(), trigger_price) } } @@ -101,7 +92,7 @@ fn check_order_type( fn create_margin_open_order( info: MessageInfo, deps: DepsMut, - env: Env, + order_type: MarginOrderType, position: MarginPosition, trading_asset: String, @@ -120,7 +111,20 @@ fn create_margin_open_order( return Err(StdError::generic_err("margin position cannot be set at: Unspecified").into()); } - //TODO: include query to test if the collateral is valid + let querrier = ElysQuerier::new(&deps.querier); + + let open_estimation = querrier.margin_open_estimation( + position.clone(), + leverage.clone(), + &trading_asset, + collateral.clone(), + take_profit_price.clone(), + Decimal::zero(), + )?; + + if !open_estimation.valid_collateral { + return Err(StdError::generic_err("not valid collateral").into()); + } let order = MarginOrder::new_open( &info.sender, @@ -175,7 +179,7 @@ fn create_margin_open_order( fn create_margin_close_order( info: MessageInfo, deps: DepsMut, - env: Env, + order_type: MarginOrderType, position_id: u64, trigger_price: Option, @@ -231,14 +235,18 @@ fn create_margin_close_order( return Ok(resp); } - let msg = ElysMsg::margin_close_position(&info.sender, position_id, 0 /*AMOUNT */); + let msg = ElysMsg::margin_close_position( + &info.sender, + position_id, + mtp.custodies[0].amount.u128() as i128, + ); let reply_id = MAX_REPLY_ID.load(deps.storage)? + 1; MAX_REPLY_ID.save(deps.storage, &reply_id)?; let reply_info = ReplyInfo { id: reply_id, - reply_type: ReplyType::MarginBrokerMarketOpen, + reply_type: ReplyType::MarginBrokerMarketClose, data: Some(to_json_binary(&order_id)?), }; diff --git a/src/action/execute/eden_cancel_vest_request.rs b/src/action/execute/eden_cancel_vest_request.rs index 273033b..ec8cc1a 100644 --- a/src/action/execute/eden_cancel_vest_request.rs +++ b/src/action/execute/eden_cancel_vest_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Int128; pub fn eden_cancel_vest_request( - env: Env, info: MessageInfo, _deps: DepsMut, amount: u64, diff --git a/src/action/execute/eden_vest_request.rs b/src/action/execute/eden_vest_request.rs index 43aab79..121dd75 100644 --- a/src/action/execute/eden_vest_request.rs +++ b/src/action/execute/eden_vest_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Int128; pub fn eden_vest_request( - env: Env, info: MessageInfo, _deps: DepsMut, amount: u64, diff --git a/src/action/execute/elys_cancel_unstake_request.rs b/src/action/execute/elys_cancel_unstake_request.rs index f43618c..c42962c 100644 --- a/src/action/execute/elys_cancel_unstake_request.rs +++ b/src/action/execute/elys_cancel_unstake_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Coin; pub fn elys_cancel_unstake_request( - env: Env, info: MessageInfo, _deps: DepsMut, validator_address: String, diff --git a/src/action/execute/elys_redelegation_request.rs b/src/action/execute/elys_redelegation_request.rs index 958395c..49b501b 100644 --- a/src/action/execute/elys_redelegation_request.rs +++ b/src/action/execute/elys_redelegation_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Coin; pub fn elys_redelegation_request( - env: Env, info: MessageInfo, _deps: DepsMut, // the amount to be staked in base denomination. diff --git a/src/action/execute/stake_request.rs b/src/action/execute/stake_request.rs index a5433c2..1fdf30e 100644 --- a/src/action/execute/stake_request.rs +++ b/src/action/execute/stake_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Int128; pub fn stake_request( - env: Env, info: MessageInfo, deps: DepsMut, // the amount to be staked in base denomination. diff --git a/src/action/execute/unstake_request.rs b/src/action/execute/unstake_request.rs index 2d0f857..de03b63 100644 --- a/src/action/execute/unstake_request.rs +++ b/src/action/execute/unstake_request.rs @@ -2,7 +2,6 @@ use super::*; use cosmwasm_std::Int128; pub fn unstake_request( - env: Env, info: MessageInfo, _deps: DepsMut, // the amount to be staked in base denomination. diff --git a/src/action/query/get_margin_orders.rs b/src/action/query/get_margin_orders.rs index 15d5187..be7fcb8 100644 --- a/src/action/query/get_margin_orders.rs +++ b/src/action/query/get_margin_orders.rs @@ -5,6 +5,7 @@ pub fn get_margin_orders( pagination: PageRequest, order_owner: Option, order_type: Option, + order_status: Option, ) -> Result { let orders: Vec = MARGIN_ORDER .prefix_range(deps.storage, None, None, Order::Ascending) @@ -20,24 +21,21 @@ pub fn get_margin_orders( }); }; - let orders = match (order_owner, order_type) { - (None, Some(order_type)) => orders - .iter() - .filter(|order| order.order_type == order_type) - .cloned() - .collect(), - (Some(owner), None) => orders - .iter() - .filter(|order| order.owner == owner) - .cloned() - .collect(), - (Some(owner), Some(order_type)) => orders - .iter() - .filter(|order| order.owner == owner && order.order_type == order_type) - .cloned() - .collect(), - (None, None) => orders, - }; + let orders: Vec = orders + .iter() + .filter(|order| { + order_owner + .as_ref() + .map_or(true, |owner| owner == &order.owner) + && order_type + .as_ref() + .map_or(true, |order_type| order_type == &order.order_type) + && order_status + .as_ref() + .map_or(true, |status| &order.status == status) + }) + .cloned() + .collect(); let page_response = match page_response.total { Some(_) => PageResponse { diff --git a/src/action/query/get_spot_orders.rs b/src/action/query/get_spot_orders.rs index d6ebbc3..a206e08 100644 --- a/src/action/query/get_spot_orders.rs +++ b/src/action/query/get_spot_orders.rs @@ -5,6 +5,7 @@ pub fn get_spot_orders( pagination: PageRequest, order_owner: Option, order_type: Option, + order_status: Option, ) -> Result { let orders: Vec = SPOT_ORDER .prefix_range(deps.storage, None, None, Order::Ascending) @@ -20,24 +21,21 @@ pub fn get_spot_orders( }); }; - let orders = match (order_owner, order_type) { - (None, Some(order_type)) => orders - .iter() - .filter(|order| order.order_type == order_type) - .cloned() - .collect(), - (Some(owner), None) => orders - .iter() - .filter(|order| order.owner_address == owner) - .cloned() - .collect(), - (Some(owner), Some(order_type)) => orders - .iter() - .filter(|order| order.owner_address == owner && order.order_type == order_type) - .cloned() - .collect(), - (None, None) => orders, - }; + let orders: Vec = orders + .iter() + .filter(|order| { + order_owner + .as_ref() + .map_or(true, |owner| owner == order.owner_address.as_str()) + && order_type + .as_ref() + .map_or(true, |order_type| order_type == &order.order_type) + && order_status + .as_ref() + .map_or(true, |status| &order.status == status) + }) + .cloned() + .collect(); let page_response = match page_response.total { Some(_) => PageResponse { diff --git a/src/action/reply/close_margin_position.rs b/src/action/reply/close_margin_position.rs index c4fc896..a1e1313 100644 --- a/src/action/reply/close_margin_position.rs +++ b/src/action/reply/close_margin_position.rs @@ -16,13 +16,13 @@ pub fn reply_to_close_margin_order( let res: MarginCloseResponse = match get_response_from_reply(module_resp) { Ok(expr) => expr, Err(err) => { - order.status = Status::NotProcessed; + order.status = Status::Pending; MARGIN_ORDER.save(deps.storage, order_id, &order)?; return Ok(err); } }; - order.status = Status::Processed; + order.status = Status::Executed; MARGIN_ORDER.save(deps.storage, order_id, &order)?; diff --git a/src/action/reply/create_margin_order_market_close.rs b/src/action/reply/create_margin_order_market_close.rs index d98f4c4..6530205 100644 --- a/src/action/reply/create_margin_order_market_close.rs +++ b/src/action/reply/create_margin_order_market_close.rs @@ -30,7 +30,7 @@ pub fn reply_to_create_margin_market_close( Err(err) => return Err(err.into()), }; - order.status = Status::Processed; + order.status = Status::Executed; let resp = Response::new().add_event( Event::new("reply_to_create_margin_market_close") diff --git a/src/action/reply/create_margin_order_market_open.rs b/src/action/reply/create_margin_order_market_open.rs index 5ba30bd..1fccdc8 100644 --- a/src/action/reply/create_margin_order_market_open.rs +++ b/src/action/reply/create_margin_order_market_open.rs @@ -30,7 +30,7 @@ pub fn reply_to_create_margin_market_open( Err(err) => return Err(err.into()), }; - order.status = Status::Processed; + order.status = Status::Executed; order.position_id = Some(margin_resp.id); MARGIN_ORDER.save(deps.storage, order_id, &order)?; diff --git a/src/action/reply/open_margin_position.rs b/src/action/reply/open_margin_position.rs index 76d329e..77bca57 100644 --- a/src/action/reply/open_margin_position.rs +++ b/src/action/reply/open_margin_position.rs @@ -16,13 +16,13 @@ pub fn reply_to_open_margin_position( let res: MarginOpenResponse = match get_response_from_reply(module_resp) { Ok(expr) => expr, Err(err) => { - order.status = Status::NotProcessed; + order.status = Status::Pending; MARGIN_ORDER.save(deps.storage, order_id, &order)?; return Ok(err); } }; - order.status = Status::Processed; + order.status = Status::Executed; MARGIN_ORDER.save(deps.storage, order_id, &order)?; diff --git a/src/action/reply/spot_order.rs b/src/action/reply/spot_order.rs index 76ce1d8..d62c699 100644 --- a/src/action/reply/spot_order.rs +++ b/src/action/reply/spot_order.rs @@ -20,7 +20,7 @@ pub fn reply_to_spot_order( } }; - order.status = Status::Processed; + order.status = Status::Executed; SPOT_ORDER.save(deps.storage, order_id, &order)?; diff --git a/src/action/reply/spot_order_market.rs b/src/action/reply/spot_order_market.rs index 88499ee..ce1442b 100644 --- a/src/action/reply/spot_order_market.rs +++ b/src/action/reply/spot_order_market.rs @@ -18,7 +18,7 @@ pub fn reply_to_spot_order_market( let mut order = SPOT_ORDER.load(deps.storage, order_id)?; - order.status = Status::Processed; + order.status = Status::Executed; SPOT_ORDER.save(deps.storage, order_id, &order)?; diff --git a/src/action/sudo/process_orders.rs b/src/action/sudo/process_orders.rs index 20cb821..b7543d0 100644 --- a/src/action/sudo/process_orders.rs +++ b/src/action/sudo/process_orders.rs @@ -52,7 +52,13 @@ pub fn process_orders( )?; if check_margin_order(&margin_order, amm_swap_estimation) { - process_margin_order(margin_order, &mut submsgs, &mut reply_info_id, deps.storage)?; + process_margin_order( + margin_order, + &mut submsgs, + &mut reply_info_id, + deps.storage, + &querier, + )?; } } @@ -68,6 +74,7 @@ fn process_margin_order( submsgs: &mut Vec>, reply_info_id: &mut u64, storage: &mut dyn Storage, + querier: &ElysQuerier<'_>, ) -> StdResult<()> { let (msg, reply_type) = if order.order_type == MarginOrderType::LimitOpen { ( @@ -82,12 +89,10 @@ fn process_margin_order( ReplyType::MarginBrokerOpen, ) } else { + let mtp = querier.mtp(order.owner.clone(), order.position_id.unwrap())?; + let amount = mtp.mtp.unwrap().custodies[0].amount.u128() as i128; ( - ElysMsg::margin_close_position( - &order.owner, - order.position_id.unwrap(), - 0, //AMOUNT - ), + ElysMsg::margin_close_position(&order.owner, order.position_id.unwrap(), amount), ReplyType::MarginBrokerClose, ) }; @@ -97,7 +102,7 @@ fn process_margin_order( reply_type, data: Some(to_json_binary(&order.order_id)?), }; - submsgs.push(SubMsg::reply_on_success(msg, *reply_info_id)); + submsgs.push(SubMsg::reply_always(msg, *reply_info_id)); REPLY_INFO.save(storage, *reply_info_id, &reply_info)?; @@ -111,7 +116,7 @@ fn check_margin_order( ) -> bool { if order.order_type == MarginOrderType::MarketClose || order.order_type == MarginOrderType::MarketOpen - || order.status != Status::NotProcessed + || order.status != Status::Pending { return false; } @@ -156,7 +161,7 @@ fn check_spot_order( if order.order_type == SpotOrderType::MarketBuy { return false; } - if order.status != Status::NotProcessed { + if order.status != Status::Pending { return false; } @@ -207,7 +212,7 @@ fn process_spot_order( data: Some(to_json_binary(&order.order_id)?), }; - submsgs.push(SubMsg::reply_on_success(msg, *reply_info_id)); + submsgs.push(SubMsg::reply_always(msg, *reply_info_id)); REPLY_INFO.save(storage, *reply_info_id, &reply_info)?; diff --git a/src/entry_point/execute.rs b/src/entry_point/execute.rs index 7c03c1e..6d2c488 100644 --- a/src/entry_point/execute.rs +++ b/src/entry_point/execute.rs @@ -44,7 +44,6 @@ pub fn execute( } => create_margin_order( info, deps, - env, position, leverage, trading_asset, @@ -59,24 +58,23 @@ pub fn execute( owner_address, order_type, } => cancel_margin_orders(info, deps, order_ids, owner_address, order_type), - CloseMarginPosition { id, amount } => close_margin_position(info, env, id, amount), + CloseMarginPosition { id, amount } => close_margin_position(info, id, amount), StakeRequest { amount, asset, validator_address, - } => stake_request(env, info, deps, amount, asset, validator_address), + } => stake_request(info, deps, amount, asset, validator_address), UnstakeRequest { amount, asset, validator_address, - } => unstake_request(env, info, deps, amount, asset, validator_address), + } => unstake_request(info, deps, amount, asset, validator_address), ElysRedelegateRequest { validator_src_address, validator_dst_address, amount, } => elys_redelegation_request( - env, info, deps, validator_src_address, @@ -87,16 +85,12 @@ pub fn execute( validator_address, amount, creation_height, - } => { - elys_cancel_unstake_request(env, info, deps, validator_address, amount, creation_height) - } - EdenVestRequest { amount } => eden_vest_request(env, info, deps, amount), - EdenCancelVestRequest { amount } => eden_cancel_vest_request(env, info, deps, amount), - ClaimRewardsRequest { withdraw_type } => { - claim_rewards_request(env, info, deps, withdraw_type) - } + } => elys_cancel_unstake_request(info, deps, validator_address, amount, creation_height), + EdenVestRequest { amount } => eden_vest_request(info, deps, amount), + EdenCancelVestRequest { amount } => eden_cancel_vest_request(info, deps, amount), + ClaimRewardsRequest { withdraw_type } => claim_rewards_request(info, deps, withdraw_type), ClaimValidatorCommissionRequest { validator_address } => { - claim_validator_commission_request(env, info, deps, validator_address) + claim_validator_commission_request(info, deps, validator_address) } } } diff --git a/src/entry_point/query.rs b/src/entry_point/query.rs index fecec44..dd47084 100644 --- a/src/entry_point/query.rs +++ b/src/entry_point/query.rs @@ -20,21 +20,25 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result Ok(to_json_binary(&query::get_spot_orders( deps, pagination, order_owner, order_type, + order_status, )?)?), GetMarginOrders { pagination, order_owner, order_type, + order_status, } => Ok(to_json_binary(&query::get_margin_orders( deps, pagination, order_owner, order_type, + order_status, )?)?), SwapEstimationByDenom { amount, diff --git a/src/msg/query_msg.rs b/src/msg/query_msg.rs index 1f0e8cd..08ce058 100644 --- a/src/msg/query_msg.rs +++ b/src/msg/query_msg.rs @@ -1,6 +1,6 @@ #[allow(unused_imports)] use super::query_resp::*; -use crate::types::{MarginOrderType, SpotOrderType}; +use crate::types::{MarginOrderType, SpotOrderType, Status}; use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Coin; #[allow(unused_imports)] @@ -23,12 +23,14 @@ pub enum QueryMsg { pagination: PageRequest, order_owner: Option, order_type: Option, + order_status: Option, }, #[returns(GetMarginOrdersResp)] GetMarginOrders { pagination: PageRequest, order_owner: Option, order_type: Option, + order_status: Option, }, #[returns(AmmSwapEstimationByDenomResponse)] SwapEstimationByDenom { diff --git a/src/tests/cancel_spot_order/process_spot_order_processing.rs b/src/tests/cancel_spot_order/process_spot_order_processing.rs index 7591f8d..c3a04f5 100644 --- a/src/tests/cancel_spot_order/process_spot_order_processing.rs +++ b/src/tests/cancel_spot_order/process_spot_order_processing.rs @@ -25,7 +25,7 @@ fn process_spot_order_processing() { order_amount: coin(120, "usdc"), // 120 USDC to be used for buying, owner_address: Addr::unchecked("user"), order_target_denom: "ubtc".to_string(), - status: Status::Processed, + status: Status::Executed, date: Date { height: 20, time: Timestamp::from_seconds(644), @@ -98,7 +98,7 @@ fn process_spot_order_processing() { assert_eq!( ContractError::CancelStatusError { order_id: 0, - status: Status::Processed + status: Status::Executed }, err.downcast().unwrap() ); diff --git a/src/tests/cancel_spot_orders/successfully_cancel_orders.rs b/src/tests/cancel_spot_orders/successfully_cancel_orders.rs index 72ae3d9..6a2dd2e 100644 --- a/src/tests/cancel_spot_orders/successfully_cancel_orders.rs +++ b/src/tests/cancel_spot_orders/successfully_cancel_orders.rs @@ -21,7 +21,7 @@ fn successfully_cancel_orders() { order_amount: coin(10, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -38,7 +38,7 @@ fn successfully_cancel_orders() { order_amount: coin(5, "eth"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -55,7 +55,7 @@ fn successfully_cancel_orders() { order_amount: coin(20, "usdt"), owner_address: Addr::unchecked("user1"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -72,7 +72,7 @@ fn successfully_cancel_orders() { order_amount: coin(6, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), diff --git a/src/tests/cancel_spot_orders/successfully_cancel_orders_id.rs b/src/tests/cancel_spot_orders/successfully_cancel_orders_id.rs index 48dbba0..d6dd14a 100644 --- a/src/tests/cancel_spot_orders/successfully_cancel_orders_id.rs +++ b/src/tests/cancel_spot_orders/successfully_cancel_orders_id.rs @@ -21,7 +21,7 @@ fn successfully_cancel_orders_ids() { order_amount: coin(10, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -38,7 +38,7 @@ fn successfully_cancel_orders_ids() { order_amount: coin(5, "eth"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -55,7 +55,7 @@ fn successfully_cancel_orders_ids() { order_amount: coin(20, "usdt"), owner_address: Addr::unchecked("user1"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -72,7 +72,7 @@ fn successfully_cancel_orders_ids() { order_amount: coin(6, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), diff --git a/src/tests/cancel_spot_orders/successfully_cancel_orders_type.rs b/src/tests/cancel_spot_orders/successfully_cancel_orders_type.rs index 925042c..b0db94a 100644 --- a/src/tests/cancel_spot_orders/successfully_cancel_orders_type.rs +++ b/src/tests/cancel_spot_orders/successfully_cancel_orders_type.rs @@ -21,7 +21,7 @@ fn successfully_cancel_orders_type() { order_amount: coin(10, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -38,7 +38,7 @@ fn successfully_cancel_orders_type() { order_amount: coin(5, "eth"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -55,7 +55,7 @@ fn successfully_cancel_orders_type() { order_amount: coin(20, "usdt"), owner_address: Addr::unchecked("user1"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -72,7 +72,7 @@ fn successfully_cancel_orders_type() { order_amount: coin(6, "btc"), owner_address: Addr::unchecked("user"), order_target_denom: "".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), diff --git a/src/tests/close_margin_position/closing_a_margin_position.rs b/src/tests/close_margin_position/closing_a_margin_position.rs index bbde65a..fe9506c 100644 --- a/src/tests/close_margin_position/closing_a_margin_position.rs +++ b/src/tests/close_margin_position/closing_a_margin_position.rs @@ -43,5 +43,5 @@ fn closing_marging_position() { let last_module_used = app .init_modules(|router, _, storage| router.custom.get_last_module(storage).unwrap()) .unwrap(); - assert_eq!(last_module_used, "MarginBrokerClose"); + assert_eq!(last_module_used, "MarginClose"); } diff --git a/src/tests/create_margin_order/successful_create_margin_market_order.rs b/src/tests/create_margin_order/successful_create_margin_market_order.rs index f50766a..4ddd7d5 100644 --- a/src/tests/create_margin_order/successful_create_margin_market_order.rs +++ b/src/tests/create_margin_order/successful_create_margin_market_order.rs @@ -77,5 +77,5 @@ fn successful_create_margin_market_open_order() { .init_modules(|router, _, store| router.custom.get_last_module(store).unwrap()) .unwrap(); - assert_eq!(last_module, "MarginBrokerOpen"); + assert_eq!(last_module, "MarginOpen"); } diff --git a/src/tests/create_margin_order/successful_create_nargin_market_close.rs b/src/tests/create_margin_order/successful_create_nargin_market_close.rs index 1268590..8e9bacd 100644 --- a/src/tests/create_margin_order/successful_create_nargin_market_close.rs +++ b/src/tests/create_margin_order/successful_create_nargin_market_close.rs @@ -81,5 +81,5 @@ fn successful_create_margin_market_open_order() { .init_modules(|router, _, store| router.custom.get_last_module(store).unwrap()) .unwrap(); - assert_eq!(last_module, "MarginBrokerClose"); + assert_eq!(last_module, "MarginClose"); } diff --git a/src/tests/create_spot_order/coin_number.rs b/src/tests/create_spot_order/coin_number.rs index cd0c4b9..53e1bcd 100644 --- a/src/tests/create_spot_order/coin_number.rs +++ b/src/tests/create_spot_order/coin_number.rs @@ -1,4 +1,5 @@ use cosmwasm_std::Uint128; +use cw_utils::PaymentError; use super::*; // This test case verifies that attempting to create an order without specifying the amount results in a "CoinNumber" error. @@ -49,5 +50,8 @@ fn coin_number() { .unwrap_err(); // Verify that the error is of type "CoinNumber." - assert_eq!(ContractError::CoinNumber, err.downcast().unwrap()); + assert_eq!( + ContractError::Payment(PaymentError::NoFunds {}), + err.downcast().unwrap() + ); } diff --git a/src/tests/create_spot_order/successful_create_market_order.rs b/src/tests/create_spot_order/successful_create_market_order.rs index 1037254..5dffa9d 100644 --- a/src/tests/create_spot_order/successful_create_market_order.rs +++ b/src/tests/create_spot_order/successful_create_market_order.rs @@ -90,9 +90,10 @@ fn successful_create_market_buy_order() { pagination: PageRequest::new(5), order_owner: None, order_type: None, + order_status: None, }, ) .unwrap(); - assert_eq!(res.orders[0].status, Status::Processed); + assert_eq!(res.orders[0].status, Status::Executed); } diff --git a/src/tests/get_spot_orders/get_spot_orders.rs b/src/tests/get_spot_orders/get_spot_orders.rs index 67d3685..8329942 100644 --- a/src/tests/get_spot_orders/get_spot_orders.rs +++ b/src/tests/get_spot_orders/get_spot_orders.rs @@ -38,6 +38,7 @@ fn get_spot_orders() { pagination: page_req.clone(), order_owner: None, order_type: None, + order_status: None, }, ) .unwrap(); @@ -56,6 +57,7 @@ fn get_spot_orders() { pagination: page_req.clone(), order_owner: None, order_type: None, + order_status: None, }, ) .unwrap(); @@ -74,6 +76,7 @@ fn get_spot_orders() { pagination: page_req.clone(), order_owner: None, order_type: None, + order_status: None, }, ) .unwrap(); @@ -94,7 +97,7 @@ fn create_orders() -> Vec { order_amount: coin(255, "btc"), owner_address: Addr::unchecked("userA"), order_target_denom: "btc".to_owned(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(600), @@ -111,7 +114,7 @@ fn create_orders() -> Vec { order_amount: coin(100, "eth"), owner_address: Addr::unchecked("userB"), order_target_denom: "eth".to_owned(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(600), @@ -128,7 +131,7 @@ fn create_orders() -> Vec { order_amount: coin(500, "xrp"), owner_address: Addr::unchecked("userC"), order_target_denom: "xrp".to_owned(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(600), @@ -145,7 +148,7 @@ fn create_orders() -> Vec { order_amount: coin(75, "ltc"), owner_address: Addr::unchecked("userD"), order_target_denom: "ltc".to_owned(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(600), @@ -162,7 +165,7 @@ fn create_orders() -> Vec { order_amount: coin(200, "ada"), owner_address: Addr::unchecked("userE"), order_target_denom: "ada".to_owned(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(600), diff --git a/src/tests/process_margin_order/process_limit_open.rs b/src/tests/process_margin_order/process_limit_open.rs index 362e915..939d020 100644 --- a/src/tests/process_margin_order/process_limit_open.rs +++ b/src/tests/process_margin_order/process_limit_open.rs @@ -118,5 +118,5 @@ fn successful_process_limit_buy_order() { .init_modules(|router, _, store| router.custom.get_last_module(store).unwrap()) .unwrap(); - assert_eq!(last_module, "MarginBrokerOpen"); + assert_eq!(last_module, "MarginOpen"); } diff --git a/src/tests/process_margin_order/process_order_close.rs b/src/tests/process_margin_order/process_order_close.rs index dbf2cc0..67e036a 100644 --- a/src/tests/process_margin_order/process_order_close.rs +++ b/src/tests/process_margin_order/process_order_close.rs @@ -1,5 +1,5 @@ use super::*; -use cosmwasm_std::Coin; +use cosmwasm_std::{Coin, Int128}; #[test] fn successful_process_limit_buy_order() { @@ -69,6 +69,36 @@ fn successful_process_limit_buy_order() { // Execute the order processing. app.wasm_sudo(addr.clone(), &sudo_msg).unwrap(); + app.init_modules(|router, _, storage| { + router.custom.set_mtp( + storage, + &vec![Mtp { + address: "user".to_string(), + collaterals: vec![coin(2, "btc")], + liabilities: Int128::zero(), + interest_paid_collaterals: vec![], + interest_paid_custodies: vec![], + interest_unpaid_collaterals: vec![], + custodies: vec![coin(5000, "usdc")], + take_profit_liabilities: Int128::zero(), + take_profit_custodies: vec![], + leverages: vec![Decimal::from_str("1.2").unwrap()], + mtp_health: Decimal::one(), + position: 2, + id: 1, + amm_pool_id: 1, + consolidate_leverage: Decimal::zero(), + sum_collateral: Int128::zero(), + take_profit_price: Decimal::from_str("1.2").unwrap(), + funding_fee_paid_collaterals: vec![], + funding_fee_paid_custodies: vec![], + funding_fee_received_collaterals: vec![], + funding_fee_received_custodies: vec![], + }], + ) + }) + .unwrap(); + let last_module = app.init_modules(|router, _, store| router.custom.get_last_module(store).unwrap()); @@ -85,5 +115,5 @@ fn successful_process_limit_buy_order() { .init_modules(|router, _, store| router.custom.get_last_module(store).unwrap()) .unwrap(); - assert_eq!(last_module, "MarginBrokerClose"); + assert_eq!(last_module, "MarginClose"); } diff --git a/src/tests/process_spot_order/successful_process_5_of_10_orders.rs b/src/tests/process_spot_order/successful_process_5_of_10_orders.rs index dfa71b4..f20861e 100644 --- a/src/tests/process_spot_order/successful_process_5_of_10_orders.rs +++ b/src/tests/process_spot_order/successful_process_5_of_10_orders.rs @@ -240,7 +240,7 @@ fn create_dummy_orders() -> Vec { quote_denom: "usdc".to_string(), rate: Decimal::from_atomics(Uint128::new(1700), 0).unwrap(), }, - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -257,7 +257,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(12000), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -274,7 +274,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(10000), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -291,7 +291,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(1800), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -308,7 +308,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(1200), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -325,7 +325,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(2500), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -342,7 +342,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(21000), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -359,7 +359,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(25000), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -376,7 +376,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(30000), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), @@ -393,7 +393,7 @@ fn create_dummy_orders() -> Vec { rate: Decimal::from_atomics(Uint128::new(2100), 0).unwrap(), }, order_target_denom: "usdc".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 20, time: Timestamp::from_seconds(500), diff --git a/src/types/margin_order.rs b/src/types/margin_order.rs index b9811ec..e4634eb 100644 --- a/src/types/margin_order.rs +++ b/src/types/margin_order.rs @@ -36,7 +36,7 @@ impl MarginOrder { None => 0, }; - let status = Status::NotProcessed; + let status = Status::Pending; Self { order_id, @@ -69,7 +69,7 @@ impl MarginOrder { None => 0, }; - let status = Status::NotProcessed; + let status = Status::Pending; let position = MarginPosition::try_from_i32(position)?; diff --git a/src/types/spot_order/impls/new.rs b/src/types/spot_order/impls/new.rs index 9e43aee..9e51c1d 100644 --- a/src/types/spot_order/impls/new.rs +++ b/src/types/spot_order/impls/new.rs @@ -25,7 +25,7 @@ impl SpotOrder { }, }; - let status = Status::NotProcessed; + let status = Status::Pending; SpotOrder { order_type, diff --git a/src/types/spot_order/impls/new_dummy.rs b/src/types/spot_order/impls/new_dummy.rs index 5dcd158..5677c29 100644 --- a/src/types/spot_order/impls/new_dummy.rs +++ b/src/types/spot_order/impls/new_dummy.rs @@ -14,7 +14,7 @@ impl SpotOrder { rate: Decimal::from_atomics(Uint128::new(5), 0).unwrap(), }, order_target_denom: "eth".to_string(), - status: Status::NotProcessed, + status: Status::Pending, date: Date { height: 12, time: Timestamp::from_nanos(500000), diff --git a/src/types/status.rs b/src/types/status.rs index 0b2f375..19e16f8 100644 --- a/src/types/status.rs +++ b/src/types/status.rs @@ -2,7 +2,7 @@ use cosmwasm_schema::cw_serde; #[cw_serde] pub enum Status { - NotProcessed, - Processed, + Pending, + Executed, Canceled, }