Skip to content

Commit

Permalink
chore: regen core docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Nov 4, 2024
1 parent 37db549 commit 1e4af87
Show file tree
Hide file tree
Showing 46 changed files with 1,075 additions and 968 deletions.
14 changes: 0 additions & 14 deletions .gitbook/developers/modules/core/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions .gitbook/developers/modules/core/genutils.md

This file was deleted.

8 changes: 4 additions & 4 deletions .gitbook/developers/modules/injective/auction/02_messages.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
sidebar_position: 2
title: Messages
title: Messages
---

# Messages

In this section, we describe the processing of the auction messages and the corresponding updates to the state.
In this section we describe the processing of the auction messages and the corresponding updates to the state.

## Msg/Bid

Expand All @@ -26,7 +26,7 @@ message MsgBid {

This service message is expected to fail if:

* `Round` does not equal the current auction round
* `BidAmount` does not exceed the previous highest bid amount by at least `min_next_increment_rate` percent.
- `Round` does not equal the current auction round
- `BidAmount` does not exceed the previous highest bid amount by at least `min_next_increment_rate` percent.

This service message transfers the `BidAmount` of INJ from the `Sender` to the auction module, stores the bid, and refunds the last bidder's bid amount.
22 changes: 11 additions & 11 deletions .gitbook/developers/modules/injective/auction/03_end_block.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
sidebar_position: 3
title: End-Block
title: End-Block
---

# EndBlock
# End-Block

### Auction Settlement

The settlement of a given auction round occurs when `blockTime ≥ EndingTimeStamp.` If a non-zero INJ bid was placed during this period (i.e., there exists a `LastBid`), the following procedure will take place:
The settlement of a given auction round occurs when `blockTime ≥ EndingTimeStamp.` If a non-zero INJ bid was placed during this period (i.e. there exists a `LastBid`), the following procedure will take place:

* The winning INJ bid amount is burned.
* The basket of coins held by the auction module is transferred to the winning bidder.
* `LastAuctionResult` is written to state and `EventAuctionResult` is emitted.
* The `LastBid` is cleared.
* The AuctionRound is incremented by 1 and the EndingTimestamp is incremented by `AuctionPeriod`.
* The accumulated exchange fees are transferred from the `exchange` module to the `auction` module for the new upcoming auction.
- The winning INJ bid amount is burned.
- The basket of coins held by the auction module is transferred to the winning bidder.
- `LastAuctionResult` is written to state and `EventAuctionResult` is emitted.
- The `LastBid` is cleared.
- The AuctionRound is incremented by 1 and the EndingTimestamp is incremented by `AuctionPeriod`.
- The accumulated exchange fees are transferred from the `exchange` module to the `auction` module for the new upcoming auction.

If the round closed without any successful bids, the existing coin basket will be rolled over into the next auction and combined with the new accumulated fee basket.
If the round closed without any successful bids, the existing coin basket will be rolled over into the next auction and combined with the new accumulated fee basket.

![img.png](img.png)
![img.png](./img.png)
16 changes: 9 additions & 7 deletions .gitbook/developers/modules/injective/auction/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Auction
# `Auction`

## Abstract

The `auction` module periodically obtains a basket of tokens accumulated from trading fees from the `exchange` module and auctions the basket to the highest bidder in an open English auction for INJ. The winner of this auction receives the basket of tokens, and the winning INJ bid amount from this auction is burned.
The `auction` module periodically obtains a basket of tokens accumulated from trading fees from the `exchange` module and auctions the basket to the highest bidder in an open English auction for INJ. The winner of this auction receives the basket of tokens and the winning INJ bid amount from this auction is burned.

## Contents

1. [**State**](01_state.md)
2. [**Messages**](02_messages.md)
3. [**End Block**](03_end_block.md)
4. [**Events**](04_events.md)
5. [**Params**](05_params.md)
1. **[State](./01_state.md)**
2. **[Messages](./02_messages.md)**
3. **[End Block](./03_end_block.md)**
4. **[Events](./04_events.md)**
5. **[Params](./05_params.md)**


Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,79 @@ sidebar_position: 2
title: Spot Market Concepts
---

# Spot Markets Concepts
# Spot Market Concepts

## Definitions

In a Spot Market with ticker **AAA/BBB, AAA is the base asset, BBB is the quote asset.**

For example, in the ETH/USDT market

* ETH is base asset
* USDT is the quote asset
- ETH is base asset
- USDT is the quote asset

The spot market's **price** refers to how much USDT (the quote asset) is required for one unit of ETH (the base asset). For all spot markets, **fees are always paid in the quote asset**, e.g., USDT.
The spot market's **price** refers to how much USDT (the quote asset) is required for one unit of ETH (the base
asset). For all spot markets, **fees are always paid in the quote asset**, e.g., USDT.

**Debit vs. Credit**
**Debit vs Credit**

* **Debit Amount** refers to the amount of asset that is withdrawn from an account.
* **Credit Amount** refers to the amount of asset that is deposited to an account.
- **Debit Amount** refers to the amount of asset that is withdrawn from an account.
- **Credit Amount** refers to the amount of asset that is deposited to an account.

**Refunds**

In our system, a refund refers to the action of incrementing the **available balance** of an account. This liberation of funds occurs as the result of an encumbrance being lifted from the account (e.g. cancelling a limit order, reducing an order's payable fee to a maker fee, using less margin to fund a market order, etc.).
In our system, a refund refers to the action of incrementing the **available balance** of an account. This liberation of
funds occurs as the result of an encumbrance being lifted from the account (e.g. cancelling a limit order, reducing an
order's payable fee to a maker fee, using less margin to fund a market order, etc.).

### Limit Buy Order

A limit buy order seeks to buy a specified `Quantity` ETH (**base asset**) in exchange for `Quantity * Price` amount of USDT (**quote asset**) **plus fees,** which depend on whether the limit order becomes executed as a maker order or a taker order.
A limit buy order seeks to buy a specified `Quantity` ETH (**base asset**) in exchange for `Quantity * Price` amount of
USDT (**quote asset**) **plus fees** which depend on whether the limit order becomes executed as a maker order or a
taker order.

### Limit Sell Order

A limit sell order seeks to sell a specified `Quantity` ETH (**base asset**) in exchange for `Quantity * Price` amount of USDT (**quote asset**) **minus fees,** which depend on whether the limit order becomes executed as a maker order or a taker order.
A limit sell order seeks to sell a specified `Quantity` ETH (**base asset**) in exchange for `Quantity * Price` amount
of USDT (**quote asset**) **minus fees** which depend on whether the limit order becomes executed as a maker order or a
taker order.

### Market Buy Order

A market buy order seeks to buy a specified `Quantity` ETH (**base asset**) at a specified worst price which is at or near the current ask using the respective account quote asset balance (USDT) as collateral\*\* (inclusive of fees).
A market buy order seeks to buy a specified `Quantity` ETH (**base asset**) at a specified worst price which is at or near
the current ask using the respective account quote asset balance (USDT) as collateral\*\* (inclusive of fees).

As a result, each market buy order implicitly has a maximum acceptable price associated with it, as filling the market order beyond that price would simply fail due to a lack of funds.
As a result, each market buy order implicitly has a maximum acceptable price associated with it, as filling the market
order beyond that price would simply fail due to a lack of funds.

### Market Sell Order

A market sell order seeks to sell a specified `Quantity` ETH (**base asset**) at a specified worst price which is at or near the current bid in exchange for any amount of the quote asset (USDT) available in the market.
A market sell order seeks to sell a specified `Quantity` ETH (**base asset**) at a specified worst price which is at or
near the current bid in exchange for any amount of the quote asset (USDT) available in the market.

As a result, each market sell order implicitly has a zero price associated with it.

### Order Types

* BUY (1): A standard buy order to purchase an asset at either the current market price or a set limit price.
* SELL (2): A standard sell order to sell an asset at either the current market price or a set limit price.
* STOP_BUY (3): This order type is not supported for spot markets.
* STOP_SELL (4): This order type is not supported for spot markets.
* TAKE_BUY (5): This order type is not supported for spot markets.
* TAKE_SELL (6): This order type is not supported for spot markets.
* BUY_PO (7): Post-Only Buy. This order type ensures that the order will only be added to the order book and not match with a pre-existing order. It guarantees that you will be the market "maker" and not the "taker".
* SELL_PO (8): Post-Only Sell. Similar to BUY_PO, this ensures that your sell order will only add liquidity to the order book and not match with a pre-existing order.
* BUY_ATOMIC (9): An atomic buy order is a market order that gets executed instantly, bypassing the Frequent Batch Auctions (FBA). It's intended for smart contracts that need to execute a trade instantly. A higher fee is paid, defined in the global exchange parameters.
* SELL_ATOMIC (10): An atomic sell order is similar to a BUY_ATOMIC, and it gets executed instantly at the current market price, bypassing the FBA.
- BUY (1): A standard buy order to purchase an asset at either the current market price or a set limit price.
- SELL (2): A standard sell order to sell an asset at either the current market price or a set limit price.
- STOP_BUY (3): This order type is not supported for spot markets.
- STOP_SELL (4): This order type is not supported for spot markets.
- TAKE_BUY (5): This order type is not supported for spot markets.
- TAKE_SELL (6): This order type is not supported for spot markets.
- BUY_PO (7): Post-Only Buy. This order type ensures that the order will only be added to the order book and not match with a pre-existing order. It guarantees that you will be the market "maker" and not the "taker".
- SELL_PO (8): Post-Only Sell. Similar to BUY_PO, this ensures that your sell order will only add liquidity to the order book and not match with a pre-existing order.
- BUY_ATOMIC (9): An atomic buy order is a market order that gets executed instantly, bypassing the Frequent Batch Auctions (FBA). It's intended for smart contracts that need to execute a trade instantly. A higher fee is paid defined in the global exchange parameters.
- SELL_ATOMIC (10): An atomic sell order is similar to a BUY_ATOMIC, and it gets executed instantly at the current market price, bypassing the FBA.

### Market Data Requirements

Orderbook data aside, so long as our Chain supports the **base capability** to obtain Tick by Tick trading data, aggregations can be applied to obtain most of the necessary higher order data, including
Orderbook data aside, so long as our Chain supports the **base capability** to obtain Tick by Tick trading data,
aggregations can be applied to obtain most of the necessary higher order data, including

* OHLCV data
* Account Trading History
* Market Statistics
- OHLCV data
- Account Trading History
- Market Statistics

## Spot Market Lifecycle

Expand All @@ -74,9 +85,10 @@ A market is first created either by the instant launch functionality through `Ms

### Listing Fee based Spot Market Creation

Allow anyone to create an active spot market of their choice without requiring governance approval by burning a pre-set SpotMarketInstantListingFee of INJ.
Allow anyone to create an active spot market of their choice without requiring governance approval by burning a pre-set
SpotMarketInstantListingFee of INJ.

We should still check that the denom is valid, though.
We should still check that the denom is valid though.

### Spot Market Status Update

Expand All @@ -89,15 +101,17 @@ A Spot Market can exist in four different states:

#### **Active State**

If a spot market is in an active state, it can accept orders and trades.
If a spot market is an active state, it can accept orders and trades.

#### Paused State

If a spot market is in a paused state, it will no longer accept orders and trades and will also not allow any users to take actions on that market (no order cancellations).
If a spot market is a paused state, it will no longer accept orders and trades and will also not allow any users to take
actions on that market (no order cancellations).

#### Suspended State

If a spot market is in a suspended state, it will no longer accept orders and trades, and will only allow traders to cancel their orders.
If a spot market is a suspended state, it will no longer accept orders and trades, and will only allow traders to cancel
their orders.

## Demolished State

Expand All @@ -107,15 +121,15 @@ When a market becomes demolished, all outstanding orders are cancelled.

There are three state transitions that correspond to the following status changes

* Activate Action - **Paused or Suspended Status → Active Status**
* Pause Action - **Active or Suspended Status → Paused Status**
* Suspend Action - **Active or Paused Status → Suspended Status**
* Demolish Action - **Paused or Suspended Status → Demolished Status**
- Activate Action - **Paused or Suspended Status → Active Status**
- Pause Action - **Active or Suspended Status → Paused Status**
- Suspend Action - **Active or Paused Status → Suspended Status**
- Demolish Action - **Paused or Suspended Status → Demolished Status**

### Spot Market Parameter Update

The following parameters exist for Spot Markets

* SpotMarketInstantListingFee
* DefaultSpotMakerFeeRate
* DefaultSpotTakerFeeRate
- SpotMarketInstantListingFee
- DefaultSpotMakerFeeRate
- DefaultSpotTakerFeeRate
Loading

0 comments on commit 1e4af87

Please sign in to comment.