diff --git a/Cargo.lock b/Cargo.lock index 477e4ff..c8be083 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#8ef5964a964f592feab90389ef6d73bc270113b3" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/add_simulateXXQueries#f3aa326af43f8631bae51545e3b205a577522c44" dependencies = [ "bech32 0.9.1", "chrono", @@ -1167,7 +1167,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#8ef5964a964f592feab90389ef6d73bc270113b3" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/add_simulateXXQueries#f3aa326af43f8631bae51545e3b205a577522c44" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index dc9f388..c8a5989 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/add_simulateXXQueries" } prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/dex/schema/dex_msg.json b/contracts/dex/schema/dex_msg.json index b8c612f..9d0c7b2 100644 --- a/contracts/dex/schema/dex_msg.json +++ b/contracts/dex/schema/dex_msg.json @@ -49,7 +49,7 @@ "description": "Additional deposit options", "type": "array", "items": { - "$ref": "#/definitions/DepositOption" + "$ref": "#/definitions/DepositOptions" } }, "receiver": { @@ -322,14 +322,20 @@ } ], "definitions": { - "DepositOption": { + "DepositOptions": { "type": "object", - "required": [ - "disable_swap" - ], "properties": { - "disable_swap": { - "type": "boolean" + "disable_autoswap": { + "type": [ + "boolean", + "null" + ] + }, + "fail_tx_on_bel": { + "type": [ + "boolean", + "null" + ] } }, "additionalProperties": false diff --git a/contracts/dex_grpc/schema/query_msg.json b/contracts/dex_grpc/schema/query_msg.json index 425765a..3bc7e5e 100644 --- a/contracts/dex_grpc/schema/query_msg.json +++ b/contracts/dex_grpc/schema/query_msg.json @@ -576,9 +576,388 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_deposit" + ], + "properties": { + "simulate_deposit": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgDeposit" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_withdrawal" + ], + "properties": { + "simulate_withdrawal": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgWithdrawal" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_place_limit_order" + ], + "properties": { + "simulate_place_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgPlaceLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_withdraw_filled_limit_order" + ], + "properties": { + "simulate_withdraw_filled_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgWithdrawFilledLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_cancel_limit_order" + ], + "properties": { + "simulate_cancel_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgCancelLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_multi_hop_swap" + ], + "properties": { + "simulate_multi_hop_swap": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgMultiHopSwap" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ], "definitions": { + "DepositOptions": { + "type": "object", + "required": [ + "disable_autoswap", + "fail_tx_on_bel" + ], + "properties": { + "disable_autoswap": { + "type": "boolean" + }, + "fail_tx_on_bel": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "MsgCancelLimitOrder": { + "type": "object", + "required": [ + "creator", + "tranche_key" + ], + "properties": { + "creator": { + "type": "string" + }, + "tranche_key": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgDeposit": { + "type": "object", + "required": [ + "amounts_a", + "amounts_b", + "creator", + "fees", + "options", + "receiver", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "amounts_a": { + "type": "array", + "items": { + "type": "string" + } + }, + "amounts_b": { + "type": "array", + "items": { + "type": "string" + } + }, + "creator": { + "type": "string" + }, + "fees": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "options": { + "type": "array", + "items": { + "$ref": "#/definitions/DepositOptions" + } + }, + "receiver": { + "type": "string" + }, + "tick_indexes_a_to_b": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "type": "string" + }, + "token_b": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgMultiHopSwap": { + "type": "object", + "required": [ + "amount_in", + "creator", + "exit_limit_price", + "pick_best_route", + "receiver", + "routes" + ], + "properties": { + "amount_in": { + "type": "string" + }, + "creator": { + "type": "string" + }, + "exit_limit_price": { + "type": "string" + }, + "pick_best_route": { + "description": "If pickBestRoute == true then all routes are run and the route with the best price is chosen otherwise, the first succesful route is used.", + "type": "boolean" + }, + "receiver": { + "type": "string" + }, + "routes": { + "type": "array", + "items": { + "$ref": "#/definitions/MultiHopRoute" + } + } + }, + "additionalProperties": false + }, + "MsgPlaceLimitOrder": { + "type": "object", + "required": [ + "amount_in", + "creator", + "limit_sell_price", + "max_amount_out", + "order_type", + "receiver", + "tick_index_in_to_out", + "token_in", + "token_out" + ], + "properties": { + "amount_in": { + "type": "string" + }, + "creator": { + "type": "string" + }, + "expiration_time": { + "description": "expirationTime is only valid iff orderType == GOOD_TIL_TIME.", + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + }, + "limit_sell_price": { + "type": "string" + }, + "max_amount_out": { + "type": "string" + }, + "order_type": { + "type": "integer", + "format": "int32" + }, + "receiver": { + "type": "string" + }, + "tick_index_in_to_out": { + "description": "DEPRECATED: tick_index_in_to_out will be removed in future release; limit_sell_price should be used instead.", + "deprecated": true, + "type": "integer", + "format": "int64" + }, + "token_in": { + "type": "string" + }, + "token_out": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgWithdrawFilledLimitOrder": { + "type": "object", + "required": [ + "creator", + "tranche_key" + ], + "properties": { + "creator": { + "type": "string" + }, + "tranche_key": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgWithdrawal": { + "type": "object", + "required": [ + "creator", + "fees", + "receiver", + "shares_to_remove", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "creator": { + "type": "string" + }, + "fees": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "receiver": { + "type": "string" + }, + "shares_to_remove": { + "type": "array", + "items": { + "type": "string" + } + }, + "tick_indexes_a_to_b": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "type": "string" + }, + "token_b": { + "type": "string" + } + }, + "additionalProperties": false + }, "MultiHopRoute": { "type": "object", "required": [ diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 42b444f..57998ee 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -235,6 +235,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &dex_querier.pool_reserves(pair_id, token_in, tick_index, fee)?, )?), + #[allow(deprecated)] // Allow deprecated call until its remove from neutron-core QueryMsg::EstimateMultiHopSwap { creator, receiver, @@ -251,6 +252,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { pick_best_route, )?)?), + #[allow(deprecated)] // Allow deprecated call until its remove from neutron-core QueryMsg::EstimatePlaceLimitOrder { creator, receiver, @@ -288,6 +290,30 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::AllPoolMetadata { pagination } => { Ok(to_json_binary(&dex_querier.pool_metadata_all(pagination)?)?) } + + QueryMsg::SimulateDeposit { msg } => { + Ok(to_json_binary(&dex_querier.simulate_deposit(Some(msg))?)?) + } + + QueryMsg::SimulateWithdrawal { msg } => Ok(to_json_binary( + &dex_querier.simulate_withdrawal(Some(msg))?, + )?), + + QueryMsg::SimulatePlaceLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_place_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateWithdrawFilledLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_withdraw_filled_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateCancelLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_cancel_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateMultiHopSwap { msg } => Ok(to_json_binary( + &dex_querier.simulate_multi_hop_swap(Some(msg))?, + )?), } } diff --git a/contracts/dex_grpc/src/msg.rs b/contracts/dex_grpc/src/msg.rs index 1b8abc8..d536d4f 100644 --- a/contracts/dex_grpc/src/msg.rs +++ b/contracts/dex_grpc/src/msg.rs @@ -1,4 +1,7 @@ -use neutron_sdk::proto_types::neutron::dex::{DepositOptions, MultiHopRoute}; +use neutron_sdk::proto_types::neutron::dex::{ + DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute, +}; use neutron_sdk::proto_types::{cosmos::base::query::v1beta1::PageRequest, neutron::dex}; use neutron_sdk::shim::Timestamp; use schemars::JsonSchema; @@ -144,6 +147,24 @@ pub enum QueryMsg { AllPoolMetadata { pagination: Option, }, + SimulateDeposit { + msg: MsgDeposit, + }, + SimulateWithdrawal { + msg: MsgWithdrawal, + }, + SimulatePlaceLimitOrder { + msg: MsgPlaceLimitOrder, + }, + SimulateWithdrawFilledLimitOrder { + msg: MsgWithdrawFilledLimitOrder, + }, + SimulateCancelLimitOrder { + msg: MsgCancelLimitOrder, + }, + SimulateMultiHopSwap { + msg: MsgMultiHopSwap, + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index b07557b..69c7dd8 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -546,14 +546,20 @@ }, "additionalProperties": false }, - "DepositOption": { + "DepositOptions": { "type": "object", - "required": [ - "disable_swap" - ], "properties": { - "disable_swap": { - "type": "boolean" + "disable_autoswap": { + "type": [ + "boolean", + "null" + ] + }, + "fail_tx_on_bel": { + "type": [ + "boolean", + "null" + ] } }, "additionalProperties": false @@ -607,7 +613,7 @@ "description": "Additional deposit options", "type": "array", "items": { - "$ref": "#/definitions/DepositOption" + "$ref": "#/definitions/DepositOptions" } }, "receiver": {