neutron_sdk/bindings/dex/
msg.rs

1use crate::bindings::dex::types::LimitOrderType;
2use cosmwasm_std::Uint128;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use super::types::{DepositOption, MultiHopRoute, PrecDec};
7
8#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
9#[serde(rename_all = "snake_case")]
10pub enum DexMsg {
11    /// Deposit provides liquidity to a specific trading pair by depositing tokens
12    /// at a specific price into one or both sides of the pair in “a liquidity pool”
13    Deposit {
14        /// The account to which PoolShares will be issued
15        receiver: String,
16        /// Denom for one side of the deposit
17        token_a: String,
18        /// Denom for the opposing side of the deposit
19        token_b: String,
20        /// Amounts of tokenA to deposit
21        amounts_a: Vec<Uint128>,
22        /// Amounts of tokenB to deposit
23        amounts_b: Vec<Uint128>,
24        /// Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)
25        tick_indexes_a_to_b: Vec<i64>,
26        /// Fees to use for each deposit
27        fees: Vec<u64>,
28        /// Additional deposit options
29        options: Vec<DepositOption>,
30    },
31    /// Withdraw is used to redeem PoolShares for the user’s pro-rata
32    /// portion of tokens within a liquidity pool. Users can withdraw from a pool at any time
33    Withdrawal {
34        /// The account to which the tokens are credited
35        receiver: String,
36        /// Denom for one side of the deposit
37        token_a: String,
38        /// Denom for the opposing side of the deposit
39        token_b: String,
40        /// Amount of shares to remove from each pool
41        shares_to_remove: Vec<Uint128>,
42        /// Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB
43        /// (ie. TokenA is on the left)
44        tick_indexes_a_to_b: Vec<i64>,
45        /// Fee for the target LiquidityPools
46        fees: Vec<u64>,
47    },
48    /// PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit
49    /// orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to
50    /// trade against preexisting liquidity (“Taker Limit Orders”)
51    PlaceLimitOrder {
52        /// Account to which TokenOut is credited or that will be allowed to
53        /// withdraw or cancel a maker order
54        receiver: String,
55        /// Token being “sold”
56        token_in: String,
57        /// Token being “bought”
58        token_out: String,
59        /// Limit tick for a limit order, specified in terms of TokenIn to TokenOut
60        tick_index_in_to_out: i64,
61        /// Amount of TokenIn to be traded
62        amount_in: Uint128,
63        /// Type of limit order to be used. Must be one of:
64        /// GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME
65        order_type: LimitOrderType,
66        // expirationTime is only valid if orderType == GOOD_TIL_TIME.
67        /// Expiration time for order. Only valid for GOOD_TIL_TIME limit orders
68        expiration_time: Option<u64>,
69        /// Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType
70        max_amount_out: Option<Uint128>,
71        /// Accepts standard decimals and decimals with scientific notation (ie. 1234.23E-7)
72        limit_sell_price: String,
73    },
74    /// WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in
75    /// its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits
76    /// all available proceeds to the user. Withdraw can be called on a limit order multiple
77    /// times as new proceeds become available
78    WithdrawFilledLimitOrder {
79        /// TrancheKey for the target limit order
80        tranche_key: String,
81    },
82    /// CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time)
83    /// can be canceled at any time if they have not been completely filled
84    CancelLimitOrder {
85        /// TrancheKey for the target limit order
86        tranche_key: String,
87    },
88    /// MultiHopSwap provides a swapping mechanism to achieve better prices by routing
89    /// through a series of pools
90    MultiHopSwap {
91        /// Account to which TokenOut is credited
92        receiver: String,
93        /// Array of possible routes
94        routes: Vec<MultiHopRoute>,
95        /// Amount of TokenIn to swap
96        amount_in: Uint128,
97        /// Minimum price that that must be satisfied for a route to succeed
98        exit_limit_price: PrecDec,
99        /// If true all routes are run and the route with the best price is used
100        pick_best_route: bool,
101    },
102}