# Actions

#### CREATEMARKET

Creates a new market for the token pair.

This action is triggered by admin to create the market pair.

* **authority**: `admin`
* **requirements**: none

**args**

* `{extended_symbol} bid_token`: extended symbol of the buy token to create token pair
* `{extended_asset} ask_token`: extended asset of the sell token to create token pair
* `{uint16_t} order_min`: min order to place
* `{uint8_t} status_code`: status code of the market pair
* `{uint64_t} ask_oracle_index`: index of the oracle to get price of token from feed

**example**

```
{
  "account": "metalpay",
  "name": "createmarket",
  "data": {
    "bid_token": {
      "quantity": "4.0000 XPR",
      "contract": "eosio.token"
    },
    "ask_token": {
      "sym": "4.0000 XMT",
      "contract": "xtokens"
    },
    "order_min": "10",
    "status_code": "1",
    "ask_oracle_index": "1"
  }
}
```

#### UPDATEMARKET

Update an exisitng market for status change or min order.

* **authority**: `admin`
* **requirements**: market id should be existed for an update&#x20;

**args**

* `{uint16_t} market_id`: id of the token pair to update
* `{uint64_t} order_min`: min order to place
* `{uint8_t} status_code`: status code of the market
* `{uint64_t} ask_oracle_index`: index of the oracle to get price of token from feed

**example**

```
{
  "account": "admin",
  "name": "updatemarket",
  "data": {
    "market_id": "2",
    "order_min": "10",
    "status_code": "3",
    "ask_oracle_index": "2",
  }
}
```

#### PLACEORDER

Creates a new order and place it into orderq or sltp table.

This action is triggered by any user who has sufficient funds to trade token pairs.

* **authority**: `user`
* **requirements**: none

**args**

* `{uint16_t} market_id`: id of the token pair
* `{name} account`: name of the account holder who would like to buy/sell
* `{uint8_t} order_type`: type of order, LIMIT(1), STOPLOSS(2) or TAKEPROFIT(3)
* `{uint8_t} order_side`: indicates order side is BUY(1)/SELL(2)
* `{uint64_t} quantity`: quantity to be traded
* `{uint64_t} price`: quoted price by the user
* `{extended_symbol} bid_symbol`: extended symbol of the buy token from the market id(token pair)
* `{extended_symbol} ask_symbol`: extended symbol of the ask token from the market id(token pair)
* `optional{uint64_t} trigger_price`: price at which order triggered from sltp to orderq, used for stoploss and takeprofit orders
* `optional{uint8_t} fill_type`: fill type of the order, options are GTC(Good Till Expiry) EXPIRY), IOC(Immediate Or Cancel) and POST\_ONLY(a limit order placed by a user will never match with any orders already on the book)
* `{name} referrer`: name of the referrer account(the referrer would get a share in fees)

**example**

```
{
  "account": "trader",
  "name": "placeorder",
  data: {
    "market_id": 1,
    "account": "trader",
    "order_type": 1,
    "order_side": 2,
    "quantity": 100000000,
    "price": 1,
    "bid_symbol": {
        "sym": "8,XETH",
        "contract": "eosio.token"
    },
    "ask_symbol": {
        "sym": "4,XMT",
        "contract": "eosio.token"
    },
    "trigger_price": 0,
    "fill_type": 1
  }
}
```

#### PROCESS

This action is used to process the orders in the orderQ. It does apply to all orders irrespective of market-id's.

* **authority**: user
* **requirements**: none

**args**

* `{uint16_t} size`: size of the orders to process

**example**

```
{
  "account": "user",
  "name": "process",
  "data": {
    "size": "50"
  }
}
```

#### PROCESSSLTP

This action is used to process the stoploss and takeprofit orders in the orderQ.&#x20;

* **authority**: user
* **requirements**: none

**args**

* `{uint16_t} market_id`: process orders for specific market
* `{uint16_t} size`: size(number) of the orders to process

**example**

```
{
  "account": "user",
  "name": "processsltp",
  "data": {
    "market_id": "2",
    "size": "20"
  }
}
```

#### CANCELORDER

This action is used to cancel orders that are queued in stoploss or orderq or orderbook.&#x20;

* **authority**: user
* **requirements**: none

**args**

* `{name} account`: name of the account that order belongs to
* `{uint64_t} order_id`: id of the order

**example**

```
{
  "account": "user",
  "name": "cancelorder",
  "data": {
    "account": "alice",
    "order_id": "23"
  }
}
```

#### PAUSEDEX

This action is used to pause and resume all activities/actions on DEX.&#x20;

* **authority**: `admin`
* **requirements**: none

**args**

* `{bool} status`: status to be updated

**example**

```
{
  "account": "admin",
  "name": "pausedex",
  "data": {
    "status": "true"
  }
}
```

#### SETFEEACNT

All fees collected through DEX trading would be deposited into fee account. The fee account can be updated by admin.

* **authority**: `admin`
* **requirements**: none

**args**

* `{name} account`: fee account to be updated

**example**

```
{
  "account": "admin",
  "name": "setfeeacnt",
  "data": {
    "account": "bob"
  }
}
```

#### SETUSERTIER

Both maker and taker fees collected based on user acitivitiy on DEX. User tier would be calculated based on 30d average colume and it can be assigned through action by admin.

* **authority**: `admin`
* **requirements**: none

**args**

* `{name} account`: fee account to be updated
* `{uint8_t} tier`: tier value

**example**

```
{
  "account": "admin",
  "name": "setusertier",
  "data": {
    "account": "alice",
    "tier": "2"
  }
}
```
