github.com/gravity-devs/liquidity@v1.5.3/x/liquidity/spec/04_messages.md (about)

     1  <!-- order: 4 -->
     2  
     3   # Messages
     4  
     5  Messages (Msg) are objects that trigger state transitions. Msgs are wrapped in transactions (Txs) that clients submit to the network. The Cosmos SDK wraps and unwraps liquidity module messages from transactions.
     6  
     7  ## MsgCreatePool
     8  
     9  A liquidity pool is created and initial coins are deposited with the `MsgCreatePool` message.
    10  
    11  ```go
    12  type MsgCreatePool struct {
    13      PoolCreatorAddress  string         // account address of the origin of this message
    14      PoolTypeId          uint32         // id of the new liquidity pool
    15      DepositCoins         sdk.Coins      // deposit initial coins for new liquidity pool
    16  }
    17  ```
    18  
    19  ### Validity Checks
    20  
    21  Validity checks are performed for MsgCreatePool messages. The transaction that is triggered with `MsgCreatePool` fails if:
    22  
    23  - if `params.CircuitBreakerEnabled` is true
    24  - `PoolCreator` address does not exist
    25  - `PoolTypeId` does not exist in parameters
    26  - A duplicate `LiquidityPool` with same `PoolTypeId` and `ReserveCoinDenoms` exists
    27  - One or more coins in `ReserveCoinDenoms` do not exist in `bank` module
    28  - The balance of `PoolCreator` does not have enough amount of coins for `DepositCoins`
    29  - The balance of `PoolCreator` does not have enough coins for `PoolCreationFee`
    30  
    31  ## MsgDepositWithinBatch
    32  
    33  Coins are deposited in a batch to a liquidity pool with the `MsgDepositWithinBatch` message.
    34  
    35  ```go
    36  type MsgDepositWithinBatch struct {
    37      DepositorAddress    string         // account address of depositor that originated this message
    38      PoolId              uint64         // id of the liquidity pool to receive deposit
    39      DepositCoins         sdk.Coins      // deposit coins
    40  }
    41  ```
    42  
    43  ## Validity Checks
    44  
    45  The MsgDepositWithinBatch message performs validity checks. The transaction that is triggered with the `MsgDepositWithinBatch` message fails if:
    46  
    47  - if `params.CircuitBreakerEnabled` is true
    48  - `Depositor` address does not exist
    49  - `PoolId` does not exist
    50  - The denoms of `DepositCoins` are not composed of existing `ReserveCoinDenoms` of the specified `LiquidityPool`
    51  - The balance of `Depositor` does not have enough coins for `DepositCoins`
    52  
    53  ## MsgWithdrawWithinBatch
    54  
    55  Withdraw coins in batch from liquidity pool with the `MsgWithdrawWithinBatch` message.
    56  
    57  ```go
    58  type MsgWithdrawWithinBatch struct {
    59      WithdrawerAddress string         // account address of the origin of this message
    60      PoolId            uint64         // id of the liquidity pool to withdraw the coins from
    61      PoolCoin          sdk.Coin       // pool coin sent for reserve coin withdrawal
    62  }
    63  ```
    64  
    65  ## Validity Checks
    66  
    67  The MsgWithdrawWithinBatch message performs validity checks. The transaction that is triggered with the `MsgWithdrawWithinBatch` message fails if:
    68  
    69  - `Withdrawer` address does not exist
    70  - `PoolId` does not exist
    71  - The denom of `PoolCoin` are not equal to the `PoolCoinDenom` of the `LiquidityPool`
    72  - The balance of `Depositor` does not have enough coins for `PoolCoin`
    73  
    74  ## MsgSwapWithinBatch
    75  
    76  Swap coins between liquidity pools in batch with the `MsgSwapWithinBatch` message.
    77  
    78  Offer coins are swapped with demand coins for the given order price.
    79  
    80  ```go
    81  type MsgSwapWithinBatch struct {
    82      SwapRequesterAddress string     // account address of the origin of this message
    83      PoolId               uint64     // id of the liquidity pool
    84      SwapTypeId           uint32     // swap type id of this swap message, default 1: InstantSwap, requesting instant swap
    85      OfferCoin            sdk.Coin   // offer coin of this swap
    86      DemandCoinDenom      string     // denom of demand coin of this swap
    87      OfferCoinFee         sdk.Coin   // offer coin fee for pay fees in half offer coin
    88      OrderPrice           sdk.Dec    // limit order price where the price is the exchange ratio of X/Y where X is the amount of the first coin and Y is the amount of the second coin when their denoms are sorted alphabetically
    89  }
    90  ```
    91  
    92  ## Validity checks
    93  
    94  The MsgSwapWithinBatch message performs validity checks. The transaction that is triggered with the `MsgSwapWithinBatch` message fails if:
    95  
    96  - if `params.CircuitBreakerEnabled` is true
    97  - `SwapRequester` address does not exist
    98  - `PoolId` does not exist
    99  - `SwapTypeId` does not exist
   100  - Denoms of `OfferCoin` or `DemandCoin` do not exist in `bank` module
   101  - The balance of `SwapRequester` does not have enough coins for `OfferCoin`
   102  - `OrderPrice` <= zero
   103  - `OfferCoinFee` equals `OfferCoin` * `params.SwapFeeRate` * `0.5` with ceiling
   104  - Has sufficient balance `OfferCoinFee` to reserve offer coin fee