From fdf32dcf1541e62170919e724ce4a8d5d7e10ca7 Mon Sep 17 00:00:00 2001 From: Albert Andrejev Date: Mon, 8 Apr 2024 11:00:59 +0300 Subject: [PATCH] fixes after rebase --- Cargo.lock | 93 ++-- contracts/dex/schema/dex_msg.json | 126 ++++-- contracts/dex/schema/dex_query.json | 169 ++++---- contracts/dex_stargate/schema/query_msg.json | 6 +- .../src/contract.rs | 10 +- .../src/testing/tests.rs | 29 +- contracts/reflect/schema/execute_msg.json | 399 ++++++++++++++++++ 7 files changed, 647 insertions(+), 185 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c650e5c..a9bd753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,9 +21,9 @@ checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "base16ct" @@ -92,9 +92,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -107,9 +107,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "num-traits", ] @@ -150,8 +150,8 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32560304ab4c365791fd307282f76637213d8083c1a98490c35159cd67852237" dependencies = [ - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "tendermint-proto 0.34.1", ] @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -345,8 +345,8 @@ dependencies = [ "cosmwasm-std", "cw2", "neutron-sdk", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "schemars", "serde", ] @@ -480,9 +480,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "libc", @@ -555,18 +555,18 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" @@ -614,19 +614,20 @@ dependencies = [ [[package]] name = "neutron-sdk" -version = "0.8.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/proposal-votes#1cbef1ae0dde2a4a96ad01c94b9bc878d94976f3" +version = "0.10.0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/proposal-votes#2dfca1734dfc4cfba478b3067417648733d66cd9" dependencies = [ "bech32", "cosmos-sdk-proto 0.20.0", "cosmwasm-schema", "cosmwasm-std", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "protobuf", "schemars", "serde", "serde-json-wasm 1.0.1", + "serde_json", "speedate", "tendermint-proto 0.34.1", "thiserror", @@ -643,7 +644,7 @@ dependencies = [ "cw-storage-plus", "cw2", "neutron-sdk", - "prost 0.12.3", + "prost 0.12.4", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -659,8 +660,8 @@ dependencies = [ "cw-storage-plus", "cw2", "neutron-sdk", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -791,12 +792,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive 0.12.3", + "prost-derive 0.12.4", ] [[package]] @@ -814,15 +815,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -836,11 +837,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ - "prost 0.12.3", + "prost 0.12.4", ] [[package]] @@ -911,9 +912,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -1018,7 +1019,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1034,9 +1035,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -1138,7 +1139,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1169,9 +1170,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1206,8 +1207,8 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "serde", "serde_bytes", "subtle-encoding", @@ -1231,7 +1232,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] diff --git a/contracts/dex/schema/dex_msg.json b/contracts/dex/schema/dex_msg.json index ac32f68..c731954 100644 --- a/contracts/dex/schema/dex_msg.json +++ b/contracts/dex/schema/dex_msg.json @@ -3,6 +3,7 @@ "title": "DexMsg", "oneOf": [ { + "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", "type": "object", "required": [ "deposit" @@ -22,18 +23,21 @@ ], "properties": { "amounts_a": { + "description": "Amounts of tokenA to deposit", "type": "array", "items": { "$ref": "#/definitions/Uint128" } }, "amounts_b": { + "description": "Amounts of tokenB to deposit", "type": "array", "items": { "$ref": "#/definitions/Uint128" } }, "fees": { + "description": "Fees to use for each deposit", "type": "array", "items": { "type": "integer", @@ -42,22 +46,18 @@ } }, "options": { + "description": "Additional deposit options", "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/definitions/DepositOption" - }, - { - "type": "null" - } - ] + "$ref": "#/definitions/DepositOption" } }, "receiver": { + "description": "The account to which PoolShares will be issued", "type": "string" }, "tick_indexes_a_to_b": { + "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", "type": "array", "items": { "type": "integer", @@ -65,9 +65,11 @@ } }, "token_a": { + "description": "Denom for one side of the deposit", "type": "string" }, "token_b": { + "description": "Denom for the opposing side of the deposit", "type": "string" } } @@ -76,6 +78,7 @@ "additionalProperties": false }, { + "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", "type": "object", "required": [ "withdrawal" @@ -93,6 +96,7 @@ ], "properties": { "fees": { + "description": "Fee for the target LiquidityPools", "type": "array", "items": { "type": "integer", @@ -101,15 +105,18 @@ } }, "receiver": { + "description": "The account to which the tokens are credited", "type": "string" }, "shares_to_remove": { + "description": "Amount of shares to remove from each pool", "type": "array", "items": { "$ref": "#/definitions/Uint128" } }, "tick_indexes_a_to_b": { + "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", "type": "array", "items": { "type": "integer", @@ -117,9 +124,11 @@ } }, "token_a": { + "description": "Denom for one side of the deposit", "type": "string" }, "token_b": { + "description": "Denom for the opposing side of the deposit", "type": "string" } } @@ -128,6 +137,7 @@ "additionalProperties": false }, { + "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", "type": "object", "required": [ "place_limit_order" @@ -141,13 +151,19 @@ "receiver", "tick_index_in_to_out", "token_in", - "tonek_out" + "token_out" ], "properties": { "amount_in": { - "$ref": "#/definitions/Uint128" + "description": "Amount of TokenIn to be traded", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] }, "expiration_time": { + "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", "type": [ "integer", "null" @@ -156,6 +172,7 @@ "minimum": 0.0 }, "max_amount_out": { + "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", "anyOf": [ { "$ref": "#/definitions/Uint128" @@ -166,19 +183,28 @@ ] }, "order_type": { - "$ref": "#/definitions/LimitOrderType" + "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", + "allOf": [ + { + "$ref": "#/definitions/LimitOrderType" + } + ] }, "receiver": { + "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", "type": "string" }, "tick_index_in_to_out": { + "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", "type": "integer", "format": "int64" }, "token_in": { + "description": "Token being “sold”", "type": "string" }, - "tonek_out": { + "token_out": { + "description": "Token being “bought”", "type": "string" } } @@ -187,6 +213,7 @@ "additionalProperties": false }, { + "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", "type": "object", "required": [ "withdraw_filled_limit_order" @@ -199,6 +226,7 @@ ], "properties": { "tranche_key": { + "description": "TrancheKey for the target limit order", "type": "string" } } @@ -207,6 +235,7 @@ "additionalProperties": false }, { + "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", "type": "object", "required": [ "cancel_limit_order" @@ -219,6 +248,7 @@ ], "properties": { "tranche_key": { + "description": "TrancheKey for the target limit order", "type": "string" } } @@ -227,6 +257,7 @@ "additionalProperties": false }, { + "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", "type": "object", "required": [ "multi_hop_swap" @@ -243,28 +274,34 @@ ], "properties": { "amount_in": { - "$ref": "#/definitions/Uint128" + "description": "Amount of TokenIn to swap", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] }, "exit_limit_price": { - "$ref": "#/definitions/PrecDec" + "description": "Minimum price that that must be satisfied for a route to succeed", + "allOf": [ + { + "$ref": "#/definitions/PrecDec" + } + ] }, "pick_best_route": { + "description": "If true all routes are run and the route with the best price is used", "type": "boolean" }, "receiver": { + "description": "Account to which TokenOut is credited", "type": "string" }, "routes": { + "description": "Array of possible routes", "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/definitions/MultiHopRoute" - }, - { - "type": "null" - } - ] + "$ref": "#/definitions/MultiHopRoute" } } } @@ -286,13 +323,42 @@ } }, "LimitOrderType": { - "type": "string", - "enum": [ - "GoodTillCancel", - "FillOrKill", - "ImmediateOrCancel", - "JustInTime", - "GoodTilTime" + "oneOf": [ + { + "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", + "type": "string", + "enum": [ + "GOOD_TIL_CANCELLED" + ] + }, + { + "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` (https://github.com/neutron-org/neutron/blob/main/x/dex/types/errors.go#L107 ErrGoodTilOrderWithoutExpiration).", + "type": "string", + "enum": [ + "FILL_OR_KILL" + ] + }, + { + "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", + "type": "string", + "enum": [ + "IMMEDIATE_OR_CANCEL" + ] + }, + { + "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", + "type": "string", + "enum": [ + "JUST_IN_TIME" + ] + }, + { + "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", + "type": "string", + "enum": [ + "GOOD_TIL_TIME" + ] + } ] }, "MultiHopRoute": { @@ -316,7 +382,7 @@ ], "properties": { "i": { - "$ref": "#/definitions/Uint128" + "type": "string" } } }, diff --git a/contracts/dex/schema/dex_query.json b/contracts/dex/schema/dex_query.json index b741119..61bd90c 100644 --- a/contracts/dex/schema/dex_query.json +++ b/contracts/dex/schema/dex_query.json @@ -3,6 +3,7 @@ "title": "DexQuery", "oneOf": [ { + "description": "Parameters queries the parameters of the module.", "type": "object", "required": [ "params" @@ -15,12 +16,13 @@ "additionalProperties": false }, { + "description": "Queries a LimitOrderTrancheUser by index.", "type": "object", "required": [ - "limit_order_trache_user" + "limit_order_tranche_user" ], "properties": { - "limit_order_trache_user": { + "limit_order_tranche_user": { "type": "object", "required": [ "address", @@ -39,6 +41,7 @@ "additionalProperties": false }, { + "description": "Queries a list of LimitOrderTrancheMap items.", "type": "object", "required": [ "limit_order_tranche_user_all" @@ -46,12 +49,16 @@ "properties": { "limit_order_tranche_user_all": { "type": "object", - "required": [ - "pagination" - ], "properties": { "pagination": { - "$ref": "#/definitions/PageRequest" + "anyOf": [ + { + "$ref": "#/definitions/PageRequest" + }, + { + "type": "null" + } + ] } } } @@ -59,6 +66,7 @@ "additionalProperties": false }, { + "description": "Queries a list of LimitOrderTrancheUser items for a given address.", "type": "object", "required": [ "limit_order_tranche_user_all_by_address" @@ -67,21 +75,11 @@ "limit_order_tranche_user_all_by_address": { "type": "object", "required": [ - "limit_orders" + "address" ], "properties": { - "limit_orders": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/LimitOrderTrancheUser" - }, - { - "type": "null" - } - ] - } + "address": { + "type": "string" }, "pagination": { "anyOf": [ @@ -99,6 +97,7 @@ "additionalProperties": false }, { + "description": "Queries a LimitOrderTranche by index.", "type": "object", "required": [ "limit_order_tranche" @@ -132,6 +131,7 @@ "additionalProperties": false }, { + "description": "Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination.", "type": "object", "required": [ "limit_order_tranche_all" @@ -166,6 +166,7 @@ "additionalProperties": false }, { + "description": "Queries a list of UserDeposits items.", "type": "object", "required": [ "user_deposit_all" @@ -174,12 +175,16 @@ "user_deposit_all": { "type": "object", "required": [ - "address" + "address", + "include_pool_data" ], "properties": { "address": { "type": "string" }, + "include_pool_data": { + "type": "boolean" + }, "pagination": { "anyOf": [ { @@ -196,6 +201,7 @@ "additionalProperties": false }, { + "description": "Queries a list of TickLiquidity items.", "type": "object", "required": [ "tick_liquidity_all" @@ -230,6 +236,7 @@ "additionalProperties": false }, { + "description": "Queries a InactiveLimitOrderTranche by index.", "type": "object", "required": [ "inactive_limit_order_tranche" @@ -263,6 +270,7 @@ "additionalProperties": false }, { + "description": "Queries a list of InactiveLimitOrderTranche items.", "type": "object", "required": [ "inactive_limit_order_tranche_all" @@ -287,6 +295,7 @@ "additionalProperties": false }, { + "description": "Queries a list of PoolReserves items.", "type": "object", "required": [ "pool_reserves_all" @@ -321,12 +330,13 @@ "additionalProperties": false }, { + "description": "Queries a PoolReserve by index", "type": "object", "required": [ - "pool_reverses" + "pool_reserves" ], "properties": { - "pool_reverses": { + "pool_reserves": { "type": "object", "required": [ "fee", @@ -356,6 +366,7 @@ "additionalProperties": false }, { + "description": "Queries the simulated result of a multihop swap", "type": "object", "required": [ "estimate_multi_hop_swap" @@ -364,7 +375,7 @@ "estimate_multi_hop_swap": { "type": "object", "required": [ - "amount_id", + "amount_in", "creator", "exit_limit_price", "pick_best_route", @@ -372,7 +383,7 @@ "routes" ], "properties": { - "amount_id": { + "amount_in": { "$ref": "#/definitions/Int128" }, "creator": { @@ -399,6 +410,7 @@ "additionalProperties": false }, { + "description": "Queries the simulated result of a PlaceLimit order", "type": "object", "required": [ "estimate_place_limit_order" @@ -407,6 +419,7 @@ "estimate_place_limit_order": { "type": "object", "required": [ + "amount_in", "creator", "order_type", "receiver", @@ -415,6 +428,9 @@ "token_out" ], "properties": { + "amount_in": { + "$ref": "#/definitions/Int128" + }, "creator": { "type": "string" }, @@ -443,7 +459,8 @@ "type": "string" }, "tick_index_in_to_out": { - "$ref": "#/definitions/Uint128" + "type": "integer", + "format": "int64" }, "token_in": { "type": "string" @@ -457,6 +474,7 @@ "additionalProperties": false }, { + "description": "Queries a pool by pair, tick and fee", "type": "object", "required": [ "pool" @@ -488,12 +506,13 @@ "additionalProperties": false }, { + "description": "Queries a pool by ID", "type": "object", "required": [ - "pool_by_i_d" + "pool_by_id" ], "properties": { - "pool_by_i_d": { + "pool_by_id": { "type": "object", "required": [ "pool_id" @@ -510,6 +529,7 @@ "additionalProperties": false }, { + "description": "Queries a PoolMetadata by ID", "type": "object", "required": [ "pool_metadata" @@ -532,6 +552,7 @@ "additionalProperties": false }, { + "description": "Queries a list of PoolMetadata items.", "type": "object", "required": [ "pool_metadata_all" @@ -565,54 +586,43 @@ "description": "An implementation of i128 that is using strings for JSON encoding/decoding, such that the full i128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `i128` to get the value out:\n\n``` # use cosmwasm_std::Int128; let a = Int128::from(258i128); assert_eq!(a.i128(), 258); ```", "type": "string" }, - "LimitOrderTrancheUser": { - "type": "object", - "required": [ - "address", - "order_type", - "shares_cancelled", - "shares_owned", - "shares_withdrawn", - "tick_index_taker_to_maker", - "trade_pair_id", - "tranche_key" - ], - "properties": { - "address": { - "type": "string" - }, - "order_type": { - "$ref": "#/definitions/LimitOrderType" - }, - "shares_cancelled": { - "$ref": "#/definitions/Int128" - }, - "shares_owned": { - "$ref": "#/definitions/Int128" + "LimitOrderType": { + "oneOf": [ + { + "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", + "type": "string", + "enum": [ + "GOOD_TIL_CANCELLED" + ] }, - "shares_withdrawn": { - "$ref": "#/definitions/Int128" + { + "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` (https://github.com/neutron-org/neutron/blob/main/x/dex/types/errors.go#L107 ErrGoodTilOrderWithoutExpiration).", + "type": "string", + "enum": [ + "FILL_OR_KILL" + ] }, - "tick_index_taker_to_maker": { - "type": "integer", - "format": "int64" + { + "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", + "type": "string", + "enum": [ + "IMMEDIATE_OR_CANCEL" + ] }, - "trade_pair_id": { - "$ref": "#/definitions/TradePairID" + { + "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", + "type": "string", + "enum": [ + "JUST_IN_TIME" + ] }, - "tranche_key": { - "type": "string" + { + "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", + "type": "string", + "enum": [ + "GOOD_TIL_TIME" + ] } - } - }, - "LimitOrderType": { - "type": "string", - "enum": [ - "GoodTillCancel", - "FillOrKill", - "ImmediateOrCancel", - "JustInTime", - "GoodTilTime" ] }, "MultiHopRoute": { @@ -676,28 +686,9 @@ ], "properties": { "i": { - "$ref": "#/definitions/Uint128" - } - } - }, - "TradePairID": { - "type": "object", - "required": [ - "maker_denom", - "taker_denom" - ], - "properties": { - "maker_denom": { - "type": "string" - }, - "taker_denom": { "type": "string" } } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" } } } diff --git a/contracts/dex_stargate/schema/query_msg.json b/contracts/dex_stargate/schema/query_msg.json index f82f3d5..a742b14 100644 --- a/contracts/dex_stargate/schema/query_msg.json +++ b/contracts/dex_stargate/schema/query_msg.json @@ -168,12 +168,16 @@ "all_user_deposits": { "type": "object", "required": [ - "address" + "address", + "include_pool_data" ], "properties": { "address": { "type": "string" }, + "include_pool_data": { + "type": "boolean" + }, "pagination": { "anyOf": [ { diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index fde2534..4503cba 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -36,14 +36,15 @@ use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; use neutron_sdk::interchain_queries::v045::register_queries::{ - new_register_gov_proposal_votes_query_msg, new_register_validators_signing_infos_query_msg, + new_register_gov_proposals_voters_votes_query_msg, + new_register_validators_signing_infos_query_msg, }; use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::interchain_queries::v045::{ new_register_balance_query_msg, new_register_bank_total_supply_query_msg, new_register_delegator_delegations_query_msg, new_register_delegator_unbonding_delegations_query_msg, - new_register_distribution_fee_pool_query_msg, new_register_gov_proposal_query_msg, + new_register_distribution_fee_pool_query_msg, new_register_gov_proposals_query_msg, new_register_staking_validators_query_msg, new_register_transfers_query_msg, }; use neutron_sdk::interchain_queries::v047::queries::{ @@ -51,7 +52,6 @@ use neutron_sdk::interchain_queries::v047::queries::{ query_government_proposal_votes, query_government_proposals, query_staking_validators, query_unbonding_delegations, query_validators_signing_infos, }; -use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; use prost::Message as ProstMessage; @@ -204,7 +204,7 @@ pub fn register_gov_proposal_query( proposals_ids: Vec, update_period: u64, ) -> NeutronResult> { - let msg = new_register_gov_proposal_query_msg(connection_id, proposals_ids, update_period)?; + let msg = new_register_gov_proposals_query_msg(connection_id, proposals_ids, update_period)?; Ok(Response::new().add_message(msg)) } @@ -219,7 +219,7 @@ pub fn register_gov_proposal_votes_query( deps.api .debug("WASMDEBUG: register_gov_proposal_votes_query"); - let msg = new_register_gov_proposal_votes_query_msg( + let msg = new_register_gov_proposals_voters_votes_query_msg( connection_id, proposals_ids, voters, diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 2a733cc..4e1eeda 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -52,8 +52,9 @@ use neutron_sdk::interchain_queries::v047::queries::{ ProposalVotesResponse, TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse, }; use neutron_sdk::interchain_queries::v047::types::{ - Balances, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, TallyResult, - TotalSupply, Validator, ValidatorSigningInfo, DECIMAL_PLACES, RECIPIENT_FIELD, + Balances, FeePool, GovernmentProposal, GovernmentProposalVotes, Proposal, ProposalVote, + SigningInfo, StakingValidator, TallyResult, TotalSupply, Validator, ValidatorSigningInfo, + WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; use prost::Message as ProstMessage; @@ -477,10 +478,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, Proposal { @@ -496,10 +497,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, Proposal { @@ -515,10 +516,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, ] diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index 0f6b741..466e8ef 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -497,6 +497,328 @@ } } }, + "DepositOption": { + "type": "object", + "required": [ + "disable_swap" + ], + "properties": { + "disable_swap": { + "type": "boolean" + } + } + }, + "DexMsg": { + "oneOf": [ + { + "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", + "type": "object", + "required": [ + "deposit" + ], + "properties": { + "deposit": { + "type": "object", + "required": [ + "amounts_a", + "amounts_b", + "fees", + "options", + "receiver", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "amounts_a": { + "description": "Amounts of tokenA to deposit", + "type": "array", + "items": { + "$ref": "#/definitions/Uint128" + } + }, + "amounts_b": { + "description": "Amounts of tokenB to deposit", + "type": "array", + "items": { + "$ref": "#/definitions/Uint128" + } + }, + "fees": { + "description": "Fees to use for each deposit", + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "options": { + "description": "Additional deposit options", + "type": "array", + "items": { + "$ref": "#/definitions/DepositOption" + } + }, + "receiver": { + "description": "The account to which PoolShares will be issued", + "type": "string" + }, + "tick_indexes_a_to_b": { + "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "description": "Denom for one side of the deposit", + "type": "string" + }, + "token_b": { + "description": "Denom for the opposing side of the deposit", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", + "type": "object", + "required": [ + "withdrawal" + ], + "properties": { + "withdrawal": { + "type": "object", + "required": [ + "fees", + "receiver", + "shares_to_remove", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "fees": { + "description": "Fee for the target LiquidityPools", + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "receiver": { + "description": "The account to which the tokens are credited", + "type": "string" + }, + "shares_to_remove": { + "description": "Amount of shares to remove from each pool", + "type": "array", + "items": { + "$ref": "#/definitions/Uint128" + } + }, + "tick_indexes_a_to_b": { + "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "description": "Denom for one side of the deposit", + "type": "string" + }, + "token_b": { + "description": "Denom for the opposing side of the deposit", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", + "type": "object", + "required": [ + "place_limit_order" + ], + "properties": { + "place_limit_order": { + "type": "object", + "required": [ + "amount_in", + "order_type", + "receiver", + "tick_index_in_to_out", + "token_in", + "token_out" + ], + "properties": { + "amount_in": { + "description": "Amount of TokenIn to be traded", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "expiration_time": { + "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "max_amount_out": { + "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", + "anyOf": [ + { + "$ref": "#/definitions/Uint128" + }, + { + "type": "null" + } + ] + }, + "order_type": { + "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", + "allOf": [ + { + "$ref": "#/definitions/LimitOrderType" + } + ] + }, + "receiver": { + "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", + "type": "string" + }, + "tick_index_in_to_out": { + "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", + "type": "integer", + "format": "int64" + }, + "token_in": { + "description": "Token being “sold”", + "type": "string" + }, + "token_out": { + "description": "Token being “bought”", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", + "type": "object", + "required": [ + "withdraw_filled_limit_order" + ], + "properties": { + "withdraw_filled_limit_order": { + "type": "object", + "required": [ + "tranche_key" + ], + "properties": { + "tranche_key": { + "description": "TrancheKey for the target limit order", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", + "type": "object", + "required": [ + "cancel_limit_order" + ], + "properties": { + "cancel_limit_order": { + "type": "object", + "required": [ + "tranche_key" + ], + "properties": { + "tranche_key": { + "description": "TrancheKey for the target limit order", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", + "type": "object", + "required": [ + "multi_hop_swap" + ], + "properties": { + "multi_hop_swap": { + "type": "object", + "required": [ + "amount_in", + "exit_limit_price", + "pick_best_route", + "receiver", + "routes" + ], + "properties": { + "amount_in": { + "description": "Amount of TokenIn to swap", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "exit_limit_price": { + "description": "Minimum price that that must be satisfied for a route to succeed", + "allOf": [ + { + "$ref": "#/definitions/PrecDec" + } + ] + }, + "pick_best_route": { + "description": "If true all routes are run and the route with the best price is used", + "type": "boolean" + }, + "receiver": { + "description": "Account to which TokenOut is credited", + "type": "string" + }, + "routes": { + "description": "Array of possible routes", + "type": "array", + "items": { + "$ref": "#/definitions/MultiHopRoute" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, "DistributionMsg": { "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "oneOf": [ @@ -820,6 +1142,45 @@ } } }, + "LimitOrderType": { + "oneOf": [ + { + "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", + "type": "string", + "enum": [ + "GOOD_TIL_CANCELLED" + ] + }, + { + "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` (https://github.com/neutron-org/neutron/blob/main/x/dex/types/errors.go#L107 ErrGoodTilOrderWithoutExpiration).", + "type": "string", + "enum": [ + "FILL_OR_KILL" + ] + }, + { + "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", + "type": "string", + "enum": [ + "IMMEDIATE_OR_CANCEL" + ] + }, + { + "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", + "type": "string", + "enum": [ + "JUST_IN_TIME" + ] + }, + { + "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", + "type": "string", + "enum": [ + "GOOD_TIL_TIME" + ] + } + ] + }, "MsgExecuteContract": { "description": "MsgExecuteContract defines a call to the contract execution", "type": "object", @@ -838,6 +1199,20 @@ } } }, + "MultiHopRoute": { + "type": "object", + "required": [ + "hops" + ], + "properties": { + "hops": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "NeutronMsg": { "description": "A number of Custom messages that can call into the Neutron bindings.", "oneOf": [ @@ -1434,6 +1809,19 @@ } }, "additionalProperties": false + }, + { + "description": "Dex messages", + "type": "object", + "required": [ + "dex" + ], + "properties": { + "dex": { + "$ref": "#/definitions/DexMsg" + } + }, + "additionalProperties": false } ] }, @@ -1539,6 +1927,17 @@ } } }, + "PrecDec": { + "type": "object", + "required": [ + "i" + ], + "properties": { + "i": { + "type": "string" + } + } + }, "ProposalExecuteMessage": { "description": "ProposalExecuteMessage defines the struct for sdk47 compatible admin proposal.", "type": "object",